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

using namespace std;

using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<ll> v(n);
  unordered_map<int, ll> mp;
  for (auto &&x : v) {
    cin >> x;
    mp[x]++;
  }
  sort(v.begin(), v.end());
  int ans = 0;
  for (ll i = (1LL << 31); i > 0; i >>= 1) {
    for (int j = 0; j < n; ++j) {
      if (v[j] > i - v[j])
        break;
      if (v[j] == i - v[j]) {
        if (mp[v[j]] >= 2) {
          mp[v[j]] -= 2;
          // cout << 1 << endl;
          ans++;
        }
        continue;
      }
      if (mp[v[j]] && mp[i - v[j]]) {
        mp[v[j]]--;
        mp[i - v[j]]--;
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 33808
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
 
int a[5];
 
int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	FOR(i, 3) cin >> a[i];
	sort(a, a+3);
	cout << (a[0] == a[1] ? a[2] : a[0]) << endl;
	return 0;
}

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i++)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

//library----------------------------------------------

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

int H,W,ans;
vector<string> field(NMAX);
bool seen[NMAX][NMAX];

//    void dfs(int h,int w){
//        seen[h][w]=true;
//
//        for(int dir=0;dir<4;dir++){
//            int nh=h+dx[dir];
//            int nw=w+dy[dir];
//
//            if(nh<0||nh>=H||nw<0||nw>=W) continue;
//            if(field[nh][nw]=='#') continue;
//            if(seen[nh][nw]) continue;
//            dfs(nh,nw);
//        }
//    }

struct node{
    int x,y,dis;
};

void bfs(int x,int y){
    memset(seen,0,sizeof(seen));
    int head=0,tail=1;
    queue<node> q;
    node now={x,y,0}; seen[x][y]=1;
    q.push(now);
    while(!q.empty()){
        now=q.front();
        q.pop();
        ans<now.dis?ans=now.dis:0;
        rep(k,4){
            int nh=dx[k]+now.x,nw=dy[k]+now.y;
            if(nh<0||nh>=H||nw<0||nw>=W) continue;
            if(field[nh][nw]=='#') continue;
            if(!seen[nh][nw]){
                seen[nh][nw]=1;
                node next={nh,nw,now.dis+1};
                q.push(next);
            }
        }
    }
}

int main(){
    cin>>H>>W;
    rep(h,H)cin>>field[h];
    rep(i,H){
        rep(j,W){
            if(field[i][j]!='#') bfs(i,j);
        }
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
using namespace std;



int main() {
    int A, B, M;
    cin >> A >> B >> M;

    long long min_a = INF, min_b = INF;
    vector<long long> a(A+1), b(B+1);
    for (int i = 1; i <= A; ++i) {
        cin >> a[i];
        min_a = min(min_a, a[i]);
    }
    for (int i = 1; i <= B; ++i) {
        cin >> b[i];
        min_b = min(min_b, b[i]);
    }

    vector<long long> x(M), y(M), c(M);
    for (int i = 0; i < M; ++i) {
        cin >> x[i] >> y[i] >> c[i];
    }

    long long min_ab = min_a + min_b;
    long long sum = 0, ans = min_ab;
    for(int i = 0; i < M; ++i) {
        sum = a[x[i]] + b[y[i]] - c[i];
        ans = min(ans, sum);
    }

    cout << ans << endl;
}

Measured memory_bytes: 4224
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	ll a, b, c;
	cin >> a >> b >> c;

	string ans;
	if (c - b - a < 0) {
		ans = "No";
	} else if (4 * a * b < (c - b - a) * (c - b - a)) {
		ans = "Yes";
	} else {
		ans = "No";
	}

	cout << ans << endl;

	return 0;
}

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

#define endl '\n'

using namespace std;

const int maxn = 2e5 + 3;

int k, n;
int a[maxn];
void read()
{
    cin >> k >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
}

void solve()
{
    int ans = k;
    for (int i = 2; i <= n; i++)
        ans = min(ans, k - (a[i] - a[i-1]));

    ans = min(ans, k - (a[1] + k - a[n]));

    cout << ans << endl;
}

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

    read();
    solve();
}


Measured memory_bytes: 1024
A,B,C,K=map(int,input().split())
ans=0
ans+=1*min(A,K)
if K-A<=0:
    K=0
else:
    K=K-A
ans+=0*min(B,K)
if K-B<=0:
    K=0
else:
    K=K-B
ans-=1*min(C,K)
print(ans)

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

using namespace std;

vector<int>adj[300000];

int n,q;

vector<int>v(300000);

void DFS(int s,int e)
{
    for(auto u:adj[s])
    {
        if(u==e) continue;
        v[u]+=v[s];
        DFS(u,s);
    }
}


int main()
{

    cin>>n>>q;

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

    for(int i=0;i<q;i++)
    {
        int p,x;
        cin>>p>>x;
        v[p]+=x;
    }

    DFS(1,0);

    for(int i=1;i<=n;i++)
    {
        cout<<v[i]<<' ';
    }
return 0;
}


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

#define INF (INT32_MAX/2)

int main() {
	int N;

	cin >> N;
	vector<int> W( N );
	for( int i = 0; i < N; i++ ) {
		cin >> W[i];
	}

	int ans = INF;
	for( int i = 0; i < N; i++ ) {
		int res1 = 0;
		int res2 = 0;
		for( int j = 0; j < i; j++ ) {
			res1 += W[j];
		}
		for( int j = i; j < N; j++ ) {
			res2 += W[j];
		}
		ans = min( ans, abs(res1- res2) );
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int L = sc.nextInt();
    int ans = 0;
    boolean zero = false;
    int min = 50000;
    int max = -50000;
    for (int i=1;i<=N;i++){
      ans += i + L-1;
      
      min = Math.min(min,(i+L-1));
      max = Math.max(max,(i+L-1));
      if ((i+L-1) == 0){
        zero = true;
      }
    }
    
    if (zero){
     
    }else{
      if (Math.abs(min) <= Math.abs(max)){
        ans -= min;
      }else{
        ans -= max;
      }
    }
    System.out.println(ans);
    
  }
}

Measured memory_bytes: 21588
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 100005
typedef long long ll;

int n;
int a[maxn];

inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

bool check(ll x,bool bo){
	for (int i=1;i<=n;i++) x-=x%a[i];
	return bo?x<=2:x>=2;
}

int main(){
	n=read();
	for (int i=1;i<=n;i++) a[i]=read();
	ll l=0,r=1e18,ansl=-1,ansr=-1;
	while (l<=r){
		ll mid=(l+r)>>1;
		if (check(mid,0)) r=mid-1,ansl=mid;
		else l=mid+1;
	}
	l=0,r=1e18;
	while (l<=r){
		ll mid=(l+r)>>1;
		if (check(mid,1)) l=mid+1,ansr=mid;
		else r=mid-1;
	}
	if (ansl>ansr) puts("-1");
	else cout<<ansl<<' '<<ansr<<endl;
	return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define INF 115292150460684697

using P = pair<i64, i64>;
vector<i64> G[1'000'000];
i64 ID[1'000][1'000];

P norm(P p) {
    if (p.first > p.second) {
        swap(p.first, p.second);
    }
    return p;
}

bool seen[1'000'000];
bool finished[1'000'000];
i64 d[1'000'000];
i64 dfs(i64 u) {
    seen[u] = true;
    i64 maxl = 1;
    for (i64 v : G[u]) {
        if (finished[v]) {
            chmax(maxl, d[v] + 1);
            continue;
        }

        if (seen[v]) {
            cout << -1 << endl;
            exit(0);
        }
        chmax(maxl, dfs(v) + 1);
    }
    finished[u] = true;
    d[u] = maxl;
    return maxl;
}

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

    set<P> start;
    REP(u, N) {
        for (i64 v = u + 1; v < N; v++) {
            start.emplace(u, v);
        }
    }

    i64 curId = 0;
    REP(u, N) {
        i64 req;
        REP(j, N - 1) {
            i64 v; cin >> v;
            v--;
            P p = norm({u, v});
            i64 id = ID[p.first][p.second];
            if (id == 0) {
                curId++;
                id = curId;
                ID[p.first][p.second] = id;
            }
            if (j > 0) {
                G[req].pb(id);
                start.erase(p);
            }
            req = id;
        }
    }

    i64 maxl = -1;
    for (auto s : start) {
        chmax(maxl, dfs(ID[s.first][s.second]));
    }
    if (maxl == -1) {
        cout << -1 << endl;
    } else {
        cout << maxl << endl;
    }

    return 0;
}


Measured memory_bytes: 70056
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
int n;
char s[110];
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	scanf("%s",s+1);
	if (n&1) { printf("No\n"); return 0; }
	for (int i=1;i<=n/2;i++)
		if (s[i]!=s[i+n/2]) { printf("No\n"); return 0; }
	printf("Yes\n");
	return 0;
}
/*
  REMEMBER:
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Array size? Integer overflow? Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 256
#include <cstdio>

int N, M;
int a[200001], b[200001];

bool con_to_N[200001];

void solve() {
	for (int i = 1; i <= M; i++) {
		con_to_N[a[i]] = (b[i] == N);
	}

	bool possible = false;
	for (int i = 1; i <= M; i++) {
		if (a[i] == 1 && con_to_N[b[i]]) {
			possible = true;
		}
	}

	printf("%s\n", possible ? "POSSIBLE" : "IMPOSSIBLE");
}

int main() {
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= M; i++) {
		scanf("%d%d", &a[i], &b[i]);
	}

	solve();
	return 0;
}



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

int main() {
  int n,k;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> k;
    arr[k-1]=i+1;
  }
  for (int i = 0; i < n; i++) {
    cout << arr[i] << " ";
  }
}

Measured memory_bytes: 1152
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define PB push_back
#define endl "\n"
#define MOD 1000000007
#define MOD2 998244353
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
typedef pair<int, int> pr;
typedef vector<int> VI;
typedef vector<pr> VP;
typedef vector<string> VS;
typedef vector<vector<int>> VV;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace(v) for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
const int inf = 1e17;
int fast_pow(int x, int y, int p);
const int sz = 300001;
int st[4*sz];
int n;

void update(int ss, int se, int i, int val, int si){
	if (i < ss || i > se){
		return;
	}
	if (ss==se)
	{
		st[si] = val;
		return ;
	}
	int mid = (ss+se)/2;

	if (i >= ss && i <= mid)
		update( ss, mid, i,val, 2 * si + 1);
	else
		update( mid + 1, se,i, val, 2 * si + 2);

	st[si] = max(st[2 * si + 1],st[2 * si + 2]);
}

int get_max(int ss, int se, int qs, int qe, int si){
	if (qs <= ss && qe >= se)
		return st[si];
	if (se < qs || ss > qe)
		return 0;
	int mid = (ss+se)/2;
	return max(get_max(ss, mid, qs, qe, 2 * si + 1) ,get_max(mid + 1, se, qs, qe, 2 * si + 2));
}



void solve() {
	cin>>n;
	int a[n],b[n];
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)cin>>b[i];
	int ans = 0;
	for(int i=0;i<n;i++){
		int left = get_max(0,n-1,0,a[i]-1,0);
		ans = max(ans,left+b[i]);
		update(0,n-1,a[i],left+b[i],0);
	}
	cout<<ans<<endl;

}


int32_t main() {

	IOS;
	int test = 1;
	// cin>>test;
	for (int i = 1; i <= test; i++) {
        // cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}
int fast_pow(int x, int y, int p) {
	int res = 1;
	x = x % p;
	while (y > 0) {
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    vector<ll> ans(N, 0);
    rep(i, N) {
        if (i % 2) {
            ans[0] -= A[i];
        }
        else ans[0] += A[i];
    }

    repd(i, 1, N) {
        ans[i] = 2 * A[i - 1] - ans[i - 1];
    }

    rep(i, N) cout << ans[i] << endl;
    return 0;
}

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

int main() {
    ll n;
    cin >> n;
    if(n%2==0){
        ll m = 10;
        ll ans = 0;
        while(1){
            if(m > n) break;
            ans += n/m;
            // cout << n/m << endl;
            m*=5;
        }
        cout << ans << endl;
    }else cout << 0 << endl;

}

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

class Dice{
public:
  vector<int> side;

  Dice(vector<int> _side){
    side = _side;
  }
  void rotate(char c){
    vector<int> t;
    if(c == 'N') t = {1, 5, 2, 3, 0, 4};
    else if (c == 'S') t = {4, 0, 2, 3, 5, 1};
    else if (c == 'E') t = {3, 1, 0, 5, 4, 2};
    else if (c == 'W') t = {2, 1, 5, 0, 4, 3};
    else if (c == 'L') t = {0, 3, 1, 4, 2, 5};
    else if (c == 'R') t = {0, 2, 4, 1, 3, 5};
    vector<int> new_side(6);
    for(int i = 0; i < 6; i++) new_side[i] = side[t[i]];
    side = new_side;
  }
  void rotate(char c, int n){
    for(int i = 0; i < n; i++) rotate(c);
  }
};

int main(){
  vector<int> _side(6);
  for(int i = 0; i < 6; i++) cin >> _side[i];
  Dice d1(_side);
  for(int i = 0; i < 6; i++) cin >> _side[i];
  Dice d2(_side);
  Dice d1_cp = d1;
  for(int x = 0; x < 4; x++){
    for(int y = 0; y < 4; y++){
      for(int z = 0; z < 4; z++){
        d1_cp.rotate('N', x);
        d1_cp.rotate('E', y);
        d1_cp.rotate('L', z);
        if(d1_cp.side == d2.side){
          cout << "Yes" << endl;
          return 0;
        }
        d1_cp = d1;
      }
    }
  }
  cout << "No" << endl;
}



Measured memory_bytes: 3144
#include <iostream>
#include <vector>
   
int main(void) {
    u_int N;    // the number of integer
    std::vector<std::vector<u_long>> dp;
    std::vector<u_int> seq;
      
    std::cin >> N;
    seq.reserve(N);
    dp.resize(N);
    for (u_int i = 0; i < N; ++i) {
        u_int tmp;
        std::cin >> tmp;
        seq.push_back(tmp);
        dp[i].resize(21, 0);
    }
      
    // solve by dp
    dp[0][seq[0]] = 1;  // initialization
    for (u_int i = 1; i < N - 1; ++i) {
        for (u_int j = 0; j < 21; ++j) {
            if (dp[i - 1][j] > 0) {
                if (j + seq[i] <= 20) {
                    dp[i][j + seq[i]] += dp[i - 1][j];
                }
                if (j >= seq[i]) {
                    dp[i][j - seq[i]] += dp[i  -1][j];
                }
            }
        }
    }
    std::cout << dp[N - 2][seq[N - 1]] << std::endl;
   
    return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Graph vector<vector<ll>>
constexpr ll INF=(1ll<<60);
constexpr ll mod=1000000007;
constexpr double pi=3.14159265358979323846;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
	ll n;cin>>n;
	vector<ll> march(5);

	rep(i,n){
		string s;cin>>s;
		if(s[0]=='M') march[0]++;
		if(s[0]=='A') march[1]++;
		if(s[0]=='R') march[2]++;
		if(s[0]=='C') march[3]++;
		if(s[0]=='H') march[4]++;
	}

	ll ans=0;
	rep(i,(1<<5)){
		if(__builtin_popcount(i)!=3) continue;

		ll prd=1;
		rep(j,5){
			if((i>>j)&1){
				prd*=march[j];
			}
		}

		ans+=prd;
	}

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

Measured memory_bytes: 3600
/*
ID: thanhvq1
LANG: C++14
PROB: namenum
*/

