akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, s, e) for (ll i = s; i < e; i++)
#define pb push_back
#define ll long long
#define mp make_pair
void primeFactors(ll n)
{
    ll count = 0;
    ll res = 0;
    while (n % 2 == 0)
    {
        count++;
        n = n / 2;
    }
    long double d = sqrt(1 + (8 * count));
    res += (long long)((-1 + d) / 2);
    for (long long i = 3; i <= sqrt(n); i = i + 2)
    {
        count = 0;
        while (n % i == 0)
        {
            count++;
            n = n / i;
        }
        d = sqrt(1 + (8 * count));
        res += (long long)((-1 + d) / 2);
    }
    if (n > 2)
        res++;
    cout << res << endl;
}
int main()
{
    ll n;
    cin >> n;
    primeFactors(n);
    return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){

  ll N;
  cin>>N;
  vector<ll> M;
  ll nin=9;
  ll six=6;
  M.push_back(0);
  for(ll i=1;six<=100000;i++){
    M.push_back(six);
    six=six*6;
  }
  for(ll i=1;nin<=100000;i++){
    M.push_back(nin);
    nin=nin*9;
  }
  sort(M.begin(),M.end());
  vector<ll> dp(N+10000,INF);
  for(ll i=0;i<6;i++){
  dp[i]=i;}

  for(ll j=0;j<N+10000;j++){
  for(ll i=0;i<(ll)M.size();i++){
    if(N<j+M[i])continue;
    dp[j+M[i]]=min(dp[j+M[i]],dp[j]+1);
  }
  }
  
  cout<<dp[N]<<endl;
 
  
}


Measured memory_bytes: 3968
#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() {
	int n, u, v;
	cin >> n >> u >> v;
	u--;
	v--;

	vector<vector<int>> g(n);

	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}

	vector<vector<int>> d(2, vector<int>(n, BIG_NUM));
	d[0][u] = d[1][v] = 0;

	for (int i = 0; i < 2; i++) {
		queue<int> q;
		if (i == 0) {
			q.push(u);
		}
		else {
			q.push(v);
		}
		while (!q.empty()) {
			int p = q.front();
			q.pop();
			for (int c : g[p]) {
				if (d[i][c] != BIG_NUM) {
					continue;
				}

				d[i][c] = d[i][p] + 1;
				q.push(c);
			}
		}
	}

	int ans = 0;

	for (int i = 0; i < n; i++) {
		int diff = d[1][i] - d[0][i];
		if (diff >= 0) {
			ans = max(ans, d[1][i] - 1);
		}


	}
	cout << ans << endl;

}

Measured memory_bytes: 10004
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,m,sum1,sum2,a[110];
int read() 
{
    int res=0,flag=1; 
	char ch=getchar();
    while (!isdigit(ch)) 
	{ 
		if (ch=='-') flag=-1;
		ch=getchar();
	}
    while (isdigit(ch)) res=res*10+ch-48,ch=getchar();
    return res*flag;
}
int main()
{
	n=read();
	sum1=0;
	for(int i=0;i<n;i++)
	{
		a[i]=read();
		sum1+=a[i];
	}
	m=read();
	sum2=sum1;
	while(m--)
	{
		int p,x;
		p=read();
		x=read();
		if(x>=a[p-1]) sum1+=x-a[p-1];
		else sum1-=a[p-1]-x;
		printf("%d\n",sum1);
		sum1=sum2;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long M = sc.nextLong();
        if (M/2 <= N) {
            System.out.println(M/2);
        } else {
            long resM = M-(N*2);
            System.out.println(resM/4+N);
        }
    }
}


Measured memory_bytes: 35704
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
#include<climits>
using namespace std;
using ll = long long;
const int mod = 1000000007;

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n, min(a, b)) << ' ' << max(0, (a + b - n)) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
 
static class Program
{
    static void Main(string[] args)
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        //入力
        var N = int.Parse(Console.ReadLine());
        
        var list = Console.ReadLine().Split(' ').Select(int.Parse);

        var result = list.Distinct().Count() ==  list.Count() ? "YES" : "NO";

        Console.WriteLine(result);

        Console.Out.Flush();
    }
    
}

Measured memory_bytes: 36764
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
// #define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

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

    int n,m;
    cin>>n>>m;
    string s;
    cin>>s;
    vi d(n+1);
    if(s[0]=='0')d[1]=1;
    rep(i,n-1)if(s[i]=='1'&&s[i+1]=='0')d[i+2]=1;

    rep(i,n)d[i+1]+=d[i];
    int out=0;
    int r=1;
    rep(i,n)if(!i||s[i]=='1'){
        while(r<=n&&d[r]-d[i]<=m)r++;
        cmax(out,r-i-1);
    }
    cout<<out<<endl;
}


