akhauriyash/Code-Regression huggingface dataset:
// Contest: AtCoder Beginner Contest 150 (https://atcoder.jp/contests/abc150)
// Problem: A: 500 Yen Coins (https://atcoder.jp/contests/abc150/tasks/abc150_a)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

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

    int k, x; cin >> k >> x;
    cout << (k * 500 >= x ? "Yes\n" : "No\n");

    return 0;
}


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

int main(){
  long long int n,t;
  cin>>n>>t;

  string s;
  cin>>s;

  int ans = 0;
  int b=1;

  for(int i =0;i<s.size();i++){
    b=1;
    if(s[i]>='0'&&s[i]<='9'){
      int a = s[i]-'0';
      for(int j =0;j<a;j++){
        b*=n;
        if(b<0||b>1000000000){
          cout<<"TLE"<<endl;
          return 0;
        }
      }
      ans+=b;
      if(ans<0||ans>1000000000||ans*t<0||ans*t>1000000000){
        cout<<"TLE"<<endl;
        return 0;
      }
    }
  }

  cout<<ans*t<<endl;

  return 0;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  int ans=0;
  rep(i,0,N){
    ans+=A[i]/2;
  }
  int memo=0;
  vi B;
  rep(i,0,N){
    if(A[i]%2==1){
      B.pb(memo);
    }
    else if(A[i]==0) memo=i+1;
  }
  rep(i,1,B.size()){
    if(B[i]==B[i-1]){
      i++;
      ans++;
    }
  }
  cout<<ans<<endl;
  }



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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define F first
#define S second

#define TRACE

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

#else
#define trace(...)
#endif

const int mod = 1e9 + 7;
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
	int x = 1 % mod;
	while(b){
		if(b & 1) x = mul(x, a);
		a = mul(a, a);
		b >>= 1;
	}
	return x;
}

inline int inv(int a){ return powr(a, mod - 2);}

ll pw10[20];

inline int get(int d, int S){
	if(d <= 8) return 0;
	int l = S / d;
	if(d >= 10 || l <= pw10[d] - pw10[d - 1]){
		return add(1, sub(sub(powr(10, d), powr(10, d - 1)), l));
	}
	return 0;
}
const int M = 1e9 + 10;
bitset<M> bs;
int main(){
	pw10[0] = 1;
	for(int i = 1; i < 20; i++){
		pw10[i] = pw10[i - 1] * 10;
	}
	int S;
	cin >> S;
	int ans = 0;
	for(int i = 1; i * i <= S; i++){
		if(S % i == 0){
			int d = i;
			ans = add(ans, get(d, S));
			if(i * i != S){
				d = S / i;
				ans = add(ans, get(d, S));
			}
		}
	}

	for(int i = 8; 2 * i + 1 <= S; i++){
		// b = S(mod i)
		int mnb = S % i;
		if(mnb == 0) mnb += i;

		for(ll b = mnb; b * 1ll * (i + 1) + i <= S; b += i){
			ans++;
		}
		if(ans >= mod) ans %= mod;
	}
	int p = 0;
	for(int d = 1; d <= 8; d++){
		for(int v = pw10[d - 1]; v < pw10[d]; v++){
			p += d;
			bs.set(p);
		}
	}
	p = 0;
	if(bs[S]) ans++;
	ans %= mod;
	for(int d = 1; d <= 8; d++){
		for(int v = pw10[d - 1]; v < pw10[d]; v++){
			p += d;
			if(bs[p + S]) ans++;
		}
	}
	if(bs[p + S]) ans = add(ans, mod - 1);
	ans %= mod;
	cout << ans;
}

Measured memory_bytes: 98560
#include <stdio.h>