#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;
//#define int long long
#define double long double
#define vec vector
#define vi vector<int>
#define FZ(n) memset((n),0,sizeof(n))
#define FMO(n) memset((n),-1,sizeof(n))
#define unset unordered_set
#define ii pair<int, int>
#define vii vector<ii>
#define F first
#define S second
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)(x).size())
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first, l.second+r.second};
} 
typedef void (*callback_function)(void); // type for conciseness
const long long ZERO = 0LL;
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0L);
const double EPS = static_cast<double>(1e-9);
typedef long long ll;

void FILEIO() {  freopen("in.txt", "r", stdin);  freopen("out.txt", "w", stdout); }
//void FILEIO() {  freopen("namenum.in", "r", stdin);  freopen("namenum.out", "w", stdout); }
void input() {   }
const int M = 1e6;

void solve() {
	int r, d, x2000; cin >> r >> d >> x2000;
	vi ans(11);
	ans[0]=x2000;
	FOR(i, 1, 11) {
		ans[i] = r * ans[i-1]-d;

//		cout << ans[i-1] << " * " << r << " - " << d << " = " << endl;

	}
	FOR(i, 1, 11) cout << ans[i] << endl;
}

//#undef int
signed main() {
//#define int long long
  ios_base::sync_with_stdio(false); cin.tie();
//  FILEIO();
//auto beginProgram = chrono::steady_clock::now();

//  while (1)
//  {
		input();
		solve();
//  }

  //auto endProgram = chrono::steady_clock::now();

  return 0;
}


