akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main() {
    ll N,M;
    cin >> N>>M;
    
    vector<ll> A(M);
    vector<ll> B(M);
    rep(i,M){
        ll a,b;
        cin >>A[i]>>B[i];
        A[i]--;
        B[i]--;
    }
    ll ans = 0;

    rep(i,M){
        UnionFind tree(N);
        rep(j,M){
            if(j!=i)
                tree.unite(A[j],B[j]);
        }

        if(!tree.same(A[i],B[i])) ans++;
    }

    cout << ans<<endl;
    return 0;
    

}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	string s;

	cin >> s;

	ll nowl = 0;
	ll nowr = 6;
	string ss = "keyence";

	REP(i, s.size()) {
		if (ss[nowl] == s[i]) {
			nowl++;
		}
		else {
			break;
		}
		if (nowl == ss.size()) {
			cout << "YES" << endl;
			return 0;
		}
	}

	RREP(i, s.size()) {
		if (ss[nowr] == s[i]) {
			nowr--;
		}
		else {
			break;
		}
		if (nowr == -1) {
			cout << "YES" << endl;
			return 0;
		}
	}

	if (nowl > nowr) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys,math,itertools
input = sys.stdin.readline
n, k = map(int, input().split())
d = [int(_) for _ in input().split()]
d_set = set(d)
d_all = set(range(10))
d_use = [str(a) for a in list(d_all - d_set)]
keta = int(math.log10(n))+1
# l1 = [int(''.join(list(a))) if int(''.join(list(a)))>=n else 100000 for a in list(itertools.product(d_use, repeat=keta+1))]
# l2 = [int(''.join(list(a))) if int(''.join(list(a)))>=n else 100000 for a in list(itertools.product(d_use, repeat=keta))]
temp = 100000
for i in list(itertools.product(d_use, repeat=keta+1)):
  a = int(''.join(list(i)))
  if (a>=n)&(a<temp):
    temp = a
for i in list(itertools.product(d_use, repeat=keta)):
  a = int(''.join(list(i)))
  if (a>=n)&(a<temp):
    temp = a

print(temp)

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

		while(scanf("%f %f",&a,&b)!=EOF) {
			if(35.50>a && 71.00>b){
				printf("AAA\n");
			}
			else if (37.50>a && 77.00>b){
				printf("AA\n");
			}
			else if (40.00>a && 83.00>b){
				printf("A\n");
			}
			else if (43.00>a && 89.00>b){
				printf("B\n");
			}
			else if(50.00>a && 105.00>b){
				printf("C\n");
			}
			else if(55.00>a && 116.00>b){
				printf("D\n");
			}
			else if(70.00>a && 148.00>b){
				printf("E\n");
			}
			else{
				printf("NA\n");
			}
		}
		return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,x,y;
  x=0;
  y=0;
  cin>>n;
  vector <int>vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  for (int i=0;i<n;i+=2){
   x+=vec.at(i);}
  for (int j=1;j<n;j+=2){
   y+=vec.at(j);}
  cout<<x-y<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db long double
