akhauriyash/Code-Regression huggingface dataset:
/*
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<int> vl;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()                                                              
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) {cout<<n<<"\n" ; return ;}
#define po(n) cout << n <<"\n " 
#define pff(n) cout << n << " " ; 
#define ar array
#define endl "\n" 
#define PI acos(-1) 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
//#ifndef ONLINE_JUDGE
//#ifndef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
//#else
//#define debug(x...)
//#endif
#define int ll 
template<class T> using oset =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update> ;
long const M=1e9+7;
const long mxN =1e5+2 ;
const ll INF =1e18;
void solve(){ 
  int n ;cin >> n ;
  int ans =0 ;
  for(int m =1;m*m<=n;m++){
    ans+=(m*(m+n/m))*(n/m+1-m) ;
  }
  int x = sqrt(n) ;
  
  cout << ans - ((x*(2*x+1))*(x+1))/6;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //cout << setprecision(20) << fixed ;
  solve() ;
  // ll t /; cin >> t ; while(t--)solve() ;
	return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  char a[2][3];
  for(int i=0;i<2;i++){
    for(int j=0;j<3;j++){
      cin>>a[i][j];
    }
  }
  bool flag=true;
  for(int i=-1;i<2;i++){
    if(a[0][i+1]!=a[1][1-i]){
      flag=false;
    }
  }
  if(flag)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_map>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	string s;
	cin >> s;
	if (s[2] == s[3] and s[4] == s[5])cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mxn=2e5+5;

int main() {
	ll n;
	cin>>n;
	ll arr[1000],i=0;
	while(n) {
		arr[i]= n%26;
		n/=26;
		i++;
	}

	for (ll j = 0; j < i - 1; j++) { 
        if (arr[j] <= 0) { 
            arr[j] += 26; 
            arr[j + 1] = arr[j + 1] - 1; 
        } 
    } 
  
    for (ll j = i; j >= 0; j--) { 
        if (arr[j] > 0) 
            cout << char('a' + arr[j] - 1); 
    } 
	return 0;
}

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

using namespace std;

int main()
{
	string S, T;
	int A, B;
	string U;
	cin >> S >> T >> A >> B >> U;
	if (U == S)
		cout << max(A - 1,0) << " " << B << "\n";
	else if ( U == T)
		cout << A << " " << max(B-1, 0) << "\n";
	else
		cout << A << " " << B << "\n";

	return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
int main(){
  long int dp[101][301][101];
  long int n,w,w1,w2,v,i,j,k;
  scanf("%ld%ld%ld%ld",&n,&w,&w1,&v);
  for(i=0;i<=n;i++)for(j=0;j<=n*3;j++)for(k=0;k<=n;k++)dp[i][j][k]=-1;
  dp[1][0][1]=v;dp[1][0][0]=0;
  for(i=2;i<=n;i++){
    scanf("%ld%ld",&w2,&v);
    for(j=0;j<=i*3;j++)for(k=0;k<=i;k++){
      dp[i][j][k]=dp[i-1][j][k];
      if(j>=w2-w1&&k&&dp[i-1][j-w2+w1][k-1]>=0)dp[i][j][k]=dp[i][j][k]<dp[i-1][j-w2+w1][k-1]+v?dp[i-1][j-w2+w1][k-1]+v:dp[i][j][k];
    }
  }
  k=0;for(i=0;i<=n*3;i++)for(j=0;j<=n;j++)if(j*w1+i<=w)k=k<dp[n][i][j]?dp[n][i][j]:k;
  printf("%ld",k);
}


Measured memory_bytes: 24192
def isCLKWISE(ph):
    return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            if isCLKWISE(phU) : break
            else :
                del phU[-2]
                if len(phU) == 2 : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            if isCLKWISE(phL) : break
            else :
                del phL[-2]
                if len(phL) == 2 : break
    ph = phU + phL[1:-1]
    return ph
  
n = range(int(input()))
P = []
for i in n:
    P.append([int(x) for x in input().split()])
      
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R : print(r[0],r[1])

Measured memory_bytes: 33828
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  string ans = "CODEFESTIVAL2016";
  string s;
  cin >> s;
  int res = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] != ans[i])res++;
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int n,F[45],i;

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




Measured memory_bytes: 2132
a,b = map(int,input().split())
s = input()
flag = True
for i in range(a+b+1):
    if i == a:
        if s[i] != "-":
            flag = False
            break
    else:
        if not (s[i] in list(map(str,range(10))) ):
            flag = False
            break
if flag:
    print("Yes")
else:
    print("No")


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

int main() {
  int n;
  cin >> n;
  vector<string> w(n);
  for (int i = 0; i < n; i++)
    cin >> w[i];

  map<string, int> m;
  bool res  = true;
  char last = w[0][0];
  for (int i = 0; i < n; i++) {
    if (last == w[i][0]) {
      if (m[w[i]] != 0) {
        res = false;
        break;
      } else {
        m[w[i]]++;
      }
    } else {
      res = false;
      break;
    }
    last = w[i][w[i].size() - 1];
  }
  if (res) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <functional>
#include <queue>
#include <regex>
#include <cassert>
#include <map>
// #include "bits/stdc++.h"

using namespace std;
//debug

#define rep(i, N, M) for (ll i = N; i < M; ++i)
#define rrep(i, N, M) for (ll i = N; i < M; --i)
#define pb push_back


typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef priority_queue<ll> pqll;
typedef priority_queue<pll, vector<pll>> pqpll;
typedef priority_queue<ll, vll, greater<ll>> pqll_greater;
typedef priority_queue<pll, vector<pll>, greater<pll>> pqpll_greater;


#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define vec(a) vector<a>
#define _CRT_SECURE_NO_WARNINGS

template<class T, class S>
T atbit(T n, S i) {
	return (n >> i) % i;
}

template<class T>
T getbit(T i) {
	return 1LL << i;
}

//#define TRANSFORM(v,w,func) decltype(v) w ; transform((v).begin(),(v).end(),back_inserter(w),func);

using namespace std;


int main() {
	ll MAX_NODE;
	ll L;
	cin >> L;
	vvll res(3);
	vll ind;
	rep(i, 0, 22) {
		if ((L >> i) % 2!= 0) {
			ind.push_back(i);
		}
	}
	MAX_NODE = ind.back()+1;
	rep(i, 0, ind.back()) {
		res[0].push_back(i);
		res[1].push_back(i + 1);
		res[2].push_back(1 << i);


		res[0].push_back(i);
		res[1].push_back(i + 1);
		res[2].push_back(0);
	}
	rep(i, 0, ind.size()-1) {
		res[0].push_back(ind[i]);
		res[1].push_back(MAX_NODE-1);
		res[2].push_back((L >> (ind[i] + 1)) << (ind[i] + 1));

	}
	cout << MAX_NODE << " " << res[0].size() << endl;
	rep(i, 0, res[0].size()) {
		cout << res[0][i]+1 << " " << res[1][i]+1 << " " << res[2][i] << endl;
	}
}
//ll N;
//cin >> N;
//vll a(N);
//rep(i,0, N) cin >> a[i];

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int boot[1005];
int main ()
{

        int K;
        boot[111] = boot[222] = boot[333] = boot[444] = boot[555] = boot[666] = boot[777] = boot[888] = boot[999] = 1;
        cin>>K;
        for(int i=K;i<=999;i++)
        {
                if(boot[i])
                {
                        cout<<i<<endl;
                        break;
                }
        }
}


Measured memory_bytes: 256
// AOJ 0620
#include<cstdio>
#include<utility>
#define rep(i,a) for(int i=0;i<(a);++i)

int N, M;
int A[1000];

int main()
{
  scanf( "%d%d", &N, &M );
  rep( i, N )
    scanf( "%d", A+i );

  rep( k, M )
  {
    rep( i, N-1 ) if( A[i]%(k+1) > A[i+1]%(k+1) )
      std::swap( A[i], A[i+1] );
  }

  rep( i, N )
    printf( "%d\n", A[i] );
  
  return 0;
}

Measured memory_bytes: 2648
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<ll,ll> P;
//#include <boost/multiprecision/cpp_int.hpp>
//using bint = boost::multiprecision::cpp_int;



int main(){
    int n;
    map<int,int> seen;
    cin >> n;
    
    rep(i,n){
        int a;
        cin >> a;
        if (seen[a]){cout <<"NO"; rn 0;}
        seen[a] = 1;
    }
    cout << "YES";
    rn 0;
}


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

int main() {
        int n;
        scanf("%d", &n);
        vector<vector<vector<long long>>> cur(5, vector<vector<long long>> (5, vector<long long> (5)));
        const int mod = 1e9 + 7;
        /*
        rep(x, 4) rep(y, 4) rep(z, 4) {
                if (x == 2 && y == 1 && z == 0) continue;
                if (x == 2 && y == 0 && z == 1) continue;
                if (x == 1 && y == 2 && z == 0) continue;
                cur[x][y][z] = 1;
        }
        */
        cur[4][4][4] = 1;
        rep(i, n) {
                vector<vector<vector<long long>>> next(5, vector<vector<long long>> (5, vector<long long> (5)));
                rep(z, 5) rep(y, 5) rep(x, 5) rep(w, 4) {
                        if (w == 2 && x == 1 && y == 0) continue;
                        if (w == 2 && x == 0 && y == 1) continue;
                        if (w == 1 && x == 2 && y == 0) continue;
                        if (w == 2 && x == 1 && z == 0) continue;
                        if (w == 2 && y == 1 && z == 0) continue;
                        (next[w][x][y] += cur[x][y][z]) %= mod;
                }
                cur.swap(next);
        }
        long long ans = 0;
        rep(x, 5) rep(y, 5) rep(z, 5) (ans += cur[x][y][z]) %= mod;
        printf("%lld\n", ans);
        return 0;
}