int main(void)
{
  int num = 0;

  int array[3][3] = {0};
  int isSelect[3][3] = {0};
  int isBingo = 0;
  int tmpjudge = 0;

  /* ビンゴカード番号 */
  for(int k = 0; k<3; k++){
    scanf("%d %d %d",&array[k][0], &array[k][1], &array[k][2]);
//    scanf("%d %d %d" &array[k+0], &array[k+1], &array[k+2]);
  }

  /* 引いた番号 */
  scanf("%d", &num);
  int b[num] = {0};
  
  for(int l = 0; l < num; l++){
    scanf("%d", &b[l]);
  }

#if 0
  for(int k = 0;k<3;k++){
    printf("%d %d %d\n",array[k][0], array[k][1], array[k][2]);
//    printf("%d %d %d\n",array[k+0], array[k+1], array[k+2]);
  }

  for(int l = 0; l < num; l++){
    printf("%d\n", b[l]);
  }
#endif

  /* 引いた数がカードにあるかチェック */
  for(int l = 0; l < num; l++){
    for(int i = 0; i < 3; i++){
      for(int j = 0; j < 3; j++){
        if(b[l] == array[i][j]){
          isSelect[i][j] = 1;
        }
      }
    }
  }
  
  /* 横ビンゴチェック*/
  if(isBingo == 0){
    for(int i = 0; i < 3; i++){
      tmpjudge = isSelect[i][0] & isSelect[i][1] & isSelect[i][2];
      if(tmpjudge == 1){
        isBingo = 1;
        break;
      }
    }
  }
  
  /* 縦ビンゴチェック*/
  if(isBingo == 0){
    for(int i = 0; i < 3; i++){
      tmpjudge = isSelect[0][i] & isSelect[1][i] & isSelect[2][i];
      if(tmpjudge == 1){
        isBingo = 1;
        break;
      }
    }
  }
  
  /* 右下方向ななめビンゴチェック */
  if(isBingo == 0){
    tmpjudge = isSelect[0][0] & isSelect[1][1] & isSelect[2][2];
    if(tmpjudge == 1){
        isBingo = 1;
    }
  }

  /* 左下方向ななめビンゴチェック */
  if(isBingo == 0){
    tmpjudge = isSelect[0][2] & isSelect[1][1] & isSelect[2][0];
    if(tmpjudge == 1){
        isBingo = 1;
    }
  }
  
  if(isBingo == 1){
    printf("Yes");
  }else{
    printf("No");
  }
}



Measured memory_bytes: 128
#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 n;

	ll k;
	int ans = 0;
	cin >> n >> k;
	VVi tri(n, Vi(65));
	rep(j, 65) {
		rep(i, n) {
			if (j == 0) {
				cin >> tri[i][0];
				tri[i][0]--;
			}

			else {
				tri[i][j] = tri[tri[i][j - 1]][j - 1];
			}
		}
	}
	int at = 0;
	for (int i = 0; k >= (1LL << i); i++) {
		if (k & (1LL << i)) {
			at = tri[at][i];
		}
	}

	cout << at+1 << endl;
}

Measured memory_bytes: 61076
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n; 
    cin >> n;
	vector<pair<int,int>> x(n);
	for(int i=0; i<n; i++){
		int a; 
        cin >> a;
		x[i] = make_pair(a,i);
	}
	sort(x.begin(),x.end());
	int l = x[n/2-1].first;
	int r = x[n/2].first;
	vector<bool> left(n,false);
	for(int i=0; i<n; i++){
		if(i < n/2){
			left[x[i].second] = true;
		}
	}
	for(int i=0; i<n; i++){
		cout << (left[i] ? r : l) << endl;
	}
    return 0;
}

Measured memory_bytes: 4828
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int j;
  j = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string C;
    cin >> C;
      if(C == "Y"){
        j = 1;
        break;
      }
  }
    if(j == 0) {
      cout << "Three" << endl;
    }
    else  {
      cout << "Four" << endl;
  }
}
  
  

Measured memory_bytes: 256
// Tenshi ni Fureta yo!

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return *(cur == ed ? ed = buffer + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur = buffer : cur)++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

// END tpl.

const int MAXN = (int) 2e5;

int n;

int fa[MAXN + 5];
int val[MAXN + 5];

inline void input()
{
	n = read<int>();
	for(int i = 2; i <= n; ++i) fa[i] = read<int>();
	for(int i = 1; i <= n; ++i) val[i] = read<int>();
}

struct node
{
	int u, cnt[2];

	inline bool operator < (const node &rhs) const
	{
		return (LL) this->cnt[1] * rhs.cnt[0] < (LL) rhs.cnt[1] * this->cnt[0];
	}

	node() { }
	node(int _u, int cnt0, int cnt1): u(_u) { cnt[0] = cnt0, cnt[1] = cnt1; }
};

namespace SET
{
	int anc[MAXN + 5];

	inline void init(int N) { for(int i = 0; i <= N; ++i) anc[i] = i; }
	inline int get_anc(int u) { return u == anc[u] ? u : anc[u] = get_anc(anc[u]); }
	inline void set_fa(int u, int v) { anc[get_anc(u)] = get_anc(v); }
}

inline void solve()
{
	static multiset<node> T;
	static multiset<node>::iterator nds[MAXN + 5];

	for(int i = 1; i <= n; ++i) nds[i] = T.emplace(i, !val[i], val[i]);

	LL ans = 0;
	int cnt[2] = {0, 0};
	SET::init(n);
	while(!T.empty())
	{
		auto p = *T.begin();
		T.erase(T.begin());

		int u = p.u;
		int v = SET::get_anc(fa[u]);
		SET::set_fa(u, v);
		if(v)
		{
			auto q = *nds[v];
			T.erase(nds[v]);

			ans += (LL) q.cnt[1] * p.cnt[0];
			nds[v] = T.emplace(v, p.cnt[0] + q.cnt[0], p.cnt[1] + q.cnt[1]);
		}
		else
		{
			ans += (LL) cnt[1] * p.cnt[0];
			cnt[0] += p.cnt[0];
			cnt[1] += p.cnt[1];
		}
	}
	printf("%lld\n", ans);
}