Measured memory_bytes: 848
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using hset = unordered_set<T>;
template<class Key, class T> using hmap = unordered_map<Key, T>;

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

int main() {
    int n, m;
    vi s(200);
    while (cin >> n >> m) {
        if (n == 0 && m == 0) break;

        int nsum = 0, msum = 0;
        for (int i=0; i<n; i++) {
            cin >> s[i];
            nsum += s[i];
        }
        for (int i=n; i<n+m; i++) {
            cin >> s[i];
            msum += s[i];
        }

        bool flg = false;
        for (int i=0; i<n; i++) {
            if ((msum - nsum) % 2 == 1) break;
            for (int j=n; j<n+m; j++) {
                if ((s[i]-s[j]) * 2 == nsum - msum) {
                    cout << s[i] << " " << s[j] << endl;
                    flg = true;
                    break;
                }
            }
            if (flg) break;
        }
        if (!flg) cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3120
// https://atcoder.jp/contests/abc148/tasks/abc148_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    string s1, s2;
    cin >> s1 >> s2;
    REP(i, N) { cout << s1[i] << s2[i]; }
    cout << endl;

    return 0;
}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 103;

int mo;

template<typename T1,typename T2> inline T1 ad(T1 &a,T2 b){return a=a+b>=mo?a+b-mo:a+b;}
template<typename T1,typename T2> inline T1 dl(T1 &a,T2 b){return a=a>=b?a-b:a-b+mo;}


inline lint powa(lint a,lint t)
{
	lint b=1;
	while(t){if(t&1)b=b*a%mo;a=a*a%mo,t>>=1;}
	return b;
}

inline lint inva(lint a)
{
	return powa(a,mo-2);
}

lint C[_][_]={0};

inline void fuck(int n=_-1)
{
	for(int i=0;i<=n;i++)C[i][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=i;j++)
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%mo;
}

int n,m,lim;
lint f[_][_][_][2]={0},tran[_][_][_][2]={0};

int main()
{
	n=ty(),m=ty(),lim=ty(),mo=ty();

	fuck();
	for(int i=0;i<lim;i++)
		for(int j=0;j<=n;j++)
			for(int k=0;k<=m;k++)
			{
				tran[i][j][k][0]=(powa(i+1,n-j)-powa(i,n-j)+mo)%mo*powa(lim-i,j)%mo;
				tran[i][j][k][1]=(powa(lim-i,k)-powa(lim-i-1,k)+mo)%mo*powa(i+1,m-k)%mo;
			}

	f[0][0][0][0]=1;
	for(int i=0;i<lim;i++)
	{
		for(int j=0;j<=n;j++)
			for(int k=0;k<=m;k++)
				if(f[i][j][k][0])
					for(int a=0,x=1;a+k<=m;a++,x=1ll*x*tran[i][j][k][0]%mo)
						ad(f[i][j][k+a][1],f[i][j][k][0]*x%mo*C[m-k][a]%mo);
		for(int j=0;j<=n;j++)
			for(int k=0;k<=m;k++)
				if(f[i][j][k][1])
					for(int a=0,x=1;a+j<=n;a++,x=1ll*x*tran[i][j][k][1]%mo)
						ad(f[i+1][j+a][k][0],f[i][j][k][1]*x%mo*C[n-j][a]%mo);
	}

	printf("%lld\n",f[lim][n][m][0]);

	return 0;
}


Measured memory_bytes: 34176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    ll cnt[1<<17];
    fill(cnt, cnt+(1<<17), 0);
    ll A, sum = 0;
    rep(i, N){
        cin >> A;
        cnt[A]++;
        sum += A;
    }
    int Q;
    cin >> Q;
    rep(i, Q){
        int b, c;
        cin >> b >> c;
        sum -= b*cnt[b];
        sum += c*cnt[b];
        cout << sum << endl;
        cnt[c] += cnt[b], cnt[b] = 0;
    }
}

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

using namespace std;

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

  unordered_map<string, int> mp;
  rep(i, N) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }

  ll ans = 0;

  for (auto &p : mp) {
    int s = p.second;
    ans += (ll)s * (s - 1) / 2;
  }

  cout << ans << endl;
}

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

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

    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++) cin >> L[i];
    sort(L.begin(), L.end());
    int a, b, c;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        a = L[i];
        for (int j = i + 1; j < N; j++) {
            b = L[j];
            auto it = upper_bound(L.begin(), L.end(), a + b - 1);
            int num = max((int) (it - L.begin()), j + 1);
            auto it2 = lower_bound(L.begin(), L.end(), b - a + 1);
            int num2 = max((int) (it2 - L.begin()), j + 1);
            cnt += max(0, num - num2);
        }

    } 
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int H,W;
    scanf("%d %d",&H,&W);
    int all=H*W;
    int h,w;
    scanf("%d %d",&h,&w);
    int cut=h*W+w*H-h*w;
    int answer=all-cut;
    printf("%d",answer);
    
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