Measured memory_bytes: 256
int main(){
    int sum[101] = {0}, r, c, i, j, k, a[101][101] = {0};
    scanf("%d%d", &r, &c);
     
    for (i = 0; i < r; i++){
        for (j = 0; j < c; j++){
            scanf("%d", &a[i][j]);
        }
    }
     
    for (i = 0; i <= r; i++){
        for (j = 0; j <= c; j++){
            if (i != r){
                if (j != c){
                    a[i][c] += a[i][j];
                    printf("%d ", a[i][j]);
                }
                else{
                    printf("%d", a[i][c]);
                }
            }
            else{
                for(k = 0; k < r; k++){
                    sum[j] += a[k][j];
                }
                printf((j != c)? "%d " : "%d", sum[j]);
            }
        }
        printf("\n");
    }
    return 0;
}

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

const ll mod = 1e9 + 7;

ll dp[1010];



int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;
    cin >> n;
    
    
    
    rep(i,1010) dp[i] = 1;
    
    for(int i = 2; i <= n; i++){
        int m = i;
        int a = 2;
        while(m >= a * a){
            if(m % a == 0){
                dp[a]++;
                m /= a;
            } else{
                a++;
            }
        }
        dp[m]++;
    }
    
    ll sum = 1;
    for(int i = 0; i < 1010; i++){
        sum = sum % mod * dp[i];
    }
    cout << sum << endl;
}


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

