akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
string s;
signed main() {
	getline(cin, s);
	for (int i = 0; i < s.size(); i++) {
		if ('a' <= s[i] && s[i] <= 'z') {
			s[i] = (char)(s[i] - 'a' + 'A');
		}
		else if ('A' <= s[i] && s[i] <= 'Z') {
			s[i] = (char)(s[i] - 'A' + 'a');
		}
	}
	cout << s << endl;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

typedef pair<ll,pll> plpl;

vector<ll>par(2e5+10);
map<ll,ll> si;
void init(ll n) {
  for(ll i=0;i<n;i++) {
    par[i]=i;
    si[i]++;
  }
}

ll root(ll x) {
  if(par[x]==x) {
    return x;
  }
  else {
    return par[x]=root(par[x]);
  }
}

ll size(ll x) {
  return si[root(x)];
}

bool same(ll x, ll y) {
  return root(x)==root(y);
}

void unite(ll x, ll y) {
  if(same(x,y)) return;
  ll temp=size(x);
  si[root(y)]+=temp;
  si[root(x)]=0;
  par[root(x)]=root(y);
}

int main() {
  ll n;
  cin >> n;
  init(n);
  vector<pll> x(n);
  vector<pll> y(n);
  for(ll i=0;i<n;i++) {
    ll a,b;
    cin >> a >> b;
    x[i]=pll(a,i);
    y[i]=pll(b,i);
  }
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  priority_queue<plpl,vector<plpl>,greater<plpl>> q;
  for(ll i=0;i<n-1;i++) {
    q.push(plpl(x[i+1].first-x[i].first,pll(x[i].second,x[i+1].second)));
    q.push(plpl(y[i+1].first-y[i].first,pll(y[i].second,y[i+1].second)));
  }
  ll ans=0;
  while(q.size()) {
    ll dis=q.top().first;
    ll a=q.top().second.first;
    ll b=q.top().second.second;
    q.pop();
    if(same(a,b)) continue;
    unite(a,b);
    ans+=dis;
  }
  cout << ans << endl;
}

Measured memory_bytes: 19440
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
const ll MOD=1e9+7;

/*

*/

int main(void){
	ll n,k,a[1010],dp[1010],ans=0;
	dp[0]=0;
	cin>>n>>k;
	reg(i,1,n){
		cin>>a[i];
		dp[i]=dp[i-1]+a[i];
	}
	//上の桁からやっていく
	// cout<<(ll)(1<<40)<<endl;
	ireg(i,0,40){
		ll cnt=0;
		ll tmp=1; //ans+(1<<i)を含んでいるものの個数
		rep(j,i)tmp*=2;
		tmp+=ans;
		// cout<<(i<<i)<<endl;
		// cout<<tmp<<endl;
		reg(i,0,n-1){
			reg(j,i+1,n){
				ll a=(dp[j]-dp[i]);
				if((a|tmp)==a)cnt++;
			}
		}
		if(cnt>=k)ans=tmp;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define vec vector
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << a << endl
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define Yes "Yes"
#define YES "YES"
#define No "No"
#define NO "NO"


const ll mod = 1e9+7;
struct mint {
  ll x;
  mint(ll x=0) : x((x%mod+mod)%mod) {}
  mint &operator+=(const mint &p) { if((x += p.x) >= mod) x -= mod; return *this; }
  mint &operator-=(const mint &p) { if((x += mod - p.x) >= mod) x -= mod; return *this; }
  mint &operator*=(const mint &p) { x = x * p.x % mod; return *this; }
  mint &operator/=(const mint &p) { *this *= p.inverse(); return *this; }
  mint operator-() const { return mint(-x); }
  mint operator+(const mint &p) const { return mint(*this) += p; }
  friend mint operator+(const int &c,const mint &p) { return mint(c) += p; }
  mint operator-(const mint &p) const { return mint(*this) -= p; }
  friend mint operator-(const int &c,const mint &p) { return mint(c) -= p; }
  mint operator*(const mint &p) const { return mint(*this) *= p; }
  friend mint operator*(const int &c,const mint &p) { return mint(c) *= p; }
  mint operator/(const mint &p) const { return mint(*this) /= p; }
  friend mint operator/(const int &c,const mint &p) { return mint(c) /= p; }
  bool operator==(const mint &p) const { return x == p.x; }
  friend bool operator==(const int &c,const mint &p) { return mint(c) == p; }
  bool operator!=(const mint &p) const { return x != p.x; }
  friend bool operator!=(const int &c, const mint &p) { return mint(c) != p; }
  mint inverse() const {
    ll a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return mint(u);
  }
  mint pow(ll n) const {
    mint ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  friend ostream &operator<<(ostream &os,const mint &p) { return os << p.x; }
  friend istream &operator>>(istream &is,mint &a) {
    ll t;
    is >> t;
    a = mint(t);
    return (is);
  }
};


int main() {
  int S;
  cin >> S;
  vec<mint> dp(S+3,0);
  dp[0] = 1;
  rep1(i,S) {
    if (i<3)
      continue;
    rep1(j,i) {
      if (j<3)
        continue;
      dp[i] += dp[i-j];
    }
  }
  print(dp[S]);
  return 0;
}

Measured memory_bytes: 3636
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b[ohara], c[ohara], d, tmp, m, h, w, x, y, sum, k, q,
    R;
ll flo1[3000][3000];

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

  cin >> n >> m >> R;
  vector<ll> r(R);
  rep(i, R) cin >> r[i], r[i]--;
  sort(all(r));
  rep(i, n) {
    rep(j, n) {
      if (i == j)
        flo1[i][j] = 0;
      else
        flo1[i][j] = LINF;
    }
  }
  rep(i, m) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    flo1[a[i]][b[i]] = c[i];
    flo1[b[i]][a[i]] = c[i];
  }
  rep(i, n) {
    rep(j, n) {
      rep(k, n) { flo1[j][k] = min(flo1[j][i] + flo1[i][k], flo1[j][k]); }
    }
  }
  ans = LINF;
  do {
    cnt = 0;
    rep(i, R - 1) { cnt += flo1[r[i]][r[i + 1]]; }
    // debug(cnt);
    ans = min(ans, cnt);
  } while (next_permutation(all(r)));
  Cout(ans);
  return 0;
}

Measured memory_bytes: 13056
N=input()
T=list(map(int,input().split()))
H=list(map(int,input().split()))
count=0
min=1000000
for h in H:
 count=count+1
 if abs(T[0]-0.006*h-T[1])<min:
  ans=count 
  min=abs(T[0]-0.006*h-T[1])
print(ans)

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

ll N;
map<ll, ll> mp;

void prime_decomposition(int n) {
  int i = 2;

  while (i * i <= n) {
    if (n % i == 0) {
      n /= i;
      mp[i]++;
    } else {
      i++;
    }
  }
  mp[n]++;

  return;
}

void solve() {
  ll num2 = 0, num4 = 0, num14 = 0, num24 = 0, num74 = 0;
  ll res = 0;
  if (N == 1) {
    cout << res << "\n";
    return;
  }

  for (int i = 2; i <= N; i++) {
    prime_decomposition(i);
  }

  ll tmp1 = 0, tmp2 = 0, tmp3 = 0, tmp4 = 0;

  for (auto p : mp) {
    for (auto q : mp) {
      if (p.first == q.first) {
        continue;
      }
      if (p.second >= 24 && q.second >= 2) {
        tmp1++;
      }
    }
  }

  for (auto p : mp) {
    for (auto q : mp) {
      if (p.first == q.first) {
        continue;
      }
      if (p.second >= 14 && q.second >= 4) {
        tmp2++;
      }
    }
  }

  for (auto p : mp) {
    if (p.second >= 74) {
      tmp3++;
    }
  }

  for (auto p : mp) {
    for (auto q : mp) {
      for (auto r : mp) {
        if (p.first == q.first || q.first == r.first || r.first == p.first) {
          continue;
        }
        if (p.second >= 4 && q.second >= 4 && r.second >= 2) {
          tmp4++;
        }
      }
    }
  }

  res += (tmp1 + tmp2 + tmp3 + tmp4 / 2);
  cout << res << "\n";
  return;
}

int main() {
  cin >> N;
  solve();
  return 0;
}

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

int main() {
  int K, T;
  cin >> K >> T;
  
  vector<int> a(T);
  int sum = 0;
  for (int& x : a) cin >> x, sum += x;
  
  int ans = 0;
  for (int i = 0; i < T; i++) {
    ans += max(0, a[i] * 2 - sum - 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
let a_s = Array.init (read_int ()) @@ fun _ -> Scanf.scanf " %d" (+) 0
let h = Array.fold_left max 0 a_s
let _ = Array.fold_left (fun b a -> if a < h && abs (a - h / 2) < abs (b - h / 2) then a else b) max_int a_s |> Printf.printf "%d %d\n" h

Measured memory_bytes: 5248
#include<cstdio>
#include<map>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(){
	int n,k,l;cin>>n>>k;
	vector<int> v;
	REP(i,n){
		cin>>l;
		v.push_back(l);
	}
	sort(v.begin(),v.end(),greater<int>());
	int ans = 0;
	REP(i,k) ans += v[i];
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

const int INF = 1e9+5;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    int n;
    cin>>n;
    vector<int>Arr(3);
    for(int day=0; day<n; day++){
        vector<int> curr(3),newArr(3);
        for(int task=0; task<3; task++){
            cin>>curr[task];
            for(int prvTask=0; prvTask<3; prvTask++){
                if(prvTask==task)continue;
                newArr[task]=max(newArr[task],Arr[prvTask]+curr[task]);
            }
        }
        Arr=newArr;
    }

    cout<<max({Arr[0],Arr[1],Arr[2]})<<endl;

    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main(){
  string s;
  int ans;
  cin >> s;
  if (s[0] == '1') ans++;
  if (s[1] == '1') ans++;
  if (s[2] == '1') ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

namespace IntegerMath
{
  int64_t floor_div(int64_t x, int64_t y) {
    return x / y;
  }

  int64_t ceil_div(int64_t x, int64_t y) {
    return (x / y) + std::min(static_cast<int64_t>(1), x % y);
  }

  int64_t sqrt(int64_t x) {
    return static_cast<int64_t>(
      ::floorl( ::sqrtl( 
        static_cast<long double>(x)
      ) )
    );
  }

  int64_t log2(int64_t x) {
    return static_cast<int64_t>(
      ::floorl( ::log2l( 
        static_cast<long double>(x)
      ) )
    );
  }    

  int64_t log10(int64_t x) {
    return static_cast<int64_t>(
      ::floorl( ::log10l( 
        static_cast<long double>(x)
      ) )
    );
  }

  int64_t number_of_digits(int64_t x) {
    return static_cast<int64_t>(
      ::ceill( ::log10l( 
        static_cast<long double>(x + 1)
      ) )
    );
  }

  uint64_t gcd(uint64_t a, uint64_t b)
  {
    uint64_t n = std::min(a, b), m = std::max(a, b);
    return (n == 0) ? m : gcd(m % n, n);
  }

  uint64_t lcm(uint64_t a, uint64_t b)
  {
    uint64_t d = gcd(a, b);
    return (a % d == 0) ? (a / d) * b : a * (b / d);
  }
};

using namespace std;

int main()
{
  uint64_t N, K;
  cin >> N >> K;

  vector<uint64_t> A(N);
  N_TIMES(n, N) { cin >> A[n]; --A[n]; }

  uint64_t log_K = IntegerMath::log2(K) + 1;

  vector<vector<uint64_t>> doubling(log_K + 1, vector<uint64_t>(N, 0));
  N_TIMES(n, N) {
    doubling[0][n] = A[n];
  }

  for (uint64_t i = 0; i < log_K; ++i) {
    N_TIMES(n, N) {
      doubling[i + 1][n] = doubling[i][doubling[i][n]];
    }
  }

  uint64_t next = 0;
  bitset<64> bs(K);
  N_TIMES(b, 64) {
    if (bs[b]) { next = doubling[b][next]; }
  }
  cout << (next + 1) << endl;

  return 0;
}

Measured memory_bytes: 101752
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(12), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N; cin >> N;
    vector<int> A(N), B(N);
    for (auto &a : A) cin >> a;
    for (auto &b : B) cin >> b;
    map<int, int> Ma, Mb;
    for (auto a : A) Ma[a]++;
    for (auto b : B) Mb[b]++;
    set<pair<int, int>> Sa, Sb;
    vector<pair<int, int>> ans;
    for (auto pa : Ma) Sa.emplace(-pa.second, pa.first);
    for (auto pb : Mb) Sb.emplace(-pb.second, -pb.first);
    bool bans = true;
    while (!Sb.empty()) {
        auto [acnt, anum] = *begin(Sa);
        auto [bcnt, bnum] = *begin(Sb);
        Sb.erase(begin(Sb));
        acnt *= -1, bcnt *= -1, bnum *= -1;
        if (bcnt != 1) Sb.emplace(-(bcnt - 1), -bnum);
        if (anum != bnum) {
            ans.emplace_back(anum, bnum);
            Sa.erase(begin(Sa));
            if (acnt != 1) Sa.emplace(-(acnt - 1), anum);
        } else {
            if (Sa.size() == 1) {
                bans = false;
                break;
            }
            auto [acnt2, anum2] = *next(begin(Sa));
            ans.emplace_back(anum2, bnum);
            Sa.erase(next(begin(Sa)));
            acnt2 *= -1;
            if (acnt2 != 1) Sa.emplace(-(acnt2 - 1), anum2);
        }
    }
    if (bans == false) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
        sort(begin(ans), end(ans));
        for (int i = 0; i < ans.size(); i++) {
            cout << ans[i].second << " \n"[i + 1 == ans.size()];
        }
    }
    return 0;
}

Measured memory_bytes: 42260
f=0
while 1:
    try:n=int(input())
    except:break
    if f:print()
    f=1
    a=[['*' for _ in range(5)]for _ in range(8)]
    for i in range(4,-1,-1):
        b=n%10
        a[not b//5][i]=' '
        a[b%5+3][i]=' '
        n//=10
    a[2]='='*5
    for i in a:
        print(''.join(i))

Measured memory_bytes: 7696
#include <iostream>
using namespace std;
int A, B, C, D, E, F; bool dp1[3009], dp2[3009];
int main() {
	cin >> A >> B >> C >> D >> E >> F;
	dp1[0] = true;
	for (int i = 1; i <= F; i++) {
		if (i >= A * 100 && dp1[i - A * 100]) dp1[i] = true;
		if (i >= B * 100 && dp1[i - B * 100]) dp1[i] = true;
	}
	dp2[0] = true;
	for (int i = 1; i <= F; i++) {
		if (i >= C && dp2[i - C]) dp2[i] = true;
		if (i >= D && dp2[i - D]) dp2[i] = true;
	}
	int rp = 0, rq = A * 100;
	for (int i = 0; i <= F; i++) {
		for (int j = 0; j <= F - i; j++) {
			if (dp1[i] && dp2[j] && (100 + E) * j <= E * (i + j) && rp * (i + j) < rq * j) {
				rp = j; rq = i + j;
			}
		}
	}
	cout << rq << ' ' << rp << endl;
	return 0;
}

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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> v(N);
    vector<vector<int64_t>> a(1e+5+1,vector<int64_t>(2,0)),b(1e+5+1,vector<int64_t>(2,0));
    for ( int64_t i = 0; i < N; ++i){
        cin >> v[i];
        if ( i % 2 == 0 ){
            a[v[i]][0] = a[v[i]][0] + 1;
            a[v[i]][1] = v[i];
        } else {
            b[v[i]][0] = b[v[i]][0] + 1;
            b[v[i]][1] = v[i];
        }
    }
    
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    
    int64_t amaxnum = a[0][0], amax = a[0][1];
    int64_t amaxnum2 = a[1][0];
    int64_t bmaxnum = b[0][0], bmax = b[0][1];
    int64_t bmaxnum2 = b[1][0];
    
    int64_t ans = 0;
    if ( amax != bmax ){
        ans = N - amaxnum - bmaxnum;
    } else {
        ans = min(N - amaxnum2 - bmaxnum, N - amaxnum - bmaxnum2);
    }
    
    cout << ans << endl;
    
    
    return 0;
}


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

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

ostream& operator<<(ostream &out, const pii &a) { return out << '(' << a.x << ", " << a.y << ')'; }
istream& operator>>(istream &in, pii &a) { return in >> a.x >> a.y; }

const int INF = 2147483647;
const ll LLINF = 9223372036854775807LL;

const int maxV = 1e5;

// lambda-expression: [] (args) -> retType { body }

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// cerr << boolalpha;
	(cout << fixed).precision(10);

	int N;
	cin >> N;
	vi cnt(maxV, 0);
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		cnt[a]++;
	}

	int best = cnt[0] + cnt[1] + cnt[2];
	int cur = best;
	int it = 1;
	while (it + 2 < maxV) {
		cur -= cnt[it - 1];
		it++;
		cur += cnt[it + 1];
		best = max(best, cur);
	}
	cout << best << endl;
	return 0;
}

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

int main()
{
    int n;
	int w[10]={1,2,4,8,16,32,64,128,256,512};
	int start;
	while(1){
		cin >> n;
		if(cin.eof()){break;}
		int	flag[10]={0};
		start=0;

		// n - w[i] で引けた配列番号を flag[i] で記憶

		for(int i=9 ; i>=0; i--){
			if(n>=w[i]){
				n-=w[i];
				flag[i]++;
				start=i;
			}
		}

		// flag[i] が 0 でなければ w[i] を表示

		cout << w[start];
		for(int i=start+1; i<=9 ; i++){
			if(flag[i]!=0){
				cout << " " << w[i];
			}
		}
		
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int n,pre[N],deg[N],q[N],size,vis[N],C,ans[N];
vector<int> e[N];
bool test(int x){
	q[size=1]=x;
	for (int i=1;i<=size;i++){
		int v=q[i];
		C++;
		for (int j=0;j<e[v].size();j++) vis[ans[e[v][j]]]=C;
		while (vis[ans[v]]==C) ans[v]++;
		if (!--deg[pre[v]]) q[++size]=pre[v];
	}
	for (int i=1;i<=n;i++){
		C++;
		for (int j=0;j<e[i].size();j++) vis[ans[e[i][j]]]=C;
		int Ans=0;
		while (vis[Ans]==C) Ans++;
		if (Ans!=ans[i]) return 0;
	}
	return 1;
}
int circle;
void find_cir(int x){
	static int vis[N],C;C++;
	while (!vis[x]) vis[x]=C,x=pre[x];
	if (vis[x]==C) circle=x;
}
int Deg[N],Ans[N];
void work(){
	for (int i=1;i<=n;i++) find_cir(i);
	int x=circle;
	for (int i=1;i<=n;i++) Deg[i]=deg[i],Ans[i]=ans[i];
	C++;
	for (int i=0;i<e[x].size();i++) if (!deg[e[x][i]]) vis[ans[e[x][i]]]=C;
	while (vis[ans[x]]==C) ans[x]++;
	deg[pre[x]]--;deg[x]--;
	if (test(pre[x])) return;
	for (int i=1;i<=n;i++) deg[i]=Deg[i],ans[i]=Ans[i];
	C++;
	for (int i=0;i<e[x].size();i++) if (!deg[e[x][i]]) vis[ans[e[x][i]]]=C;
	while (vis[ans[x]]==C) ans[x]++;
	for (ans[x]++;vis[ans[x]]==C;ans[x]++);
	deg[pre[x]]--;deg[x]--;
	if (!test(pre[x])) puts("IMPOSSIBLE"),exit(0);
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&pre[i]),e[pre[i]].push_back(i);
	for (int i=1;i<=n;i++) deg[i]=e[i].size();
	for (int i=1;i<=n;i++) if (!deg[i]) q[++size]=i;
	for (int i=1;i<=size;i++){
		int v=q[i];
		C++;
		for (int j=0;j<e[v].size();j++) vis[ans[e[v][j]]]=C;
		while (vis[ans[v]]==C) ans[v]++;
		if (!--deg[pre[v]]) q[++size]=pre[v];
	}
	if (size!=n) work();
	puts("POSSIBLE");
	return 0;
}

Measured memory_bytes: 16384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

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

    string s; cin >> s;
    set<char> chars;
    rep(k, sz(s)) chars.insert(s[k]);
    if (chars.size()==1) {
        cout << 0 << endl;
        return 0;
    }
    int ans = INF;
    int n = sz(s);
    rep(i, 26) {
        char c = 'a'+i;
        if (!chars.count(c)) continue;
        int cnt = 0;
        string t = s;
        debug(t);
        rep(j, n/2+1) {
            int del; 
            rep(k, sz(t)) {
                if ((k<sz(t)-1&&t[k]!=c&&t[k+1]!=c) || k==sz(t)-1) del = k;
                if (k<sz(t)-1 && t[k+1]==c) t[k] = c;
            }
            t.erase(t.begin()+del);
            debug(c, t);
            set<char> st;
            rep(k, sz(t)) st.insert(t[k]);
            cnt++;
            if (st.size()==1) break;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import queue
def search(sy,sx):
    global H,W,Maze
    q = queue.Queue()

    Visit = [[-1]*W for _ in range(H)]
    Dir = [[0,1],[0,-1],[1,0],[-1,0]]

    Visit[sy][sx] = 0 
    q.put([sy,sx])

    while not q.empty():
        ty,tx = q.get()
        path = Visit[ty][tx]

        for dy,dx in Dir:
            ny = ty + dy
            nx = tx + dx
            if 0 <= ny and ny < H and 0 <= nx and nx < W:
                if Maze[ny][nx] == '.':
                    if Visit[ny][nx] == -1:
                        Visit[ny][nx] = path+1
                        q.put([ny,nx])
    max1 = 0
    for h in range(H):
        for w in range(W):
            max1 = max(max1,Visit[h][w])
    return max1

H,W = map(int,input().split())
Maze = []
for h in range(H):
    Maze.append(input())

ans = 0
for sy in range(H):
    for sx in range(W):
        if Maze[sy][sx] == '#':
            continue
        p = search(sy,sx)          
        if p > 0:
            ans = max(ans,p)
print(ans)


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> G[N];
    REP(i, M)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<ll> michishirube(N, -1);
    queue<ll> q;
    vector<bool> isVisited(N, false);
    vector<bool> isAdd(N, false);
    q.push(0);
    isAdd[0] = true;
    while(!q.empty())
    {
        ll p = q.front();
        q.pop();
        isVisited[p] = true;
        REPV(it, G[p])
        {
            if (!isVisited[*it] && !isAdd[*it])
            {
                q.push(*it);
                isAdd[*it] = true;
                if (michishirube[*it] == -1)
                {
                    michishirube[*it] = p;
                }
            }
        }
    }

    cout << "Yes" << endl;
    for (ll i = 1; i < N; ++i)
    {
        cout << michishirube[i] + 1 << endl;
    }
}


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

using namespace std;

const int max_n = -1, mod = 1000000007;

int n, k;
bool zero;
vector<int> a, b;

int mul(int x, int y) {
    return 1LL * x * y % mod;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        if (!x) {
            zero = 1;
            continue;
        }
        if (x > 0) {
            a.push_back(x);
        } else {
            b.push_back(-x);
        }
    }
    bool ok = false;
    for (int i = 0; i <= b.size(); i += 2) {
        if (i <= k && k <= i + a.size()) {
            ok = 1;
        }
    }
    if (ok) {
        int ca = k;
        if (ca > a.size()) {
            ca = a.size();
            if ((k - ca) % 2) {
                --ca;
            }
        }
        sort(a.begin(), a.end());
        reverse(a.begin(), a.end());
        sort(b.begin(), b.end());
        reverse(b.begin(), b.end());
        int pos = k - ca;
        while (ca >= 2 && pos + 1 < b.size()) {
            long long p1 = 1LL * a[ca - 1] * a[ca - 2];
            long long p2 = 1LL * b[pos] * b[pos + 1];
            if (p2 > p1) {
                ca -= 2;
                pos += 2;
            } else {
                break;
            }
        }
        //cout << ca << " " << pos << endl;
        int ans = 1;
        for (int i = 0; i < ca; ++i) {
            ans = mul(ans, a[i]);
        }
        for (int i = 0; i < pos; ++i) {
            ans = mul(ans, b[i]);
        }
        printf("%d\n", ans);
    } else if (zero) {
        puts("0");
    } else {
        int ans = 1;
        if (k == n) {
            for (int x : a) {
                ans = mul(ans, x);
            }
            for (int x : b) {
                ans = mul(ans, mod - x);
            }
        } else if (a.empty()) {
            assert(k % 2);
            sort(b.begin(), b.end());
            for (int i = 0; i < k; ++i) {
                ans = mul(ans, mod - b[i]);
            }
        } else {
            assert(false);
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 4392
#include<stdio.h>

int main() {
   int i,j,n,m,tmp;
   double sum = 0,count = 0;
   int a[1000];
   scanf("%d %d",&n,&m);
   for(i = 0;i < n;i++) {
     scanf("%d",&a[i]);
     sum += a[i];
   }
   for(i = 0;i < n;i++) {
     for(j = i;j < n;j++) {
       if(a[i] < a[j]) {
         tmp = a[i];
         a[i] = a[j];
         a[j] = tmp;
       }
     }
   }
   for(i = 0;i < m;i++) {
     if(a[i] >= sum/(4*m)) {
       count++;
     }
   }
   if(count == m) {
     printf("Yes\n");
   } else {
     printf("No\n");
   }

}


Measured memory_bytes: 128
n = int(input())
h = list(map(int, input().split()))

dp = [float("inf")] * n
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, n):
    one = abs(h[i] - h[i-1]) + dp[i-1]
    two = abs(h[i] - h[i-2]) + dp[i-2]
    dp[i] = min(one, two)
print(dp[n-1])

Measured memory_bytes: 52208
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn min(a: i64, b: i64) -> i64 {
    if a < b {a} else {b}
}

fn main() {
    input!{
        n: i64,
        a: i64,
        b: i64,
        c: i64,
        d: i64,
        e: i64,
    }
    let min_val = min(a, min(b, min(c, min(d, e)))); 
    let answer: i64 = if n <= min_val { 5 } else {
        n / min_val + 5 - if n % min_val == 0 {1} else {0}
    };

    println!("{}", answer);
}



Measured memory_bytes: 4352
a, b, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = []
y = []
c = []
for i in range(m):
    xi, yi, ci = map(int, input().split())
    x.append(xi)
    y.append(yi)
    c.append(ci)
ans = min(a) + min(b)
for j in range(m):
    kk = a[x[j]-1] + b[y[j]-1] - c[j]
    if ans > kk:
        ans = kk
print(ans) 

Measured memory_bytes: 24620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define ll long long
 
//const int INF = 1e8;
typedef pair<int,int>P;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
queue<P> que;

int main(){
  int n;cin >> n;
  int m;cin >> m;
  bool a[n];for(int i = 0;i<n;i++) a[i] = true;
  for(int i = 0;i<m;i++){
    int ai;cin >> ai;
    a[ai-1] = false;
  }
  long long b[n];
  b[0] = 1;b[1] = 2;
  if(a[0] == false) {b[0] = 0;b[1] = 1;}
  if(a[1] == false) {b[1] = 0;}
  for(int i = 2;i< n;i++){
    if(a[i] == true){
      b[i] = (b[i-1] + b[i-2])%1000000007;
    }else{
      b[i] = 0;
    }
  }
  cout << b[n-1] << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main() {
    cin>>N;
    ll ans = MOD;
    for(ll i = 1; i*i <= N; ++i){
        //if(i == 10000) cout<<'A'<<endl;
        if(N%i == 0){
            ll check = N/i, temp = 0;
            while(check > 0){
                check /= 10;
                ++temp;
            }
            ans = min(ans, temp);
        }
    }
    cout<<ans<<endl;
}

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

int main(){
	int n;
	int k;
	int result;
	cin >> n >> k;
	if(k == 1){
		result = 0;
	}else{
		int max;
		max = n - (k - 1);
		result = max - 1;
	}
	cout << result << endl;
}

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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;



int main() {
    string s, t;
    cin2(s, t);
    lli sl = s.length();
    lli tl = t.length();

    map<char, vector<lli>> m;

    REP(i, 0, sl) {
        m[s[i]].push_back(i);
    }
    //REP(i, 0, sl) {
    //    vector<lli> x = m[s[i]];
    //    REP(j, 0, x.size()) {
    //        cout << x[j] << endl;
    //    }
    //}
    //REPIT(it, m) {
    //    cout << it->first << ": ";
    //    REP(i, 0, (it->second.size())) {
    //        cout << it->second[i] << ", ";
    //    }
    //    cout << endl;
    //}

    lli count = 0;
    lli pos = -1;
    lli cur = 0;
    while(cur < tl) {
        auto it = upper_bound(m[t[cur]].begin(), m[t[cur]].end(), pos);
        if (it == m[t[cur]].end()) {
            //cout << "if" << endl;
            //cout1(cur);
            if (pos == -1) {
                cout << -1 << endl;
                return 0;
            }
            count++;
            pos = -1;
        }
        else {
            //cout << "else" << endl;
            //cout1(cur);
            //cout1(*it);
            pos = *it;
            cur++;
        }
    }
    cout << count * sl + pos+1 << endl;
}


Measured memory_bytes: 1728
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 100005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   vi a(n);
   rep(i,0,n)cin>>a[i];
   sort(all(a),greater<int>());
   int sum=0;
   if(n<6)
   {
       if(n == 2)
       {
           cout<<a[0]<<endl;
       }
       else if(n == 3)
       {
           cout<<a[0]+a[1]<<endl;
       }
       else if(n == 4)
       {
           cout<<(a[0]+2*a[1])<<endl;
       }
       else if(n == 5)
       {
           cout<<(a[0]+2*a[1]+a[2])<<endl;
       }
   }
   else
   {
       sum+=(a[0]+2*a[1]+a[2]);
       priority_queue<int>pq;
       pq.push(a[2]);
       pq.push(a[3]);
       pq.push(a[3]);
       pq.push(a[4]);
       pq.push(a[4]);
       for(int i=5;i<n;i++)
       {
           sum+=pq.top();
           pq.pop();
           pq.push(a[i]);
           pq.push(a[i]);
       }
       cout<<sum<<endl;
   }

}


Measured memory_bytes: 6876
program ABC177C
    implicit none
    integer(8)::N,m=1000000007,i,ans=0
    integer(8),allocatable::A(:),S(:)
    read*,N
    allocate(A(N))
    allocate(S(N))
    read*,A
    do i=1,N
        if(i==1)then
            S(i)=mod(A(i),m)
        else
            S(i)=mod(S(i-1)+A(i),m)
        end if
    end do

    do i=1,N-1
        if(S(N)-S(i)<0)then
            ans=ans+mod(A(i)*(m+S(N)-S(i)),m)
        else
            ans=ans+mod(A(i)*(S(N)-S(i)),m)
        end if
        ans=mod(ans,m)
    end do
    print'(i0)',mod(ans,m)
end program ABC177C

Measured memory_bytes: 6176
#include <iostream>
#include <string>
using namespace std;
int main(void) {
  string s;
  cin >> s;
  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] == 'A' && s[i+1] == 'C') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sunuke = new Scanner(System.in);
    int n = sunuke.nextInt();
    int x = 800 * n;
    int y = 200 * ( n / 15 );
    System.out.println(x - y);
  }
}

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

void make_list(int m, int *pl);
int count_prime(int m, int *pl);

int main(void){
	
	int n;
	int prime_list[246912];
	make_list(246912, prime_list);
	
/*	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			cout << prime_list[i*10+j] << " ";
		}
		cout << endl;
	}
*/	
	while(1){
		cin >> n;
		
		if(n <= 0){
			break;
		}
		
		cout << (count_prime(2 * n, prime_list) -
			count_prime(n, prime_list)) << endl;
		
	}
	
	return 0;
}

void make_list(int m, int *pl){
	for(int i=2;i<m;i++){
		*(pl+i) = 1;
	}
	
	for(int i=2;i<(int)sqrt(m);i++){
		if(*(pl+i) == 0){
			continue;
		}
		for(int j=i+1;j<m;j++){
			if(j % i == 0){
				*(pl+j) = 0;
			}
		}
	}
	
}

int count_prime(int m, int *pl){
	if(m == 1){
		return 0;
	}
	int ans = 0;
	
	for(int i=0;i<=m;i++){
		if(*(pl+i) == 1){
			ans ++;
		}
	}
	
	return ans;
}

Measured memory_bytes: 2124
#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#include<set>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#define my_max zhi5968
typedef long long ll;
using namespace std;

int main()
{
	int a,b;
	cin>>a>>b;
	printf("%d\n",a%b==0?0:1); 
	return 0;
}


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

using namespace std;

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


string s;
bool t0, t1;
ll ans = INF;
int main() {
	cin >> s;
	REP(i, s.size()) {
		if (s[i] == '0')t0 = true;
		if (s[i] == '1')t1 = true;
	}
	if (!t0 or !t1) {
		cout << s.size() << endl;
		return 0;
	}
	REP(i, s.size() - 1) {
		if (s[i] != s[i + 1]) {
			ans = min(ans, max(i + 1, (ll)s.size() - i - 1));
		}
	}
	cout << ans << endl;
}




Measured memory_bytes: 512
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from fractions import gcd
e = enumerate

sys.setrecursionlimit(10**7)
N, K = map(int, input().split())
H = list(map(int, input().split()))

H.sort(reverse=True)

print(sum(H[K:]))


Measured memory_bytes: 27780
#include <iostream>
#include <string>
#include <map>
using namespace std;

pair<string,int> operation(string op,string opa,string buffer,int cur) {
    if(op == "forward") {
        if(opa == "word") {
            while(cur < buffer.length() && buffer[cur] == ' ') cur++;
            while(cur < buffer.length() && buffer[cur] != ' ') cur++;
        }else{
            cur++;
            cur = min(cur,(int)buffer.length());
        }
    }else if(op == "backward") {
        if(opa == "word") {
            cur--;
            while(cur >= 0 && buffer[cur] == ' ') cur--;
            while(cur >= 0 && buffer[cur] != ' ') cur--;
            if(cur >= 0 && buffer[cur] == ' ') cur++;
            cur = max(0,cur);
        }else{
            cur--;
            cur = max(0,cur);
        }
    }else if(op == "delete") {
        if(opa == "word") {
            int pc = cur;

            for(int i=cur; i<buffer.length(); ++i) {
                if(buffer[i] != ' ') break;
                // no word exists in the right
                if(i == buffer.length()-1) {
                    return make_pair(buffer,cur);
                }
            }

            while(cur < buffer.length() && buffer[cur] == ' ') cur++;
            while(cur < buffer.length() && buffer[cur] != ' ') cur++;
            buffer = buffer.substr(0,pc) + buffer.substr(cur);
            cur = pc;
        }else{
            if(cur < buffer.length()) {
                buffer = buffer.substr(0,cur)
                    + ((cur==buffer.length()-1)?"":buffer.substr(cur+1));
            }
        }
    }else if(op == "insert") {
        buffer = buffer.substr(0,cur) + opa + buffer.substr(cur);
        cur += opa.length();
    }

    return make_pair(buffer,cur);
}

int main() {
    int t,n;
    cin>>t;
    string buffer,op,opa;
    string lastop = "nop";
    for(int i=0; i<t; ++i) {
        if(lastop != "insert") cin.ignore();
        getline(cin,buffer);
//        cout<<buffer<<endl;
        cin>>n;
        int cur = 0;

        for(int j=0; j<n; ++j) {
            cin>>op;
            lastop = op;
            if(op != "insert") {
                cin>>opa;
            }else{
                getline(cin,opa);
                for(int i=0; i<opa.length(); ++i)
                    if(opa[i] == '\"') {
                        opa = opa.substr(i+1);
                        break;
                    }
                opa = opa.substr(0,opa.length()-1);
            }
            pair<string,int> ret = operation(op,opa,buffer,cur);
            cur = ret.second;
            buffer = ret.first;
//            cout<<cur<<" "<<buffer<<endl;
        }

        for(int i=0; i<buffer.length(); ++i) {
            if(i == cur) cout<<"^";
            cout<<buffer[i];
        }
        if(cur == buffer.length()) cout<<"^";

        cout<<endl;
    }
}

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

int main() {
  ll s,w=0;

  cin >> s >> w;

  if (s<=w) cout << "unsafe" << endl;
  else  cout << "safe" << endl;
  return 0;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//

#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}

int loadvec(vector<int>& v, int N=-1) {
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    // assert(i <= N);
    return i;
}
void read_cr() {
    fgets(_buf, 256, stdin);
}

ll solve(int N, vi& a) {
    ll cnt = 0;
    rep(i,N){
        while (a[i] % 2 == 0) {
            a[i] >>= 1;
            ++cnt;
        }
    }
    return cnt;
}

int main() {
    vi a;
    int N = loadvec(a);
    cout << solve(N,a) << endl;
    // cout << (solve(N,a) ? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 892