akhauriyash/Code-Regression huggingface dataset:
n = int(input())
stmp = list(input())
Q = int(input())
target = ord("a")
s = [ord(stmp[i])-target for i in range(n)]

class BIT:
	"""
	<Attention> 0-indexed.
	query ... return the sum [0 to m]
	sum ... return the sum [a to b]
	sumall ... return the sum [all]
	add ... 'add' number to element (be careful that it doesn't set a value.)
	search ... the sum version of bisect.right
	output ... return the n-th element
	listout ... return the BIT list
	"""
	
	def query(self, m):
		res = 0
		while m > 0:
			res += self.bit[m]
			m -= m&(-m)
		return res
	
	def sum(self, a, b):
		return self.query(b)-self.query(a)
	
	def sumall(self):
		bitlen = self.bitlen-1
		return self.query(bitlen)
	
	def add(self, m, x):
		m += 1
		bitlen = len(self.bit)
		while m <= bitlen-1:
			self.bit[m] += x
			m += m&(-m)
		return
	
	def __init__(self, n):
		self.bitlen = n+1
		self.bit = [0]*(n+1)

b = [BIT(n) for i in range(26)]
for i in range(n):
	b[s[i]].add(i, 1)

for _ in range(Q):
	q,qtmpa,qtmpb = input().split()
	if q[0] == "1":
		qa = int(qtmpa)
		t = ord(qtmpb)-target
		b[t].add(qa-1, 1)
		b[s[qa-1]].add(qa-1, -1)
		s[qa-1] = t
	else:
		ans = 0
		qta = int(qtmpa)
		qtb = int(qtmpb)
		for i in range(26):
			if b[i].sum(qta-1, qtb) != 0:
				ans += 1
		print(ans)


Measured memory_bytes: 171012
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define MOD = 998244353;
#define int long long int
#define double long double
#define inf (int)(1e15)
#define all(x) (x).begin(), (x).end()
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define isYes(x) printf("%s\n", (x) ? "Yes" : "No")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define isIn(x, y, h, w) (x >= 0 && x < h && y >= 0 && y < w)
#define pair pair<int, int>
typedef vector<int> vi;   // Vector of long long
typedef vector<vi> vvi;   // Vector of vi
typedef vector<pair> vii; // Vector of pairs
typedef vector<vii> vvii; // Vector of Vector of pairs
typedef vector<bool> vb;  // Vector of bool
#define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value)
#define ff first          // For pairs
#define ss second
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}, dy8[] = {1, -1, 1, 0, -1, 1, -0, -1};
#define testcases(t) \
    int(t);          \
    cin >> (t);      \
    while ((t)--)
