akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
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; }

vector<ll> n{1,0,-1,0,1};
int main(){
	ll h, w; cin >> h >> w;
	ll sy, sx, gy, gx; cin >> sy >> sx >> gy >> gx;
	sy--; sx--; gy--; gx--;
	vector<string> s(h);
	rep(i,0,h) cin >> s[i];
	vector<vector<ll>> dist(h,vector<ll>(w,INF));
	deque<pair<ll,ll>> que;
	que.push_back({sy,sx});
	dist[sy][sx] = 0;

	 // 01-BFS
	while(!que.empty()){
		ll y = que.front().first;
		ll x = que.front().second;
		que.pop_front();
		for(ll i = 0; i < 4; i++){
			ll ny = y + n[i];
			ll nx = x + n[i + 1];
			if (ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
			if (s[ny][nx] == '#') continue;
			if(dist[ny][nx] > dist[y][x]){
				dist[ny][nx] = dist[y][x];
				que.push_front({ny,nx});
			}
		}
		for(ll i = -2; i < 3; i++){
			for(ll j = -2; j < 3; j++){
				ll ny = y + i;
				ll nx = x + j;
				if (ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
				if (s[ny][nx] == '#') continue;
				if(dist[ny][nx] > dist[y][x] + 1){
					dist[ny][nx] = dist[y][x] + 1;
					que.push_back({ny,nx});
				}
			}
		}
	}
	if(dist[gy][gx] == INF) dist[gy][gx] = -1;
	cout << dist[gy][gx] << endl;

}


Measured memory_bytes: 13544
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

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

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

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


    int main() {
        string s;
        cin >> s;
        ll z;
        cin >> z;
        ll a = 0;
        vector<ll> x;
        ll ans = 0;
        for (int i = 0; i < s.size()-1; i++) {
            a++;
            if (s.at(i) != s.at(i + 1)) {
                x.push_back(a);
                a = 0;
            }
        }
        a++;
        ll h = 0;
        if(a!=0)x.push_back(a);
        ll f = x.size();
        if (f == 1) {
            ans = z * s.size() / 2;
            cout << ans << endl;
        }
        else {
            if (s.at(0) == s.at(s.size() - 1) && x.at(0)*x.at(f-1) % 2 ==1) {
                h = z - 1;
            }
            ll ans = 0;
            for (int i = 0; i < f; i++) {
                ans += x.at(i) / 2;
            }
            cout << z * ans+h << endl;;
        }
    }

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

int main() {
  int n; cin >> n;
  vector<int> H(n);
  int ans = 0;
  rep(i,n) cin >> H[i];
  rep(i,n-1) {
    if (H[i] < H[i+1]) continue;
    else {
      int cnt = 0;
      while (H[i] >= H[i+1] && i < n-1) {
        cnt++;
        i++;
      }
      ans = max(ans, cnt);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3740
#include "iostream"
#include <vector>
#include <algorithm>
#include <math.h>
#include <limits.h>
using namespace std;


int main(){
    long N;
    cin >> N;
    vector<vector<long>> robots(N, vector<long>(2)); 

    for (long i = 0; i < N; i++){
        long x, l;
        cin >> x >> l;
        robots.at(i).at(0) = x + l;
        robots.at(i).at(1) = x - l;
    }
    // 範囲の上限の順にソート
    sort(robots.begin(), robots.end());
    // for (long i = 0; i < N; i++){
    //     cout << robots.at(i).at(1) << ", " << robots.at(i).at(0) << endl;
    // }

    long x = -LONG_MAX;
    long ans = 0;
    for (long i = 0; i < N; i++){
        // cout << i << ", " << x << endl;
        if (x <= robots.at(i).at(1)) {
            ans++;
            x = robots.at(i).at(0);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7808
#include<cstdio>
typedef long long ll;
const int mod=998244353;
int N,A,B;
ll K,fac[300010],ifac[300010];
ll inv(int a,int p=mod){return a==1?1:(1+p*(a-inv(p%a,a)))/a%p;}
ll C(int n,int m){return fac[n]*ifac[m]%mod*ifac[n-m]%mod;}
int main(){
	scanf("%d%d%d%lld",&N,&A,&B,&K);
	for(int i=*fac=1;i<=N;i++)fac[i]=fac[i-1]*i%mod;
	ifac[N]=inv(fac[N]);
	for(int i=N;i;i--)ifac[i-1]=ifac[i]*i%mod;
	int s=0;
	for(int i=0;i<=N;i++){
		ll j=K-1ll*A*i;
		if(j%B==0){
			j/=B;
			if(j>=0&&j<=N){
				s=(s+C(N,i)*C(N,j))%mod;
			}
		}
	}
	printf("%d\n",s);
}

Measured memory_bytes: 4864
#include <stdio.h>
#define MAX 100
#define INF 1000000

int matrixChainOrder(int[], int);
int min(int, int);

int main(){
    int p[MAX];
    int n;

    scanf("%d",&n);

    for(int i = 1; i <= n; i++){
        scanf("%d %d", &p[i - 1], &p[i]);
    }

    printf("%d\n", matrixChainOrder(p, n));

    return 0;
}

int matrixChainOrder(int p[], int n){
    int m[MAX][MAX];
    int q, i, j, k, l;

    for(int i = 1; i < n; i++){
        m[i][i] = 0;
    }

    for(l = 2; l <= n; l++){
        for(i = 1; i <= n - l + 1; i++){
            j = i + l - 1;
            m[i][j] = INF;
            for(k = i; k < j; k++){
                q = m[i][k] + m[k + 1][j] + (p[i - 1] * p[k] * p[j]);
                m[i][j] = min(m[i][j], q);
            }
        }
    }

    return m[1][n];
}

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





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

typedef long long ll;
typedef long double ld;

ll niz[1000005];
ll dp[1000005];

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n, k;
    cin >> n >> k;
    for(int i=1; i<=n; i++){
        cin >> niz[i];
    }
    for(int i=2; i<=n; i++){
        dp[i] = 1000000000;
        for(int j=i-1; j>=1 && i-j <= k; j--){
            dp[i] = min(dp[i], dp[j] + abs(niz[i] - niz[j]));
        }
    }
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 5120
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#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;
 
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         UNIQUE(v)                   v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;
//int dx[]={0,0,1,-1,1,1,-1,-1};
//int dy[]={1,-1,0,0,1,-1,1,-1};

#define lim 10005

ll a[lim];
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n,k;
    sfl(n),sfl(k);
    for(ll i=1;i<=n;i++){
        sfl(a[i]);
    }
    sort(a+1,a+n+1);
    ll sum=0;
    for(ll i=1;i<=k;i++){
        sum += a[i];
    }
    cout << sum << endl;
    return 0;
}


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

ll dp[100001][13] = {0};
const int m = 13;

int main()
{
    string S;
    cin >> S;
    ll n = S.size();
    // 初期化
    if (S[n - 1] == '?') REP(i, 10) dp[1][i] = 1;
    else dp[1][S[n - 1] - '0'] = 1;

    vector<ll> r(n + 1);
    r[0] = 1;
    for (int i = 1; i <= n; ++i)
    {
        r[i] = (10 * r[i - 1]) % m;
    }
    for (int i = 2; i <= n; ++i)
    {
        if (S[n - i] == '?')
        {
            for (int j = 0; j <= 9; ++j)
            {
                int res = (j * r[i - 1]) % m;
                for (int k = 0; k < m; ++k)
                {
                    dp[i][(res + k) % m] += dp[i - 1][k];
                    dp[i][(res + k) % m] = dp[i][(res + k) % m] % MOD;
                } 
            }
        }
        else
        {
            int res = ((S[n - i] - '0') * r[i - 1]) % m;
            for (int k = 0; k < m; ++k)
            {
                dp[i][(res + k) % m] += dp[i - 1][k];
                dp[i][(res + k) % m] = dp[i][(res + k) % m] % MOD;
            }
        }
    }

    cout << dp[n][5] << endl;
}


Measured memory_bytes: 11392
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define DEBUG true
#define $(x) {if (DEBUG) {cout << #x << " = " << (x) << endl;}}


int main() {
    LL N;
    cin >> N;
    VI A(N), B(N);
    LL a_sum = 0, b_sum = 0;
    REP(i, N) {
        cin >> A[i];
        a_sum += A[i];
    }
    REP(i, N) {
        cin >> B[i];
        b_sum += B[i];
    }
    if (a_sum < b_sum) {
        cout << "-1" << endl;
        return 0;
    }
    LL ans = 0, debt = 0;
    VI plus;
    REP(i, N) {
        if (A[i] < B[i]) {
            ans++;
            debt += B[i] - A[i];
        } else if (A[i] > B[i]) {
            plus.PB(A[i] - B[i]);
        }
    }
    RSORT(plus);
    LL index = 0;
    while (debt > 0) {
        debt -= plus[index];
        index++;
        ans++;
    }
    cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 2552
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

const int N=2e5+5;
int n,a[N],pos[N];

void init()
{
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;++i) scanf("%d",&a[i]),pos[a[i]]=i;
}

void work()
{
	int i,cnt=0,now=0;
	for(i=n-1;i;--i)
	{
		if(!cnt)
		{
			if(pos[i]>pos[i+1]) ++cnt,now=i+1;
			continue;
		}
		if(pos[now]<=pos[i]&&pos[i]<=pos[i+1]) continue;
		if(pos[i]<=pos[i+1]&&pos[i+1]<=pos[now]) continue;
		if(pos[i+1]<=pos[now]&&pos[now]<=pos[i]) continue;
		++cnt,now=i+1;
	}
	printf("%d\n",cnt);
}

int main()
{
	init();work();
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n, p;
    cin >> n >> p;
    ll onecnt = 0;
    ll zerocnt = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        if (a % 2 == 1)
            ++onecnt;
        else
            ++zerocnt;
    }

    vector<vector<ll>> comb(n + 1, vector<ll>(n + 1));
    comb[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= i; ++j) {
            comb[i][j] = comb[i - 1][j];
            if (j > 0)
                comb[i][j] += comb[i - 1][j - 1];
        }
    }

    ll ans = 0;
    for (int i = p; i <= onecnt; i += 2) {
        ans += comb[onecnt][i];
    }

    cout << ans * (1LL << zerocnt) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const ll mod = 1e9 + 7;
const int M = 2e6 + 5;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   if(pow < 0) return 0;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;ll c = (a * b)%mod;return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(2e6 + 7)] , inv_fac[(int)(2e6 + 7)];
void precomp_factorial(){fac[0] = 1;for(ll i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(ll i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};

using namespace std;


int main()
{
  int n, x;
  cin >> n >> x;
  int g = 0;
  for(int i = 0; i < n; i++){
      int n1;
      cin >> n1;
      n1 = (abs(n1-x));
      g = gcd(n1, g);
       //cout << n1 << " " << g << endl;
  }
  cout << g;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ull<<62)-1)
#define cINFINT ((1<<30)-1)


int main()
{
	ll n,a[3],b[3];
	cin>>n>>a[0]>>a[1]>>a[2]>>b[0]>>b[1]>>b[2];
	
	ll maxx = n;
	REP( n0, 5001 )
	{
		if( n0 * a[0] > n ) break;
		ll nn = n - n0 * a[0];
		REP( n1, 5001 )
		{
			if( n1 * a[1] > nn ) break;
			ll nnn = nn - n1 * a[1];

			ll n2 = 0;
			if( b[2] > a[2] ) n2 = nnn / a[2]; 
			ll next = nnn - n2*a[2] + n0*b[0] + n1*b[1] + n2*b[2];

			maxx = max( maxx, next );
		}
	}
	n = maxx;
	
	if( a[0]>b[0] && a[1]>b[1] && a[2]>b[2] )
	{
		REP( n0, 5001 )
		{
			if( n0 * b[0] > n ) break;
			ll nn = n - n0 * b[0];
			REP( n1, 5001 )
			{
				if( n1 * b[1] > nn ) break;
				ll nnn = nn - n1 * b[1];

				ll n2 = 0;
				if( a[2] > b[2] ) n2 = nnn / b[2]; 
				ll next = nnn - n2*b[2] + n0*a[0] + n1*a[1] + n2*a[2];

				maxx = max( maxx, next );
			}
		}
		n = maxx;
	}
	else
	{
		ll ba[2];
		if( a[0] <= b[0] )
			ba[0] = 1, ba[1] = 2;
		else if( a[1] <= b[1] )
			ba[0] = 0, ba[1] = 2;
		else
			ba[0] = 0, ba[1] = 1;

		REP( n0, 25000001 )
		{
			if( n0 * b[ba[0]] > n ) break;
			ll nn = n - n0 * b[ba[0]];

			ll n1 = 0;
			if( a[ba[1]] > b[ba[1]] ) n1 = nn / b[ba[1]]; 
			ll next = nn - n1*b[ba[1]] + n0*a[ba[0]] + n1*a[ba[1]];

			maxx = max( maxx, next );
		}
		n = maxx;
	}

	cout << n << endl;
	return 0;
}

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

#define ll long long int
#define mod 1000000007
#define sbits(x) __builtin_popcountll(x)
#define zbits(x) __builtin_ctzll(x)
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x

using namespace std;

int main()
{
	int k;
	cin>>k;
	int a,b;
	cin>>a>>b;
	int f=0;
	for(int i=a;i<=b;i++){
		if(i%k == 0) {
			f=1;
			cout<<"OK";
			break;
		}
	}
	if(f==0) cout<<"NG";
	return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <climits>
#include <math.h>
#include <utility>
#include <ctime>
#include <cstdlib>
using namespace std;

typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main() {
	vc a(2), b(2);
	rep(i, 2)cin >> a.at(i);
	rep(i, 2)cin >> b.at(i);
	int x, y;
	x = (a.at(0) - '0') * 10 + (a.at(1) - '0');
	y = (b.at(0) - '0') * 10 + (b.at(1) - '0');
	if ((1 <= x and x <= 12) and (1 <= y and y <= 12)) {
		cout << "AMBIGUOUS" << endl;
		return 0;
	}
	if ((1 <= x and x <= 12) and !(1 <= y and y <= 12)) {
		cout << "MMYY" << endl;
		return 0;
	}
	if (!(1 <= x and x <= 12) and (1 <= y and y <= 12)) {
		cout << "YYMM" << endl;
		return 0;
	}
	if (!(1 <= x and x <= 12) and !(1 <= y and y <= 12)) {
		cout << "NA" << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#coding: Shift_JIS

def set_array(a,n):
	str=input()
	array=str.split()
	for i in range(n):
		a.append(int(array[i]))
	

n=int(input())
S=[]
set_array(S,n)
q=int(input())
T=[]
set_array(T,q)
C=0

def binary_search(S,x):
	s=0
	e=len(S)-1
	while s<=e:
		med=int((s+e)/2)
		if S[med]==x: return 1
		elif S[med]>x: e=med-1
		else: s=med+1
	return 0

for v in T:
	C+=binary_search(S,v)

print(C)



Measured memory_bytes: 17748
n=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
pre=-1
cnt=0
ans=0
for i in range(n):
    a=A[i]
    if a==pre:
        cnt+=1
        pre=-1
        if ans ==0:
            ans+=a
        else:
            ans*=a
    else:
        pre=a
    if cnt==2:
        break
print(ans)

Measured memory_bytes: 14252
#include <iostream>
#include <cstring>

using namespace std;


int play_turn(char s[], char h, int turn)
{
    // aiko
    if (s[turn] == h)
        return 0;
    // win
    if (s[turn] == 'g' && h == 'p')
        return 1;
    return -1;
}


int play(char s[], int num_p, int num_g, int turn)
{
    if (turn == strlen(s))
        return 0;

    int point_p = play_turn(s, 'p', turn);
    int point_g = play_turn(s, 'g', turn);
    if (num_p >= num_g) {
        return point_g + play(s, num_p, num_g + 1, turn + 1);
    }

    if (point_g >= point_p)
        return point_g + play(s, num_p, num_g + 1, turn + 1);
    else
        return point_p + play(s, num_p + 1, num_g, turn + 1);
}


char s[100000];
int main(void)
{
    cin >> s;

    int ans = play(s, 0, 0, 0);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void){
    char str[10];
    int count = 0;
    int i,j = 0;
    
    scanf("%s", str);
    
    for(i = 0; i < 10; i++){
        if(str[i] == 'A' || str[i] == 'C' || str[i] == 'G' || str[i] == 'T'){
            j++;
        }else{
            if(count < j){
                count = j;
            }
            j = 0;
        }
    }
    if(count < j){
        count = j;
    }
    
    printf("%d", count);
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FI          freopen("input.txt", "r", stdin)
#define FO          freopen("output.txt", "w", stdout)
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 1e5 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-9;
//int dx[] = {0, -1}, dy[] = {-1, 0};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
ll dp[N][2][105];
int k;
vi v;
ll f(int i, bool flag, int sum){
    if(i == sz(v)) return (sum % k == 0);
    ll &ans = dp[i][flag][sum];
    if(ans == -1){
        ans = 0;
        for(int j = 0; j < 10; j++){
            if(flag or j <= v[i])
                ans = (ans % mod + f(i + 1, flag || (j < v[i]), (sum + j) % k) % mod) % mod;
        }
    }
    return ans;
}
ll get(string &x){
    cls(dp, -1);
    for(auto i : x)
        v.pb(i - '0');
    return f(0, 0, 0);
}
void solve(){
    string str;
    cin >> str >> k;
    cout << (get(str) - 1 + mod) % mod << '\n';
}  
int main(){
    FIN;
    int t = 1;
    //cin >> t;
    for(int i = 1; i <= t; i++){
        solve(); 
    }
    //EjecuteTime;
    return 0;
}       

Measured memory_bytes: 169008
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int a[20][20][2],num[20];
int main(){
	n=read();m=(1<<n)-1;
	for(register int i=1;i<=n;i++){
		num[i]=read();
		for(register int j=1;j<=num[i];j++){
			a[i][j][0]=read();a[i][j][1]=read();
		}
	}
	int ans=0;
	for(register int s=1;s<=m;s++){
		int flag=0,numm=0;
		for(register int i=1;i<=n;i++){
			if((1<<(i-1))&s){
				numm++;
				for(register int j=1;j<=num[i];j++){
					if(a[i][j][1]==1 && !((1<<(a[i][j][0]-1)) & s)){flag=1;break;}
					if(a[i][j][1]==0 && ((1<<(a[i][j][0]-1)) & s)){flag=1;break;}
				}
			}
		}
		if(!flag)ans=max(ans,numm);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] l = new int[n];
		for (int i = 0; i < n; i++) {
			l[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(l);

		int sum = 0;
		for (int i = 0; i < n - 1; i++) {
			sum += l[i];
		}
		if (sum > l[n - 1])
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}


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

int main() {
  int H, W; cin >> H >> W;
  vector<string> S(H);
  for (int i = 0; i < H; i++) cin >> S.at(i);
  vector<int> Mx(H*W);
  vector<int> My(H*W);
  for (int y = 0; y < H; y++) {
    int tmp = 0;
    int cnt = 0;
    for (int x = 0; x < W; x++) {
      if (S.at(y).at(x) == '#') {
        for (int i = 0; i < cnt; i++) {
          Mx.at(W*y+tmp+i) = x - tmp;
        }
        tmp = x+1;
        cnt = 0;
        continue;
      }
      cnt++;
    }
    for (int i = 0; i < cnt; i++) {
      Mx.at(W*y+tmp+i) = W - tmp;
    }
  }
  for (int x = 0; x < W; x++) {
    int tmp = 0;
    int cnt = 0;
    for (int y = 0; y < H; y++) {
      if (S.at(y).at(x) == '#') {
        for (int i = 0; i < cnt; i++) {
          My.at(W*(tmp+i)+x) = y - tmp;
        }
        tmp = y+1;
        cnt = 0;
        continue;
      }
      cnt++;
    }
    for (int i = 0; i < cnt; i++) {
      My.at(W*(tmp+i)+x) = H -tmp;
    }
  }
  int ans = 0;
  for (int i = 0; i < H*W; i++) {
    ans = max(ans, Mx.at(i) + My.at(i) - 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

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

signed main(){
	int a,b,t;
	cin>>a>>b>>t;
	cout<<t/a*b<<endl;


	return 0;
}



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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A+B > C+D){
    cout << "Left" << endl;
  }
  else if (A+B < C+D){
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
//const int N = 3e5+7 ;
//const int INF = 1e18 ;
//const int MOD = 1e9 + 7 ;


void solve(){
	string s ;
	cin >> s ;
	if(s[0] == '7' || s[1] == '7' || s[2] == '7')cout << "Yes\n" ;
	else cout << "No\n" ;

}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


Measured memory_bytes: 3664
P = 10**9 + 7
N, M = map(int, input().split())

d = [0]*(M+1)
d[0] = 1
for i in range(1, M+1):
    d[i] = (d[i-1]*i)%P

ans = d[M]*pow(d[M-N], P-2, P)
ans **= 2
ans %= P
for i in range(1, N+1):
    temp = (d[N]*pow(d[N-i], P-2, P)*pow(d[i], P-2, P))%P
    temp *= d[M]
    temp %= P
    temp *= pow(d[M-i], P-2, P)
    temp %= P
    temp *= ((d[M-i]*pow(d[max(M-N, 1)], P-2, P))**2)%P
    ans += (temp%P)*(-1)**i
    ans %= P
print(ans%P)

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


const int INF=1e+9;

int main(){
   long long a,b,c;
   cin>>a>>b>>c;

   if(a==b&&b==c){
      if(a%2==1)
         cout<<0<<endl;
      else
         cout<<-1<<endl;
      return 0;
   }

   int cnt=0;
   while(a%2==0&&b%2==0&&c%2==0){
      int ha=a/2,hb=b/2,hc=c/2;
      a=hb+hc;
      b=ha+hc;
      c=ha+hb;
      cnt++;
   }

   cout<<cnt<<endl;
}

Measured memory_bytes: 256
///////////////////////////////////////////
// product.cpp created 2018-12-22
// Kamil Tokarski

/*       biblioteczka       */
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <string>
#include <iomanip>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;

// types
typedef long long ll;
typedef long double ld;

#define PR  pair
#define PII pair<ll, ll>
#define PLL pair<ll, ll>

#define VEC vector
#define VL VEC<ll>
#define VI VEC<ll>
#define VPI VEC<PII>
#define VPL VEC<PLL>

// IO
#define fastio ios_base::sync_with_stdio(NULL);cout.tie(NULL);cin.tie(NULL)
#define precise(x) cout << fixed << setprecision(x)

#define read_file(var, file) ifstream var(file)
#define write_file(var, file) ofstream var(file)
#define close_file(var) var.close()

// containers
#define sz(x) (ll)(x.size())
#define all(x) x.begin(), x.end()
/*          koniec          */
const ll MAXN = 1e7 + 1;

struct Div {
  ll value;
  ll alpha;

  bool operator<(const Div &d) const {
    return alpha < d.alpha; 
  }
};
vector<Div> divs;

ll N, P;
ll sito[MAXN];

ll get_pow(ll a, ll b) {
  if(b == 0)
    return 1;
  if(b == 1)
    return a;

  ll val = get_pow(a, b / 2);
  if(b & 1)
    return val * val * a;
  return val * val;
}

int main(int argc, char **argv) {
  fastio;

  cin >> N >> P; 
  if(N == 1) {
    cout << P << endl;
    return 0;
  }

  for(ll i = 2; i < MAXN; ++i) {
    ll alpha = 0;
    while((P % i) == 0)
      ++alpha,
        P /= i;
    if(alpha > 0)
      divs.push_back({i, alpha});
  }

  if(P > 1)
    divs.push_back({P, 1});

  ll gcd = 1;
  for(auto &d : divs) {
    ll reflow = (d.alpha) / N;
    if(reflow == 0)
      continue;

    gcd *= get_pow(d.value, reflow);
  }

  cout << gcd << endl;
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
using namespace std;
int main(void)
{
  char α;
  
  scanf("%c", &α);
  
  if((α>='a')&&(α<='z')){
    printf("a");
  }
  else if((α>='A')&&(α<='Z')){
    printf("A");
  }
  return 0;
}


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

int main () {
  int a, b;
  cin >> a >> b;
  cout << (a + b) % 24 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc =new Scanner(System.in);
		
		int a=sc.nextInt();
		int b=sc.nextInt();
		
		int ans =0;
		ans= Math.max(a+b, a-b);
		ans= Math.max(ans, a*b);
		
		System.out.println(ans);
		
}
}




Measured memory_bytes: 23252
#include <stdio.h>

int main() {
	int k, s, x, y, z, cnt;

	scanf("%d%d", &k, &s);
	cnt = 0;
	for (x = 0; x <= k; x++)
		for (y = 0; y <= k && x + y <= s; y++) {
			z = s - x - y;
			if (z <= k)
				cnt++;
		}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int i,j,k,m,n,a,b,c;
char s[10000];
int main()
{
	scanf("%d",&n);
	scanf("%s",&s);
	scanf("%d",&k);
	for(int i=0;i<n;i++)
	{
		if(s[i]!=s[k-1]) printf("*");
		else cout<<s[i];
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,y;
    int a[]={0,1,3,1,2,1,2,1,1,2,1,2,1};
    cin>>x>>y;
    if(a[x]==a[y]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define I inline
I int MAX(int a,int b)
{
	return a>b?a:b;
}
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	printf("%d",MAX(MAX(a-b,a+b),a*b));
	return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toLong() }

    // a, b <= n && a % b >= k

    fun 特定の割る数に対してすべての余りを考慮できる場合(divisor: Long): Long {

        var patternNum = n / divisor
        var restSetNum = divisor - k

        return patternNum * restSetNum
    }

    fun 特定の割る数に対して上限Nの関係で一部の余りしか考慮できない場合(divisor: Long): Long {

        var num: Long

        if (k != 0L) {
            num = n % divisor - (k - 1)
        } else {
            num = n % divisor
        }

        return if (num < 0) 0 else num
    }

    var count = 0L

    for (i in (k + 1)..n) {
        // 割る数を k ~ n に変えていったときの数を算出
        // 最後の一つ手前まで + 最後余ったところ
        count += 特定の割る数に対してすべての余りを考慮できる場合(i) + 特定の割る数に対して上限Nの関係で一部の余りしか考慮できない場合(i)
    }

    print(count)
}

// 考慮するべきケース
// k = 0 の場合 -> OK
// n = 1 の場合 -> OK
// 結果が Int に収まらないケース !! 

Measured memory_bytes: 38008
#168 - F
import sys
import numpy as np
#from numba import njit


def main():
    N, M = map(int, sys.stdin.buffer.readline().split())
    LineData = np.int64(sys.stdin.buffer.read().split())

    INF = 10**9 + 1

    LineData = LineData.reshape(-1, 3)
    A, B, C = LineData[:N].T
    D, E, F = LineData[N:].T
    #X = np.unique(np.concatenate([D, [-INF, 0, INF]]))
    #Y = np.unique(np.concatenate([C, [-INF, 0, INF]]))
    X = np.unique(np.concatenate([D, [-INF, INF]]))
    Y = np.unique(np.concatenate([C, [-INF, INF]]))
    A = np.searchsorted(X, A)
    B = np.searchsorted(X, B, 'right') - 1
    C = np.searchsorted(Y, C)
    D = np.searchsorted(X, D)
    E = np.searchsorted(Y, E)
    F = np.searchsorted(Y, F, 'right') - 1

    area = cal_area(A, B, C, D, E, F, X, Y)

    if area == 0:
        print("INF")
    else:
        print(area)


#@njit
def cal_area(A, B, C, D, E, F, X, Y):
    x = np.searchsorted(X, 0, 'right') - 1
    y = np.searchsorted(Y, 0, 'right') - 1

    DX = X[1:] - X[:-1]
    DY = Y[1:] - Y[:-1]

    A = A.tolist()
    B = B.tolist()
    C = C.tolist()
    D = D.tolist()
    E = E.tolist()
    F = F.tolist()
    X = X.tolist()
    Y = Y.tolist()
    DX = DX.tolist()
    DY = DY.tolist()

    LenX = len(X)
    LenY = len(Y)

    visit = [[False] * LenY for _ in range(LenX)]
    visit[x][y] = True
    area = 0
    queue = [(x, y)]

    LineX = [[False] * LenY for _ in range(LenX)]
    LineY = [[False] * LenY for _ in range(LenX)]

    for x1, x2, y in zip(A, B, C):
        for x in range(x1, x2):
            LineY[x][y] = True

    for x, y1, y2 in zip(D, E, F):
        for y in range(y1, y2):
            LineX[x][y] = True

    while queue:
        x, y = queue.pop()

        if x == 0 or x == LenX - 1 or y == 0 or y == LenY - 1:
            area = 0
            break
        
        area += DX[x] * DY[y]

        if not LineX[x][y] and not visit[x - 1][y]:
            visit[x - 1][y] = True
            queue.append((x - 1, y))
        if not LineY[x][y] and not visit[x][y - 1]:
            visit[x][y - 1] = True
            queue.append((x, y - 1))
        if not LineX[x + 1][y] and not visit[x + 1][y]:
            visit[x + 1][y] = True
            queue.append((x + 1, y))
        if not LineY[x][y + 1] and not visit[x][y + 1]:
            visit[x][y + 1] = True
            queue.append((x, y + 1))

    return area


if __name__ == '__main__':
	main()

sys.exit()


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

uint64_t get_rand_range(uint64_t min_val, uint64_t max_val) {
    static std::mt19937_64 mt64(0);

    std::uniform_int_distribution<uint64_t> get_rand_uni_int( min_val, max_val );

    return get_rand_uni_int(mt64);
}
  
int main() {
  int D;
  cin >> D;
  
  for (int i = 0; i < D; i++) {
    int ans = get_rand_range(1, 26);
    cout << ans << endl;
  }
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc103/tasks/abc103_d

int main() {
    int N, M; cin >> N >> M;
    P p[M];
    REP(i, M) {
        int a, b; cin >> a >> b;
        p[i] = {b, a};
    }
    sort(p, p+M);

    int cnt = 0;
    int now = 0;

    REP(i, M) {
        int l = p[i].second;
        int r = p[i].first;
        if (l >= now) {
            cnt++;
            now = r;
        }
    }

    cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize "trapv"
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ld long double
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,a,n) for(int i=a;i<n;i++)
#define all(v) v.begin(),v.end()
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
int main()
{
    fio;
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n,k;
        cin>>n>>k;
        ll a[n];
        rep(i,n)
        cin>>a[i];
        ll l=1,r=(ll)1e9,mid=0;
        ll res=INT_MAX;
        while(l<=r)
        {
            mid=l+(r-l)/2;
            int trials=0;
            rep(i,n)
            {
                if(a[i]>mid){
                trials+=((a[i]+mid-1)/mid)-1;
                }
            }
            if(trials>k)
            l=mid+1;
            else
            {
                r=mid-1;
                res=min(res,mid);
            }
        }
        cout<<res<<endl;
    }
}

Measured memory_bytes: 5140
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define mod 1000000007

using namespace std;
class CompareFirst
{
public:
  bool operator()(pair<int,int> n1,pair<int,int> n2) {
    return n1.first>n2.first; //>:desc <:asc
  }
};


int main(){

  string s;
  int i,j,k,l,n,m;
  vector<string> vs;
  vector<int> vi;
  pair<int,int> pr;
  //unordered_map<string,int> mp;
  //priority_queue<int> pq; // default ‘å‚«‚¢‡
  //priority_queue<pair<int,int>,vector<pair<int,int>>,CompareFirst> pq;

  cin >> n;
  int a[n],b[n],c[n];
  
  rep(i,0,n-1){
    cin >> a[i];
    --a[i];
  }
  rep(i,0,n-1){
    cin >> b[i];
  }
  rep(i,0,n-2){
    cin >> c[i];
  }
  
  int ans = 0;
  int prev = 999;
  rep(i,0,n-1){
    ans += b[a[i]];
    if(prev == a[i]-1)ans += c[a[i]-1];
    prev = a[i];
//    cout <<a[i] << " " << b[a[i]] <<" " << ans << endl;
  }
    
  

  cout << ans << endl;
//  printf("%.10f\n",ans);

  return 0;

}


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

int main()
{
	int H, W, h, w; scanf("%d%d%d%d", &H, &W, &h, &w);
	int a = 4000, b = -(h * w - 1) * a - 1;
	if(H % h == 0 && W % w == 0) return 0 * puts("No");
	puts("Yes");
	for(int i = 1; i <= H; i++, puts(""))
		for(int j = 1; j <= W; j++)
		{
			if(i % h == 0 && j % w == 0) printf("%d ", b);
			else printf("%d ", a);
		}
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
        ll i,j,k;

        for(i=1;i<6;i++){
                ll x;
                cin>>x;
                if(x==0)k=i;
        }
        cout<<k<<endl;
        return 0;
}


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

int main() {
  int n;
  while(cin >> n && n) {
    int a[6]={1,2,3,6,5,4};
    string s;
    while(n--) {
      cin >> s;
      if(s[0]=='n') {
	swap(a[0],a[4]);
	swap(a[3],a[4]);
	swap(a[1],a[3]);
      } else if(s[0]=='e') {
	swap(a[0],a[2]);
	swap(a[2],a[3]);
	swap(a[3],a[5]);
      } else if(s[0]=='s') {
	swap(a[0],a[1]);
	swap(a[1],a[3]);
	swap(a[3],a[4]);
      } else {
	swap(a[0],a[5]);
	swap(a[3],a[5]);
	swap(a[2],a[3]);
      }
    }
    cout << a[0] << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    A, B = map(int, input().split())
    if B % A == 0:
        print(A + B)
    else:
        print(B - A)


if __name__ == '__main__':
    main()


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

#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset((a), v, sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

int main() {
	string S; cin >> S;
	if (S[2] == S[3] && S[4] == S[5]) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

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

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

	vector<char> sVec(s.size());
	for (int i = 0; i < s.size(); i++) sVec[i] = s.at(i);

	vector<int> a(q);
	
	int reverseFlag = 0;

	for (int i = 0; i < q; i++) {
		cin >> a[i];
		if (a[i] == 1) {
			if (reverseFlag == 0) reverseFlag = 1;
			else reverseFlag = 0;
		}
		else { // a[i] == 2
			
			int tmp_i; cin >> tmp_i;
			char tmp_c; cin >> tmp_c;
			
			if (tmp_i == 1 + reverseFlag) {
				sVec.insert(sVec.begin(), tmp_c);
			}
			else {
				sVec.push_back(tmp_c);
			}
		}
	}

	if (reverseFlag == 1)reverse(sVec.begin(), sVec.end());

	string ans;
	for (int i = 0; i < sVec.size(); i++) {
		ans += sVec.at(i);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2236
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;

class Main {
    // static {
    //     try {
    //         System.setOut(new PrintStream(new File("output.txt")));
    //         new File("input.txt").createNewFile();
    //         System.setIn(new FileInputStream(new File("input.txt")));
    //     } catch (Exception e) {
    //         e.printStackTrace();
    //     }
    // }
    static FastReader fastReader = new FastReader();
    static BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(System.out));
    static StringBuffer stringBuffer = new StringBuffer();

    public static void main(String[] args) throws Exception {
        try {
            // int testCases = fastReader.nextInt();
            int testCases=1;
            while (testCases-- > 0) {
                int n=fastReader.nextInt();
                long a[]=new long[n];
                long b[]=new long[n];
                long c[]=new long[n];
                for(int i=0;i<n;i++){
                    a[i]=fastReader.nextInt();
                    b[i]=fastReader.nextInt();
                    c[i]=fastReader.nextInt();
                }
                long dp[][]=new long[n][3];
                dp[0][0]=a[0];
                dp[0][1]=b[0];
                dp[0][2]=c[0];
                for(int i=1;i<n;i++){
                    dp[i][0]=a[i]+Math.max(dp[i-1][1], dp[i-1][2]);
                    dp[i][1]=b[i]+Math.max(dp[i-1][0], dp[i-1][2]);
                    dp[i][2]=c[i]+Math.max(dp[i-1][0], dp[i-1][1]);
                }
                System.out.println(Math.max(dp[n-1][0], Math.max(dp[n-1][1], dp[n-1][2])));
                
            }
            bufferedWriter.write(stringBuffer.toString());
            bufferedWriter.flush();
        } catch (Exception e) {
            return;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

Measured memory_bytes: 61452
/*

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

using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

void flagfunc3(bool flag){cout<<(flag?"Yes\n":"No\n");}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  string s;cin>>s;
  int hoge=0;
  rep(i,s.size())hoge+=s[i]-'0';
  flagfunc3(hoge%9==0);
}

Measured memory_bytes: 3732