#define all(a) a.begin(),a.end()
#define pb push_back
#define f(i,l,u) for(ll i=l;i<u;i++)
#define lb lower_bound
#define ub upper_bound
#define pii pair<ll,ll> 

        
long long power( long long x, 
                         ll y, ll p) 
{ 
   long long res = 1; // Initialize result 
  
    x = x % p; 
    while (y > 0) { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x) % p; 
  
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 

  
int main() {
 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  
   
  ll n;
  cin>>n;
  ll ans=1;
  ll mod=1e9+7;
  if(n==1)
  cout<<0<<endl;
  else
  {
    
      ans=power(10,n,mod);
        ans+=power(8,n,mod);
        
        
        ans-=power(9,n,mod);
        ans+=mod;
        ans%=mod;
        ans-=power(9,n,mod);
        ans+=mod;
        ans%=mod;
     
      cout<<ans<<endl;
  }
   

      

return 0;    
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int N;

long long dp[200000];

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

  rep(i, 200000) dp[i] = INF;

  vector<int> a;
  for(int i=1; i<=N; i*=6) a.push_back(i);
  for(int i=9; i<=N; i*=9) a.push_back(i);

  dp[0] = 0;
  rep(i, N){
    for(int j : a){
      chmin(dp[i+j], dp[i]+1);
    }
  }

  cout << dp[N] << endl;

  return 0;
}


Measured memory_bytes: 1792
#MLE注意！0や1のケースに注意

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = list(map(int, input().split()))
    adj = [[] for _ in range(n)] #頂点数, 場合によって変える
    for _ in range(n-1):
        c,b = map(int, input().split())
        adj[c-1].append(b-1)
        adj[b-1].append(c-1)

    # 頂点1も含む
    res = [0]*n
    res[0] = 1

    def dfs(v, par, L):
        if v != 0:
            if a[v] > L[-1]:
                temp = -1
                L.append(a[v])
            else:
                temp = bisect_left(L, a[v])
                pre = L[temp]
                L[temp] = a[v]
        res[v] = len(L)
        for nv in adj[v]:
            if nv == par:
                continue
            dfs(nv, v, L)
        if v != 0:
            if temp == -1:
                L.pop(-1)
            else:
                L[temp] = pre

    L = [a[0]]
    dfs(0, -1, L)
    for i in range(n):
        print(res[i])

if __name__ == '__main__':
    main()


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

using namespace std;

int main(){
	string s;
	cin>>s;
	if(s=="SUN") cout<<7;
	if(s=="SAT") cout<<1;
	if(s=="FRI") cout<<2;
	if(s=="THU") cout<<3;
	if(s=="WED") cout<<4;
	if(s=="TUE") cout<<5;
	if(s=="MON") cout<<6;
	return 0;
}

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

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int time = 0;
	time = min(b,d) - max(a,c);
	if(time < 0) time = 0;
	cout << time << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using p = pair<int, int>;

int main()
{
    long long ans = 0;
    int n;

    cin >> n;
    for(int i=1;i<n+1;i++){
        if (i % 3 == 0)
            continue;
        else if (i % 5 == 0)
            continue;
        else
            ans += i;
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 3648
# C
ABC = list(map(int, input().split()))
ABC.sort()
a = ABC[2] - ABC[1]
b = ABC[1] - ABC[0]
# a + b // 2
# b % 2 == 1 -> + 2
if b % 2 == 1:
    c = 2
else:
    c = 0
ans = a + b // 2 + c
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b; cin >> a >> b;
  	if (b < a) swap(a, b);
  	if (a == 1 && b == 2) cout << 3 << endl;
	if (a == 1 && b == 3) cout << 2 << endl;
  	if (a == 2 && b == 3) cout << 1 << endl;
}

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

#define int long long
using P = pair<int, int>;

struct edge {
    int to;
    int cost;
    edge(int to, int cost) : to(to), cost(cost) { }
};

int V, E, r;

vector<edge> G[100001];
int d[100001];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, 1e+9);
    d[s] = 0;
    que.push(P(0, s));
    while(!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        for(int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

auto main() -> signed {
    cin >> V >> E >> r;
    int s, t, di;
    for(int i=0; i<E; ++i) {
        cin >> s >> t >> di;
        G[s].push_back(edge(t, di));
    }
    dijkstra(r);
    for(int i=0; i<V; ++i) {
        if(d[i]==1e+9) cout << "INF" << endl;
        else cout << d[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 19420
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };
const double PI = 3.14159265358979323846;




int main() {

	int n, m;
	cin >> n >> m;

	int ans = (n - 1) * (m - 1);

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



Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
B = [0 for _ in range(N+1)]
for i in range(N//2+1,N+1):
    B[i] = A[i]
for i in range(N//2,0,-1):
    cnt = A[i]
    for j in range(2,N//i+1):
        cnt = (cnt+B[i*j])%2
    B[i] = cnt
C = []
for i in range(1,N+1):
    if B[i]==1:
        C.append(i)
print(len(C))
print(*C)

Measured memory_bytes: 107532
// debugging airy's code
#include <math.h>
#include <stdio.h>
#include <cstdio>
using namespace std;

long int isqrt(long int x);

const int MAX_N = 1000;

int main() {
    long int N = 0;
    /* read input */
    scanf("%ld", &N);
    long int s = isqrt(2 * N);
    if (2 * N == s * (s + 1)) {
        printf("Yes\n");

        int n = 1;
        int sets[MAX_N][MAX_N];
        for (long int i = 0; i < s; i++) {
            for (long int j = i; j < s; j++) {
                sets[i][j] = n;
                sets[j + 1][i] = n;
                n++;
            }
        }
        printf("%ld\n", s+1);
        for (int i = 0; i < s + 1; i++) {
            printf("%ld ", s);
            for (int j = 0; j < s - 1; j++) {
                printf("%d ", sets[i][j]);
            }
            printf("%d\n", sets[i][s - 1]);
        }
    } else
        printf("No\n");
    return 0;
}

long int isqrt(long int x) {
    long int ans = 1;
    while (ans * ans < x) {
        ans++;
    }
    return ans - 1;
}

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

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

  cout<<n[a]-n[a+1]/2<<endl;

}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 205;
const int inf = 1e9;

int n,m;
int cost[12][12];
int g[maxn][maxn];

int dijkstra(int src) {
  vector<int> res(10, inf);
  set<pair<int,int>> fringe;
  for (int i=0; i<=9; i++) {
    fringe.insert({cost[src][i], i});
  }
  
  while (!fringe.empty()) {
    auto cur = *fringe.begin();
    fringe.erase(fringe.begin());
    int v = cur.second;
    int dist = cur.first;
    if (dist < res[v]) {
      res[v] = dist;
      for (int to=0; to<=9; to++) {
        fringe.insert({dist + cost[v][to], to});
      }
    }
  }
  return res[1];
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  //cout << fixed << setprecision(6);
  cin>>n>>m;
  for (int i=0; i<=9; i++) {
    for (int j=0; j<=9; j++) {
      cin>>cost[i][j];
    }
  }
  
  vector<int> cost_to_1(10, inf);
  for (int i=0; i<=9; i++) {
    if (i==1) {
      cost_to_1[i]=0;
    } else {
      cost_to_1[i] = dijkstra(i);
    }
  }
  
  int ans = 0;
  
  for (int i=0; i<n; i++) {
    for (int j=0; j<m; j++) {
      cin>>g[i][j];
      if (g[i][j]==-1) continue;
      ans += cost_to_1[g[i][j]];
    }
  }
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	string ans = "keyence";
	if (s == ans) {
		cout << "YES" << endl; return 0;
	}
	rep(i, s.size()) {
		FOR(j, i, s.size()) {
			string tmp;
			rep(k, s.size()) {
				if (i <= k && k <= j)continue;
				tmp += s[k];
			}
			if (tmp == ans) {
				cout << "YES" << endl; return 0;
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}

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

long long int n,z,w;
long long int a[2001];

int main(){
    cin>>n>>z>>w;
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    long long int A=a[n-2],B=a[n-1];
    long long int a_b=abs(A-B),
        b_y=abs(B-w);
    if(n!=1){
        cout<<max(a_b,b_y)<<endl;
    }
    else{
        cout<<abs(a[0]-w)<<endl;
    }
    return 0;
}


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

#define rep(i, a, b) for (register int i = a; i <= b; i++)
#define per(i, a, b) for (register int i = a; i >= b; i--)
#define dbg(x) cout << #x << ": " << x << endl;
#define pii pair<int, int>
typedef long long ll;

using namespace std;

int read() {
	register int ret = 0; char c = getchar();
	while (!isdigit(c)) c = getchar();
	while (isdigit(c)) { ret = ret * 10 + (c - '0'); c = getchar(); }
	return ret;
}

int a[110];
stack<int> st;

int main() {
	int n = read();
	rep(i, 1, n) a[i] = read();
	int it = n;
	while (it--) {
		int pos = -1;
		for (int i = n; i >= 1; i--) {
			if (a[i] == i) {
				pos = i;
				st.push(i);
				for (int k = i; k <= n - 1; k++) a[k] = a[k + 1];
				n--;
				break;
			}
		}
		if (pos == -1) return 0 * puts("-1");
	}
	while (st.size()) {
		cout << st.top() << endl;
		st.pop();
	}
}

Measured memory_bytes: 256
while True:
    n,x = map(int,input().split())
    ans = 0
    if n == 0 and x == 0:
        break
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i + j + k == x:
                    ans += 1
    print(ans)


Measured memory_bytes: 5596
# C - Go to School
def main():
    import numpy as np
    n = int(input())
    a = list(map(int, input().split()))
    a = np.array(a)
    a = np.argsort(a)
    for i in a:
        print(i+1,end=" ")

if __name__ ==  "__main__":
    main()

Measured memory_bytes: 23376
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,s,c=0,i,j;
	scanf("%d %d",&k,&s);
	for(i=0;i<=k;i++)
	for(j=0;j<=k;j++)
	{
		if(s-i-j<=k && s-i-j>=0)
		c++;
	}
	printf("%d",c);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
  ll N;
  ll mod = 1000000007;
  cin >> N;
  vector<ll> A(N, 0);
  vector<ll> B(N + 1, 0);
  for (ll i = 0; i < N; i++) {
    cin >> A.at(i);
    B.at(i + 1) = B.at(i) + A.at(i);
  }
  ll ans = 0;
  for (ll i = 0; i < N; i++) {
    ll sum = (B.at(N) - B.at(i + 1)) % mod;
    ans += A.at(i) * sum; 
    ans %= mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6364
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;
	if(a==1){
		a=14;
	}
	if(b==1){
		b=14;
	}
	if(a>b){
		cout << "Alice" << endl;
	}else if(a<b){
		cout << "Bob" << endl;
	}else{
		cout << "Draw" << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a = 1, b = 1, c = 2, i = 2;
    int n;
    scanf("%d", &n);
    while (i < n) {
        a = b;
        b = c;
        c = a + b;
        i++;
    }
    if (n<2){
        printf("1\n");
    }else{
        printf("%d\n", c);
    }
    return 0;
}



Measured memory_bytes: 2732
#include <iostream>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>


#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;

using namespace std;

ll modd = 1000 * 1000 * 1000 + 7;

class UnionFind {
    public:
      vector<int> parent;
      vector<int> size;
//      size[i] = number of nodes in tree rooted at i
// Note: not necessarily correct if i is not a root node
      set<int> roots;

    UnionFind(int n) : parent(n), size(n) {
        forr(i,0,n) { roots.insert(i); }
        forr(i,0,n) {
            parent[i] = i; size[i] = 1;
        }
    } 

    int Find(int p) {
        int root = p;
        while (root != parent[root]) {  root = parent[root]; }
        while (p != root) {
            int newp = parent[p];
            parent[p] = root;
            p = newp;
        }
        return root;
    }

    void Union(int p, int q) {
        int rootP = Find(p);
        int rootQ = Find(q);
        if (rootP == rootQ) return;

        if (size[rootP] < size[rootQ]) {
            parent[rootP] = rootQ;
            size[rootQ] += size[rootP];
            roots.erase(rootP);
        }
        else {
            parent[rootQ] = rootP;
            size[rootP] += size[rootQ];
            roots.erase(rootQ);
        }
    }

};



int main()   {

      ios_base::sync_with_stdio(false);

      cout.precision(17);
      mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
      uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n); readint(m);
        UnionFind uf(n);
        forr(i,0,m) {
            readint(aa); readint(bb);
            uf.Union(aa-1,bb-1);
        }
        cout << uf.roots.size()-1 << endl;
    }
    return 0;
}


Measured memory_bytes: 8780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ll n;cin>>n;
    ll sqrt=pow(n,0.5);
    ll ans=100000000000;
    for(int i=1;i<sqrt+1;i++){
        if(n%i==0){
            int d=max(log10(i)+1,log10(n/i)+1);
            ans=min(ans,(ll)d);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000007;
constexpr int INF = 2000000000;
using namespace std;

bool dp[30][3000];
int n;
vector<int> N;

bool solve(int i, int m) {
	if (dp[i][m]!=0) return dp[i][m];

	if (m == 0) dp[i][m] = true;
	else if (i >= n)dp[i][m] = false;
	else if (solve(i + 1, m))dp[i][m] = true;
	else if (solve(i + 1, m - N[i]))dp[i][m] = true;
	else dp[i][m] = false;

	return dp[i][m];
}

int main() {
	cin >> n;
	int a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		N.emplace_back(a);
	}
	for (int i = 0; i < 30; i++) {
		for (int j = 0; j < 3000; j++) {
			dp[i][j] = false;
		}
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> a;
		cout << (solve(0, a) ? "yes" : "no") << endl;
	}
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define eb emplace_back
#define precision(n) cout << fixed << setprecision(n);
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{
    fast;
    long long  int x;
    cin>>x;
  long long  int a=100;
  int ans=0;
    while(a<x)
    {
        a+=a/100;
        ans++;
    }
   cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename key>
using ordered_set = tree<key, null_type, less<key>, rb_tree_tag, tree_order_statistics_node_update>;
#define F first
#define S second
#define T second.first
#define C second.second
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
#define all(v) v.begin(),v.end()
#define OO 0x3f3f3f3fLL
#define INF 0x3f3f3f3f3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef pair<ll,pair<ll,ll>> piii;
const int N = 2e5+5, M= 20, mod = 1000000000;
const double EPS = 1e-10;

int main(){
    FIO
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ll k;
    cin>>k;
    ll prev = 0;
    bool f = 0;
    for(int i=0; i<k+k; i++){
        ll cur = ((prev*10LL)%k) +7LL;
        cur%=k;
        if(cur == 0){
            cout<<i+1;
            f = 1;
            break;
        }
        prev = cur;
    }
    if(f == 0)RT(-1);
}


Measured memory_bytes: 3652
import bisect
A,B,Q=map(int,input().split())
INF=10**12
S=[-INF]
for i in range(A):
  S.append(int(input()))
S.append(INF)
T=[-INF]
for i in range(B):
  T.append(int(input()))
T.append(INF)
for i in range(Q):
  x=int(input())
  sl=[S[bisect.bisect_left(S,x)],S[bisect.bisect_left(S,x)-1]]
  tl=[T[bisect.bisect_left(T,x)],T[bisect.bisect_left(T,x)-1]]
  ans=[]
  for s in sl:
    for t in tl:
      ans.append(abs(x-s)+abs(s-t))
      ans.append(abs(x-t)+abs(t-s))
  print(min(ans))

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

typedef long long ll;
#define PI 3.1415926535897932384626433
#define mod 1000000007

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

int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(){
    int n, d;
    cin >> n >> d;
    int x[n][d];
    for (int i = 0; i < n; i++){
        for (int j = 0; j < d; j++){
            cin >> x[i][j];
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            double sq = 0;
            if (i != j && i < j){
                for (int k = 0; k < d; k++){
                    sq += pow(abs(x[i][k] - x[j][k]), 2);
                }
                sq = sqrt(sq);
                if (ceil(sq) == floor(sq)){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

	int  A, B, C, D, E, F;

	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%d", &C);
	scanf("%d", &D);

	E = A + B;
	F = C + D;

	if (E > F) {
		printf("Left");
	}
	if (F > E) {
		printf("Right");
	}
	if (E == F) {
		printf("Balanced");
	}

	return 0;
}

Measured memory_bytes: 128
//ABC111-A
#include <stdio.h>

int main(){
	int s[3], i;
	for(i = 0; i < 3; i++){
		scanf("%1d", &s[i]);
	}
	for(i = 0; i < 3; i++){
		if(s[i] == 1){
			printf("%d", 9);
		}
		else if(s[i] == 9){
			printf("%d", 1);
		}
		else{
			printf("%d", s[i]);
		}
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 128
N=int(input())
A=list(map(int,input().split()))
C=[0]*(N+1)

ans1=0
s=0

for A_i in A:
    C[A_i]+=1

for j in range(1,N+1):
    c=C[j]
    if c>1:
        s=c*(c-1)/2
        ans1=ans1+s
        
for A_k in A:
    d=C[A_k]
    if d<2:
        ans=ans1
    else:
        ans=ans1-(d-1)
    print(int(ans))

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

long long MOD = 998244353;
const int MAX = 510000;

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 p(long long m, long long x) {
  if (x == 0) {
    return 1;
  }
  if (x == 1) {
    return m;
  }
  if (x % 2 == 0) {
    long long tmp = p(m, x / 2);
    long long tmp2 = tmp * tmp;
    return tmp2 % MOD;
  } else {
    long long tmp = p(m, (x - 1)/ 2);
    long long tmp2 = (tmp * tmp) % MOD;
    return (tmp2 * m) % MOD;
  }
}
int main() {
  long long n, m, k;
  cin>>n>>m>>k;
  long long ans = 0;
  COMinit();
  for (int i=0; i<=k; i++) {
    long long x = n - i;
    long long tmp = p(m - 1, x - 1);
    long long tmp2 = COM(n - 1, x - 1);
    tmp = (tmp * m) % MOD;
    tmp = (tmp * tmp2) % MOD;
    ans += tmp;
    ans %= MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 15592
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
    int x,y;
    cin>>x>>y;
    int a,b,c;
    a=x+y;
    b=x*y;
    c=x-y;
    int maxx;
    maxx=max(a,max(b,c));
    cout<<maxx<<endl;
    return 0;
}

Measured memory_bytes: 256
/*    特徴    */

/*    教訓    */

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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


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



// --------- library end - //


int main(){

  ll N = il();
  ll sum = 0;
  vector<ll> buckets(100001, 0);
  rep(i, N){
    ll a = il();
    buckets[a]++;
    sum += a;
  }
  ll Q = il();


  rep(i, Q){
    ll b = il();
    ll idou = buckets[b];
    ll c = il();
    sum -= idou * b;
    sum += idou * c;
    buckets[b] = 0;
    buckets[c] += idou;
    cout << sum << endl;
  }



  
}

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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> Pll;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;cin>>N;
  cout<<"ABC"<<N<<endl;
  return 0;
}


Measured memory_bytes: 256
def solve():
    N = int(raw_input())
    cards = map(int, raw_input().split())

    points = [0, 0]
    for i in xrange(N):
        max_point = max(cards)
        points[i % 2] += max_point
        cards.remove(max_point)

    print points[0] - points[1]

if __name__ == "__main__":
    solve()


Measured memory_bytes: 2568
#include<iostream>
#include<stdio.h>
using namespace std;

const int NUM = 25;

int main() {
	int wf[NUM][NUM];
	
	for ( int i = 0; i < NUM; i++ ) {
		for ( int j = 0; j < NUM; j++ ) {
			if ( i == j ) {
				wf[i][j] = 0;
			} else {
				wf[i][j] = 100000;
			}
		}
	}
	
	int n,m;
	cin >> n >> m;
	for ( int i = 0; i < m; i++ ) {
		int a,b,c,d;
		scanf ( "%d,%d,%d,%d",&a,&b,&c,&d );
		a--;b--;
		wf[a][b] = c;
		wf[b][a] = d;
	}
	
	for ( int a = 0; a < n; a++ ) {
		for ( int b = 0; b < n; b++ ) {
			for ( int c = 0; c < n; c++ ) {
				wf[b][c] = min ( wf[b][c] , wf[b][a] + wf[a][c] );
			}
		}
	}
	int x1,x2,y1,y2;
	scanf ( "%d,%d,%d,%d",&x1,&x2,&y1,&y2 );
	x1--;x2--;
	int cost = wf[x1][x2] + wf[x2][x1];
	cout << y1 - ( y2 + cost ) << endl;
}

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

int ctoi(const char c) {
  if ('0' <= c && c <= '9') return (c - '0');
  return -1;
}

int main() {
  char c;
  int hundred = 0;
  int ten = 0;
  int one = 0;
  int residual = 1000;
  while (cin >> c) {
    hundred = ten;
    ten = one;
    one = ctoi(c);
    int num = hundred * 100 + ten * 10 + one;
    int restmp = abs(num - 753);
    if (restmp < residual) residual = restmp;
  }
  cout << residual << endl;
}

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

int main(){
    using namespace std;
    using tuplis = array<int, 3>;
    const int sq = 1200;
    
    int n, q;
    cin >> n >> q;
    vector<int> c(n);
    for(int& i : c){
        cin >> i;
        i--;
    }
    vector<tuplis> query(q);
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        l--;
        query[i] = {l, r, i};
    }
    sort(query.begin(), query.end(), [&](const tuplis& a, const tuplis& b){ if(a[0] / sq == b[0] / sq) return a[1] < b[1]; return a[0] < b[0]; });
    vector<int> ans(q);
    vector<int> cnt(n);
    int types = 0, L = 0, R = 0;
    for(auto [l, r, i] : query){
        while(L < l){
            cnt[c[L]]--;
            types -= !cnt[c[L]];
            L++;
        }
        while(L > l){
            L--;
            types += !cnt[c[L]];
            cnt[c[L]]++;
        }
        while(R > r){
            R--;
            cnt[c[R]]--;
            types -= !cnt[c[R]];
        }
        while(R < r){
            types += !cnt[c[R]];
            cnt[c[R]]++;
            R++;
        }
        ans[i] = types;
    }
    for(int i : ans) cout << i << ' ';
}

Measured memory_bytes: 15464
import java.util.Scanner;
	public class Main{
		public static void main(String args[]){
			Scanner sc = new Scanner(System.in);
			while(sc.hasNext()){
				double num = sc.nextDouble();
				double sum = num;
				for(int i = 0; i <9; i++){
					if(i%2==0){
						num = num *2;
					}else{
						num = num /3;
					}
					sum+=num;
				}
				
			System.out.println(sum);
			}
		}
	}
	

Measured memory_bytes: 28116
// -*- mode:c++; c-basic-offset:2 -*-
// Problem: Poor Turkeys
// Link: http://agc016.contest.atcoder.jp/tasks/agc016_e
//
//
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int main() {
  const uint64_t NMAX = 400;
  uint64_t N, M;
  cin >> N >> M;
  assert(N <= NMAX);

  vector<bitset<NMAX>> S(N);
  for (uint64_t i = 0; i < M; ++i) {
    uint64_t x, y;
    cin >> x >> y;
    --x; --y;

    for (uint64_t j = 0; j < N; ++j) {
      if (S[y][j]) {  // j in S[y]
        S[j].set(x);
      }
      if (S[x][j]) {  // j in S[x]
        S[j].set(y);
      }
    }

    bitset<NMAX> Ox(S[x]);
    bitset<NMAX> Oy(S[y]);
    for (uint64_t j = 0; j < N; ++j) {
      if (Ox[j]) {
        S[y].set(j);
      }
      if (Oy[j]) {
        S[x].set(j);
      }
    }
    S[x].set(y);
    S[y].set(x);
  }

  uint64_t ret = 0;
  for (uint64_t i = 0; i < N; ++i) {
    if (S[i][i]) {
      for (uint64_t j = 0; j < N; ++j) {
        S[j].set(i);
      }
    }
  }
  for (uint64_t i = 0; i < N; ++i) {
    if (S[i][i]) {
      continue;
    }
    ret += N - S[i].count() - 1;
  }
  assert(ret % 2 == 0);
  cout << ret / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
N, T = map(int, input().split())
ls = []
for i in range(N):
  a, b = map(int, input().split())
  ls += [(a,b)]
ls.sort(key=lambda x:x[0])
t = [[0]*T for i in range(N+1)]
for i in range(1,N+1):
  a, b = ls[i-1]
  for j in range(T):
    if j-a>=0:
      t[i][j] = max(t[i-1][j-a]+b,t[i-1][j])
last = [0]
for i in range(N-1,-1,-1):
  last += [max(last[-1], ls[i][-1])]
ans = 0
for i in range(1,N+1):
  j = N-i
  ans = max(ans, last[j]+t[i][-1])
print(ans)

Measured memory_bytes: 116440
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1 << 30;
const ll MOD = 1000000007;
long long A, B, N;
int main(void) {
  cin >> A >> B >> N;

  vector<int> keep;
  int zeroCount = 0;
  long long m = min(N, B - 1);
  int max = floor((A * m) / B) - A * floor(m / B);
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Read();
            if (S.Length == 3)
            {
                for (int i = 2; i >= 0; i--)
                {
                    Console.Write(S[i]);
                }
            }else
            {
                Console.WriteLine(S);
            }

            Console.WriteLine();
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13140
#include <cstdio>
#include <algorithm>

using namespace std;


int main() {
    int n;
    scanf("%d", &n);

    int cnt = 0;
    for(int x = 3; x <= n; x += 2) {
        int dc = 0;
        for(int d = 1; d <= x; d++) if(x % d == 0) dc++;
        if(dc == 8) cnt++;
    }

    printf("%d\n", cnt);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;

class A
{
	static void Main()
	{
		var es = Console.ReadLine().Split();
		var s = new Stack<int>();

		foreach (var e in es)
		{
			switch (e)
			{
				case "+":
					s.Push(s.Pop() + s.Pop());
					break;
				case "-":
					s.Push(-s.Pop() + s.Pop());
					break;
				case "*":
					s.Push(s.Pop() * s.Pop());
					break;
				default:
					s.Push(int.Parse(e));
					break;
			}
		}
		Console.WriteLine(s.Pop());
	}
}



Measured memory_bytes: 18424
#include<stdio.h>
int main(){
  int i;
  int w,h;
  char s[w];
  scanf("%d %d",&w,&h);
  for(int i=0;i<w;i++){
    scanf("%s",s);
    printf("%s\n%s\n",s,s);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n);i++)
#define rep1(i,n) for(int i=1; i<(n); i++)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;
const int mod = 1e9+7;

int h, w, n;
string S, T;
int sh, sw;

bool solve(char x, char y, int sz, int st){
    int l = 0, r = sz+1;
    rep(i, n){
        if(T[i] == x) r = min(sz+1, r+1);
        if(T[i] == y) l = max(0, l-1);
        //cout << l << " " << r << endl;
        if(S[i] == x) l++;
        if(S[i] == y) r--;
        //cout << l << " " << r << endl;
        if(r <= l+1) return false;
    }
    if(l >= st || r <= st) return false;
    return true;
}

int main(){
    cin >> h >> w >> n;
    cin >> sh >> sw;
    cin >> S >> T;
    reverse(all(S));
    reverse(all(T));
    cout << (solve('L', 'R', w, sw)&&solve('U', 'D', h, sh) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 776
#include <iostream>

int main(void){
  int n, k, x, disp = 0, i;
  std::cin >> n >> k;
  for(i = 0; i < n; i++){
    std::cin >> x;
    disp += (x < k-x) ? x*2 : (k-x)*2;
  }
  std::cout << disp << std::endl;
  return 0;
}

Measured memory_bytes: 3596
use std::io;
//use std::collections::HashMap;
//use std::collections::BinaryHeap;
use std::collections::HashSet;
//use std::mem;
//use std::cmp;


fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

fn read_int() -> i64{
    read_ints()[0]
}

//////////////////////////////////////////////////////////////////////

fn reverse(s: &String) -> String{
    s.chars().rev().collect::<String>()
}

fn solve(){
    let mut myset = HashSet::new();
    let s = read_line();

    for i in 1..s.len(){
        let first = s[0..i].to_string();
        let rfirst = reverse(&first);
        let rest  = s[i..s.len()].to_string();
        let rrest = reverse(&rest);
        
        myset.insert(format!("{}{}",rest,first));
        myset.insert(format!("{}{}",rest,rfirst));
        myset.insert(format!("{}{}",rrest,first));
        myset.insert(format!("{}{}",rrest,rfirst));
        
        myset.insert(format!("{}{}",first,rest));
        myset.insert(format!("{}{}",first,rrest));
        myset.insert(format!("{}{}",rfirst,rest));
        myset.insert(format!("{}{}",rfirst,rrest));
    }
    
    println!("{}",myset.len());

}

fn main(){
    let n = read_int();
    for _i in 0..n{
        solve();
    }
}



/*
DOCS


let mut h = HashMap::new();
let a = 5;
h.insert(a,true);
match h.get(&a){
    Some(v) => println!("{}",v),
    None    => println!("none"),
}


use std::mem;

let mut x = 5;
let mut y = 1;
mem::swap(&mut x,&mut y);


let v = vec![0;2]; // [0,0]

s.chars().nth(i as usize).unwrap();


// priority queue
// https://doc.rust-lang.org/std/collections/struct.BinaryHeap.html
use std::collections::BinaryHeap;
let mut heap = BinaryHeap::new();

heap.push(1);
heap.push(5);
heap.push(2);

assert_eq!(heap.pop(), Some(5));
assert_eq!(heap.pop(), Some(2));
assert_eq!(heap.pop(), Some(1));
assert_eq!(heap.pop(), None);


let mut vs = heap.into_vec();
vs.reverse();



*/



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

int main() {
    int K, X; cin >> K >> X;
    int now = X-K+1;
    while(now <= X+K-1){
        cout << now << endl;
        now++;
    }

    return 0;
}

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

int main() {

    int a, b, k;
    scanf("%d %d %d", &a, &b, &k);

    int cnt = 0;
    int mindata;
    if (a >= b) {
        mindata = b;
    } else {
        mindata = a;
    }

    while (mindata >= 1) {
        
        if (a % mindata == 0 && b % mindata == 0) {
            cnt += 1;
        }

        if (cnt == k) {
            printf("%d", mindata);
            break;
        }
        mindata--;

    }


    return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
long long modpow(long long m, long long n, long long modvalue) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2, modvalue);
        return t * t % modvalue;
    } else {
        return modpow(m, n - 1, modvalue) * m % modvalue;
    }
}
bool bitcheck(ll x, ll y) { return (x >> y) & 1; }

template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;

long long moddiv(long long a, long long b, ll modvalue) { return (a * modpow(b, mod - 2, modvalue)) % modvalue; }

const ll INF = 1LL << 60;

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

ll nCkmod(ll n, ll k, ll modvalue) {
    ll numera = 1;
    for (int i = n; i > n - k; i--) {
        numera *= i;
        numera %= modvalue;
    }
    ll denomi = 1;
    REP(i, k) {
        denomi *= (i + 1);
        denomi %= modvalue;
    }
    return moddiv(numera, denomi, modvalue);
}
map<ll, ll> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}
int main() {
    ll n;
    cin >> n;
    vector<ll> v1(n / 2);
    vector<ll> v2(n / 2);
    vector<P> cnt1(100006);
    vector<P> cnt2(100006);
    REP(i, n) {
        if (i % 2 == 0) {
            cin >> v1[i / 2];
            cnt1[v1[i / 2]].second = v1[i / 2];
            cnt1[v1[i / 2]].first++;
        }
        if (i % 2 == 1) {
            cin >> v2[i / 2];
            cnt2[v2[i / 2]].second = v2[i / 2];
            cnt2[v2[i / 2]].first++;
        }
    }
    sort(cnt1.rbegin(), cnt1.rend());
    sort(cnt2.rbegin(), cnt2.rend());
    if (cnt1[0].second != cnt2[0].second) {
        cout << n - cnt1[0].first - cnt2[0].first << endl;
    } else {
        cout << min(n - cnt1[0].first - cnt2[1].first, n - cnt2[0].first - cnt1[1].first) << endl;
    }
}

Measured memory_bytes: 7132