const int MAX = 10010;      // 素数判定する最大の数
bool IsPrime[MAX];
vector<int> Era(int n = MAX) {
    vector<int> res;
    IsPrime[0] = false; IsPrime[1] = false;
    for (int i = 2; i < n; ++i) IsPrime[i] = true;
    for (int i = 2; i < n; ++i) {
        if (IsPrime[i]) {
            res.push_back(i);
            for (int j = i*2; j < n; j += i) IsPrime[j] = false;
        }
    }
    return res;
}

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}

int main() {
    int N; cin >> N;
    vector<vector<long long> > res(N, vector<long long>(N, 0));
    vector<int> primes = Era();
    for (int wa = 0; wa <= N*2; wa += 2) {
        for (int sa = -N/2*2; sa <= N/2*2; sa += 2) {
            if ((wa + sa) & 1) continue;
            int i = (wa + sa) / 2;
            int j = (wa - sa) / 2;
            if (i < 0 || i >= N || j < 0 || j >= N) continue;
            if ((i + j) & 1) continue;
            res[i][j] = primes[wa/2] * primes[(sa + N/2*2)/2 + N];
        }
    }
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if ((i + j) % 2 == 0) continue;
            long long L = 1;
            for (int k = 0; k < 4; ++k) {
                int ni = i + dx[k], nj = j + dy[k];
                if (ni < 0 || ni >= N || nj < 0 || nj >= N) continue;
                L = LCM(L, res[ni][nj]);
            }
            res[i][j] = L + 1;
        }
    }
    if (N == 2) res[0][1] = res[1][0]*2-1;
    
    bool ok = true;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (res[i][j] > 1000000000000000LL) ok = false;
            cout << res[i][j] << " ";
        }
        cout << endl;
    }
    
    //cout << ok << endl;
}


























Measured memory_bytes: 5120
// AOJ 2108 Aaron and Bruce
// 2018.3.4

#include <stdio.h>
#include <string.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	while (c <= ' ') c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int m, lim;
int hi[51], to[51][51];
int dp[51][51][102];

int dfs(int a, int b, int t)
{
	int i, x, ans;

	if (a == b) return t;
	if (t >= lim) return lim;
	if (dp[a][b][t] >= 0) return dp[a][b][t];
	if (t & 1) {
		ans = lim;
		for (i = 0; i < hi[b]; i++) {
			x = dfs(a, to[b][i], t+1);
			if (x < ans) { ans = x; if (x == 0) break; }
		}
	} else {
		ans = 0;
		for (i = 0; i < hi[a]; i++) {
			x = dfs(to[a][i], b, t+1);
			if (x > ans) { ans = x;	if (x == lim) break; }
		}
	}
	return dp[a][b][t] = ans;
}

int main()
{
	int cno, r, c, a, b, ans;

	cno = in(); while (cno--) {
		m = in(), lim = m << 1;
		for (r = 0; r < m; r++) {
			hi[r] = 0;
			for (c = 0; c < m; c++)	if (in()) to[r][hi[r]++] = c;
			to[r][hi[r]++] = r;
		}
		a = in(), b = in();

		memset(dp, -1, sizeof(dp));
		ans = dfs(a, b, 0);
		if (ans >= lim)	puts("infinity");
		else printf("%d\n", ans >> 1);
	}
	return 0;
}


Measured memory_bytes: 2676
#include<cstdio>
using namespace std;
int i,n,a[200010];
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	printf("%d",a[n]);
	for (i=n-2;i>=1;i-=2) printf(" %d",a[i]);
	if (n%2==1)
	{
		for (i=2;i<=n;i+=2) printf(" %d",a[i]);	
	}
	else
	{
		for (i=1;i<=n;i+=2) printf(" %d",a[i]);	
	}
	printf("\n");
}

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

const int MAX_N = 8;

vector<int> p[MAX_N];
bool visited[MAX_N];
int N, M, ans = 0;

void dfs(int x) {
  if (visited[x]) return;

  visited[x] = true;
  for (vector<int>::iterator it=p[x].begin(); it!=p[x].end(); ++it) {
    dfs(*it);
  }

  bool flag = true;
  for (int i=0; i<N; i++) {
    if (!visited[i]) flag = false;
  }
  if (flag) ans++;
  visited[x] = false;
}