int main()
{
#ifdef K_ON
	freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}




Measured memory_bytes: 16768
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;
using ll = long long;

int main(int argc, char const* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X;
    cin >> X;
    int max = 1;
    for (int i=2; i<=31; ++i) {
        for (int j=2; j<=9; ++j) {
            int tmp = pow(i, j);
            if (tmp > X) {
                break;
            }
            if (tmp > max) {
                max = tmp;
            }
        }
    }
    cout << max << '\n';
    return 0;
}


Measured memory_bytes: 888
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
	
#define PI 3.141592653589793
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
// Use for file I/O;
#define FIN string _fname = "paintbarn"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

using namespace std;

const ll INF = 1e9 + 10;
const ll INF2 = 3e18 + 10;
const int MOD = 1e9 + 7;
const ld EPS = 1e-4;

const int LOGN = 19;
const int MAXN = 305;


inline void add_self(int &a, int b) {
	a = (a + b) % MOD;
}

ll dp[1 << 16];
ll t[1 << 16];
ll p[16][16];
int a[16];

int main() {
	FAST;

	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> p[i][j];
		}
	}
	for (int i = 0; i < (1 << n); i++) dp[i] = -INF2;

	for (int mask = 0; mask < (1 << n); mask++) {
		for (int i = 0; i < n; i++) {
			if ((mask >> i) & 1) {
				for (int j = i + 1; j < n; j++) {
					if ((mask >> j) & 1) {
						t[mask] += p[i][j];
					}
				}
			}
		}
	}

	dp[0] = 0;
	for (int mask = 0; mask < (1 << n); mask++) {
		int b = 0;
		for (int i = 0; i < n; i++) {
			if (!((mask >> i) & 1)) {a[b] = i; b++;}
		}
		for (int m = 1; m < (1 << b); m++) {
			int nmask = 0;
			for (int i = 0; i < b; i++) {
				if ((m >> i) & 1) {nmask += 1 << a[i];}
			}
			dp[nmask | mask] = max(dp[nmask | mask], dp[mask] + t[nmask]);
		}
	}
	cout << dp[(1 << n) - 1];

}

Measured memory_bytes: 4644
#include <stdio.h>

int max(int a, int b) { if(a>b) return a; else return b; }

int main(void)
{
	int i, n;
	int v[20], c[20], dp[21];
	scanf("%d%*c", &n);
	for(i=0;i<n;i++) {
		scanf("%d%*c", &v[i]);
	}
	for(i=0;i<n;i++) {
		scanf("%d%*c", &c[i]);
	}

	dp[0] = 0;
	for(i=0;i<n;i++) {
		dp[i+1] = max(dp[i], dp[i] + v[i] - c[i]);
	}

	printf("%d", dp[n]);
	
	return 0;
}


Measured memory_bytes: 128
// by ul {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
// }}}

int N, K;
void input() {
}

void solve() {
    int cnt = 0;
    RI(N, K);
    REP(i, N) {
        int t; RI(t);
        if(t >= K) cnt++;
    }
    printf("%d\n", cnt);
}

int main( int argc, char *argv[] ) {
    input();
    solve();
    return 0;
}


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

int getmini(int x, int y, int z)
{
	int i = 0;
	if (y % 2 == z % 2)
	{
		if (y >= z)
		{
			while (x > y)
			{
				y++;
				z++;
				i++;
			}
			while (x > z)
			{
				z += 2;
				i++;
			}
		}
		else
		{
			while (x > z)
			{
				y++;
				z++;
				i++;
			}
			while (x > y)
			{
				y += 2;
				i++;
			}
		}

	}
	if (y % 2 != z % 2)
	{
		if (x == y || x == z)
		{
			x++;
			y++;
			i++;
		}
		else if (x > y && x > z)
		{
			x++;
			y++;
			i++;
		}
		if (y >= z)
		{
			while (x > y)
			{
				y++;
				z++;
				i++;
			}
			while (x > z)
			{
				z += 2;
				i++;
			}
		}
		else
		{
			while (x > z)
			{
				y++;
				z++;
				i++;
			}
			while (x > y)
			{
				y += 2;
				i++;
			}
		}
	}
	return i;
}
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a >= b && a > c)
	{
		cout << getmini(a, b, c);
	}
	else if (b >= c && b > a)
	{
		cout << getmini(b, c, a);
	}
	else if (c >= a && c > b)
	{
		cout << getmini(c, a, b);
	}
	else
	{
		cout << "0";
	}
	return 0;
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

