akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 5005
#define M 10005
#define ll long long
#define mod 1000000007
void Read(int &p)
{
	p = 0;
	char c = getchar();
	for (; c < '0' || c > '9'; c = getchar());
	for (; c >= '0' && c <= '9'; c = getchar())p = p * 10 + c - '0';
}
int n, tar[M], nex[M], fir[N], cnt;
int siz[N];
int dp[N][N], f[N], g[N];
void Add(int a, int b)
{
	++cnt;
	tar[cnt] = b;
	nex[cnt] = fir[a];
	fir[a] = cnt;
}
void Dfs(int r, int fa)
{
	siz[r] = 1;
	dp[r][1] = 1;
	for (int i = fir[r]; i; i = nex[i])
	{
		int v = tar[i];
		if (v != fa)
		{
			Dfs(v, r);
		    for (int j = 0; j <= siz[r]; j++)
			{
				g[j] = dp[r][j];
				dp[r][j] = 0;
			}
			for (int j = 0; j <= siz[r]; j++)
				for (int k = 0; k <= siz[v]; k++)
					dp[r][j + k] = (dp[r][j + k] + (ll)g[j] * dp[v][k]) % mod;
			siz[r] += siz[v];
		}
	}
	for (int i = 0; i <= siz[r]; i++)
		dp[r][0] = (dp[r][0] - (ll)dp[r][i] * f[i]) % mod;
}
int main()
{
	Read(n);
	for (int i = 1; i < n; i++)
	{
		int u, v;
		Read(u), Read(v);
		Add(u, v), Add(v, u);
	}
	f[0] = 1;
	for (int i = 1; i <= n; i++)
	{
		if (i & 1)continue;
		f[i] = (ll)f[i - 2] * (i - 1) % mod;
	}
	Dfs(1, 0);
	int ans = -dp[1][0];
	if (ans < 0)
		ans += mod;
	printf("%d\n", ans);
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a < c && c < b){
    cout << "Yes" << endl;
  }else if(b < c && c < a){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}

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

int N;
int K;

vector<i64> x,y;

i64 INF = 3999999996000000002LL;

i64 ans(vector<i64>& X,vector<i64>& Y,int f = 0){
  if(X.size() == 4){
    i64 MINx = *min_element(X.begin(),X.end());
    i64 MAXx = *max_element(X.begin(),X.end());
    i64 MINy = *min_element(Y.begin(),Y.end());
    i64 MAXy = *max_element(Y.begin(),Y.end());

    int cou = 0;
    rep(i,0,N - 1){
      if(MINx <= x[i] && x[i] <= MAXx && MINy <= y[i] && y[i] <= MAXy){
        cou++;
      }
    }

    if(cou >= K){
      return (MAXx - MINx) * (MAXy - MINy);
    }
    else return INF;
  }
  i64 res = INF;
  rep(i,f,N - 1){
    X.push_back(x[i]);
    Y.push_back(y[i]);
    res = min(res,ans(X,Y));
    X.pop_back();
    Y.pop_back();
  }
  return res;
}

int main(){
  cin >> N >> K;
  x.resize(N);
  y.resize(N);
  rep(i,0,N - 1){
    cin >> x[i] >> y[i];
  }
  vector<i64> t1,t2;
  cout << ans(t1,t2,0) << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);

signed main(){
    ll x,y,ans=3*INF;cin>>x>>y;

    if(x<=y){
        ans=min(y-x,abs(y+x)+1);
    }else{
        if(x*y>0){
            ans=x-y+2;
        }else{
            ans=1+abs(x+y);
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n;
	cin >> n;
	n %= 10;
	if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9) cout << "hon";
	else if(n == 0 || n == 1 || n == 6 || n == 8) cout << "pon";
	else cout << "bon";
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 1000000000;
typedef pair<int, int> P;
const int MAX_N = 1000000;
const int MAX_L = 100000000;
const int MAX_SQRT_B = 10000;
typedef int64_t ll;
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; }

int N, M;
int WA[105000];
bool AC[1050000];

void solve() {
    cin >> N >> M;
    int WAnum = 0;
    int ACnum = 0;
    for (int i = 1; i <= N; i++)
    {
        WA[i] = 0;
        AC[i] = false;
    }
    while (M--)
    {
        int p;
        string S;
        cin >> p >> S;
        if (AC[p])continue;
        if (S=="AC")
        {
            AC[p] = true;
            ACnum++;
            WAnum += WA[p];
        }
        else if (S == "WA") {
            WA[p]++;
        }
    }
    cout << ACnum << " " << WAnum << endl;
    return;
}

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

Measured memory_bytes: 4072
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
//long long num[100000];
int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.length();i+=2){
		cout<<s[i];
	}
	return 0;
}