void dfs(const Graph &G, vector<bool> &seen, int v) {
    seen[v] = true;
    for (auto nv : G[v]) if (!seen[nv]) dfs(G, seen, nv);
}

int main() {
    int N, M;
    cin >> N >> M;
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        G[a].push_back(b), G[b].push_back(a);
    }
    int res = 0;
    vector<bool> seen(N, false);
    for (int v = 0; v < N; ++v) {
        if (seen[v]) continue;
        else{
          dfs(G, seen, v);
          ++res;
        }
    }
    cout << res - 1 << endl;
}

Measured memory_bytes: 9512
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef array<ll,2> pll;
const ll NMAX=3005;
ll dp[NMAX][NMAX];
int main()
{
    string a,b;
    cin>>a>>b;
    for(ll i=0;i<a.size();i++){
        for(ll j=0;j<b.size();j++){
            ll cnd=max(dp[i][j+1],dp[i+1][j]);
            if(a[i]==b[j]) cnd=max(cnd,dp[i][j]+1);
            dp[i+1][j+1]=cnd;
        }
    }
    ll x=a.size(),y=b.size();
    string ans;
    while(x>0 && y>0){
        if(a[x-1]==b[y-1]){
            ans.push_back(a[x-1]);
            x--; y--;
        }
        else if(dp[x-1][y]>dp[x][y-1])
            x--;
        else y--;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
    return 0;
}


Measured memory_bytes: 74044
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

int main() {
	int N, A[100005];
	cin >> N;
	REP(i, N) {
		cin >> A[i];
	}

	int Count[100005];
	REP(i, 100005) Count[i] = 0;
	REP(i, N) {
		Count[A[i]]++;
	}

	int ne = 0;
	int cnt = 0;
	REP(i, 100005) {
		if (Count[i] == 0) continue;
		else if (Count[i] % 2 == 0) ne++;

		cnt++;
	}


	cout << cnt - ne % 2 << endl;

	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
class Main{
    public static void main(String[] args){
		int n,m;
		int[][] a=new int[101][101];
		int[] b=new int[101];
		int[] c=new int[101];
		for(int i=0;i<100;i++)c[i]=0;
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		m=sc.nextInt();
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				a[i][j]=sc.nextInt();
			}
		}
		for(int j=1;j<=m;j++){
			b[j]=sc.nextInt();
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				c[i]+=(a[i][j]*b[j]);
			}
		}
		for(int i=1;i<=n;i++){
			System.out.println(c[i]);
		}
    }
}



Measured memory_bytes: 41088
#include <iostream>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int, int> P;
 
