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

int main() {
  int X, Y;
  cin >> X >> Y;
  for (int i = 0; i <= X; i++) {
    if (i * 2 + (X - i) * 4 == Y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define vec_rep(itr,v) for(auto itr = v.begin(); itr != v.end(); ++itr)

int main(void){
    int N,M;
    cin >> N >> M;
    ll ans = N*(N-1)/2 + M*(M-1)/2; 
    cout << ans << endl;
    return 0;
}

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

int main(){
    for(int n;cin>>n, n;){
        vector<char>input(n+1);
        for(int i=1;i<=n;i++){
            cin>>input[i];
        }
        vector<int>vec(256, 0);
        int tie = 1;
        for(int i=1;i<=n;i++){
            char c = input[i];
            vec[c]++;
            int nokori = n - i;
            char ans = ' ';
            for(char d = 'A'; d <= 'Z'; d++){
                int dFlg = 1;
                for(char e = 'A'; e<='Z'; e++){
                    if(d==e)continue;
                    if(vec[e]+nokori>=vec[d])dFlg = 0;
                }
                if(dFlg)ans=d;
            }
            if(ans!=' '){
                cout<<ans<<" "<<i<<endl;
                tie = 0;
                break;
            }
        }

        if(tie){
            cout<<"TIE"<<endl;
        }
    }


    return 0;
}


Measured memory_bytes: 3124
#include <iostream>

int main() {
  int A, B;
  std::cin >> A >> B;
  if (A < B) {
    std::cout << 2 * B - 1 << "\n";
  } else if (B < A) {
    std::cout << 2 * A - 1 << "\n";
  } else {
    std::cout << 2 * A << "\n";
  }
  return 0;
}

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

using namespace std;

typedef long long ll;

#define FOR(_i, _a, _b) for (int _i=_a; i<_b; ++_i)

const int INF = 1e9+7;

int main()
{
    int n;
    cin >> n;
    vector <int> a(n+1);
    vector <int> dp(n+1, INF);
    dp[1] = 0;
    FOR(i, 1, n+1)
        cin >> a[i];
    FOR(i, 2, n+1)
        dp[i] = min(dp[i-1] + abs(a[i]-a[i-1]), dp[i-2] + abs(a[i] - a[i-2]));

    cout << dp[n];
    return 0;
}


Measured memory_bytes: 1024
from itertools import product

def input2():
	return map(int,input().split())
  
h,w,k=input2()
C=[list(input()) for _ in range(h)]





ans=0

for row_bit in product(range(2),repeat=h): #[行]0:赤なし，1:赤あり
	for col_bit in product(range(2),repeat=w): #[列]0:赤なし，1:赤あり
		count=0
		# 以下，黒("#")の個数判定
		for row in range(h):
			for col in range(w):
				if C[row][col]=="#" and (row_bit[row]==0 and col_bit[col]==0):
					count+=1
		if count==k:
			ans+=1
print(ans)


Measured memory_bytes: 9164
import Control.Applicative
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import Data.List

maxDiff :: (Ord a , Num a)=> [a] -> a
maxDiff xs =  fst $ foldl'
    (\(ma',mi') n -> (max ma' (n-mi'), min mi' n)) (- (head xs),head xs) (tail xs)

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.lines <$> BC.getContents

main = do
    _ <- getLine
    readInts >>= print . maxDiff

Measured memory_bytes: 87192
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	long long int n;
	long long int a, b;
	cin >> n >> a >> b;
	if (abs(a - b) % 2 == 0) {
		cout << (abs(a - b) / 2);
	}
	else {
		long long int k = min(min(abs(a - 1), abs(n - a)), min(abs(b - 1), abs(n - b)));
		long long int sum = k + 1 + (abs(a - b) / 2);
		cout << sum;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define len(s) s.length()
#define all(v) v.begin(),v.end()
const ll INF = INT_MAX;
const int N = 2e5 + 5;
const ll mod = 1000000007 ;
using namespace std;

int main() {


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


	ll tc = 1;
	// cin >> tc;
	while (tc--) {

		ll n, m, l, r;
		ll i, j;
		ll x, y;

		ll A;
		ld B;
		cin >> A >> B;
		ld C = A * B;

		C = floor(C);

		cout << ll(C) << endl;

	}
}

Measured memory_bytes: 3748
// #include </Users/kmudda/Downloads/Karthik/stdc++.h>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <climits>
#define ll long long int
#define ld long double
#define vl vector<ll>
#define vi vector<int>
#define vvl vector< vl >
#define vvi vector< vi >
#define pb push_back
#define mp make_pair
#define max_int_value 2147483647
#define max_long_value 9223372036854775807
#define min_long_value -9223372036854775806
#define ii pair<ll,ll>
#define F first
#define S second
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)
 
#define CLR(v, d)     memset(v, d, sizeof(v))
 
template<typename T> T gcd(T a, T b){return (b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return (a*(b/gcd_gg(a,b)));}
template<typename T> T mod(T a, T b) {return (a<b ? a : a%b);}
template<typename T> T mod_neg(T a, T b) {return ((a%b)+b)%b;}
ll mulmod(ll a,ll b, ll m){ll q=(ll)(((ld)a*(ld)b)/(ld)m);ll r=a*b-q*m;if(r>m)r%=m;if(r<0)r+=m;return r;}
template<typename T> T expo(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template<typename T> T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mod(x*p,m);p=mod(p*p,m);n>>=1;}return x;}
template<typename T> T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T> T mod_inverse(T a, T n){T x,y;T d = extended_euclid(a, n, x, y);return (d>1?-1:mod_neg(x,n));}
 
using namespace std;
 
string IntToString (int a)
{
    ostringstream temp;
    temp<<a;
    return temp.str();
}
 
int StringToInt (string str)
{
    int xx;
    stringstream ss;
    ss << str;
    ss >> xx;
    return xx;
}
 
ll powerwithmodulus(ll base, ll exponent,ll modulus){
    ll result = 1; base%=modulus;
    while (exponent > 0)
    {
        if (exponent % 2 == 1) result = (result * base) % modulus;
        exponent = exponent >> 1;
        base = (base * base) % modulus;
    }
    return result;
}

/*  NCR using DP
for(int n = 0; n <= 1000; n++)
        for(int r = 0; r <= n; r++)
            if(r == 0 || n == r) ncr[n][r] = 1;
            else ncr[n][r] = (ncr[n-1][r-1] + ncr[n-1][r]) % mod;

*/

 
ll largestPowerOf2(ll n)
{
    return (ll)pow(2, floor(log(n) / log(2)));
}

inline bool cmp1(pair<ll,ll> &p1, pair<ll,ll> &p2) {
    if(p1.F == p2.F)
        return p1.S < p2.S;
    else
        return p1.F < p2.F;
}
 
//lower case std::transform(str.begin(), str.end(), str.begin(), ::tolower);
//Ascii A-65 Z-90 a-97 z-122 0-48 9-57

int cal(int pow, int val, int MOD){
   if(pow <= 0)
      return 1;
   int v = cal(pow/2, val, MOD);
   if(pow % 2 == 0)
      return (v*v) % MOD; 
   else
      return (((v*val) % MOD) * v) % MOD;
}


ll t,n,m,sum=0,coun=0,m1,m2,m3,i,j,k,sum1,sum2,p,q,r,s,p1,q1;
bool flag2;

int main() {

  fast_io;
  //freopen("inputf.in", "r", stdin);
  //freopen("outputf.in", "w", stdout);
  cin>>p>>q;
  if(p < 6) {
    cout<<"0"<<endl;
  } else if(p >= 13) {
    cout<<q<<endl;
  } else {
    cout<<q/2<<endl;
  }
  
  

}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <queue>
#include <vector>

using namespace std;

#define R register
#define ll long long

const int MAXN=100+5;
const int MAXM=MAXN<<1;
const ll inf=(1ll<<60);

inline int min(int x,int  y) { return x<y?x:y; }
inline int max(int x,int  y) { return x>y?x:y; } 

int n;
int du[MAXN];

vector<int> Edge[MAXN];

inline void add(int x,int y)
{
	Edge[x].push_back(y);
	Edge[y].push_back(x);
}

inline void init()
{
	scanf("%d",&n);
	for(R int i=1;i<n;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		add(x,y);du[x]++;du[y]++;
	}
}

int ans1=1e9;
ll ans2=inf;
int dep[MAXN];
int son[MAXN];

inline void dfs1(int x,int fx)
{
	//dep[x]=dep[fx]+1;
	for(R int i=0;i<Edge[x].size();i++)
	{
		int y=Edge[x][i];
		if(y==fx) continue;
		son[x]++;
		dep[y]=dep[x]+1;
		dfs1(y,x);
	}
}

int md[MAXN];

inline void cal()
{
	int maxd=0;
	for(R int i=1;i<=n;i++) maxd=max(maxd,dep[i]);
	//cout<<maxd<<endl;
	memset(md,0,sizeof(md));
	ll cnt=0;
	for(R int i=1;i<=n;i++)
	{
		md[dep[i]]=max(md[dep[i]],son[i]);
		if(dep[i]==1) cnt++;
		//cout<<son[i]<<" ";
	}//cout<<endl;
	for(R int i=1;i<maxd;i++)
	{
			cnt=cnt*md[i];
			//cout<<md[i]<<" ";
	}
	//cout<<endl;
	if(maxd<ans1) ans1=maxd,ans2=inf;
	if(maxd==ans1&&cnt<ans2) ans2=cnt;
	//return cnt;
}

inline void solve1() //暴力枚举点
{
	for(R int i=1;i<=n;i++)
	{
		memset(son,0,sizeof(son));
		dep[i]=1;
		dfs1(i,0);
		cal();
	}
}

inline void dfs2(int x,int fx)
{
	for(R int i=0;i<Edge[x].size();i++)
	{
		int y=Edge[x][i];
		if(y==fx) continue;
		memset(son,0,sizeof(son));
		dep[x]=dep[y]=1;
		dfs1(x,y);dfs1(y,x);
		cal();
		dfs2(y,x);
	}
}

inline void solve2() //暴力枚举边
{
	dfs2(1,0);
}

inline void work()
{
	solve1();
	solve2();
}

int main()
{
	init();
	work();
	for(R int i=1;i<=n;i++)
		if(du[i]==1)
		{
			Edge[i].push_back(++n);
			work();
			Edge[i].pop_back();
			n--;
		}
	printf("%d %lld\n",ans1,ans2);
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long int I;

int keta(int a){
    int count=0;
    while(a!=0){
        a/=10;
        count++;
    }
    return count;
}


int main(){
    long long int n,cnt=0;
    cin>>n;
    int a[10][10]={0};
    int k=0,s,t;

    for(int i=1;i<=n;i++){
        k=keta(i)-1;
        s=i/pow(10,k);
        t=i%10;
        a[s][t]+=1;
    }

    for(int i=1;i<10;i++){
        for(int j=i;j<10;j++){
            cnt+=a[i][j]*a[j][i];
            if(i!=j){
                cnt+=a[i][j]*a[j][i];
            }
        }
    }
    cout<<cnt<<endl;

    return 0;
} //カモンAC

Measured memory_bytes: 256
# N
# a1
# ...
# an

n = gets.chomp.to_i

as = n.times.map do |_i|
  gets.chomp.to_i
end

as.sort!

i = 0
last = 101

as.reverse_each do |a|
  i += 1 if a < last
  last = a
end

puts i


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main() {
  string s; cin >> s;
	int tmp = 0;
	int ans = 0;
  FOR(i,0,2){
		if(s[i]=='R') ++tmp;
		else tmp = 0;
		chmax(ans,tmp);
  }
	cout << ans << endl;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>

int main(void){
  int top=0;
  int S[1000];
  int a,b,c;
  char op[1000];


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

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


  while(scanf("%s",op)!=EOF){
    if(op[0]=='+'){
      a=pop();
      b=pop();
      c=a+b;
      //printf("%d\n",a);
      //printf("%d\n",b);
      //printf("%d\n",c);
      push(c);
    }else if(op[0]=='-'){
      a=pop();
      b=pop();
      c=b-a;
      //printf("%d\n",a);
      //printf("%d\n",b);
      //printf("%d\n",c);
      push(c);
    }else if(op[0]=='*'){
      a=pop();
      b=pop();
      c=a*b;
      //printf("%d\n",a);
      //printf("%d\n",b);
      //printf("%d\n",c);
      push(c);
    }else if(op[0]=='/'){
      a=pop();
      b=pop();
      c=b/a;
      //printf("%d\n",a);
      //printf("%d\n",b);
      //printf("%d\n",c);
      push(c);
    }else{
      push(atoi(&op[0]));
    }
  }

  printf("%d\n",pop());
  
  return 0;
}

Measured memory_bytes: 1832
#include <stdio.h>

int main(){
  int i,c[9],a[3][3],b[3][3];

  scanf("%d %d %d",&c[0],&c[1],&c[2]);
  scanf("%d %d %d",&c[3],&c[4],&c[5]);
  scanf("%d %d %d",&c[6],&c[7],&c[8]);

  if(c[0]-c[3]!=c[1]-c[4]||c[1]-c[4]!=c[2]-c[5]){
    printf("No");
    return 0;
  }
  if(c[0]-c[6]!=c[1]-c[7]||c[1]-c[7]!=c[2]-c[8]){
    printf("No");
    return 0;
  }
  if(c[0]-c[1]!=c[3]-c[4]||c[3]-c[4]!=c[6]-c[7]){
    printf("No");
    return 0;
  }
  if(c[0]-c[2]!=c[3]-c[5]||c[3]-c[5]!=c[6]-c[8]){
    printf("No");
    return 0;
  }
  printf("Yes");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
   ll n,x,i,count=0,t,s;
   cin>>n>>x;
   ll a[n];
   for(i=0;i<n;i++){
       cin>>a[i];
   }
   sort(a,a+n);
   for(i=0;i<n-1;i++){
       if(a[i]<=x){
            x = x-a[i];
            count++;
            }
       
       
   }
   s=x;
   if(s==a[n-1]){
       count++;
   }
   cout<<count;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int NIL = -1;
const int MAX = 30;

struct Node {
    int parent, left, right;
};

Node tree[MAX];

int get_parent(int node_id) {
    return tree[node_id].parent;
}

int get_brother(int node_id) {
    int parent = tree[node_id].parent;
    if (parent == -1) {
        return NIL;
    } else if (tree[parent].left == node_id) {
        return tree[parent].right;
    } else if (tree[parent].right == node_id) {
        return tree[parent].left;
    }
}

int get_degree(int node_id) {
    // nodeの子の数
    int number_of_children = 0;
    if (tree[node_id].right != NIL) number_of_children++;
    if (tree[node_id].left != NIL) number_of_children++;

    return number_of_children;
}

int get_depth(int node_id) {
    int depth = 0;
    int temp_parent = tree[node_id].parent;
    while (true) {
        if (temp_parent == NIL) return depth;
        else depth++;
        temp_parent = tree[temp_parent].parent;
    }
}

int get_height(int node_id) {
    int h1, h2;
    h1 = h2 = 0;
    if (tree[node_id].left != NIL) h1 = get_height(tree[node_id].left) + 1;
    if (tree[node_id].right != NIL) h2 = get_height(tree[node_id].right) + 1;

    return max(h1, h2);
}

string get_type(int node_id) {
    if (get_parent(node_id) == NIL) return "root";
    else if (tree[node_id].left == NIL && tree[node_id].right == NIL) return "leaf";
    else return "internal node";
}

void print_node(int node_id) {
    cout << "node " << node_id << ": parent = " << get_parent(node_id) << ", sibling = " << get_brother(node_id)
        << ", degree = " << get_degree(node_id) <<  ", depth = " << get_depth(node_id) << ", height = " << get_height(node_id)
        << ", " << get_type(node_id) << endl;
}

void print_tree(int number_of_nodes) {
    for (int n=0; n < number_of_nodes; n++) {
        print_node(n);
    }
}

int main() {
    int number_of_nodes, node_id, left_node, right_node;
    cin >> number_of_nodes;

    for (int n=0; n < number_of_nodes; n++) tree[n].parent = tree[n].left = tree[n].parent = NIL;

    for (int n=0; n < number_of_nodes; n++) {
        cin >> node_id;
        cin >> left_node;
        cin >> right_node;

        tree[node_id].left = left_node;
        tree[node_id].right = right_node;
        if (left_node != NIL) tree[left_node].parent = node_id;
        if (right_node != NIL) tree[right_node].parent = node_id;
    }

    print_tree(number_of_nodes);
    return 0;
}



Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#define REP(i, start, n) for(int i = start; i < n; ++i)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
#define debug2d(var)  do{std::cout << #var << " : \n";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;

vector<vector<int> > G;
vector<int> dp;

int rec(int v) {
    if (dp[v] != -1) return dp[v];

    int res = 0;
    for(auto nv : G[v]) {
        res = max(res, rec(nv)+1);
    }

    return dp[v] = res;
}

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

    G.assign(N+1, vector<int>());
    dp.assign(N+1, -1);
    REP(i, 1, M+1) {
        int x, y;
        cin >> x >> y;
        G[x].push_back(y);
    }

    int ans = 0;
    REP(i, 1, N+1) {
        ans = max(ans, rec(i));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;

using vi = vector<int>;
using vs = vector<string>;
using ll = long long;
using vll = vector<ll>;

#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)

#ifdef LOCAL
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#else
#define dump(c) ;
#endif

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

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

inline vi uni(vi &vec) {
    sort(vec.begin(), vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

struct ____ {
    ____() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} ________;

string solve() {
    string S;
    cin >> S;
    vi nums(4);
    rep(i, 4) nums[i] = S[i] - '0';

    rep(M, 1 << 3) {
        int t = nums[0];
        stringstream ss;
        ss << S[0];

        rep(i, 4-1) {
            if ((M >> i & 1) == 1) {
                t += nums[i+1];
                ss << '+' << S[i+1];
            } else {
                t -= nums[i+1];
                ss << '-' << S[i+1];
            }
        }

        if(t == 7) {
            ss << "=7";
            return ss.str();
        }
    }

    return "";
}

int main() {
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define GET_BIT(n, i) (((n) & (1LL << ((i)-1))) >> ((i)-1)) // i start from 1
#define SET_BIT(n, i) ((n) | (1LL << ((i)-1)))
#define CLR_BIT(n, i) ((n) & ~(1LL << ((i)-1)))
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
void myInit();
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int MOD = 1000000007;
const int N = 3e5, M = N;
//=========TQR==============
vi g[N];

int main() {
	myInit();
	FIO;
	ll a, b, c, d, sn = 0;
	cin >> a >> b >> c >> d;
	cout << max(a * c, max(a * d, max(b * c, b * d))) << endl;

	return 0;
}

void myInit() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int mpow(int base, int exp) {
	base %= MOD;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = ((ll)result * base) % MOD;
		base = ((ll)base * base) % MOD;
		exp >>= 1;
	}
	return result;
}

void ipgraph(int n, int m) {
	int i, u, v;
	while (m--) {
		cin >> u >> v;
		g[u - 1].pb(v - 1);
		g[v - 1].pb(u - 1);
	}
}

void dfs(int u, int par) {
	for (int v : g[u]) {
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10636
r, g, b, n = gets.split.map(&:to_i)
ans = 0
0.upto(n) do |i|
  break if r * i > n
  0.upto(n) do |j|
    break if r * i + g * j > n
    c = n - r * i - g * j
    ans += 1 if c % b == 0;
  end
end
puts ans

Measured memory_bytes: 1788
n = gets.to_i
a = gets.chomp.split
n.times do |i|
    a[i] = a[i].to_i
end

diffs = []
n.times do |i|
    ((i+1)..(n-1)).each do |j|
        diff = (a[i] - a[j]).abs
        diffs << diff
    end
end

puts diffs.max

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    double sum = 0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    sum /= 4*m;
    sort(a.begin(), a.end());
    int fi = 0;
    rep(i,n) if(a[i] >= sum){
        fi = n-i;
        break;
    }
    if(fi >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import permutations
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

for i,p in enumerate(permutations(range(1,N+1))):
    if p==P:
        a = i
    if p==Q:
        b = i

print (abs(a-b))


Measured memory_bytes: 3060
#include <stdio.h>
int main(){
 
  int d[6],i,blank;
  char ENSW[100];
 
  for(i = 0; i < 6; i++){
 
    scanf("%d",&d[i]);
 
  }
 
  scanf("%s",ENSW);
   
  for(i = 0; ENSW[i] != '\0'; i++){
 
    if(ENSW[i] == 'N'){
 
      blank=d[0];
      d[0]=d[1];
      d[1]=d[5];
      d[5]=d[4];
      d[4]=blank;
 
    }
 
    if(ENSW[i] == 'E'){
 
      blank=d[0];
      d[0]=d[3];
      d[3]=d[5];
      d[5]=d[2];
      d[2]=blank;
 
    }
 
    if(ENSW[i] == 'S'){
 
      blank=d[0];
      d[0]=d[4];
      d[4]=d[5];
      d[5]=d[1];
      d[1]=blank;
 
    }
 
    if(ENSW[i] == 'W'){
 
      blank=d[0];
      d[0]=d[2];
      d[2]=d[5];
      d[5]=d[3];
      d[3]=blank;
 
    }
 
  }
   
  printf("%d\n",d[0]);
 
  return 0;
 
}


Measured memory_bytes: 2144
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#define rep(x, l, r) for(int x = l; x <= r; x++)
#define repd(x, r, l) for(int x = r; x >= l; x--)
#define clr(x, y) memset(x, y, sizeof(x))
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define MAXN
#define fi first
#define se second
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
const int INF = 1 << 30;
const int p = 1000000009;
int lowbit(int x){ return x & (-x);}
int fast_power(int a, int b){ int x; for(x = 1; b; b >>= 1){ if(b & 1) x = 1ll * x * a % p; a = 1ll * a * a % p;} return x % p;}

int main(){
	int n;
	char st[55];
	scanf("%d", &n);
	scanf("%s", st);
	int ans = 0;
	rep(i, 0, n - 3)
		if(st[i] == 'A' && st[i + 1] == 'B' && st[i + 2] == 'C') ans++;
	printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,i,j,k,sz,n0,n1;
char s[500010],t[500010],a[500010],b[500010];
int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	scanf("%s",t+1);
	n0=strlen(s+1);n1=strlen(t+1);
	for(i=n/n0;i>=0;i--)if((n-n0*i)%n1==0){
		for(j=1;j<=i;j++){
			for(k=1;k<=n0;k++)a[++sz]=s[k];
		}
		for(j=1;j<=(n-n0*i)/n1;j++){
			for(k=1;k<=n1;k++)a[++sz]=t[k];
		}
		break;
	}
	sz=0;
	for(i=n/n1;i>=0;i--)if((n-n1*i)%n0==0){
		for(j=1;j<=i;j++){
			for(k=1;k<=n1;k++)b[++sz]=t[k];
		}
		for(j=1;j<=(n-n1*i)/n0;j++){
			for(k=1;k<=n0;k++)b[++sz]=s[k];
		}
		break;
	}
	for(i=1;i<=n;i++)if(a[i]<b[i]){
		for(i=1;i<=n;i++)printf("%c",a[i]);return 0;
	}
	 else if(a[i]>b[i]){
	 	for(i=1;i<=n;i++)printf("%c",b[i]);return 0;
	 }
	 for(i=1;i<=n;i++)printf("%c",a[i]);
}

Measured memory_bytes: 1280
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll X;
    cin >> X;
    if (X >= 30)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

using namespace std;

typedef pair<int, int> PII;
typedef long long ll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pct __builtin_popcount

#define INF 10000000010LL

int p[1000], pb[1000], L; ll pc[1000]; 
int n; map<ll, int> F; map<ll, ll> ra;
set<ll> C;

int main () {
	for (int i = 2; i < 3000; i ++) {
		bool F = 1;
		for (int j = 2; j*j <= i; j ++) 
			if (i%j == 0) {F = 0; break;}
		if (F) {
			p[L] = i;
			pb[L] = i*i;
			pc[L] = (ll)i*i*i;
			L ++;
		}
	}
	cin >> n;
	int S = 0;
	bool F1 = 0;
	for (int i = 0; i < n; i ++) {
		ll x;
		cin >> x;
		ll y = 1;
		ll x1 = 1;
		for (int j = 0; x != x1 && j < L; j ++) {
			while (x%pc[j] == 0) {
				x /= pc[j];
			}
			if (x%pb[j] == 0) {
				y *= p[j];
				x1 *= pb[j];
				if (y > INF) y = INF;
			} else
			if (x%p[j] == 0) {
				y *= pb[j];
				x1 *= p[j];
				if (y > INF) y = INF;
			}
		}
		x /= x1;
		if (y >= INF) {
			S ++; continue;
		}
		if (x != 1) {
			int c = sqrt(x); int cc = -1; 
			for (int d = max(1, c-10); d <= c+10; d ++)
				if ((ll)d*d == x) {
					cc = d; break;
				}
			if (cc == -1) {
				if (INF/x/x < y) {S ++; continue;}
				y *= x; y *= x;
			} else {
				y *= cc;
			}
		}
		if (y >= INF) {
			S ++; continue;
		}
		x *= x1;
		if (x == 1) {
			if (!F1) {
				F1 = 1;
				S ++;
			}
			continue;
		}
		F[x] ++;
		ra[x] = y;
	}
	
	for (map<ll,int>::iterator i = F.begin(); i != F.end(); i ++) {
		ll r = ra[i->fi];
		if (i->fi < r || F.find(r) == F.end()) {
			S += max(i->se, F[r]);
		}
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 20864
import itertools
n = int(input())
d = {}
for i in range(n):
  s = str(input())[0]
  if (s == 'M') or (s == 'A') or (s == 'R') or (s == 'C') or (s == 'H') :
    if s in d:
      d[s] += 1
    else:
      d[s] = 1
if len(d) <= 2:
  print(0)
else:
  d = sorted(d.values())
  if len(d) == 3:
    ans = 1
    for i in d:
      ans *= i
    print(ans)
  else:
    ans = 0
    for team in itertools.combinations(d, 3):
      cnt = 1
      for i in team:
        cnt *= i
      ans += cnt
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <tuple>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <random>
#include <queue>
#include <deque>
#include <iterator>
#include <map>
#include <functional>
#include <numeric>
using namespace std;
#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 pb(a) push_back(a)
#define llong long long
#define INF 1145141919
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
int dy[] = { 1, 0, -1, 0 };
int dx[] = { 0, 1, 0, -1 };
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }


int main() {
	string s;
	int d0 = 0; // 010101
	int d1 = 0; // 101010
	cin >> s;
	REP(i, s.length()) {
		// 000
		// 010
		// 101

		// 01010101
 		if (i % 2 == 0 && s[i] != '0') {
			d0++;
		}
		if (i % 2 == 1 && s[i] != '1') {
			d0++;
		}

		// 10101010
		if (i % 2 == 0 && s[i] != '1') {
			d1++;
		}
		if (i % 2 == 1 && s[i] != '0') {
			d1++;
		}

	}
	cout << min(d0, d1) << endl;
	return 0;
}


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

int main() {
    string a,b,c;
    cin >> a >> b >> c;
    if(a.at(a.size()-1) == b.at(0) && b.at(b.size()-1) == c.at(0)){
        cout << "YES";
    } else {
        cout << "NO";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>

using namespace std;

int main(){
	
	while(true){
		
		int n;
		
		cin >> n;
		
		if(n == 0){
			break;
		}
		
		string name[10];
		int index[10], index_ans[10];
		double w[10], s[10];
		
		for(int i = 0; i < n; i++){
			cin >> name[i] >> w[i] >> s[i];
			index[i] = i;
		}
		
		double G_min = 100000;
		
		do{
			double weight_sum = 0;
			for(int i = 0; i < n; i++){
				if(weight_sum > s[index[i]]){
					break;
				}
				weight_sum += w[index[i]];
				if(i == n - 1){
					int G_cur = 0;
					for(int j = 0; j < n; j++){
						G_cur += w[index[j]] * (n - j);
					}
					if(G_cur < G_min){
						G_min = G_cur;
						for(int j = 0; j < n; j++){
							index_ans[j] = index[j];
						}
					}
				}
			}
		}while(next_permutation(index, index + n));
		
		for(int i = 0; i < n; i++){
			cout << name[index_ans[n - i - 1]] << endl;
		}
		
	}
	
	return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

    int a, b; cin >> a >> b;
    if(b%a == 0) {
        cout << a+b << endl;
    } else {
        cout << b-a << endl;
    }
    return 0;
}


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

const int inf = 1e9;

int main () {
    int N, K;
    std::cin >> N >> K ;
    int arr[N];
    for ( int i = 0; i < N; ++i ) 
        std::cin >> arr[i];
    int dp[N];
    dp[0] = 0;
    for ( int i = 1; i < N; ++i ) {
        int min_el = inf;
        for ( int pos = 1; pos <= K; ++pos) {
            if( i-pos >= 0 ) {
                min_el = std::min(dp[i-pos] + std::abs(arr[i-pos]- arr[i]), min_el); 
            }
        }   
        dp[i] = min_el;
    }
    std::cout << dp[N-1] << std::endl;
    return 0;
}


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

constexpr int mod = 10;

int mod_pow(int a, long long x) {
	int res = 1;
	while(x) {
		if(x & 1) res = (res * a) % mod;
		a = (a * a) % mod;
		x >>= 1;
	}
	return res;
}

int main() {
	long long n, m, k;
	cin >> n >> m >> k;

	n %= mod;

	int a = n;
	const int c = mod_pow(a, m);

	long long ans = 0;
	unordered_map<int, int> index;
	for(long long i = 0; i < k; ++i) {
		if(index.count(a)) {
			const int start = index[a];
			const int T = i - start;
			const int num = (k - start) / T;

			ans = 0;
			for(const auto e : index) {
				if(e.second >= start) ans += (long long)e.first * num;
				else ans += e.first;
			}

			for(long long j = start + num * T; j < k; ++j) {
				ans += mod_pow(n, 1 + j * m);
			}
			break;
		}

		ans += a;
		index[a] = i;
		a = (a * c) % mod;
	}

	cout << ans << endl;

	return 0;
}


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

main(){
  string X;
  cin >> X;
  
if(X[0]!='A'){
  cout << "WA" <<endl;
  return 0; 
}

int count =0;
for(int i=2; i<=X.size()-2 ;i++){
  if(X[i]=='C') count++;
}
  
if(count!=1){
 cout << "WA" <<endl;
  return 0; 
} 

  
bool flag = true;
for(int i=1;i<X.size();i++){
if(X[i]=='a'||X[i]=='b'||X[i]=='c'||X[i]=='d'||X[i]=='e'||X[i]=='f'||X[i]=='g'||X[i]=='h'
   ||X[i]=='i'||X[i]=='j'||X[i]=='k'||X[i]=='l'||X[i]=='m'||X[i]=='n'||X[i]=='o'||X[i]=='p'
   ||X[i]=='q'||X[i]=='r'||X[i]=='s'||X[i]=='t'||X[i]=='u'||X[i]=='v'||X[i]=='w'||X[i]=='x'
   ||X[i]=='y'||X[i]=='z'||X[i]=='C') flag =true; 
else{
  flag = false;
  break;
}
}
  
if(!flag) cout << "WA" <<endl;
if(flag) cout << "AC" <<endl;

  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
//ショートカット
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<n;i++)
#define all(v) v.begin(), v.end()
#define pb push_back
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

//関数
//最大公約数
long long gcd(long long m,long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m,long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x,long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  lin(n);lin(a);lin(b);
  cout<<min(n*a,b);
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        
        int T_health = in.nextInt();
        int T_streng = in.nextInt();
        int A_health = in.nextInt();
        int A_streng = in.nextInt();
     
        int k = 0;
        while(A_health > 0 && T_health > 0) {
            
            if(1-k == 1) {
                k = 1;
                A_health =  A_health - T_streng;
            }
            else {
                k = 0;
                T_health = T_health - A_streng;
            }
            
            if(T_health <= 0) {
                System.out.println("No");
            }
            else if(A_health <= 0) {
                System.out.println("Yes");
            }
        }
    }
    

        
}


Measured memory_bytes: 35648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define D(a) (double)(a)
#define vct vector
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define vb vct<bool>
#define vs vector<string>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define For(a,n,in) for(int i=a; i<n; i+=in)
#define print(v) for(auto it:v)cout<<it<<' ';cout<<endl;
#define PI acos(-1)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
///................function.....................///
#define siz(s) (int)(s.size())
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mod 999999937
const int N=1000005;
vll a(N),b(N);
int n;
int main()
{
    ///freopen("in.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    int n,i,j;
    string s;
    cin>>n>>s;
    int w=0,r=0,ww=0;
    bool ok=0;
    vi wpos,rpos;
    for(i=0; i<n; i++)
    {
        (s[i]=='W')?w++,wpos.pb(i):rpos.pb(i),r++;
    }
    if(w==0||r==0)
    {
        cout<<0<<endl;
        return 0;
    }
    j=n-1;
    for(i=0; i<j; i++)
    {
        if(s[i]=='W')
        {
            while(s[j]!='R'&&i<j)j--;
            if(s[j]=='R')
                swap(s[i],s[j]),ww++;
            else break;
        }
    }
    cout<<ww<<endl;

}


Measured memory_bytes: 20388
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] arr = new int[n][n];

        for (int i = 0; i < n; ++i) {
            int id = sc.nextInt();
            int degree = sc.nextInt();
            for (int j = 0; j < degree; ++j) {
                int a = sc.nextInt();
                arr[id - 1][a - 1] = 1;
            }
        }

        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                System.out.print(arr[i][j]);
                if (j != n - 1)
                    System.out.print(" ");
            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 34448
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top,S[1000];
void push(int x){
	S[++top]=x;
}
int pop(){
	top--;
	return S[top+1];
}
int main(void){
	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]=='-'){
			a=pop();
			b=pop();
			push(b-a);
		}else if(s[0]=='*'){
			a=pop();
			b=pop();
			push(a*b);
		}else{
			push(atoi(s));
		}
		
	}
	printf("%d\n",pop());
	return 0;
	
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n;
    cin >> n;

    int a[100000];
    rep(i, n){
        cin >> a[i];
    }
    sort(a, a+n);
    
    int tmp=a[0], count = 0;
    bool check = false;
    for(int i=1; i<n; i++){
        if(tmp == a[i] && !check){
            check = true;
            count++;
        }
        else{
            check = false;
        }
        tmp = a[i];
    }
    
    cout << n - 2*count;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
//S.size()
//配列名.Length()
using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;


int main(void){
	string S; cin>>S;
	VC Sd(0);
	int num = 0,cnt = 0;
	for(int i = 0;i < S.size() - 1; i++)Sd.push_back(S[i]);

	bool jud = true;

	while(Sd.size() > 0){
		num = 0;
		jud = true;
		if(Sd.size() % 2 == 0){
			num = Sd.size() / 2;
			for(int j = 0; j < num; j++){
				if(Sd[j] != Sd[j + num])jud = false;
			}
			if(jud){
				for(int x = 0; x < Sd.size(); x++)cnt++;
				cout<<cnt;
				break;
			}
		}
		Sd.pop_back();
	}
}


Measured memory_bytes: 256
#include<stdio.h>

void Rec(int,int);

int P[41],I[41],Po[41],n,now=0,s;

int main()
{
  int i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&P[i]);
  }
  for(i=0;i<n;i++){
    scanf("%d",&I[i]);
  }
  Rec(0,n);
  for(i=0;i<n-1;i++){
    printf("%d ",Po[i]);
  }
  printf("%d\n",Po[i]);
return 0;
}

void Rec(int l,int r)
{
  int c,m;
  if(l>=r)return;
  c=P[now++];
  m=Find(c);
  Rec(l,m);
  Rec(m+1,r);
  //printf("%d ",c);
  Po[s++]=c;
  
}

int Find(int c)
{
  int i;
  for(i=0;i<n;i++){
    if(c==I[i])return i;
  }
  return 0;
}
  

Measured memory_bytes: 596
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner s=new Scanner(System.in);
		int a=s.nextInt();
		String[]b=new String[a];
		for(int i=0;i<a;i++)b[i]=s.next();
		int t=0;
		int c=s.nextInt();
		for(int i=0;i<c;i++){
			String str=s.next();
			boolean ok=false;
			for(int j=0;j<a;j++)if(b[j].equals(str))ok=true;
			if(ok){
				if(t%2==0)System.out.println("Opened by "+str);
				else System.out.println("Closed by "+str);
				t++;
			}else System.out.println("Unknown "+str);
		}
	}
}

Measured memory_bytes: 21240
#include <iostream>

using namespace std;

class Dice {
    public:
    int face[6];
    Dice() {}
    void rotateX () {
        rotate(0, 1, 5, 4);
    }
    void rotateY () {
        rotate(0, 2, 5, 3);
    }
    void rotateZ () {
        rotate(1, 2, 4, 3);
    }
    void rotate (int a, int b, int c, int d) {
        int t = face[a];
        face[a] = face[b];
        face[b] = face[c];
        face[c] = face[d];
        face[d] = t;
    }
};

bool eq(Dice d1, Dice d2) {
    for (int i = 0; i < 6; i++)
        if (d1.face[i] != d2.face[i]) return false;
    return true;
}

bool equal(Dice d1, Dice d2) {
    for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 4; j++) {
            if (eq(d1, d2)) return true;
            d1.rotateZ();
        }
        if (i % 2 == 0) d1.rotateY();
        else d1.rotateX();
    }
    return false;
}

Dice d[100];
int n;

bool check () {
    for (int i = 0; i < n - 1; i++)
        for (int j = i + 1; j < n; j++) if (equal(d[i], d[j])) return false;
    return true;
}

int main () {
    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < 6; j++) cin >> d[i].face[j];
    
    if (check()) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3100
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    while(1){
        int count=0;
        int n,x;
        cin>>n>>x;
        if(n==0&&x==0){
             break;
        }
        for(int i=n;i>=1;i--){
            for(int j=n;j>i;j--){
                for(int k=n;k>j;k--){
                    if(i+j+k==x){
                        count++;
                    }        
                }
            }
        }
        cout<<count<<endl;
    }
}



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

typedef long long LL;

int main(void){
    LL k, n;
    int a[200000];
    cin >> k >> n;
    int tmp;
    rep(i, n){
        cin >> a[i];
    }
    int ans = a[n - 1] - a[0];
    int dis;
    for(int i = 0;i < n - 1;i++){
        dis = k - a[i + 1] + a[i];
        if(dis < ans)ans = dis;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
bool judge(int a,int b,string s){
    string temm = "##";
    s = s + temm;
    bool jud[s.size()];
    rep(i,s.size()){
        jud[i] = false;
    }
    jud[a-1] = true;
    queue<int> que;
    que.push(a-1);
    int tem;
    while(!que.empty()){
        tem = que.front();
        if(s[tem+1] == '#' && s[tem+2] == '#'){
            que.pop();
        }
        else{
            if(s[tem+1] == '.'){
                que.push(tem+1);
                jud[tem+1] = true;
            }
            if(s[tem+2] == '.'){
                que.push(tem+2);
                jud[tem+2] = true;
            }
            que.pop();
        }
    }
    if(jud[b-1]){
        return true;
    }
    else{
        return false;
    }
}
bool check(int a,int b,string s){
    for(int i = a-2;i<=b-2;i++){
        if(s[i] == '.' && s[i+1] == '.' && s[i+2] == '.'){
            return true;
        }
    }
    return false;
}
int main(){
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    if(judge(a,c,s) && judge(b,d,s)){
        if(c<d){
            cout << "Yes" << endl;
        }
        else{
            if(check(b,d,s)){
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }
        }
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 1156
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
bool ok(int a[],int p[],int m){
    rep(i,m){
        if(a[i] != p[i] ){
            return false;
        }
    }
    return true;
}
int main(){
    int n,m;
    cin >> n >> m;
    map<int,vector<int>> mp;
    int k,l;
    rep(i,m){
        cin >> k;
        rep(j,k){
            cin >> l;
            mp[l].push_back(i);
        }
    }
    int p[m];
    int a[m] = {0};
    rep(i,m){
        cin >> p[i];
    }
    int tem,t;
    int ans = 0;
    rep(i,pow(2,n)){
        tem = i;
        rep(j,n){
            if(tem%2==1){
                rep(l,mp[j+1].size()){
                    a[mp[j+1][l]]++;
                    a[mp[j+1][l]]%=2;
                }
            }
            tem/=2;
        }
        if(ok(a,p,m)){
            ans++;
        }
        rep(j,m){
            a[j] = 0;
        }
    }
    cout << ans << endl;
}

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

int main(void){
    int N;
    cin>>N;
    double ans=0;
    for (int i=0;i<N;i++){
        double x;
        string u;
        cin>>x>>u;
        if (u=="JPY") ans+=x;
        else ans+=x*380000;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0002&lang=jp

#include <algorithm>
#include <iostream>
#include <vector>

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

using namespace std;

//テ」ツδ榲」ツつッテ」ツδュテ・ツョツ堙ァツセツゥ
#define ALL(v) (v).begin(),(v).end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); ++i)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define SORT(x) sort(begin(x),end(x))
#define SELECT_SORT(x, n) sort(begin(x),begin(x)+n)
#define SWAP(type, a, b) do {type tmp = a; a = b; b = tmp;} while (0)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))

//テ・ツョツ堙ヲツ閉ー
#define INF 2000000000000
#define MAX 10

//DEBUGテァツ板ィ
#define BAR() cout << "----------------------------" << endl;
#define DUMP(v) (cerr << #v << ": " << v << endl)
#define PRINT(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;


int main()
{
	int a=0;
	int b=0;
	while(cin >> a >> b)
	{
		int total = a + b;
		
		int i;
		if(total == 0){
			cout << i << endl;
		}else{
			for(i = 0; total != 0; i++){ total /= 10; }
			cout << i << endl;
		}
	}
	
}

Measured memory_bytes: 1160