#define All(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   int n;cin >> n;
   vector<string> s(n);
   rep(i,n)cin >> s[i];
   int m;cin >> m;
   vector<string> t(m);
   rep(i,m)cin >> t[i];

   int ans = 0;
   for(int i=0;i<n;i++){
      int tmp = 0;
      for(int j=0;j<n;j++)if(s[i] == s[j])tmp++;
      for(int j=0;j<m;j++)if(s[i] == t[j])tmp--;
      ans = max(ans,tmp);
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;

    if (n == 1) {
            cout << "No" << endl;
            return 0;
    }

    if (n % 2 == 1) {
                    cout << "No" << endl;
            return 0;
    }

    for (int i=0; i<n/2; i++) {
        if (s[i] != s[i+(n/2)]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

template <typename T>
T powi(T a, ll n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= a; 
        a *= a;
        n >>= 1;
    }
    return ret;
}

template <ll mod>
class ModInt {
private:
    ll num;
public:
    ModInt() {};
    ModInt(ll n) { num = n % mod; }
    ModInt inv() const { return powi(*this, mod-2); }
    explicit operator ll() const { return num; }

    ModInt& operator+=(const ModInt& a) {
        num += a.num; 
        if (num >= mod) num -= mod; 
        return *this;
    }
    ModInt& operator-=(const ModInt& a) {
        if (num < a.num) num += mod;
        num -= a.num;
        return *this;
    }
    ModInt& operator*=(const ModInt& a) {
        num = num * a.num % mod;
        return *this;
    }
    ModInt& operator/=(const ModInt& a) { return *this *= a.inv(); }
    friend ModInt operator+(const ModInt& a, const ModInt& b) { return ModInt(a) += b; }
    friend ModInt operator-(const ModInt& a, const ModInt& b) { return ModInt(a) -= b; }
    friend ModInt operator*(const ModInt& a, const ModInt& b) { return ModInt(a) *= b; }
    friend ModInt operator/(const ModInt& a, const ModInt& b) { return ModInt(a) /= b; }

    friend ostream& operator<<(ostream& os, const ModInt& a) { return os << a.num; }
    friend istream& operator>>(istream& is, ModInt& a) {
        ll tmp;
        is >> tmp;
        a.num = tmp % mod;
        return is;
    }

    class Factorial {
    private:
        static vector<ModInt> table[2];
    public:
        static void reserve(int n) {
            for (auto &v: table) v.resize(n+1);
            table[0][0] = 1;
            for (int i = 1; i <= n; ++i) table[0][i] = table[0][i-1].num * i;
            table[1][n] = table[0][n].inv();
            for (int i = n; i >= 1; --i) table[1][i-1] = table[1][i].num * i;
        }
    
    private:
        int num;
    public:
        Factorial() {};
        Factorial(int n): num(n) {};
        ModInt finv() const { return table[1][num]; }
        operator ModInt() const { return table[0][num]; }
    };
    ModInt& operator /=(const Factorial& a) { return *this *= a.finv(); }
    friend ModInt operator /(const ModInt& a, const Factorial& b) { return ModInt(a) /= b; }
};
template<ll mod>
vector<ModInt<mod>> ModInt<mod>::Factorial::table[2];

using mint = ModInt<1000000007>;
using fact = mint::Factorial;

mint P(int n, int k) {
    return fact(n) / fact(n-k);
}
mint C(int n, int k) {
    return fact(n) / fact(n-k) / fact(k);
}
mint H(int n, int k) {
    return C(n+k-1, k);
}

int main() {
    int n, k;
    cin >> n >> k;
    int r = n-k;

    fact::reserve(4000);

    for (int i = 1; i <= k; ++i) {
        if (r < (i-1)) cout << 0 << endl;
        else cout << H(i, k-i) * H(i+1, r-(i-1)) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main()
{
  long long int n,t,i,l;
  cin>>n>>t;
  string s;
  vector <string> v;
  for(i=0;i<n;i++)
  {
    cin>>s;
    v.push_back(s);
  }
  sort(v.begin(),v.end());
  for(i=0;i<n;i++)
  {
    cout<<v[i];
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int n;
  scanf("%d",&n);
  long i;
  i = 2;
  long l1,l0;
  l0 = 2;
  l1 = 1;
  long li;
  long t;
  long lim1;
  li = 1;
  lim1 = 2;
  while (i <= n)
  {
    t = li;
    li = li + lim1;
    lim1 = t;
    i++;
  }
  printf("%ld",li);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

char s[12];

int main() {
  cin >> s;
  for (int i=0; i<4; i++) cout << s[i];
  cout << " ";
  for (int i=4; i<12; i++) cout << s[i];
  cout << "\n";
  return 0;
}



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

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define digits(x) floor(log10(x) + 1)
#define countbits(x) ((int)log2(x)+1)
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define init(arr,value) memset(arr,value,sizeof(arr))
#define deb(x) cout << #x << "=" << x << endl;
#define test unsigned int tet;cin >> tet;while(tet--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);cout << fixed;
#define int long long

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const ll N   = 500500;

signed main(void)
{
    	fastio
        string s,t,ans;
        cin >> s >> t;
        int n = s.size();
        int m = t.size();
        int dp[n+1][m+1];
        for(int i=0; i<=n; i++){
            for(int j=0; j<=m; j++){
                if(i == 0 || j == 0) dp[i][j] = 0;
                else if(s[i-1] == t[j-1]){
                    dp[i][j] = 1 + dp[i-1][j-1];
                }
                else{
                    dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
                }
            }
        }

        int i = n, j = m;
        while(i > 0 && j > 0)
        {
            if(s[i-1] == t[j-1]){
                ans.pb(s[i-1]);
                i--;
                j--;
            }
            else if(dp[i-1][j] > dp[i][j-1]){
                i--;
            }
            else{
                j--;
            }
        }
        reverse(all(ans));
        cout << ans;


    	return 0;
}



Measured memory_bytes: 73924
#include<iostream>
#include<vector>
#include<algorithm>
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf=1e18;
int pa[1000010];
int par(int x)
{
    if(pa[x]==-1)
        return x;
    return pa[x]=par(pa[x]);
}
inline void uni(int x,int y)
{
    x=par(x);
    y=par(y);
    if(x==y)
        return;
    pa[x]=y;
    return;
}
ll n,i,ans;
ll a[1000010],b[1000010];
ll c[1000010],d[1000010];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n;
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n;i++)
        cin>>b[i];
    for(i=0;i<n;i++)
        a[n]^=a[i];
    for(i=0;i<n;i++)
        b[n]^=b[i];
    n++;
    for(i=0;i<n;i++)
        c[i]=a[i],d[i]=b[i];
    sort(c,c+n);
    sort(d,d+n);
    for(i=0;i<n;i++)
        if(c[i]!=d[i])
            return cout<<-1<<endl,0;
    fill(pa,pa+n,-2);
    for(i=0;i<n;i++)
    {
        if(a[i]!=b[i]||i==n-1)
        {
            int t1=lower_bound(c,c+n,a[i])-c;
            int t2=lower_bound(c,c+n,b[i])-c;
            if(pa[t1]==-2)
                pa[t1]=-1;
            if(pa[t2]==-2)
                pa[t2]=-1;
            uni(t1,t2);
            if(i<n-1)
                ans++;
        }
    }
    for(i=0;i<n;i++)
        if(pa[i]==-1)
            ans++;
    cout<<ans-1<<endl;
    return 0;
}

Measured memory_bytes: 14848
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int N = sc.nextInt();
		int[] A = new int[N];
		Arrays.setAll(A, i -> sc.nextInt());
		int max = A[0] + K - A[N-1];
		for(int i = 1; i < N; i++) {
			max = Math.max(max, A[i] - A[i-1]);
		}
		System.out.println(K - max);
	}

}


Measured memory_bytes: 67460
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int get() { int r; cin >> r; return r; }
signed main() {
	double x0, y0, r, r1, r2, x3, y3;
	double x1, x2, y1, y2;
	cin >> x0 >> y0 >> r; r1 = r;
	cin >> x3 >> y3 >> r2;
	if (y0 == y3) {
		y1 = 1;
		x1 = ((x0 - x3) * (x0 + x3) + (y0 - y3) * (y0 + y3) - (r1 - r2) * (r1 + r2) - 2 * (y0 - y3) * y1) / (x0 - x3) / 2;
		y2 = 2;
		x2 = ((x0 - x3) * (x0 + x3) + (y0 - y3) * (y0 + y3) - (r1 - r2) * (r1 + r2) - 2 * (y0 - y3) * y2) / (x0 - x3) / 2;
	}
	else {
		x1 = 1;
		y1 = ((x0 - x3) * (x0 + x3) + (y0 - y3) * (y0 + y3) - (r1 - r2) * (r1 + r2) - 2 * (x0 - x3) * x1) / (y0 - y3) / 2;
		x2 = 2;
		y2 = ((x0 - x3) * (x0 + x3) + (y0 - y3) * (y0 + y3) - (r1 - r2) * (r1 + r2) - 2 * (x0 - x3) * x2) / (y0 - y3) / 2;
	}

	double p = ((y2 - y1) * (x0 - x1) - (x2 - x1) * (y0 - y1)) / ((x2 - x1) * (x1 - x2) + (y2 - y1) * (y1 - y2));
	p = -p;
	double x4 = x0 + p * (y1 - y2), y4 = y0 - p * (x1 - x2);
	double k = sqrt(r * r - (x0 - x4) * (x0 - x4) - (y0 - y4) * (y0 - y4)) / sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	if (x1 < x2) { swap(x1, x2); swap(y1, y2); }
	else if (x1 == x2 && y1 < y2) { swap(x1, x2); swap(y1, y2); }
	printf("%.10f %.10f %.10f %.10f\n", x4 - k * (x1 - x2), y4 - k * (y1 - y2), x4 + k * (x1 - x2), y4 + k * (y1 - y2));
}


Measured memory_bytes: 3296
#include<stdio.h>

// found = 1: みつかった
// found = 0: まだみつかっていない
int found;

main(){
  int n,A[20],q,M[200];
    int i;
  scanf("%d", &n);
  for(i=0; i<n; i++)
    scanf("%d", &A[i]);
  scanf("%d", &q);
  for(i=0; i<q; i++)
    scanf("%d", &M[i]);
  
  for(i=0;i<q;i++){
    found = 0;
    solve(A, 0, M[i], n);
    if(found==0)
      printf("no\n");
    else if(found==1)
      printf("yes\n");
  }
  return 0;
}

int solve(int A[], int p, int t, int n){

  if(p<n){
    solve(A, p+1, t-A[p], n); //A[p]番目を使うとき
    solve(A, p+1, t, n); //使わないとき  
  }

  if(t==0)
    found=1;  

}

Measured memory_bytes: 580
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
  int x1,y1,x2,y2,x3,y3,x4,y4;
  cin >> x1 >> y1 >> x2 >> y2;
  int xd = x2 - x1;
  int yd = y2 - y1;
  x3 = x2 - yd;
  y3 = y2 + xd;
  x4 = x3 - xd;
  y4 = y3 - yd;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}


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

int A, B, X;

int main()
{
	scanf("%d%d%d", &A, &B, &X);

	bool isok = X >= A && X <= A + B;

	if (isok) {
		puts("YES");
	} else {
		puts("NO");
	}
	return 0;
}


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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(a>b)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream&os, const pair<t,u>&p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream&operator <<(ostream&os,const vc<t>&v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	int n;cin>>n;
	map<int,int> sum;
	rep(_,n){
		int a;cin>>a;
		for(int i=1;i*i<=a;i++)if(a%i==0){
			if(i>1)sum[i]+=a;
			if(i<a/i)sum[a/i]+=a;
		}
	}
	int ans=0;
	for(auto kv:sum)
		chmax(ans,kv.b);
	cout<<ans<<endl;
}



Measured memory_bytes: 4484
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

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

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

int N;
string S;

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

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
            ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
/**                                                     **\
 *    created by:   Divianshu Bansal                     *
 *    e-mail id:    god_coder@icloud.com                 *
*                                                        */

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>


using namespace std;
using namespace __gnu_pbds;


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>new_data_set;
#define MOD 1000000007
#define int long long
#define BIG 998244353
#define pf push_front
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589


int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
int max3(int a,int b,int c){
    return max(a,max(b,c));
}
int min3(int a,int b,int c){
    return min(a,min(b,c));
}

int32_t main(){
    fast;
    string s1,s2;
    cin>>s1>>s2;
    int tot=0;
    for(int i=0;i<s1.length();++i){
        if(s1[i]==s2[i]){
            ++tot;
        }
    }
    cout<<tot;
    return 0;
}

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

using Graph=vector<vector<int>>;
const int INF=1e9;

int main()
{
        int N, K; cin>>N>>K;
        vector<int> a(N);
        for(int i=0;i<N;i++) cin>>a[i], a[i]--;

        Graph G(N);
        for(int i=1;i<N;i++){
                G[a[i]].push_back(i);
        }
        /*
        for(int i=0;i<N;i++){
                cout<<i+1<<": ";
                for(int j:G[i]) cout<<j+1<<' '; cout<<endl;
        }
        */

        int ans=(a[0]!=0);
        function<int(int, int)> dfs=[&](int v, int p)
        {
                int res=0;
                for(int u:G[v]) if(u!=p){
                        res=max(res, dfs(u, v)+1);
                }
                if(res==K-1 and p>0){
                        ans++; res=-1;
                }
                return res;
        };
        dfs(0, -1);
        cout<<ans<<endl;
        return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<int> R(H, 0), L(W, 0);
  vector<vector<char>> A(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A.at(i).at(j);
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (A.at(i).at(j) == '#') {
        R.at(i) = 1;
        L.at(j) = 1;
      }
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (R.at(i) == 1 && L.at(j) == 1) {
        cout << A.at(i).at(j);
      }  
      if (j == W - 1 && R.at(i) == 1) {
        cout << endl;
      }
    }
  }
}


