akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};

int main(){
    ll n; cin >> n;
    multiset<ll> se;
    rep(i,n){
        ll a; cin >> a;
        se.insert(a);
    }
    ll ans = 0;
    while(se.size()>1){
        auto itr = se.end();
        itr--;
        ll x = *itr;
        se.erase(itr);
        ll cur = 1;
        while(cur <= x*2){
            auto itr2 = se.find(cur-x);
            if(itr2 != se.end()){
                se.erase(itr2);
                ans++;
                break;
            }
            cur *= 2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 9600
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;


int f[] = { 0,1,2,0,1,2,0,1,2 };
int dp[100001][3][3][2];
void solve() {
	string s; cin >> s; if (s == "#") exit(0);
	vector<int> v(s.size()); for (int i = 0; i < v.size(); i++) v[i] = f[s[i] - '1'];
	for (int i = 0; i <= s.size(); i++) for (int j = 0; j < 3; j++) for (int k = 0; k < 3; k++) for (int l = 0; l < 2; l++) dp[i][j][k][l] = inf;
	for (int j = v[0]; j < 3; j++) dp[0][v[0]][j][0] = 0;
	for (int i = 0; i <= v[0]; i++) dp[0][i][v[0]][1] = 0;
	for (int i = 1; i < v.size(); i++) {
		int cur = v[i];
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j <= cur) {
					chmin(dp[i][j][cur][1], dp[i - 1][j][k][0]);
					chmin(dp[i][j][cur][1], dp[i - 1][j][k][1] + 1);
				}
				if (cur <= k) {
					chmin(dp[i][cur][k][0], dp[i - 1][j][k][0] + 1);
					chmin(dp[i][cur][k][0], dp[i - 1][j][k][1]);
				}
			}
		}
	}
	int res = inf; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) for (int k = 0; k < 2; k++) chmin(res, dp[v.size() - 1][i][j][k]);
	printf("%d\n", res);
}

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

	int kkt = 89;
	while (kkt) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 10816
//#include <bits/stdc++.h>
#include<iostream>
#include <iosfwd>
#include<limits.h>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <limits>
#include<stdio.h>
#include <queue>
#include <stack>
#include <math.h>
#include<string.h>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include<vector>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
#define fr(i,j,n)   for(lli i=j;i<(n);++i)
#define bk(i,j,n)   for(lli i=j;i>=n&&j>=n;--i)
#define pb push_back
#define m_p make_pair
#define F first
#define S second
#define endl "\n"
#define mem(p,v) memset(p,v,sizeof(p))
#define present(c,x)    ((c).find(x) != (c).end())
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define debug4(x,y,z,a) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<" "<<#a<<" "<<a<<endl;
#define ub upper_bound
#define lb lower_bound
typedef long long int lli;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<lli> vl;
typedef pair<lli,lli> pl;
inline lli max(lli a,lli b){ return a>b?a:b;}
inline lli min(lli a,lli b){ return a<b?a:b;}
const long long inf = 9e18;
const lli MOD =1e9+7;
double pie = 2*acos(0.0);
void show(vector<lli> v){fr(i,0,v.size())cout<<v[i]<<" ";cout<<endl;}
void show(vector<int> v){fr(i,0,v.size())cout<<v[i]<<" ";cout<<endl;}
void show(int a[], int arraysize){for (int i = 0; i < arraysize; ++i)cout << a[i] << " ";cout<<endl;}
void show(lli a[], lli arraysize){for (lli i = 0; i < arraysize; ++i)cout << a[i] << " ";cout<<endl;}
void show(bool a[], lli arraysize){for (lli i = 0; i < arraysize; ++i)cout << a[i] << " ";cout<<endl;}
void show(set<int> s){for (auto it = s.begin(); it != s.end(); it++){cout << *it << " ";}cout<<endl;}
void show(map<lli,lli> mp){for (auto it = mp.begin(); it != mp.end(); it++){cout << it->first << " "<<it->second<<endl;}cout<<endl;}

lli modpow(lli x,lli n){lli res=1;while(n>0){if(n&1) res=((res%MOD)*(x%MOD))%MOD;x=((x%MOD)*(x%MOD))%MOD;n>>=1;}return res;}
lli power(lli x, lli n){lli res=1;while(n>0){if(n&1) res=res*x;x=x*x;n>>=1;}return res;}

