akhauriyash/Code-Regression huggingface dataset:
//#i#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <cassert>
#include <fstream>
#include <stdio.h>

typedef long long ll;
//typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<vector<vector<string>>> da(n, vector<vector<string>>(n, vector<string>(0)));
    da[0][0].push_back("a");
    rip(i,n-1,0){
        rip(j,i+1,0){
            rip(k,da[i][j].size(),0){
                rip(l,j+1,0){
                    da[i+1][j].push_back(da[i][j][k]+char('a'+l));
                }
                da[i+1][j+1].push_back(da[i][j][k]+char('a'+j+1));
            }
        }
    }
    vector<string> ans(0);
    rip(i,n,0){
        rip(j,da[n-1][i].size(),0) ans.push_back(da[n-1][i][j]);
    }
    sort(all(ans));
    rip(i,ans.size(),0) cout << ans[i] << endl;
}

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

/*

dp[i][j] after consider i the last select is j

select i
dp[i][i] = \max_{j} dp[i-1][j] + \sum_{j<l[k]<=i && r[k]>=i} a[k]
for i add l[k]==i to [0,l[k]-1]
      remove all r[k]==i-1 from [0,l[k]-1]

not select i
dp[i][j] = dp[i-1][j]

*/

typedef long long LL;
typedef pair<int,int> PII;
const int M=2e5+5;
const LL NLINF=0x8080808080808080;
LL dp[M]; // select i the max profit
vector<PII> lset[M];
vector<PII> rset[M];

struct SegT
{
	LL mx[M*2],add[M*2];
	int ML,MR;
	void build(int o,int l,int r)
	{
		mx[o]=NLINF;
		add[o]=0;
		if(l==r) return;
		int mid=(l+r)>>1;
		int ls=o+1,rs=o+((mid-l+1)<<1);
		build(ls,l,mid);
		build(rs,mid+1,r);
	}
	
	void push(int o,int ls,int rs)
	{
		if(add[o])
		{
			add[ls]+=add[o];
			mx[ls]+=add[o];
			add[rs]+=add[o];
			mx[rs]+=add[o];
			add[o]=0;
		}
	}
	void pull(int o,int ls,int rs)
	{
		mx[o]=max(mx[ls],mx[rs]);
	}
	LL V,L,R;
	void update_(int o,int l,int r)
	{
		if(L<=l&&r<=R)
		{
			mx[o]+=V;
			add[o]+=V;
			return;
		}
		int mid=(l+r)>>1;
		int ls=o+1,rs=o+((mid-l+1)<<1);
		push(o,ls,rs);
		if(L<=mid) update_(ls,l,mid);
		if(mid<R) update_(rs,mid+1,r);
		pull(o,ls,rs);
	}
	void update(int l,int r,LL v)
	{
		//cout<<"U "<<l<<" "<<r<<" "<<v<<endl;
		L=l; R=r; V=v;
		update_(0,ML,MR);
	}
	LL query_(int o,int l,int r)
	{
		if(L<=l&&r<=R)
			return mx[o];
		int mid=(l+r)>>1;
		int ls=o+1,rs=o+((mid-l+1)<<1);
		push(o,ls,rs);
		LL ans=NLINF;
		if(L<=mid) ans=max(ans,query_(ls,l,mid));
		if(mid<R) ans=max(ans,query_(rs,mid+1,r));
		pull(o,ls,rs);
		return ans;
	}
	LL query(int l,int r)
	{
		//cout<<"Q "<<l<<" "<<r;
		L=l; R=r;
		LL ans=query_(0,ML,MR);
		//cout<<" = "<<ans<<endl;
		return ans;
	}
	void show(int o,int l,int r)
	{
		cout<<mx[o]<<" "<<l<<" "<<r<<endl;
		if(l==r) return;
		int mid=(l+r)>>1;
		int ls=o+1,rs=o+((mid-l+1)<<1);
		show(ls,l,mid);
		show(rs,mid+1,r);
	}
}segt;

