akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

unordered_set<string> expr[16];
unordered_map<string, int> exprset;

int mns[1 << 16];
int eval(const string &s, int a, int &p){
	if(s[p] == '-'){
		p++;
		return !eval(s, a, p);
	}
	if(s[p] == '('){
		p++;
		int l = eval(s, a, p);
		char op = s[p++];
		int r = eval(s, a, p);
		assert(s[p] == ')');
		p++;
		if(op == '*') return l && r;
		if(op == '^') return l ^  r;
		assert(0);
	}
	char v = s[p++];
	if(v == '0' || v == '1') return v == '1';
	return a >> (v - 'a') & 1;
}
int eval(const string &s, int a){
	int p = 0;
	return eval(s, a, p);
}
int calcset(const string &s){
	if(exprset.count(s)) return exprset[s];
	int ans = 0;
	rep(a, 1 << 4) ans |= eval(s, a) << a;
	return exprset[s] = ans;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	rep(i, 1 << 16) mns[i] = 16;
	for(const auto &p : {"0", "1", "a", "b", "c", "d"}){
		expr[1].insert(p);
		mns[calcset(p)] = 1;
	}
	for(int i = 2; i < 16; i++){
		for(const auto &j : expr[i - 1]) expr[i].insert("-" + j);
		for(int j = 1; j < i - 2; j++) for(const auto &k : expr[j]) if(i - j > 3) for(const auto &l : expr[i - j - 3]){
			for(const auto &p : {"(" + k + "*" + l + ")", "(" + k + "^" + l + ")"}){
				int x = calcset(p);
				if(mns[x] != 16) continue;
				expr[i].insert(p);
				mns[x] = i;
			}
		}
	}
	//dbg(expr[15].size());
	for(int i = 1; i < 15; i++) for(const auto &j : expr[i]){
		int ans = calcset(j);
		mns[ans] = min(mns[ans], i);
	}
	
	//rep(i, 1 << 16) dbg(i, mns[i]);
	
	
	string s;
	while(cin >> s, s != "."){
		cout << mns[calcset(s)] << endl;
	}
	
	return 0;
}

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

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

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> x(N), y(N);
    REP(i, N) cin >> x[i] >> y[i];

    vector<ll> permutation;
    REP(i, N) permutation.push_back(i);
    double ans = 0;
    ll count = 0;
    do{
        REP(i, N - 1)
        {
            ll src = permutation[i], dst = permutation[i + 1];
            ans += sqrt((double)((x[src] - x[dst]) * (x[src] - x[dst]) + (y[src] - y[dst]) * (y[src] - y[dst])));
        }
        count++;
    }while(next_permutation(ALL(permutation)));
    ans /= count;

    cout << fixed;
    cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

bool is_prime[1000001];

vector<ll> compute_factors(ll target_num){
  vector<ll> res;
  for(ll i = 2; i * i <= target_num; i++){
    if(!is_prime[i]) continue;
    if(target_num % i == 0){
      int count = 0;
      while(target_num % i == 0){
        target_num /= i;
        count++;
      }
      res.push_back(count);
    }
  }

  if(target_num != 1){
    res.push_back(1);
  }
  return res;
}

ll count_combination(const vector<ll>& factors,vector<ll>& current){
  if(current.size() == factors.size()){
    ll tmp = 1;
    for(int i = 0; i < factors.size(); i++){
      if(factors[i] == current[i]){
        tmp *= factors[i] + 1;
      }
    }
    return tmp;
  }

  ll res = 0;
  for(int i = 0; i <= factors[current.size()]; i++){
    current.push_back(i);
    res += count_combination(factors,current);
    current.pop_back();
  }
  return res;
}

int main(){
  memset(is_prime,true,sizeof(is_prime));
  is_prime[0] = false;
  is_prime[1] = false;
  for(ll i = 2; i * i <= 1000000000000; i++){
    if(is_prime[i]){
      for(ll j = i + i; j <= 1000000; j += i){
        is_prime[j] = false;
      }
    }
  }

  ll target_num;
  while(~scanf("%lld",&target_num)){
    if(target_num == 0) break;
    vector<ll> factors = compute_factors(target_num);
    vector<ll> current;
    printf("%lld\n",(count_combination(factors,current) + 1) / 2);
  }
}

Measured memory_bytes: 2188
#include <stdio.h>
#include <math.h>
 
int isprime(int);
 
main(){
 
  int n,res=0;
  int i;
  int A[10000];
   
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<n;i++){
    if(isprime(A[i])==0) res++;
  }
 
 
  printf("%d\n",res);
 
  return 0;
}
 
 
 
int isprime(int x)
{
  int i;
 
  if(x==2) return 0;
 
  if(x<2 || x%2==0) return 1;
 
 
  i=3;
  while(i<=sqrt(x)){
    if(x%i==0) return 1;
    i+=2;
  }
  return 0;
 }