/////// ------ Main code starts here ------ /////
lli n,m;
int a[22][22];
void solve()
{
    cin>>n;
    fr(i,0,n)
    {
        fr(j,0,n)
        {
            cin>>a[i][j];
        }
    }
    vector<lli> dp(1<<n,0);
    dp[0]=1;
    fr(j,0,(1<<n)-1)
    {
        lli i=__builtin_popcount(j);
        fr(k,0,n)
        {
            if(a[i][k] && !(j&(1<<k)))
            {
                lli m2=(j^(1<<k));
                dp[m2]=(dp[m2]+dp[j])%MOD;
            }
        }
    }
    cout<<dp[(1<<n)-1]<<endl;
    
}
int main()
{
    run;cout<<fixed<<setprecision(12);
    int t;
    t=1;
    while(t){solve();t--;}
    return 0;
}






Measured memory_bytes: 19548
s = str(input())
q = int(input())
g = 0
A = ""
B = ""
for i in range(q):
  query = input()
  if (query == "1"):
    g = 1-g
  else:
    queries = query.split()
    f = int(queries[1])-1
    c = queries[2]
    if (g == f):
      B = "".join([B,c])
    else:
      A = "".join([A,c])
s = "".join(["".join(list(B)[::-1]),s,A])
if (g == 1):
  s = "".join(list(s)[::-1])
print(s)


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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    map<int, int> mp;
    for(int i=0; i<N; i++) mp[A[i]]++;
    for(int i=0; i<M; i++){
        int b, c;
        cin >> b >> c;
        auto it = mp.begin();
        int d = 0;
        while(b > 0 && it != mp.end() && it->first < c){
            if(it->second <= b){
                b -= it->second;
                d += it->second;
                it = mp.erase(it);
            }else{
                mp[it->first] -= b;
                d += b;
                b = 0;
            }
        }
        if(d > 0) mp[c] += d;
    }
    int64_t ans = 0;
    for(auto& p : mp){
        ans += (int64_t)p.first*p.second;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
constexpr uint64_t L1 = 1ull;
constexpr ull bit(int n){ return 1ull << n;}

constexpr ll INF       = 1000000000;/* 1e+9a */

void solve(istream& cin) {
    int N;
    while(cin >> N){
        bool win_firt = false;
        for (int i = 0; i < N; ++i) {
            ll tmp;
            cin >> tmp;
            if(tmp %2 == 1){
                win_firt = true;
            }
        }
        
        cout << (win_firt ? "first" : "second")  << endl;
    }
}

int main(int argc, char *argv[]) {
    string FileName("B"), Modifier("MEPH_");
    string ExecutionName = Modifier + FileName;
    string sub(argv[0]);
    if(sub.size() > ExecutionName.size())
        sub = sub.substr(sub.size()-ExecutionName.size(), ExecutionName.size());

    cout << setprecision(16) << scientific;
    if (sub != ExecutionName) {
        cin.tie(0);
        ios::sync_with_stdio(false);
        solve(cin);
    }
    else {    
	    cerr << sub << endl;
        string inFile = FileName + "_sample.txt";
        auto fs = fstream(inFile, fstream::in);
        solve(fs);
    }
}


Measured memory_bytes: 256
import sys
MOD = 10**9 + 7
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
def adj(n): return [[] for _ in range(n)]

def inv(a): return pow(a, MOD-2, MOD) #逆元
def comb(n,r):
    ans = 1
    for i in range(r): ans *= n-i; ans *= inv(r-i); ans %= MOD
    return ans

    
n,k = imap()
ans = n-k+1
print(ans)
for i in range(2,k+1):
    ans *= (n-k-i+2) * (k-i+1) * inv(i) * inv(i-1)
    print(ans %MOD)


Measured memory_bytes: 3444
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int count[110] = { 0 };
	count[a]++;
	count[b]++;
	count[c]++;
	int an = 0;
	for (int i = 0; i <= 100; i++) {
		if (count[i] > 0) {
			an++;
		}
	}
	cout << an << endl;
}

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

ll N, M, A;
char S[200][200];
ll dp[100][100][4][11][11];

const ll INF = 1LL << 50;
const ll dy[4] = { -1, +0, +1, +0 };
const ll dx[4] = { +0, +1, +0, -1 };

struct state {
  ll y, x, dir, p, q, dist;
  bool operator<(const state &s) const {
    return dist > s.dist;
  }
};