Measured memory_bytes: 256
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')


def maxdiff(s1, s2, s3):
    return max(abs(s1-s2), abs(s2-s3), abs(s3-s1))

def solve():
    h,w = f()
    ans = int(1e10)

    for hc in range(h):
        s1 = hc * w

        h2 = (h-hc)//2
        h3 = h - hc -h2
        s2 = h2 * w
        s3 = h3 * w

        ans = min(ans, maxdiff(s1, s2, s3))

        w1 = w//2
        w2 = w - w1
        s2 = w1 * (h-hc)
        s3 = w2 * (h-hc)
        ans = min(ans, maxdiff(s1, s2, s3))


    for wc in range(w):
        s1 = wc * h

        w2 = (w-wc)//2
        w3 = w - wc -w2
        s2 = w2 * h
        s3 = w3 * h

        ans = min(ans, maxdiff(s1, s2, s3))

        h1 = h//2
        h2 = h - h1
        s2 = h1 * (w-wc)
        s3 = h2 * (w-wc)
        ans = min(ans, maxdiff(s1, s2, s3))



    print(ans)



solve()


Measured memory_bytes: 3064
S=input()
Odd=S[::2]
Even=S[1::2]

X=0
import math
for i in range(math.ceil(len(S)/2)):
    if Odd[i]=="L":
        X+=1