int main() {
  int a, b;
  cin >> N >> M;
  for (int i=0; i<N; i++) {
    visited[i] = false;
  }
  for (int i=0; i<M; i++) {
    cin >> a >> b; a--; b--;
    p[a].push_back(b);
    p[b].push_back(a);
  }
  dfs(0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#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 _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

ll rec(ll X){
  if(X==1) return 1;
  else return 1+2*rec(X/2);
}

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  ll H; cin>>H;
  cout << rec(H) << endl;
  return 0;
}


Measured memory_bytes: 256
WMAX = 10 ** 4 + 1
n = int(input())
A = list(map(int, input().split()))  #1 5 3 4 2
B = sorted(A)  #1 2 3 4 5

is_visited = [False] * n
next_idxs = {}

for i, b in enumerate(B):
  next_idxs[b] = i

m_A = min(A)

ans = 0
for i in range(n):
  if is_visited[i]:
    continue
  cur = i
  S = 0
  n2 = 0
  m = WMAX
  while True:
    is_visited[cur] = True
    S += A[cur]
    m = min(m, A[cur])
    n2 += 1
    cur = next_idxs[A[cur]]
    if is_visited[cur]:
      break
  ans += min(m*(n2-2) + S, m+S+(1+n2)*m_A)

print(ans)



Measured memory_bytes: 5720
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val n = in.nextInt
  val as = Array.fill(n)(in.nextInt)
  def gcd(l: Int, r: Int): Int = if (r == 0) l else gcd(r, (l % r))
  println(as.reduceLeft(gcd))
}

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

using namespace std;

#define ll long long




void solve() {

	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}

	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 3580
using System;

class Plogram
{
    static void Main()
    {

        var num = int.Parse(Console.ReadLine());

        string rating;
        if(num<1200)
        {
            rating = "ABC";
        }
        else if(num<2800)
        {
            rating = "ARC";
        }
        else
        {
            rating = "AGC";
        }
        Console.WriteLine(rating);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main(){
    int b = 0;
    string a = "CODEFESTIVAL2016",s;
   cin >> s;
   for(int i=0;i<16;i++){
       if(s[i]!=a[i]) b++;
   }
   cout << b << endl;
}

Measured memory_bytes: 256
n,m,k=map(int,input().split())
ab=[tuple(map(int,input().split())) for _ in range(m)]
cd=[tuple(map(int,input().split())) for _ in range(k)]

class UnionFind():
    def __init__(self,n):
        self.n=n
        self.root=[-1]*(n+1)
        self.rnk=[0]*(n+1)

    def Find_Root(self,x):
        if self.root[x]<0:
            return x
        else:
            self.root[x]=self.Find_Root(self.root[x])
            return self.root[x]

    def Unite(self,x,y):
        x=self.Find_Root(x)
        y=self.Find_Root(y)
        if x==y:
            return
        elif self.rnk[x]>self.rnk[y]:
            self.root[x]+=self.root[y]
            self.root[y]=x
        else:
            self.root[y]+=self.root[x]
            self.root[x]=y
            if self.rnk[x]==self.rnk[y]:
                self.rnk[y]+=1

    def isSameGroup(self,x,y):
        return self.Find_Root(x)==self.Find_Root(y)

    def Count(self,x):
        return -self.root[self.Find_Root(x)]

u=UnionFind(n)
for i in range(m):
    a,b=ab[i]
    u.Unite(a,b)
l=[u.Count(i)-1 for i in range(n+1)]
for i in range(m):
    a,b=ab[i]
    l[a]-=1
    l[b]-=1
for i in range(k):
    c,d=cd[i]
    if u.isSameGroup(c,d):
        l[c]-=1
        l[d]-=1
print(*l[1:])


Measured memory_bytes: 115928
import java.util.Map.Entry;
import java.util.*;
import java.math.*;
import org.w3c.dom.css.Counter;
  
public class Main{
    public static void main(String[] args){
 
        Scanner sc = new Scanner(System.in);
        String hoge = sc.next();

        //int countQ = 0;
        hoge = hoge.replace("?", "D");
        System.out.println(hoge);

          /**
        int counQ = 0;
        int positionQ = hoge.indexOf('?');
        while (positionQ != -1) {
            counQ++;
            positionQ = hoge.indexOf('e', positionQ + 1);
          }


          /**
          int countD = 0;
          int positionD = hoge.indexOf('D');
          while (positionD != -1) {
              countD++;
              positionD = hoge.indexOf('D', positionD + 1);
            }

            int countDP = 0;
            int positionDP = hoge.indexOf("DP");
            while (positionDP != -1) {
                countDP++;
                positionDP = hoge.indexOf("DP", positionDP + 1);
              }

              
            int countPQ = 0;
            int positionPQ = hoge.indexOf('D');
            while (positionPQ != -1) {
                countPQ++;
                positionPQ = hoge.indexOf('D', positionDP + 1);
              }

              int countPD = 0;
              int positionPD = hoge.indexOf("DP");
              while (positionDP != -1) {
                    countPD++;
                    positionPD = hoge.indexOf("DP", positionPD + 1);
                }
  


        int H1 = sc.nextInt();
        int M1 = sc.nextInt();
        int H2 = sc.nextInt();
        int M2 = sc.nextInt();
        int K = sc.nextInt();

        int BigH2 = H2-H1;
        int BigH2M2 = BigH2*60+M2;
        int clearTime = BigH2M2-M1;
        int answer = clearTime - K ;
        System.out.println(answer);

/**
        int n = sc.nextInt();
        long k = sc.nextLong();
        int[] a = new int[n];
 
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
 
        // 通った街を記録する配列
        ArrayList<Integer> list = new ArrayList<Integer>();
        list.add(1);    // 一つ目の町
 
        // ループの先頭の町がリストの何番目にあるかを格納する変数
        int check = -1;
 
        // 転送先を格納する変数。
        int temp = 1;   // 計算のため初期値１
 
        for (long i = 0; i < k; i++) {
            temp = a[temp-1];   //　転送先設定
            // 訪れた町かチェック
            // 訪れていた場合、ループ前のイントロ部分の長さを求める
            if (list.contains(temp)) {
                check = list.indexOf(temp);
            	break;
            }
            list.add(temp);
        }
        if(check == -1){
            System.out.println(temp);
        }else{
 
        // 合計移動回数をループ長で割った余りを求める
        int std = (int)(k-check) % (list.size() - check);
 
        System.out.println(list.get((int)(std + check)));
        }
        **/
    }
}

Measured memory_bytes: 40976
fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    println(if (N == M) "Yes" else "No")
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }

Measured memory_bytes: 37864
import copy

def num_from_card(card):
    return int(card[2:])

def partition(A, p, r):
    x = num_from_card(A[r])
    i = p-1
    for j in range(p, r):
        if num_from_card(A[j]) <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1

def quick_sort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quick_sort(A, p, q-1)
        quick_sort(A, q+1, r)

def merge(A, left, mid, right):
    L = A[left: mid]
    R = A[mid: right]
    L.append('  ' + str(int(10e9 + 1)))
    R.append('  ' + str(int(10e9 + 1)))
    i, j = 0, 0
    for k in range(left, right):
        if num_from_card(L[i]) <= num_from_card(R[j]):
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def merge_sort(A, left, right):
    if left + 1 < right:
        mid = int((left + right)/2)
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)