int main(void) {
  cin >> N >> M >> A;
  REP(i, 0, N) REP(j, 0, M) cin >> S[i][j];

  ll sy, sx, gy, gx;
  REP(i, 0, N) REP(j, 0, M) {
    if(S[i][j] == 'S') {
      sy = i;
      sx = j;
    }
    if(S[i][j] == 'G') {
      gy = i;
      gx = j;
    }
  }

  REP(y, 0, N) REP(x, 0, M) REP(dir, 0, 4) REP(p, 0, A + 1) REP(q, 0, A + 1) dp[y][x][dir][p][q] = INF;

  priority_queue<state> que;
  if(sy + 1 < N && S[sy + 1][sx] != '#') {
    que.push((state) { sy + 1, sx, 2, 0, 0, 0 });
  }

  while(!que.empty()) {
    state s = que.top();
    que.pop();

    ll y = s.y, x = s.x, dir = s.dir, p = s.p, q = s.q, dist = s.dist;

    if(dp[y][x][dir][p][q] <= dist) continue;
    dp[y][x][dir][p][q] = dist;

    if(y == gy && x == gx) {
      cout << dist << endl;
      return 0;
    }

    REP(k, -1, 2) {
      if(y == sy && x == sx && k != 0) continue;
      if(y == sy && x == sx && dir % 2 == 0) continue;
      ll ndir = (dir + k + 4) % 4;
      ll ny = y + dy[ndir];
      ll nx = x + dx[ndir];
      ll np = p;
      ll nq = q;
      if(dir % 2 == 0) {
        np += (k == -1 ? 1 : 0);
        nq += (k == +1 ? 1 : 0);
      } else {
        np += (k == +1 ? 1 : 0);
        nq += (k == -1 ? 1 : 0);
      }
      if(0 <= ny && ny < N && 0 <= nx && nx < M && S[ny][nx] != '#' && np <= A && nq <= A) {
        que.push((state) { ny, nx, ndir, np, nq, np + nq });
      }
    }
  }

  cout << -1 << endl;
}


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

const int MAX_N = 1e5 + 5;
int n, ans;
int Arr[MAX_N];
unordered_map <int, int> cnt[2][2], Mark;
unordered_map <int, int>::iterator it;

void calc(int x) {
	for (int i = 0; i < n; i++)
		cnt[x][i & 1][Arr[i]]++;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &Arr[i]);
		Mark[Arr[i]]++;
	}

	calc(0);
	sort(Arr, Arr + n);
	calc(1);

	for (it = Mark.begin(); it != Mark.end(); it++)
		ans += abs(cnt[0][0][it->first] - cnt[1][0][it->first]);

	printf("%d", ans >> 1);
	return 0;
}