Measured memory_bytes: 3600
n, m = map(int, input().split())
shops = []
for i in range(n):
    a, b = map(int, input().split())
    shops.append((a, b))
shops.sort()

i = 0
total = 0
price = 0
while True:
    a, b = shops[i]
    if b >= m - total:
        price += (m - total) * a
        break
    else:
        total += b
        price += a * b
        i += 1

print(price)


Measured memory_bytes: 53208
#include <iostream>

using namespace std;

int main() {
    int a, b, c, i, Y;
    Y=0;
        cin >> a >> b >> c;
        for (i=a; i<=b; i++)
    {
        if (c%i==0)
            Y = Y+1;
    }
        cout << Y << endl;
}


Measured memory_bytes: 3100
a, b = map(int,input().split())
if a > 0 and b > 0:
    print("Positive")
elif (a == 0 or b == 0) or (a<0 and b>0):
    print("Zero")
elif a < 0 and b < 0:
    if (abs(a) - abs(b)) % 2 == 0:
        print("Negative")
    else:
        print("Positive")

Measured memory_bytes: 3060
a=[]
b=[10]
x=0
ans=0
for i in range(0,5):
  a.append(int(input()))
  

for j in range(0,5):
  ans+=a[j]
  if a[j]%10>0:
    ans+=(10-(a[j]%10))
    b.append(a[j]%10)
        
