akhauriyash/Code-Regression huggingface dataset:
h, w, k = map(int, input().split())
c = [input() for _ in range(h)]
ans = 0
for i in range(1<<h):
	for j in range(1<<w):
		cnt = 0
		for x in range(h):
			for y in range(w):
				if (i >> x) & 1 and (j >> y) & 1 and c[x][y] == "#":
					cnt += 1
		if cnt == k:
			ans += 1
print(ans)

Measured memory_bytes: 68356
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

int main() {
	string atcoder, s, contest;
	cin >> atcoder >> s >> contest;
	cout << "A";
	cout << s[0];
	cout << "C" << endl;
	return 0;
}

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

//factorial
int fact(int n) {
	int a = 1;
	for (int i = 1;i <= n;i++) a *= i;
	return a;
}

int n, r;
int main(){
	cin >> n >> r;
	if (n < 10)r += 100 * (10 - n);
	cout << r << endl;
}



Measured memory_bytes: 256
#ABC048C
N,x=map(int,input().split())
A=list(map(int,input().split()))
ans=0
for i in range(len(A)-1):
    t=max(0,sum(A[i:i+2])-x)
    ans+=t
    if A[i+1]<t:
        A[i+1]=0
    else:
        A[i+1]-=t
print(ans)

Measured memory_bytes: 14540
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main()
{
    long N, ans = 0;
    cin >> N;
    for (long i = 1; i <= N; i++)
    {
        if (i < 10 | (100 <= i && i < 1000) | (10000 <= i && i < 100000))
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdlib>
#include<cmath>
#include<algorithm>

using namespace std;

int main() {
	int N;
	while(1) {
		cin >> N;
		if(N==0) break;

		int point[N][2];
		point[0][0] = 0;
		point[0][1] = 0;
		for(int i=1; i<N; i++) {
			int n, d;
			cin >> n >> d;
			if(d==0) {
				point[i][0] = point[n][0] - 1;
				point[i][1] = point[n][1];
			} 
			if(d==1) {
				point[i][0] = point[n][0];
				point[i][1] = point[n][1] - 1;
			} 
			if(d==2) {
				point[i][0] = point[n][0] + 1;
				point[i][1] = point[n][1];
			} 
			if(d==3) {
				point[i][0] = point[n][0];
				point[i][1] = point[n][1] + 1;
			} 
		}

		int x[2], y[2];
		x[0] = 0;
		x[1] = 0;
		y[0] = 0;
		y[1] = 0;

		for(int i=1; i<N; i++) {
			if(point[i][0] < x[0]) x[0] = point[i][0];
			if(point[i][0] > x[1]) x[1] = point[i][0];
			if(point[i][1] < y[0]) y[0] = point[i][1];
			if(point[i][1] > y[1]) y[1] = point[i][1];
		}

		cout << x[1] - x[0] + 1 << ' ' << y[1] - y[0] + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 1164
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let mut alock = false;
    let mut aidx = 0;
    let mut zidx = 0;

    for (i, v) in s.chars().enumerate() {
        if v == 'A' && !alock {
            aidx = i;
            alock = true;
        }
        if v == 'Z' {
            zidx = i
        }
    }
    println!("{}", zidx - aidx + 1);
}


Measured memory_bytes: 4352
import math

def lcm(a, b):
    return (a * b) // math.gcd(a, b)
def div2(n):
    return bin(n)[::-1].find("1")

n, m = map(int, input().split())
a = list(map(int, input().split()))
ans = a[0]
count = div2(a[0])
for i in range(1, len(a)):
    if count != div2(a[i]):
        print(0)
        exit()
    ans = lcm(ans, a[i])
ans //= 2
print((m // ans + 1) // 2)

Measured memory_bytes: 84792
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

class Main {
	public static void main(String args[]) throws IOException {
		@SuppressWarnings("resource")
		Scanner cin = new Scanner(System.in);
		ArrayList<String> inLines = new ArrayList<String>();
		for (; cin.hasNext();) {
			inLines.add(cin.nextLine());
		}
		Solver solver = new Solver();
		solver.solve(inLines);
	}
}

class Solver {

	public void solve(ArrayList<String> inLines) {
		int N = Integer.parseInt(inLines.get(0));
		String[] strArr = inLines.get(1).split(" ");
		boolean ans = true;
		for (int i = 0; i < N; i++) {
			if (Long.parseLong(strArr[i]) % 2 == 1)
				ans = !ans;
		}
		if (ans)
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}


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

using namespace std;

using LL = long long;

bool isT(LL a, LL b, LL c) {
    if (a == b || a == c || b == c) return false;
    return (a + b > c) && (a + c > b) && (b + c > a);
}

void solver() {
    int n; cin >> n;
    vector<int> a(n);
    for(int &x : a) cin >> x;

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

    LL ans = 0;

    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j < n; ++j) {
            if (a[i] == a[j]) continue;
            for(int k = j + 1; k < n; ++k) {
                if (a[j] == a[k]) continue;
                ans += isT(a[i], a[j], a[k]);
            }
        }
    }

    cout << ans << '\n';

}

int main() {

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

    int t = 1;
    //cin >> t;
    
    while(t--)
        solver();

    return 0;
}

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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    ll i,j,n,m,k,cnt=0,ans=0,t=1;
    ll a,b,c;
    cin>>a>>b>>c;
    ret(max(0LL,c-(a-b)));    
    
    return 0;
}

Measured memory_bytes: 764
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int a[] = new int[n + 1];
        
        int plus;
        int zeroIndex = -1;
        int maxIndex = n + 1;
        boolean isAdd = false;
        for(int i = 0; i < n + 1; i++){
            a[i] = sc.nextInt();
            if(a[i] >= 0){
                if(isAdd == false){
                    isAdd = true;
                    a[i + 1] = a[i];
                    a[i] = 0;
                    zeroIndex = i;
                    i++;
                }
            }
            if(i == n - 1 && isAdd == false){
                i++;
                a[i] = 0;
                isAdd = true;
                zeroIndex = i;
            }
        }
        
        int start = zeroIndex - k;
        int s = 0;
        if(start < 0){
            s = 0 - start;
            start = 0;
        }
        int left = -a[start];
        int right = a[s + zeroIndex];
        
        int min = left > right ? left + right * 2 : left * 2 + right;
        
        while(true){
            start++;
            if(start > zeroIndex){
                break;
            }
            s++;
            if(zeroIndex + s > maxIndex - 1){
                break;
            }
            left = -a[start];
            right = a[s + zeroIndex];
            
            int total = left > right ? left + right * 2 : left * 2 + right;
            if(total < min){
                min = total;
            }
        }
        
        System.out.println(min);
    }
}


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

using namespace std;

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

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = int(1e9) + 7;

int W[55], B[55], R[55];

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

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

  reps(i, 1, n) {

    W[i] = W[i-1];
    B[i] = B[i-1];
    R[i] = R[i-1];

    string s;
    cin >> s;

    rep(j, m) {
      if (s[j] != 'W') ++W[i];
      if (s[j] != 'B') ++B[i];
      if (s[j] != 'R') ++R[i];
    }

  }

  int minv = INF;
  for (int i = 1; i <= n - 2; ++i) {
    for (int j = i + 1; j <= n - 1; ++j) {
      chmin(minv, W[i] + B[j] - B[i] + R[n] - R[j]);
    }
  }

  cout << minv << "\n";

  return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int N;
	int X;
	int m[999];
	int minAmount;
	int maxQuantity;

	cin >> N >> X;
	maxQuantity = N;

	cin >> m[0];
	X = X - m[0];
	minAmount = m[0];

	for (int i = 1; i < N; i++) {
		cin >> m[i];
		X = X - m[i];
		if (m[i] < minAmount) { 
			minAmount = m[i]; 
		}
	}
	
	while(true) { 		
		if ( X >= minAmount ) {
			X = X - minAmount;
			maxQuantity++;
		}		
		else {
			break;
		}
	}
	
	cout << maxQuantity << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

//??°???????????£??\?????????
VI g[100010];
//???????????\?¬???°?????????
int h[100010];
signed main(void)
{
  //????????°v???????????°e
  int v, e;
  cin >> v >> e;
  REP(i, e) {
    int s, t;
    cin >> s >> t;
    s--, t--;
    //??????s????????????t???????????????
    g[s].push_back(t);
    h[t]++;
  }

  //??\?¬???°???0??????????????????
  stack<int> st;

  int only = 1;
  //??\?¬???°???0???????????§????????°st?????????
  REP(i, v) if(h[i] == 0) st.push(i);
  if(st.size() >= 2) only = 0;

  //??????????????????????????°??????
  VI ans;
  //st????????????????????§?????????
  while(st.size()) {
    //st????????????????????????????????????
    int i = st.top(); st.pop();
    ans.push_back(i);
    int cnt = 0;
    for(auto& j: g[i]) {
      //??£??\?????????????????\?¬???°???????????????1
      h[j]--;
      //??????????????£?????\?¬???°???0???????????°st?????????
      if(h[j] == 0) st.push(j), cnt++;
    }
    if(cnt >= 2) only = 0;
  }

  //ans???????????????
  for(int i: ans) cout << i+1 << endl;
  cout << !only << endl;

  return 0;
}

Measured memory_bytes: 6040
#include <stdio.h>
#include <math.h>

typedef struct {
  double x;
  double y;
} point;

int kock(int n, point p1, point p2) {
  point s, u, t;
  double rad = 60 * M_PI / 180;

  if (n == 0) return n;
  else {
    s.x = (2.0 * p1.x + 1.0 * p2.x) / 3.0;
    s.y = (2.0 * p1.y + 1.0 * p2.y) / 3.0;
    t.x = (1.0 * p1.x + 2.0 * p2.x) / 3.0;
    t.y = (1.0 * p1.y + 2.0 * p2.y) / 3.0;
    u.x = (t.x - s.x) * cos(rad) - (t.y - s.y) * sin(rad) + s.x;
    u.y = (t.x - s.x) * sin(rad) + (t.y - s.y) * cos(rad) + s.y;

    kock(n-1, p1, s);
    printf("%f %f\n", s.x, s.y);
    kock(n-1, s, u);
    printf("%f %f\n", u.x, u.y);
    kock(n-1, u, t);
    printf("%f %f\n", t.x, t.y);
    kock(n-1, t, p2);

    return n;
  }
}

int main() {
  int n;
  point p1, p2;

  p1.x = 0.0;
  p1.y = 0.0;
  p2.x = 100.0;
  p2.y = 0.0;

  scanf("%d", &n);

  printf("%f %f\n", p1.x, p1.y);
  kock(n, p1, p2);
  printf("%f %f\n", p2.x, p2.y);

  return 0;
}

Measured memory_bytes: 636
# include"stdio.h"
int main(){
  long k,a,b,bis=1,money=0;
  scanf("%ld %ld %ld",&k,&a,&b);
  if(a<b&&b-a!=1){
      for(int i=0;i<k;i++){
          if(money){
            money--;
            bis+=b;
            continue;
          }
          if(bis<a||i==k-1)   bis++;
          else{
            bis=bis-a;
            money++;
          }
      }
  }
  else if((a<b&&b-a==1)||a>b||a==b){
    for(int i=0;i<k;i++)
         bis++;
  }

  printf("%ld\n",bis);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  auto pw = [](long long x) { return x * x * x * x * x; };
  long long X;
  cin >> X;
  auto solve = [&]() {
    for (long long A = 1; pw(A) - pw(A - 1) <= X; A++) {
      long long tmp = pw(A) - X;
      int sgn = tmp > 0 ? 1 : -1;
      for (long long B = 0; pw(B) <= abs(tmp); B++) {
        if (pw(B) * sgn == tmp) return make_pair(A, B * sgn);
      }
    }
    return make_pair(0ll, 0ll);
  };
  long long A, B;
  tie(A, B) = solve();
  cout << A << " " << B << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

struct RollingHash {
    static const int base1 = 1007, base2 = 2009;
    static const int mod1 = 1000000007, mod2 = 1000000009;
    vector<long long> hash1, hash2, power1, power2;

    // construct
    RollingHash(const string &S) {
        int n = (int)S.size();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        power1.assign(n+1, 1);
        power2.assign(n+1, 1);
        for (int i = 0; i < n; ++i) {
            hash1[i+1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i+1] = (hash2[i] * base2 + S[i]) % mod2;
            power1[i+1] = (power1[i] * base1) % mod1;
            power2[i+1] = (power2[i] * base2) % mod2;
        }
    }
    
    // get hash of S[left:right]
    inline pair<long long, long long> get(int l, int r) const {
        long long res1 = hash1[r] - hash1[l] * power1[r-l] % mod1;
        if (res1 < 0) res1 += mod1;
        long long res2 = hash2[r] - hash2[l] * power2[r-l] % mod2;
        if (res2 < 0) res2 += mod2;
        return {res1, res2};
    }

    // get lcp of S[a:] and T[b:]
    inline ll getLCP(ll a, ll b) const {
        ll len = min((ll)hash1.size()-a, (ll)hash1.size()-b);
        ll low = 0, high = len;
        while (high - low > 1) {
            ll mid = (low + high) >> 1;
            if (get(a, a+mid) != get(b, b+mid)) high = mid;
            else low = mid;
        }
        return low;
    }
};

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

  ll n;
  string s;
  cin >> n >> s;

  RollingHash r(s);
  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    for (ll j = i+1; j < n; j++) {
      if (cmax(ans, min(j-i, r.getLCP(i, j)))) {
        //cout << i << " " << j << endl;
      }
    }
  }
  cout << ans << endl;
}


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	int h[n+1];
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
	}
	int dp[n+1];
	dp[1] = 0;
	dp[2] = abs(h[2] - h[1]);
	for (int i = 3; i <= n; i++) {
		dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]));
	}
	cout << dp[n] << "\n";
	
	return 0;
}


