akhauriyash/Code-Regression huggingface dataset:
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  double t, x;
  cin >> t >> x;
  cout << fixed << setprecision(10);
  cout << t / x << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3772
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    int A[100000];
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    sort(A, A+N);
    int *ptr;
    if(N == 2){
        cout << A[1] << ' ' << A[0] << endl;
    }else{
        if(A[N-1]%2 == 0){
            ptr = lower_bound(A, A+N, A[N-1]/2);
            if(*ptr - A[N-1]/2  > A[N-1]/2 - *(ptr-1)) cout << A[N-1] << ' ' << *(ptr-1) << endl;
            else cout  << A[N-1] << ' ' << *ptr << endl;  
        }else{
            
            ptr = lower_bound(A, A+N, (A[N-1]-1)/2);
            
            if((*ptr)*2 - A[N-1]  > A[N-1] - (*(ptr-1))*2) cout << A[N-1] << ' ' << *(ptr-1) << endl;
            else cout  << A[N-1] << ' ' << *ptr << endl;
        }
    }
}


Measured memory_bytes: 640
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
A.sort()
A.reverse()
c = Counter(A)
ans = 0
# 大きいものからペアを探す
# 選択する数をx,ペアをyとする(1 <= y <= x)
# x < x+y <= 2*x よりxに対してx+yが2のべき乗となるようなものは一意に定まる
# したがってyも一意に定まるので,あとはyを探してくる
# x,yのペアが見つかれば1カウント
for e in A:
# x == y のとき １ループで2個減っているのでチェックする前にc[e] == 0となる可能性あり
    if c[e] == 0:
        continue
    c[e] -= 1
    pair = pow(2,e.bit_length()) - e
    if c[pair] >= 1:
        ans += 1
        c[pair] -= 1
print(ans)

Measured memory_bytes: 33296
#include<iostream>
#include<cstdlib>
#include<string>
#include<cstring>
using namespace std;

int main(){
	char input[80];
	int num = 0;
	char charNum[5];
	int cont;
	while(cin >> input){
		for(int i=0; i < strlen(input); i++){
			if('0'<= input[i] && input[i] <= '9'){
				for(int j=0; '0' <= input[i+j] && input[i+j] <= '9'; j++){
					charNum[j] = input[i+j];
					cont = j;
				}
				num += atoi(charNum);
				i += cont;
				for(int i=0; i < 5; i++){
					charNum[i] = '\0';
				}
			}
		}
	}
	cout << num << endl;
}

Measured memory_bytes: 1148
#include <iostream>

using namespace std;
int main() {
    int n;
    int p[20];
    cin >> n;
    for (int i=0; i<n; i++) cin >> p[i];

    int out = 0;
    for (int i=1; i<n-1; i++) {
        if (
            (p[i-1] > p[i] && p[i] > p[i+1]) ||
            (p[i+1] > p[i] && p[i] > p[i-1])) { out++; }
    }
    cout << out << endl;
    return 0;
}



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

typedef long long ll;
typedef pair<int,int> PII;
#define CINSPEED std::ios::sync_with_stdio(false),std::cin.tie(0),std::cout.tie(0)
#define fi first
#define se second
#define pb push_back

ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){ return a * b / gcd(a,b);}


const int N = 100010,M = 1000010;
int cmp(int a,int b)
{
    return a > b;
}

void solved()
{
    ll h,n;
    cin >> h >> n;
    vector<ll>a(n);
    ll sum = 0;
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    if(sum >= h)cout << "Yes";
    else cout <<"No";
   
}

int main()
{
    //CINSPEED;
    solved();
#ifdef LOCAL
    system("pause");
#endif
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

const int INF = 1e9 + 7;

#define ARRAY_MAX 105

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


int main() {

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

	int mini = 0;
	int ans = 0;
	for (int i = 1; i < n; i++)
	{
		if (a[i - 1] > a[i])
		{
			ans += a[i - 1] - mini;
			mini = a[i];
		}
	}
	ans += a[n - 1] - mini;

	cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int sum1[100001];
int mod(int a){
    if(a>=0)
        return a;
    else
        return (-1*a);
}
int sum(int i,int h[],int n,int k)
    {
        // if(i==(n-1))
        //     return 0;
        // if(i==0 && j==1)
        //     return 0;
        int min=0; 
        if(sum1[i]!=10001)
            return sum1[i];
        else
        {
            // sum1[i]=min(sum(i+1,h,n)+mod(h[i]-h[i+1]),sum(i+2,h,n)+mod(h[i]-h[i+2]));
            // min=sum1[i][1]+mod(h[i]-h[i+1]);
            if(i!=(n-1))
                {
                    sum1[i+1]=sum(i+1,h,n,k);
                    min=sum1[i+1]+mod(h[i]-h[i+1]);
                }
            for(int j=2;j<=k;j++)
                {
                    if((i+j)<n)
                    {
                        sum1[i+j]=sum(i+j,h,n,k);
                        if((sum1[i+j]+mod(h[i]-h[i+j]))<min)
                            {
                                min=sum1[i+j]+mod(h[i]-h[i+j]);
                            }
                    }
                    else
                        break;
                }
        
            return min;
        }
    }
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++)
        {
            cin>>h[i];
        }
    for(int i=0;i<100001;i++)
    {
        // for(int j=0;j<101;j++)
            sum1[i]=10001;
    }
    sum1[n-1]=0;
    sum1[n-2]=mod(h[n-1]-h[n-2]);
    cout<<sum(0,h,n,k);
}


