akhauriyash/Code-Regression huggingface dataset:
from itertools import permutations
n,m = map(int,input().split())
G = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)
ans = 0
for p in permutations(range(1,n)):
    now = 0
    for nxt in p:
        if nxt not in G[now]: break
        now = nxt
    else:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
typedef long long ll;
using namespace std;

int N;

ll dfs(ll a, ll b, ll c, ll n){
  if(n > N) return 0;
  ll res = 0;
  if(a > 0 && b > 0 && c > 0) res = 1;
  res += dfs(a + 1, b, c, 10 * n + 3);
  res += dfs(a, b + 1, c, 10 * n + 5);
  res += dfs(a, b, c + 1, 10 * n + 7);
  return res;
}

int main(){
  cin >> N;
  cout << dfs(0,0,0,0) << endl;
  
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    int arr[M] = {};
    for(int i = 0; i < N; i++) {
        int K;
        cin >> K;
        for(int j = 0; j < K; j++) {
            int A;
            cin >> A;
            A--;
            arr[A]++;
        }
    }
    int ans = 0;
    for(int i = 0; i < M; i++)
        if(arr[i] == N) ans++;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;
int n;
int a[maxn], b[maxn];
char s[maxn];
int main()
{
	scanf("%d%s", &n, s + 1);
	for(int i = 1; i <= n; ++i) a[i] = s[i] == 'W' ? 1 : 0;
	for(int i = 1; i <= n; ++i) b[i] = b[i - 1] + a[i];
	int ans = n;
	for(int i = 0; i <= n; ++i) ans = min(ans, max(b[i], n - i - (b[n] - b[i])));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5452
import math
a, b, C = map(int, raw_input().split())
S = (a * b * math.sin(math.radians(C))) / 2
c = math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(C)))
L = a + b + c
h = (S * 2) / a
print("%f" % (S, ))
print("%f" % (L, ))
print("%f" % (h, ))

Measured memory_bytes: 4424
n, x = (int(x) for x in input().split())

f = [0] * (n+1)
g = [0] * (n+1)
f[0] = 1
g[0] = 1
for i in range(1, n+1):
    f[i] = f[i-1]* 2 + 3
    g[i] = g[i-1]* 2 + 1

total = 0
remain = x

def eat(n):

    global total
    global f
    global remain

    if remain == 0:
        return
    if n < 0:
        return
    if f[n] <= remain:
        total += g[n]
        remain -= f[n]
        return
    if f[n] > remain:
        remain -=1
        if remain == 0:
            return
        if f[n-1] > remain:
            eat(n-1)
        else:
            total += g[n-1]
            remain -= f[n-1]
            if remain == 0:
                return
            total += 1
            remain -= 1
            eat(n-1)

eat(n)
print(total)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<numeric>
#include<set>
#include<map>
#include<list>
#include<valarray>
#define ll long long 
#define d double
using namespace std;


int main()
{
	ll w;
	cin >> w;
	string x,z="";
	cin >> x;
	for (int i = 0; i < x.length(); i++)
	{
		if (i < w)
		{
			z += x[i];
		}
	}
	if(x.length()==z.length())
	cout << z << endl;
	else
	{
		z += "...";
		cout << z << endl;
	}

}


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


int main()
{
	int k;  cin>>k;
	int a,b;  cin>>a>>b;
	int i;
	
	i=(b/k)*k;
 
	  if((a<=i))  {
		  	  cout<<"OK"<<endl;
		  }
		  else{
		  cout<<"NG"<<endl;
         }
 
}



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

int main() {
	string s; cin >> s;
	string dir[]{ "dream","eraser","erase","dreamer" };
	int d = 0;
	queue<string>que;
	que.push("");
	while (!que.empty()) {
		string v = que.front(); que.pop();
		if (v.size() == s.size() && v == s) {
			puts("YES"); return 0;
		}
		rep(i, 4) {
			if (v.size() + dir[i].size() <= s.size() && s.substr(v.size(), dir[i].size()) == dir[i])
				que.push(v + dir[i]);
		}
	}
	puts("NO");
}

Measured memory_bytes: 1264
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int cost[maxn][3];
int dp[maxn][3];
 int n;

void solve()
{
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= 3; j++){
             int mx = 0;
            for(int k = 1; k <= 3; k++){
                if(k != j){
                    mx = max(mx, dp[i-1][k] + cost[i][j]);
                   // cout << mx << " ---- ";
                }
            }
            //cout << endl;
            dp[i][j] = mx;
        }
    }
}

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= 3; j++){
            cin >> cost[i][j];
        }
    }
    solve();
    cout << max(dp[n][1], max(dp[n][2], dp[n][3]))<<endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define hi cout<<'h'<<'i'<<'\n' 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define all(v) v.B,v.E
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 200005
//<<fixed << setprecision(9)
 