Measured memory_bytes: 1024
h, w = map(int, raw_input().split())
a = []
for i in range(h):
	tmp = '#' + str(raw_input()) + '#'
	a.append(tmp)
tmp1 = ['#' * (w + 2)]
a = tmp1 + a + tmp1
for i in range(h + 2):
	print a[i]

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

#define all(n) n.begin(),n.end()
#define ll long long

#define pb push_back
#define eb emplace_back
#define endl "\n"
#define pll pair<ll,ll>
#define ff first
#define ss second

using namespace std;
const ll maxn=2e5+20;
const ll maxx=1e16;
const ll mod=1e9+7;
const ll mod1=998244353;

ll n, m,k ;
ll ax[5]={-1,1,0,0};
ll ay[5]={0,0,-1,1};
unordered_map<ll,unordered_map<ll,ll>> dd;
unordered_map<ll,unordered_map<ll,ll>> dp;
unordered_map<ll,unordered_map<ll,ll>> dp1;
unordered_map<ll,unordered_map<ll,char>> a;

bool chk(ll x ,ll y)
{

    if (x<1||x>n) return false;
    if (y<1||y>m) return false;
  //  if (dd[x][y]) return false;
    if (a[x][y]=='@') return false;
    return true;
}
void dosth(ll x, ll y )
{
   queue<pll> q;
  if (chk(x,y)) q.push(make_pair(x,y));
   dd[x][y]=1;
   dp[x][y]=0;
   while (!q.empty())
   {
     auto p= q.front();
     q.pop();
     //if ()
     for (int i=3;i>=0;i--)
     {
         for (int j=1;j<=k;j++)
         {
             ll x1=p.ff+ax[i]*j;
             ll y1=p.ss+ay[i]*j;
             if (!chk(x1,y1)) break;

            // if (dd[x1][y1]) continue;
            // dd[x1][y1]=1;
             if (dp[x1][y1]>dp[p.ff][p.ss]+1)
             {
                 dp[x1][y1]=dp[p.ff][p.ss]+1;
                 q.push(make_pair(x1,y1));
             }
             else if (dp[x1][y1]==dp[p.ff][p.ss]+1)continue;
                else break;
            // q.push(make_pair(x1,y1));
         }
     }
   }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    if (fopen("TEAMS.INP","r"))
    {
        freopen("TEAMS.INP", "r", stdin);
        freopen("TEAMS.OUT", "w", stdout);
    }
    cin>>n>>m >>k;
    ll x, y ,x1,y1;
    cin>>x>>y>>x1>>y1;
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=m;j++)
        {
            char x;
             cin>>x;

            a[i][j]=x;
            dp[i][j]=1e15;
        }
    }

    dosth(x,y);
    ll h= 1e15;
    if (dp[x1][y1]==1e15)
    {
        cout <<-1;
        return 0;
    }
   cout <<dp[x1][y1];