Measured memory_bytes: 8832
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int  n,m;
char c;
int num[55];
int bj[10];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{cin>>c;num[c-'a'+1]++;}
	}
	for(int i=1;i<=26;i++)
	{
		bj[num[i]%4]++;
	}
	if((n&1)&&(m&1))
	{
		if(bj[1]==1&&bj[3]==0)
		{
			if(bj[2]>(n+m-2)/2)
			{
				printf("No");
			}
			else printf("Yes");
		}
		else if(bj[3]==1&&bj[1]==0)
		{
			bj[2]++;
			if(bj[2]>(n+m-2)/2)
			{
				printf("No");
			}
			else printf("Yes");
		}
		else printf("No");
	}
	else if(n&1)
	{
		if(bj[1]==0&&bj[3]==0)  
		{                       
			if(bj[2]>m/2)         
			{
				printf("No");
			}
			else printf("Yes");
		}
		else printf("No");
	}
	else if(m&1)
	{
		if(bj[1]==0&&bj[3]==0)
		{
			if(bj[2]>n/2)
			{
				printf("No");
			}
			else printf("Yes");
		}
		else printf("No");
	}
	else
	{
		if(bj[1]==0&&bj[3]==0&&bj[2]==0)
		{
			printf("Yes");
		}
		else printf("No");
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }



signed main(){

    int n; cin >> n;
    int N = 1 << n;
    vec A(N); readv(A);
    IREP(i, n){
        N = 1 << i;
        vec tmp(N);
        REP(j, N){
            if(A[2 * j] == A[2 * j + 1]) tmp[j] = A[2 * j];
            else tmp[j] = llabs(A[2 * j] - A[2 * j + 1]);
        }
        A = tmp;
    }
    cout << A[0] << endl;
    
    return 0;
}

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

using namespace std;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

struct Edge {
    int from, to, cost;
};

void print(vector<vector<pii>> &G) {
    int N = G.size();
    vector<Edge> E;
    int M = 0;
    for(int i = 0; i < N; i++) {
        M += G[i].size();
        for(int j = 0; j < G[i].size(); j++) {
            E.push_back({i, G[i][j].first, G[i][j].second});
        }
    }
    cout << N << " " << M << endl;
    for(int i = 0; i < M; i++) {
        cout << E[i].from + 1 << " " << E[i].to + 1 << " " << E[i].cost << endl;
    }
}

void solve() {
    int L;
    cin >> L;
    int N = 1;
    while((1 << N) <= L) N++;

    vector<vector<pii>> G(N);
    for(int i = 0; i < N - 1; i++) {
        G[i].push_back({i + 1, 0});
        G[i].push_back({i + 1, 1 << i});
    }

    for(int i = N - 2; i >= 0; i--) {
        if (L - (1 << i) >= (1 << (N - 1))) {
            G[i].push_back({N - 1, L - (1 << i)});
            L -= (1 << i);
        }
    }

    print(G);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll N,M;cin>>N>>M;
    vector<ll> A(M);
    REP(i,M)cin>>A[i];
    ll sm=0;
    REP(i,M){
        sm+=A[i];
    }
    if(N-sm>=0)
        cout<<N-sm<<"\n";
    else
    {
        cout<<"-1\n";
    }
}

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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int, int>
#define all(x) x.begin(), x.end()
#define Matrix vector<vector<int>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = ((int64_t)2e18);
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

signed main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int t;

  // cin >> t;
  t = 1;

  while (t--) {
    int n;
    cin >> n;

    int m;
    cin >> m;

    n = 2 * m + 1;
    int h = (n / 2) + 1;
    vector<ii> ans;

    for (int i = 1, j = h; i < j; ++i, --j) {
      ans.eb(i, j);
    }

    for (int i = h + 1, j = n; i < j; ++i, --j)
      ans.eb(i, j);

    for (int i = 0; i < m; ++i)
      cout << ans[i].ff << ' ' << ans[i].ss << endl;
  }
}

Measured memory_bytes: 5304
def main():
    n = int(input())
    a = list(map(int,input().split()))
    dic = {}
    for i in range(n):
        if not a[i] in dic.keys():
            dic[a[i]] = 1
        else:
            dic[a[i]] += 1
    s = 0
    for k in dic.keys():
        s += dic[k] * k
    q = int(input())
    for i in range(q):
        b,c = map(int,input().split())
        if b in dic.keys():
            cnt = dic[b]
        else:
            cnt = 0
        dic[b] = 0
        if c in dic.keys():
            dic[c] += cnt
        else:
            dic[c] = cnt
        s = s + cnt * (c-b)
        print(s)

if __name__ == "__main__":
    main()


Measured memory_bytes: 23692
from heapq import heappush,heappop

n,m=[int(x) for x in input().rstrip().split()]
ab=[[] for i in range(10**5)]

for i in range(n):
  a,b=[int(x) for x in input().rstrip().split()]
  if a<=m:
    ab[m-a].append(-b)