const int INF = 100000000;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
int main(){
    int h, w;
    cin >> h >> w;
    char c[51][51];
    int les[51][51];
    int black = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> c[i][j];
            if(c[i][j] == '#'){
                black++;
            }
            les[i][j] = INF;
        }
    }
    queue<P> que;
    les[0][0] = 1;
    que.push(P(0, 0));
    while(que.size()){
        P p = que.front();
        que.pop();
        int x = p.first;
        int y = p.second;
        for(int i = 0; i < 4; i++){
            if(0 <= x + dx[i] && x + dx[i] < h && 0 <= y + dy[i] && y + dy[i] < w && 
               c[x + dx[i]][y + dy[i]] == '.' && les[x + dx[i]][y + dy[i]] == INF){
                les[x + dx[i]][y + dy[i]] = les[x][y] + 1;
                que.push(P(x + dx[i], y + dy[i]));
            }
        }
    }
    int l = les[h - 1][w - 1];
    if(l == INF){
        cout << -1 << endl;
    }
    else{
        cout << h * w - l - black << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 1000000;

void prime_factor(int n)
{
	for(int i=2;i*i<=n;i++){
		while(n%i == 0){
			printf(" %d",i);
			n /= i;
		}
	}
	if(n != 1){
		printf(" %d",n);
	}
	return;
}

int main()
{
	int n;
	scanf("%d",&n);
	printf("%d:",n);
	prime_factor(n);
	printf("\n");
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	
	if(n==4){
		cout << max({a[0],a[1],a[2],a[3]}) - min({a[0],a[1],a[2],a[3]}) << endl;
		return 0;
	}
	
	vector<ll> sum(n);
	sum[0] = a[0];
	rep(i,n-1) sum[i+1] = sum[i] + a[i+1];
	
	ll P,Q,R,S;
	int l=0,mid=1,r=2;
	
	ll res = 1e18;
	
	while(mid < n-2){
		
		while(l < mid-1){
			ll prev = abs(sum[mid]-2*sum[l]);
			ll next = abs(sum[mid]-2*sum[l+1]);
			if(prev > next) l++;
			else break;
		}
		
		while(r < n-2){
			ll prev = abs(sum[n-1]-2*sum[r]+sum[mid]);
			ll next = abs(sum[n-1]-2*sum[r+1]+sum[mid]);
			if(prev > next) r++;
			else break;
		}

		P = sum[l];
		Q = sum[mid] - sum[l];
		R = sum[r] - sum[mid];
		S = sum[n-1] - sum[r];
		
		res = min(res, max({P,Q,R,S}) - min({P,Q,R,S}));
		mid++;
	}
	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 1000000000
#define mod 1000000007
#define INF2 1000000000000000000

int dp[41][1020][1020];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int Ma, Mb;
    cin >> Ma >> Mb;
    int a[41], b[41], c[41];
    rep(i, N) cin >> a[i] >> b[i] >> c[i];
    rep(i, 41) rep(j, 1010) rep(k, 1010) dp[i][j][k] = INF;
    dp[0][0][0] = 0;
    rep(i, N) {
        rep(j, 1010) {
            rep(k, 1010) {
                dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]); 
                if (j + a[i] <= 1000 && k + b[i] <= 1000){
                    dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j + a[i]][k + b[i]]);
                    dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]] , dp[i][j][k] + c[i]); 
                }
            }
        }
    }
    int ans = INF;
    // rep(i, 10) {
    //     rep(j, 10) {
    //         if (dp[N][i][j] != INF)
    //             cout << dp[N][i][j] << " ";
    //         else 
    //             cout << "- ";
    //     }
    //     cout << endl;
    // }
    rep(i, 1001) {
        rep(j, 1001) {
            if (i > 0 && j > 0 && dp[N][i][j] < INF && i * Mb == j * Ma) {
                ans = min(ans, dp[N][i][j]);
            } 
        }
    }
    if (ans >= INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 166784
//Volume5-0502
import java.util.*;

class Main {
	
	private static int[] dice;
	private static int   sum;
	
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int n;
		String s;
		while((n=sc.nextInt())!=0){
			init();
			while(n-- > 0){
				s=sc.next();
				if     (s.equals("North")){north() ;}
				if     (s.equals("South")){south() ;}
				else if(s.equals("East")) {east()  ;}
				else if(s.equals("West")) {west()  ;}
				else if(s.equals("Right")){right() ;}
				else if(s.equals("Left")) {left()  ;}
				sum+=dice[2];
			}
			System.out.println(sum);
		}
	}
	
	private static void init(){
		dice    = new int[6];
		sum     = 1;
		dice[0] = 4;
		dice[1] = 5;
		dice[2] = 1;
		dice[3] = 2;
		dice[4] = 6;
		dice[5] = 3;
	}
	
	private static void north(){
		for(int i=1;i<4;i++){
			swap(i,i+1);
		}
	}
	private static void south(){
		for(int i=3;i>0;i--){
			swap(i,i+1);
		}
	}

	private static void east(){
		swap(2,5);swap(2,4);swap(0,2);
	}

	private static void west(){
		swap(0,2);swap(2,4);swap(2,5);
	}

	private static void right(){
		swap(0,1);swap(0,3);swap(3,5);
	}
	
	private static void left(){
		swap(3,5);swap(0,3);swap(0,1);
	}
	
	private static void swap(int i,int j){
		dice[j]  = dice[i] - dice[j];
		dice[i] -= dice[j];
		dice[j] += dice[i];
	}
}

Measured memory_bytes: 25592
n=int(input())
l=list(map(int,input().split()))
l.sort()
lmax=l[-1]
mini=abs(2*l[0]-lmax)
tmp=0
for i in range(1,n-1):
  if mini>abs(2*l[i]-lmax):
    tmp=i
    mini=abs(2*l[i]-lmax)
print(lmax,l[tmp])

Measured memory_bytes: 14060
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;


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

  vector<pair<string,pair<ll,ll>>>r(n);
  rep(i,n){
    cin>>r[i].first;
    ll a;cin>>a;
    r[i].second.first=-a;
    r[i].second.second=i+1;
  }
  sort(all(r));
  rep(i,n){
    cout<<r[i].second.second<<endl;
  }

  return 0;

}


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

#define INF (1e9)
#define LLINF (1e18)
#define long long

#define MAX_V 3000

using namespace std;

typedef struct edge{
public:
	int to;
	double cost;
	edge(){}
	edge(int _to,double _cost){
		to = _to;
		cost = _cost;
	}
	bool operator<(const edge &a)const{
		if(cost == a.cost) return to > a.to;
		return cost > a.cost;	//for asc
	}
}edge;


double dist[MAX_V + 1];
vector<edge> G[MAX_V + 1];

priority_queue<edge> pque;

int shops[MAX_V + 1];

int V;
int E;
int K;


double ans;

double calc(double x,double y,double e){
	double a;
	a = (y - x + e) / 2;
	return a;
}