for i in range(len(S)//2):
    if  Even[i]=="R":
        X+=1

if X==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
ll cnt[100];
int main(){
  ll n,m,k,a;
  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>k;
    for(int j=0;j<k;j++){
      cin>>a;
      cnt[a]++;
    }
  }
  ll ans=0;
  for(int i=1;i<=m;i++)if(cnt[i]==n)ans++;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import numpy
H, W, M = [int(x) for x in input().split()]

width = numpy.array([0] * W, dtype='int64')
height = numpy.array([0] * H, dtype='int64')

obj = set()
for i in range(M):
    h, w = [int(x) - 1 for x in input().split()]

    width[w] += 1
    height[h] += 1
    obj.add((h, w))

result_h = set(numpy.where(height == numpy.max(height))[0])
result_w = set(numpy.where(width == numpy.max(width))[0])

if len(result_h) * len(result_w) > M:
    print(numpy.max(height) + numpy.max(width))
    exit()

for h in result_h:
    for w in result_w:
        if not (h, w) in obj:
            print(numpy.max(height) + numpy.max(width))
            exit()

print(numpy.max(height) + numpy.max(width) - 1)


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    char x;
    cin >> x;
    cout << char(x+1) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class UnionFind {
    private int[] _parent;
    private int[] _rank;
    
    public int find(int i){
      int p = _parent[i];
      if(i == p){
        return i;
      }
      return _parent[i] = find(p);
    }
    
    public void union(int i, int j){
      int root1 = find(i);
      int root2 = find(j);
      
      if(root1 == root2){
        return;
      }
      
      if(_rank[root1] > _rank[root2]){
        _parent[root2] = root1;
      } else if(_rank[root2] > _rank[root1]){
        _parent[root1] = root2;
      } else{
        _parent[root2] = root1;
        _rank[root1]++;
      }
    }
    
    public UnionFind(int max){
      _parent = new int[max];
      _rank = new int[max];
      
      for(int i = 0; i < max; i++){
        _parent[i] = i;
      }
    }
    
    public boolean same(int i, int j){
      int root1 = find(i);
      int root2 = find(j);
      
      return root1 == root2;
    }
}

public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int M = sc.nextInt();
      UnionFind uf = new UnionFind(N);
      
      // 都市を結ぶ
      for(int i = 0; i < M; i++){
        int A = sc.nextInt()-1;
        int B = sc.nextInt()-1;
        
        uf.union(A,B);
      }
      
      // 必要な道路数カウント
      int count = 0;
      for(int i = 0; i < N; i++){
        if(!uf.same(0,i)){
          uf.union(0,i);
          count++;
        }
      }
      
      // 出力
      System.out.println(count);
    }
    

}