/*2 3
4
1 1 2 3
..@
...
@..*/




}


Measured memory_bytes: 91448
function Main(input) {
  var len = parseInt(input.split("\n")[0]);
  input = input.split("\n")[1].split(" ");
  input.sort(function (a,b){
  	return parseInt(a) - parseInt(b);
  });
  //console.log(input);
  var getPosition = len / 2 - 1;
  var minNannido = parseInt(input[len / 2 - 1]);
  var maxNannido = parseInt(input[len / 2]);
  console.log(maxNannido - minNannido);
}

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


Measured memory_bytes: 19512
N=int(input())
A=list(map(int,input().split()))

check=1
ans=0

ans_flag=False

for a in A:
    if a==check:
        ans_flag=True
        check += 1
        
    else:
        ans += 1
        
if ans_flag == False:
    ans=-1
    
print(ans)

Measured memory_bytes: 100240
//Practice more and more
//learn for better
#define bn begin()
#define en end()
#define mx 1000010
#define pb push_back
#define PI (2.0*acos(0.0))
#define ALL(a) a.begin(),a.end()
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rep(a,b) for(int a=0;a<b;++a)
#define fastio ios::sync_with_stdio(false)
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int>  vi;
typedef vector<ll> vll;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
	int a,b,n,i,j,t,tmp;
	cin>>n;
	vi v,v1(mx,0);
	for(i=0;i<n;i++)
	{
		cin>>a;
		v.pb(a);
	}
	sort(ALL(v));
	for(i=0;i<n;i++)
	{
		tmp=v[i];
		for(j=tmp;j<=v[n-1];j+=tmp)
		v1[j]++;
	}
	ll cnt=0;
	for(i=0;i<n;i++)
{
	// cout<<v[i]<<" "<<v1[v[i]]<<endl;
	if(v1[v[i]]==1)
	cnt++;
}
cout<<cnt<<endl;
//	cout<<"Prodip";


	return 0;
}