void solve(){
	for(int i = 0;i < MAX_V + 1;i++) dist[i] = INF;

	for(int i = 0;i < K;i++){
		pque.push(edge(shops[i],0));
	}

#ifndef EVAL
//	puts("###DBG1");
#endif

	while(!pque.empty()){
		edge e = pque.top(); pque.pop();
		if(dist[e.to] != INF) continue;
		dist[e.to] = e.cost;

		for(int i = 0;i < G[e.to].size();i++){
			int _to = G[e.to][i].to;
			double _cost = G[e.to][i].cost + e.cost;
			pque.push(edge(_to,_cost));
		}

	}

#ifndef EVAL
//	puts("###DBG2");
#endif

	ans = 0;
	for(int i = 1;i < V + 1;i++){
		for(int j = 0;j < G[i].size();j++){
			//printf("###%lf\n",dist[i] + calc(dist[i],dist[G[i][j].to],G[i][j].cost));
			ans = max(ans,dist[i] + calc(dist[i],dist[G[i][j].to],G[i][j].cost));
		}
	}


	return ;
}

int main(){

	scanf("%d%d%d",&V,&E,&K);
	int _u,_v;
	double _cost;
	for(int i = 0;i < E;i++){
		scanf("%d%d",&_u,&_v);
		scanf("%lf",&_cost);
		G[_u].push_back(edge(_v,_cost));
		G[_v].push_back(edge(_u,_cost));
	}
	for(int i = 0;i < K;i++){
		scanf("%d",shops + i);
	}

#ifndef EVAL
//	puts("###DBG");
#endif

	solve();
	//printf("***%lf\n",ans);
	printf("%d\n",(int)(ans + 0.5));

	return 0;
}