Measured memory_bytes: 17060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <cassert>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    
    int ans = 0;
    REP(i, n) {
        if ((!(i & 1)) && (a[i] & 1)) ++ans;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3620
/*input

*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(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())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main()
{
	IOS;
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[0]*a[1]/2;
	return 0;
}


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1)/b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }

int nmax=200000; // 2*(10^5)
vvec g(nmax);



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    map<int,int> mp;
    rep(i,n){
        mp[a[i]]++;
    }
    int cnt=0;
    for(auto x:mp){
        if(x.sc%2==1) cnt++;
    }
    cout<<cnt<<endl;
    
}

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

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> connections(N, 0);
    for(int i=0;i<M;i++){
        int sideA, sideB;
        cin >> sideA >> sideB;
        connections.at(sideA-1)++;
        connections.at(sideB-1)++;
    }
    for(int i=0;i<N;i++){
        cout << connections.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
open Scanf
open Printf
       
let _ =
  let w, h, n = scanf "%d %d %d\n" (fun x y z -> (x, y, z)) in
  let rec loop (lx, ly) (rx, ry) c =
    if c = 0 then (rx - lx) * (ry - ly)
    else
      match scanf "%d %d %d\n" (fun i j k -> (i, j, k)) with
        x, y, a when a = 1 -> loop (min rx (max x lx), ly) (rx, ry) (c-1)
      | x, y, a when a = 2 -> loop (lx, ly) (max lx (min x rx), ry) (c-1)
      | x, y, a when a = 3 -> loop (lx, min ry (max y ly)) (rx, ry) (c-1)
      | x, y, a -> loop (lx, ly) (rx, max ly (min y ry)) (c-1)
  in
  printf "%d\n" @@ loop (0, 0) (w, h) n


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <utility> // pair
#include <algorithm> // swap
using namespace std;

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()

signed main() {
  int n;
  cin >> n;
  vector<tuple<string, int, int>> scores;
  rep(i, n) {
    string name;
    int score;
    cin >> name >> score;
    scores.push_back(tuple<string, int, int>(name, score, i+1));
  }
  sort(all(scores), [](const auto &l, const auto &r) {
    return get<0>(l) != get<0>(r) ? get<0>(l) < get<0>(r) : get<1>(l) > get<1>(r);
  });
  for(auto s : scores) {
    cout << get<2>(s) << endl;
  }
}


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

int main(){

  long long ans = 9999999999;
  int N, K; cin >> N >> K;

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

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

  for(int i = 0 ; i < N - K + 1; ++i){
    ans = std::min(h[i+K-1] - h[i], ans);
  }

  cout << ans << endl;
  

}

Measured memory_bytes: 1024
s = str(input())
t = str(input())

l_st = len(s) - len(t) + 1
l_t = len(t)

ans = l_t
for _ in range(l_st):
    mx = l_t
    for i in range(l_t):
        if s[_+i] == t[i]:
            mx -= 1
        ans = min(ans, mx)
print(ans)
    

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

int main(){
 int N,K,mini;
  mini=0;
 cin>>N>>K;
 vector<int> vec(N);
  for(int i=0;i<N;i++){
  cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  for(int i=0;i<K;i++){
  mini+=vec.at(i);
  }
  cout<<mini<<endl;
}

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

int main(){
	int i=1, n, x;
	cin>>n;

	while(++i<=n){
		x=i;
		if(x%3==0){
			cout<<" "<<i;
		}else if(x%10==3){
			cout<<" "<<i;
		}else{
			while(x/=10){
				if(x%10==3){
					cout<<" "<<i;
					break;
				}
			}
		}
	}

	cout<<endl;
}


Measured memory_bytes: 3112
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	l := nextLine()
	s := strings.Split(l, " ")
	stack := make([]int, 0, len(s))

	f := func() (v1, v2 int) {
		n := len(stack) - 1
		v1 = stack[n-1]
		v2 = stack[n]
		stack = stack[:n-1]
		return
	}
	for i := range s {
		switch s[i] {
		case "+":
			v1, v2 := f()
			stack = append(stack, v1+v2)
		case "-":
			v1, v2 := f()
			stack = append(stack, v1-v2)
		case "*":
			v1, v2 := f()
			stack = append(stack, v1*v2)
		default:
			v, err := strconv.Atoi(s[i])
			if err != nil {
				panic("a to i error")
			}
			stack = append(stack, v)
		}
	}
	fmt.Println(stack[0])
}

// =================================
// I/O util
// =================================

var sc = bufio.NewScanner(os.Stdin)

// Scan required
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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



Measured memory_bytes: 1100
#include <iostream>

using namespace std;

int main()
{
    
    int s;
    int hours,minitues,seconds;
    
    cin >> s;
    
    seconds = s % 60;
    s = s/60;
    
    minitues = s %60;
    s = s/60;
    
    hours = s % 24;
    
    cout << hours <<":"<<minitues<<":"<<seconds<<endl; 
    
    
    
    
    return 0;
}



Measured memory_bytes: 3116
#include <algorithm>
#include <iostream>
#include <map>
#include <stdio.h>

typedef long long ll;

using namespace std;

int main() {
  int N;
  cin >> N;
  map<int, int> M;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    ++M[a];
  }
  int a = 0;
  int b = 0;
  for (auto it = M.rbegin(); it != M.rend(); ++it) {
    if (it->second >= 2) {
      if (a == 0) {
        if (it->second >= 4) {
          a = it->first;
          b = it->first;
          break;
        } else {
          a = it->first;
        }
      } else {
        b = it->first;
        break;
      }
    }
  }
  printf("%lld\n", (ll)a * b);
}

Measured memory_bytes: 7792
N,K=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(N)]

from collections import defaultdict
DICT=defaultdict(int)

for a,b in AB:
    DICT[a]+=b

for k in sorted(DICT):
    if DICT[k]>=K:
        print(k)
        break
    else:
        K-=DICT[k]


Measured memory_bytes: 33732
#include<stdio.h>

int main(){
  char S[4];
  scanf("%s",S);

  int cnt=0;
  for(int i=0; i<4; i++){
    if(S[i]=='+'){
      cnt++;
    }else{
      cnt--;
    }
  }

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

  return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

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




using namespace std;
int main() {
	
	int n;
	vector<int>z;
	int t;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t;
		z.push_back(t);
	}
	long long int a = 0, b = 0;
	
	for (int i = 0; i < n; i++) {
		a += z[i] - 1;
	}
	
	/*
	for (int i = 0; i <= 100000000; i++) {
		b = 0;
		for (int j = 0; j < n; j++) {
			b += (i%z[j] );
		}
		a = max(b, a);
	}
	*/
	cout << a << endl;

	return 0;
}