int main()
{
	//freopen("W.in","r",stdin);
	int n,m; scanf("%d%d",&n,&m);
	int li,ri,ai;
	for(int i=0;i<m;i++)
	{
		scanf("%d%d%d",&li,&ri,&ai);
		lset[li].push_back({ri,ai});
		rset[ri].push_back({li,ai});
	}
	memset(dp,0x80,sizeof(dp));
	//cout<<dp[0]<<" "<<NLINF<<endl;
	dp[0]=0;
	segt.build(0,0,n);
	segt.ML=0; segt.MR=n;
	segt.update(0,0,-NLINF);
	//segt.show(0,0,n);
	for(int i=1;i<=n;i++)
	{
		//cout<<endl<<"!!!!!! "<<i<<endl;
		for(auto p:lset[i])
			segt.update(0,i-1,p.second);
		for(auto p:rset[i-1])
			segt.update(0,p.first-1,-p.second);
		//cout<<endl;
		//segt.show(0,0,n);
		LL pdp=dp[i];
		dp[i]=segt.query(0,i-1);
		segt.update(i,i,dp[i]-pdp);
		// cout<<dp[i]<<endl;
		// for(int i=0;i<=n;i++)
		// 	cout<<dp[i]<<" ";
		// cout<<endl;
	}
	LL ans=NLINF;
	for(int i=0;i<=n;i++)
		ans=max(ans,dp[i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 29952
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		int a, b;
		cin >> a >> b;
		cout << max(0, a - 2 * b) << "\n";
	}
	return 0;
}

Measured memory_bytes: 3604
n,m=map(int,input().split())
edge=[[] for i in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)
import sys
sys.setrecursionlimit(10**6)
dep=[-1 for i in range(n+1)]
color=[0 for i in range(n+1)]
def dfs(s,d,c):
    dep[s]=d
    color[s]=c
    for i in edge[s]:
        if dep[i]==-1:
            if not dfs(i,d+1,-c):
                return False
        else:
            if color[i]==c:
                return False
    return True
if dfs(1,0,1):
    print(color.count(1)*color.count(-1)-m)
else:
    print(n*(n-1)//2-m)

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

// 制約充足問題っぽい
int main() {
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    vector<ll> ans(n);
    int index = 1;
    if(s1[0]==s2[0]){
        ans[0] = 3;
    }else{
        ans[1] = 3*2;
        index++;
    }
    bool flag = true;
    for(int i=index; i<n; i++){
        if(s1[i]==s2[i]){
            if(s1[i-1] == s2[i-1]){
                ans[i] = ans[i-1] * 2;
            }else{
                ans[i] = ans[i-1];
            }
        }else{
            if(flag){
                flag = false;
            }else{
                if(s1[i-2] == s2[i-2]){
                    ans[i] = ans[i-2] * 2;
                }else{
                    ans[i] = ans[i-2] * 3;
                }
                flag = true;
            }
        }
        ans[i] = ans[i] % MOD;
    }

    cout << ans[n-1] << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
C = {}
for i in range(N):
    a = A[i]
    if a not in C:
        C[a] = 0
    C[a] += 1
cnt = 0
for a in C:
    if C[a]<a:
        cnt += C[a]
    else:
        cnt += C[a]-a
print(cnt)

Measured memory_bytes: 98720
#include <cstdio>
#include <algorithm>
using namespace std;
const int MaxN = 100003;
int n,a[MaxN],b[MaxN];
int t1[MaxN],t2[MaxN];

int fa[MaxN],rk[MaxN];
bool vis[MaxN];
int getfa(int x) {
	if (x!=fa[x]) fa[x]=getfa(fa[x]);
	return fa[x];
}
void uni(int a,int b) {
	a=getfa(a),b=getfa(b);
	if (a!=b) {
		if (rk[a]<rk[b]) {
			fa[a]=b;
			rk[b]+=rk[a];
		} else {
			fa[b]=a;
			rk[a]+=rk[b];
		}
	}
}

int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",a+i);
	for (int i=1;i<=n;++i) scanf("%d",b+i);
	for (int i=0;i<=n;++i) a[0]^=a[i],b[0]^=b[i];
	for (int i=0;i<=n;++i) t1[i]=a[i],t2[i]=b[i];
	sort(t1,t1+n+1),sort(t2,t2+n+1);
	for (int i=0;i<=n;++i)
		if (t1[i]!=t2[i]) {
			puts("-1");
			return 0;
		}
	int* ed=unique(t1,t1+n+1);
	for (int i=0;i<=n;++i) a[i]=lower_bound(t1,ed,a[i])-t1,b[i]=lower_bound(t1,ed,b[i])-t1;
	for (int i=0;i<=n;++i) fa[i]=i,rk[i]=1;
	int ans=0;
	for (int i=1;i<=n;++i) if (a[i]!=b[i]) {
		uni(a[i],b[i]);
		ans++;
	}
	for (int i=0;i<=n;++i) if (getfa(i)==i && rk[i]>=2) ans++;
	if (rk[getfa(a[0])]>=2) ans--;
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}


Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

void yes(bool cap=false){
    if (cap)cout<<"YES";
    else cout<<"Yes";
}
void no(bool cap=false){
    if (cap)cout<<"NO";
    else cout<<"No";
}


Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}

/*   kokomade  */

int cnt = 0;
bool is_prime[ 50000 + 1 ];
vector<int> P;
void Eratosthenes( const int N )
{
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;//初期化
    }
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
}