if min(b)!=0:
  x=min(b)
    
print(ans-10+x)    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multi_set;

#define mod         1000000007
#define pi          acos(-1.0)
#define eps         1e-9


#define fast       ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define fs          first
#define sc          second
#define pb         push_back
#define sp          printf(" ")
#define nl          '\n'
#define all(a) a.begin(),a.end()
#define unique(c) (c).resize(unique(all(c)) - (c).begin())
#define itn int

#define set0(a)     memset(a,0,sizeof(a))
#define setneg(a)   memset(a,-1,sizeof(a))
#define setinf(a)   memset(a,126,sizeof(a))

#define REP(i,start,end) for (int i = start; i <=end; i++)
#define RREP(i,end,start) for (int i=end; i>=start ;i--)

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef vector<double> vd;
typedef vector<vector<LL> > matrix;
typedef vector<vector<int> > graph;
LL INF=1e9;

const int maxn=1e5+5;

graph adj(maxn);
int deg[maxn]={0};
int dist[maxn]={0};
bool visited[maxn]={0};
void dfs(int x)
{
    visited[x]=1;
    for(int y: adj[x])
    {
        dist[y]=max(dist[y],1+dist[x]);
        deg[y]--;
        if(deg[y]==0)
            dfs(y);
    }
}
void solve()
{
    int n,m;
    cin>>n>>m;
    while(m--)
    {
        int x,y;
        cin>>x>>y;
        adj[x].pb(y);
        deg[y]++;
    }
    int ans=0;
    REP(i,1,n)
    {
        if(!visited[i] and deg[i]==0)
        dfs(i);
    }
    REP(i,1,n)
        ans=max(ans,dist[i]);
    cout<<ans<<nl;



}
int main()
{
    fast;
        solve();
}