Measured memory_bytes: 512
/*-------enazuma11----------------*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define F first
#define S second
#define M 1000000007
 
/* int x[]={-1,-1,0,1,1,1,0,-1};
int y[]={0,1,1,1,0,-1,-1,-1};
*/
/* int x[]={-1,0,1,0};
int y[]={0,1,0,-1};
*/

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
	//	cin>>t;
	while(t--){
		int n;
		cin>>n;
		vector<string> v;
		map<string,ll> mp;
		string s;
		rep(i,0,n){
			cin>>s;
			sort(all(s));
			v.pb(s);
			mp[s]++;
		}
		ll ans=0;
		for(auto i:mp)
		{
			ll req=i.S*(i.S-1)/2;
			ans+=req;
			
		}
		cout<<ans<<'\n';
	}
	return 0;
}


Measured memory_bytes: 16628
/*input
ha
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = unsigned long long;
using ld = long double;
using pii = pair<ll,ll>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=1e18;
const int INF=1e6+1;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
const ll maxn=2e5+5;
const ll maxlg=__lg(maxn)+2;
int main(){
    string s;
    cin>>s;
    if(sz(s)%2){
        cout<<"No";
        return 0;
    }
    REP(i,sz(s)){
        if(i%2 and s[i]!='i'){
            cout<<"No";
            return 0;
        }
        if(i%2==0 and s[i]!='h'){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}

Measured memory_bytes: 256
A = list(map(int,input().split( )))
a=A[0]
b=A[1]
k=A[2]
x=0
for h in range(100):
	i= (b if a>b else a)-h
	if a%i + b%i:
		continue
	x=x+1
	if x == k:
		break
print(i)


Measured memory_bytes: 3060
// cities to vapori-
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz // math is your friend
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define REP(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int main(){

	fastio;
	long double x;
	cin >> x;

	cout << fixed << setprecision(10) << x*x*x/27 << endl;

	return 0;
}


Measured memory_bytes: 256
def e_sequence_decomposing(N, A):
    # 求める解は、「与えられた数列の、単調非増加部分列の長さの最大値」
    # なので、「与えられた数列を逆にした数列の、単調非減少部分列の長さの最大値」
    # を求める。これは Longest Increasing Subsequence の考え方を援用できる。
    import bisect

    # lnds[k]: ある要素まで見たときにk+1個の非減少部分列が作れるもののうち、
    # 最も要素の値が小さいもの
    lnds = []  # Longest Non-Decreasing Subsequence

    for a in A[::-1]:
        idx = bisect.bisect_right(lnds, a)
        if idx == len(lnds):
            lnds.append(a)
        else:
            lnds[idx] = a
    return len(lnds)

N = int(input())
A = [int(input()) for _ in range(N)]
print(e_sequence_decomposing(N, A))

Measured memory_bytes: 8604
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
const long long mod=1000000007;
long long fac[40007],inv[40003];
inline long long power_mod(long long p,long long q){
    long long ret=1;
    while(q){
        if(q&1)ret=ret*p%mod;
        p=p*p%mod;
        q>>=1;
    }
    return ret;
}
inline long long C(int x,int y){
    return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
long long n,a[2000007],b[2000007],dp[4007][4007];
int main(){
    fac[0]=1;
    for(int i=1;i<=40003;++i){
    	fac[i]=fac[i-1]*i%mod;
	}
    inv[40003]=power_mod(fac[40003],mod-2);
    for(int i=40003-1;i>=0;--i){
    	inv[i]=inv[i+1]*(i+1)%mod;
	}
    cin>>n;
    for(int i=1;i<=n;i++){
    	cin>>a[i]>>b[i];
        dp[2001-a[i]][2001-b[i]]++;
    }
    for(int i=1;i<=4001;i++){
    	for(int j=1;j<=4001;j++){
            dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
            dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
        }
	}
    long long ans=0;
    for(int i=1;i<=n;i++){
    	ans=(ans+dp[2001+a[i]][2001+b[i]])%mod;
	}
    for(int i=1;i<=n;i++){
		ans=(ans-C(a[i]+a[i]+b[i]+b[i],a[i]+a[i])+mod)%mod;
	}
    cout<<ans*power_mod(2,mod-2)%mod<<endl;
    return 0;
}

Measured memory_bytes: 134016
n = int(input())

a = []

for i in range(n):
	a.append( int( input() ) )

a	= sorted(a)#小さい順に並べたリストを返してくれる
a.reverse()#リストの中身を逆向きに並べ替えてくれる

tmp = a[0]#先に代入
ans = 1

for i in range(1, n):
	if a[i] != tmp:
		ans = ans + 1
	tmp = a[i]
	
print(ans)

Measured memory_bytes: 3060
# 写経
# https://atcoder.jp/contests/dp/submissions/6401166
# 私が再帰関数でTLEした計算方法だが、
# 3重ループを使うと、間に合うらしい

def main():
    from collections import Counter

    def tami(i, j, k):
        if i is 0 and j is 0 and k is 0:
            return

        res = fN
        if i is 0:
            pass
        else:
            res += dp[i - 1][j][k] * i
        if j is 0:
            pass
        else:
            res += dp[i + 1][j - 1][k] * j
        if k is 0:
            pass
        else:
            res += dp[i][j + 1][k - 1] * k
        res *= divTable[i + j + k]

        dp[i][j][k] = res
        return

    N = int(input())
    fN = float(N)
    a = list(map(int, input().split()))

    c = Counter(a)
    one = c[1]
    two = c[2]
    three = c[3]

    dp = tuple(tuple([0.0] * (N + 1) for _ in range(N + 1)) for _ in range(N + 1))

    divTable = [1]
    for i in range(1, N * 3 + 1):
        divTable.append(1.0 / i)

    for k in range(N + 1):
        for j in range(N - k + 1):
            for i in range(N - k - j + 1):
                tami(i, j, k)

    print(dp[one][two][three])


if __name__ == '__main__':
    main()


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


signed main(){

    int a, b;

    std::cin >> a >> b;

    if (a > b){
        std::cout << "a > b" << std::endl;
    }
    else if (a < b){
        std::cout << "a < b" << std::endl;
    }
    else if (a == b){
        std::cout << "a == b" << std::endl;
    }

    return 0;

}


Measured memory_bytes: 3076
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>

using namespace std;

typedef long long LL;

const int mod = 1e9 + 7;

int qmi(int a, int k)
{
    int res = 1;
    while(k)
    {
        if(k & 1)  res = (LL)res * a % mod;
        k >>= 1;
        a = (LL)a * a % mod;
    }
    return res;
}

int C(int a, int b)
{
    if(a < b)  return 0;
    
    int up = 1, down = 1;
    for(int i = a, j = b; j; i --, j --)
    {
        up = (LL)up * i % mod;
        down = (LL)down * j % mod;
    }
    return (LL)up * qmi(down, mod - 2) % mod;
}

int main()
{
    //init(N - 1);
    
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    
    int res = (((LL)qmi(2, n) - 1 - C(n, a) - C(n, b)) % mod + mod) % mod;
    printf("%d", res);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())
const double pi = 3.14159265358979323846;

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

    ll i,j,n;
    cin>>n;
    vector<ll> a(n);
    map<ll,ll> mp;
    ll s = 0;
    for(i=0;i<n;i++) cin>>a[i],mp[a[i]]++,s+=a[i];
    ll q;
    cin>>q;
    ll b,c;
    for(i=0;i<q;i++)
    {
        cin>>b>>c;
        s-=(mp[b]*b);
        s+=(mp[b]*c);
        mp[c] += mp[b];
        mp[b] = 0;
        cout<<s<<"\n";
    }
}

Measured memory_bytes: 9996
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int V,M;
const int MAX_V=100050;
vector<int> G[MAX_V];
vector<int> rG[MAX_V]; //辺の向きを逆にした
vector<int> vs; //帰りがけ順の並び
bool used[MAX_V]; //すでに調べたか
int cmp[MAX_V]; //属する強連結成分のトポロジカル順序(小さい方からお大きい方に辺が張られる)

void add_edge(int from, int to){
    G[from].pb(to);
    rG[to].pb(from);
}

void dfs(int v){
    used[v]=true;
    rep(i,0,sz(G[v])){
        if(!used[G[v][i]]) dfs(G[v][i]);
    }
    vs.pb(v);
}
void rdfs(int v,int k){
    used[v]=true;
    cmp[v]=k;
    rep(i,0,sz(rG[v])){
        if(!used[rG[v][i]]) rdfs(rG[v][i],k);
    }
}
// 強連結成分の数を返す
int scc(){
    memset(used,0,sizeof(used));
    vs.clear();
    rep(v,0,V){
        if(!used[v]) dfs(v);
    }
    memset(used,0,sizeof(used));
    int k=0;
    rer(i,sz(vs),0){
        if(!used[vs[i]]) rdfs(vs[i],k++);
    }
    return k;
}
int par[100010];
int top[100010];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>V>>M;
    rep(i,0,V-1+M){
        int a,b;
        cin>>a>>b;
        add_edge(a-1, b-1);
    }
    scc();
    rep(i,0,V){
        top[cmp[i]]=i;
    }
    par[top[0]]=0;
    rep(i,1,V){
        if(sz(rG[top[i]])==1) par[top[i]]=rG[top[i]][0]+1;
        else{
            int res=0;
            rep(j,0,sz(rG[top[i]])){
                res=max(res,cmp[rG[top[i]][j]]);
            }
            par[top[i]]=top[res]+1;
        }
    }
    rep(i,0,V){
        cout <<par[i]<<"\n";
    }
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FORR(i, m, n) for(int i = m; i >= n; i--)

using namespace std;

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

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

	int a, b, x;
	cin >> a >> b >> x;

	cout << ((a <= x and x <= a+b) ? "YES" : "NO") << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

class Main {
    static long MOD = (long)Math.pow(10, 9) + 7;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        String s = in.next();
        String t = in.next();
        for (int i=0; i<N; i++) {
            System.out.print(s.charAt(i));
            System.out.print(t.charAt(i));
        }
    }
}

Measured memory_bytes: 19796
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 202 , P = 998244353;
int n,pw[N]={1};
pii p[N];

int main(){
    rep(i,1,N) pw[i]=pw[i-1]*2%P;
    cin >> n;
    rep(i,0,n) cin >> p[i].fi >> p[i].se;
    sort(p , p + n);
    int ans = (pw[n]+P-1)%P , del = 0;
    rep(i,0,n) {
        map<pii,int> vis;
        rep(j,i+1,n){
            int dx=p[j].fi-p[i].fi;
            int dy=p[j].se-p[i].se;
            if(dx==0) dy=1;
            else if(dy==0) dx=1;
            else {
                int g=__gcd(dx,abs(dy));
                dx/=g,dy/=g;
            }
            vis[mp(dx,dy)]++;
        }
        for(auto e : vis) (del += pw[e.se] - 1) %= P;
        (del += 1) %= P;
    }
    (ans += P - del) %= P;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = input()
l = input().split()
data = []
for i in range(int(min(l)), int(max(l))+1):
    sum_l = 0
    for j in range(len(l)):
        sum_l = sum_l + (int(l[j])-i)**2
    data.append(sum_l)

print(min(data))

Measured memory_bytes: 3060
/*
ID: c4ts0up
LANG: C++
TASK: Caracal vs Monster
URL: 
*/
#include <bits/stdc++.h>
#define ll long long 
using namespace std;