Measured memory_bytes: 59544
#include<stdio.h>

int main(void){
  int i,j,k,n,rs;
  char ch[300];
  int a,b,ansa=0,ansb=0;
  char tc,hc,ac,ic,sc;
  char hoge;

  scanf("%d%c",&n,&hoge);
  for(i=0;i<n;i++){
    for(j=0;;j++){
      scanf("%c",&ch[j]);
      if(ch[j]=='\n')
        break;
    }
    ch[j]=0;

    rs=0;
    for(a=3;a<200;a+=2){
      for(b=0;b<30;b++){
        tc=(a*('t'-'a')+b)%26+'a';
        hc=(a*('h'-'a')+b)%26+'a';
        ac=(a*('a'-'a')+b)%26+'a';
        ic=(a*('i'-'a')+b)%26+'a';
        sc=(a*('s'-'a')+b)%26+'a';

        for(j=0;ch[j+3];j++)
          if(ch[j]==tc && ch[j+1]==hc)
            if(ch[j+2]==ac && ch[j+3]==tc ||
                ch[j+2]==ic && ch[j+3]==sc){
              ansa=a;
              ansb=b;
              rs=1;
              break;
            }
        if(rs) break;
      }
      if(rs) break;
    }
    
    for(j=0;ch[j];j++)
      if('a'<=ch[j] && ch[j]<='z'){
        ch[j]-=('a'+ansb);
        for(;ch[j]<0;)
          ch[j]+=26;
        for(k=0;;k++)
          if((ch[j]+k*26)%ansa==0){
            ch[j]=(ch[j]+k*26)/ansa;
            ch[j]+='a';
            break;
          }
      }

    printf("%s\n",ch);
  }

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);
 
using namespace std;
 
namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;
 