int main() {
    IOS;
    int n,x;cin>>n;
    // int a,b,c;cin>>a>>b>>c;
    // string str;cin>>str;


    vector<int> l(n);
    // vector<string> s(n);

    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    ssort(l);
    double ans=l[0];
    for(int i=1;i<n;i++){
        ans=1.0*(ans+l[i])/2;
    }

    cout<<std::fixed << std::setprecision(15)<<ans;



    cout<<endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 256
import bisect


def solve(A, B, Q, Ss, Ts, Xs):
    ans = []
    Ss.append(10 ** 21)
    Ss.insert(0, -10 ** 21)
    Ts.append(10 ** 21)
    Ts.insert(0, -10 ** 21)
    for x in Xs:
        s_right = bisect.bisect_right(Ss, x)
        s_left = max(s_right - 1, 0)
        t_right = bisect.bisect_right(Ts, x)
        t_left = max(t_right - 1, 0)

        s_right = Ss[s_right]
        s_left = Ss[s_left]
        t_right = Ts[t_right]
        t_left = Ts[t_left]

        d_s_right = abs(s_right - x)
        d_s_left = abs(s_left - x)
        d_t_right = abs(t_right - x)
        d_t_left = abs(t_left - x)

        tans = 10 ** 35
        if x <= s_right and x <= t_right:
            tans = min(tans, max(d_t_right, d_s_right))
        if s_right <= x and t_right <= x:
            tans = min(tans, max(d_t_right, d_s_right))
        if s_left <= x and t_left <= x:
            tans = min(tans, max(d_s_left, d_t_left))
        tans = min(tans, min(d_s_right, d_t_left) * 2 + max(d_s_right, d_t_left))
        tans = min(tans, min(d_t_right, d_s_left) * 2 + max(d_t_right, d_s_left))
        ans.append(str(tans))
    return "\n".join(ans)

if __name__ == "__main__":
    A, B, Q = tuple(map(int, input().split(" ")))
    Ss = [int(input()) for _ in range(A)]
    Ts = [int(input()) for _ in range(B)]
    Xs = [int(input()) for _ in range(Q)]
    print(solve(A, B, Q, Ss, Ts, Xs))


Measured memory_bytes: 23220
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

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

	u64 div_base = 2019;
	u64 ans = 0;
	boost::dynamic_bitset<> search_done(S.size()+1);
	
	for(u64 b=0; b<S.size(); b++) {
		if(search_done[b]) continue;

		u64 tmp_div = 0;
		u64 num_b_variations = 0;
		
		for(u64 e=b; e<S.size(); e++) {
			tmp_div = tmp_div * 10 + S[e] - '0';
			bool is_zero = (tmp_div == 0);
			if(is_zero && search_done[e]) break;

			tmp_div = tmp_div % div_base;

			if(!is_zero && tmp_div == 0) {
				num_b_variations++;
				ans += num_b_variations;	
				
				
				search_done[e+1] = 1;
			}
		}
	}

	cout << ans;

}


Measured memory_bytes: 3732
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


template<class Type>
Type solve(Type res){
    ll N; cin >> N;
    string sN = to_string(N);
    ll sum = accumulate(sN.begin(),sN.end(),0) - '0'*sN.length();
    if(N%sum) res = "No";
    else res = "Yes";
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    //solve<ll>(0);
    cout << fixed << setprecision(12) << solve("") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lld long long int
#define pb push_back
#define in insert
#define mod 1000000007
#define pi 3.14159265358979

using namespace std;

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

    lld n,x;
    cin>>n;
    map<lld,lld>m;

    for(lld i=0;i<n;i++)
    {
        cin>>x;
        m.in({x,i+1});
    }
    for(auto it=m.begin();it!=m.end();it++)
    {
        cout<<it->second<<' ';
    }
    cout<<"\n";
}


Measured memory_bytes: 9816
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  int max_x = X;
  int min_y = Y;
  for(int i=0; i<N; i++) {
    int x;
    cin >> x;
    if(x > max_x)
      max_x = x;
  }
  for(int i=0; i<M; i++) {
    int y;
    cin >> y;
    if(y < min_y)
      min_y = y;
  }
  if(max_x < min_y)
    cout << "No War" << endl;
  else
    cout << "War" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
}