vi G[space];
int main()
{
    int n,i,j,t;
    boost;
    int m;
    cin>>n;
    rep(i,2,n+1)
    {
        cin>>j;
        G[j].pb(i);
    }
 
    rep(i,1,n+1)cout<<G[i].size()<<'\n';
    return 0;
}

Measured memory_bytes: 14592
#include <stdio.h>

void trace(int A[], int N) {
  int i;
  for ( i = 0; i < N; i++ ) {
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

void insertionSort(int A[], int N) {
  int j, i, v;
  for ( i = 1; i < N; i++ ) {
    v = A[i];
    j = i - 1;
    while ( j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    trace(A, N);
  }
}

int main() {
  int N, i, j;
  int A[100];

  scanf("%d", &N);
  for ( i = 0; i < N; i++ ) scanf("%d", &A[i]);

  trace(A, N);
  insertionSort(A, N);

  return 0;
}

Measured memory_bytes: 2740
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <cstring>
#include <string.h>
#include <sstream>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MOD = 1e9+7;
const ll CFMOD = 998244353;
const double PI  = 3.14159265358;
const double EPS = 1e-6;
 
#define INT_MX 2147483647
#define INF ((int)1e9)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define siz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define PB push_back
#define PF push_front
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define vec vector
#define __ <<' '<<
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

void solve(){
    int n, m;
    string s;
    
    cin >> n >> m >> s;
    
    ll ans = 0;
    if(m == 2 || m == 5){
        rep(i, n)
            if((s[i] - '0') % m == 0)
                ans += i + 1;
        cout << ans << '\n';
        return ;
    }
    
    reverse(ALL(s));
    int k = 1;
    vec<int> v(n+1), cnt(m);
    
    rep1(i, n){
        v[i] = ((s[i-1] - '0') * k + v[i-1]) % m;
        k = k * 10 % m;
    }
    
    for(auto i:v){
        ans += cnt[i];
        cnt[i]++;
    }
    
    cout << ans << '\n';
}

int main() {
    int T = 1;
    
    //cin >> T;
    while(T--){
        solve();
    }
}


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

#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for(int i = 0; i < (n); i++)

int main()
{
   int N, K;
   cin >> N >> K;
   vector<int> L;
   REP(i, N) 
   {
      int tmp;
      cin >> tmp;
      L.push_back(tmp);
   }
   sort(ALL(L), greater<int>());
   int ans;
   REP(i, K) ans += L[i];
   cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<complex>
#include<cstdio>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}

void solve(){
	int n;
	cin>>n;
	ll mini=1e18,maxi=-1e18;
	ll mini1=1e18,maxi1=-1e18;
	for(int i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		mini=min(mini,x+y);
		maxi=max(maxi,x+y);
		mini1=min(mini1,x-y);
		maxi1=max(maxi1,x-y);
	}
	cout<<max(maxi-mini,maxi1-mini1)<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}


Measured memory_bytes: 3624
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) x.begin(), x.end()

#define mp make_pair
#define in insert
#define er erase
#define con continue
#define pb push_back
#define sc scanf
#define pr printf
#define ub upper_bound
#define lb lower_bound
#define s second
#define f first
#define int long long

const long long infl = 1e18; 
const int N = 3e5 + 300, N2 = 2e3, inf = 1e18 + 200;

set <int> S;
vector <int> g[N], gr[N];
int n, m, k, p;
int a[N];
int d[N], us[N], us2[N];
string ss;

void dfs1(int v){
	us[v] = 1;
	for (auto to: g[v]){
		if (!us[to]){
			dfs1(to);
		}
	}
}

void dfs2(int v){
	us2[v] = 1;
	for (auto to: gr[v]){
		if (!us2[to]){
			dfs2(to);
		}
	}
}

main (){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m >> p;
	vector <pair <pair <int,int> , int> > v; 
	for (int i = 0; i < m; i++){
		int x, y, z;
		cin >> x >> y >> z;
		g[x].pb(y);
		gr[y].pb(x);
		v.pb({{x, y}, z - p});
	}
	dfs1(1);
	dfs2(n);
	d[1] = 0;
	for (int i = 2; i <= n; i++){
		d[i] = -inf;
	}
	/*sort(all(v));
	reverse(all(v));*/
	int mx = 0;
	for (int i = 1; i <= 2*n + 1; i++){
		//random_shuffle(all(v));
		int ok = 0;
		for (int j = 0; j < m; j++){
			int x = v[j].f.f, y = v[j].f.s, z = v[j].s;
			if (d[x] == -inf || !us[x] || !us2[x] || !us[y] || !us2[y]) con;
			if (d[y] < d[x] + z && d[x] + z < inf){
				d[y] = d[x] + z;
				ok = 1;
			}
		}	
		if (ok == 0) break;
		if (ok == 1 && i >= n){
			cout << -1;
			return 0;
		}
	}
	cout << max(d[n], 0ll);
	return 0;
}












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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll Pow(ll A, ll N){
  if (N == 0) return 1;
  if (N % 2 == 0) return Pow(A * A % MOD, N / 2);
  return Pow(A * A % MOD, N / 2) * A % MOD;
}

ll fac[2005], rev[2005];

int main(){
  int S; cin >> S;
  fac[0] = 1; rev[0] = 1;
  for (ll i = 1; i <= S; i++){
    fac[i] = fac[i-1] * i % MOD;
    rev[i] = Pow(fac[i], MOD - 2);
  }

  ll ans = 0;
  for (int i = 1; S - 3 * i >= 0; i++){
    ll now = fac[S - 2 * i - 1] * rev[S - 3 * i] % MOD;
    now *= rev[i-1]; now %= MOD;
    ans += now; ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
import itertools
n = int(input())

s357 = list("357") + [""]
cnt = []
for v in itertools.product(s357, repeat=9):
    s = "".join(v)
    if s and len(set(list(s))) >= 3 and int(s) <= n:
        cnt.append(int(s))
print(len(set(cnt)))


Measured memory_bytes: 13744
/*raghav0307 - Raghav Gupta*/

#include <bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int ll

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;

signed main(){
	fast_io();
	map<multiset<char>, int> mp;
	int n;	cin >> n;
	for(int i = 0; i < n; i++){
		multiset<char> s;
		for(int j = 0; j < 10; j++){
			char c;	cin >> c;
			s.insert(c);
		}
		mp[s]++;
	}
	int ans = 0;
	for(auto x : mp){
		// cout << x.ss << "\n";
		ans += (x.ss*(x.ss - 1))/2;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 56576
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int w,h,n;
  cin>>w>>h>>n;
  int lx=0,rx=w,dy=0,uy=h;
  int x[n],y[n],a[n];
  REP(i,n){
    cin>>x[i]>>y[i]>>a[i];
  }
  REP(i,n){
    if(a[i]==1){
      lx = max(lx,x[i]);
    }else if(a[i]==2){
      rx = min(rx,x[i]);
    }else if(a[i]==3){
      dy = max(dy,y[i]);
    }else{
      uy = min(uy,y[i]);
    }
  }
  if(lx>=rx || dy>=uy){
    cout<<0<<endl;
  }else{
    cout<<(rx-lx)*(uy-dy)<<endl;
  }
  return 0;
}



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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

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

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

vector<int> g[100000];
ll dp[100001][2];

void dfs(int x, int par = -1)
{
  dp[x][0] = dp[x][1] = 1; 

  for(auto to : g[x]){
    if(to == par) continue;

    dfs(to, x);
    dp[x][0] *= dp[to][0] + dp[to][1];
    dp[x][0] %= mod;
    dp[x][1] *= dp[to][0];
    dp[x][1] %= mod;
  }
}

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

  rep(i, n-1){
    int x, y;
    cin >> x >> y;
    x--; y--;

    g[x].pb(y);
    g[y].pb(x);
  }

  dfs(0);

  ll ans = dp[0][0] + dp[0][1];
  ans %= mod;

  cout << ans << endl;

  return 0;
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend()
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

ll total[51], pat[51];
ll patty(ll i, ll x){
  if (x <= 1) return (i == 0);
  else if (x <= total[i - 1] + 1) return patty(i - 1, x - 1);
  else if (x == total[i - 1] + 2) return (1ll << i);
  else if (total[i - 1] + 3 <= x) return patty(i  - 1, x - total[i - 1] - 2) + (1ll << i);
}

int main(){
  ll N, X; cin >> N >> X;
  total[0] = 1, pat[0] = 1;
  REP(i, 50){
    total[i + 1] = 2 * total[i] + 3;
    pat[i + 1] = 2 * pat[i] + 1;
  }
  cout << patty(N, X) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define db(x) cout<<x<<" "
#define db1(x) cout<<x<<'\n'
#define db2(x,y) cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pair(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define ff first
#define ss second
using namespace std;
using ll = long long int;

void solve(){

	ll h,a;
	cin>>h>>a;

	ll ans = ceil((double)h/(double)a);
	
	db1(ans);	

}



int main(){

  
 int t=1;
 //cin>>t;


while(t--){
  solve();
  }
      
  



	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    int table[100005] = {0};
    table[0] = 3;
    
    int n;
    cin >> n;
    
    ll ans = 1;
    rep(i, n) {
        int a;
        cin >> a;
        
        (ans *= table[a]) %= inf;
        table[a]--;
        table[a + 1]++;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long dp[2][2019], n, ans = 0, c = 0;
string s;
int main(int argc, char const *argv[])
{
	cin >> s;
	n = s.length();
	memset(dp, 0, sizeof(dp));
	dp[1][0] = 1;
	for (int i = 0; i < n; ++i)
	{
		c = ((c * 10) % 2019 + (s[i] - '0')) % 2019;
		memset(dp[i & 1], 0, sizeof(dp[i & 1]));
		for (int j = 0; j < 2019; ++j)
		{
			dp[i & 1][(j * 10) % 2019] += dp[!(i & 1)][j];
		}
		ans += dp[i & 1][c];
		dp[i & 1][c] ++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3728
#include<iostream>
#include<cmath>
#include<string>
#include<cstdlib>
#include<ctime>
#include<map>
#include<vector>
#include<list>
using namespace std;

#define ll long long
#define uint unsigned int
#define alloc(n,type) (type*)calloc(n,sizeof(type))
#define MODULE 1
#define RAND(min,max) (rand()%(max-min+1)+min)
#define repeat(i,condition) for(int i = 0; condition; i++)
#define LOG(log) cout<<#log<<" : "<<log<<'\n'
#define DEBUG() {cout<<"DEBUG "<<num_debug<<'\n'; num_debug++;}
int num_debug = 0;
bool* IsPrime;
vector<int> Prime;

int compare_int(const void* a, const void* b);
class Math {
public:
	template<typename T> static T Fac(int n) {
		T ans = 1;
		for (int i = 2; i <= n; i++) {
			ans *= i;
		}
		return ans;
	}
public :
	template<typename T> static T P(int n, int r) {
		T ans = 1;
		for (int i = 0; i < r; i++) {
			ans *= n - i;
		}
		return ans;
	}
public:
	template<typename T>static T C(int n, int r) {
		T nmr = 1;
		T dnm = 1;
		if (n - r < r)
			r = n - r;
		for (int i = 0; i < r; i++) {
			nmr *= n - i;
			dnm *= r - i;
		}
		return nmr / dnm;
	}
};
class Module_int {
public:
	static const int mod = MODULE;

public:
	static int add(int a, int b) {
		int ans = a + b;
		if (ans < 0)
			ans += mod;
		ans %= mod;
		return ans;
	}
public:
	static int mult(int a, int b) {
		return (a * b) % mod;
	}

public:
	static int Pow(int a, int b) {
		int base = a % mod;
		if (mod / 2 < abs(base))
			if (base < 0) {
				base += mod;  //negative
			}
			else {
				base -= mod;  //positive
			}

		return pow(base, b);
	}
};


int main(void) {
	srand((unsigned)time(NULL));

	int L, R;
	int d;
	cin >> L;
	cin >> R;
	cin >> d;

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

	cout << ans;

	return 0;
}


int compare_int(const void* a, const void* b) {
	return *(int*)a - *(int*)b;
}
void PrimeEnable(int n) {
	//initialize IsPrime
	IsPrime = (bool*)calloc(n + 1, sizeof(bool));
	for (int i = 0; i <= n; i++)
		IsPrime[i] = true;

	//IsPrime 
	IsPrime[0] = IsPrime[1] = false;
	for (int i = 2; i * i <= n; i++) {
		if (IsPrime[i])
			for (int j = i; i * j <= n; j++) {
				IsPrime[i * j] = false;
			}
	}

	//push back to Prime
	for (int i = 0; i <= n; i++) {
		if (IsPrime[i])
			Prime.push_back(i);
	}
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n,k;cin>>n>>k;
  if(2*k-1 <= n){
    P("YES");
  }else{
    P("NO");
  }
  return 0;
}


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

const int INF = 1 << 30;
const int MAX = 100000;

struct Card {
	char suit;
	int num;
};

void swap(Card &x, Card &y) {
	Card tmp = x;
	x = y;
	y = tmp;
}

int partition(Card A[], int p, int r) {
	Card x = A[r];
	int i = p; // First index greater than A[r]
	for (int j = p; j <= r-1; j++) {
		if (A[j].num > x.num) continue;
		swap(A[i], A[j]); // Insert A[j] (less than A[r])
		i++;
	}
	swap(A[i], A[r]);
	return i;
}

void quickSort(Card A[], int p, int r) {
	if (p >= r) return;
	int q = partition(A, p, r);
	quickSort(A, p, q-1);
	quickSort(A, q+1, r);
}

void merge(Card A[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    vector<Card> L(n1+1), R(n2+1);
    for (int i = 0; i < n1; i++) L[i] = A[left+i];
    for (int i = 0; i < n2; i++) R[i] = A[mid+i];
    L[n1].num = INF;
    R[n2].num = INF;
    int i = 0, j = 0;
    for (int k = left; k <= right-1; k++) {
        if (L[i].num <= R[j].num) {
            A[k] = L[i];
            i++;
        }
        else {
			A[k] = R[j];
            j++;
        }
    }
}

void mergeSort(Card A[], int left, int right) {
    if (left + 1 >= right) return;
    int mid = (left + right) / 2;
    int ans = 0;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
}

int main() {
	int n;
	Card A[MAX], B[MAX];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i].suit >> A[i].num;
		B[i] = A[i];
	}

	quickSort(A, 0, n-1);
	mergeSort(B, 0, n);
	bool stable = true;
	for (int i = 0; i < n; i++) {
		if (A[i].suit == B[i].suit) continue;
		stable = false;
		break;
	}
	if (stable) cout << "Stable" << endl;
	else cout << "Not stable" << endl;
	for (int i = 0; i < n; i++) cout << A[i].suit << ' ' << A[i].num << endl;
}



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

using namespace std;

#define ll long long
int MAX=2e6;

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

	ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n,k;
    int a[MAX];
    cin>>n>>k;
    for(int i=0;i<n;i++)
    	cin>>a[i];
    for(int i=k;i<n;i++){
		if(a[i]>a[i-k])
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
	return 0;
}


Measured memory_bytes: 4444
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

template<typename T> //最大公約数
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T> //最小公倍数
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_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 || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}


struct UnionFind {
	vector<int> par, rank, cnt;
	UnionFind(int n) : par(n), rank(n, 0), cnt(n, 1){
		for(int i = 0; i < n; ++i) par[i] = i;
	}
 
	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}
	
 
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
 
		if (rank[x] < rank[y]) swap(x, y);
 
		par[y] = x;
		cnt[x] += cnt[y];
		if (rank[x] == rank[y]) rank[x]++;
	}
 
	bool same(int x, int y) {
		return find(x) == find(y);
	}
 
	int size(int x) {
		return cnt[find(x)];
	}
};

int main(){
    int N, M, K; cin >> N >> M >> K;
    vector<int> candidate(N, 0);
    vector<vector<int> > FriendGraph(N), BlockGraph(N);
    UnionFind Friend(N), Block(N);


    for (int i = 0; i < M; i++){
        int a, b; cin >> a >> b; a--; b--;
        FriendGraph[a].push_back(b);
        FriendGraph[b].push_back(a);
        Friend.unite(a, b);
    }
    for (int i = 0; i < K; i++){
        int c, d; cin >> c >> d; c--; d--;
        BlockGraph[c].push_back(d);
        BlockGraph[d].push_back(c);
        Block.unite(c, d);
    }

    vector<int> ans(N);
    for (int i = 0; i < N; i++){
        int parent = Friend.find(i);
        set<int> st;
        for (int u = 0; u < FriendGraph[i].size(); u++){
            int to = FriendGraph[i][u];
            st.insert(to);
        }

        for (int u = 0; u < BlockGraph[i].size(); u++){
            int to = BlockGraph[i][u];
            if (Friend.same(to, i)){
                st.insert(to);
            }
        }
        ans[i] = Friend.size(parent) - st.size() - 1; 
    }

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



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

int main(){
    int n;
    cin>>n;
    int enter[n+1] = {0};
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        enter[x] = i+1;
    }
    for(int i=1;i<=n;i++)
        cout<<enter[i]<<" ";
    return 0;
}


Measured memory_bytes: 1152
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		double[] V = new double[N];
		for(int i = 0;i < N;i++){
			V[i] = Double.parseDouble(sc.next());
		}
		sc.close();
		Arrays.sort(V);
		for(int i = 0;i < N-1;i++){
			V[i+1] = (V[i] + V[i+1]) / 2;
		}
		System.out.println(V[N-1]);
	}
}

Measured memory_bytes: 22996
#include<iostream>
using namespace std;
int a[200001];
int main(){
    int n;
    cin>>n;
    while(n--){
        int x;
        cin>>x;
        a[x+1]=a[x+1]+1;
        a[x-1]++;
        a[x]++;
    }
    int maxn=0;
    for(int i=0;i<=200000;i++){
        if(a[i]>maxn){
            maxn=a[i];
        }
	}
    cout<<maxn;
    return 0;
 } 

Measured memory_bytes: 640
#include<stdio.h>
int main(void){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a==b){
		puts("a == b");
	}else if(a>b){
		puts("a > b");
	}else{
		puts("a < b");
	}
	
	return 0;
}


Measured memory_bytes: 2084
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    ll x,n;
    cin>>x;
    n=sqrt(2*x);
    while (n*(n+1)<2*x)
        n++;
    cout<<n<<endl;
}

Measured memory_bytes: 256
import math
X, K, D = map(int,input().split())

if abs(X) > D*K:
    print(abs(X) - D*K)
    exit()

a = math.ceil(abs(X)/D)

ans = abs(abs(X) - D*a)
if (K - a) % 2 == 0:
    print(ans)
else:
    print(abs(D - ans))

Measured memory_bytes: 9176
package main

import (
	"fmt"
	"time"
)

func main() {
	var s string
	fmt.Scan(&s)
	t, _ := time.Parse("2006/01/02", s)
	d, _ := time.Parse("2006/01/02", "2019/04/30")

	if t.Before(d) || t.Equal(d) {
		fmt.Println("Heisei")
	} else {
		fmt.Println("TBD")
	}
}


Measured memory_bytes: 1900
s=input()
t=input()

ls=len(s)
lt=len(t)

def f(a,b):
    r=""
    for i in range(lt):
        if a[i]==b[i] or a[i]=="?":
            r+=b[i]
        else:
            return False
    return True
        
ans=[]

for i in range(ls-lt+1):
    c=""
    if f(s[i:i+lt],t):
        c+=s[0:i]
        c+=t
        c+=s[i+lt:ls]
        c=c.replace("?","a")
        ans.append(c)

if ans==[]:
    print("UNRESTORABLE")
else:
    print(min(ans))


Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define loop(i,a,b) for(int i = a; i < b; i++)
#define rep(i,a) loop(i,0,a)


int main()
{	
	string a;
	
	cin>>a;
	
	int i=0;
	int flg=0;
	while(a[i]!='\0'){
		if(a[i]=='C'){
			flg=1;
			break;
		}
		i++;
	}
	while(a[i]!='\0'){
		if(a[i]=='F'){
			cout<<"Yes"<<endl;
			return 0;
		}
		i++;
	}
	cout<<"No"<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <queue>
#include <bits/stdc++.h>
#include <stack>
#include <vector>
#include <list>

using namespace std;

int main(){
  int ans1,ans2;
  int sum = 0;
  int n;
  cin >> n;

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

  ans1 = ans2 = 0;
  int avg = sum / n;
  for(int i = 0; i < n; i++){
    if(avg > a[i])
      ans1 += ((avg-a[i])*(avg-a[i]));
    else
      ans1 += ((a[i]-avg)*(a[i]-avg));
  }
  avg += 1;
  for(int i = 0; i < n; i++){
    if(avg > a[i])
      ans2 += ((avg-a[i])*(avg-a[i]));
    else
      ans2 += ((a[i]-avg)*(a[i]-avg));
  }

  int min = ans1;
  if(min > ans2) min = ans2;
  cout << min << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

n, m, s = map(int, input().split())
s = min(s, 2500)
from collections import defaultdict
# O(ElogV)
import heapq
def dijkstra(s, x):
    # 始点sから各頂点への最短距離
    d = defaultdict(lambda: float("inf"))
    d[(s, x)] = 0
    # 各頂点が訪問済みかどうか
    used = defaultdict(lambda: False)
    used[(s, x)] = True
    # 仮の距離を記録するヒープ
    que = []
    for e in edge[(s, x)]:
        heapq.heappush(que, e)
    while que:
        minedge = heapq.heappop(que)
        if used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = True
        for e in edge[v]:
            if not used[e[1]]:
                heapq.heappush(que, (e[0] + d[v], e[1]))
    return d

max_money = 2500
edge = defaultdict(list)
for _ in range(m):
    u, v, a, b = map(int, input().split())
    u -= 1
    v -= 1
    for i in range(a, max_money + 1):
        edge[(u, i)].append((b, (v, i - a)))
        edge[(v, i)].append((b, (u, i - a)))
for j in range(n):
    c, d = map(int, input().split())
    for i in range(max_money):
        if i + c <= max_money:
            edge[(j, i)].append((d, (j, i + c)))

ans = [10**18]*n

d = dijkstra(0, s)
for i in d:
    x, y = i
    cost = d[i]
    ans[x] = min(ans[x], cost)
for i in ans[1:]:
    print(i)


Measured memory_bytes: 188732
#include <stdio.h>
#include <stdlib.h>
int a[1000][2000]={0};
int main() {
    int N, K;
    int x, y;
    char c;
    scanf("%d %d", &N, &K);
    int i,j;
    for(i=0;i<N;i++) {
        scanf("%d %d %c", &x, &y, &c);
        y%=2*K;
        if(c=='W')x+=K;
        if(y>=K){
            x+=K;
            y-=K;
        }
        x%=2*K;
        a[y][x]++;
        if(x<K){
            a[y][x+K]--;
            if(y!=0){
                a[0][x+K]++;
                a[y][x+K]--;
                if(x!=0){
                    a[0][0]++;
                    a[y][0]--;
                    a[0][x]--;
                    a[y][x]++;
                }
            }
        }else{
            a[y][0]++;
            a[y][x-K]--;
            if(y!=0){
                a[0][x-K]++;
                a[y][x-K]--;
                a[0][x]--;
                a[y][x]++;
            }
        }
    }
    for(i=0;i<K-1;i++){
        for(j=0;j<2*K;j++){
            a[i+1][j]+=a[i][j];
        }
    }
    for(i=0;i<K;i++){
        for(j=0;j<2*K-1;j++){
            a[i][j+1]+=a[i][j];
        }
    }
    int ans=0;
    for(i=0;i<K;i++){
        for(j=0;j<2*K;j++){
            if(ans<a[i][j])ans=a[i][j];
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 7936
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:256000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

// belik's shit
ll const mod = 1e9 + 7;
namespace {
	ll mult(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) {
			val += mod;
		}
		if (val >= mod) {
			val -= mod;
		}
		return val;
	}
	ll poww(ll a, ll b)
	{
		ll val = 1;
		a %= mod;
		while (b > 0){
			if (b % 2) val = mult(a, val);
			a = mult(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 2e5 + 5;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n; cin >> n; ll ans = 0;
	for (ll x = 1; x <= n; x++) {
		string s = to_string(x);
		if ((ll)s.size() % 2 == 1) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;

}
/*

*/

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

int main(){
	double r,L, S;
	cin >> r;
	L = 2 * r*3.14159265358979323;
	S = L*r / 2;
	printf("%.6lf %.6lf\n",S,L);
	return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int mod=1e9+7;

int id[1005][1005];
vector<int>to[1000005];
bool visited[1000005];
int dp[1000005];
bool calculated[1000005];

int toid(int i,int j){
  if(i>j){swap(i,j);}
  return id[i][j];
}

int main() {
  int N,K;
  cin>>N>>K;
  if(K==1){cout<<0<<endl;}
  else{cout<<N-(K-1)-1<<endl;}
  return 0;  
}

Measured memory_bytes: 27044
#include <iostream>

int main() {
  int A,B,C,K;
  std::cin >> A >> B >> C >> K;
  
  int ans = 0;
  
  if (A >= K) {
    ans = K;
  } else if (A+B >= K) {
    ans = A;
  } else {
    ans += A;
    ans -= (K-A-B);
  }
  
  std::cout << ans << std::endl;
  
  return 0;
}

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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define SORT(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> P;

int main(){
	int a , b ;cin >>a >>b;
	if(a<=8&&b<=8){
		cout <<"Yay!"<<endl;
	  }
	  else{
		cout<<":("<<endl;
		}
	  }




Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define rep(i, n) for(int i = 1; i < (n); i++)

int main(){
    string s;
    cin >> s;
    int n = s.length(), ans = 0;
    rep(i,4)rep(j,4)rep(k,4)rep(l,4){
        if(i+j+k+l != n)    continue;
        string ss = s.substr(0,i), t = s.substr(i, j), u = s.substr(i+j, k), v = s.substr(i+j+k, l);
        if((i!=1 && ss[0]=='0') || (j!=1 && t[0]=='0') || (k!=1 && u[0]=='0') || (l!=1 && v[0]=='0'))    continue;
        if(stoi(ss) < 256 && stoi(t) < 256 && stoi(u) < 256 && stoi(v) < 256)    ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3212
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    long long n,k,ans;

	cin>>n>>k;
    if(n<=k)ans=min(n,k-n);
    else ans=min(n%k,abs(n%k-k));
   
    cout<<ans;	
}

Measured memory_bytes: 256
#include <cstdio>
#define rep(i,j,k) for (i=j;i<=k;i++)
using namespace std;
const int N=3e5+5;
int n,i,j,u,v,a[N],f[N];
int En,fst[N],to[N*2],nxt[N*2];
void add(int u,int v) {
	En++; nxt[En]=fst[u]; fst[u]=En; to[En]=v;
}
void dfs(int x,int fa)
{
	int j,v;
	f[x]=0;
	for (j=fst[x];j;j=nxt[j])
		if (to[j]!=fa)
		{
			v=to[j];
			dfs(v,x);
			if (a[v]>=a[x] || f[v]) continue;
			f[x]=1;
		}
}
int main()
{
//	freopen("sidestep.in","r",stdin);
//	freopen("sidestep.out","w",stdout);
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",&a[i]);
	rep(i,1,n-1)
	{
		scanf("%d%d",&u,&v);
		add(u,v); add(v,u);
	}
	rep(i,1,n)
	{
		dfs(i,i);
		if (f[i]) printf("%d ",i);
	}
	return 0;
}

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

long long knapsack[110][10101];

int main(){
    int N, W;
    cin >> N >> W;
    
    vector<int> v(N), w(N);
    for (int i = 0; i < N; i++) cin >> v[i] >> w[i];
    
    // knapsack[i+1][j] :
    // (0-indexにおいて)0番目の荷物から~i番目までの荷物において
    // 重さの総和がj以下のときの
    // 価値の総和の最大値とする
    // 答えは, knapsack[N][W]である
    
    for (int i = 0; i < 110; i++){
        for (int j = 0; j < 10101; j++) knapsack[i][j] = 0;
    }
  

    // 荷物の番号を動かす 0 ~ N-1まで
    for (int i = 0; i < N; i++){
        
        // 重さを動かす　0 ~ Wまで(including W)
        for (int j = 0; j <= W; j++){
            
            knapsack[i+1][j] = knapsack[i][j]; //一旦, i番目では何も選ばないことにする
            
            if (j - w[i] >= 0) knapsack[i+1][j] = max(knapsack[i][j], knapsack[i+1][j-w[i]] + v[i]);
        } 
    }
    
    cout << knapsack[N][W] << endl;
}


Measured memory_bytes: 11780
#![allow(dead_code)]

mod reader {
    use std;

    macro_rules! read_line((  ) => {
                           {
                           let mut input = String :: new (  ) ; std :: io ::
                           stdin (  ) . read_line ( & mut input ) . unwrap (
                           ) ; input } } ;);

    pub fn read_to_vec<T: std::str::FromStr>() -> Vec<T> {
        read_line!().split_whitespace().map(|e|
                                                e.parse().ok().unwrap()).collect()
    }

    pub fn read_and_parse<T: std::str::FromStr>() -> T {
        read_line!().trim().parse().ok().unwrap()
    }
}

use reader::*;

fn main() {
    let n: i32 = read_and_parse();
    let h: Vec<i32> = read_to_vec();

    let mut count: i32 = 1;
    for (i, &inn) in h.iter().enumerate() {
        if let Some(&max) = h[..i].iter().max() {
            if max <= inn { count += 1 }
        }
    }

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


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

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

        int d = 0;
        int counter = 1;
        for (int i = 0; i < n; i++) {
            d = d + sc.nextInt();
            if (d <= x) {
                counter++;
            } else {
                break;
            }
        }

        System.out.println(counter);

        sc.close();
    }

}


Measured memory_bytes: 23892
while True:
    m, f, r = map(int, input().split())
    A = m + f
    if m == f == r == -1:
        break
    elif m == -1 or f == -1:
        print('F')
    elif A >= 80:
        print('A')
    elif 65 <= A < 80:
        print('B')
    elif 50 <= A < 65:
        print('C')
    elif 30 <= A < 50:
        if 50 <= r:
            print('C')
        else:
            print('D')
    else:
        print('F')

Measured memory_bytes: 7668
#include<iostream>
#include<vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

int main(){
	string s,t;
	cin>>s>>t;
	int sum=0;
	rep(i,s.size()){
		if(s[i]!=t[i])sum++;
	}
	cout<<sum<<endl;

	return 0;
}


Measured memory_bytes: 3920
import sys
n, m = map(int, input().split())
sumans = 0
ans = 0

list = [[0 for i in range(2)] for j in range(n)]

for i in range(n):
	list[i][0], list[i][1]= map(int, input().split())
	
list = sorted(list)

for i in range(n):
	for j in range(int(list[i][1])):
		sumans += list[i][0]
		ans += 1
		if ans == m:
			print(sumans)
			sys.exit()

Measured memory_bytes: 22444
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

using path=pair<ll,ll>;
using graph=vector<vector<path>>;

bool dijkstra(graph &g, ll s, int a, int b) {
  vl d(g.size(), LINF);
  priority_queue<path, vector<path>, greater<>> que;
  d[s] = 0;
  que.push(path(0, s)); // cost, index
  while (!que.empty()) {
    path p = que.top(); que.pop();
    int i = p.second;
    if (d[i] < p.first) continue;
    each(x, g[i]) {
      if ((x.second == a && i == b) || (x.second == b && i == a)) {
        continue;
      }
      if (d[x.second] > d[i] + x.first) {
        d[x.second] = d[i] + x.first;
        que.push(path(d[x.second], x.second));
      }
    }
  }
  each(x, d) {
    if (x == LINF) {
      return true;
    }
  }

  return false;
}

void solve() {
  VAR(int, N, M);
  graph g(N, vector<path>());
  vector<path> v(M);

  rep(i, 0, M) {
    VAR(ll, ai, bi);
    g[ai - 1].push_back(path(1, bi - 1));
    g[bi - 1].push_back(path(1, ai - 1));
    v[i] = path(ai - 1, bi - 1);
  }

  int ans = 0;
  rep(i, 0, M) {
    if (dijkstra(g, 0, v[i].first, v[i].second)) {
      ans++;
    }
  }
  print(ans);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt(), b = scan.nextInt(), c = scan.nextInt();
		
		 System.out.println((a<b&&b<c) ? "Yes" : "No");
	}

}

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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int i##_to_ = (t), i = (f); i <= i##_to_; i++)
#define uptil(f, t, i)   for(int i##_to_ = (t), i = (f); i <  i##_to_; i++)
#define downto(f, t, i)  for(int i##_to_ = (t), i = (f); i >= i##_to_; i--)
#define downtil(f, t, i) for(int i##_to_ = (t), i = (f); i >  i##_to_; i--)
typedef long double LD;
#define long long long

#if defined(EBUG) && !defined(ONLINE_JUDGE)
#define debug true
#define ln << endl
#else
#define debug false
#define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '



signed main() { // long: 64bit
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }

    int N, M; scanf("%d%d", &N, &M);

    cout << (N - 1) * (M - 1);

    return 0;
}


Measured memory_bytes: 256