Measured memory_bytes: 9728
s = list(input())
if len(s) == 1:
    print(0)
    exit()
for i in range(len(s)):
    if s[i] == "A":
        start = i
        break
for i in range(len(s))[::-1]:
    if s[i] == "Z":
        end = i
        break
print(end - start + 1)


Measured memory_bytes: 4840
#include <algorithm>
#include <array>
#include <cassert>
#include <chrono>
#include <iostream>
#include <random>
#include <set>
#include <unordered_map>
#include <vector>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


const int64_t INF64 = int64_t(2e18) + 5;

int64_t N, A, B, C, D;
unordered_map<int64_t, int64_t> save;
set<int64_t> divisions;

int64_t evaluate(int a, int b, int c) {
    int64_t n = N;
    while (a-- > 0) n /= 2;
    while (b-- > 0) n /= 3;
    while (c-- > 0) n /= 5;
    return n;
}

int64_t closest(int64_t n) {
    int64_t dist = INF64;
    auto it = divisions.lower_bound(n);

    if (it != divisions.end())
        dist = min(dist, *it - n);

    if (it != divisions.begin()) {
        it--;
        dist = min(dist, n - *it);
    }

    return dist;
}

const int CUTOFF = 1;

int64_t solve(int64_t n) {
    if (n == 0)
        return 0;

    if (n == 1)
        return D;

    if (closest(n) > CUTOFF)
        return INF64;

    if (save.find(n) != save.end())
        return save[n];

    int64_t ans = (long double) D * n < INF64 ? D * n : INF64;

    ans = min(ans, n % 2 * D + A + solve(n / 2));
    ans = min(ans, n % 3 * D + B + solve(n / 3));
    ans = min(ans, n % 5 * D + C + solve(n / 5));

    if (n > 2) ans = min(ans, (2 - n % 2) * D + A + solve(n / 2 + 1));
    ans = min(ans, (3 - n % 3) * D + B + solve(n / 3 + 1));
    ans = min(ans, (5 - n % 5) * D + C + solve(n / 5 + 1));

    return save[n] = ans;
}