template<typename T>
int gcds(T nums) {
  if(nums.size() == 0) {
    //本来未定義
    return 0;
  }
  
  if(nums.size() == 1) {
    return nums[0];
  }
  
  int g = gcd(nums[0], nums[1]);
  for (size_t i = 2; i < nums.size(); i++)
  {
    g = gcd(g, nums[i]);
  }
  
  return g;
}

int main(void) {
  int N, X;
  cin >> N >> X;
  
  vi x(N);
  rep(i, N) cin >> x[i];
  
  rep(i, N) x[i] = abs(X - x[i]);
  
  fin(gcds(x));
  return 0;
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool flag = true;
    while(c > 0) {
        c -= b;
        if (a <= 0) {
            flag = false;
            break;
        }
        a -= d;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}       

Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  int N;
  cin >> N;
  vector<int> a(N), b(N);
  rep(i, N-1) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
  }
  vector<vector<int>> to(N);
  rep(i, N-1) {
    to[a[i]].push_back(b[i]);
    to[b[i]].push_back(a[i]);
  }
  vector<vector<int>> node(N, vector<int>(2));
  queue<pair<int, int>> que;
  que.push({0, -1});

  auto bfs = [&](int n) {
    while(!que.empty()) {
      int now, prev;
      tie(now, prev) = que.front();
      que.pop();
      rep(i, to[now].size()) {
        if(to[now][i] == prev)
          continue;
        node[to[now][i]][n] = node[now][n]+1;
        que.push({to[now][i], now});
      }
    }
  };

  bfs(0);
  que.push({N-1, -1});
  bfs(1);
  int fennec = 0, snuke = 0;
  rep(i, N) {
    if(node[i][0] <= node[i][1])
      fennec++;
    else
      snuke++;
  }
  if(fennec > snuke)
    cout << "Fennec" << endl;
  else
    cout << "Snuke" << endl;
  return 0;
}

Measured memory_bytes: 12032
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        a[0] = sc.nextInt();
        a[1] = sc.nextInt();
        a[2] = sc.nextInt();
        Arrays.sort(a);

        if (a[0] == a[1] && a[1] == a[2]) {
            System.out.println(0);
            return;
        }

        int ans = 0;
        int d1 = a[2] - a[0];
        int d2 = a[2] - a[1];
        ans += d1 / 2 + d2 / 2;

        if (d1 % 2 == 0) {
            if (d2 % 2 == 0) {

            } else {
                ans += 2;
            }
        } else {
            if (d2 % 2 == 0) {
                ans += 2;
            } else {
                ans += 1;
            }
        }

        System.out.println(ans);
    }
}

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

int main() {
    long long int a,b,cnt=1;
    cin>>a>>b;
    if(a<b) swap(a,b);
    while(1) {
        if(cnt==0 || b==0) break;
        cnt=a%b;
        a=b;b=cnt;
    }
    cout<<a<<'\n';

    return 0;
}

Measured memory_bytes: 3088
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL A[200000];

LL ans = 0;

void solve(){
  sort(A,A+N,greater<LL>());
  //valueがあと何回利用できるかをcounter[value]とする
  map<LL,LL> counter;
  //valueが利用できる状態(counter[value]>0)ならsはvalueを含む
  set<LL> s;
  counter[A[0]]++;
  s.insert(A[0]);
  for(int i=1;i<N;i++){
    LL value = *(--s.end());
    counter[value]--;
    if(counter[value]==0) s.erase(value);

    ans += value;
    counter[A[i]] += 2LL;
    s.insert(A[i]);
  }
}

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];

    solve();

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

Measured memory_bytes: 21908
def main():
    S = input()
    s_len = len(list(S))
    for i in range(s_len):
        s = S[i]
        ans = "Yes"
        if s == "U" or s == "D":
            pass
        else:
            if i % 2 == 0:
                if s == "R":
                    pass
                else:
                    ans = "No"
                    break
            else:
                if s == "L":
                    pass
                else:
                    ans = "No"
                    break
 
    print(ans)
if __name__ == '__main__':
    main()

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

using namespace std;

template<class INT>
std::map<INT, int> prime_factorize(INT n){
    std::map<INT, int> res;
    for (INT i = 2; i * i <= n; i++){
        while (n % i == 0){
            res[i]++;
            n /= i;
        }
    }

    if (n > 1)
        res[n]++;

    return res;
}