int n, q;
ll sum[100010], sum2[100010], a[100000];
 
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	cin >> n >> q;
	rep(i, n){
		cin >> a[i]; a[i] *= 2;
		sum[i + 1] = sum[i] + a[i];
		sum2[i + 1] = sum2[i] + (i % 2 ? 0 : a[i]);
	}
	while(q--){
		ll x; cin >> x; x *= 2;
		ll lo = 0, hi = 2e9, mid;
		while(lo + 1 < hi){
			mid = (lo + hi) / 2;
			int l = lower_bound(a, a + n, x - mid) - a;
			int r = lower_bound(a, a + n, x + mid) - a;
			if(r - l > n - r) hi = mid;
			else lo = mid;
		}
		int l = lower_bound(a, a + n, x - lo) - a;
		int r = lower_bound(a, a + n, x + lo) - a;
		
		ll ans = sum[n] - sum[r];
		int res = l - (r - l != n - r);
		if(res % 2) ans += sum2[res];
		else ans += sum[res] - sum2[res];
		cout << ans / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 4096
#include<cstdio>
#include<cmath>
const double pi=acos(-1.0);
int n;
double a[3010],ansx,ansy,L;
int main(){
	scanf("%d%lf",&n,&L);
	for(int i=1;i<=n;i++)scanf("%lf",&a[i]);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++){
			double A=(a[i]+a[j])/2,X=cos(2.0*pi*A/L),Y=sin(2.0*pi*A/L);
			ansx+=X*(n-2-(j-i-1)),ansy+=Y*(n-2-(j-i-1));
			X=-X,Y=-Y;
			ansx+=X*(j-i-1),ansy+=Y*(j-i-1);
		}
	double sum=1ll*n*(n-1)*(n-2)/6;
	printf("%.10lf %.10lf",ansx/sum,ansy/sum);
}

Measured memory_bytes: 128
N = int(input())
A, B = map(int, input().split())
p_list = list(map(int, input().split()))

first_list = list(filter(lambda x: x <= A, p_list))
second_list = list(filter(lambda x: A + 1 <= x <= B, p_list))
third_list = list(filter(lambda x: x >= B + 1, p_list))

print(min(map(len, [first_list, second_list, third_list])))

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define DELNL        cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}