ans=0
l=[]
for i in range(m-1,-1,-1):
  for b in ab[i]:
    heappush(l,b)

  if l:
    ans-=heappop(l)

print(ans)


Measured memory_bytes: 22288
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>

struct TDice
{
    int Top;
    int Front;
    int Right;
    int Back;
    int Left;
    int Bottom;
};
TDice MakeDice(std::istream& in)
{
    TDice Dice;
    in >> Dice.Top
       >> Dice.Front
       >> Dice.Right
       >> Dice.Left
       >> Dice.Back
       >> Dice.Bottom;
    return Dice;
}
void RollN(TDice& Dice)
{
    int temp    = Dice.Top;
    Dice.Top    = Dice.Front;
    Dice.Front  = Dice.Bottom;
    Dice.Bottom = Dice.Back;
    Dice.Back   = temp;
}
void RollE(TDice& Dice)
{
    int temp    = Dice.Top;
    Dice.Top    = Dice.Left;
    Dice.Left   = Dice.Bottom;
    Dice.Bottom = Dice.Right;
    Dice.Right  = temp;
}
void RollW(TDice& Dice)
{
    int temp    = Dice.Top;
    Dice.Top    = Dice.Right;
    Dice.Right  = Dice.Bottom;
    Dice.Bottom = Dice.Left;
    Dice.Left   = temp;
}
void RollS(TDice& Dice)
{
    int temp    = Dice.Top;
    Dice.Top    = Dice.Back;
    Dice.Back   = Dice.Bottom;
    Dice.Bottom = Dice.Front;
    Dice.Front  = temp;
}

void Roll(char c, TDice& Dice)
{
    switch(c){
    case 'N': RollN(Dice); break;
    case 'E': RollE(Dice); break;
    case 'W': RollW(Dice); break;
    case 'S': RollS(Dice); break;
    }
}
bool IsInclude(int Num, const TDice& Dice)
{
    return
        Dice.Top    == Num ||
        Dice.Front  == Num ||
        Dice.Right  == Num ||
        Dice.Back   == Num ||
        Dice.Left   == Num ||
        Dice.Bottom == Num; 
}
void RollToTop(int Num, TDice& Dice)
{
    assert(IsInclude(Num, Dice));
    if(Dice.Top == Num){
    }else
    if(Dice.Left == Num){
        RollE(Dice);
    }else
    if(Dice.Right == Num){
        RollW(Dice);
    }else
    if(Dice.Front == Num){
        RollN(Dice);
    }else
    if(Dice.Back == Num){
        RollS(Dice);
    }else
    if(Dice.Bottom == Num){
        RollE(Dice);
        RollE(Dice);
    }else{
        assert(false);
    }
}
void RollToFront(int Num, TDice& Dice)
{
    RollToTop(Num, Dice);
    RollS(Dice);
}
void RollToTopFront(int Top, int Front, TDice& Dice)
{
    RollToFront(Front, Dice);
    RollToTop(Top, Dice);
}