int main(){
    int64_t n;
    cin >> n;
    auto P = prime_factorize(n);
    vector<int64_t> S(1);
    for (int i = 0; S[S.size() - 1] < 40; i++){
        S.push_back(S[S.size() - 1] + i + 1);
    }

    int ans = 0;
    for (const auto &[p, c]: P){
        for (int i = 0; i < S.size(); i++){
            if (c < S[i]){
                ans += i - 1;
                break;
            }
        }
    }

    cout << ans << endl;
}

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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,j,x,n,k,y;
    cin>>a>>b;
    if(a>=b)
        n=a;
    else
        n=b;
    for(int i=0;i<999999999;i++)
    {
        x=a-i;
        if(x<0)
            x=x*-1;
        y=b-i;
        if(y<0)
            y=y*-1;
        if(x==y)
        {
            cout<<i<<endl;
            return 0;

        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


Measured memory_bytes: 256
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    c = 1
    ans = 0
    for i in range(n):
        if a[i] == c:
            c += 1
        else:
            ans += 1
    if ans == n:
        print(-1)
    else:
        print(ans)

    
    

        


if __name__ == '__main__':
    main()


Measured memory_bytes: 102344
#include <cstdio>
#include <algorithm>
#define LL long long
#define MOD 1000000007
using namespace std;

int r, g, b;

int main(){
	scanf("%d%d%d",&r,&g,&b);
	if((r*100+g*10+b)%4==0)printf("YES\n");
	else printf("NO\n");
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int i,j;
	char s[11];
	char al[2][26]={"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
	for(i=0; i<3; i++)
	{
		scanf("%s", s);
		for(j=0; j<26; j++)
		{
			if(s[0]==al[0][j])
			printf("%c", al[1][j]);
		}
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

b = [0 for _ in range(n)]

for i, e in enumerate(a[::-1]):
    _sum = sum(b[n-1 - i: n: n-i])
    if _sum % 2 == e:
        pass
    else:
        b[n-1 - i] = 1

ball_cnt = sum(b)
print(ball_cnt)
if ball_cnt > 0:
    boxes = [i + 1 for i, e in enumerate(b) if e == 1]
    print(" ".join(map(str, boxes)))


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	ll a[n], b[n], c[n], ans=0;
	for(int i=0; i<n; i++){
		cin >> a[i] >> b[i];
		c[i]=a[i]+b[i];
		ans-=b[i];
	}
	sort(c, c+n, greater<ll>());
	for(int i=0; i<n; i+=2) ans+=c[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
bool aaa[11111111];
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}


int main() {
  int n,k,x,m,memo=0;
  cin>>n;
  //vector<string> a(n),b(0),c(0);
  vector<int> count(n);
  bool ok=true;
  rep(i,n){
    cin>>count[i];
    if(count[i]%2==0){if(count[i]%3!=0&&count[i]%5!=0)ok=false;}
  }
  if(ok){cout<<"APPROVED"<<endl;}
  else cout<<"DENIED"<<endl;

  //vector<vector<bool>> sinsetsu(15,vector<bool>(14)),usotsuki(15,vector<bool>(14));
  //vector<vector<int>> sss(15,vector<int>(14))
  //vector<vector<int>> sss(h,vector<int>(w));
  //vector<int> a(k),b(k);
  //char x;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int inf = 1001001001;
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}

int main() {
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n);
    rep(i,n) cin >> a[i] >> b[i] >> c[i];
    vector<vector<int>> dp(n,vector<int>(3,0));
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    rep(i,n-1) rep(j,3){
            if(j == 0) {
                chmax(dp[i+1][1],dp[i][j]+b[i+1]);
                chmax(dp[i+1][2],dp[i][j]+c[i+1]);
            } else if(j == 1) {
                chmax(dp[i+1][0],dp[i][j]+a[i+1]);
                chmax(dp[i+1][2],dp[i][j]+c[i+1]);
            } else {
                chmax(dp[i+1][0],dp[i][j]+a[i+1]);
                chmax(dp[i+1][1],dp[i][j]+b[i+1]);
            }
        }
    cout << tmax(dp[n-1][0],dp[n-1][1],dp[n-1][2]) << endl;
}

Measured memory_bytes: 6912
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]]

n=int(input())
a=list(map(int,input().split()))

dic={}
ans=0
for i in range(n):
    if i-a[i] in dic:
        ans+=dic[i-a[i]]
    if a[i]+i in dic:
        dic[a[i]+i]+=1
    else:
        dic[a[i]+i]=1
print(ans)

Measured memory_bytes: 124312
n,y = map(int,input().split())

for i in range(n+1):
    for j in range(n-i+1):
        if (10000*i + 5000*j + 1000*(n-i-j)) == y:
            print(i,j,n-i-j)
            exit()
            
print("-1 -1 -1")

Measured memory_bytes: 3060
N, M = map(int, input().split())

count = [0] * M

for n in range(N):
    A = list(map(int, input().split()))

    for a in A[1:]:
        count[a-1] += 1

ans = 0

for m in range(M):
    if count[m] == N:
        ans += 1

print(ans)

Measured memory_bytes: 3060
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		// Scanner sc = new Scanner(new File("test_1.txt"));
		// Scanner sc = new Scanner(new File("test_2.txt"));
		// Scanner sc = new Scanner(new File("in4.txt"));
		int N = sc.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		int max = 0;
		for (int i = 0; i < N; i++) {
			int n = sc.nextInt();
			list.add(n);			
			if (n > max)
				max = n;
		}

		int ans = 0;
		for (int n : list) {
			boolean is_prime = true;
			for (int i = 2; i * i <= n; i++)
				if (n % i == 0)
					is_prime = false;
			if (is_prime)
				ans++;
		}
		System.out.println(ans);		
		
	}
}

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