#define range(c, r) (c).begin(), (c).begin() + (r)    // Mainly used in sorting
#define present(c, x) ((c).find(x) != (c).end())      // for sets, maps, multi-maps
#define cpresent(c, x) (find(all(c), x) != (c).end()) // for vectors
#define run(x, c) for ((x) = (c).begin(); (x) != (c).end(); (x)++)
#define fo0 (i, n) for (i = 0; i < n; i++)
#define fo1 (i, n) for (i = 1; i <= n; i++)
#define rfo(i, n) for (i = n - 1; i >= 0; i--)
#define rfor(i, n) for (i = n; i > 0; i--)
signed main()
{
    int n, a, b;
    cin >> a >> b >> n;
    int val = min(n, b - 1);
    int ans = ((a * val) / b) - (a * (val / b));
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define deb(x) cout << #x << " " << x << endl;

typedef long long ll;
#define For(i,n) for(int i=0;i<n;i++)
int x[101];
int main(){
    int t,i,n,j,k;
   // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int avg1,avg2,sum,sum1,sum2=0;
    sum=0;
    
    sum1=0;
    cin>>n;
    For(i,n){
        cin>>x[i];
        sum+=x[i];
    }
    
        avg1=(sum+n-1)/n;
        avg2=(sum)/n;
    sum=0;
    For(i,n){
        sum1+=(x[i]-avg1)*(x[i]-avg1);
        sum2+=(x[i]-avg2)*(x[i]-avg2);
    }
    cout<<min(sum1,sum2);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define mod 1000000007
#define inf 1<<30
#define mp(a,b) make_pair(a,b)
#define len(u,N) u.begin(),u.begin()+N


ll N;
string S;
ll B[200010];
ll W[200010];

int main() {
    cin >> N;
    cin >> S;
    rep(i,N){
        if (S[i] == '#'){
            B[i+1] = B[i]+1;
        }
        else B[i+1] = B[i];
    }
    // rep(i,N+1) cout << B[i] << " ";
    // cout << endl;
    rep(i,N){
        if (S[i] == '.'){
            W[i+1] = W[i]+1;
        }
        else W[i+1] = W[i];
    }
    // rep(i,N+1) cout << W[i] << " ";
    // cout << endl;
    ll res = 10000000007;
    rep(i,N+1){
        ll temp = W[N]-W[i] + B[i]-B[0];
        res = min(res,temp);
    }
    cout << res << endl;
    return 0;
}


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

long long N, W, weight[105], value[105], ans;
long long dp[105][100005];

long long f(long long n, long long v) {
	if (n==0) {
		if (v==0) return 0;
		else return 1e12;
	}
	if (dp[n][v] != -1) return dp[n][v];
	dp[n][v] = f(n-1, v);
	if (v >= value[n])
		dp[n][v] = min(dp[n][v], f(n-1, v-value[n])+weight[n]);
	return dp[n][v];
}

int main() {
	cin >> N >> W;
	for(int i=1; i<=N; i++) {
		cin >> weight[i] >> value[i];
	}
	memset(dp, -1, sizeof(dp));
	for(int i=0; i<=100000; i++) {
		long long res = f(N, i);
		if (res <= W)
			ans = i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 82304
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

struct Permutation {
	typedef int Index;
	int m;
	vector<Index> v;
	Permutation() {}
	Permutation(int m_) : v(m), m(m_) {
		clear();
	}
	void clear() {
		rep(i, m) v[i] = i;
	}
	Permutation operator*(const Permutation &that) const {
		assert(m == that.m);
		Permutation x(m);
		rep(i, m) x.v[i] = that.v[v[i]];
		return x;
	}
	Permutation &operator*=(const Permutation &that) {
		return *this = *this * that;
	}
	Permutation inverse() const {
		Permutation x(m);
		rep(i, m) x.v[v[i]] = i;
		return x;
	}
};
Permutation operator^(const Permutation& t, ll k) {
	Permutation A = t, B = Permutation(t.m);
	while(k) {
		if(k & 1) B *= A;
		A *= A;
		k >>= 1;
	}
	return B;
}

int main() {
	//2 x - y
	int N;
	while(~scanf("%d", &N)) {
		vector<int> xs(N);
		for(int i = 0; i < N; ++ i)
			scanf("%d", &xs[i]);
		int M; long long K;
		scanf("%d%lld", &M, &K);
		vector<int> as(M);
		for(int i = 0; i < M; ++ i)
			scanf("%d", &as[i]), -- as[i];
		Permutation perm(N);
		for(int a : as)
			swap(perm.v[a - 1], perm.v[a]);
		perm = perm ^ K;
		ll cur = xs[0];
		for(int i = 0; i < N; ++ i) {
			printf("%lld\n", cur);
			if(i < N - 1) {
				int a = perm.v[i];
				cur += xs[a + 1];
				cur -= xs[a];
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2560
n = int(input())
s = list(input())
a = {}
b = {}
c = []
for i in range(n):
  a = set(s[:i+1])
  b = set(s[i+1:])
  c.append(len((a&b)))
  a.clear()
  b.clear()
print(max(c))
  


Measured memory_bytes: 3060
n = int(input())
for i in range(1,n+1):
    if i % 3 == 0:
        print(" {0}".format(i), end="")
    else:
        x = i
        while x != 0:
            if x % 10 == 3:
                print(" {0}".format(i), end="")
                break;
            x //= 10;
print("")

Measured memory_bytes: 7880
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.1415926535897932384626;
long long int mod = 1000000007;
 
vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//abcのbed乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 





ll i,j,k,ii,jj;
ll n,m,num,sumxor,sum,ans;
ll a,b,c,d,e,f,g,h,w,v;
ll x[800005],y[800005],z[900005];
ll v1[500005],v2[500005];
ll vnum,vnew,vold;
char s[500005];
ll dp[85][5005];
bool dame;

void unite(ll a,ll b){
	v1[vnum] = a;
	v2[vnum] = b;
	vnum ++;
}

void unitenew(ll a){
	v1[vnum] = a;
	v2[vnum] = vnew;
	vnew++;
	vnum++;
}


int main(){	
	cin>>s;
	n = strlen(s);
	
	if(s[0] == '0' || s[n-1] == '1'){
		dame = true;
	}
	
	for(i=0;i<n-1;i++){
		if(s[i] != s[n-2-i])dame=true;
	}
	
	if(dame){
		p(-1);
		return 0;
	}

	num = 0;
	for(i=(n)/2;i>=0;i--){
		if(s[i]=='1'){
			x[num] = i+1;
			num++;
		}
	}
	unite(1,2);

	vnew = 3;
	vold = 1;
	//deba(num);
	for(i=0;i<num-1;i++){
		for(j=0;j<x[i]-x[i+1];j++){
			//deba(x[i]-x[i+1]);
			unitenew(vold);
			
		}
		vold = vnew - 1;

	}
	while(vnew <= n){
		unite(2,vnew);
		vnew++;
	}
	for(i=0;i<vnum;i++){
		pe(v1[i]);
		p(v2[i]);
	}

		


	return 0;
}

Measured memory_bytes: 35328
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

int A,B;
char C;

signed main(){

    in(A,C,B);
    out(C=='+'?A+B:A-B);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

template <class T>
struct fenwick {
    vector<T> node;
    int n;
    fenwick(int _n)
        : n(_n) {
        node.resize(n);
    }
    void add(int x, T v) {
        while (x < n) {
            node[x] += v;
            x |= (x + 1);
        }
    }
    T get(int x) {
        T v = 0;
        while (x >= 0) {
            v += node[x];
            x = (x & (x + 1)) - 1;
        }
        return v;
    }
    T get(int a, int b) {  // [a, b]
        return get(b) - (a ? get(a - 1) : 0);
    }
    int lower_bound(T v) {
        int x = 0;
        int h = 1;
        while (n >= (h << 1)) {
            h <<= 1;
        }
        for (int k = h; k > 0; k >>= 1) {
            if (x + k <= n && node[x + k - 1] < v) {
                v -= node[x + k - 1];
                x += k;
            }
        }
        return x;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), t(n), b, c;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        t[i] = a[i];
        if (i % 2 == 0) {
            b.emplace_back(a[i]);
        } else {
            c.emplace_back(a[i]);
        }
    }
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    sort(t.begin(), t.end());
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            a[i] = b[i / 2];
        } else {
            a[i] = c[i / 2];
        }
        a[i] = lower_bound(t.begin(), t.end(), a[i]) - t.begin();
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 != a[i] % 2) {
            ans++;
        }
    }
    cout << ans / 2 << '\n';
    return 0;
}

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

int Par[100000];

void init(int n)
{
	for(int i = 0;i<n;i++)
	{
		Par[i] = i;
	}
}

int find(int x)
{
	if(x==Par[x])return x;
	return Par[x] = find(Par[x]);
}

void unite(int x,int y)
{
	x = find(x);
	y = find(y);
	Par[y] = x;
}
bool same(int x,int y)
{
	return find(x)==find(y);
}

int main()
{
	int n,q;
	cin >> n >> q;
	init(n);
	while(q--)
	{
		int com;
		cin >> com;
		int x,y;
		cin >> x >> y;
		if(com==0)
		{
			unite(x,y);
		}
		else
		{
			if(same(x,y))
			{
				cout<<1<<endl;
			}
			else
			{
				cout<<0<<endl;
			}
			
		}
		
	}
}


Measured memory_bytes: 3132
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int X[200005];
int ans[200005];
vector<pair<int,int> >pa;

int main() {

	int N;

	scanf("%d",&N);

	int i,j;

	for(i=1;i<=N;i++){
		scanf(" %d",&X[i]);
		pa.push_back(make_pair(X[i],i));
	}

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

	int check[2]={pa[N/2].first,pa[(N/2)-1].first};

	for(i=0;i<N/2;i++){
		ans[pa[i].second]=check[0];
	}
	for(i=N/2;i<N;i++){
		ans[pa[i].second]=check[1];
	}

	for(i=1;i<=N;i++){
		cout<<ans[i]<<endl;
	}

	return 0;
}

Measured memory_bytes: 5744
n = int(input())
csf = [list(map(int, input().split())) for _ in range(n-1)]

from math import ceil

for i in range(n):
    t = 0
    for c, s, f in csf[i:]:
        t = max(s, ceil(t / f) * f)
        t += c
    print(t)
    


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
ll n;
int main(){
	
	cin>>n;
	
	for(int i=n;;i++){
		if(prime(i)){
			cout<<i<<endl;
			return 0;
		}
	}
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rgi register int
#define ll long long
class fastin{
	private: int _ch,_f;
	public: inline fastin& operator>>(char&c) {c=getchar(); return *this;}
		template<typename _Tp> inline fastin& operator>>(_Tp&_x){
		_x=0; while(!isdigit(_ch)) _f|=(_ch==45),_ch=getchar();
		while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
		_f&&(_x=-_x,_f=0); return *this;}
	fastin() {_ch=_f=0;}
}fin;
class fastout{
#define endl '\n'
	private: int _num[32],_head;
	public: inline fastout& operator<<(char c) {putchar(c); return *this;}
		template<typename _Tp> inline fastout& operator<<(_Tp _x){
		_Tp _k; if(_x==0) {putchar('0'); return *this;} if(_x<0) putchar('-'),_x=-_x;
		while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
		while(_head>0) putchar(_num[_head]),--_head; return *this;}
	fastout() {_head=0;}
}fout;
// ----------------------------
// #define int ll
// using namespace std;
const int maxn=200004;
const int mod=998244353,inf=1000000007;

int a[maxn];
signed main()
{
	int n,k;
	fin>>n>>k;
	for(rgi i=1;i<=n;++i) fin>>a[i];
	std::sort(a+1,a+1+n);
	ll sum=0;
	for(rgi i=1;i<=k;++i) sum+=a[i];
	fout<<sum;;
	return 0;
}
// ----------------------------
// by imzzy


Measured memory_bytes: 3600
import bisect
MAX_N=2*10**5
isdmore5=[1 for i in range(MAX_N+1)]
isprime=[1 for i in range(MAX_N+1)]
i=2
isprime[0]=0;isprime[1]=0
isdmore5[0]=0;isdmore5[1]=0
while(i*i<=MAX_N):
    if isprime[i]!=0:
        for j in range(2*i,MAX_N+1,i):
            isprime[j]=0
    i+=1
prime=[]
for i in range(MAX_N+1):
    if isprime[i]==1:
        prime.append(i)
        isdmore5[i]=0
#print(prime)
for p in prime:
    k=bisect.bisect_left(prime,MAX_N//p)
    #print(p,k,prime[k-1]*p,prime[k]*p,prime[k+1]*p)
    for i in range(k):
        #print(p,prime[i],p*prime[i])
        isdmore5[p*prime[i]]=0
i=2
while(i*i*i<=MAX_N):
    if isprime[i]==1:
        isdmore5[i*i*i]=0
    i+=1
ans=[0 for i in range(MAX_N+1)]
for i in range(3,MAX_N+1):
    if isdmore5[i]==1:
        ans[i]=ans[i-1]+1
    else:
        ans[i]=ans[i-1]
Q=int(input())
for i in range(Q):
    print(ans[int(input())])


Measured memory_bytes: 15372
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n; cin >> n;
	string s; cin >> s;
	ll r = 0;
	rep(i,n) if(s[i] == 'R') r++;
	ll ans = r;
	ll now = 0;
	ll w = 0;
	rep(i,n){
		if(s[i] == 'R') now++;
		else w++;
		chmin(ans, max(r-now, w));
	}
	cout << ans << "\n";
}


Measured memory_bytes: 3724
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
  L,R,d = parseMap(split(readline()))
  count = 0
  for i in L:R
    if i%d ==0
      count+=1
    end
  end
  println("$count")
end
main()


Measured memory_bytes: 162704
#include <stdio.h>
int n;
int a, b;
int x, y;
int main() {
	scanf("%d", &n);
	a = n / 100;
	b = n % 100;
	if (a <= 12 && a > 0)x++;
	if (b <= 12 && b > 0)y++;
	if (x * y)printf("AMBIGUOUS\n");
	if (x == 1 && y == 0)printf("MMYY\n");
	if (x == 0 && y == 1)printf("YYMM\n");
	if (x == 0 && y == 0)printf("NA\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string>
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int h[n];
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }   
    sort(h, h + n); 

    int ans = 1000000000;
    for (int i = 0; i < n - k + 1; i++) {
        if (ans > h[i + k - 1] - h[i]) {
            ans = h[i + k - 1] - h[i];
        }
    }   
    cout << ans;
}


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

int main()
{
  int x, y, z;

  cin >> x >> y >> z;

  if (x == 1){
    cout << "Hello World";
  }

  else{
    cout << y + z;
  }
}


Measured memory_bytes: 3568
N = int(input())
s = []
for i in range(N):
    s.append(str(input()))
M = int(input())
t = []
for j in range(M):
    t.append(str(input()))
MAX = 0
for k in range(N):
    kari = s[k]
    ao = s.count(kari)
    aka = t.count(kari)
    kane = ao-aka
    if kane >= MAX:
        MAX = kane
print(MAX)

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

int main() {
  int Max , N , M;
  Max = 0;
  cin >> N;
  vector<string> vec1(N);
  
  for (int i=0; i < N ; i++){ //配列を代入。
    cin >> vec1.at(i);
  }
  
  cin >> M;
  vector<string> vec2(M);
  
  for (int i=0; i < M ; i++){ //配列を代入。
    cin >> vec2.at(i);
  }
  
  //テスト:配列の出力
  //for (int i=0; i<N ; i++){
    //cout << vec1.at(i) << ' ';
  //}

  for (int i = 0 ; i < N ; i++){
    int count = 0;
    for (int j = 0 ; j < N ; j++){
      if (vec1.at(j)==vec1.at(i)){
        count ++;
      }
    }
    for (int k = 0 ; k < M ; k++){
      if (vec2.at(k)==vec1.at(i)){
        count --;
      }
    }
    if (count > Max){
      Max = count;
    }
  }
  cout << Max << endl;
    
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int A, B, C;
  int i;
  i = scanf("%d %d %d", &A, &B, &C);
  for(i = 1; i < B; i ++){
    if((A * i) % B == C){
      printf("YES\n");
      return 0;
    }
  }
  printf("NO\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define F(i, a, b) for (int i = (a); i < (b); ++i)
#define F2(i, a, b) for (int i = (a); i <= (b); ++i)
#define dF(i, a, b) for (int i = (a); i > (b); --i)
#define dF2(i, a, b) for (int i = (a); i >= (b); --i)
#define maxn 1010
using namespace std;
typedef long long LL;
bool flag[maxn];
struct Point {
    int x, y;
    bool operator < (const Point& p) const {
        return x < p.x && y < p.y;
    }
}a[maxn], b[maxn];
typedef long long LL;
struct Edge {
    int to, ne;
    Edge(int _to=0, int _ne=0) : to(_to), ne(_ne) {}
}edge[20000];
int tot, ne[maxn], match[maxn], vis[maxn];
void add(int u, int v) {
    edge[tot] = Edge(v, ne[u]);
    ne[u] = tot++;
}
int find(int u) {
    for (int i = ne[u]; ~i; i = edge[i].ne) {
        int v = edge[i].to;
        if (!vis[v]) {
            vis[v] = true;
            if (!match[v] || find(match[v])) {
                match[v] = u;
                return true;
            }
        }
    }
    return false;
}
int main() {
    memset(ne, -1, sizeof ne);
    int n, x, y;
    scanf("%d", &n);
    F(i, 0, n) scanf("%d%d", &a[i].x, &a[i].y);
    F(i, 0, n) scanf("%d%d", &b[i].x, &b[i].y);
    F(i, 0, n) {
        F(j, 0, n) {
            if (a[i]<b[j]) add(i+1, j+n+1), add(j+n+1, i+1);
        }
    }
    int cnt=0;
    F2(i, 1, n) {
        memset(vis, 0, sizeof vis);
        if (find(i)) ++cnt;
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

// min
int main(void){
  int n = 0;
  char w[101][11];


  scanf("%d", &n);
  
  // 読み込みと判定の箇所は分ける
  for(int i = 0; i < n; i++){
    scanf("%s", w[i]);
  }

  for(int i = 1; i < n; i++){
    if(w[i - 1][strlen(w[i - 1]) - 1] != w[i][0]){
      printf("No\n");
      return 0;
    }
    for(int j = 0; j < i; j++){
      if(strcmp(w[i], w[j]) == 0){
        printf("No\n");
        return 0;
      }
    }

  }

  printf("Yes\n");

  return 0;

}


Measured memory_bytes: 128
def is_x(x,k,d):
    if x==0:
        if k%2==0:
            print(0)
            exit()
        else:
            print(d)
            exit()

def x_is_mosbat(x,k,d):
    if x<0:
        x=-x
    p=x//d
    if p>=k:
        print(x-d*k)
        exit()
    else:
        x=x-d*p
        k-=p
        if abs(x-d)<x:
            x=x-d
            k-=1
        if k%2==0:
            print(abs(x))
            exit()
        else:
            print(abs(x-d)) if x>0 else print(x+d)
            exit()
    
x,k,d=map(int,input().split())
is_x(x,k,d)
x_is_mosbat(x,k,d)

Measured memory_bytes: 61768
#include <bits/stdc++.h>
//#include <map>
//#include <set>
//#include <list>
//#include <cmath>
//#include <ctime>
//#include <deque>
//#include <queue>
//#include <stack>
//#include <string>
//#include <bitset>
//#include <cstdio>
//#include <limits>
//#include <vector>
//#include <climits>
//#include <cstring>
//#include <cstdlib>
//#include <fstream>
//#include <numeric>
//#include <sstream>
//#include <iomanip>
//#include <iostream>
//#include <algorithm>
//#include <unordered_map>

using namespace std;

#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.141592653589793238462643383279502884
#define MAX 1000100
#define mod 1000000007
#define EPS 1E-9
#define int long long
#define endl "\n"

int fix(int cur, int m)
{
    return ((cur%m) + m) % m;
}

int fast_power(int x, int y,int m)
{
    if (y == 0)
        return 1;
    int temp = fast_power(x, y / 2, m) ;
    temp = (temp*temp)% m;
    if (y % 2 != 0)
        temp = (temp*x)% m;
    return temp;

}


int32_t main()
{
    //freopen("D:/Important Files/Cocktail/SOLVE/TestLib/testcases/input/input11.txt", "r", stdin);
    //freopen("D:/Important Files/Cocktail/SOLVE/TestLib/testcases/output/output11.txt", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.tie(0);

    int n,k;
    cin >> n>>k;
    int arr[n];
    for(int i=0;i<n;cin>>arr[i++]);

    int mx=-1e9;

    int acum[n+1]={};
    for(int i=1;i<=n;i++)
        acum[i]=arr[i-1]+acum[i-1];



    int s,e;
    for(int i=0;i<=n-k;i++)
    {
        int dif=acum[i+k]-acum[i];
        if(dif>mx)
        {
            mx=dif;
            s=i,e=i+k;
        }
    }
    double sum=0;
    for(int i=s;i<e;i++)
    {
        int cc=arr[i];
        sum+=(arr[i]+1)/2.0;
    }
    cout << fixed <<setprecision(6) << sum << endl;




    return 0;
}


Measured memory_bytes: 3456
#include <iostream>

int main(){
    int A, B, K, X, S;
    
    std::cin >> A >> B >> K;
   if(A<B) S = A;
      else S = B;
    for(int lp = 0; lp < K; lp++){
     
      if(A%S == 0 && B%S == 0) X = S;
      else lp--;
      S--;
    }
    std::cout << X << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#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++)
const long long INF =  999999999;

typedef pair<int,int> P;

int cost[2010][2010];
int mincost[2020];
bool used[2020];
int V;

int main(){
  int n,res=0;
  cin>>n;
  REP(i,n){
    REP(j,n){
      cin>>cost[i][j];
    }
  }
  REP(i,n){
    mincost[i]=INF;
    used[i]=false;
  }
  mincost[0]=0;

  while(true){
    int v=-1;

    REP(u,n){
      if(!used[u] &&(v==-1 || mincost[u]<mincost[v]))v=u;
    }

    if(v==-1)break;
    used[v]=true;
    res += mincost[v];

    REP(u,n){
      if(cost[v][u]==-1)continue;
      mincost[u]=min(mincost[u],cost[v][u]);
    }
  }
  cout<<res<<endl;

}



Measured memory_bytes: 3440
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

#define int long

const int INF = 1000000009;
const long LINF = 1123456789012345678;

int n, k;
signed main(){
	scanf("%ld %ld", &n, &k);
	if((n+1)/2 >= k){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int dp[2][1000010];
int fault[1000010],temp[1000010];
	

int main(){
	int n,p;
	cin>>n>>p;
	int x[n],y[n];
	rep(i,n)cin>>x[i]>>y[i];
	rep(i,2)rep(j,p+1)dp[i][j]=-1;
	dp[0][p]=0;
	rep(i,p+1){fault[i]=0;temp[i]=0;}
	rep(i,n){
		rep(j,p+1){
			if(dp[0][j]==-1)continue;
			dp[1][j]=dp[0][j];
			temp[j]=0;
			if(fault[j]==0){
				if(x[i]>=y[i]){
					if(dp[1][j]<dp[0][j]+1){
						dp[1][j]=dp[0][j]+1;
						temp[j]=0;
					}
				}else{
					if(j>=(y[i]-x[i])){
						if(dp[1][j-(y[i]-x[i])]<dp[0][j]+1){
							dp[1][j-(y[i]-x[i])]=dp[0][j]+1;
							temp[j-(y[i]-x[i])]=y[i]-x[i];
						}
					}
				}
			}else{
				if((x[i]-fault[j]>=y[i])){
					dp[1][j]=dp[0][j]+1;
					temp[j]=0;
				}else{
					int alt=max(x[i]-fault[j],0);
					if(j>=(y[i]-alt)){
						if(dp[1][j-(y[i]-alt)]<dp[0][j]+1){
							dp[1][j-(y[i]-alt)]=dp[0][j]+1;
							temp[j-(y[i]-alt)]=(y[i]-alt);
						}
					}
				}
			}
		}
		rep(j,p+1)dp[0][j]=dp[1][j];
		rep(j,p+1)fault[j]=temp[j];
	}
	int ans=0;
	rep(i,p+1){
		ans=max(ans,dp[1][i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 18660
A,B,K = map(int,input().split())
lsans = []
for i in range(A,A+K):
    if i <= B:
        lsans.append(i)
for j in range(B+1-K,B+1):
    if j >= A and not(j in lsans):
        lsans.append(j)
for i in lsans:
    print(i)

Measured memory_bytes: 8960
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <cmath>

#define ll long long
#define eps 1e-8
#define MOD 1000000007

#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f

// change if necessary
#define MAXN 1000000

using namespace std;

ll n, k;
vector<vector<ll>> grid;

vector<vector<ll>> matrix_mult(vector<vector<ll>> m1, vector<vector<ll>> m2) {
    vector<vector<ll>> ans;

    for (ll i = 0; i < m1.size(); i++) {
        vector<ll> row;
        for (ll j = 0; j < m2[0].size(); j++) {
            ll sum = 0;
            for (ll a = 0; a < m1[0].size(); a++) {
                sum += m1[i][a] * m2[a][j];

                // include if mod is necessary
                sum %= MOD;
            }
            
            row.push_back(sum);
        }

        ans.push_back(row);
    }

    return ans;
}

vector<vector<ll>> matrix_expo(vector<vector<ll>> m, ll n) {
    if (n == 1) {
        return m;
    }

    vector<vector<ll>> temp = matrix_expo(m, n / 2);

    if (n % 2 == 0) {
        return matrix_mult(temp, temp);
    }

    return matrix_mult(matrix_mult(temp, temp), m);
}

int main() {
    cin.tie(0)->sync_with_stdio(0);

    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        grid.push_back(vector<ll>());
        for (int j = 0; j < n; j++) {
            int x; cin >> x;
            grid[i].push_back(x);
        }
    }

    auto res = matrix_expo(grid, k);
    ll ans = 0;

    for (auto v : res) {
        for (auto x : v) {
            ans += x;
            if (ans > MOD) ans -= MOD;
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N; cin >> N;
    string s; cin >> s;
    int k; cin >> k;

    char c = s[k-1];
    for(int i=0; i<s.size(); i++){
        if(s[i] != c) s[i] = '*';
    }

    cout << s << endl;
}

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

typedef long long ll;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    // 前処理
    COMinit();

    int n,k;
    cin >> n >> k;

    ll ans = 0;
    ll limit = min(k, n-1);
    for(int l = 0; l <= limit; l++){
        ans += COM(n, l) * COM(n-1, l);
        ans %= MOD;
    }
    cout << ans << endl;

}


Measured memory_bytes: 12160
a = int(input(""))
b = input("").split(" ")
c = 0
d = []

for i in range(a):
	c = 0
	while (int(b[i]) % 2 == 0):
		b[i] = int(b[i]) / 2
		c += 1
	d.append(c)
print(min(d))

Measured memory_bytes: 3060
// IOI 2021
 
#include <bits/stdc++.h>
using namespace std;
 
#define endl "\n"
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9, MOD = 1e9 + 7;
 
/////////////////////////////////////////////////////////////////////
 
const int N = 1e5 + 5;

int X[N];

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

	int n, a, b; cin >> n >> a >> b;
	for (int i = 0; i < n; i++) cin >> X[i];
	ll ans = 0;
	for (int i = 1; i < n; i++) ans += min(1LL * b, 1LL * a * (X[i] - X[i - 1]));
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
const int INF=1e9;

int main(){
    int n,x;cin>>n>>x;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    int sum=0;
    int ans;
    for(int i=0;i<n;i++){
        sum+=a[i];
        if(sum==x){
            ans=i+1;break;
        }
        else if(sum>x){
            ans=i;break;
        }
    }
    if(sum<x) ans=n-1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <string.h>

int main(){
	int n;
	char a[3];
	int ac=0,wa=0,tle=0,re=0;
	scanf("%d",&n);
	for(int i=0; i<n; i++){
		scanf("%s",&a);
		if (strcmp(a,"AC") == 0) ac++;
		else if (strcmp(a,"WA") == 0) wa++;
		else if (strcmp(a,"TLE") == 0) tle++;
		else re++;
	}
	printf("AC x %d\n", ac);
	printf("WA x %d\n", wa);
	printf("TLE x %d\n", tle);
	printf("RE x %d\n", re);
	return 0;
}

Measured memory_bytes: 1684
#include <bits/stdc++.h>
using namespace std;
#define debug pt(rt),cerr<<'\n'
const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}

const int N=2e5+50;
int n,a[N],nowmx;
inline unsigned int unit() {static unsigned int x=19260817; x^=(x<<13); x^=(x>>17); x^=(x<<5); return x;}
inline int Max(int x,int y) {return (x>y) ? x : y;}
struct node {
	node *lc,*rc;
	unsigned int pri;
	int val,sze,mx,all,tag; 
	node() : lc(NULL),rc(NULL),pri(unit()),sze(0),mx(0),all(1) {}
	inline void upt() {
		mx=Max(Max(rc->mx,lc->mx),val);
		sze=lc->sze+rc->sze+1;
		all=lc->all&rc->all&tag;
	}
} *rt,*nowrt,Pool[N],*pool=Pool,*null=pool;
typedef pair <node*,node*> pii;
inline node* merge(node *x,node *y) {
	if(y==null) return x;
	if(x==null) return y;
	if(x->pri>y->pri) {
		x->rc=merge(x->rc,y);
		x->upt(); return x;
	} else {
		y->lc=merge(x,y->lc);
		y->upt(); return y;
	}
}
inline pii split(node *x,int sze) {
	if(x==null) return pii(null,null);
	if(x->lc->sze>=sze) {
		pii tr=split(x->lc,sze);
		x->lc=tr.second; x->upt();
		return pii(tr.first,x);
	} else {
		pii tr=split(x->rc,sze-x->lc->sze-1);
		x->rc=tr.first; x->upt();
		return pii(x,tr.second);
	}
}
inline void Merge(node *&x,node *y) {
	if(y==null) {return;}
	if(x==null) {x=y; return;}
	node *t=x; while(t->rc!=null) t=t->rc;
	node *t2=y; static node* stk[N]; int top=0;
	while(t2->lc!=null) stk[++top]=t2, t2=t2->lc;
	t2->tag=(t2->val>t->val) ? 1 : 0; t2->upt();
	while(top) stk[top--]->upt();
	x=merge(x,y);
}
inline pii split_val(node *x,int lim) {
	if(x==null) return pii(null,null);
	if(Max(x->val,x->lc->mx)<lim) {
		pii tr=split_val(x->rc,lim);
		x->rc=tr.first; x->upt();
		return pii(x,tr.second); 
	} else {
		pii tr=split_val(x->lc,lim);
		x->lc=tr.second; x->upt();
		return pii(tr.first,x);
	}
}
inline node* find_nxt(int lim) {
	pii tr=split_val(rt,lim);
	int res=0; 
	node *t=tr.second;
	while(t!=null) {
		if(!t->lc->all) t=t->lc;
		else if(!t->tag) {res+=t->lc->sze; break;}
		else {res+=t->lc->sze+1; t=t->rc;}
	}
	pii tr2=split(tr.second,res);
	Merge(nowrt,tr.first);
	rt=tr2.second; 
	return tr2.first;
}
inline node* newnode() {
	node *t=++pool;
	t->lc=t->rc=null;
	return t;
}
node* q[N]; int qt;
int main() {
	n=rd(); rt=null; nowmx=n;
	for(int i=1;i<=n;i++) a[i]=rd();
	for(int i=0;i<=n;i++) {
		node *t=newnode();
		t->val=a[i]; t->sze=1; t->mx=a[i];
		t->all=(i ? (a[i]>a[i-1]) : 1);
		t->tag=t->all; 
		rt=merge(rt,t);
	}
	int step=0;
	while(!rt->all) {
		++step;
		int mxval=1, pos=0;
		qt=0;
		nowrt=null;
		while(mxval<nowmx) 
			mxval=(q[++qt]=find_nxt(mxval))->mx;
		Merge(nowrt,rt); rt=nowrt;
		for(int i=1;i<=qt;i++) Merge(rt,q[i]);
		while(nowmx>3) {
			pii tr=split(rt,nowmx);
			if(tr.second->val==nowmx) rt=tr.first, --nowmx;
			else {rt=merge(tr.first,tr.second); break;}
		}
	}
	cout<<step<<'\n';
}

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

int main(){
    vector<vector<int>> a(3, vector<int>(3));
    for (int i=0; i<3; i++){
        for (int j=0; j<3; j++){
           cin >> a.at(i).at(j);
        }
    }

    int n;
    cin >> n;

    vector<int> b(n);
    for (int i=0; i<n; i++){
        cin >> b.at(i);
    }
    
    int count=0;
    for(int i=0; i<3; i++){
        for (int k=0; k<n; k++){
            if(b.at(k) == a.at(i).at(0)){
                count++;
            }
        }
    } 
    if(count == 3){
        cout << "Yes" << endl;
        return 0;
    }
    
    count = 0;   
    for(int i=0; i<3; i++){
        for (int k=0; k<n; k++){
            if(b.at(k) == a.at(i).at(1)){
                count++;
            }
        }
    } 
    if(count == 3){
        cout << "Yes" << endl;
        return 0;
    }
    
    count = 0;
    for(int i=0; i<3; i++){
        for (int k=0; k<n; k++){
            if(b.at(k) == a.at(i).at(2)){
                count++;
            }
        }
    } 
    if(count == 3){
        cout << "Yes" << endl;
        return 0;
    }
    
    count = 0;
    for(int i=0; i<3; i++){
        for (int k=0; k<n; k++){
            if(b.at(k) == a.at(0).at(i)){
                count++;
            }
        }
    } 
    if(count == 3){
        cout << "Yes" << endl;
        return 0;
    }

    count = 0;
    for(int i=0; i<3; i++){
        for (int k=0; k<n; k++){
            if(b.at(k) == a.at(1).at(i)){
                count++;
            }
        }
    } 
    if(count == 3){
        cout << "Yes" << endl;
        return 0;
    }

        count = 0;
    for(int i=0; i<3; i++){
        for (int k=0; k<n; k++){
            if(b.at(k) == a.at(2).at(i)){
                count++;
            }
        }
    } 
    if(count == 3){
        cout << "Yes" << endl;
        return 0;
    }
    
    count = 0;
    for(int i=0; i<3; i++){
        for (int k=0; k<n; k++){
            if(b.at(k) == a.at(i).at(i)){
                count++;
            }
        }
    } 
    if(count == 3){
        cout << "Yes" << endl;
        return 0;
    }

        count = 0;
    for(int i=0; i<3; i++){
        for (int k=0; k<n; k++){
            if(b.at(k) == a.at(i).at(2-i)){
                count++;
            }
        }
    } 
    if(count == 3){
        cout << "Yes" << endl;
        return 0;
    }
    
    cout << "No" << endl;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> l={1};
    for(int i=6; i<=N; i*=6) l.push_back(i);
    for(int i=9; i<=N; i*=9) l.push_back(i);
    sort(l.begin(), l.end());
    l.erase(unique(l.begin(), l.end()), l.end());

    queue<int> q;
    q.push(N);
    set<int> used;
    for(int res = 1;; res++){
        auto n = q.size();
        for(int i=0;i<n;i++){
            auto v = q.front(); q.pop();
            for(auto j : l){
                if(v < j) continue;
                if(used.count(v - j) > 0) continue;
                if(v == j){
                    cout << res << endl;
                    return 0;
                }
                q.push(v - j);
                used.insert(v - j);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

void solve()
{
	int N;
	cin >> N;
	int ans = 1;
	while (ans * 2 <= N)
	{
		ans *= 2;
	}
	cout << ans << endl;
}

int main()
{
	solve();
	return(0);
}

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

using namespace std; 

int main() 
{
	int a;

	cin >> a;

	if(a>=30)
	{
		cout << "Yes";
	}

	else
	{
		cout << "No";
	}
		
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int a;
  cin>>a;
  cout<<48-a<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>



int main(){

	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);

	int max=a;

	if(b>max) max=b;

	if(c>max) max=c;

	printf("%d\n", a+b+c-max);

	return 0;

}

Measured memory_bytes: 128
R, G, B, N = map(int, input().split())

cnt = 0
for r in range(N//R+1):
    Rr = R*r
    for g in range((N-Rr)//G+1):
        if (N-(R*r + G*g)) % B == 0:
            cnt += 1
print(cnt)

Measured memory_bytes: 2940
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		String aString = scanner.next();
		String xString = scanner.next();
		String cString = scanner.next();

		System.out.println("A" + xString.charAt(0) + "C");
	}
}

Measured memory_bytes: 21844
/**
 *      purpose : ABC 59 C
 *      author  : kyomukyomupurin
 *      created : 2018-10-22 02:22:55
**/

#include <bits/stdc++.h>
using namespace std;
#define int64 long long

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    int64 a[N] = {};
    for (int i = 0; i < N; ++i) cin >> a[i];

    // i(odd) > 0
    int64 sum1 = 0; int64 cost1 = 0;
    for (int i = 0; i < N; ++i) {
        sum1 += a[i];
        if (i % 2 == 1 && sum1 <= 0) {
            cost1 += -1 * sum1 + 1; sum1 = 1;
        }
        else if (i % 2 == 0 && sum1 >= 0) {
            cost1 += sum1 + 1; sum1 = -1;
        }
    }

    //i(even) > 0
    int64 sum2 = 0; int64 cost2 = 0;
    for (int i = 0; i < N; ++i) {
        sum2 += a[i];
        if (i % 2 == 0 && sum2 <= 0){
            cost2 += -1 * sum2 + 1; sum2 = 1;
        }
        else if (i % 2 == 1 && sum2 >= 0){
            cost2 += sum2 + 1; sum2 = -1;
        }
    }
    cout << min(cost1, cost2) << '\n';
    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)


int main() {
    int N, d[50];
    cin >> N;
    rep(i,N) cin >> d[i];


    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i == j) {
                continue;
            }
            ans += d[i] * d[j];
        }
    }

    cout << ans/2 << endl;
    return 0;

}


Measured memory_bytes: 256