n = int(input())
cards = [input() for i in range(n)]
merge_cards = copy.copy(cards)

quick_sort(cards, 0, n-1)
merge_sort(merge_cards, 0, n)

if merge_cards == cards:
    print('Stable')
else:
    print('Not stable')

for c in cards:
    print(c)



Measured memory_bytes: 14296
from bisect import bisect_left, bisect_right

N, M, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

prefA = [0]
prefB = [0]
for x in A:
    prefA.append(prefA[-1] + x)
for x in B:
    prefB.append(prefB[-1] + x)
best = 0
for a, cumA in enumerate(prefA):
    if K - cumA < 0:
        break
    b = bisect_right(prefB, K - cumA)
    if b == 0:
        continue
    b -= 1
    # print(A[:a], prefA[a], B[:b], prefB[b], sum(A[:a] + B[:b]))
    assert prefB[b] <= K - prefA[a]
    best = max(best, a + b)
print(best)


Measured memory_bytes: 133252
a, b, c, d = [int(x) for x in input()]

for op1 in "+-":
  for op2 in "+-":
    for op3 in "+-":
      ab = a + b if op1 == "+" else a - b
      abc = ab + c if op2 == "+" else ab - c
      abcd = abc + d if op3 == "+" else abc - d
      if abcd == 7:
        print(str(a) + op1 + str(b) + op2 + str(c) + op3 + str(d) + "=7")
        exit()

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

const int INF=1<<30;
const int MaxRC=1e3;
int dx[4]={ 0, 1, 0,-1};
int dy[4]={ 1, 0,-1, 0};

struct DATA{
	int x, y;
	DATA(int x=0,int y=0):x(x),y(y){}
} st, ed, now, nxt;

int main(){
	int R, C, K;
	while(scanf("%d %d %d\n",&R,&C,&K)!=EOF){
		
		scanf("%d %d %d %d\n",&st.x,&st.y,&ed.x,&ed.y);
		st.x--, st.y--, ed.x--, ed.y--;
		vector<vector<char>> mat(R, vector<char>(C));
		for(int i=0;i<R;i++,getchar())
			for(int j=0;j<C;j++)
				mat[i][j]=getchar();
		
		vector<vector<int>> step(R, vector<int>(C,INF));
		queue<DATA> Q;
		Q.push(DATA(st.x,st.y));
		step[st.x][st.y]=0;
		while(Q.empty()==0){
			now=Q.front(); Q.pop();
			if(now.x==ed.x and now.y==ed.y) break;
			for(int i=0;i<4;i++)
				for(int k=1;k<=K;k++){
					nxt=DATA(now.x+k*dx[i],now.y+k*dy[i]);
					if(nxt.x==-1 or nxt.x==R or nxt.y==-1 or nxt.y==C or mat[nxt.x][nxt.y]=='@' or step[nxt.x][nxt.y]<=step[now.x][now.y])
						break;
					if(step[nxt.x][nxt.y]>step[now.x][now.y]+1){
						step[nxt.x][nxt.y]=step[now.x][now.y]+1;
						Q.push(nxt);
					}
				}
		}
		printf("%d\n",(step[ed.x][ed.y]==INF)? -1: step[ed.x][ed.y]);
		
	}
}