ll h, cnt, level;

int main() {
	cin >> h;
	
	level = 0;
	cnt = 1;
	
	while (h > 1) {
		level += cnt;
		cnt *= 2;
		h /= 2;
	}
	
	level += cnt;
	cout << level << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    int x[200];
    int sum=0;
    for(int i=0;i<a;i++){
        cin>>x[i];
        if(b-x[i]>=x[i]-0){
            sum+=x[i]*2;
        }else{
            sum+=(b-x[i])*2;
        }
    }
    cout<<sum<<endl;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  for(int i=0; i<N; i++) cin >> X.at(i);
  int mincost = 0;
  for(int i=0; i<N; i++) mincost += (X.at(i) - 1) * (X.at(i) - 1); 
  int pcost;
  for(int i=2; i<=100; i++){
    pcost = 0;
    for(int j=0; j<N; j++) pcost += (X.at(j) - i) * (X.at(j) - i);
    if(pcost < mincost){
      mincost = pcost;
    }
  }
  cout << mincost << endl;
}

Measured memory_bytes: 256
# ABC161b


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    ans = 0
    s = sum(a)
    for i in a:
        if i >= s / 4 / m:
            ans += 1
    if ans >= m:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
from collections import Counter


repeated = input().strip()
num_repeat = int(input())