void run_case() {
    cin >> N >> A >> B >> C >> D;
    save.clear();
    divisions.clear();

    for (int a = 0; a <= 60; a++)
        for (int b = 0; b <= 40; b++)
            for (int c = 0; c <= 30; c++)
                if (a + b + c <= 60)
                    divisions.insert(evaluate(a, b, c));

    cout << solve(N) << '\n';
}

int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    int tests;
    cin >> tests;

    while (tests-- > 0)
        run_case();
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long h;
    long long mob = 1;
    long long attack = 0;
    cin >> h;
    while (h > 0) {
        attack += mob;
        h /= 2;
        mob *= 2;
    }
    cout << attack << '\n';
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))
#define INF (1<<28)
#define pb push_back
#define fs first
#define sc second


const char dx[]={0,1,0,-1},dy[]={1,0,-1,0};
template<class T>
ostream &operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()) out << v[i] << ", " ;
	return out << "}" << endl;
}
template<class S,class T>
ostream &operator<<(ostream &out, const pair<S,T> p){
	return out << "(" << p.fs << ", " << p.sc << ")";
}
int main(){
	cpp_int x, y, s;
	cin >> x >> y;
	s = abs(x - y);
	cout << (s < (cpp_int)2 ?"Brown":"Alice") << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
count = 0

for i in range(n-1):
    for j in range(n-1, i, -1):
        if a[j-1] > a[j]:
            a[j-1], a[j] = a[j], a[j-1]
            count += 1

print(*a)
print(count)


Measured memory_bytes: 5604
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;


int main() {
	int n;

	while(cin >> n, n) {
		int scoreA = 0, scoreB = 0;

		REP(i, n) {
			int a, b, sum;
			cin >> a >> b;
			sum = a+b;

			if(a > b) {
				scoreA += sum;
			} else if(a < b) {
				scoreB += sum;
			} else {
				scoreA += a;
				scoreB += b;
			}
		}

		cout << scoreA << " " << scoreB << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#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>
#include <stack>
#include <set>
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 INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5+3;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	int a,b;
	cin>>a>>b;
	cout<<(a<=8&&b<=8?"Yay!":":(")<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main
{
   public static void main(String[] args) throws Exception
   {
      PrintWriter out = new PrintWriter(System.out);
      new Main(new FastScanner(System.in), out);
      out.close();
   }

   public Main(FastScanner in, PrintWriter out)
   {
      int N = in.nextInt();
      
      int canTake = 0;
      int xor = 0;
      while (N-->0)
      {
         int v = in.nextInt();
         xor ^= v;
         canTake |= Integer.lowestOneBit(v);
      }
      
      int res = 0;
      while (xor > 0)
      {
         int pos = Integer.highestOneBit(xor);
         if ((pos&canTake) > 0)
         {
            xor ^= pos|(pos-1);
         }
         else
         {
            out.println(-1);
            return;
         }
         res++;
      }

      out.println(res);
   }
}

class FastScanner{
   private InputStream stream;
   private byte[] buf = new byte[1024];
   private int curChar;
   private int numChars;

   public FastScanner(InputStream stream)
   {
      this.stream = stream;
   }

   int read()
   {
      if (numChars == -1)
         throw new InputMismatchException();
      if (curChar >= numChars){
         curChar = 0;
         try{
            numChars = stream.read(buf);
         } catch (IOException e) {
            throw new InputMismatchException();
         }
         if (numChars <= 0)
            return -1;
      }
      return buf[curChar++];
   }

   boolean isSpaceChar(int c)
   {
      return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1;
   }
   
   boolean isEndline(int c)
   {
      return c=='\n'||c=='\r'||c==-1;
   }

   int nextInt()
   {
      return Integer.parseInt(next());
   }
   
   long nextLong()
   {
      return Long.parseLong(next());
   }

   double nextDouble()
   {
      return Double.parseDouble(next());
   }

   String next(){
      int c = read();
      while (isSpaceChar(c))
         c = read();
      StringBuilder res = new StringBuilder();
      do{
         res.appendCodePoint(c);
         c = read();
      }while(!isSpaceChar(c));
      return res.toString();
   }
   
   String nextLine(){
      int c = read();
      while (isEndline(c))
         c = read();
      StringBuilder res = new StringBuilder();
      do{
         res.appendCodePoint(c);
         c = read();
      }while(!isEndline(c));
      return res.toString();
   }
}


Measured memory_bytes: 24032