Measured memory_bytes: 256
X, Y = map(int,input().split())

def cmb(n, k, mod, fac, ifac):
    """
    nCkを計算する
    """
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod


def make_tables(mod, n):
    """
    階乗テーブル、逆元の階乗テーブルを作成する
    """
    fac = [1, 1] # 階乗テーブル・・・(1)
    ifac = [1, 1] #逆元の階乗テーブル・・・(2)
    inverse = [0, 1] #逆元テーブル・・・(3)

    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac


def comb(m,n):
    MOD = 10**9 + 7
    fac, ifac = make_tables(MOD, m)
    ans = cmb(m, n, MOD, fac, ifac)
    return ans

def calculate(x,y):
    m = 0
    n = 0

    if ((x + y) % 3) != 0:
        print(0)
        return

    result = []

    while (2*m <= x) and (m <= y):
        n = x - 2 * m
        if (2*m + n == x) and (2*n + m == y):
            result.append(comb(m+n,n))

        m = m + 1

    if len(result) == 0:
        print(0)
    else:
        print(min(result))

calculate(X,Y)

Measured memory_bytes: 82440
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define ull unsigned long long
using namespace std;
void io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

const int MAXN = 1e2 + 5;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9 + 7;

ll S;
ll a, b, x, y;

int main() {
    io();
    cin >> S;
    if (S == (ll)1e18) {
        cout << "0 0 1000000000 0 0 1000000000";
    } else {
        ll S0 = S;
        int cnt = 0;
        while (S0) {
            S0 /= 10;
            cnt++;
        }
        y = 1;
        for (int i = 0; i < cnt / 2; i++) {
            y *= 10;
        }
        ll l = S / y;
        ll r = S % y;
        a = l + 1;
        b = y - r;
        x = 1;
        cout << "0 0 " << a << ' ' << b << ' ' << x << ' ' << y;
    }
}


Measured memory_bytes: 3580
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class D { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long X = GetLong();
		long Y = GetLong();
		long Z = GetLong();
		long K = GetLong();
		var A = GetLongs(X);
		var B = GetLongs(Y);
		var C = GetLongs(Z);

		var AB = new List<long>();
		for(long i = 0; i < X; i++)
		{
			for(long j = 0; j < Y; j++)
				AB.Add(A[i] + B[j]);
		}
		AB.Sort((x, y) => y.CompareTo(x));
		AB = AB.Take((int)K).ToList();

		var ABC = new List<long>();
		for(long i = 0, E = AB.Count; i < E; i++)
		{
			for(long j = 0; j < Z; j++)
				ABC.Add(AB[(int)i] + C[(int)j]);
		}
		ABC.Sort((x, y) => y.CompareTo(x));
		WriteLine(string.Join("\n", ABC.Take((int)K)));
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 67592
#include <iostream>
#include <cmath>
const int MAX = 10000010;
using namespace std;

bool p[MAX];

void sieve_of_eratosthenes(){
    for(int i=0 ; i<MAX ; i++){
        p[i] = (i<=1)? false : true ;
    }
    for(int i=2 ; i <= sqrt((double)MAX)+1 ; i++){
        if( p[i] ){
            for(int j=i*2 ; j<MAX ; j+=i){
                p[j] = false;
            }
        }
    }
}

int main(){
    int n, m = 13;

    sieve_of_eratosthenes();
    while( cin >> n , n ){
		for(int i=n ; i>=13 ; --i ){
			if( p[i] && p[i-2] && p[i-6] && p[i-8] ){
				cout << i << endl;
				break;
			}
		}
    }
}

Measured memory_bytes: 10000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
typedef long long ll;
const int mod = 1e9 + 7;
int main() {

    int n;
    cin >> n;

    vector<int> v(n);
    rep(i, n) cin >> v[i];

    int s = 1;
    int ans = 0;
    rep(i, n){
        if(v[i] == s){
            s++;
        }
        else{
            ans++;
        }
    }
    
    if(ans == n){
        cout << -1;
        return 0;
    }
    else{
        cout << ans;
    }
    
    return 0;
}

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

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

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

/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}