typedef  long long ll;

int main()
{
    ll n;
    cin>>n;
    ll a[n+1],b[n+1];
    for(ll i=1;i<=n;i++)
    {
        cin>>a[i];
        b[a[i]]=i;
    }

    for(ll i=1;i<=n;i++)
    {
        cout<<b[i]<<" ";
    }

}


Measured memory_bytes: 2432
#include<stdio.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define ll long long
#define INF 2000000000
int main(){
	int n,m;
	while(~getII(n,m)){
		F(i,0,m){
			VgetI(tmp);
			n-=tmp;
		}
		printf("%d\n",n>=0?n:-1);
	}
}


Measured memory_bytes: 1732
#include <iostream>
#include <cstring>

using namespace std;

int main(){
	int n;
	int gems[21][21];
	while(cin >> n && n){
		memset(gems, 0, sizeof(gems));
		for(int i=0;i<n;i++){
			int x, y; cin >> x >> y;
			gems[x][y] = 1;
		}
		int px = 10, py = 10;
		gems[10][10] = 0;
		int m; cin >> m;
		for(int i=0;i<m;i++){
			char c; int d; cin >> c >> d;
			for(int j=0;j<d;j++){
				switch(c){
					case 'N': py++; break;
					case 'E': px++; break;
					case 'S': py--; break;
 					case 'W': px--; break;
				}
				gems[px][py] = 0;
			}
		}
		bool ok = true;
		for(int i=0;i<=20;i++){
			for(int j=0;j<=20;j++)
				if(gems[i][j]) ok = false;
		}
		cout << (ok ? "Yes" : "No") << endl;
	}
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    int n;
    cin>>n;
    string s,t,u="";
    cin>>s>>t;
    ll ans=0;
    for(int i=0;i<s.size();i++){
        if(i!=s.size()-1&&s[i]==s[i+1]){
            u+='Y';
            i++;
        } else {
            u+='X';
        }
    }

    int diff=0;

    if(u[0]=='X')ans=3;
    else{
        ans=6;
    }
    
    for(int i=1;i<u.size();i++){
        if(u[i]=='X'){
            if(u[i-1]=='X'){
                ans*=2;
                ans%=P;
            } else {//Y
                ans*=1;
                ans%=P;
            }
        } else {//Y
            if(u[i-1]=='X'){
                ans*=2;
                ans%=P;
            } else {//Y
                ans*=3;
                ans%=P;
            }
        }
        // fin(ans);
    }

    
    fin(ans);
    // fin(u);

//////////////////////////////////////////////////////
return 0;}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,max;

	scanf("%d %d %d",&a,&b,&c);


	if(a>b){
		max=a;
		a=b;
		b=max;
	}
	if(b>c){
		max=b;
		b=c;
		c=max;
	}

	if(a>b){
		max=a;
		a=b;
		b=max;
	}

	printf("%d %d %d\n",a,b,c);

	return 0;
}




Measured memory_bytes: 2036
from sys import stdin


def main():
    n, k = map(int, stdin.readline().split())
    ab = [list(map(int, stdin.readline().split())) for _ in range(n)]
    ab.sort(key=lambda x: x[0])
    count = 0
    for a, b in ab:
        if count + b < k:
            count += b
        else:
            print(a)
            exit()