Measured memory_bytes: 12044
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>

using namespace std;

int N;

set<int> A[100000]; // iに負けた人集合

int search(int i) {
    if(A[i].empty()) { // 誰にも勝ててない
        return 0;
    }
    vector<int> nums;
    for(auto x : A[i]) {
        //printf("%d <- %d\n", i, x);
        nums.push_back(search(x)+1);
    }
    int max = 0;
    std::sort(nums.begin(), nums.end());
    for(auto t : nums) {
        if(max < t) max = t;
        else if(max >= t) ++max;
    }
    return max;
}


int main() {
    scanf("%d", &N);
    for(int i = 1; i < N; ++i) { // 2 <= i <= N
        int t;
        scanf("%d", &t);
        A[t-1].insert(i);
    }
    /*
    for(int x = 0; x < N; ++x) {
        printf("%d\n", x);
        for(auto t : A[x]) {
            printf("\t%d\n", t);
        }
        printf("\n");
    }
    */
    printf("%d\n", search(0));
    return 0;
}


Measured memory_bytes: 17408
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;

class KT{
    public:
    int _n;
    vector<long long> range, d, d2;
    vector<pair<int, long long>> apEnds;
    KT(int n):range(n,0), d(n,0), d2(n,0), _n(n){}
    
    void addAP(int start, int end, long long a0=1, long long r=1){
        d[start]+=a0;
        if(end<_n-1){
            d[end+1]-=a0;
            d2[end+1]-=r;
            apEnds.push_back(make_pair(end+1,-r*(end-start)));
        }
        if(start<_n-1){
            d2[start+1]+=r;
        }
    }
    
    void update(){
        for(int i=1; i<_n; i++){
            d[i]+=d[i-1];
            d2[i]+=d2[i-1];
        }
        for(auto p:apEnds){
            d2[p.first]+=p.second;
        }
        for(int i=0; i<_n; i++){
            if(i) d2[i]+=d2[i-1];
            range[i]=d[i]+d2[i];
        }
        
    }
    void disp(){
        for(int i:range){
            cout<<i<<" ";
        }
    }
    
};




int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n,m;
    cin>>n>>m;
    
    vector<int> vi(n);
    for(int i=0; i<n; i++){
        cin>>vi[i];
    }
    KT kt(m+1);
    
    long long unModPresses=0;
    for(int i=0; i<n-1; i++){
        if(vi[i]<=vi[i+1]){
            unModPresses+=vi[i+1]-vi[i];
        }
        else{
            unModPresses+=vi[i+1]+(m-vi[i]);
        }
    }
    
    for(int i=0; i<n-1; i++){
        if(vi[i]<=vi[i+1]-2){
            kt.addAP(vi[i]+2,vi[i+1]);
        }
        else if(vi[i]>vi[i+1]){
            if(vi[i]+2<=m){
                kt.addAP(vi[i]+2,m);
            }
            int a0=m-vi[i];
            kt.addAP(1,vi[i+1],a0);
            
        }
    }
    
    kt.update();
    long long maxImp=*max_element(kt.range.begin(),kt.range.end());
    //cout<<unModPresses<<endl;
    cout<<unModPresses-maxImp;
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 5236
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    string S;cin>>S;
    string T;cin>>T;
    string S2=S+S;
    vector<vector<int>> alphabet(26);
    For(i,0,S2.size()){
        alphabet[S2[i]-'a'].push_back(i);
    }
    int p=-1;
    For(i,0,T.size()){
        auto itr=upper_bound(ALL(alphabet[T[i]-'a']),p);
        if(itr==alphabet[T[i]-'a'].end()) {
            ans=-1;
            break;
        }
        else {
            p=(*itr);
            if(p>=S.size()){
                p-=S.size();
                ans+=S.size();
            }
        }
    }
    if(ans>-1) ans+=p+1;
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 1980
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 105;
const int mod = 1000000007;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  string s;
  cin>>s;
  if(s[1]=='B')s[1]='R';
  else s[1]='B';
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 3628
D, G = list(map(int, input().split()))
p = [0]*D
c = [0]*D

ans = 10**9


for i in range(D):
    p[i], c[i] = list(map(int, input().split()))