__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

struct unionfind {
    vector<int> d;
    unionfind(int n) : d(n, -1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};

int main() {
    int n, m;
    cin >> n >> m;
    unionfind uf(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a, b);
    }
    int ans = 0;
    rep(i, n) chmax(ans, uf.size(i));
    cout << ans << '\n';
}


Measured memory_bytes: 4052
s = str(input())

res = 0
max_res = 0
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'T' or s[i] == 'G' or s[i] == 'C':
        res += 1
        if res > max_res:
            max_res = res
    else:
        res = 0
print(max_res)


Measured memory_bytes: 2940
def iskaibun(S: str):
    # print(S)
    return all(x==y for x, y in zip(S, reversed(S)))


def main():
    S = input()
    N = len(S)
    if iskaibun(S) and iskaibun(S[:(N-1)//2]) and iskaibun(S[(N+3)//2-1:]):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: i32,
    }
    for i in 1..10 {
        for j in 1..10 {
            if n == i * j {
                puts!("Yes\n");
                return;
            }
        }
    }
    puts!("No\n");
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

int main() {
  int n; cin >> n;
  int nowx,nowy,nowt;
  nowx = 1; nowy = 1; nowt = 0; 
  FOR(i,0,n-1){
    int t,x,y; cin >> t >> x >> y;
    if((abs(nowx-x) + abs(nowy-y) - (t-nowt))%2==0 && abs(nowx-x) + abs(nowy-y) <= (t-nowt)){
      nowx = x;
      nowy = y;
      nowt = t;
    } else {
      cout << "No" << "\n";
      return 0;
    }
  }
  cout << "Yes" << "\n";
    

}


Measured memory_bytes: 256
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj),rend(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1 << 30);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    fill((T*)array, (T*)(array + N), val);
}int N, M, Q,L,R;
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)
    // Constructor
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }
    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }
    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }
    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};
int main() {
    int n, m, k,a,b,c,d; cin >> n >> m >> k;
    vector<set<int>> da(n);
    UnionFind tree(n);
    rep(i, m) {
        cin >> a >> b; a--; b--;
        da[a].insert(b);
        da[b].insert(a);
        tree.merge(a, b);
    }
    rep(i, k) {
        cin >> c >> d; c--; d--;
        if (tree.issame(c, d)) {
            da[c].insert(d);
            da[d].insert(c);
        }
    }
    rep(i, n) {
        cout << tree.size(i) - 1 - da[i].size() << " ";
    }cout << endl;
}

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

int partition( int p, int r);
void swap(int *a, int *b);

#define M 100100

int A[M],n;

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

    int p = partition(0,n-1);

    for(int i = 0; i < n; i++){
        if(i == p) cout << "[" << A[i] << "]";
        else cout << A[i];

        if(i != n-1) cout << " ";
    }
    cout << endl;
    
}

int partition( int p, int r){
    int x = A[r];
    int i = p-1,j;
    for(j = p; j < r; j++){
        if(A[j] <= x){
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i+1], A[r]);
    return i+1;
}

void swap(int *a, int *b){
    int w = *a;
    *a = *b; *b = w;
}


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

int const N = 500000, M = 1 << 20, md = 1e9 + 7;
int x[N + 1], fr[N + 1], an, n;
vector<int> v[M];

inline void ad(int &x, int y) { if ((x += y) >= md)x -= md; }
inline int s0(int l, int r) { return fr[r] - fr[l - 1]; }

void go(vector<int> const &v, bool sad = false){
	int sa = 0, dps = 0;
	f(i, 1, v.size()){
		ad(sa, (ll)dps * s0(v[i - 1], v[i]) % md);
		ad(an, sad ? (ll)(sa + 1) * s0(v[i], n) % md : sa + 1);
		ad(dps, sa + 1);
	}
}