Measured memory_bytes: 8172
def calc_sum(n):
    total = 0
    while n>0:
        #print(n//10, n % 10)
        total += n % 10
        n //= 10
        
    return total
        
while  True:
    n = int (input())
    result = 0
    
    if n == 0:
       break
    else:
        print (calc_sum(n))


Measured memory_bytes: 5600
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

  ll N ;cin >> N;
  vector<ll> A;

  rep(i,N){
    ll inp;cin >> inp;
    A.pb(inp);
  }
  if(N <= 2){
    cout << 1 << endl;
    return 0;
  }
  
  int flag ;// 1: +, -1: -, 0: same
  ll ans = 0;
  ll cnt = 0;
  rep(i,N){
    if(cnt == 0){
      ans ++;
      if(i == N-1) break;
      i++;
      if(A[i-1] == A[i]) flag = 0;
      else if(A[i-1] < A[i]) flag = 1;
      else if(A[i-1] > A[i]) flag = -1;
      cnt = 2;
    }
    if(flag == 0){
      if(A[i] == A[i-1]) continue;
      else if(A[i-1] < A[i]) {flag = 1;continue;}
      else if(A[i-1] > A[i]) {flag = -1; continue;}
    }
    
    if(((flag == 1) && (A[i-1] > A[i])) || ((flag == -1) && (A[i-1] < A[i]))){
      ans ++;
      if(i == N-1) break;
      i++;
      if(A[i-1] == A[i]) flag = 0;
      else if(A[i-1] < A[i]) flag = 1;
      else if(A[i-1] > A[i]) flag = -1;
      cnt = 2;
    }
    
  }
  cout << ans << endl;
  

  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 1400