len_repeated = len(repeated)

if len_repeated == 1:
    print(num_repeat // 2)

elif len_repeated == 2:
    if repeated[0] == repeated[1]:
        print(num_repeat)
    else:
        print(0)

else:
    c = Counter(repeated)
    # characters are all same, like aaa
    if len(c) == 1:
        print((num_repeat * len_repeated) // 2)
    #
    else:
        arr = [1]
        for i in range(1, len_repeated):
            if repeated[i - 1] == repeated[i]:
                arr[-1] += 1
            else:
                arr.append(1)

        if repeated[0] == repeated[-1]:
            change_first = sum([i//2 for i in arr[:-1]])
            change_last = arr[-1] // 2
            elem = arr.pop(0) + arr.pop(-1)
            arr.append(elem)
            change_rep = sum([i//2 for i in arr])
            print(change_first + change_rep * (num_repeat-1) + change_last)

        else:
            print(sum([i//2 for i in arr]) * num_repeat)

exit(0)


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int N, M, Q;
vector<int> a, b, c, d;

int ans = 0;
void dfs(vector<int> &A) {
  // 終了条件
  // 狙った桁が完成したら、何らかの処理を行う
  if(A.size() == N) {
    int tmp = 0;
    for(int i = 0; i < Q; ++i) {
      if(A[b[i] - 1] - A[a[i] - 1] == c[i]) {
        tmp += d[i];
      }
    }

    if(ans < tmp) {
      ans = tmp;
    }
    return;
  }

  int start;
  if(A.empty()) {
    start = 1;
  } else {
    start = A[A.size() - 1];
  }
  for(int v = start; v <= M; ++v) {
    A.push_back(v);
    dfs(A);
    A.pop_back();
  }
}

int main() {
  cin >> N >> M >> Q;
  a.resize(Q);
  b.resize(Q);
  c.resize(Q);
  d.resize(Q);
  REP(i, Q) cin >> a[i] >> b[i] >> c[i] >> d[i];

  vector<int> A;
  dfs(A);
  cout << ans << endl;
}

Measured memory_bytes: 3596
n = int(input())
 
talk = [[] for _ in range(n)]
for i in range(n):
    tmp = int(input())
    for j in range(tmp):
        person, state = map(int, input().split())
        talk[i].append([person-1, state])
#print(talk)

from itertools import product
s = [0,1]
ptns = sorted(list(product(s, repeat=n)), reverse=1)
#print(ptns)

for i in range(len(ptns)):
    for j in range(n):
        if ptns[i][j] == 1: 
            for k in talk[j]:
                if ptns[i][k[0]] != k[1]:
                    break
            else:
                continue
            break
    else:
        print(sum(ptns[i]))
        exit()

Measured memory_bytes: 9076
mod = 10**9 + 7
n, m = map(int, input().split())
a = [True]*(n+1)
for _ in range(m): a[int(input())] = False
dp = [0]*(n+1)
dp[0] = 1
if a[1]: dp[1] = 1
for i in range(2, n+1):
    if a[i-2]: dp[i] += dp[i-2]
    if a[i-1]: dp[i] += dp[i-1]
    dp[i] %= mod
print(dp[-1])

Measured memory_bytes: 7768
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

const INF: i64 = 1 << 50;

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize, m: usize,
        ac: [(i64, [usize1]); m],
    }
    let mut trans = vec![INF; 1 << n];
    for (a, c) in ac {
        let mut s = 0;
        for c in c { s |= 1 << c; }
        trans[s] = min(trans[s], a);
    }
    let mut dp = vec![INF; 1 << n];
    dp[0] = 0;
    for a in 0..1 << n {
        for b in 0..1 << n {
            dp[a | b] = min(dp[a | b], dp[a] + trans[b]);
        }
    }
    let ans = dp[(1 << n) - 1];
    puts!("{}\n", if ans >= INF { -1 } else { ans });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int cnt_r=0,cnt_l=0;
  for(int i=0; i<N; i++){
    if(S[i]=='('){
      cnt_r++;
    }else{
      if(cnt_r){
        cnt_r--;
      }else{
        cnt_l++;
      }
    }
  }
  for(int i=0; i<cnt_l; i++){
    cout << '(';
  }
  cout << S;
  for(int i=0; i<cnt_r; i++){
    cout << ')';
  }
  cout << endl;
  return 0;
}


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

class SatisfactionScore {
 public:
  int d;
  vector<int> c;
  vector<vector<int>> s;
  vector<int> t;
  vector<set<int>> u;
  int v;

  SatisfactionScore(int d_)
      : d(d_), c(26), s(d_, vector<int>(26)), t(d_), u(26, {0, d_ + 1}), v(0) {}

  int InitialScore() {
    vector<int> l(26, 0);
    v = 0;
    rep(i, d) {
      v += s[i][t[i] - 1];
      l[t[i] - 1] = i + 1;
      rep(j, 26) { v -= c[j] * (i + 1 - l[j]); }
    }
    return v;
  }

  int ModifiedScore(int di, int qi) {
    int pi = t[di - 1];
    int ret = v + s[di - 1][qi - 1] - s[di - 1][pi - 1];

    for (auto i : {pi - 1, qi - 1}) {
      auto itr = u[i].upper_bound(di);
      int nd = *(itr);
      advance(itr, (i == pi - 1) ? -2 : -1);
      int pd = *(itr);

      int delta = c[i] * (di - pd) * (nd - di);
      ret += (i == pi - 1) ? -delta : delta;
    }

    return ret;
  }

  void Update(int di, int qi, int nv) {
    v = nv;
    u[qi - 1].insert(di);
    u[t[di - 1] - 1].erase(di);
    t[di - 1] = qi;
  }
};

int main() {
  int d;
  cin >> d;
  SatisfactionScore ss(d);
  rep(i, 26) cin >> ss.c[i];
  rep(i, d) rep(j, 26) cin >> ss.s[i][j];
  rep(i, d) {
    cin >> ss.t[i];
    ss.u[ss.t[i] - 1].insert(i + 1);
  }
  int cv = ss.InitialScore();

  int m;
  cin >> m;
  rep(i, m) {
    int di, qi;
    cin >> di >> qi;
    cv = ss.ModifiedScore(di, qi);
    ss.Update(di, qi, cv);
    cout << cv << endl;
  }

  return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B,M;
  cin>>A>>B>>M;
  vector<int> reizouko(A);
  vector<int> renji(B);
  priority_queue<int, vector<int>, greater<int>> minA;
  priority_queue<int, vector<int>, greater<int>> minB;
  priority_queue<int, vector<int>, greater<int>> price;
  for(int i=0; i<A; i++){
    int a;
    cin>>a;
    reizouko.at(i)=a;
    minA.push(a);
  }
  for(int i=0; i<B; i++){
    int b;
    cin>>b;
    renji.at(i)=b;
    minB.push(b);
  }

  price.push(minA.top()+minB.top());
  for(int i=0; i<M; i++){
    int x, y, c;
    cin>>x>>y>>c;
    price.push(reizouko.at(x-1)+renji.at(y-1)-c);
  }
  cout << price.top() << endl;
}


Measured memory_bytes: 2552
import heapq
import math

n, m = map(int, input().split())
a = [-1*int(x) for x in input().split()]
heapq.heapify(a)
 
for _ in range(m):
    min_a = heapq.heappop(a)
    heapq.heappush(a, math.ceil(min_a / 2))
    
print(sum(a)*(-1))





Measured memory_bytes: 14536
def resolve():
    S = input()
    N = len(S)
    L1 = (N-1)//2
    L2 = (N+3)//2

    if S[0:L1] == S[L2-1:N]:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 2940
answer = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 3, 8, 8, 11, 11, 11, 11, 14, 14, 32, 32, 35, 35, 35, 35, 42, 42, 42, 42, 49, 49, 49, 49, 49, 49, 75, 75, 86, 86, 86, 86, 86, 86, 123, 123, 131, 131, 131, 131, 148, 148, 153, 153, 170, 170, 170, 170, 170, 170, 227, 227, 227, 227, 227, 227, 250, 250, 323, 323, 324, 324, 324, 324, 354, 354, 354, 354, 384, 384, 384, 384, 384, 391, 491, 491, 529, 529, 529, 529, 529, 529, 543]
N = int(input())
print(answer[N])


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

#define rep(i,n) for(int i = 0 ; i < (int)(n) ; i++)
static const double EPS = 1e-8;

int n,hx,hy,dx,dy;
int x[20],y[20];
bool flag;

void dfs(int unvisit, int cx, int cy, double t){
   if(flag)return;
  
   if(unvisit==0)flag = true;
   
   else{
      //枝刈り
      rep(i,n){
	 if(!((unvisit >> i) & 1))continue;
	 if(hypot(dx-x[i], dy-y[i]) < t + hypot(cx-x[i], cy-y[i]) + EPS)return;
      }

      rep(i,n){
	 if(!((unvisit >> i) & 1))continue;
	 dfs((unvisit & ~(1 << i)), x[i], y[i], t + hypot(cx-x[i], cy-y[i]));
      }
   }
}

string solve(){
   flag = false;
   dfs((1<<n)-1, hx, hy, 0);
   return (flag) ? "YES" : "NO";
}

int main(){
   while(cin >> n >> hx >> hy >> dx >> dy){
      if((n|hx|hy|dx|dy)==0)break;
   
      rep(i,n){
	 cin >> x[i] >> y[i];
      }
      
      cout << solve() << endl;
   }
   return 0;
}

Measured memory_bytes: 1208
#include <stdio.h>
 
int main(void)
{
   int a, b, c;
 
   scanf("%d%d%d", &a, &b, &c);
 
   if(c <= (a+b)){
      printf("Yes\n");
   }
   else{
      printf("No\n");
   }
 
   return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};


/*
class UnionFind {
  private:
    vector<I> data;
 
  public:
    I root(I x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    UnionFind(I size) : data(size, -1) { }
    bool same(I x, I y) { return root(x) == root(y); }
    I size(I x) { return -data[root(x)]; }
   
    bool unite(I x, I y) {
      x = root(x); y = root(y);
      if (x != y) {
        if (data[y] < data[x]) swap(x, y);
        data[x] += data[y]; data[y] = x;
        return true;
      }
      else {
        return false;
      }
    }
};
*/

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  I n,k,l;
  cin >> n >> k >> l;
  UnionFind pq(n+1), rs(n+1);
  REP(i,k){
    I p,q;
    cin >> p >> q;
    pq.unite(p,q);
  }
  REP(i,l){
    I r,s;
    cin >> r >> s;
    rs.unite(r,s);
  }
  vector<P> t(n+1);
  REP(i,n+1){
    if (i==0) continue;
    t.at(i).first = pq.find(i);
    t.at(i).second = rs.find(i);
  }
  vector<P> tmp(n+1);
  tmp = t;
  SORT(tmp);
  REP(i,n+1){
    if (i==0) continue;
    P p = t.at(i);
    I lo = lower_bound(ALL(tmp), p) - tmp.begin();
    I up = upper_bound(ALL(tmp), p) - tmp.begin();
    I an = upper_bound(ALL(tmp), p) - lower_bound(ALL(tmp), p);
    if (i < n){
      cout << an << " ";
    }else{
      cout << an << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 8448
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const llint big=1e15+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
int main(void){
	int n;cin>>n;
	llint ans=0,gen=0,mae=0;
	vector<pair<llint,llint>> ke(n);
	for(auto &it:ke){cin>>it.fir>>it.sec;}
	sort(ke.begin(),ke.end());
	for(auto it:ke){
		gen-=it.fir-mae;
		mae=it.fir;
		maxeq(gen,0);
		gen+=it.sec;
		maxeq(ans,gen);
	}
	cout<<ans<<endl;
	RE;
}

Measured memory_bytes: 3328
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



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

	vector<string> week{ "SUN","MON","TUE","WED","THU","FRI","SAT" };
	for (int i = 0; i < 7; i++) {
		if (week[i] == s) {
			cout << 7 - i << endl;
			return 0;
		}
	}

}


Measured memory_bytes: 3608
#include <stdio.h>

int main()
{
	int a[30];
	int w,n,i,an,bn,nazo;
	scanf("%d",&w);
	for(i=0;i<w;i++)a[i]=i+1;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	scanf("%d,%d",&an,&bn);
	nazo=a[an-1];a[an-1]=a[bn-1];a[bn-1]=nazo;//swap
	}
	for(i=0;i<w;i++)printf("%d\n",a[i]);
	return 0;
}

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

ll K = 0;
vector<vector<ll>> G(100005);
vector<pair<ll, ll>> vp;

map<pair<ll, ll>, ll> ans;
vector<ll> used(100005, 0);

void dfs(int c, int oldColor) {

  K = max(K, (ll) G[c].size());
  ll newColor = 1;

  for (ll n: G[c]) {
    if (used[n]) continue;
    if (newColor == oldColor) newColor++;
    used[n] = 1;
    ans[make_pair(c, n)] = newColor;
    ans[make_pair(n, c)] = newColor;
    dfs(n, newColor);
    newColor++;
  }
}

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

  int N; cin >> N;

  for (ll i = 0; i < N - 1; i++) {
    ll a, b; cin >> a >> b; a--; b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
    vp.emplace_back(a, b);
  }

  used[0] = 1;
  dfs(0, -1);

  cout << K << '\n';
  for (ll i = 0; i < N - 1; i++) {
    cout << ans[vp[i]] << '\n';
  }
  return 0;
}

Measured memory_bytes: 21748
def trial_divide(n):
    ret = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            if n // i == i:
                ret += 1
            else:
                ret += 2
    return ret
        
def main():
    n = int(input())
    count = 0
    for i in range(1, n+1):
        if i % 2:
            if trial_divide(i) == 8:
                count += 1
    print(count)
        
if __name__=='__main__':
    main()

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

int main() {
  ll n;
  cin >> n;
  ll c=0;
  ll i=0;
  ll pow=1;
  n--;
  while (c<=n){
    pow*=26;

    i++;
  //  cout<<i<<"i"<<endl;

    c+=pow;
  //  cout<<pow<<endl;
  }
//cout<<c<<'c'<<endl;
//  n-=c;
  //n+=pow;
  vector<ll> v(i);
  ll p=26;
  rep(j,i){
//    cout<<n<<"N"<<endl;

    ll now=n%p;
  //  cout<<now<<"n"<<endl;
    v[i-j-1]=now;
    n-=now;
    n/=p;
  //  cout<<n<<"N"<<endl;
  //  p*=26;
  n--;
  }
  rep(j,i){
    char ans;
    ans='a'+(v[j]);
   //cout<<v[j]<<endl;
    cout<<ans;
  }

}


Measured memory_bytes: 3628
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
x,y=map(int,input().split())
if (x in a)and(y in a):
  print('Yes')
elif (x in b)and(y in b):
  print('Yes')
elif x==y:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
n = int(input())
a = []
largest = 0
second_largest = 0
for i in range(n):
    temp = int(input())
    if temp > largest:
        largest = temp
    elif largest >= temp > second_largest:
        second_largest = temp
    a.append(temp)

for i in range(n):
    if a[i] == largest:
        print(second_largest)
    else:
        print(largest)

Measured memory_bytes: 68952
import sys
input = sys.stdin.readline

X,Y,Z,N,M,S,T=map(int,input().split())

CS=[[0,0,0]]+[list(map(int,input().split()))+[i+1]+[0] for i in range(N)]
CC=[[0,0,0]]+[list(map(int,input().split()))+[i+1]+[1] for i in range(M)]

CS_SLIST=[[] for i in range(X+1)]
CS_CLIST=[[] for i in range(Y+1)]
CC_CLIST=[[] for i in range(Y+1)]
CC_ULIST=[[] for i in range(Z+1)]

for x,y,z,_ in CS[1:]:
    CS_SLIST[x].append(z)
    CS_CLIST[y].append(z)

for x,y,z,_ in CC[1:]:
    CC_CLIST[x].append(z)
    CC_ULIST[y].append(z)

import heapq
MINCOST_CS=[1<<30]*(N+1)
MINCOST_CC=[1<<30]*(M+1)

MINCOST_CS[S]=0

Q=[[0]+CS[S]]
USES=[0]*(X+1)
USEC=[0]*(Y+1)
USEU=[0]*(Z+1)


while Q:
    #print(Q)
    cost,x,y,z,cs=heapq.heappop(Q)
    
    if cs==0:

        if USES[x]==0:
            USES[x]=1
            for to in CS_SLIST[x]:
                if MINCOST_CS[to]>cost+1:
                    MINCOST_CS[to]=cost+1
                    heapq.heappush(Q,[cost+1]+CS[to])

        if USEC[y]==0:
            USEC[y]=1

            for to in CS_CLIST[y]:
                if MINCOST_CS[to]>cost+1:
                    MINCOST_CS[to]=cost+1
                    heapq.heappush(Q,[cost+1]+CS[to])

            for to in CC_CLIST[y]:
                if MINCOST_CC[to]>cost+1:
                    MINCOST_CC[to]=cost+1
                    heapq.heappush(Q,[cost+1]+CC[to])

    else:

        if USEU[y]==0:
            USEU[y]=1
            for to in CC_ULIST[y]:
                if MINCOST_CC[to]>cost+1:
                    MINCOST_CC[to]=cost+1
                    heapq.heappush(Q,[cost+1]+CC[to])

        if USEC[x]==0:
            USEC[x]=1

            for to in CS_CLIST[x]:
                if MINCOST_CS[to]>cost+1:
                    MINCOST_CS[to]=cost+1
                    heapq.heappush(Q,[cost+1]+CS[to])

            for to in CC_CLIST[x]:
                if MINCOST_CC[to]>cost+1:
                    MINCOST_CC[to]=cost+1
                    heapq.heappush(Q,[cost+1]+CC[to])

#print(MINCOST_CS)
#print(MINCOST_CC)

if MINCOST_CC[T]==1<<30:
    print(-1)
else:
    print(MINCOST_CC[T])
                
                
            
        



Measured memory_bytes: 88156
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = a - (2*b);
    if(c < 0){
      c = 0;
    }


    System.out.println(c);
  }
}


Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int s[n];
    for(int i=0;i<n;i++) cin >> s[i];

    long ans = 0;
    for(int c=1;c<n-1;c++){
        long dp=0;
        for(int k=1;k*c<n-1;k++){
            if((n-1)%c==0 && 2*k*c>=n-1) break;
            if((n-1)%c!=0 && (k+1)*c>=n-1) break;
            dp+=s[n-1-k*c]+s[k*c];
            ans = max(ans, dp);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
import os, sys, re, math

D,N = map(int,input().split(' '))
#ret = (100 ** D) * N
#if N == 100:
#    ret += 100 ** D
#print(ret)

cnt = 0
cur = 0

while cnt < N:
    cur += 100 ** D
    if cur // 100 ** D != 100:
        cnt += 1

print(cur)


Measured memory_bytes: 38576
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

r=int(input())
print(3*(r**2))

Measured memory_bytes: 69060
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int s = scanner.nextInt();
        final Set<Integer> appeared = new HashSet<>();
        int m = 1;
        do {
            appeared.add(s);
            if (s % 2 == 0) {
                s = s / 2;
            } else {
                s = 3 * s + 1;
            }
            m++;
        } while (!appeared.contains(s));
        System.out.println(m);
    }
}


Measured memory_bytes: 23764
while True:
    n,m=map(int, input().split())
    if n==0 and m==0:
        break
    a=list(map(int, input().split()))
    
    price=0
    for i in range(n-1):
        for j in range(i+1, n):
            if i==j:
                break
            
            if a[i]+a[j]>price and a[i]+a[j]<=m:
                price=a[i]+a[j]
                
    if price==0:
        print("NONE")
    else:
        print(price)


Measured memory_bytes: 5624
#include<iostream>

using namespace std;

int main()
{ 
    long long int a,b,x;
    cin >> a >> b >> x;

    long long div_b = b/x;
    long long div_a = a/x;
    long long ans = div_b -div_a;

    if(a%x==0) ans += 1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()


int main() {
    int h, n;
    cin >> h >> n;
    vector<int> a(n), b(n);
    rep (i, n) {
        cin >> a[i] >> b[i];
    }

    vector<int> dp(h+1, 1e9+7);
    dp[0] = 0;
    rep(i, 1, h+1) {
        rep(j, n) {
            int prev = max(0, i - a[j]);
            chmin(dp[i], dp[prev] + b[j]);
        }
    }
    cout << dp[h] << endl;

}

Measured memory_bytes: 256
// Try AtCoder
// author: Leonardone @ NEETSDKASU
import std.stdio      : readln, writeln;
import std.array      : split;
import std.string     : chomp;
import std.conv       : to;

auto gets() { return readln.chomp; }
auto getVals(T)() { return gets.split.to!(T[]); }

void main() {
    auto xs = getVals!int;
    auto A = xs[0];
    auto B = xs[1];
    auto C = xs[2];
    auto D = xs[3];
    auto E = xs[4];
    auto F = xs[5];
    int ansSugar = 0, ansWater = 100 * A;
    for (int a = 0; 100 * A * a <= F; a++) {
        int sizeA = 100 * A * a;
        for (int b = 0; sizeA + 100 * B * b <= F; b++) {
            int water = sizeA + 100 * B * b;
            for (int c = 0; water + C * c <= F; c++) {
                int sizeC = C * c;
                if (sizeC * 100 > E * water) { break; }
                for (int d = 0; water + sizeC + D * d <= F; d++) {
                    int sugar = sizeC + D * d;
                    if (sugar * 100 > E * water) { break; }
                    if (ansWater == 0) {
                        ansSugar = sugar;
                        ansWater = water;
                    } else if (sugar*(ansWater+ansSugar) > ansSugar*(water+sugar)) {
                        ansSugar = sugar;
                        ansWater = water;
                    }
                }
            }
        }
    }
    writeln(ansWater+ansSugar, " ", ansSugar);
}

Measured memory_bytes: 256