int main(){
	scanf("%d", &n);
	f(i, 1, n + 1)scanf("%d", x + i);
	f(i, 1, n + 1)x[i] ^= x[i - 1];
	f(i, 1, n + 1)fr[i] = fr[i - 1] + (x[i] == 0);
	f(i, 1, M)v[i].push_back(1);
	f(i, 1, n + 1)if (x[i])v[x[i]].push_back(i);
	an = 1;
	if (x[n])go(v[x[n]], true);
	else {
		f(i, 1, fr[n])ad(an, an);
		f(i, 1, M)go(v[i]);
	}
	printf("%d\n", an);
}

Measured memory_bytes: 64256
// AOJ 1620 Boolean Expression Compressor
// 2018.2.12 bal4u

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

typedef struct { char w; int p; } TBL;
TBL tbl[1 << 16];
char w[3000], exp[3000][17]; int top, end;
char buf[20], *p;

int eval()
{
	int f;
	char c = *p; if (*p) p++;
	if      (c == '0') return 0;
	else if (c == '1') return 0xffff;
	else if (c == 'a') return 0xff00;
	else if (c == 'b') return 0xf0f0;
	else if (c == 'c') return 0xcccc;
	else if (c == 'd') return 0xaaaa;
	else if (c == '-') {
		f = 1; while (*p == '-') f = !f, p++; 
		if (f) return (~eval()) & 0xffff;
		else   return eval();
	}
	else if (c == '(') {
		int y, x = eval();
		if (*p++ == '^') { y = eval(); p++;	return x ^ y; }
		else             { y = eval(); p++;	return x & y; }
	}
	return 0;
}

void insert(char *s, int sz)
{
    int id;

	p = s, id = eval();
	if (sz < tbl[id].w) w[tbl[id].p] = 0, tbl[id].w = 0;
	if (tbl[id].w == 0) {
		tbl[id].w = sz, tbl[id].p = end;
		w[end] = sz, memcpy(exp[end++], s, sz);
	}
}

void mktbl()
{
	int i, _end;
	char buf[100], *p, *q;

	insert("0", 1), insert("1", 1);
	insert("a", 1), insert("b", 1), insert("c", 1), insert("d", 1);

	while (top < end) {
		for (_end = end; top < _end; top++) {
			if (w[top] == 0) continue;
				
			if (w[top] > 15) continue;
			if (*exp[top] != '-') {
				q = buf;
				*q++ = '-', p = exp[top]; while (*p) *q++ = *p++; *q = 0;
				insert(buf, q-buf);
			}

			if (w[top] > 13) continue;
			for (i = 0; i < _end; i++) {
				if (w[i] == 0 || w[i] + w[top] > 13) continue;

				q = buf;
				*q++ = '(', p = exp[top]; while (*p) *q++ = *p++;
				*q++ = '^', p = exp[i];   while (*p) *q++ = *p++;
				*q++ = ')', *q = 0;
				insert(buf, q-buf);

				q = buf;
				*q++ = '(', p = exp[top]; while (*p) *q++ = *p++;
				*q++ = '*', p = exp[i];   while (*p) *q++ = *p++;
				*q++ = ')', *q = 0;
				insert(buf, q-buf);
			}
		}
	}
}

int main()
{
	mktbl();
	//printf("end %d\n", end);	// end = 2604

	while (fgets(p=buf, sizeof(buf), stdin) && *p != '.') {
		printf("%d\n", tbl[eval()].w);
	}
	return 0;
}



Measured memory_bytes: 2428
# -*- coding: utf-8 -*-
import numpy as np
n, m = map(int, input().split())
student = np.zeros([n,2])
check_point = np.zeros([m,2])
res = np.ones([n,m])
for i in range(n):
    student[i,0], student[i,1] = map(int, input().split())
for i in range(m):
    check_point[i,0], check_point[i,1] = map(int, input().split())
    res[:,i] = abs(student[:,0]-check_point[i,0])+abs(student[:,1]-check_point[i,1])
for i in range(n):
    print(np.argmin(res[i,:])+1)


Measured memory_bytes: 21248
using System;
using System.Linq;