int main()
{
    ll maxi=-1,cnt=0;
    ll n=in();vector<ll>a(n);
    REP(i,n){
        ll foo=in();
        if(foo==maxi){
            ++cnt;
        }else if(foo>maxi){
            maxi=foo;
            cnt=1;
        }
        a[i]=foo;
    }
    ll maxi2=-1;
    REP(i,n){
        if(a[i]!=maxi){
            maxi2=max(maxi2,a[i]);
        }
    }
    REP(i,n){
        if(a[i]<maxi){
            cout<<maxi<<endl;
        }else{
            if(cnt==1){
                cout<<maxi2<<endl;
            }else{
                cout<<maxi<<endl;
            }
        }
    }
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
string st;
int main(){
	long long n,i,j,k,f[100010];
	cin>>n;
	cin>>st;
	for(i=0;i<=1;i++)
		for(j=0;j<=1;j++){
			f[0]=i;
			f[1]=j;
			for(k=1;k<=n-2;k++)
				f[k+1]=(st[k]=='o'?0:1)^f[k-1]^f[k];
			if(f[0]==((st[n-1]=='o'?0:1)^f[n-2]^f[n-1])&&f[n-1]==((st[0]=='o'?0:1)^f[0]^f[1])){
				for(i=0;i<=n-1;i++)cout<<(f[i]==1?'W':'S');
				return 0;
			}
		}
	cout<<-1;
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long double p=3.14159265358979323846;
    long double a;
    cin>>a;
    cout<<2.0*p*a<<endl;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    cin>>N;
    vector<ll> A(N+1);
    vector<ll> B(N);
    rep(i,N+1) cin>>A.at(i);
    rep(i,N) cin>>B.at(i);
    ll counter=0;
    rep(i,N+1) counter+=A.at(i);
    rep(i,N) {
        if(B.at(i)<=A.at(i)) {
            A.at(i)-=B.at(i);
            if(A.at(i)<0) A.at(i)=0;
        }
        else {
            A.at(i+1)=(A.at(i+1)+A.at(i)-B.at(i));
            if(A.at(i+1)<0) A.at(i+1)=0;
            A.at(i)=0;
        }
    }
    ll after=0;
    rep(i,N+1) {
        if(A.at(i)<0) A.at(i)=0;
    } 
    /*rep(i,N+1) {
        cout<<A.at(i)<<" ";
    }*/
    cout<<endl;
    rep(i,N+1) {
        after+=A.at(i);
    }
    cout<<counter-after<<endl; 
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
using namespace std;
typedef long long ll;
const ll inf = 0x3f3f3f3f3f3f3f;
const int maxn = 100100;
vector<int> p[maxn];
priority_queue<int> q;
int main(void)
{
    int n,m;
    int a,b;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%d%d",&a,&b);
        p[a].push_back(b);
    }
    int ans = 0;
    for(int i=1;i<maxn;i++) sort(p[i].begin(),p[i].end());
    for(int i=1;i<=m;i++){
        for(int j=0;j<p[i].size();j++){
            q.push(p[i][j]);
        }
        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 5632
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main() {
  unsigned short *A, *B; // �T�C�Y�̏����ȕ����Ȃ��̐����^
  int C[VMAX+1];
  int n, i, j;

  scanf( "%d" , &n );
  A = malloc((n+1) * sizeof(short));
  B = malloc((n+1) * sizeof(short));
  for ( i=1; i<=n; i++ ) scanf( "%d" , &A[i] );

  // �\�[�g�J�n
  for ( i=0; i<VMAX+1; i++ ) C[i] = 0;
  for ( j=1; j<=n; j++ ) C[A[j]]++; // C[i] �� i �̏o�������L�^����
  for ( i=1; i<VMAX+1; i++ )
    C[i] = C[i] + C[i-1]; // C[i] �� i �ȉ��̐��̏o�������L�^����
  for ( j=n; j>0; j-- ) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i=1; i<=(n-1); i++ ) printf( "%d " , B[i] );
  printf( "%d\n" , B[n] );
  
  return 0;
}



Measured memory_bytes: 9636
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n,m;
    while(scanf("%d%d",&n,&m),n||m){
        int mav=0,mac=n+m;
        for(int i=1;i<5;i++){
            scanf("%d%d",&n,&m);
            if(n+m>mac){
                mac=n+m;
                mav=i;
            }
        }
        printf("%c %d\n",'A'+mav,mac);
    }

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

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

void solve() {
  int a;
  cin >> a;
  cout << exp(a, 1) + exp(a, 2) + exp(a, 3) << endl;
}


Measured memory_bytes: 3652
#include<stdio.h>

int main()
{
    char S[10],T[11],A[10];
    int l1,l2,l3,i,a=0;
    scanf("%s %s",S,T);
    l1=strlen(S);
    l2=strlen(T);
    l3=l2-1;
    for(i=0;i<l3;i++)
    {
      A[i]=T[i];
    } 
    for(i=0;i<l1;i++)
    {
      if(S[i] == A[i])
      {
        a++;
      }
    }
    if(a == l1)
    { 
      printf("Yes\n");
    } 
    else
    {
      printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1648
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	printf("%d\n",min(a,b)+min(c,d));
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<cassert>

int top, S[1000];

void push(int x) {
	S[++top] = x;
}

int pop() {
	top--;
	return S[top + 1];
}

int main() {
	int a, b, x, no, np;
	top = 0;
	char s[100];
	no = np = 0;
	while (scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
			no++;
		}
		else if (s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
			no++;
		}
		else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
			no++;
		}
		else {
			x = atoi(s);
			assert(0 <= x && x <= 1000000);
			push(x);
			np++;
		}
	}

	printf("%d\n", pop());

	return 0;
}


Measured memory_bytes: 2740
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define inf 1e9
#define mod 1000000007
#define endl "\n"
#define ff first
#define ss second

void solve()
{
	int n;
	cin >> n;
	int arr[n];
	multiset<int> m1;
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
		m1.insert(arr[i]);
	}

	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		bool check = true;
		int ele = arr[i];
		m1.erase(m1.find(arr[i]));
		for (int a = 1; a * a <= arr[i]; a++)
		{
			if (arr[i] % a == 0)
			{
				if (a * a == arr[i])
				{
					if (m1.find(a) != m1.end())
					{
						check = false;
						break;
					}
				}
				else
				{
					if (m1.find(a) != m1.end())
					{
						check = false;
						break;
					}
					if (m1.find(arr[i] / a) != m1.end())
					{
						check = false;
						break;
					}
				}
			}
		}
		m1.insert(ele);
		if (check)
			cnt++;
	}

	cout << cnt;
}

signed main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 14540
N, X = map(int, input().split())
a, p = [1], [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)
def f(N, X): # X <= 0 や X > a_N を許容し解説本文から簡略化
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a[N-1]:
        return f(N-1, X-1)
    else:
        return p[N-1] + 1 + f(N-1, X-2-a[N-1])
print(f(N, X))

Measured memory_bytes: 3064
S = list(raw_input())

mx_cnt = 0
cnt=0

for c in S:
#    print c,cnt,mx_cnt
    if (c == 'A') or (c == 'T') or (c == 'G') or (c == 'C') :
        cnt += 1
#        print c,cnt,mx_cnt,"CTAG"
    else:
#        print c,cnt,mx_cnt,"not CTAG"
        if cnt > mx_cnt:
            mx_cnt = cnt
#            print c,cnt,mx_cnt,"update"
        cnt = 0

if cnt > mx_cnt:
    mx_cnt = cnt

print mx_cnt