bool Equal(const TDice& A, const TDice& B)
{
    return
        A.Top    == B.Top &&
        A.Front  == B.Front &&
        A.Right  == B.Right &&
        A.Back   == B.Back &&
        A.Left   == B.Left &&
        A.Bottom == B.Bottom;
}
bool EqualIfRoll(const TDice&A, const TDice&B)
{
    TDice X = A;
    RollToTopFront(B.Top, B.Front, X);
    return Equal(X, B);
}
int main()
{
    TDice A = MakeDice(std::cin);
    TDice B = MakeDice(std::cin);
    std::cout << (EqualIfRoll(A, B) ? "Yes" : "No") << std::endl;
    return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<stdlib.h>
#define N 500000

int tmp[N],cnt = 0;

void MergeSort(int A[],int left , int right){
    int mid,i,j,k;
    if(left < right){
        mid = (left + right) / 2;
        MergeSort(A , left , mid);
        MergeSort(A , mid + 1 , right);

        for(i = mid ; i >=left ; i--)tmp[i] = A[i];
        for(j = mid + 1 ; j <= right ;j++)tmp[right - (j - (mid + 1))] = A[j];

        i = left;
        j = right;
        for(k = left ; k <= right ;k++){
            if(tmp[i] < tmp[j])
            A[k] = tmp[i++];
            else A[k] = tmp[j--];
            cnt++;
        }
        }
    }

int main()
{
    int i,n,A[N];

    scanf("%d",&n);
    for(i = 0 ; i < n ; i++){
        scanf("%d",&A[i]);
        if(A[i] < 0 || A[i] > 1000000000)exit(1);
    }

    MergeSort(A , 0 , n - 1);
    for(i = 0 ; i < n ; i++){
        if(i > 0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",cnt);

    return 0;
}



Measured memory_bytes: 5624
#include <iostream>

using namespace std;

long long res[88];
int n;

int main()
{
	cin >> n;
	res[0] = 2;
	res[1] = 1;

	for (int i = 2; i <= n; ++i)
		res[i] = res[i-1] + res[i-2];

	cout << res[n] << endl;

	return 0;
}

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

int main()
{
	int N,T,t,c;
	cin >> N >> T;
	vector<int> cost;
	for(int i(0);i<N;++i){
		cin >> c >> t;
		if(t <= T){
			cost.push_back(c);
		}
	}
	if(cost.size() == 0){
		cout << "TLE" << endl;
		return 0;
	}
	sort(begin(cost), end(cost));
	cout << cost[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string>) {}
template<typename T1,typename T2> ostream& operator<<(ostream& os, pair<T1,T2> buf) {
  return os << "(" << buf.first << ": " << buf.second << ")"; }
#define DefOut(Con) template<typename T>ostream&operator<<(ostream&os,Con<T>&A){ bool f = false; os << "{"; \
  for (const auto e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
#define DefOut2(Con) template<typename K,typename V>ostream&operator<<(ostream&os,Con<K,V>&A) \
{ bool f = false; os << "{"; for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
template<typename T>ostream &operator << (ostream &os,vector<vector<T>>& A) {
  for (auto &B: A) os << '\n' << B; return os; }
DefOut(vector) DefOut(set) DefOut(multiset) DefOut2(map) 
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << a << endl; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1000000007;
long long const INF = 1e18;
#define PI 3.14159265358979323846
/***********************************************************************/

int32_t main() {

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  string s;
  cin >> s;
  while (SZ(s) < 15) s += 'o';
  int cnt = 0;
  for (char c: s) cnt += c == 'o';
  cout << (cnt >= 8 ? "YES" : "NO") << endl;

  return 0;
}


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

int main(){
  int n, x=0, ans=0;
  cin>>n;
  for(int i=0; i<n; i++){
    char c;
    cin>>c;
    if(c=='I')x++;
    else x--;
    ans=max(ans, x);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(v)";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
function QuickSelect(a,k){
  --k;
  var l=0,r=a.length-1;
  while(l<r){
    var i=l-1,j=r,m=l+r>>1;
    var p=a[m],t;a[m]=a[r];
    while(1){
      g:
      while(i<j){
        if(p<a[++i]){
          while(i<j)if(a[--j]<=p)break g;
        }else if(a[--j]<p){
          while(i<j+1)if(p<=a[++i])break g;
        }
      }
      if(j<=i)break;
      t=a[i];a[i]=a[j];a[j]=t;
    }
    a[r]=a[i];a[i]=p;
    if(i<k)l=i+1;else if(k<i)r=i-1;else break;
  }
  return a[k];
}

console.log(main());
function main(){
  var x = o.a();
  var y = o.a();
  var z = o.a();
  var k = o.a();
  var a = o.l();
  var b = o.l();
  var c = o.l();
  var u = [];
  for(var i = 0; i < x; i++){
    for(var j = 0; j < y; j++){
      u.push(a[i]+b[j]);
    }
  }
  if(k < u.length){
    u = solve(u,k);
  }
  var ans = [];
  for(var i = 0; i < z; i++){
    for(var j = 0; j < u.length; j++){
      ans.push(c[i]+u[j]);
    }
  }
  if(k < ans.length){
    ans = solve(ans,k);
  }
  return ans.sort((a,b)=>b-a).join("\n");
}
function solve(a,k){
  QuickSelect(a,a.length - k);
  return a.slice(a.length - k);
}

Measured memory_bytes: 142796
#include<stdio.h>
int main()
{
	int a[100005]={100005};
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int sum=0; 
	for(int i=1;i<=n;i++){
		if(a[i]==i){
				int t=a[i];
				a[i]=a[i+1];
				a[i+1]=t;
				sum++;
		}
	}
	printf("%d\n",sum);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long 
using ldb = long double;
using pa = pair < int, int >;
#define pb push_back
#define F  first
#define S  second
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;
int n,a,b,c,d;
string s1,s2,s3,s;
int ans,sum;
int32_t main() {
    fast();
    cin >> n;
    vector<int>q(n);
    f(i,0,n){
        cin >> q[i];   
    }   
    sort(all(q));
    int ma=1e11,ans=1e11;
    f(i,1,300){
        ma=0;
        f(j,0,n){
            ma+=((i-q[j])*(i-q[j]));   
        }
        ans=min(ans,ma);
    }
    cout<<ans;
}

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

using namespace std;

int main()
{
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    deque<char> q;
    bool is_rev = false;
    for (int i = 0; i < S.size(); i++)
    {
        q.push_back(S[i]);
    }
    for (int i = 0; i < Q; i++)
    {
        int T;
        cin >> T;
        if (T == 1)
        {
            is_rev = !is_rev;
        }
        else if (T == 2)
        {
            int F;
            cin >> F;
            if (F == 1)
            {
                string s;
                cin >> s;
                if (!is_rev)
                {
                    q.push_front(s[0]);
                }
                else
                {
                    q.push_back(s[0]);
                }
            }
            else if (F == 2)
            {
                string s;
                cin >> s;
                if (is_rev)
                {
                    q.push_front(s[0]);
                }
                else
                {
                    q.push_back(s[0]);
                }
            }
        }
    }
    if (!is_rev)
    {
        while (!q.empty())
        {
            cout << q.front();
            q.pop_front();
        }

        cout << endl;
    }
    else
    {
        while (!q.empty())
        {
            cout << q.back();
            q.pop_back();
        }
        cout << endl;
    }
}

Measured memory_bytes: 1024
/*
*
*   Bismillah Hir Rahman Nir Raheem
*   Name: Jaied Al Sabid
*
*/

#include <iostream>
#include <string>
#include <bits/stdc++.h>

using namespace std;

#define pf printf
#define sf scanf
#define elf else if
#define Size 100

bool isPrime(int32_t x);

int main()
{
    int32_t x;

    cin>>x;

    while(true)
    {
        if(isPrime(x) == true)
        {
            cout<<x<<endl;
            break;
        }
        else
        {
            x++;
        }
    }

    return 0;
}

bool isPrime(int32_t x)
{
    int rs = sqrt(x);
    for(int i = 2; i <= rs; i++)
    {
        if(x % i == 0)
        {
            return false;
            break;
        }
    }

    return true;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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

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

	if (a <= 0 && 0 <= b) {
		cout << "Zero" << endl;
	}
	else if (a > 0 && b > 0) {
		cout << "Positive" << endl;
	}
	else if (abs(a - b) % 2 == 0) {
		cout << "Negative" << endl;
	}
	else
		cout << "Positive" << endl;
	return 0;
}



Measured memory_bytes: 256
/// Swift5 -> Swift2.2

extension String {
    // split(separator:maxSplits:omittingEmptySubsequences:)
    func split(separator separator: Character) -> [String] {
        return self.characters.split(separator).map(String.init)
    }
}
extension Array {
    // init(repeating:count:)
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
    // lastIndex(where:)
    func lastIndex(where predicate: (Element) -> Bool) -> Int? {
      	for i in stride(from: count - 1, through: 0, by: -1) {
          	if predicate(self[i]) {
              	return i
            }
        }
      	return nil
    }
}
extension Array where Element: Comparable {
    // sorted()
    func sorted() -> [Element] {
        return self.sort( { $0 < $1 } )
    }
    // max()
    func max() -> Element? {
        guard self.count > 0 else { return nil }
        return self.reduce(self.first!) { return Swift.max($0, $1) }
    }
}
extension String {
    // Sequence#enumerated()
  	// public func enumerate<Seq : SequenceType>(base: Seq) -> EnumerateSequence<Seq>
    func enumerated() -> EnumerateSequence<[Character]> {
        return Array(self.characters).enumerate()
    }
}
// stride(from:through:by:)
func stride(from start: Int, through end: Int, by stride: Int) -> StrideThrough<Int> {
    return start.stride(through: end, by: stride)
}
// stride(from:to:by)
func stride(from start: Int, to end: Int, by stride: Int) -> StrideTo<Int> {
    return start.stride(to: end, by: stride)
}

/// end

let input = readLine()!.split(separator: " ").map { Int($0)! }
let N = input[0]
let M = input[1]

var a = [Int]()

for _ in stride(from: 0, to: M, by: 1) {
    a.append(Int(readLine()!)!)
}

var dp = Array(repeating: Optional<Int>.None, count: N + 1)
dp[0] = 1

for i in stride(from: 1, through: N, by: 1) {
    guard i != a.first else {
        a.removeFirst(1)
        continue
    }
    guard i > 1 else {
        dp[1] = 1
        continue
    }

    switch (dp[i - 1], dp[i - 2]) {
    case (.Some(let one), .Some(let two)):
        dp[i] = (one + two) % 1_000_000_007
    case (.Some(let one), .None):
        dp[i] = one
    case (.None, .Some(let two)):
        dp[i] = two
    default:
        break
    }
}

print(dp.last! ?? 0)


Measured memory_bytes: 4208
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;
const double pi=3.141592653589793238;
int main(){
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a<0 && c<0){
        if(b>=0 && d>=0){
            cout << max(a*c,b*d) << endl;
        }
        else{
            cout << a*c << endl;
        }
    }
    else if(b>=0 && d>=0){
        cout << b*d << endl;
    }
    else{
        if(a>0) cout << a*d << endl;
        else cout << b*c << endl;
    }
}



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

#define ld long double
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define nl '\n'
#define pii pair <ll, ll>
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979323846264
#define y1 abacaba
#define fn "abc"
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define pcnt(i) __builtin_popcount(i)
#define lcm(a,b) (a * b) / __gcd(a, b)
#define chill_wave ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pressF freopen("rsq.in", "r", stdin); freopen("rsq.out", "w", stdout);

using namespace std;

const long long MXN = 1e6 + 23;
const long long MAXN = 2e3 + 1;
const long long MOD = 1e9 + 7;
const long long MAXLOG = 20;
const long long INF = 1e18;

inline void f_math(bool ok = 0) { chill_wave if(ok) { pressF; } }

//int dx[]= {1,0,-1,0}; int dy[]= {0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1}; int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2}; int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={-1,-1,+0,+1,+1,+0}; int dy[]={-1,+1,+2,+1,-1,-2}; //Hexagonal Direction

ll n, a[MXN], A, B, c[MXN];

void init() {
	for(int i = 1; i <= n; i++) c[i] = a[i];
}

int main() {

    f_math();
   	
 	cin >> n >> A >> B;    
 	for(int i = 1; i <= n; i++) {
 		cin >> a[i];
 	}
 	sort(a + 1, a + 1 + n);
 	init();                                 
 	int l = 1, r = 1e9;
 	while(r - l > 1) {
 		int m = (l + r) / 2;
 		init();
 		for(int i = 1; i <= n; i++) {
 			c[i] -= (B * m);	 		
 		}
 		int col = m;
 		bool can = 1;
 		for(int i = n; i >= 1; i--) {
 			int cel = (c[i] + (A - B) - 1) / (A - B);
 			if(cel > col && c[i] > 0) {
 				can = 0;
 				break;					
 			}
 			col -= cel;			 		
 		}
 		if(can) {
 		 	r = m;
 		} else {
 		 	l = m;
 		}	
 	}
 	init();
 	for(int i = 1; i <= n; i++) {
 		c[i] -= (B * l);	 		
 	}
 	int col = l;
 	bool can = 1;
 	for(int i = n; i >= 1; i--) {
 		int cel = (c[i] + (A - B) - 1) / (A - B);
		if(cel > col && c[i] > 0) {
 			can = 0;
 			break;					
 		}
 		col -= cel;			 		
	}
	if(can) cout << l;
	else cout << r;
 	return 0;
}


Measured memory_bytes: 5120
package main

import (
	"fmt"
)

func main() {
	// Code for B - Ruined Square
	var x1, x2, y1, y2 int
	fmt.Scanf("%d %d %d %d", &x1, &y1, &x2, &y2)

	A := x2 - x1
	B := y2 - y1
	fmt.Println(x2-B, y2+A, x1-B, y1+A)
}


Measured memory_bytes: 1832
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair<int,string> P;

static const double eps = 1e-8;

bool prime[1000001];
int dp[1000001];

int main(){

	fill((bool*)prime,(bool*)prime+1000000,true);

	prime[0] = false;
	prime[1] = false;
	for(int i = 2;i*i<=1000000;i++){
		if(prime[i]){
			for(int j=i+i;j<=1000000;j+=i){
				prime[j] = false;
			}
		}
	}

	int n,x;
	while(~scanf("%d %d",&n,&x)){
		if(n==x && x==0) break;

		memset(dp,0,sizeof(dp));
		vector<int> foods;
		for(int i=0;i<n;i++){
			int cost;
			scanf("%d",&cost);
			foods.push_back(cost);
			dp[cost] = 1;
		}

		sort(foods.begin(),foods.end());

		for(int i=0;i<=x;i++){
			for(int j=0;j<foods.size();j++){
				if(i - foods[j] >= 0 && dp[i - foods[j]]){
					dp[i] = 1;
					break;
				}
			}
		}

		int res = -1;
		for(int i=x;i>=1;i--){
			if(!prime[i]) continue;
			

			if(dp[i]){
				res = i;
				goto found;
			}
		}
found:;
		if(res==-1) printf("NA\n");
		else printf("%d\n",res);
	}
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int A, B; cin >> A >> B;
    cout << max(A+B, max(A-B, A*B)) << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = []
b = [[] for i in range(n)]
for i in range(m):
	p, y = map(int, input().split())
	a.append([p,y])
	b[p-1].append(y)
dic = {}
for i in range(n):
	b[i].sort()
	for j,k in enumerate(b[i]):
		dic[k] = j+1

for i, j in a:
	print ("{:06d}".format(i) + "{:06d}".format(dic[j]))

Measured memory_bytes: 40656
// Generated by CoffeeScript 1.3.3
(function() {
  var a=[];
  var stdin = process.openStdin();
  stdin.setEncoding('utf8');

  var proc = function(s) {
    var bidx, count, eidx, m;
    bidx = s.indexOf('(');
    while (bidx !== -1) {
      count = 1;
      eidx = bidx + 1;
      while (count > 0) {
        if (s[eidx] === '(') {
          count++;
        }
        if (s[eidx] === ')') {
          count--;
        }
        eidx++;
      }
      s = s.substring(0, bidx) + proc(s.substring(bidx + 1, eidx - 1)) + s.substring(eidx);
      bidx = s.indexOf('(');
    }
    while ((m = /^(.*?)(-?\d+)([*/])(-?\d+)(.*)$/.exec(s)) != null) {
      if (m[3] === '*') {
        s = m[1] + (parseInt(m[2]) * parseInt(m[4])) + m[5];
      } else {
        s = m[1] + (parseInt(m[2]) / parseInt(m[4]) ^ 0) + m[5];
      }
    }
    while ((m = /^(.*?)(-?\d+)([+Z])(-?\d+)(.*)$/.exec(s)) != null) {
      if (m[3] === '+') {
        s = m[1] + (parseInt(m[2]) + parseInt(m[4])) + m[5];
      } else {
        s = m[1] + (parseInt(m[2]) - parseInt(m[4])) + m[5];
      }
    }
    return s;
  };

  stdin.on('data', function(input) {
    var e, x;
    x = (function() {
      var _i, _len, _ref, _results;
      _ref = input.split("\n");
      _results = [];
      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
        e = _ref[_i];
        _results.push(e);
      }
      return _results;
    })();
    if (x.length > 2 || !isNaN(x[1])) {
      return a = x;
    } else {
      return a.push(x[0]);
    }
  });

  stdin.on('end', function(z) {
    var i, n, s, _i, _results;
    n = parseInt(a[0]);
    _results = [];
    for (i = _i = 1; 1 <= n ? _i <= n : _i >= n; i = 1 <= n ? ++_i : --_i) {
      s = a[i].substring(0, a[i].indexOf('=')).replace(/-/g, 'Z');
      _results.push(console.log(proc(s)));
    }
    return _results;
  });

}).call(this);

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


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

	sort(p,p+n);
	int one=0,two=0,thr=0;
	for (int i = 0; i < n; ++i){
		if(a>=p[i])
			one++;
		else if(b+1<=p[i])
			thr++;
		else
			two++;
	}

	cout<<min(one,min(two,thr))<<endl;


}



Measured memory_bytes: 256
#include <iostream>

 

 

 

using namespace std;

 

 

 

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


Measured memory_bytes: 3076
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

const int MAX_V = 101;

int d[MAX_V][MAX_V];
int V, E;
map<pair<int, int>, bool> mp;
vector<int> a, b;

void warshall_floyd() {
  for (int k = 0; k < V; k++) {
    for (int i = 0; i < V; i++) {
      for (int j = 0; j < V; j++) {
        if (d[i][k] == INF || d[k][j] == INF) {
          continue;
        }
        if (d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
          mp[make_pair(i, j)] = false;
          // mp[make_pair(i, k)] = true;
          // mp[make_pair(k, j)] = true;
        }
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> V >> E;
  a.resize(E);
  b.resize(E);
  for (int i = 0; i < V; i++) {
    for (int j = 0; j < V; j++) {
      if (i == j) {
        d[i][j] = 0;
      } else {
        d[i][j] = INF;
      }
    }
  }
  for (int i = 0; i < E; i++) {
    int ai, bi, ci;
    cin >> ai >> bi >> ci;
    ai--;
    bi--;
    d[ai][bi] = ci;
    d[bi][ai] = ci;
    a[i] = ai;
    b[i] = bi;
    mp[make_pair(ai, bi)] = true;
    mp[make_pair(bi, ai)] = true;
  }

  warshall_floyd();
  int ans = E;
  for (int i = 0; i < E; i++) {
    if (mp[make_pair(a[i], b[i])] && mp[make_pair(b[i], a[i])]) {
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 896
function Main(input) {
	input = input.split(" ").map(Number);

	if((input[1]+input[0])%2==1){
		console.log("IMPOSSIBLE")
	}else{
		console.log((input[0]+input[1])/2)
	}

}Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
using System;
class Program
{
    static void Main(string[] args)
    {
        int X = int.Parse(System.Console.ReadLine());
        int a = 0;
        int b = 0;
        int c = 0;
        int d = 1;

        for (int i = 1; i < 1001; i++)
        {
            for (int j = 2; j < 10; j++)
            {
                int result = (int)Math.Pow(i, j);
                if (result > a && result <= X)
                {
                    a = result;
                }
                if (result > X) { break; }
            }
        }
        Console.WriteLine(a);
    }

}

Measured memory_bytes: 11092
#include<iostream>
#include<cstdlib>
#include<cstdio>
using namespace std;

int top, S[1000];

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

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

int main(){
    int a, b;
    top = 0;
    char s[100];
    
    while(scanf("%s", s) != EOF){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        }else if(s[0] == '-'){
            b = pop();
            a = pop();
            push(a - b);
        }else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(a * b);
        }else{
            push(atoi(s));
        }
    }
    
    int ans = pop();
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
typedef pair<string,string> P;
int bnf();
set<P> used;
map<char,int> M;
string S;
int idx,valid;
char ch[8]={'0','1','+','-','*','(',')','='};
int ord[8];

bool check(string a){//テ」ツつ、テ」ツつウテ」ツδシテ」ツδォテ」ツ?ョテヲツ閉ーテ」ツ?ィテ」ツつォテ」ツδε」ツつウテ」ツ?ョテ・ツッツセテ・ツソツ愿」ツつ津ァツ「ツコティツェツ?
  int par=0;
  for(char s:a){
    par += (s == '(') - (s == ')');
    if(s == '=') return 0;
    if(par < 0) return 0;
  }
  return par==0;
}
//100-10*-(10+11*100)=100*1000
int getNum(){ //テヲツ鳴?・ツュツ療・ツ按療」ツつ津ヲツ閉ーテ・ツュツ療」ツ?ォテ」ツ?凖」ツつ?
  int res = 0;
  if(S[idx] == '0' && isdigit(S[idx+1])) valid  = 0;
  while(isdigit(S[idx]))res = res*2 + S[idx++]-'0';
  return res;
}

int cal(){
  char ch = S[idx];
  int res = 0,sign = 1;
  if(ch=='+'||ch=='*'||ch==')'){ valid = 0;return 0;}
  
  while(S[idx] == '-') idx++, sign *= -1;
  ch = S[idx];

  if(isdigit(ch)){
    res = sign*getNum();
    if(S[idx] == '*'){idx++; return res * cal();}
    return res;
  }
  else if(ch == '(') {
    idx++;res = sign*bnf();idx++;
    return res;
  }
  valid = 0;
  return 0;
}

int bnf(){
  int res = cal();
  while(idx<(int)S.size()){
    if(valid == 0) return -1;
    char ch = S[idx];
    if(ch == '('){valid = 0;}
    else if(ch == '*'){idx++;res *= cal();}
    else if(ch == '+'){idx++;res += cal();}
    else if(ch == '-'){idx++;res -= cal();}
    else if(ch != ')') valid = 0;
    else break;
  }
  if(valid ==0) return -1;
  return res;
}

string mkS(string a){
  string res;
  for(char s:a){
    if(isalpha(s))res += ch[ ord[ M[s] ] ];
    else res += s;
  }
  return res;
}


int calc(string A,string B){
  if(A.size()==0 || B.size()==0) return 0;
  if(used.count(P(A,B)))return 0;
  used.insert(P(A,B));
  valid = check(A) && check(B);
  idx = 0;
  S = A;
  int ra = bnf();
  idx = 0;
  S = B;
  int rb = bnf();
  //if(valid)cout<<A<<"="<<B<<" "<<valid<<" "<<ra<<" "<<rb<<endl;
  return ra == rb && valid;
}

int calc(string s){
  s = mkS(s);
  for(int i=0;i<(int)s.size();i++)
    if(s[i]=='=') return calc(s.substr(0,i),s.substr(i+1,s.size()-i-1));
  return 0;
}

int dfs(int num,string &s){
  if(num == 8) return calc(s);
  
  int res = 0;
  for(int i=0;i<8;i++){
    if(ord[i] != -1)continue;
    ord[i] = num;
    res +=dfs(num+1,s);
    ord[i] = -1;
  }
  return res;
}


int main(){
  string str;
  cin>>str;
  if(str.size()<3)cout<<0<<endl,exit(0);

  map<char,int> cnt;
  for(int i=0;i<(int)str.size();i++)if(isalpha(str[i]))cnt[str[i]]++;
  if(cnt.size()>8)cout<<0<<endl,exit(0);

  int c = 0;
  for(pair<char,int> p:cnt)if(isalpha(p.first)) M[p.first] = c++;
  
  memset(ord,-1,sizeof(ord));  
  cout<<dfs(0,str)<<endl;
  return 0;
}

Measured memory_bytes: 10024
#include <stdio.h>
int main(void){
  int n,i,h=0,t=0;
  char s[101];
  scanf("%d\n%s",&n,s);
  for (i=0;i<n;i++){
    if (s[i]=='(') h++;
    else{
      if (h) h--;
      else t++;
    }
  }
  for (i=0;i<t;i++) printf("(");
  printf("%s",s);
  for (i=0;i<h;i++) printf(")");
  printf("\n");
  return 0;
}

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

#define MAX(a , b) (a > b? a : b)
#define MIN(a , b) (a < b? a : b)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define mp make_pair

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;

const double pi = 2.0*acos(0.0);

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

    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin >> n;
    cout << a[n-1] << endl;

    return 0;
}


Measured memory_bytes: 256
my $q = <STDIN>;
chomp($q);
my @a = split / /, $q;
my $tmp = 0;
my $tmp2 = 0;
foreach (@a)
{
    $tmp = $_ if $tmp < $_;
    $tmp2 = $tmp2 + $_;
}
print $tmp2-$tmp."\n";

1;


Measured memory_bytes: 640
S = input()
K = int(input())
def calc(s):
    a = 0
    i = 1
    while i < len(s):
        if s[i] == s[i-1]:
            a += 1
            i += 2
        else:
            i += 1
    return a

A = calc(S)
B = calc(S*2)
C = calc(S*3)
D = calc(S*4)
if K <= 10:
    print(calc(S*K))
elif K % 2 == 1:
    print(A + (C-A) * (K-1) // 2)
else:
    print(B + (D-B) * (K-2) // 2)


Measured memory_bytes: 3316
#include<cstring>
#include <cmath>
#include <cstdio>
#include<cstdlib>
#include <vector>
#include <iostream>
#include <algorithm>
#include<map>
using namespace std;
#define MOD 1000000007
map<long long,long long>ma;
char a[100005];

int main() {

 long n,m,res[200005],i,j,temp,len,q,a,b;
   
    string s,x;
    cin>>n>>a>>b;
    cin>>s;
    res[0]=res[1]=0;
    for(i=0;i<n;i++)
    {  
        if(s[i]=='a')
        {
            if(res[0]<a+b)
            {
                res[0]++;
                cout<<"Yes"<<endl;
               
            }
            else
            {
                cout<<"No"<<endl;
            }
        }
        else if(s[i]=='b')
        {
            if(res[0]<a+b&&res[1]<b)
            {
                res[0]++;
                res[1]++;
                cout<<"Yes"<<endl;
            }
            else
                cout<<"No"<<endl;
        }
            
        else
            cout<<"No"<<endl;
        
    }

}

Measured memory_bytes: 896
#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 each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

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

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 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> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(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) { each(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; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { cout << p.first << ' ' << p.second; return os; }

void solve() {
  i64 N, A, B; cin >> N >> A >> B;
  vi64 X(N); cin >> X;

  i64 ans = 0, now = X[0];
  reps(i, N - 1) {
    if ((X[i] - now) * A < B)
      ans += (X[i] - now) * A;
    else
      ans += B;
    now = X[i];
  }
  cout << ans << '\n';
}


Measured memory_bytes: 1024