namespace kupc2016_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int ret = 0;
            for (int i = 0; i < x[0]; i++)
            {
                int t = int.Parse(Console.ReadLine());
                if (t < x[1] || x[2] <= t) ret++;
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 13268
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define PI 3.14159265358979323846264338327950288
 
using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;
using vll = vector<long long int> ;

int pref[1000075] ;
int main(){
    FAST_IO ;
    string S , T ; cin >> S >> T ;
    int N = ( int ) S.size() ;
    int L = ( int ) T.size() ;
    int ans = L ;
    for( int i = 0 ; i < N - L + 1 ; i++ ){
        int d = 0 ;
        for( int j = 0 ; j < L ; j++ ){
            if( S[i+j] != T[j] )
                d++ ;
        }
        ans = min( d , ans ) ;
    }
    cout << ans << endl ;
    return 0 ;
    
}
 

Measured memory_bytes: 3596
import queue
import math
import copy
"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""
(N,M) = (int(i) for i in input().split(" "))
S = input()[::-1]
T = []
for s in S:
	if len(T)%2 == 0:
		if s == '0':
			T.append(1)
		else:
			T[-1]+=1
	else:
		if s== '1':
			T.append(1)
		else:
			T[-1]+=1
for i in range(1,len(T)):
	T[i] += T[i-1]
# print(T)
ans = []
cur = 0

tt = 0

while cur+M<N:
	cur += M
	while T[tt] <= cur:
		tt += 1
	if tt % 2 == 1:
		tt  -= 1
		st = M-cur+T[tt]-1
		if st == 0:
			ans = None
			break
		ans.append(st)
		cur = T[tt] - 1
	else:
		ans.append(M)
if ans != None and cur < N:
	ans.append(N-cur)
if ans == None:
	ans= [-1]
print(" ".join([str(i) for i in ans[::-1]]))





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

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    for (int i = 0; i < N; i++)
        cin >> X[i];
    vector<int> v(N);
    copy(X.begin(), X.end(), v.begin());
    sort(X.begin(), X.end());

    int mid_1 = X[N / 2 - 1], mid_2 = X[N / 2];
    for (int i = 0; i < N; i++) {
        if (v[i] <= mid_1)
            cout << mid_2 << endl;
        else
            cout << mid_1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3712
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int n; vector<string> s;
bool ok(int d, int l, int r) {
	if (s[l].size() == d) l++;
	for (int i = l; i < r; i++) {
		if (s[i].size() == d) return false;
	}
	bool ret = true;
	for (int p = l, i = l + 1; i <= r; i++) {
		if (i == r || s[i - 1][d] != s[i][d]) {
			if (!ok(d + 1, p, i)) ret = false;
			p = i;
		}
	}
	return ret;
}
bool cycle_detection(vector<vector<int> > &G) {
	vector<bool> vis(G.size());
	function<bool(int, int, bool)> rec = [&](int pos, int start, bool flag) {
		if (pos == start && flag) return true;
		if (flag) vis[pos] = true;
		bool ret = false;
		for (int e : G[pos]) {
			if (!vis[e]) ret = ret || rec(e, start, true);
		}
		return ret;
	};
	for (int i = 0; i < G.size(); i++) {
		fill(vis.begin(), vis.end(), false);
		if (rec(i, i, false)) return true;
	}
	return false;
}
int main() {
	while (cin >> n, n) {
		s = vector<string>(n);
		for (int i = 0; i < n; i++) cin >> s[i];
		s.erase(unique(s.begin(), s.end()), s.end()); n = s.size();
		bool res = ok(0, 0, n);
		if (!res) cout << "no" << endl;
		else {
			vector<vector<int> > G(26);
			for (int i = 1; i < n; i++) {
				for (int j = 0; j < min(s[i - 1].size(), s[i].size()); j++) {
					if (s[i - 1][j] != s[i][j]) {
						G[s[i - 1][j] - 97].push_back(s[i][j] - 97);
						break;
					}
				}
			}
			cout << (cycle_detection(G) ? "no" : "yes") << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3184
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>

#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
 int n; cin >> n;
 int a[n+2];
  a[0] = 0;
  rep(i,n){
    cin >> a[i+1];
  }
  a[n+1] = 0;
  int sum = 0;
  for(int j=0;j<n+1;j++){
    sum += abs(a[j+1]-a[j]);
  }

  for(int k=1;k<=n;k++){
    cout << sum - abs(a[k]-a[k-1]) - abs(a[k+1]-a[k]) +abs(a[k+1] - a[k-1]) << endl;
  }
                 
  
 return 0;
}

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

int main(){
  int N;
  cin >> N;
  int sum=0;
  for (int i=0;i<N;i++){
    int l,r;
    cin >> l >> r;
    sum += (r-l + 1);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256