Measured memory_bytes: 12916
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        List<Long> list = new ArrayList<>();
        for(int i = 0; i < N; i++)
            list.add(new Long(in.nextLong()));

        long ans = 0;
        for(long v : list){
            while(v % 2 == 0){
                ans++;
                v /= 2;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 34016
import math
n = int(input())
a = [int(i) for i in input().split()]

a.sort()
b = [0 for _ in range(a[-1])]
c = 0
for i in a:
    x = i-1
    while len(b) > x:
        b[x] += 1
        x += i 
for i in a:
    if b[i-1] == 1:
        c += 1
print(c)

Measured memory_bytes: 32148
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <bitset>
#include <assert.h>

using namespace std;
typedef long long ll;
typedef set<int>::iterator ssii;

#define Cmp(a, b) memcmp(a, b, sizeof(b))
#define Cpy(a, b) memcpy(a, b, sizeof(b))
#define Set(a, v) memset(a, v, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define _forS(i, l, r) for(set<int>::iterator i = (l); i != (r); i++)
#define _rep(i, l, r) for(int i = (l); i <= (r); i++)
#define _for(i, l, r) for(int i = (l); i < (r); i++)
#define _forDown(i, l, r) for(int i = (l); i >= r; i--)
#define debug_(ch, i) printf(#ch"[%d]: %d\n", i, ch[i])
#define debug_m(mp, p) printf(#mp"[%d]: %d\n", p->first, p->second)
#define debugS(str) cout << "dbg: " << str << endl;
#define debugArr(arr, x, y) _for(i, 0, x) { _for(j, 0, y) printf("%c", arr[i][j]); printf("\n"); }
#define _forPlus(i, l, d, r) for(int i = (l); i + d < (r); i++)
#define lowbit(i) (i & (-i))
#define MPR(a, b) make_pair(a, b)

pair<int, int> crack(int n) {
    int st = sqrt(n);
    int fac = n / st;
    while (n % st) {
        st += 1;
        fac = n / st;
    }

    return make_pair(st, fac);
}

inline ll qpow(ll a, int n) {
    ll ans = 1;
    for(; n; n >>= 1) {
        if(n & 1) ans *= 1ll * a;
        a *= a;
    }
    return ans;
}

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

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

// ============================================================== //

const int maxn = 200000 + 10;
int a[maxn];
int N, K;

void solve() {
    _rep(i, K+1, N) {
        if(a[i] > a[i-K]) printf("Yes\n");
        else printf("No\n");
    }
}

void init() {
    //
}

int main() {
    //freopen("input.txt", "r", stdin);
    init();
    cin >> N >> K;

    _rep(i, 1, N) scanf("%d", &a[i]);
    solve();
}

Measured memory_bytes: 4500
import math 

repo = list(map(int, input().split()))

a_kane = repo[0]
b_kane = repo[1]
c_kane = repo[2]
a_maisu = repo[3]
b_maisu = repo[4]
kingaku = 0

test_kane_tantai = 0
test_kane_harf = 0

tantai_kane = a_kane + b_kane
harf_kane = c_kane*2

kaburi_maisu = abs(a_maisu-b_maisu)


if(tantai_kane<harf_kane): #A,Bでシンプルに買った方がいい
    kingaku = a_kane*a_maisu + b_kane*b_maisu
else: #Cで買った方がいい
    if(a_maisu>b_maisu):
        sabun_maisu = a_maisu-b_maisu
        kaburi_maisu = b_maisu
        kingaku += kaburi_maisu*c_kane*2
        test_kane_tantai = sabun_maisu*a_kane
        test_kane_harf = sabun_maisu*c_kane*2
        if(test_kane_tantai>test_kane_harf):
            kingaku += test_kane_harf
        else:
            kingaku += test_kane_tantai
    else:
        sabun_maisu = b_maisu-a_maisu
        kaburi_maisu = a_maisu
        kingaku += kaburi_maisu*c_kane*2
        test_kane_tantai = sabun_maisu*b_kane
        test_kane_harf = sabun_maisu*c_kane*2
        if(test_kane_tantai>test_kane_harf):
            kingaku += test_kane_harf
        else:
            kingaku += test_kane_tantai

print(kingaku)

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
 
typedef long long               ll;
typedef long double             ld;
 
 
#define racecar          ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time_start		 time_t start, end; time(&start); 
#define time_end		 time(&end);double time_taken=double(end-start);cout <<"\n"<< time_taken*1000<<" ms";
#define si(a)            scanf("%d", &a)
#define si2(a,b)         scanf("%d %d", &a,&b)
#define sll(a)           scanf("%I64d",&a)
#define sll2(a,b)        scanf("%I64d %I64d",&a,&b)
#define pb               push_back
#define pi(a)            printf("%d",int(a))
#define pll(a)           printf("%I64d",ll(a))
#define all(x)           (x).begin(),(x).end()
#define rall(x)          (x).rbegin(),(x).rend()
#define ps               printf(" ")
#define nln              printf("\n")
#define ff               first
#define ss               second
#define vi               vector<int>
#define vll              vector<ll>
#define vstr             vector<string>
#define vc               vector<char>
#define pii              pair<int,int>
#define PLL              pair<ll,ll>
#define PI               acos(-1)
#define sq(x)            x*x
#define forr(i,a,b)      for(ll i=ll(a);i<ll(b);i++)
#define forn(i,a,b)      for(ll i=ll(a);i>ll(b);i--)
#define max3(a,b,c)      max(a,max(b,c))
#define max4(a,b,c,d)    max(max3(a,b,c),d)
#define min3(a,b,c)      min(a,min(b,c))
#define mod              1000000007
#define inf              9223372036854775807

///knight moves:
///int dx[] = {-2, -1, 1, 2, -2, -1, 1, 2}; 
///int dy[] = {-1, -2, -2, -1, 1, 2, 2, 1};

 
ll power(ll b,ll n)
{
    if(n==0) return 1;
    else if(n%2) return b*power(b,n/2)*power(b,n/2);
    else return power(b,n/2)*power(b,n/2);
}
 
ld root(ll n,ll r)
{
    ld dif=0.0001;
    ld guess=n/2.0;
    while(abs(pow(guess,r)-n)>=dif)
    {
        ld temp=pow(guess,r)-n;
        ld tmp=r*pow(guess,r-1);
        guess-=temp/tmp;
    }
    return guess;
}
 
void fileio()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

ll fact(ll n)
{
	if(n==0 || n==1) return 1;
	ll temp=1;
	forr(i,1,n+1) temp*=i;
	return temp;
}




int solve()
{  
    ll n;
    sll(n);
    
    vll v(n);

    forr(i,0,n) sll(v[i]);

    PLL p;
    vector<PLL>v1;
    forr(i,0,n)	
    {
    	p.ff=v[i];
    	p.ss=i;
    	v1.pb(p);
    }
    
    sort(rall(v1));
    
    forr(i,0,n)
    {
    	if(i==v1[0].ss) pll(v1[1].ff);
    	else pll(v1[0].ff);
    	nln;
    }
    
    
    		
   	return 0;
}
	
 
int main()
{

//    racecar;
//    cout<<fixed<<setprecision(6);
//    fileio();
    solve();

}

 
 
///    Before submission=>
///    ***check for integer overflow,array bounds
///    ***check for n


Measured memory_bytes: 18668
package main

import (
	"fmt"
	"sort"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	if a%2 == 0 || b%2 == 0 || c%2 == 0 {
		fmt.Println(0)
		return
	}

	s := []int{a, b, c}
	sort.Ints(s)
	fmt.Println(s[0] * s[1])
}


Measured memory_bytes: 1840
notation = input().split()
stack = []
for s in notation:
    try:
        stack.append(int(s))
    except:
        n = 0
        if s == '+':
            n = stack[-2] + stack[-1]
        elif s == '-':
            n = stack[-2] - stack[-1]
        elif s == '*':
            n = stack[-2] * stack[-1]
        elif s == '/':
            n = stack[-2] / stack[-1]

        stack = stack[:-2] + [n]

assert(len(stack) == 1)
print(stack[0])



Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define For(i,start,end) for(i64 i = start; i < end; i++)
#define newline std::cout<<'\n';
#define newlinedx(num) for(int i=0;i<num;i++)std::cout<<'\n';
using namespace std;
typedef long long ll;
typedef unsigned long ul;

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ui = uint64_t;

//----------------library in this time--------------------------------
template <class T>
T gcd(const T a,const T b) {
    return (b == 0) ? a : gcd (b, a % b);
}
template <class T>
T lcm(const T a, const T b) {
    return a * b / gcd(a,b);
}
template <class T>
inline T ave(const T a, const T b) {
    return (a + b) / 2.0f;
}

long long squareTwo(const long long a,const long long b) {
    return (b == 1) ? a : squareTwo(a * 2, b - 1);
}

template <class T>
inline T Max(const T a,const T b) {
    return (a >= b) ? a : b;
}

template <class T>
inline T Min(const T a,const T b) {
    return (a <= b) ? a : b;
}


//------------------------main function-------------------------------
void Main(){
    int N; cin >> N;
    for(int i = 1; i*i <= N; i++)if(N % i == 0 && N / i < 10){
        cout << "Yes" << endl;
        return;
    }
    cout << "No" << endl;
}

//--------------------------------------------------------------------
int main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
     
    Main();
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
city = []
city_dict = {}
for i in range(m):
    tmp1, tmp2 = map(int, input().split())
    city.append([tmp1, tmp2])
    if tmp1 not in city_dict.keys():
        city_dict[tmp1] = [tmp2]
    else:
        city_dict[tmp1].append(tmp2)
# for i in range(m):
#     print(i, city[i])
# for i in city_dict.keys():
#     print(i, city_dict[i])
for i in city_dict.keys():
    city_dict[i].sort()
    city_list = zip(city_dict[i], range(len(city_dict[i])))
    city_dict[i] = dict(city_list)

# for i in city_dict.keys():
#     for j in city_dict[i].keys():
#         print(city_dict[i][j])

for i in range(m):
    tmp1 = city[i][0]
    tmp2 = city[i][1]
    # print(tmp1, tmp2)
    # print("{:06}".format(tmp1))
    print("{:06}{:06}".format(tmp1, city_dict[tmp1][tmp2]+1))


Measured memory_bytes: 59956
#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>;
const int INF = 1000000001;

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() {
  int n;
  cin >> n;

  while(0 < n){
    int digit = n % 10;
    if(digit == 7){
      cout << "Yes" << endl;
      return 0;
    }
    n /= 10;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3636
def g():
    from collections import defaultdict
    import sys

    sys.setrecursionlimit(10 ** 6)
    N, M = map(int, input().split())
    xy = defaultdict(list)
    memo = {}
    for _ in range(M):
        x, y = map(int, input().split())
        xy[x].append(y)

    def g2(x):
        if x in memo:
            return memo[x]
        else:
            r = 0
            for ny in xy[x]:
                r = max(r, g2(ny) + 1)
            memo[x] = r
        return r

    ans = 0
    for i in range(1, N + 1):
        ans = max(ans, g2(i))
    return ans


if __name__ == '__main__':
    ans = g()
    print(ans)

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

int main(int argc, char const *argv[]) {
  int n, q;
  cin >> n >> q;
  queue<pair<string, int> > Q;
  while (n--) {
    string name;
    int tim;
    cin >> name >> tim;
    pair<string, int> task = make_pair(name, tim);
    Q.push(task);
  }
  int T = 0, r = q;
  while (Q.size()) {
    pair<string, int> t = Q.front();
    Q.pop();
    if (t.second <= r) {
      T += t.second;
      cout << t.first << " " << T << endl;
    } else {
      t.second -= r;
      T += r;
      r = q;
      Q.push(t);
    }
  }
  return 0;
}



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

public class Program
{
	public static void Main()
	{
		var line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        int N = 0,W=0;
        N = line[0];
        W = line[1];
        int[] w = new int[N];
        int[] v = new int[N];

        for (int i = 0; i < N; i++)
        {
            var tmpline = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

            v[i] = tmpline[0];
            w[i] = tmpline[1];
        }

        int[,] dp = new int[N+1, W+1];

        dp[0, 0] = 0;

        for (int i = 0; i < N; i++)
        {
            for (int j = 1;  j < W + 1;  j++)
            {
                if (j - w[i] <0)
                {
                    dp[i + 1, j] = dp[i, j];
                }
                else
                {
                    dp[i + 1, j] = Math.Max(dp[i, j], dp[i, j - w[i]] + v[i]);
                }

            }
        }
        Console.WriteLine(dp[N,W]);
	}
}



Measured memory_bytes: 13132
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void push(int);
int pop(void);
int d[1000];
int n;
int main(){
  int x,y,n=0;
  char retu[100];
  while(scanf("%s",retu)!=EOF){
    if(retu[0]=='+'){
      x=pop();
      y=pop();
      push(x+y);
    }
    else if(retu[0]=='-'){
      x=pop();
      y=pop();
      push(y-x);
    }
    else if(retu[0]=='*'){
      x=pop();
      y=pop();
      push(x*y);
    }
    else push(atoi(retu));
  }
  printf("%d\n",pop());
  return 0;
}
void push(int x){
  d[++n]=x;
}
int pop(){
  n--;
  return d[n+1];
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int n = 0, w = 0, s = 0, e = 0;
    for (int i = 0; i < (int)S.size(); ++i) {
        if (S[i] == 'N')
            n++;
        if (S[i] == 'S')
            s++;
        if (S[i] == 'W')
            w++;
        if (S[i] == 'E')
            e++;
    }
    if (n != s && min(n, s) == 0) {
        cout << "No"
             << "\n";
    } else if (w != e && min(w, e) == 0) {
        cout << "No"
             << "\n";
    } else {
        cout << "Yes"
             << "\n";
    }
    return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;

/* --------------------------------------------------- */

int main() {
    int x;
    cin >> x;
    int ans;
    if(400 <= x && x < 600) ans = 8;
    if(600 <= x && x < 800) ans = 7;
    if(800 <= x && x < 1000) ans = 6;
    if(1000 <= x && x < 1200) ans = 5;
    if(1200 <= x && x < 1400) ans = 4;
    if(1400 <= x && x < 1600) ans = 3;
    if(1600 <= x && x < 1800) ans = 2;
    if(1800 <= x && x < 2000) ans = 1;
   
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
package main

import (
	"fmt"
)

func main() {
	var x, y, z int
	fmt.Scanf("%d %d %d", &x, &y, &z)
	swap(x, y, z)
}

func swap(x, y, z int) {
	tmp := x
	x = y
	y = tmp
	tmp = x
	x = z
	z = tmp
	fmt.Printf("%d %d %d\n", x, y, z)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <string>
using namespace std;

typedef long long ll;
typedef unsigned long long u_ll;

int N;
ll ans = 0;

int main() {
	cin >> N;
	vector <int> L(N + 1);
	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}
	L[N] = 10000;

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

	for (int i = 0; i < N - 2; i++) {
		for (int j = i + 1; j < N - 1; j++) {
			int k = j + 1;
			while ((L[k] < L[i] + L[j]) && (k < N)) {
				if (L[i] < L[k] + L[j]) {
					if (L[j] < L[k] + L[i]) {
						ans += 1;
					}
				}
				k++;
			}
		}
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


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

    int l=0, r=0;
    REP(i,M){
        int a; cin >> a;
        if(a<X) l++;
        else r++;
    }

    cout << min(l,r) << endl;
    return 0;
}

Measured memory_bytes: 3560
#include<stdio.h>

static const int MAX = 500;
static const int INFTY = (1<<21);

int main() {
  int n,i,j,k,c,t,x,minv,M[MAX][MAX],d[MAX],vis[MAX];

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++) {
    for(j = 0 ; j < n ; j++) {
      M[i][j] = INFTY;
    }
  }

  for(i = 0 ; i < n ; i++) {
    scanf("%d%d",&t,&k);
    for(j = 0 ; j < k ; j++) {
      scanf("%d%d",&x,&c);
      M[t][x] = c;
    }
  }

  for(i = 0 ; i < n ; i++) {
    d[i] = INFTY;
    vis[i] = 0;
  }

  d[0] = 0;

  while(1) {
    minv = INFTY;
    t = -1;
    for(i = 0 ; i < n ; i++) {
      if(minv > d[i] && !vis[i]) {
        t = i;
        minv = d[i];
      }
    }

    if(t == -1)
      break;
    vis[t] = 1;
    for(x = 0 ; x < n ; x++) {
      if(!vis[x] && M[t][x] != INFTY) {
        if(d[x] > d[t] + M[t][x]) {
          d[x] = d[t] + M[t][x];
        }
      }
    }
  }
  for(i = 0 ; i < n ; i++) {
    printf("%d %d\n",i,(d[i]==INFTY?-1:d[i]));
  }
  return 0;
}





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

#define int long long
const int MOD = 1e9 + 7;
const int INF = 1 << 29;

const int N = 1e6 + 10;
vector<int> g[N];
int deg[N];
int par[N];

void solve(){
 int n, m;
 cin >> n >> m;
 for (int i = 1; i <= n + m - 1; i++){
  int x, y;
  cin >> x >> y;
  g[x].push_back(y);
  deg[y]++;
 }  
 queue<int> Q;
 for (int i = 1; i <= n; i++){
  if (deg[i] == 0)
    Q.push(i);
 }
 while (!Q.empty()){
  int node = Q.front();
  Q.pop();
  for (auto &it : g[node]){
    if (--deg[it] == 0){
      Q.push(it);
      par[it] = node;
    }
  }
 }
 for (int i = 1; i <= n; i++){
  cout << par[i] << endl;
 }
}
int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}

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

int linearSearch(int *A, int q, int n) {
    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (A[i] == q) {
            sum += 1;
            break;
        }
    }
    return sum;
}

int main() {
    int n, q, sum = 0;
    int A[100001];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    cin >> q;
    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;
        sum += linearSearch(A, t, n);
    }
    cout << sum << endl;

    return 0;
}



Measured memory_bytes: 3116
from math import *
n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
p_1 = 0
p_2 = 0
p_3 = 0
p_inf = []
for i in range(n):
        p_1 += abs(x[i]-y[i])
        p_2 += pow(abs(x[i]-y[i]),2)
        p_3 += pow(abs(x[i]-y[i]),3)
        p_inf.append(abs(x[i]-y[i]))
print("%f" %p_1)
print("%f" %(sqrt(p_2)))
print("%f" %(pow(p_3,1/3)))
print("%f" %(max(p_inf)))



Measured memory_bytes: 5720
while True:
	H,W = map(int,input().split())
	if H ==0 and W == 0:
		break
	
	for i in range (H):
		for j in range (W):
			if (i+j)%2 == 0:
				print('#', end = "")
			else:
				print('.', end = "")
		print("")
	print("")

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  ll x,k,d; cin >> x >> k >> d;
  x = abs(x);
  ll y = x / d;
  if(y > k){
    cout << x - k * d << endl;
    return 0;
  } else {
    x -= y*d;
    k -= y;
    if(k % 2 == 0){
      cout << x << endl;
    }else{
      cout << d-x << endl;
    }
  }
  return 0;
}


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

using ll = int64_t;
const int MAX = 2e5;

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n; cin >> n;
    vector<int> v(n);
    for (auto& it : v) cin >> it;
    sort(v.rbegin(), v.rend());
    ll ans = v[0];
    int lim = (n-2)/2;
    for (int i = 1; i <= lim; i++) {
        ans += 2*v[i];
    }
    if ((n-2)%2 == 1) ans += v[lim+1];
    cout << ans;


    return 0;
}

Measured memory_bytes: 3920
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>
#include <cstdint>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long ll;

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


int main() {
    string n; cin >> n;
    int ans = 0;
    rep(i, 4) if (n[i] == '2') ans++;
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256