a,b,c,x,y=map(int,input().split())
ans=1e10
for i in range(0,2*max(x,y)+1,2):
  d=c*i+max(0,x-i//2)*a+max(0,y-i//2)*b
  ans=min(d,ans)
print(ans)
  

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif
 
//#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
#define N 10
#define B 1
#define W -1
int n, m, p;
int cube[N][N][N];
int h[N][N];
int dx[] = {1, 0, 0, 1, -1, 0, 0, 1, -1, 1, -1, 1, -1};
int dy[] = {0, 1, 0, 1, 1, 1, -1, 0, 0, 1, 1, 1, 1};
int dz[] = {0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, -1, -1};
 
int inrange(int x, int y, int z) {
  return 0 <= x&&x < n && 0 <= y&&y < n && 0 <= z&&z < n;
}
int check() {
  rep(i, 0, n) rep(j, 0, n) rep(k, 0, n) {
    rep(l, 0, 13) {
      map<int, int> color;
      rep(u, 0, m) {
        int x = i + u * dx[l], y = j + u * dy[l], z = k + u * dz[l];
        if (inrange(x, y, z))
          color[cube[x][y][z]]++;
      }
      if (color[B] == m)
        return B;
      else if (color[W] == m)
        return W;
    }
  }
  return 0;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  while (cin >> n >> m >> p, n && m && p) {
    memset(cube, 0, sizeof(cube));
    memset(h, 0, sizeof(h));
    int winner = 0;
    int fin = 0;
    for (int i = 0; i < p; i++) {
      int x, y;
      cin >> x >> y;
      x--,y--;
      if (i & 1)
        cube[x][y][h[x][y]++] = W;
      else
        cube[x][y][h[x][y]++] = B;
 
      if (winner == 0) {
        winner = check();
        fin++;
      }
    }
    if (winner == 1)
      cout << "Black " << fin << endl;
    else if (winner == -1)
      cout << "White " << fin << endl;
    else
      cout << "Draw" << endl;
  }
 
  return 0;
}

Measured memory_bytes: 3136
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
using ll = long long;

using namespace std;
int main()
{/*三日目*/
//少数も使いたい割り算はしない方がいい(三日目）
// 数値の大きさ
	long a; cin >> a;
	int k; cin >> k;
	bool ok = true;
	int sum = 1;
	int zyo=k;
	while (ok) {
		if (a >= zyo) {
			sum++;
		}
		else
			ok = false;
		zyo *= k;


	}cout << sum;

}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
const int MAXN = 1001010;
char ch[MAXN];
int cnt[MAXN], n, p, sum;
int main(){
    scanf("%s", ch+1);
    n = strlen(ch+1);
    int ans = MAXN;
    for(int i = 1; i <= n; i ++){
        if(ch[i] != ch[i-1])
            p ++;
        cnt[p] ++;
    }
    for(int i = 1; i <= p; i ++){
        sum += cnt[i];
        int tem = max(n-sum, sum);
        ans = min(ans, tem);
        //printf("%d %d\n", cnt[i], sum);
        //printf("%d\n%d %d \n", cnt[i], sum, n - sum);
    }
    
    printf("%d", ans);
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c,d;
bool i[100];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,w;
  cin >>a>>b;
  lol x=a*b;
  if(a<b) swap(a,b);
  lol r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  cout <<x/b<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

int main(){
	int n; cin >> n;
	vector<ll> A;
	rep(i,n){
		ll a; cin >> a;
		A.push_back(a);
	}
	// ll ans[n];
	// rep(i,n) ans[i]=0;
	// rep(i,n){
	// 	ll r = A[i];
	// 	rep(j,n){
	// 		ans[min(i+j, (i+j)%n)] += r;
	// 		r *= -1;
	// 	}
	// }
	// cout << ans[n-1] << ' ';
	// rep(i,n-1){
	// 	cout << ans[i] << ' ';
	// }
	ll ans = 0;
	int flp = 1;
	rep(i,n){
		ans += A[i]*flp;
		flp *= -1;
	}
	rep(i,n){
		cout << ans << ' ';
		ans *= -1;
		ans += 2*A[i];
	}


	cout << endl;
	return 0;
}


Measured memory_bytes: 2164
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class ABC169
{
    static void Main()
    {
        //int A = 198;
        //double B = 1.10;
        //dynamic ans = A * B;
        //long[] num_array = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        string[] num_array = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
        decimal A = decimal.Parse(num_array[0]);
        decimal B = decimal.Parse(num_array[1]);

        //double ans = Math.Floor(A * B);
        Console.WriteLine(Math.Floor(A * B));
        //System.Diagnostics.Debug.WriteLine(Math.Floor(A * B));
    }
}

Measured memory_bytes: 27496
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<bits/extc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vector<ll>>;
const ll mod = 1e9 + 7;
using oset = tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 5e4 + 3;

int main() {
//	ios::sync_with_stdio(0);
//	cin.tie(0);
//	cout.tie(0);
	ll n;
	vector<pair<ll, ll>> x, xx;
	cin >> n;
	ll L = 0, R = 1e9, ans = 0;
	x.resize(n);
	multiset<ll> gg;
	for(auto &i : x) {
		cin >> i.first >> i.second, i.second++;
		L = max(L, i.first);
		R = min(R, i.second);
		ans = max(ans, i.second-i.first);
		gg.insert(i.second);
//		i.second *= -1;
	}
	ans += max(0ll, R-L);
	sort(all(x));
//	for(auto &i : x) i.second*=-1;
	ll tans = 0;
	for(int i = 0; i+1 < n; i++) {
		gg.erase(gg.find(x[i].second));
		tans = max(tans, max(0ll, R-x[i].first) + max(0ll, (*gg.begin())-L));
	}
	cout << max(ans, tans) << '\n';
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int printDivisibleNumber(int arr[], int n){
   unordered_set<int> s;
   int maxElement = INT_MIN;
   for (int i = 0; i < n; i++) {
      s.insert(arr[i]);
      maxElement = max(maxElement, arr[i]);
   }
   unordered_set<int> res;
   for (int i = 0; i < n; i++) {
      if (arr[i] != 0) {
         for (int j = arr[i] * 2; j <= maxElement; j += arr[i]) {
            if (s.find(j) != s.end())
               res.insert(j);
            }
         }
      }
   unordered_map<int, int> mp;
   for (int i = 0; i <n; i++)
      mp[arr[i]]++;
   unordered_map<int, int>::iterator it;
   vector<int> ans;
   for (it = mp.begin(); it != mp.end(); it++) {
      if (it->second >= 2) {
         if (res.find(it->first) == res.end()) {
            int val = it->second;
            while (val--)
               ans.push_back(it->first);
         }
      }
      if (res.find(it->first) != res.end()) {
         int val = it->second;
         while (val--)
            ans.push_back(it->first);
      }
   }
   int count=0;
   for (auto x : ans)
      count++;
   return count;
}
int main(){
   int n;
   cin >> n;
   int arr[n];
   for(int i=0;i<n;i++)
      cin >> arr[i];
   int ans=printDivisibleNumber(arr, n);
   cout << n-ans << "\n";
   return 0;
}

Measured memory_bytes: 30532
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
a = LIST()
arr = [0 for _ in range(n + 1)]
arr[1] = a[0]
for i in range(2, n + 1):
    arr[i] = arr[i - 1] + a[i - 1]
arr2= Counter(arr)
arr3 = list(set(arr))
ans = 0
for i in range(len(arr3)):
    ans += arr2[arr3[i]] * (arr2[arr3[i]] - 1) // 2
print(ans)


Measured memory_bytes: 49224
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE


void solve(void)
{
  string str;
  cin>>str;
  int A = 0,B = 0;
  for (int i = 0; i < str.size(); i++)
  {
    if(str[i] == '+')A++;
    else A--;
    
  }
  cout<<A<<endl;
  


  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int find_index(string s, string t) {
	auto judge = [](string& s, string& t, int idx) {
		if (s.length() - idx < t.length())
			return false;
		bool res = true;
		for (int i = 0; i < t.length(); ++i) 
			res &= (s[idx + i] == t[i] || s[idx + i] == '?');
		return res;
	};
	for (int i = s.length() - 1; i >= 0; --i)
		if (judge(s, t, i))
			return i;
	return -1;
}

int main(void) {
	string S, T; cin >> S >> T;
	int idx = find_index(S, T);
	if (idx == -1) cout << "UNRESTORABLE" << endl;
	else {
		for (int i = 0; i < idx; ++i) {
			if (S[i] == '?') cout << 'a';
			else cout << S[i];
		}
		cout << T;
		for (int i = idx + T.length(); i < S.length(); ++i) {
			if (S[i] == '?') cout << 'a';
			else cout << S[i];
		}
		cout << endl;
	}
	return 0;
} 

Measured memory_bytes: 3616
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner (System.in);
        //ますの数
        int n=sc.nextInt();
        //料金所の数
        int m=sc.nextInt();
        int x=sc.nextInt();
        int down=0;
        int up=0;
        for(int i=1;i<m+1;i++){
           if(sc.nextInt()>x) up++;
           else down++;
        }
        if(down<up) System.out.println(down);
        else System.out.println(up);

        
        

    }
}

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

bool g[maxn+5][maxn+5];
int dx[4]={0,1,0,-1};
int dy[4]={-1,0,1,0};
int ans=0;
int h,w;

bool check(int y,int x){
    return (0<=y&&y<h&&0<=x&&x<w);
}

void bfs(int sy,int sx){
    int d[maxn+5][maxn+5];
    queue<pair<int,int>> que;
    que.push(pii(sy,sx));
    rep(i,h){
        rep(j,w){
            d[i][j]=INF;
        }
    }

    d[sy][sx]=0;
    while(!que.empty()){
        pii arg=que.front();que.pop();
        for(int i=0;i<4;i++){
            int ny=arg.first+dy[i];
            int nx=arg.second+dx[i];
            if(check(ny,nx)&&d[ny][nx]==INF&&g[ny][nx]){
                d[ny][nx]=d[arg.first][arg.second]+1;
                que.push(pii(ny,nx));
            }
        }
    }

    rep(i,h){
        rep(j,w){
            if(g[i][j])ans=max(ans,d[i][j]);
        }
    }

    return;
}

int main(){
    cin >> h>>w;
    rep(i,h){
        rep(j,w){
            char c;
            cin >> c;
            if(c=='.'){
                g[i][j]=true;
            }else{
                g[i][j]=false;
            }
        }
    }

    rep(i,h){
        rep(j,w){
            if(g[i][j])bfs(i,j);
        }
    }

    cout << ans<<endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int x;
	bool prime = true;
	cin >>x;
	for (int i = x;;i++){
		prime = true;
		for (int c = 2; c <= sqrt(i) and prime ;c++){
			prime &= (i % c!=0);
		}
		if (prime){
			cout << i << endl;
			return 0;
		}
		}
//	cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
using ll = long long;
 
int main(){
	int n;
  	cin >> n;
  	double ans = 2 * n * M_PI;
  	cout << ans << endl;
}

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

int main(){
  while(1){
    int w, q;
    cin >> w >> q;
    if(w==0 & q==0) break;

    bool neko[100];
    for(int i=0;i<100;i++) neko[i]=false;
    int hei[100];
    for(int i=0;i<100;i++) hei[i]=-1;

    for(int i=0;i<q;i++){
      getchar();
      char c;
      cin >> c;
      if(c=='s'){
        int id, nw;
        cin >> id >> nw;
        int size=-1;
        int count=0;
        for(int j=0;j<=w;j++){
          if(j==w){
            if(size<count) size=count;
            if(size>=nw){
              neko[id]=true;
              cout << j-size << endl;
              for(int k=0;k<nw;k++){
                hei[j-size+k]=id;
              }
            }
            break;
          }
          if(hei[j]!=-1){
            if(size<count) size=count;
            if(size>=nw){
              neko[id]=true;
              cout << j-size << endl;
              for(int k=0;k<nw;k++){
                hei[j-size+k]=id;
              }
              break;
            }
            count=0;
          }
          else count++;
        }
        if(neko[id]==false){
          cout << "impossible" << endl;
        }
      }

      else if(c=='w'){
        int id;
        cin >> id;
        for(int i=0;i<100;i++){
          if(hei[i]==id) hei[i]=-1;
        }
      }

    }
    cout << "END" << endl;
  }
  return 0;
}

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

int main(){
    int n,rank;
    char suit;
    int cards[4][14];

    for (int s = 0; s < 4; s++){
        for (int r = 1; r <= 13; r++){
            cards[s][r] = 0;
        }
    }

    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> suit >> rank;
        if (suit == 'S'){
            cards[0][rank] = 1;
        } else if (suit == 'H'){
            cards[1][rank] = 1;
        } else if (suit == 'C'){
            cards[2][rank] = 1;
        }  else if (suit == 'D'){
            cards[3][rank] = 1;
        }
    }

    //cout << "result" << endl;

    for (int s = 0; s < 4; s++){
        for (int r = 1; r <= 13; r++){
            if (cards[s][r] == 1){
                continue;
            } else if (cards[s][r] == 0){
                if (s == 0){
                    suit = 'S';
                } else if (s == 1){
                    suit = 'H';
                } else if (s == 2){
                    suit = 'C';
                } else if (s == 3){
                    suit = 'D';
                }
            }
            cout << suit << " " << r << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3048
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int N,A,B;
    cin >> N >> A >> B;
    if (N * A < B){
        cout << N * A << endl;
    } else {
        cout << B << endl;
    }

    return 0;
}


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

#define X first
#define Y second
typedef pair<int, int> P;
typedef vector<P> vp;


int main() {
	int m, n;
	while(cin >> m && m){
		int x, y;
		vp mstars;
		for(int i = 0; i < m; ++i){
			scanf("%d %d", &x, &y);
			mstars.push_back(P(x, y));
		}
		cin >> n;
		vp nstars;
		for(int i = 0; i < n; ++i){
			scanf("%d %d", &x, &y);
			nstars.push_back(P(x, y));
		}
		sort(mstars.begin(), mstars.end());
		sort(nstars.begin(), nstars.end());
		bool ok = false;
		for(int i = 0; i < n; ++i){
			for(int j = 0; j < m; ++j){
				int dx = nstars[i].X - mstars[j].X;
				int dy = nstars[i].Y - mstars[j].Y;
				for(int k = 0; k < m; ++k){
					if(j == k)
						continue;
					if(!binary_search(nstars.begin(), nstars.end(), P(mstars[k].X + dx, mstars[k].Y + dy)))
						break;
					if(k == m - 1){
						cout << dx << " " << dy << endl;
						ok = true;
					}
				}
				if(ok)
					break;
			}
			if(ok)
				break;
		}
	}
	return 0;
}

Measured memory_bytes: 1264
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int main(){
    ll h;
    cin >> h;
    
    ll f[45];
    f[0]=0;
    f[1]=1;
    reps(i,2,43){
        f[i]=f[i-1]*2+1;
    }
    
    ll k=0;
    while(h){
        h/=2;
        k++;
    }
    cerr<<k<<endl;
    ll ans=pow(2,k-1)+f[k-1];
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 384