if __name__ == "__main__":
    main()


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    string s[3];
    int diff = 'A' - 'a';
    cin >> s[0] >> s[1] >> s[2];
    printf("%c%c%c\n", s[0][0] + diff, s[1][0] + diff, s[2][0] + diff);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <list>
#include <utility>

using P = std::pair<int, long long>;

class Edge{
public:
    int from, to;
    long long cost;
    Edge(): from(0), to(0), cost(0){}
    Edge(int u, int v, long long w): from(u), to(v), cost(w){}
    ~Edge(){}
    bool operator<(const Edge &e)const{
        return cost < e.cost;
    }
};

void search(std::vector<long long> &dist,
    std::vector<bool> &visited,
    std::vector<std::list<P> > &e_list, int s)
{
    std::deque<P> que;
    que.push_front(P(s, 0));
    while(!que.empty()){
        int u = que.back().first;
        long long d = que.back().second;
        que.pop_back();
        if(visited[u] == true) continue;

        visited[u] = true;
        dist[u] = d;
        for(auto &&itr = e_list[u].begin(); itr != e_list[u].end(); itr++){
            int v = itr->first;
            long long c = itr->second;
            que.push_front(P(v, d+c));
        }
    }
}

int main()
{
    int N, M;
    scanf("%d %d", &N, &M);
    std::vector<Edge> edge(M);
    for(int i=0; i<M; i++){
        scanf(" %d %d %lld", &edge[i].from, &edge[i].to, &edge[i].cost);
        edge[i].from--; edge[i].to--;
    }

    if(M == 0){
        std::cout << "Yes" << std::endl; return 0;
    }

    std::vector<std::list<P> > e_list(N);
    for(int i=0; i<M; i++){
        int u = edge[i].from;
        int v = edge[i].to;
        int c = edge[i].cost;
        e_list[u].push_back(P(v, c));
        e_list[v].push_back(P(u, -c));
    }

    std::vector<long long> dist(N);
    std::vector<bool> visited(N, false);
    for(int i=0; i<N; i++){
        if(visited[i] == false) search(dist, visited, e_list, i);
    }

    bool flag = true;
    for(int i=0; i<M; i++){
        int u = edge[i].from;
        int v = edge[i].to;
        int d = edge[i].cost;
        if(dist[v] - dist[u] != d) flag = false;
    }

    if(flag == true) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
}

Measured memory_bytes: 29440
D = int(input())
c = [0] + list(map(int, input().split()))
s = [[0]] + [[0] + list(map(int, input().split())) for _ in range(D)]
t = [int(input()) for _ in range(D)]

last = [0] * 27
ans = 0
d = 0
for i in t:
    d += 1
    for j in range(1, 27):
        if j == i:
            continue
        ans -= c[j] * (d - last[j])
    last[i] = d
    ans += s[d][i]
    print(ans)

Measured memory_bytes: 9260
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll N, M;

int main() {
  cin >> N >> M;
  ll x = 1900 * M + 100 * (N - M);
  ll y = pow(2, M) * x;
  cout << ((pow(2, M) * x + (pow(2, M) - 1) * y)) / pow(2, M);
}


Measured memory_bytes: 4272
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <set>
#include <cstdio>
using namespace std;

typedef long long ll;
typedef pair<ll,int> P;
typedef pair<int,P> P2;
const int inf=1000000000;
ll dp[51][51][2501]={};
int n;
int x[51]={};

ll calc(int n1,int k1,int t){
	if((n1<0||k1<0)||t<0)return 0;
	if(dp[n1][k1][t]>=0)return dp[n1][k1][t];
	dp[n1][k1][t]=calc(n1-1,k1,t)+calc(n1-1,k1-1,t-x[n1]);
	return dp[n1][k1][t];
}
int main() {
	int a;

	cin>>n>>a;
	for(int i=1;i<n+1;++i)cin>>x[i];

	for(int i=1;i<51;++i){
		for(int j=1;j<51;++j){
			for(int k=1;k<2501;++k){
				dp[i][j][k]=-1;
			}
		}
	}
	for(int i=0;i<51;++i)dp[i][0][0]=1;
	ll t=0;
	for(int i=1;i<n+1;++i){
		t+=calc(n,i,a*i);
//		cout<<t<<endl;
	}
	cout<<t<<endl;
	return 0;
}


Measured memory_bytes: 50048
let () =
  let pi = 4. *. atan 1. in
  let r = float_of_string (read_line()) in
  Printf.printf "%.5f" (pi *. r *. r);
  print_string " ";
  Printf.printf "%.5f" (pi *. 2. *. r);
  print_string "\n"