Measured memory_bytes: 2568
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
L = 0
for i in range(len(B)):
    i_ = N-i-1
    if A[i_ +1]<= B[i_]:
        B_ = B[i_]-A[i_+1]
        A[i_+1]=0
        A[i_]=A[i_]-B_
        if A[i_]<0:
            L += A[i_]
            A[i_]=0
        L += B[i_]
    else:
        L += B[i_]
        A[i_+1]-=B[i_]
print(L)

Measured memory_bytes: 19648
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

typedef long long ll;
#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

int main(){
	ll N;
	cin >> N;
	
	int i = 1;
	ll ans = 1;
	for(; pow(i, 2) <= N; ++i){
		ans = pow(i, 2);
	}
	cout << ans << endl;
}


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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


ll f(ll x){
    if (x % 2) {
        ll pairs = (x+1)/2;
        return pairs % 2;
    } else {
        return f(x-1) ^ x;
    }
}

ll solve(ll a, ll b) {
    ll fa_=f(a-1), fb=f(b);
    return fb ^ fa_;
}

int main() {
    ll a,b; cin >> a >> b;
    cout << solve(a,b) << endl;
    return 0;
}


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

class Program
{
    static void Main()
    {
        int N = int.Parse(ReadLine());
        var input = ReadLine().Split(' ');
        List<int> A = new List<int>(N);
        for(int i = 0; i < input.Length; i++)
        {
            A.Add(int.Parse(input[i]));
        }
        
        int max = 0;
        for(int i = 0; i < N; i++)
        {
            for(int j = 0; j < N; j++)
            {
                if (max < Abs(A[i] - A[j])) max = Abs(A[i] - A[j]);
            }
        }

        WriteLine(max);
    }
}

Measured memory_bytes: 13268
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <tuple>
#include <climits>

using namespace std;


int main() {
    long long n, k;
    cin>>n>>k;
    vector<long long> a(n), b(n);
    for (int i=0; i<n; i++) cin>>a[i]>>b[i];

    long long ans = 0;
    for (int i=0; i<30; i++) {
        if (k & (1<<i)) {
            long long cur = 0;
            for (int j=0; j<n; j++) {
                long long nk = k & ~(1<<i);
                if (((nk | a[j]) >> i == nk >> i)) {
                    cur += b[j];
                }
            }
            ans = max(ans, cur);
        }
    }
    long long cur = 0;
    for (int i=0; i<n; i++) {
        if ((k | a[i]) == k) cur += b[i];
    }
    cout<<max(ans, cur)<<endl;
}

Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		String[] n ={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q",
				"r","s","t","u","v","w","x","y","z"};

		Scanner sc = new Scanner(System.in);
		String C = sc.next();

		for(int i=0; i < n.length; i++) {
			if(C.equals(n[i])) {
				System.out.println(n[i+1]);
			}
		}
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>

using namespace std;

long od(long num, int x) {
    long as = 0;
    while (num > (long)x) {
        --num;
        ++as;
    }
    return as;
}

int main()
{
    int n, x; cin >> n >> x;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];

    long ans = 0;
    for (int i = 0; i < n - 1; ++i) {
        long num = a[i] + a[i+1];
        if (num > x) {
            long tmp = od(num, x);
            ans += tmp;
            if (tmp > a[i+1]) {
                tmp -= a[i+1];
                a[i+1] = 0;
                a[i] -= tmp;
            } else {
                a[i+1] -= tmp;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INL inline
#define REG register
#define DB double
#define LDB long double
#define ULL unsigned long long
#define LL long long

#define RPT(i,x,y) for (REG int i=(x);i<(y);i++)
#define DRPT(i,x,y) for (REG int i=(x);i>(y);i--)
#define MST(a,b) memset((a),(b),sizeof(a))
#define MRK() cout<<"Mark"<<endl;
#define WRT(x) cout<<#x<<" = "<<(x)<<endl;

#define MAXN 101000
#define MAXM 10000
#define MOD 998244353
#define INF 0x3f3f3f3f
#define LLINF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-5

#define _ 0
using namespace std;

int a[MAXN];
int n;
int main()
{
	int ans=0;
	cin>>n;
	RPT(i,0,n)
	{
		scanf("%d",&a[i]);
		ans^=a[i];
	}
	if (ans==0)
		cout<<"Yes";
	else
		cout<<"No";
	
	return ~~(0^_^0);
}



Measured memory_bytes: 640
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli n;
vll a;
map<lli,lli> m;
vll ans;

int main(){
    cin >> n;
    a = vll(n);
    for(lli i = 0;i < n;i++) cin >> a[i];
    for(lli i = 0;i < n;i++){
        m[a[i]]++;
    }
    for(auto itr = m.begin();itr != m.end();itr++){
        for(lli i = 0;i < itr->second;i++){
            ans.push_back(itr->first);
        }
    }
    cout << ans[0];
    for(lli i = 1;i < ans.size();i++){
        cout << " " << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 35440