for i in range(2**D):
    t = 0
    p_ = 0
    tyu = -1
    for j in range(D):
        if i & (1 << j):
            t += p[j]*100*(j+1) + c[j]
            p_ += p[j]
        else:
            if tyu < j:
                tyu = j



    if t >= G:
        ans = min(ans, p_)
    
    else:
        if tyu != -1:
            for j in range(p[tyu]-1):
                t += 100 * (tyu+1)
                p_ += 1
                if t >= G:
                    ans = min(ans, p_)

    
print(ans)

Measured memory_bytes: 3064
def gcd(x, y):
    if y > x:
        x, y = y, x
    while y:
        x, y = y, x % y
    return x

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

l=[0]*N
l[0]=a[0]
for i in range(1,N):
    l[i]=gcd(l[i-1],a[i])

r=[0]*N
r[N-1]=a[N-1]
for i in range(N-2,-1,-1):
    r[i]=gcd(r[i+1],a[i])

ans=max(r[1],l[N-2])
for i in range(1,N-1):
    tmp=gcd(l[i-1],r[i+1])
    if tmp>ans: ans=tmp

print(ans)

Measured memory_bytes: 14436
///17571@nith.ac.in @Ankit Verma
#include <bits/stdc++.h>
using namespace std;
#define ff          first
#define ss          second
#define pb          push_back
#define MP          make_pair
#define int         long long
#define ll          long long
#define inf         0x3f3f3f3f
#define MOD         1000000007
#define ld          long double
#define eb          emplace_back
#define pii         pair<int,int>
#define ull         unsigned long long
#define all(v)      v.begin(), v.end()
#define f(i,x,n)    for(int i=x;i<n;i++)
#define fr(i,x,n)   for(int i=x;i>=n;i--)
#define fastio      ios::sync_with_stdio(false)

#define n_l '\n'
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); } 
#define debug(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl

void IO() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
int32_t main() {
    IO();
    fastio;
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n; cin >> n;
    string s = "abcdefghijklmnopqrstuvwxyz";
    string res;
    while (n > 0) {
      n -= 1;
      int off = n % 26;
      res += s[off];
      n /= 26;
    }
    reverse(all(res));
    cout << res << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F first
#define S second
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define sz size()
#define all(A)    A.begin(), A.end()
#define mem(a, b) memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)   for(ll i=0;i<(b);i++)
#define f1(i,b)   for(ll i=1;i<=(b);i++)
#define f2(i,a,b) for(ll i=(a);i<=(b);i++)
#define f3(i,b,a) for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))
#define mod 1000000007

#define whilee(i,t)  while(i!=t)
#define  sl(a)  scanf("%lld",&a)
#define  pl(a)  printf("%lld\n",a)

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;

//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> A;
//map <ll,ll> A;
//pair <ll,ll> A ;
//vector <pair <ll,ll>> A ;
//bitset<32> bset1;
//char ch;
//string S, T, U;
ll i, j, k, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, cnt=0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);//NULL
    cout.tie(nullptr);//NULL

    //scan(n);
    cin>>n>>m;
    x=n+m;
  if(x%2==0)
  {
    cout<<x/2<<endl;
  }
  else
  {
    cout<<"IMPOSSIBLE"<<endl;
  }
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
 
public class Main {
  final static int max = 100;
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
      int i = 0;
      String N;     
        long A = scan.nextLong();
        double B = scan.nextDouble();
     //   System.out.println(a[i]);
        cal(A,B);
        scan.close();
    }
  
  public static void cal(long a,double b){
     long s = 0;
     long bb;
    bb = Math.round(b*100);
     s = a*bb/100;
     System.out.println(s);
  }
}

Measured memory_bytes: 36816
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
#include <algorithm>
#include <vector>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    if(n<1000) {
        printf("ABC\n");
    }
    else {
        printf("ABD\n");
    }

    return 0;
}


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