;;


Measured memory_bytes: 2556
<?php
/*
    http://agc007.contest.atcoder.jp/tasks/agc007_a

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

// define('DEBUG', true);
define('DEBUG', false);

ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%d %d", $H, $W);

for ($i = 0; $i < $H; $i++) {
	fscanf(STDIN, "%s", $A);
	$arr2[] = str_split($A);
}

$cnt = 0;

for ($x = 0; $x < $W; $x++) {
	for ($y = 0; $y < $H; $y++) {
		if ($arr2[$y][$x] == "#") $cnt++;
		$arr[$x][$y] = $arr2[$y][$x];
	}
}
/*
for ($y = 0; $y < $H; $y++) {
	for ($x = 0; $x < $W; $x++) {
		echo "{$arr[$x][$y]}";
	}
	echo "\n";
}
*/

$x = $y = 0;
$cnt--;

while (true) {
	if ($x == $W - 1 && $y == $H - 1) {
		// echo $cnt;
		if ($cnt == 0) {
			echo "Possible\n";
		} else {
			echo "Impossible\n";
		}
		exit;
	}
	$dirY = ($arr[$x][$y + 1] == "#");
	$dirX = ($arr[$x + 1][$y] == "#");
	// echo "x:{$x} y:{$y} XX:{$dirX} YY:{$dirY}\n";


	if ($dirY + $dirX == 1) {
		$arr[$x][$y] = $cnt--;
		if ($dirY === true) {
			$y++;
		}
		if ($dirX === true) {
			$x++;
		}

	} else {
		echo "Impossible\n";
		exit;
	}
}


Measured memory_bytes: 2936
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template <typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
	const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

const int N = 2e3 + 10;
vvi dist(N, vi(N));

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int n;
	cin >> n;
	vvi dist(n, vi(n));
	int x, y;
	cin >> x >> y;
	--x, --y;
	vi ans(n);
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			dist[i][j] = j - i;
			dist[i][j] = min(dist[i][j], 1 + abs(x - i) + abs(y - j));
			dist[i][j] = min(dist[i][j], 1 + abs(y - i) + abs(x - j));
			ans[dist[i][j]]++;
		}
	}
	for(int i = 1; i <= n - 1; i++)
		cout << ans[i] << endl;
}

Measured memory_bytes: 31872
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        char s[] = sc.next().toCharArray();
        int o = 0;
        int l = 0;

        for (int i = 0; i < s.length; i++) {
            if (s[i] == '0') {
                o++;
            } else {
                l++;
            }
        }

        System.out.println(Math.min(o, l) * 2);
    }

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            new Main().main(sc);
        } catch (Exception e) {
            throw e;
        }
    }
}


Measured memory_bytes: 27092
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
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;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////
const int MAX = 510000;
 
long long fac[MAX], finv[MAX], inv[MAX];
 



int main() {
int ans = 0;
	int N; cin >> N;
	for (int i = 1; i <= N; i++)
	{
		int a;	cin >> a;
		if(i!=a){ans++;}
	}
	if(ans > 2){cout << "NO" << endl;}
	else{cout << "YES" << endl;}
	
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int i=0;
		while(true){
			if((1<<(i+1))<=N)i++;
			else break;
		}
		System.out.println(1<<i);
	}

}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int dp[110][110] = {0};
int main(){
    int topk;
    int pp,topp;
    scanf("%d",&topk);
    scanf("%d %d",&pp,&topp);
    int pcal;
    scanf("%d",&pcal);
    vector<int>tcal(1,0);
    for(int i = 0;i < topk;i++){
        int a;
        scanf("%d",&a);
        tcal.push_back(a);
    }
    for(int i = 1;i <= topk;i++){
        for(int j = 1;j <= topk;j++){
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-1]+tcal[i]);
        }
    }
    /*for(int i = 0;i <= topk;i++){
        for(int j = 0;j <= topk;j++){
            cout << dp[topk-i][j] << ' ';
        }
        cout << endl;
    }*/
    vector<int>ppc;
    for(int i = 0;i <= topk;i++){
        int b = (dp[topk][i]+pcal)/(i*topp+pp);
        ppc.push_back(b);
    }
    sort(ppc.begin(),ppc.end());
    /*for(int i = 0;i <=  topk;i++){
        cout << ppc[i] << ' ';
    }
    cout << endl;*/
    printf("%d\n",ppc[topk]);
    return 0;
}

Measured memory_bytes: 3292