Measured memory_bytes: 632
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

a=factorization(int(input()))

b=[1,3,6,10,15,21,28,36,43]

ans=0
if len(a)==1 and a[0][0]==1:
    print(0)
    exit()

for i in a:
    for j in range(len(b)):
        if i[1]<b[j]:
            ans+=j
            break
print(ans)

Measured memory_bytes: 9372
use std::io;

fn main(){
    loop{
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        let n = s.trim().parse().unwrap();
        if n == 0{
            break;
        }
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        let p: Vec<f64> = s.trim().split_whitespace().map(|x| x.parse().unwrap()).collect::<_>();
        let mut m: f64 = 0.;
        for i in 0..n{
            m += p[i] / n as f64;
        }
        let mut a: f64 = 0.;
        for i in 0..n{
            a += (p[i] - m).powi(2) / n as f64;
        }
        println!("{}", a.sqrt());
    }
}


Measured memory_bytes: 5088
#include<iostream>
#include<stdio.h>
#include<iomanip>
using namespace std;

int main() {

  int a, b, c, x, ans=0;
  cin >> a >> b >> c >> x;
  for(int i=0; i<=a; i++){
    for(int j=0; j<=b; j++){
      for(int k=0; k<=c; k++){
        if(x==i*500+j*100+k*50){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<set>  
#include<map>  
#include<stack>  
#include<cmath>  
#include<cstdio>  
#include<queue>  
#include<vector>  
#include<cstring> 
#include<climits>  
#include<iostream> 
#include<algorithm> 
using namespace std; 
#define INF 1000000000000000
#define MAXN 100000
#define LL long long
LL read(){ 
    LL f=1,x=0; 
    char c=getchar(); 
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();} 
    while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();} 
    return f*x; 
}
LL n,m,Min=1,Max=INF,val[MAXN+5],vis[MAXN+5];
struct edge{
	LL v,w;
	edge(){}
	edge(LL V,LL W){v=V,w=W;}
};
vector<edge> G[MAXN+5];
void DFS(LL x,LL u,LL fa,LL f){
	if(x<=0){
		if(f){
			printf("0\n");
			exit(0);
		}
		Min=max(Min,-x+2);
	}
	if(f) Max=min(Max,x);
	vis[u]=f+1,val[u]=x;
	LL v,w,siz=G[u].size();
	for(int i=0;i<siz;i++){
		v=G[u][i].v,w=G[u][i].w;
		if(v==fa) continue;
		if(vis[v]){
			if(vis[u]==vis[v]){
				if(((val[u]+val[v])%2+4)%2!=w%2){
					printf("0\n");
					exit(0);
				}
				if(vis[u]==1){
					Max=min(Max,1+(w-(val[u]+val[v]))/2);
					Min=max(Min,1+(w-(val[u]+val[v]))/2);
					if(Min!=Max)
						printf("0\n"),exit(0);
				}
				else{
					if(Min>1+((val[u]+val[v])-w)/2||Max<1+((val[u]+val[v])-w)/2){
						printf("0\n");
						exit(0);
					}
					Max=Min=1+((val[u]+val[v])-w)/2;
				}
			}else{
				if(val[u]+val[v]!=w){
					printf("0\n");
					exit(0);
				}
				if(val[v]<=0){
					if(vis[v]-1){
						printf("0\n");
						exit(0);
					}
					Min=max(Min,-val[v]+1);
				}
			}
			continue;
		}
		DFS(w-x,v,u,(f+1)%2);
	}
	return ;
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=m;i++){
		LL u=read(),v=read(),w=read();
		G[u].push_back(edge(v,w));
		G[v].push_back(edge(u,w));
	}
	DFS(1,1,-1,0);
	printf("%lld\n",max(0ll,Max-Min+1));
    return 0;
}

Measured memory_bytes: 17152
#include <bits/stdc++.h>
#include<set>
#include <algorithm>
#define ll long long 
#include <string.h>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
using namespace std;
int main()
{
	ll int a[5],i;
	for(i=0;i<5;i++){
		cin>>a[i];
		if (a[i]==0)
		{
			cout<<i+1<<endl;
			break;
		}
	}
	
}
    
	
		

	
			

		


 







Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop") 
#define all(a) a.begin(),a.end()
#define bs binary_search
#define ll long long int
#define ps push_back
#define fs first
#define sc second
#define mkp make_pair
#define mod 1000000007
ll dp[100001];
ll maxval(ll ar[],ll n,ll k){
	ll i,j,l=0;
	//cout<<k<<endl;
	if(dp[k]!=-1) {
		return dp[k];
	}
	for(i=0;i<n;i++){
		if(ar[i]==k){
			return dp[k]=1;
		}
		if(ar[i]>k) l++;
	}
	if(l==n) return dp[k]=0;


	ll a,b;
	for(i=0;i<n;i++){
		if(k>ar[i]){
			a=maxval(ar,n,k-ar[i]);
			if(a==0) return dp[k]=1;
		}
	}
	return dp[k]=0;
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n>>k;

	memset(dp,-1,sizeof(dp));

	ll ar[n];
	for(i=0;i<n;i++){
		cin>>ar[i];
	}
	
	l=maxval(ar,n,k);
	if(l==1) cout<<"First";
	else cout<<"Second";
	return 0;
}
//ctrl H replace

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

int main(){
  int i,j;
  char c;
  cin>>c;
  c+=1;
  cout<<c<<endl;


  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int lxl(int n)
{
	int cnt = 0;
	for(int i=1; i<=n; i++)
	{
		if(n % i == 0)
			cnt ++;
		if(cnt > 8)
			return false;
	}
	if(cnt == 8)return true;
	if(cnt < 8 || cnt > 8)return false;
}
int main()
{
	int n;
	cin >> n;
	int cnt = 0;
	for(int i=1; i<=n; i+=2)
		if(lxl(i))
			cnt ++;
	cout << cnt << endl;
}

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

int main() {
    int n;
    cin >> n;
    char s[100];
    rep(i, n) {
        cin >> s[i];
        if (s[i] == 'Y') {
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 510000;
const int MOD = 998244353;
//


        signed main() {
         string s;
         cin>>s;
         if(s.size()%2){
           cout<<"No";
           return 0;
         }
         for(int i=0;i<s.size()/2;i++){
           if(s[2*i]!='h'||s[2*i+1]!='i'){
             cout<<"No";
             return 0;
           }
         }
         cout<<"Yes";
         return 0;

       

        


      }


        


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin>>a[i];
    ll xsum = 0;
    for(int i=0; i<n; i++){
        xsum = xsum ^ a[i];
    }
    for(int i=0; i<n; i++){
        ll ans = xsum ^ a[i];
        cout<<ans<<" "; 
    }
    cout<<endl;
}

Measured memory_bytes: 4744
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

class DisjointSet {
  public:
  vector<int> rank, p;

  DisjointSet() {}
  DisjointSet(int size) {
    rank.resize(size, 0);
    p.resize(size, 0);
    rep(i, size) makeSet(i);
  }

  void makeSet(int x) {
    p[x] = x;
    rank[x] = 0;
  }

  bool same(int x, int y) {
    return findSet(x) == findSet(y);
  }

  void unite(int x, int y) {
    link(findSet(x), findSet(y));
  }

  void link(int x, int y) {
    if (rank[x] > rank[y]) {
      p[y] = x;
    }
    else {
      p[x] = y;
      if (rank[x] == rank[y]) rank[y]++;
    }
  }

  int findSet(int x) {
    if (x != p[x]) {
      p[x] = findSet(p[x]);
    }
    return p[x];
  }
};

struct Edge {
  int u, v, c;

  Edge(int u, int v, int c): u(u), v(v), c(c) {}

  bool operator < (const Edge& e) const {
    return c < e.c;
  }
};

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> p(n);
  rep(i, n) cin >> p[i].first >> p[i].second;

  vector<pair<int, int>> x(n), y(n);
  rep(i, n) {
    x[i] = {p[i].first, i};
    y[i] = {p[i].second, i};
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());

  vector<Edge> e;
  rep(i, n - 1) {
    int c = x[i + 1].first - x[i].first;
    c = min(c, abs(p[x[i + 1].second].second - p[x[i].second].second));
    e.push_back(Edge(x[i].second, x[i + 1].second, c));
  }
  rep(i, n - 1) {
    int c = y[i + 1].first - y[i].first;
    c = min(c, abs(p[y[i + 1].second].first - p[y[i].second].first));
    e.push_back(Edge(y[i].second, y[i + 1].second, c));
  }
  sort(e.begin(), e.end());

  int ans = 0;
  DisjointSet ds(n);
  rep(i, 2 * n - 2) {
    if (!ds.same(e[i].u, e[i].v)) {
      ans += e[i].c;
      ds.unite(e[i].u, e[i].v);
    }
  }
  cout << ans << endl;






  
  return 0;
}

Measured memory_bytes: 7284
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

using cat = long long;

cat mod = 998244353;

cat pw(cat a, cat e) {
	if(e <= 0) return 1;
	cat x = pw(a, e/2);
	x = x * x % mod;
	if(e&1) x = x * a % mod;
	return x;
}

cat om[22];

void ntt(cat * a, int n, bool rev = 0) {
	for(int i = 0, j = 0; i < n; ++i) {
		if(i < j) swap(a[i], a[j]);
		for(int k = n>>1; (j^=k) < k; k >>= 1) {}
	}
	for(int i = 2, e = 1; i <= n; i <<= 1, e++) {
		int len = i>>1;
		cat w = om[e];
		static cat om_pw[1<<19];
		om_pw[0] = 1;
		for(int j = 1; j < len; j++) om_pw[j] = om_pw[j-1] * w % mod;
		for(int j = 0; j < n; j += i) {
			cat * cur_ptr = om_pw;
			for(int k = j; k < j+len; ++k) {
				cat u = a[k], v = a[k+len] * *(cur_ptr++) % mod;
				a[k] = u + v, a[k+len] = u - v;
				if(a[k] >= mod) a[k] -= mod;
				if(a[k+len] < 0) a[k+len] += mod;
			}
		}
	}
	if(rev) {
		cat n_inv = pw(n, mod-2);
		reverse(a+1, a+n);
		for(int i = 0; i < n; i++) a[i] = a[i] * n_inv % mod;
	}
}

int main() {
	for(int i = 0; i < 22; i++) om[i] = pw(3, (mod-1)>>i);
	int N, M;
	cin >> N >> M;
	cat fac[500010], inv[500010];
	fac[0] = inv[0] = 1;
	for(int i = 1; i <= 500000; i++) fac[i] = fac[i-1] * i % mod;
	for(int i = 1; i <= 500000; i++) inv[i] = (i%2 == 0 && i > 2) ? inv[2] * inv[i/2] % mod : pw(i, mod-2);
	for(int i = 1; i <= 500000; i++) inv[i] = inv[i-1] * inv[i] % mod;
	cat A[1<<20];
	memset(A, 0, sizeof(A));
	cat N_pw = 1;
	for(int i = 0; i <= M; i++) {
		A[i] = inv[i] * N_pw % mod;
		N_pw = N_pw * N % mod;
	}
	ntt(A, 1<<20);
	cat B[1<<20];
	memset(B, 0, sizeof(B));
	cat M_pw = 1;
	for(int i = N; i >= 0; i--) {
		B[i] = inv[i] * inv[N-i] % mod * M_pw % mod;
		M_pw = M_pw * (mod-1-M) % mod;
	}
	ntt(B, 1<<20);
	cat C[1<<20];
	for(int i = 0; i < (1<<20); i++) C[i] = A[i] * B[i] % mod;
	ntt(C, 1<<20, 1);
	cat ans = 0;
	for(int i = 0; i <= M; i++) ans = (ans + C[i] * inv[M-i]) % mod;
	ans = ans * fac[N] % mod * fac[M] % mod * (N%2 ? mod-1 : 1) % mod;
	cout << ans << "\n";
}


Measured memory_bytes: 36736
#include<stdio.h>

int main() {
    int x, y, z, res;
    scanf("%d%d%d", &x, &y, &z);
    if(x>=y) {
        if(z%x == 0) {
            res = z/x;
        } else {
            res = z/x+1;
        }
    } else {
        if(z%y == 0) {
            res = z/y;
        } else {
            res = z/y+1;
        }
    }

    printf("%d", res);
    return 0;
}

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

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

int N, Q, S, T, X, D;
set<pair<int, pair<int, int>>> events; // Ordena los eventos del sweep line
multiset<int> active; // Guarda alturas ordenadas de segmentos activos
vector<int> ans;

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

    cin >> N >> Q;

    rep(i, N)
    {
        cin >> S >> T >> X;
        events.insert({T - X, {0, X}});
        events.insert({S - X, {1, X}});

        if (S - X < 0 && T - X >= 0) active.insert(X);
    }

    rep(i, Q) { cin >> D; events.insert({D, {2, i}}); }

    ans.assign(Q, -1);

    for (auto e : events)
    {
        T = e.second.first;
        X = e.second.second;

        if (T == 0) active.erase(X);
        if (T == 1) active.insert(X);
        if (T == 2 && !active.empty()) ans[X] = *active.begin();
    }

    rep(i, Q) cout << ans[i] << '\n';
}

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

int main() {
  long long N, M;cin >> N >> M;
  vector<long long> L(M);
  vector<long long> R(M);
  for (int i = 0; i < M; i++)
  {
    cin >> L.at(i) >> R.at(i);
  }
  
  int ans = 0;
  int start = *max_element(L.begin(), L.end());
  int end = *min_element(R.begin(), R.end());
  for (int i = 1; i <= N; i++)
  {
    if(start <= i && i <= end) {
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main(){ 
  Int N;
  cin >> N;
  
  vector<Int> tak(N, 1), aok(N, 1);
  
  
  rep(i,N) {
    Int T, A, gcd;
    cin >> T >> A;
    gcd = __gcd(T,A);
    T /= gcd;
    A /= gcd;
    if (i == 0) {
      tak[i] = T;
      aok[i] = A;
    }
    else {
      if (T >= tak[i-1] && A >= aok[i-1]) {
        tak[i] = T;
        aok[i] = A;
      }
      else {
        Int tq, aq, q;
        tq = (tak[i-1] + T - 1) / T;
        aq = (aok[i-1] + A - 1) / A;
        q = max(tq,aq);
        tak[i] = T * q;
        aok[i] = A * q;
      }
    }
  }
  
  cout << tak[N-1] + aok[N-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <cmath>
#include <iomanip>

using namespace std;

int dp[100010];

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

    dp[0]=0;
    for(int n=1; n<=100000; n++){
        dp[n]=std::numeric_limits<int>::max()-1;
    }
    for(int n=1; n<=100000; n++){
        int power=6;
        while(power<=n){
            dp[n]=min(dp[n], dp[n-power]+1);
            power*=6;
        }

        power=9;
        while(power<=n){
            dp[n]=min(dp[n], dp[n-power]+1);
            power*=9;
        }

        dp[n]=min(dp[n], dp[n-1]+1);
    }

    cout<<dp[N]<<endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ps push_back
#define LL long long
using namespace std;
const int maxn=4e5+5;
int a[maxn];
int b[maxn];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, j, i;
    LL ans=0;
    cin>>i;
//    for(LL i=1; i<=n; i++)
//    {
//        int sum=0;
//        for(LL j=1; j<=sqrt(i); j++)
//        {
//            if(i%j==0)
//            {
//                if(j*j!=i)sum+=2;
//                else sum++;
//            }
//        }
//        ans+=sum*i;
////        cout<<ans<<endl;
        LL s2=0;
        for(LL k=1; k<=i; k++)
        {
            s2+=k*0.5*(i/k)*floor(1+i*1.0/k);
        }
        cout<<s2<<endl;
//    }
    return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

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

    ll a, b;
    cin >> a >> b;
    REP(i, b) {
        if(a * (i + 1) % b  == 0) {
            cout << a * (i + 1) << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
using System;

namespace AOJ.Volume2
{
    public class Aka_bekoAnd40Thieves
    {
        public static int Main()
        {
            // ???????????????????????????
            // A???0
            // B???1
            // W???2
            // X???3
            // Y???4
            // Z???5
            var map = new int[6, 2];
            // -1???????????????
            map[0, 0] = 3;
            map[0, 1] = 4;
            map[1, 0] = 4;
            map[1, 1] = 3;
            map[2, 0] = 1;
            map[2, 1] = 4;
            map[3, 0] = -1;
            map[3, 1] = 5;
            map[4, 0] = 3;
            map[4, 1] = -1;
            map[5, 0] = 2;
            map[5, 1] = 1;

            while (true)
            {
                var input = Console.ReadLine();
                if(input == "#") { break; }
                int current = 0;
                foreach(var c in input)
                {
                    int i = int.Parse(c.ToString());
                    current = map[current, i];
                    if(current < 0) { break; }
                }
                if(current == 1) { Console.WriteLine("Yes"); }
                else { Console.WriteLine("No"); }
            }

            return 0;
        }
    }
}

Measured memory_bytes: 8836
Q, H, S, D = map(int,input().split())
N = int(input())
W = min(2*Q, H)
T = min(2*W, S)
E = min(2*T, D)
if N%2 == 0:
    ans = E * (N//2)
else:
    ans = E * (N//2) + T
print(ans)

Measured memory_bytes: 3064
n=int(input())
h=list(map(int,input().split()))
dp=[0]*(len(h))
dp[1]+=abs(h[1]-h[0])
for i in range(2,len(h)):
    dp[i] = min( 
            abs(h[i]-h[i-1])+dp[i-1],
            abs(h[i]-h[i-2])+dp[i-2]
            )
print(dp[-1])


Measured memory_bytes: 20460
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int main(){
	int n;
	ll a,b;
	cin>>n>>a>>b;
  ll h[n];
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	long long int sa=a-b;
	long long int mi=0,ma=1000000000,mid;
	while(ma-mi>1){
		mid=(mi+ma)/2;
		long long int cnt=0;
		for(int i=0;i<n;i++){
			if(h[i]>b*mid){
				cnt+=(h[i] - b * mid + a - b - 1) / (a-b);
			}
		}
		if(cnt>mid){
			mi=mid;
		}
		else{
			ma=mid;
		}
	}
	cout<<ma<<endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int l = scan.nextInt();
        long [] [] a = new long[n][m];
        long [] [] b = new long[m][l];
        long [] [] c = new long[n][l];
        for(int x = 0; x < n; x++){
            for(int y = 0; y < m; y++){
                a[x] [y] = scan.nextInt();
            }
        }
        for(int x = 0; x < m; x++){
            for(int y = 0; y < l; y++){
                b[x] [y] = scan.nextInt();
            }
        }
        for(int x =0; x < n; x++){
            for(int y = 0; y < l; y++){
                for(int r = 0; r < m; r++){
                    c[x][y] = c[x][y] + (a[x][r] * b[r][y]);
                }
            }
        }
        for(int x = 0; x < n; x++){
            for(int y = 0; y < l; y++){
                if(y != l-1) {
                    System.out.print(c[x][y] + " ");
                }
                else{
                    System.out.print(c[x][y]);
                }
            }
            System.out.println();
        }
    }
}


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

char s[525252], t[1525830];

int nxt[525252];

int A[525252];

int memo[525252];
const int INF = 830252521;
int dfs(int p){
    if(memo[p]!=-1){
        return memo[p];
    }
    if(nxt[p]==-1){
        return memo[p] = 0;
    }else{
        memo[p] = INF;
        return memo[p] = dfs(nxt[p]) + 1;
    }
}

int main(){
    scanf("%s%s",t,s);
    int n = strlen(s);
    int m = strlen(t);
    s[n] = '$';
    int k = 1;
    while(k==1 || k*m < 2*n){
        REP(i,m)t[i+k*m] = t[i];
        k++;
    }
    fill(nxt,nxt+m,-1);

    // KMP
    {
        A[0] = -1;
        int j = -1;
        REP(i,n+1){
            while(j>=0 && s[i]!=s[j])j = A[j];
            j++;
            A[i+1] = j;
        }
    }
    // search
    int head = 0;
    int i = 0;
    while(head+i < k*m){
        // DEBUG(head); DEBUG(i);
        if(s[i]==t[head+i]){
            i++;
            if(i==n){
                nxt[head%m] = (head+i)%m;
                // DEBUG(head%m);
            }
        }else{
            head = head+i-A[i];
            if(i>0)i = A[i];
        }
    }

    // DEBUG(n); DEBUG(m);

    fill(memo,memo+m,-1);
    int ans = 0;
    REP(i,m){
        if(nxt[i]==-1)continue;
        int x = dfs(i);
        CHMAX(ans, x);
    }
    if(ans >= INF){
        puts("-1");
    }else{
        printf("%d\n",ans);
    }
    return 0;
}


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

#define ll long long

using namespace std;

int main(){
	ll i,j,r,c,l,n,x,z,s=0;
	
	cin>>r>>c;
	
	long long a[r+2][c+1];

	for(i=1;i<=r;i++){
		for(j=1;j<=c;j++){
			cin>>a[i][j];
			a[r+1][j]=0;
		}
	}
	
	for(i=1;i<=r+1;i++){
		s=0;
		for(j=1;j<=c;j++){
			cout<<a[i][j]<<" ";
			s+=a[i][j];
			a[r+1][j]+=a[i][j];
		}
		cout<<s<<endl;
	}
	
}


Measured memory_bytes: 3168
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int K,ans = 0;
    cin >> K;

    repc(a, 1, K + 1){
        repc(b, 1, K + 1){
            repc(c, 1, K + 1){
                ans += __gcd(__gcd(a,b), c);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3588
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	k := scanInt()
	a := scanInts(n)

	ans := 1 << 60
	bitExhaustiveSearch(n, func(f []bool) {
		pre := 0
		cnt := 0
		co := 0
		for i := 0; i < n; i++ {
			if !f[i] {
				pre = max(pre,a[i])
				continue
			}

			cnt++
			co += max(0, pre+1-a[i])
			pre = max(pre+1, a[i])
		}

		if cnt >= k {
			// fmt.Fprintln(wr, f, co)
			ans = min(ans, co)
		}
	})

	fmt.Fprintln(wr, ans)
}

func bitExhaustiveSearch(n int, fn func(a []bool)) {
	all := 1 << uint(n)
	a := make([]bool, n)
	for i := 0; i < all; i++ {
		for j := 0; j < n; j++ {
			if i >> uint(j) & 1 == 1 { a[j] = true } else { a[j] = false }
		}
		fn(a)
	}
}


Measured memory_bytes: 640
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while(a > 0 && c > 0) {
    c -= b;
    if(c <= 0) {cout << "Yes" << endl; return 0;}
    a -= d;
    if(a <= 0) {cout << "No" << endl; return 0;}
  }
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 3136
from scipy.misc import comb #<-Atcoderではこちらを使うべし


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr


ans = 1
n, m = map(int, input().split())
lst = factorization(m)
if lst[0][0] == 1:
    print(1)
    exit()
for e in lst:
    ans *= comb((n + e[1] - 1), n - 1, exact=True)
print(ans % 1000000007)


Measured memory_bytes: 23932
#include<bits/stdc++.h>
#define endl "\n"
#define int long  long 

using namespace std ; 
	 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ;

	int n ; 
	cin >> n ; 
	cout << (n+1 )/2 ; 


}       





Measured memory_bytes: 3624
#include<stdio.h>

#define MAX 1000000
int h,array[MAX+1];


int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i + 1;
}

void maxHeap(int A[],int i){
  int l,r,largest;
  int temp;
  l = left(i);
  r = right(i);

  if(l <= h && A[l] > A[i]){
    largest = l;
  }else{
    largest = i;
  }
  if(r <= h && A[r] > A[largest]){
    largest = r;
  }
  if(largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeap(A,largest);
  }
    
}

void buildMaxHeap(int A[]){
  int i;
  for(i = h/2;i >= 1;i--){
    maxHeap(A,i);
  } 
}


int main(){
  int i;

  scanf("%d",&h);
  for(i = 1;i<=h;i++){
    scanf("%d",&array[i]);

  }
  buildMaxHeap(array);
    for(i = 1;i<=h;i++){
      printf(" %d",array[i]);
    }
    printf("\n");
    return 0;
  }



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

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  bool comf = true;
  for (int i = 0; i < (int)S.length(); i++)
    comf &= S[i] == 'U' || S[i] == 'D' || (S[i] == (i & 1 ? 'L' : 'R'));
  cout << (comf ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 3640
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"sort"
	"strconv"
)

func main() {
	x, y := readInt(), readInt()
	a, b, c := readInt(), readInt(), readInt()
	p, q, r := make([]int, a), make([]int, b), make([]int, c)
	for i := range p {
		p[i] = readInt()
	}
	for i := range q {
		q[i] = readInt()
	}
	for i := range r {
		r[i] = readInt()
	}
	sort.Sort(sort.Reverse(sort.IntSlice(p)))
	sort.Sort(sort.Reverse(sort.IntSlice(q)))
	sort.Sort(sort.Reverse(sort.IntSlice(r)))

	arr := make([]int, 0, x+y)
	for i := 0; i < x; i++ {
		arr = append(arr, p[i])
	}
	for i := 0; i < y; i++ {
		arr = append(arr, q[i])
	}

	sort.Ints(arr)
	for i := 0; i < min(len(arr)-1, c); i++ {
		if r[i] < arr[i] {
			break
		}
		arr[i] = r[i]
	}

	// fmt.Println(p)
	// fmt.Println(q)
	// fmt.Println(r)

	ans := 0
	for i := range arr {
		ans += arr[i]
	}
	fmt.Println(ans)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    vvi data(n, vi(n));
    rep(i, n) rep(j, n) cin >> data[i][j];

    vi dp(1 << n, 0);
    dp[0] = 1;

    rep(i, n) {
        rep(j, dp.size()) {
            if (__builtin_popcount(j) == i) {
                rep(k, n) {
                    if (data[i][k] && (j & (1 << k)) == 0) {
                        dp[j | (1 << k)] = (dp[j | (1 << k)] + dp[j]) % MOD;
                    }
                }
            }
        }
        /*
        rep(j, dp.size()) {
            cout << dp[j] << " ";
        }
        cout << endl;
        */
    }

    std::cout << dp.back() << std::endl;

    return 0;
}


Measured memory_bytes: 16640
/*
Contest: -
Problem: Atcoder Grand Contest 044 C
Author: tzc_wk
Time: 2020.5.25
*/
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y1010101010101
#define y0			y0101010101010
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
int n=read(),m;
char s[1000005];
int tot=1,a[1000005<<2],ans[1000005];
int ch[1000005<<2][4],lz[1000005<<2];
inline void build(int k,int val,int dep){
	if(dep==n){
		a[k]=val;
//		cout<<k<<" "<<val<<endl;
		return;
	}
	for(int i=0;i<3;i++){
		build(ch[k][i]=++tot,val+i*pow(3,dep),dep+1);
	}
}
inline void pushdown(int k){
	if(lz[k]){
		swap(ch[k][1],ch[k][2]);
		for(int i=0;i<3;i++)	lz[ch[k][i]]^=1;
		lz[k]=0;
	}
}
inline void add(){
	int cur=1;
	for(int i=1;i<=n;i++){
		pushdown(cur);
		swap(ch[cur][0],ch[cur][2]);
		swap(ch[cur][1],ch[cur][2]);
		cur=ch[cur][0];
	}
}
inline void dfs(int k,int val,int dep){
	if(dep==n){
		ans[a[k]]=val;
		return;
	}
	pushdown(k);
	for(int i=0;i<3;i++){
		dfs(ch[k][i],val+i*pow(3,dep),dep+1);
	}
}
signed main(){
	build(1,0,0);
	cin>>s+1;
	m=strlen(s+1);
	fz(i,1,m){
		if(s[i]=='S')	lz[1]^=1;
		else			add();
	}
	dfs(1,0,0);
	fz(i,0,pow(3,n)-1)	cout<<ans[i]<<" ";
	return 0;
}
/*
		0
  0     1     2
0 3 6 1 4 7 2 5 8
*/

Measured memory_bytes: 25016
#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define lli long long int
using namespace std;
#define S second
#define F first
#define pb push_back 
#define M1 1000000007
#define M2 998244353
#define plli pair<lli,lli>
#define setit set<lli>::iterator seti
#define mapit map<lli,lli> ::iterator mapi
#define MP make_pair
#define MT make_tuple
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define fr(j,a,b) for(j=a;j<b;j++)


int power(int x, unsigned int y, int p)  
{    int res = 1;    
     x = x % p;
     if (x == 0) return 0;
     while (y > 0)  
     {  if (y & 1)  
        res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
     }  
    return res;  
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lli t,i,m,j,n,x,k,f,g,q,r,w,l,b,c;
    cin>>n>>m;
    lli a[n];
    x=0;
    for(i=0;i<n;i++){
        cin>>a[i];
        x=x+a[i];
    }
    l=0;
    sort(a,a+n);
    for(i=n-1;i>=0;i--){
        if(4*m*a[i]>=x){
            l++;
        }
        else{
            break;
        }
    }
    if(l>=m){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}

Measured memory_bytes: 256
count = 0
N = int(input())
L = list(map(int, input().split())) #1行にN個の整数を入力したい.
L.sort(reverse=True) #リストLを降順に並び替えたい(昇順の時は"()"の中身は何も書かない)
for i in range(0, N-2): #全探索
    for j in range(i, N-1):
        for k in range(j, N):
            if L[i] == L[j] or L[j] == L[k] or L[i] == L[k]:
                count += 0
            elif L[i] < L[j] + L[k]:
                #print(L[i])
                count += 1
print(count)

Measured memory_bytes: 9188
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

N, L = map(int, input().split())
S = []
for i in range(N):
    S.append(input().rstrip('\n'))
S.sort()
print(''.join(S))


Measured memory_bytes: 9100
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
  if(K%2==0){
    System.out.println(K*K/4);
  }else{
    System.out.println((K+1)*(K-1)/4);
  }
  }
}


Measured memory_bytes: 23252
#include <iostream>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;

    int ok = 0;
    for (int i = 0; i < n; ++i) {
        int h;
        cin >> h;

        if (h >= k)
            ++ok;
    }

    cout << ok << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
        int n[1000][2]={0},i,num,diff[1000]={0},sum=0;

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

        for(i=0;i<num;i++){
                diff[i] = (n[i][1]-n[i][0])+1;
        }

        for(i=0;i<num;i++){
                sum += diff[i];
        }

        printf("%d",sum);
        return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define LL long long
#define MAXN 200005
using namespace std;

int n, ans, l1=1, l2=1, t1, t2, a[MAXN], b[MAXN];

int main()
{
	scanf("%d", &n);
	for(int i=1; i<=n; i++) scanf("%d", &a[i]), b[a[i]]=i;
	for(int i=2; i<=n; i++)
	{
		if(b[i]>b[i-1]) l1++;
		else t1=max(l1, t1), l1=1;
	}
	t1=max(l1, t1);
	printf("%d\n", n-t1);
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);



int main()
{
    fastInp;
    
    ll n;
    cin >> n;

    vector<ll> vec(n);
    for (int i = 0; i < vec.size(); i++) cin >> vec[i];

    vector<ll> ans;
    ans.push_back(0);
    for (int i = 1; i < n; i++) {
        ll cur = vec[i - 1] ^ vec[i];
        ans.push_back(ans.back() ^ cur);
    }

    bool flag = false;
    ll c2 = 0;
    for (int i = 0; i < 1; i++) {
        ll x = 0;
        for (int j = 0; j < n; j++) {
            if (i != j) x ^= ans[j];
        }
        c2 = x ^ vec[i];
        if (x != vec[i]) flag = true;
    }

    for (int i = 0; i < n; i++) ans[i] ^= c2; 
    flag = false;

    for (int i = 0; i < n; i++) cout << ans[i] << " ";
    return 0;
}

Measured memory_bytes: 6868
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 +10 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase

#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
show_flg=True

ans='Possible'
n=I()
p=LI_()
b=[30000*(n-i) for i in range(n)]
a=[30000*(i+1) for i in range(n)]
prev=b[p[0]]
l=[]
for i in range(n):
    b[p[i]]+=i
    l.append(a[p[i]]+b[p[i]])
    





show(*a)
show(*b)


Measured memory_bytes: 46736