public class Main {
	/**
	 * ????????????????????????
	 * @param h
	 * @param w
	 * @return
	 */
	public static int exception(int h,int w){
		int result = 0;
		if(3 <= h && h <= 300 && 3 <= w && w <= 300){ //??????????????????(??\????¶???????)
			result = 2;
		}
		else if(h == 0 && w == 0){
			result = 1; //0,0??\?????§??\???????????????
		}
		else{
			System.out.println("3~300????????§??\?????????????????????.???????????????.");
			result = 0;
		}
		return result;
	}
	public static void main(String[] args) {
		/**
		 * ?????°?????£?¨?
		 */
		int a = 0;
		int t = 0, inc = 0;
		int h = 0,w = 0; //height:h width:w
		int x = 0;
		/**
		 * ???????????£?¨?
		 */
		ArrayList<String> st = new ArrayList<String>();
		ArrayList<Integer> parse = new ArrayList<Integer>();
		/**
		 * ????¨???????????????\???
		 */
		Scanner scan = new Scanner(System.in);
		while(a == 0){
		for (t = 0; t < 2; t++){ //??´??°2???????????????
		st.add(scan.next());
		}
		h = Integer.parseInt(st.get(inc));
		w = Integer.parseInt(st.get(inc+1));
		parse.add(h);
		parse.add(w);
		if(exception(h,w) == 1){ //h=w=0?????¨??????????????????????????????
			break;
		}
		else if(exception(h,w) == 0){ //??????????????????????????????.
			System.exit(0);
		}
		inc = inc + 2; //???????????§?????°
		}
		/**
		 * ??????
		 */
		for(int n= 1; n < ((parse.size())/2) ; ++n){ //???????????°??????
		 for(int i = 0; i < parse.get(2*(n-1)); ++i){ //hight
			for(int j = 0; j < parse.get(2*n-1); ++j){ //width
				if(i == 0 || i == parse.get(2*(n-1))-1){
				System.out.print("#");
				}
				else if(j == 0 || j == parse.get(2*n-1)-1){
					System.out.print("#");
				}
				else{
					System.out.print(".");
				}
			}
			System.out.println("");
		 }
		 System.out.println("");
		}
	}
}

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

using namespace std;
const int mod = 1000000007;

int main(){
    int N, Q;
    long long int K;
    cin >> N >> K >> Q;
    vector<int> A(Q);
    vector<int> B(N);
    for (int i = 0; i < Q; i++){
        cin >> A.at(i);
        B.at(A.at(i)-1)++;
    }

    for (int i = 0; i < N; i++){
        if(Q - B.at(i) >= K){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }

}

Measured memory_bytes: 1408
n = int(input())
m = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

ans = 0
for i in range(n):
    if b[i] >= m[i]:
        ans += m[i]
        b[i] -= m[i]
        m[i] = 0
        if b[i] > 0:
            if m[i + 1] >= b[i]:
                m[i + 1] -= b[i]
                ans += b[i]
            else:
                ans += m[i + 1]
                m[i + 1] = 0
    else:
        ans += b[i]
        m[i] -= b[i]
print(ans)


Measured memory_bytes: 82020
N,K = map(int,input().split())
XY = [list(map(int,input().split())) for _ in [0]*N]

iX = sorted(x for x,y in XY)
iY = sorted(y for x,y in XY)
X = {x:i for i,x in enumerate(iX)}
Y = {y:i for i,y in enumerate(iY)}

c = [[0]*(N+1) for i in [0]*(N+1)]
for x,y in XY:
    c[Y[y]+1][X[x]+1] = 1

for i in range(N):
    for j in range(N):
        c[i+1][j+1] += c[i+1][j]
for i in range(N):
    for j in range(N):
        c[i+1][j+1] += c[i][j+1]

ans = 10**20
for l in range(N):
    for r in range(l+1,N):
        u = 0
        d = 1
        while d<N:
            if c[d+1][r+1]+c[u][l]-c[u][r+1]-c[d+1][l] >=K:
                ans = min(ans,
                         (iX[r]-iX[l])*(iY[d]-iY[u]))
                u+=1
            else:d+=1

print(ans)

Measured memory_bytes: 3064
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define reps(i, s, n) for (int i = s; i < (int)(n); ++i)
using namespace std;
using ll = long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
constexpr int INF = 1e9 + 7;
constexpr ll LINF = 1LL << 60;

void solve() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    int ans = 2 * n;
    reps(i, 1, n + 1) {
        if (s.substr(n - i) == t.substr(0, i)) {
            ans = 2 * n - i;
        }
    }
    cout << ans << "\n";
}
int main() {
    cin.tie(nullptr);
    // ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3520
#include <iostream>
using namespace std;
int main(void){
    int N,A[3][110]={},i,j,n,max,c[110]={};
    cin>>N;
    for(i=1;i<=2;i++){
        for(j=1;j<=N;j++){
            cin>>A[i][j];
        }
    }
    for(n=1;n<=N;n++){
        for(j=1;j<=n;j++){
            c[n]+=A[1][j]; //+A[2][j+1];
            //cout<<"c["<<n<<"]="<<c[n]<<endl;
        }
        for(j=n;j<=N;j++){
            c[n]+=A[2][j]; //+A[1][j-1];
            //cout<<"c["<<n<<"]="<<c[n]<<endl;
        }
    }
    max=c[1];
    for(i=2;i<=N;i++){
        if(max<c[i]) max=c[i];
    }
    cout<<max;
}


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


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

    long long i,j,k,l,m,n,o,p;
   cin>>p;
   int a=0,b=0,c=0,d=0;
   while(p--){
    char s[5];
    cin>>s;
    if(s[0]=='A') a++;
    if(s[0]=='W')b++;
    if(s[0]=='T')c++;
    if(s[0]=='R')d++;}
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;




    return 0;


}


Measured memory_bytes: 3588