akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

const int mod = 998244353;
struct ModInt {
    lint x;
    ModInt (lint a) : x((a % mod + mod) % mod) {}
    ModInt operator - () const {
        return ModInt(-x);
    }
    ModInt &operator += (const ModInt &a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator -= (const ModInt &a) {
        if ((x -= a.x) < 0) x += mod;
        return *this;
    }
    ModInt &operator *= (const ModInt &a) {
        (x *= a.x) %= mod;
        return *this;
    }
    ModInt operator + (const ModInt &a) const {
        ModInt res(*this);
        return res += a;
    }
    ModInt operator - (const ModInt &a) const {
        ModInt res(*this);
        return res -= a;
    }
    ModInt operator * (const ModInt &a) const {
        ModInt res(*this);
        return res *= a;
    }
    ModInt pow(lint t) const {
        if (!t) return 1;
        ModInt a = pow(t / 2);
        a *= a;
        if (t % 2) a *= *this;
        return a;
    }
    ModInt inv() const {
        return pow(mod - 2);
    }
    ModInt &operator /= (const ModInt &a) {
        return (*this) *= a.inv();
    }
    ModInt operator / (const ModInt &a) const {
        ModInt res(*this);
        return res /= a;
    }
    friend ostream &operator << (ostream &os, const ModInt &a){
        os << a.x;
        return os;
    }
};

vector<ModInt> fact;
ModInt com(int x, int y) {return fact[x] / fact[y] / fact[x - y];}

int main() {
    ModInt now(1);
    fact.push_back(now);
    for (int i = 1; i < 200010; ++i) {
        ModInt m(i);
        now *= m;
        fact.push_back(now);
    }
    int N, M, K;
    cin >> N >> M >> K;
    ModInt ans(0);
    rep(i, K + 1) {
        ModInt a = com(N - 1, i);
        ModInt b(M - 1);
        ModInt c = b.pow(N - 1 - i);
        ans += a * c;
    }
    ModInt x(M);
    ans *= x;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 5208
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
using ll=long long;

int main(){
	ll a,b,c;
	cin >> a >> b >> c;
	bool s=a%2&&b%2&&c%2;
	ll aa=0,bb=0,cc=0;
	ll ans=0;
	while(a%2==0&&b%2==0&&c%2==0){ 
		aa=(b+c)/2;
		bb=(a+c)/2;
		cc=(a+b)/2;
		a=aa;
		b=bb;
		c=cc;
		ans++;
		if(a==b&&b==c&&c==a){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string

	fmt.Scanln(&s)
	fmt.Println(logic(s))
}

func logic(s string) string {
	result := ""

	for _, c := range s {
		if string(c) == "B" {
			if len(result) > 0 {
				result = result[:len(result)-1]
			}
			continue
		}
		result += string(c)
	}
	return result
}


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

int main()
{
    int n;
    cin >> n;
    int a[n] = {};
    for(int i=0; i<n; i++) cin >> a[i];
    
    int current = 1;
    int count = 0;
    for(int i=0; i<n; i++){
        if(a[i] == current){
            count++;
            current++;
        }
    }
    if(count == 0){
        cout << -1 << endl;
    }else{
        cout << n-count << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#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 pb push_back
#define mp make_pair
#define in insert
#define f first
#define s second
#define ll long long
#define int long long
#define dd double
  
const int mod = 1e9 + 7;
const int N = 2e5 + 7;
const int inf = 2e9;
const ll INF = 1e18;

ll dp[N], t[4*N], c[4*N], p[N];
vector<ll> la[N];
vector<pair<ll, ll>> ra[N];

void push (int v, int tl, int tr) {
	t[v] += c[v];
	if (tl != tr){
		c[v + v] += c[v];
		c[v + v + 1] += c[v];
	}
	c[v] = 0;
}

void update (int v, int tl, int tr, int l, int r, int val) {
	push (v, tl, tr);
	if (tl >= l && tr <= r) {
		c[v] += val;
		push(v, tl, tr);
		return;
	}
	if (tl > r || tr < l) {
		return;
	}

	int mid = (tl + tr) / 2;
	update (v + v, tl, mid, l, r, val);
	update (v + v + 1, mid + 1, tr, l, r, val);
	t[v] = max(t[v + v], t[v + v + 1]);
}

ll get (int v, int tl, int tr, int l, int r) {
	push (v, tl, tr);
	if (tl >= l && tr <= r) {
		return t[v];
	}
	if (tl > r || tr < l) {
		return -INF;
	}
	int mid = (tl + tr) / 2;
	return max(get(v + v, tl, mid, l, r), get(v + v + 1, mid + 1, tr, l, r));
}

main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	// freopen("*.in", "r", stdin);freopen("*.out", "w", stdout);
	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int l, r, x;
		cin >> l >> r >> x;
		la[l].pb(x);
		ra[r].pb({l - 1, x});
	}

	ll ans = 0;

	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < la[i].size(); j++)
			update (1, 0, n, 0, i - 1, la[i][j]);

		dp[i] = get(1, 0, n, 0, i - 1);
		ans = max(ans, dp[i]);
		update (1, 0, n, i, i, dp[i]);

		for (int j = 0; j < ra[i].size(); j++)
			update (1, 0, n, 0, ra[i][j].f, -ra[i][j].s);
	}

	cout << ans;
}

Measured memory_bytes: 37760
from string import *
N = int(input())
S = input()
ans = ""

for i in range(len(S)):
    n = ascii_uppercase.find(S[i])
    if(n+N-1 >= 25):
        ans += ascii_uppercase[n+N-26]
    else:
        ans += ascii_uppercase[n+N]
    
print(ans)

Measured memory_bytes: 3772
#include<stdio.h>
int main()
{
  int S,h,m,s;

    scanf("%d",&S);

    h = S / 3600;

    m = (S - h*3600) / 60;

    s = (S - (h*3600 + m*60));
  
    printf("%d:%d:%d\n",h,m,s);

    return 0;
}

Measured memory_bytes: 1840
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    int N; cin >> N;
    vector<int> A(N); rep(i, N) cin >> A[i];

    int odd_cnt = 0;
    rep(i, N) {
        if (A[i] & 1) odd_cnt++;
    }

    if (odd_cnt & 1) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}


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

using namespace std;

int main() {

	string o,e;
	cin >> o >> e;

	for (long i = 0; i < min(o.size(), e.size()); i++) {
		cout << o[i] << e[i];
	}

	if (o.size() != e.size()) {
		cout << o[o.size() - 1] << endl;
	}

	return 0;

}

Measured memory_bytes: 384
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	while(cin>>s) {
		string last;
		ll si=0,ans=0;
		REP(i, s.size()) {
			string t=s.substr(si, i-si+1);
//			DD(last);DD(t);
			if(last!=t) {last=t;si=i+1;ans++;}
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

cat mod = 998244353;
cat C[11][11];

void count(int h, int w, char f_e, char f_h, char f_w, int & out, cat cur = 1) {
	if(h+w == 0) {
		out += cur;
		if(out >= mod) out -= mod;
		return;
	}
	for(int c = 0; c < 2; c++) for(int i = 0; i <= h; i++) for(int j = 0; j <= w; j++) if(i+j) {
		if((f_h>>c)&1 && i) break;
		if((f_w>>c)&1 && j) break;
		if(j && f_e&2 && c) break;
		if(i && f_e&4 && c) break;
		if(!(f_e&1)) if((h == i)^(w == j)) continue;
		cat x = C[h][i] * C[w][j] % mod;
		int n_h = f_h, n_w = f_w;
		if(i) n_w ^= n_w&(1<<(1-c));
		if(j) n_h ^= n_h&(1<<(1-c));
		n_h |= 1<<c;
		n_w |= 1<<c;
		int n_e = (f_e&1) + ((!i)<<1) + ((!j)<<2);
		count(h-i, w-j, n_e, n_h, n_w, out, cur*x%mod);
	}
}

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int H, W;
	cin >> H >> W;
	vector<int> V(H, 0);
	for(int i = 0; i < H; i++) {
		string s;
		cin >> s;
		for(int j = 0; j < W; j++)
			if(s[j] == '#') V[i] |= 1<<j;
	}
	memset(C, 0, sizeof(C));
	for(int i = 0; i <= 10; i++) {
		C[i][0] = 1;
		for(int j = 1; j <= i; j++)
			C[i][j] = (C[i-1][j]+C[i-1][j-1])%mod;
	}
	int cnt[11][11];
	memset(cnt, 0, sizeof(cnt));
	for(int i = 0; i <= H; i++) for(int j = 0; j <= W; j++) if(i+j < 20)
		count(i, j, (H-i) || (W-j), 0, 0, cnt[i][j]);
	cnt[10][10] = 710838430;
	cat ans = cnt[H][W];
	for(int i = 0; i < (1<<H)-1; i++) {
		vector<int> Vr, Vc(W, 0);
		for(int j = 0; j < H; j++)
			if(!((i>>j)&1)) Vr.push_back(V[j]);
		for(int j = 0; j < W; j++) {
			for(int k = 0; k < H; k++)
				if(!((i>>k)&1)) Vc[j] += ((V[k]>>j)&1)<<k;
			Vc[j] = (!Vc[j]) || (Vc[j] == (1<<H)-1-i);
		}
		int n = H-Vr.size();
		for(int j = 0; j < (1<<W)-1; j++) {
			int m = (1<<W)-1-j;
			bool ok = true;
			for(int k = 0; k < H-n; k++) if(!(Vr[k]&m) || (Vr[k]&m) == m) {
				ok = false;
				break;
			}
			if(!ok) continue;
			for(int k = 0; k < W; k++) if(!((j>>k)&1) && Vc[k]) {
				ok = false;
				break;
			}
			if(!ok) continue;
			ans += cnt[n][__builtin_popcount(j)];
			if(ans >= mod) ans -= mod;
		}
	}
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

vector<vector<int> >v;
int belong[100010];
bool *vis;
int ind=0,neic=0;

void dfs(int u)
{
    vis[u]=true;
    belong[u]=ind;
    neic+=1;
    for(int i=0;i<v[u].size();i++)
    {
        if(vis[v[u][i]]==false)
            dfs(v[u][i]);
    }
}

int main()
{
    fastio;
    int n,m,k;
    cin >> n >> m >> k;
    vector<vector<int> >v1(n);
    v=v1;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin >> x >>y;
        x-=1;y-=1;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    vector<pair<int,int> >e(k);
    for(int i=0;i<k;i++)
    {
        int x,y;
        cin >> x >> y;
        x-=1;y-=1;
        e[i].first=x;e[i].second=y;
    }
    vis=new bool[n];
    for(int i=0;i<n;i++)
        vis[i]=false;
    vector<int>necomp;
    for(int i=0;i<n;i++)
    {
        if(vis[i]==false)
        {
            dfs(i);
            necomp.push_back(neic);
            neic=0;
            ind+=1;
        }
    }
    int ne[100010];
    for(int i=0;i<n;i++)
        ne[i]=0;
    for(int i=0;i<k;i++)
    {
        int a=e[i].first,b=e[i].second;
        if(belong[a]==belong[b])
        {
            ne[a]+=1;
            ne[b]+=1;
        }
    }
    for(int i=0;i<n;i++)
    {
        int ans=necomp[belong[i]]-1-v[i].size()-ne[i];
        cout << ans << " ";
    }
    cout << endl;
}

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

typedef long long ll;
typedef long double ld;

using namespace std;

void INeedIt() {
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int a[100001];
int main() {
	INeedIt();
	int n, k, ans = 0;
	cin>>n>>k;
	for (int i=0;i<n;i++){
		cin>>a[i];
		if (k<=a[i]) ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i, n)cin >> v[i];
    reverse(v.begin(), v.end());
    for(int i = 1; i < n; i++){
        if(v[i-1] >= v[i])continue;
        else if(v[i-1] == v[i]-1){
            v[i] -= 1;
        }
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    system("pause");
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
 
int main(){
  int H ,W ;
  cin >> H >> W ;
  string S[H][W] ;
  rep(i,H){
    rep(j,W) cin >> S[i][j];
  }
 
  rep(i,H){
    rep(j,W){ 
      cout << S[i][j];
      cout << endl;
      cout << S[i][j];
      cout << endl;
    }
  }
}

Measured memory_bytes: 384
/* https://atcoder.jp/contests/abc079/tasks/abc079_c */

#include <iostream>
#include <vector>

/* {{{ Variables */
std::string S;
std::vector<int> nums(4);
/* }}} */

int main(int argc, char *argv[])
{
  /* {{{ Input */
  std::cin >> S;
  for (int i = 0; i < 4; ++i) {
    nums.at(i) = S.at(i) - '0';
  }
  /* }}} */

  /* {{{ Output */
  for (int i = 0; i < 1 << 3; ++i) {
    std::string expr = std::to_string(nums.at(0));
    std::vector<int> opes(3);
    int result = nums.at(0);

    for (int j = 0; j < 3; ++j) {
      int ope = 1 & i >> j;

      opes.at(j) = ope;
      if (ope == 1) {
        result += nums.at(j+1);
        expr += "+" + std::to_string(nums.at(j+1));
      } else {
        result -= nums.at(j+1);
        expr += "-" + std::to_string(nums.at(j+1));
      }
    }

    if (result == 7) {
      std::cout << expr + "=7" << std::endl;
      return 0;
    }
  }
  /* }}} */

  return 0;
}


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

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

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

int main(){
    string str1;

    cin >> str1;
    if(str1[0] == 'H'){
        string str2;
        cin >> str2;
        if(str2[0] == 'H'){
            cout << "H" << endl;
        }
        else{
            cout << "D" << endl;
        }
    }
    else{
        string str2;
        cin >> str2;
        if(str2[0] == 'H'){
            cout << "D" << endl;
        }
        else{
            cout << "H" << endl;
        }
    }

    return 0;
}

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

int main() {
  double w,h,x,y;
  cin>>w>>h>>x>>y;
  cout<<w*h/2<<' ';
  if (w/2==x&&h/2==y)
    cout<<1<<endl;
  else
    cout<<0<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define maxn 10005
#define inf 0x3f3f3f3f
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int m,n,k,w[10005],lst[10005];
vector <int> a;
struct edge{
	int to,cap,cst,rev;
};
vector <edge> adj[maxn];
int dis[maxn],h[maxn];
int V,prvv[maxn],prve[maxn];
bool inque[maxn];
void addedge(int u,int v,int c,int d){
	adj[u].push_back((edge){v,c,d,(int)adj[v].size()});
	adj[v].push_back((edge){u,0,-d,(int)adj[u].size() - 1});
}
int min_cost_flow(int s,int t,int f){
	memset(h,0,sizeof(h));
	int res = 0;
	bool fir = true;
	while(f > 0){
		memset(dis,0x3f,sizeof(dis));
		dis[s] = 0;
		if(fir){
			memset(inque,0,sizeof(inque));
			queue <int> que;
			que.push(s);
			inque[s] = true;
			while(!que.empty()){
				int u = que.front();que.pop();
				inque[u] = false;
				for(int i=0;i<adj[u].size();i++){
					edge &e = adj[u][i];
					if(e.cap && dis[u] + h[u] + e.cst - h[e.to] < dis[e.to]){
						dis[e.to] = dis[u] + h[u] + e.cst - h[e.to];
						prvv[e.to] = u;
						prve[e.to] = i;
						if(!inque[e.to]){
							que.push(e.to);
							inque[e.to] = true;
						}
					}
				}
			}
			fir = false;
		}else{
			priority_queue <P,vector<P>,greater<P> > que;
			que.push(mp(0,s));
			while(!que.empty()){
				P p = que.top();que.pop();
				int u = p.second;
				if(p.first != dis[u]) continue;
				for(int i=0;i<adj[u].size();i++){
					edge &e = adj[u][i];
					if(e.cap && dis[u] + h[u] - h[e.to] + e.cst < dis[e.to]){
						dis[e.to] = dis[u] + h[u] - h[e.to] + e.cst;
						prvv[e.to] = u;
						prve[e.to] = i;
						que.push(mp(dis[e.to],e.to));
					}
				}
			}
		}
		for(int i=0;i<=V;i++) h[i] += dis[i];
	  if(h[t] >= inf) return -1;
		int flow = f;
		for(int i=t;i!=s;i=prvv[i]){
			flow = min(flow,adj[prvv[i]][prve[i]].cap);
		}
		f -= flow;
		res += flow * h[t];
		for(int i=t;i!=s;i=prvv[i]){
			edge &e = adj[prvv[i]][prve[i]];
			e.cap -= flow;
			adj[e.to][e.rev].cap += flow;
		}
	}
	return res;
}
int main(){
	memset(lst,-1,sizeof(lst));
	scanf("%d%d%d",&m,&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&w[i]);
	}
	for(int i=1;i<=k;i++){
		int x;
		scanf("%d",&x);
		a.push_back(x);
	}
	int sum = 0;
	a.erase(unique(a.begin(),a.end()),a.end());
	k = a.size();
	for(int i=0;i<k-1;i++){
		addedge(i,i+1,m,0);
	}
	for(int i=0;i<k;i++){
		sum += w[a[i]];
		if(lst[a[i]] != -1) addedge(lst[a[i]],i-1,1,-w[a[i]]);
		lst[a[i]] = i;
	}
	V = k-1;
	printf("%d\n",sum + min_cost_flow(0,k-1,m-1));
	return 0;
}


Measured memory_bytes: 4380
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    A = LI()
    while True:
        ans = min(A)
        A = [x%ans for x in A if x%ans != 0]
        if not A:
            print(ans)
            break
        A.append(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 20056
#![allow(dead_code)]
use crate::scanner::Scanner;
fn main() {
    let mut scan = Scanner::new();
    let a = scan.read::<i64>();
    let b = scan.read::<i64>();
    println!("{}", a * b);
}
mod scanner {
    use std::io::{stdin, BufReader, Bytes, Read, Stdin};
    use std::str::FromStr;
    pub struct Scanner {
        buf: Bytes<BufReader<Stdin>>,
    }
    impl Scanner {
        pub fn new() -> Scanner {
            Scanner {
                buf: BufReader::new(stdin()).bytes(),
            }
        }
        pub fn read_next<T: FromStr>(&mut self) -> Option<T> {
            let token = self
                .buf
                .by_ref()
                .map(|c| c.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect::<String>();
            token.parse::<T>().ok()
        }
        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_next().unwrap()
        }
        pub fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.read::<T>()).collect()
        }
        pub fn chars(&mut self) -> Vec<char> {
            self.read::<String>().chars().collect()
        }
    }
}



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

typedef long long ll;

// pairsをfirstを優先キーとして昇順ソート
bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
// pairsをsecond優先キーとして昇順ソート
bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main()
{
    ll N;
    ll D;
    ll A;

    cin >> N >> D >> A;

    vector<pair<ll, ll> > pairs(N);
    vector<ll> X(N);

    for(ll i=0; i<N; i++){
        cin >> pairs[i].first >> pairs[i].second;
    }
    // Xで昇順ソート
    sort(pairs.begin(), pairs.end(), compare_by_a);

    for(ll i=0; i<N; i++){
        X[i] = pairs[i].first;
    }

    // 爆弾の効果の及ばない範囲を計算
    vector<ll> damage(N+1, 0);
    ll count=0;

    for(ll i=0; i<N; i++){
        // モンスターに与えるダメージが必要なとき
        if(damage[i] < pairs[i].second){
            // モンスター i を倒すのに必要な回数
            ll need = (pairs[i].second - damage[i] + A - 1) / A;

            // X[i] を左端とした爆発が届く範囲を求める
            ll right = pairs[i].first + D * 2;
            ll id = upper_bound(X.begin(), X.end(), right) - X.begin();

            // imos法
            damage[i] += need * A;
            damage[id] -= need * A;
            count += need;
        }
        // 累積和をとる
        damage[i+1] += damage[i];
    }
    cout << count << endl;
    return 0;
}


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

int main()
{
	ll n;
	cin >> n;
	vector<pair<ll,ll>> fa;
	for(ll i = 2;i*i<=n;i++)
	{
		
		if(n%i==0)
		{
			ll x = 0;
			while(n%i==0)
			{
				x++;
				n/=i;
			}
			fa.emplace_back(i,x);
			//cout<<i<<endl;
		}
	}
	if(n!=1)
	{
		fa.emplace_back(n,1);
	}
	ll ans = 0;
	//cout<<';'<<endl;
	for(auto &i:fa)
	{
		for(ll j = 1;j<=i.second;j++)
		{
			i.second-=j;
			ans++;
		}
	}
	cout<<ans<<endl;
}

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

typedef long long i64;

int g[2][3];
int sac[5010];

i64 rucsac(int n, int c)
{
	fill(sac, sac + n + 1, 0);
	for (int t = 0; t < 3; t++) {
		int cost = g[c][t], castig = g[c ^ 1][t] - g[c][t];
		if (castig <= 0)
			continue;
		for (int i = cost; i <= n; i++)
			sac[i] = max(sac[i], sac[i - cost] + castig);
	}
	int best = n;
	for (int i = 0; i <= n; i++)
		best = max(best, n + sac[i]);
	return best;
}




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

	int n;
	cin >> n;
	cin >> g[0][0] >> g[0][1] >> g[0][2] >> g[1][0] >> g[1][1] >> g[1][2];

	int mijloc = rucsac(n, 0);
	i64 ans = 0;

	if (mijloc <= n) {
		assert(mijloc == n);
		/// stau pe loc
		ans = rucsac(n, 1);
	}
	else {
		vector <pair <i64, i64>> c;
		for (int i = 0; i < 3; i++) {
			i64 cost = g[1][i], profit = g[0][i] - g[1][i];
			if (profit <= 0)
				continue;
			c.push_back({ cost, profit });
		}
		if (c.empty())
			ans = mijloc;
		else if (c.size() == 1)
			ans = mijloc + (mijloc / c[0].first) * c[0].second;
		else {
			assert(c.size() == 2);
			for (int i = 0; i <= 5000 * 5000; i++) {
				i64 c1 = i * c[0].first;
				if (c1 > mijloc)
					break;
				int left = mijloc - c1;
				ans = max(ans, mijloc + i * c[0].second + (left / c[1].first) * c[1].second);
			}
		}
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from bisect import bisect_right

N,*A = map(int,read().split())

def LIS(seq):
    # 狭義
    N = len(seq)
    INF = 10**18
    dp = [INF] * (N+1)
    for x in seq:
        i = bisect_right(dp,x)
        dp[i] = x
    return bisect_right(dp,INF-1)

answer = LIS([-x for x in A])
print(answer)

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

int main(){
	int in, out;
	stack<int> stk;
	while( cin >> in ){
		
		if(in != 0){
			stk.push(in);
		}else{
			out = stk.top();
			cout << out << endl;
			stk.pop();
		}
	}
	return 0;
}

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

int main(){
  int N,M,X,Y;
  cin >>N>>M>>X>>Y;
  int x[N];
  int y[M];

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

  sort(x,x+N);
  sort(y,y+M);
  
  int flag=0;
  for (int j=0;j<Y-X;j++){
    if((X<X+j)&&(X+j<=Y)&&(x[N-1]<X+j)&&(y[0]>=X+j)){
    cout<<"No War"<<endl;
    return 0;
    }
  }

  cout<<"War"<<endl;

  return 0;
}

  


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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    int maxi = 0;
    for(int i=0;i<n;++i){
        string s;
        cin >> s;
        mp[s]++;
        maxi = max(maxi, mp[s]);
    }

    for(auto e: mp){
        if(e.second == maxi){
            cout << e.first << endl;
        }
    }

    return 0;
}

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

using namespace std;

#define ll long long int

ll f(ll b, ll n) {
	
	if(n < b)return n;
	
	return f(b,n/b) + n % b;
}

int main() {
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	ll n,s; cin >> n >> s;
	
	ll sq = sqrt(n);
	
	for(ll i = 2; i <= sq; i++) {
		if(f(i,n) == s) {
			cout << i << '\n';
			return 0;
		}
	}
	
	for(ll i = sq; i > 0; i--) {
		
		if(abs(n-s) % i != 0)continue;
		
		ll x = (n-s)/i + 1;
		
		if(x < 2)continue;
		if(x < sq)continue;
		if(x*i + (n%x) != n)continue;
		if(f(x,n) != s)continue;
			
		cout << x << '\n';
		return 0;
	}
	
	if(n == s) {
		cout << n+1 << '\n';
		return 0;
	}
	
	cout << -1 << '\n';
	
	return 0;
}

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

  int sum = 0;
  int i = 0;
  while(i < N){
    int l, r;
    cin >> l >> r;
	sum += (r - l) + 1;
    i++;
  }
  
  cout << sum << endl;
}

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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

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

int main(void)
{
	ll n, k; cin >> n >> k;
	string s, a; cin >> s;
	ll ans = 0;
	a = s;
	if(a[k-1]==tolower(a[k-1])) a[k-1] = toupper(a[k-1]);
	else a[k-1] = tolower(a[k-1]);
	cout << a << endl;
	return 0;
}

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

const int MAXN = 110;
const int NINF = 0xcfcfcfcf;
char buf[MAXN];
int H, W, dp[2][MAXN][MAXN][MAXN];
int pre[MAXN][MAXN];
void getmax(int & x, int y) { x < y ? x = y : 0; }
struct M {
	int l, r, u, d;
	M(int a1, int a2, int a3, int a4) {
		l = a1, r = a2, u = a3, d = a4;
	}
} ;
inline int gm(int x) { return x < 0 ? 0 : x; }
inline int in(M a, M b) {
	a.l = std::max(a.l, b.l);
	a.u = std::max(a.u, b.u);
	a.r = std::min(a.r, b.r);
	a.d = std::min(a.d, b.d);
	if (a.l > a.r || a.u > a.d) return 0;
	return pre[a.d][a.r] - pre[a.d][a.l - 1] - pre[a.u - 1][a.r] + pre[a.u - 1][a.l - 1];
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> H >> W;
	int X, Y;
	for (int i = 1; i <= H; ++i) {
		std::cin >> buf + 1;
		for (int j = 1; j <= W; ++j) {
			if (buf[j] == 'E') Y = i, X = j;
			else if (buf[j] == 'o') pre[i][j] = 1;
			pre[i][j] += pre[i][j - 1];
		}
	}
	for (int i = 1; i <= H; ++i)
		for (int j = 1; j <= W; ++j)
			pre[i][j] += pre[i - 1][j];
	int ans = 0;
	int now = 1, lst = 0;
	memset(dp, 0xcf, sizeof dp);
	dp[now][0][0][0] = 0;
	for (int u = 0; u < Y; ++u) {
		std::swap(lst, now);
		for (int d = 0; d <= H - Y; ++d)
		for (int l = 0; l < X; ++l)
		for (int r = 0; r <= W - X; ++r) {
			int & f = dp[now][d][l][r] = 0, t;
			M lim(r + 1, W - l, d + 1, H - u);
			if (u) {
				t = in(M(X - l, X + r, Y - u, Y - u), lim);
				getmax(f, dp[lst][d][l][r] + t);
			}
			if (d) {
				t = in(M(X - l, X + r, Y + d, Y + d), lim);
				getmax(f, dp[now][d - 1][l][r] + t);
			}
			if (l) {
				t = in(M(X - l, X - l, Y - u, Y + d), lim);
				getmax(f, dp[now][d][l - 1][r] + t);
			}
			if (r) {
				t = in(M(X + r, X + r, Y - u, Y + d), lim);
				getmax(f, dp[now][d][l][r - 1] + t);
			}
			getmax(ans, f);
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) (V).begin(),(V).end()

int main() {
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	string S;
	cin >> S;
	bool j = false;
	A--;B--;C--;D--;
	for (int i = B;i < D;i++) {
		if (S[i] == '#'&&S[i + 1] == '#') {
			cout << "No" << endl;
			return 0;
		}
		if (S[i - 1] != '#'&&S[i]!='#'&&S[i + 1] != '#') {
			j = true;
		}
	}
	if (D != N - 1 && S[D - 1] != '#' && S[D]!='#' && S[D + 1] != '#') {
		j = true;
	}
	if (!j&&C > D) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = A;i < C;i++) {
		if (S[i] == '#'&&S[i + 1] == '#') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 640
from operator import itemgetter


n = int(input())
red = {tuple(int(i) for i in input().split()): False for _ in range(n)}
blue = {tuple(int(i) for i in input().split()): False for _ in range(n)}
c = 0
for b in sorted(blue.keys()):
    for r in sorted(red.keys(), key=itemgetter(1), reverse=True):
        if not red[r] and b[0] > r[0] and b[1] > r[1]:
            red[r] = True
            blue[b] = True
            c += 1
            break
print(c)


Measured memory_bytes: 3064
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int n, m;
    cin >> n >> m;

    cout << (n - 1) * (m - 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int X, Y;
    cin >> X >> Y;

    int ax2 = 4 * X - Y;
    int bx2 = -2 * X + Y;

    if (ax2 >= 0 && ax2 % 2 == 0 && bx2 >= 0 && bx2 % 2 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
using namespace std;
int main(void){
    
    //変数：入出力文字「 ioString 」, 最初の4文字「 fastString 」, 残りの文字「 restString 」と置く
    string ioString, fastString, restString;
    //変数：交換回数「 m 」、交換場所を「 h 」と置く
    int m, h;
    
    cin >> ioString;

    
    while(1){
        if( ioString == "-") break;
        cin >> m;
        for(int i = 0; i < m; i++){
            cin >> h;
            //初期化：交換文字をクリアしている
            fastString.clear();
            restString.clear();
            //分割：入出力文字を分割している
            fastString.insert(0,ioString.substr(0,h));
            restString.insert(0,ioString.substr(h,ioString.size()-h));
            //初期化・入替文字代入している
            ioString.clear();
            ioString = restString + fastString;
        }
        cout << ioString << endl;
        cin >> ioString;
    }
    
}



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

long long int n, a, b;
cin >> n >> a >> b;
long long int q=0, r=0;
q=n/(a+b);
r=n%(a+b);

if(n==a+b) cout<< a << endl;
else if (n>a+b){
    if (r<a) cout << q*a + r << endl;
    else cout << q*a + a << endl;
}
else if (n<a+b){
    if (n<a) cout << n << endl;
    else cout << a << endl;
}

}

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

int main() {
    string s;
  	int connter = 0;
    cin >> s;
    int counter = 0;
    if (s[0] == '1') ++counter;
    if (s[1] == '1') ++counter;
    if (s[2] == '1') ++counter;
    cout << counter << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <string>
#include <sstream>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int main(){
	int n, m;
	double l[20],a[20],b[20];
	double ans = 0.0;
	scanf("%d%d", &n, &m);
	rep(i,n) scanf("%lf%lf%lf", &l[i], &a[i], &b[i]);
	for(int i = 0; i <= 1<<20; i++){
		bitset<25> bi(i);
		if(bi.count() != m) continue;
		Vi vec;
		rep(j,n) if(bi[j]) vec.pb(j);
		double sum = 0.0;
		rep(j,vec.size()){
			for(int k = j+1; k < vec.size(); k++){
				sum += (l[vec[j]]-l[vec[k]])*(l[vec[j]]-l[vec[k]])+(a[vec[j]]-a[vec[k]])*(a[vec[j]]-a[vec[k]])+(b[vec[j]]-b[vec[k]])*(b[vec[j]]-b[vec[k]]);
			}
		}
		ans = max(ans,sum);
	}
	printf("%.9f\n", ans);
}

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

const int N=101;

int n,m,sx,sy;
short ans;
short dp[N][N][N][N],s1[N][N],s2[N][N];
char s[N];

short Max(short a,short b){
	if (a>=b) return a;
	return b;
}

int main(){
	int i,j,k,l;
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++){
		scanf("%s",s+1);
		for (j=1;j<=m;j++){
			if (s[j]=='E') sx=i,sy=j;
			s1[i][j]=s2[i][j]=(s[j]=='o');
			s1[i][j]+=s1[i][j-1];
			s2[i][j]+=s2[i-1][j];
		}
	}
	for (i=sx;i>=1;i--)
		for (j=sy;j>=1;j--)
			for (k=sx;k<=n;k++)
				for (l=sy;l<=m;l++){
					ans=max(ans,dp[i][j][k][l]);
					if (i>1&&i+sx>k+1) dp[i-1][j][k][l]=Max(dp[i-1][j][k][l],dp[i][j][k][l]+s1[i-1][min(l,m-sy+j)]-s1[i-1][max((int)j-1,l-sy)]);
					if (k<n&&sx+k<n+i) dp[i][j][k+1][l]=Max(dp[i][j][k+1][l],dp[i][j][k][l]+s1[k+1][min(l,m-sy+j)]-s1[k+1][max(j-1,l-sy)]);
					if (j>1&&j+sy>l+1) dp[i][j-1][k][l]=Max(dp[i][j-1][k][l],dp[i][j][k][l]+s2[min(k,n-sx+i)][j-1]-s2[max(i-1,k-sx)][j-1]);
					if (l<m&&sy+l<m+j) dp[i][j][k][l+1]=Max(dp[i][j][k][l+1],dp[i][j][k][l]+s2[min(k,n-sx+i)][l+1]-s2[max(i-1,k-sx)][l+1]);
				}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 201088
#include <cstdio>

using namespace std;

int main()
{
	int a, b, c, d;
	scanf("%d %d", &a,&b);
	if(a==1 || b==1){
		if(a==b){
			printf("Draw");
		}
		else if(a>b){
			printf("Bob");
		}
		else {
			printf("Alice");
		}
		}
	
	else {
		if(a==b){
			printf("Draw");
		}
		else if(a>b){
			printf("Alice");
		}
		else {
			printf("Bob");
		}
	}
}



Measured memory_bytes: 128
memo = [[0, 1]]

def f(n, b, p, k):
	if b+p == k: return [b, p]
	if n == 0: return [b, p+1]
	newlst1 = [b+1, p]
	if newlst1[0]+newlst1[1] == k: return newlst1
	newlst2 = [newlst1[0]+memo[n-1][0], newlst1[1]+memo[n-1][1]]
	if newlst2[0] + newlst2[1] == k: return newlst2
	if newlst2[0] + newlst2[1] > k: return f(n-1, newlst1[0], newlst1[1], k)
	newlst3 = [newlst2[0], newlst2[1]+1]
	if newlst3[0]+newlst3[1] == k: return newlst3
	newlst4 = [newlst3[0]+memo[n-1][0], newlst3[1]+memo[n-1][1]]
	if newlst4[0]+newlst4[1] == k: return newlst4
	if newlst4[0]+newlst4[1] > k: return f(n-1, newlst3[0], newlst3[1], k)
	return [newlst4[0]+1, newlst4[1]]

N, K = map(int, input().split())
for i in range(1, N):
	memo.append([2*memo[i-1][0]+2, 2*memo[i-1][1]+1])
print(f(N, 0, 0, K)[1])

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MS=2510,MN=60;
const ll INF=1e18;
struct edge{
    int to,money;
    ll  time;
    edge(){}
    edge(int _to,int _money,ll _time)
    {to=_to,money=_money,time=_time;}
    bool operator <(edge tmp) const
    {return time>tmp.time;}
};
vector<edge> g[MN];
int n,m,s;
ll dp[MN][MS+10],ans[MN];
int main()
{
    scanf("%d%d%d",&n,&m,&s);
    for(int i=0,u,v,a,b;i<m;i++)
    {
        scanf("%d%d%d%d",&u,&v,&a,&b);
        g[u].emplace_back(v,a,(ll)b);
        g[v].emplace_back(u,a,(ll)b);
    }
    for(int i=1,c,d;i<=n;i++)
    {
        scanf("%d%d",&c,&d);
        g[i].emplace_back(i,-c,(ll)d);
    }
    for(int i=0;i<MN;i++)
        for(int j=0;j<MS+10;j++)
            dp[i][j]=INF;
    for(int i=0;i<MN;i++)
        ans[i]=INF;
    priority_queue<edge> q;
    q.emplace(1,min(MS,s),0);
    while(!q.empty())
    {
        edge tmp=q.top();q.pop();
        int u=tmp.to,money=tmp.money;ll time=tmp.time;
        if(time>=dp[u][min(MS,money)])
            continue;
        dp[u][min(MS,money)]=time;
        ans[u]=min(time,ans[u]);
        for(auto e: g[u])
            if(money-e.money>=0)
                q.emplace(e.to,money-e.money,time+e.time);
    }
    for(int i=2;i<=n;i++)
        printf("%lld\n",ans[i]);
    return 0;
}


Measured memory_bytes: 12844
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    static int N;
    static int A;
    static int B;
    static int C;
    static int[] l;
    static int ans = int.MaxValue;
    static void Main(string[] args)
    {
        int[] NABC = ReadLineParseIntArray();
        N = NABC[0];
        A = NABC[1];
        B = NABC[2];
        C = NABC[3];
        l = new int[N];
        for(int i = 0; i < N; i++)
            l[i] = ReadLineParseInt();
        BFS(0, 0, 0, 0, -30);
        WriteLine(ans);
    }
    static void BFS(int d, int a, int b, int c, int p)
    {
        if (d == N)
        {
            ans = Min(ans, Abs(a - A) + Abs(b - B) + Abs(c - C) + p + (Min(Min(a, b), c) == 0 ? 100000000 : 0));
            return;
        }
        BFS(d + 1, a, b, c, p);
        BFS(d + 1, a + l[d], b, c, p + 10);
        BFS(d + 1, a, b + l[d], c, p + 10);
        BFS(d + 1, a, b, c + l[d], p + 10);
    }
    static int ReadLineParseInt() => int.Parse(ReadLine());
    static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
}

Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int s[4];
char f[4];

void dfs(int i, int res) {
	if (i == 3) {
		if (res == 7) {
			cout << s[0] << f[0] << s[1] << f[1] << s[2] << f[2] << s[3] << "=7" << endl;
			exit(0);
		}
		return;
	}
	f[i] = '-';
	dfs(i + 1, res - s[i + 1]);
	f[i] = '+';
	dfs(i + 1, res + s[i + 1]);
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	char str[4]; cin >> str;
	rep(i, 4)s[i] = str[i] - '0';
	dfs(0, s[0]);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

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

int main(){
  bool flag=false,hantei=true;;
  string S[100];
  int H,W;
  cin>>H>>W;
  for(int i=0;i<H;i++) cin>>S[i];

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++,flag=false){
      if(S[i][j]=='#'){
        for(int k=0;k<4;k++){
          int ny=i+dy[k],nx=j+dx[k];
          if(ny>=0 && nx>=0 && ny<H && nx<W && S[ny][nx]=='#') flag=true;
        }
        if(!flag){
          hantei=false;
          break;
        }
      }
    }
  }

  if(hantei) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <numeric>
#include <functional>
using namespace std;
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(void){
  int X;
  cin >> X;
  for (int i = X; i < (4+100000); i++){
    
    if (IsPrime(i)){
      cout << i << endl;
      break;
    }
  }
}

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

using namespace std;
using ll = long long;

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

	ll a, b, c, k;
	cin >> a >> b >> c >> k;

	cout << (k%2==0 ? a-b : b-a) << endl;

	return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;
  bool jg=true;
  for(int i=0;i<A;i++) {
    if(!(S[i]>='0' && S[i] <= '9')) {
      jg=false;
    }
  }
  if(S[A]!='-') jg=false;

  for(int i=A+1;i<A+B;i++) {
    if(!(S[i]>='0' && S[i] <= '9')) {
      jg=false;
    }
  }
  if(jg) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline()[:-1]

from collections import defaultdict

sys.setrecursionlimit(10 ** 7)


def dfs(v, parent, d):
    depth[v] = d
    for to, cost in tree[v]:
        if to == parent:
            continue
        dfs(to, v, d + cost)


depth = defaultdict(int)
tree = defaultdict(set)
n = int(input())
for i in range(n-1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    tree[a].add((b, c))
    tree[b].add((a, c))

q, k = map(int, input().split())
k -= 1

# k からの距離をすべて求める
dfs(k, -1, 0)
for i in range(q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    # (k - x の距離) + (k - y の距離)
    print(depth[x] + depth[y])


Measured memory_bytes: 155640
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll x,y;
	cin>>x>>y;
	ll lcm=0;
	ll a=x,b=y,r=1;
	while(b!=0){
		r=a%b;
		a=b;
		b=r;
	}
	lcm=x/a*y;
	for(ll i=0;i<=lcm;i+=x){
		if(i%y!=0){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 256
firstinput = input("")
secondinput = input("")
firstinputsplit = firstinput.split(" ")
secondinputsplit = secondinput.split(" ")
H = int(firstinputsplit[0])
N = int(firstinputsplit[1])
firstcont = H <= 1000000000 and N <= 1000000
skill = 0
exe = 0
for i in secondinputsplit:
    skill = skill + int(i)
    exe = exe + 1
if firstcont == True and exe == len(secondinputsplit):
  if H <= skill:
    print("Yes")
  else:
    print("No")
else:
  print(H)
  

  


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

using namespace std ; 

int main () { 
	
	string a ; 
	string b ; 
	vector <char> str ; 
	
	cin >> a >> b ; 
	for ( int i = 0 ; i < a.size()-1 ; i ++ ) {
	str.push_back(a[i]);
	str.push_back(b[i]) ;  
     }
     str.push_back(a[a.size()-1]);
     if ( a.size() == b.size() ) {
		str.push_back(b[b.size()-1]) ;  
	 }
	for ( auto & s : str ) 
		cout << s ; 
		cout << endl ; 
	
}


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


struct UnionFind{
  vector<int> r,p;
  vector<vector<int> > v;
  UnionFind(){}
  UnionFind(int size){init(size);}
  void init(int size){
    r.resize(size,0);
    p.resize(size,0);
    v.resize(size);
    for(int i=0;i<size;i++){
      r[i]=1,p[i]=i;
      v[i].resize(1,i);
    }
  }
  bool same(int x,int y){
    return p[x]==p[y];
  }
  void unite(int x,int y){
    x=p[x];y=p[y];
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    for(int i=0;i<(int)v[y].size();i++){
      p[v[y][i]]=x;
      v[x].push_back(v[y][i]);
    }
    v[y].clear();
  }
};
signed main(){
  int n,q;
  cin>>n>>q;
  UnionFind uf(n);
  for(int i=0;i<q;i++){
    int c,x,y;
    cin>>c>>x>>y;
    if(c) cout<<uf.same(x,y)<<endl;
    else uf.unite(x,y);
  }
  return 0;
}

Measured memory_bytes: 3968