akhauriyash/Code-Regression huggingface dataset:
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    string S;
    cin >> S;
    ll ans = 0;
    ll cnt = 0;
    for (char c : S) {
        if (!(c == 'A' || c == 'C' || c == 'G' || c == 'T')) {
            ans = max(ans, cnt);
            cnt = 0;
        } else {
            ++cnt;
        }
    }
    ans = max(ans, cnt);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << #x " = " << (x) << '\n';
#define P(x) cout << #x << '\n';    
#define int long long
typedef pair<int, int> pii;
const int mod = 1000000007;

int modpow(int x, int y, int p = mod) 
{ 
	int res = 1;       
	x %= p;   
	while (y > 0) 
	{ 
		if (y & 1) 
			res = (res * x) % p; 
		y >>= 1;
		x = (x * x) % p;   
	} 
	return res; 
} 
int add(int x, int y) 
{
	x %= mod;
	y %= mod;
	x += y;
	if (x >= mod) return x - mod;
	return x;
}
int sub(int x, int y) 
{
	x %= mod;
	y %= mod;
	x -= y;
	if (x < 0) return x + mod;
	return x;
}
int inv(int a, int m = mod)
{
	// a %= mod;
	return modpow(a, m - 2, m);
}
int mul(int a, int b) 
{
	// a %= mod;
	// b %= mod;
	return (long long) a * b % mod;
}

const int maxn = 1e5 + 10;
int fac[maxn], invfac[maxn];
int ncr(int n, int r)
{
	int ans = mul(fac[n], mul(invfac[r], invfac[n - r]));
	return ans;
}
int a[maxn];

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
	
	fac[0] = invfac[0] = 1;
	for(int i = 1; i < maxn; ++ i)
	{
		fac[i] = mul(i, fac[i - 1]);
		invfac[i] = inv(fac[i]);
	}
	
	int n, k;
	cin >> n >> k;
	for(int i = 1; i <= n; ++ i)
	{
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	int ans = 0;
	
	for(int i = 1; i <= n; ++ i)
	{
		int bef = i - 1;
		int aft = n - i;
		int to = k - 1;
		if(aft >= to)
		{
			int mini = mul(ncr(aft, to), a[i]);
			
			ans = sub(ans, mini);
		}
		if(bef >= to)
		{
			int maxi = mul(ncr(bef, to), a[i]);
			ans = add(ans, maxi);
		}
	}
	cout << ans << '\n';
	
	return 0;
}






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


// ローリングハッシュ
// 二分探索で LCP を求める機能つき
struct RollingHash {
    static const int base1 = 1007, base2 = 2009;
    static const int mod1 = 1000000007, mod2 = 1000000009;
    vector<long long> hash1, hash2, power1, power2;

    // construct
    RollingHash(const string &S) {
        int n = (int)S.size();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        power1.assign(n+1, 1);
        power2.assign(n+1, 1);
        for (int i = 0; i < n; ++i) {
            hash1[i+1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i+1] = (hash2[i] * base2 + S[i]) % mod2;
            power1[i+1] = (power1[i] * base1) % mod1;
            power2[i+1] = (power2[i] * base2) % mod2;
        }
    }
    
    // get hash of S[left:right]
    inline pair<long long, long long> get(int l, int r) const {
        long long res1 = hash1[r] - hash1[l] * power1[r-l] % mod1;
        if (res1 < 0) res1 += mod1;
        long long res2 = hash2[r] - hash2[l] * power2[r-l] % mod2;
        if (res2 < 0) res2 += mod2;
        return {res1, res2};
    }

    // get lcp of S[a:] and T[b:]
    inline int getLCP(int a, int b) const {
        int len = min((int)hash1.size()-a, (int)hash1.size()-b);
        int low = 0, high = len;
        while (high - low > 1) {
            int mid = (low + high) >> 1;
            if (get(a, a+mid) != get(b, b+mid)) high = mid;
            else low = mid;
        }
        return low;
    }
};

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

    // ロリハ
    RollingHash rh(S);

    // 求める
    int res = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            int lcp = rh.getLCP(i, j);
            lcp = min(lcp, j-i);
            res = max(res, lcp);
        }
    }   
        
    cout << res << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  #define int long long
  int answer=0;
  int N,K;
  cin>>N>>K;
  unordered_map<int,int> mp;
  for(int i=1;i<=N;i++){
    mp[i%K]++; 
  }
  for(int i=1;i<=N;i++){
    if((2*i)%K==0){
      answer+=mp[(K-i%K)%K]*mp[(K-i%K)%K];
    }
  }
  cout<<answer<<endl;
}

Measured memory_bytes: 7220
from heapq import heappop, heappush
H, W = map(int,input().split())
dire = [(1, 0), (0, 1), (-1, 0), (0, -1)]
mp = [[0] * (W + 2)]
cnt = 0
for i in range(H):
    S = [0]
    for ch in input():
        S.append(ch)
        if ch == ".":
            cnt += 1
    S.append(0)
    mp.append(S)
mp.append([0] * (W + 2))
leng = [[float("inf")] * (W + 2) for _ in range(H + 2)]
leng[1][1] = 1
que = [(1, 1, 1)]
while que:
    cost, i, j = heappop(que)
    if cost != leng[i][j]:
        continue
    for di, dj in dire:
        if mp[i + di][j + dj] == ".":
            if leng[i + di][j + dj] > cost + 1:
                leng[i + di][j + dj] = cost + 1
                heappush(que, (leng[i + di][j + dj], i + di, j + dj))
if leng[H][W] == float("inf"):
    print(-1)
else:
    print(cnt - leng[H][W])

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int i,k;
	cin >> k;
	long long a[100010],mn=2,mx=2;
	for(i=0;i<k;i++){
		cin >> a[k-1-i];
	}
	if(a[0]!=2){
		cout << -1 << endl;
		return 0;
	}
	
	for(i=1;i<k;i++){
		mn = ((mn-1)/a[i]+1)*a[i];
		mx = (mx+a[i-1]-1)/a[i]*a[i];
		if(mn>mx){
			cout << -1 << endl;
			return 0;
		}
	}
	mx = mx+a[k-1]-1;
	cout << mn <<" " <<  mx << endl;
}

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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    vector<ll> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    sort(v.rbegin(),v.rend());
    ll ans=0;
    ll count=1;
    if(n>1){
        ans+=v[0];
        count+=1;

    }
    if(n>2){
        ans+=v[1];
        count+=1;

    }
    if(n>3){
        ans+=v[1];
        count+=1;

    }
    for(int i=2;;i++){
        if(count>=n){
            break;
        }
        ans+=v[i];
        count+=1;

        if(count>=n){
            break;
        }
        ans+=v[i];
        count+=1;

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


Measured memory_bytes: 4764
import sys

N = int(input())
nsum = N * (N + 1) // 2

for S in range(N*(N-1)//2, N-1, -1):
    s = [nsum - n for n in range(0, N+1)]
    cutv = []
    for n in range(N, 0, -1):
        rem = s[n] - S
        for i in range(rem, 0, -1):
            if s[n] == S:
                break
            if s[n] - i < S:
                continue
            if s[i] - n < S:
                continue
            s[i] -= n
            s[n] -= i
            if i <= n:
                cutv.append((i, n))
            else:
                cutv.append((n, i))
        if s[n] != S:
            break
    else:
        print(N * (N - 1) // 2 - len(cutv))
        for i in range(1, N + 1):
            for j in range(i + 1, N + 1):
                if (i, j) not in cutv:
                    print(i, j)
        sys.exit()

raise


Measured memory_bytes: 43248
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<sys/time.h>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int ri()
{
	register int x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();};
	return f?-x:x;
}
void wi(int x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}
const int N=105;
int e[N][N],mth[N],vis[N],a[N],b[N],c[N],d[N],n;
int dfs(int x)
{
	for(int i=1;i<=n;i++)
	{
		if(!e[x][i]||vis[i])	continue;
		vis[i]=1;
		if(!mth[i]||dfs(mth[i]))
		{
			mth[i]=x;
			return 1;
		}
	}
	return 0;
}
int main()
{
	n=ri();
	int i,j,cnt=0;
	for(i=1;i<=n;i++)	a[i]=ri(),b[i]=ri();
	for(i=1;i<=n;i++)	c[i]=ri(),d[i]=ri();
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			if(a[i]<c[j]&&b[i]<d[j])	e[i][j]=1;
	for(i=1;i<=n;i++)
	{
		memset(vis,0,sizeof(vis));
		if(dfs(i))	cnt++;
	}
	wi(cnt);putchar('\n');
	return 0;
}


Measured memory_bytes: 256
/*
ID: amagica1
TASK: ariprog
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define NINF -INF
#define mp make_pair
#define boost() cin.tie(0); cin.sync_with_stdio(0)
#define For(i, a, b) for(int i=a; i<b; i++)
#define FOR(i, a, b) for(int i=a; i<=b; i++)
#define Rev(i, a, b) for(int i=a; i>b; i--)
#define REV(i, a, b) for(int i=a; i>=b; i--)
typedef long long ll;
typedef long double ld;
typedef int64_t l;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int MAXN = 1000005;
ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
bool a[3];
int main() {
    //-----------FILE------------//
    // freopen("ariprog.in", "r", stdin);
    // freopen("ariprog.out", "w", stdout);
    //----------------------------//
    int n; string s, t;
    cin >> n;
    cin >> s >> t;
    for(int i=0; i<n; i++) {
        cout<<s[i]<<t[i];
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define pb push_back
#define ob pop_back
#define xx first
#define yy second
#define dob double
#define rin(i,n,k) for(int i=0;i<n;i+=k)
#define int long long int
#define ss size()
using namespace std;
const int M=1e9+7,maxn=100010;
std::vector<int> adj[maxn];
std::vector<int> v1;
int ans,n,k,m,x,y,q,par[maxn],h[maxn],mach[maxn],sk[maxn],dp[maxn];
bool mark[maxn],bpart[maxn];
string s,s1,s2;
map <string ,int> mp;
bool markchaild[maxn];
bool dfsmach(int v){
    if(v==-1) return true;
    if(mark[v]==1) return false;
    mark[v]=1;
    for(int i=0;i<adj[v].ss;i++){
        int u=adj[v][i];
        if(dfsmach(mach[u])){
            bpart[u]=((bpart[v]+1)%2);
            mach[u]=v;
            mach[v]=u;
            return true;
        }
    }
    return false;
}


int32_t main() {
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>x>>y;
        h[x]++;
        h[y]++;
    }
    for(int i=1;i<=n;i++)
        cout<<h[i]<<endl;
    return 0;
}


Measured memory_bytes: 4736
#include <cstdio>


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

    int taaTurns=0,aoTurn=0;
    while (taaTurns*B<C) taaTurns++;
    while (aoTurn*D<A) aoTurn++;

    if (taaTurns<=aoTurn) puts("Yes");
    else puts("No");


    return 0;
}

Measured memory_bytes: 1620
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL n,m;
    cin >> n >> m;
    LL ans = 1;
    for(LL x = 1; x*x <= m; x++){
        if(m%x == 0){
            if(x*n <= m){
                ans = max(ans,x);
            }
            if((m/x)*n <= m){
                ans = max(ans,m/x);
            }
        }
    }

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int P[200010];
int _P[200010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    rep(i, N) {
        cin >> P[i];
        _P[P[i]] = i;
    }
    int ans = 1;
    int tmp = 1;
    REP(i, 1, N - 1) {
        if (_P[i] <= _P[i + 1]) tmp++;
        else {
            tmp = 1;
        }
        ans = max(tmp, ans);
    }
    cout << N - ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define  FIO        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  all(v)     v.begin(),v.end()
#define  rall(v)    v.rbegin(),v.rend()
#define  MEM(a,x)   memset(a,x,sizeof(a))
#define  pi         acos(-1.0)
#define  ll     long long
#define  pb     push_back
#define  mp     make_pair
#define  pii    pair< int,int >
#define  pll    pair< ll,ll >
#define  vii    vector< int >
#define  vll    vector< ll >
#define  vpi    vector< pii >
#define  vpl    vector<pll>
#define  MX     100005
#define  EPS    1e-12
#define  ss     second
#define  ff     first
int cases=1;
#ifdef ppqq
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " is " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cerr.write(names, comma - names) << " is " << arg1 <<"  ";
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
///******************************************START******************************************
int main()
{
   //freopen ("output.txt","w",stdout);
   //freopen ("input.txt","r",stdin);
    FIO;
    double r;
    cin>>r;
    cout<<(2.0*pi*r);
}


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

int main() {
long q,h,s,d;
long n;
cin>>q>>h>>s>>d>>n;
double a[4];
a[0]=q*4;
a[1]=h*2;
a[2]=s;
a[3]=double(d)/2;
int mi=0;
long m=1234567890;
for(int i=0;i<4;i++){
  if(a[i]<m) m=a[i],mi=i;
}
//cout<<mi<<endl;
long ans=0;
if(n%2!=0&&mi==3){
  ans += d*(n/2);
  //cout<<ans<<endl;
  n=1;
  int mi=0;
  long m=1234567890;
  for(int i=0;i<3;i++){
    if(a[i]<m) m=a[i],mi=i;
  }
  if(mi==0)ans+= q*4;
  else if(mi==1) ans+=h*2;
  else ans+=s;
}

else{
  if(mi==0) ans+= q*4*n;
  else if(mi==1) ans+=h*2*n;
  else if(mi==2)ans+=s*n;
  else ans+=d*(n/2);
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())
divisitor = []
for i in range(a, b+1):
    if a < 0 or b < 0 or c < 0:
        break
    elif a > 10001 or b > 10001 or c > 10001:
        break
    elif a > b:
        break
    elif c % i == 0:
        divisitor.append(int(c/i))

print((len(divisitor)))

Measured memory_bytes: 7672
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];

  map<ll,int> m;
  ll ans = 0;
  REP(i,n) {
    ans+=m[i-a[i]];
    m[i+a[i]]++;
  }

  COUT(ans);
  return 0;
}

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

int main(){
	int n,m,i,card[200],k,fc[200],bc[200],j,a;
	while(cin >> n && n){
		for(i = 0;i < 200;i++){
			card[i] = i + 1;
		}
		cin >> m;
		for(i = 0;i < m;i++){
			a = 0;
			cin >> k;
			if(k == 0){
				for(j = 0;j < n;j++){
					fc[a] = card[j];
					a++;
				}
				a = 0;
				for(j = n;j < 2*n;j++){
					bc[a] = card[j];
					a++;
				}
				a = 0;
				for(j = 0;j < n;j++){
					card[a] = fc[j];
					a++;
					card[a] = bc[j];
					a++;
				}
			}
			else {
				for(j = 0;j < k;j++){
					fc[a] = card[j];
					a++;
				}
				a = 0;
				for(j = k;j < 2*n;j++){
					bc[a] = card[j];
					a++;
				}
				a = 0;
				for(j = 0;j < (2*n-k);j++){
					card[a] = bc[j];
					a++;
				}
				for(j = 0;j < k;j++){
					card[a] = fc[j];
					a++;
				}
			}
		}
		for(i = 0;i < 2*n;i++){
			cout << card[i] << endl;
		}

	}
	return  0;
}

Measured memory_bytes: 0
// D - Coloring Edges on Tree
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

int main(){
	int N; cin>>N;
	int G[N], C[N-1];
	rp(i, 0, N-1){
		int p; scanf("%d%d", &p, C+i);
		G[--C[i]] = p-1;
	}

	int K = 1;
	int pre_colors[N]; rp(i, 0, N) pre_colors[i] = 0;

	rp(c, 1, N){
		int p = G[c];
		int color = pre_colors[p] + 1;
		pre_colors[p] = G[c] = color==G[p]? ++color: color;
		K = max(K, color);
	}

	putint(K);
	for(int c:C) putint(G[c]);
	fwrite(dn, 1, di - dn, stdout);
}

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

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define nfor(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef long double ld;
typedef pair<int, int> pti;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

template<typename A, typename B> inline ostream& operator<< (ostream& out, const pair<A, B>& p) { return out << "(" << p.x << ", " << p.y << ")"; }
template<typename T> inline ostream& operator<< (ostream& out, const vector<T>& a) { out << "["; forn(i, sz(a)) { if (i) out << ','; out << ' ' << a[i]; } return out << " ]"; }
template<typename T> inline ostream& operator<< (ostream& out, const set<T>& a) { return out << vector<T>(all(a)); }
template<typename X, typename Y> inline ostream& operator<< (ostream& out, const map<X, Y>& a) { return out << vector<pair<X, Y>>(all(a)); }
template<typename T> inline ostream& operator<< (ostream& out, const pair<T*, int>& a) { return out << vector<T>(a.x, a.x + a.y); }

inline ld gett() { return ld(clock()) / CLOCKS_PER_SEC; }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

#ifdef SU1
//#define GEN
#ifndef GEN
#define LOG
#endif
#endif

string s;

bool read() {
  return !!(cin >> s);
}

const int mod = 1000 * 1000 * 1000 + 7;

inline int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
inline int mul(int a, int b) { return int(a * 1ll * b % mod); }
inline void inc(int& a, int b) { a = add(a, b); }

const int N = 100100;
int z[N][4];

void solve() {
  memset(z, 0, sizeof(z));

  z[0][0] = 1;
  forn(i, sz(s))
    forn(j, 4) {
      inc(z[i + 1][j], mul(z[i][j], s[i] == '?' ? 3 : 1));
      if (j == 0 && (s[i] == 'A' || s[i] == '?')) inc(z[i + 1][j + 1], z[i][j]);
      if (j == 1 && (s[i] == 'B' || s[i] == '?')) inc(z[i + 1][j + 1], z[i][j]);
      if (j == 2 && (s[i] == 'C' || s[i] == '?')) inc(z[i + 1][j + 1], z[i][j]);
    }
  cout << z[sz(s)][3] << endl;
}

int main() {
#ifdef SU1
  assert(freopen("input.txt", "rt", stdin));
  //assert(freopen("output.txt", "wt", stdout));
#endif

  cout << setprecision(10) << fixed;
  cerr << setprecision(5) << fixed;

  while (read()) {
    ld stime = gett();
    solve();
#ifdef SU1
    cerr << "Time: " << gett() - stime << endl;
#endif
    //break;
  }

  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if(c == 'a' || c == 'e'  || c == 'i'  || c == 'o'  || c == 'u'){
   cout << "vowel" << endl; 
  }else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

template<long long mod = 1000000007>
struct modint{
	long long a;

	modint() : a(0){}
	modint(long long t){
		a = t % mod;
		if(a < 0) a += mod;
	}

	operator long long() const{ return a; }

	bool operator==(const modint &x) const{ return a == x.a; }
	bool operator!=(const modint &x) const{ return a != x.a; }

	modint operator-() const{ return modint(a ? (mod - a) : 0); }
	modint operator~() const{ return pow(mod - 2); }

	modint operator+(const modint &x) const{ return modint(*this) += x; }
	modint operator-(const modint &x) const{ return modint(*this) -= x; }
	modint operator*(const modint &x) const{ return modint(*this) *= x; }
	modint operator/(const modint &x) const{ return modint(*this) /= x; }

	modint &operator+=(const modint &x){
		a += x.a;
		if(a >= mod) a -= mod;
		return *this;
	}
	modint &operator-=(const modint &x){
		a -= x.a;
		if(a < 0) a += mod;
		return *this;
	}
	modint &operator*=(const modint &x){
		a = a * x.a % mod;
		return *this;
	}
	modint &operator/=(const modint &x){
		a = a * (~x).a % mod; 
		return *this;
	}

	friend ostream &operator<<(ostream &os,const modint &x){
		return os << x.a;
	}
	friend istream &operator>>(istream &is,modint &x){
		long long t;
		is >> t;
		x = modint(t);
		return is;
	}

	modint pow(long long x) const{
		modint ret = 1,tmp = a;
		for(;x;tmp *= tmp,x >>= 1){
			if(x & 1) ret *= tmp;
		}
		return ret;
	}
};

signed main(){
	int n,k;
	cin >> n >> k;
	int sn = sqrt(n);
	modint<> dp[110][sn + 5][2] = {};
	dp[0][1][0] = 1;
	for(int i = 0;i < k;i++){
		modint<> sum = 0;
		for(int j = 1;j <= n / (sn + 1);j++){
			sum += dp[i][j][0];
			dp[i + 1][j][1] = sum * modint<>(n / j - n / (j + 1));
		}
		for(int j = n / (sn + 1) + 1;j <= sn;j++) sum += dp[i][j][0];
		for(int j = sn;j >= 1;j--){
			sum += dp[i][j][1];
			dp[i + 1][j][0] = sum;
		}
	}
	modint<> ans = 0;
	for(int i = 1;i <= sn + 1;i++) ans += dp[k][i][0] + dp[k][i][1];
	cout << ans << endl;
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vll a(n);
  ll su = 0;
  ll sua = 0;
  REP(i, n) {
    cin >> a[i];
    sua += a[i];
    su += i+1;
  }

  if(sua % su) {
    cout << "NO" << endl;
    return 0;
  }

  ll k = sua / su;

  vll b(n);
  REP(i, n) {
    b[i] = a[(i+1)%n] - a[i];
  }

  bool ok = true;
  ll cnt = 0;
  REP(i, n) {
    ok &= b[i] <= k;
    ok &= (k - b[i]) % n == 0;
    cnt += (k - b[i]) / n;
  }

  ok &= cnt == k;

  cout << (ok ? "YES" : "NO") << endl;





}








Measured memory_bytes: 4708
#pragma GCC optimize("-Ofast")

#include <bits/stdc++.h>

using namespace std;

signed main(){
    /* 入力を受け取る */
    int n;
    cin >> n;
    int* a = new int[n + 1];
    int* b = new int[n];
    for (int i = 0;i < n + 1;++i)
        cin >> a[i];
    for (int i = 0;i < n;++i)
        cin >> b[i];

    /*
    次をi=0,1,...,n-1について行う
        i番目の勇者はi番目の町のモンスターを倒せるだけ倒し、
        残りの力でi+1番目の町のモンスターを倒す
     */
    long long ans = 0; // 累計討伐数
    for (int i = 0;i < n;++i){
        int def; // i番目の勇者がi番目の町で倒すモンスター数
        a[i] -= (def = min(a[i],b[i]));
        ans += def;
        ans += min(a[i+1],b[i] - def);
        a[i+1] -= min(a[i+1],b[i] - def); // 余力でi+1番目の町
    }

    /* 答えの出力 */
    cout << ans << endl;

    /* メモリを開放、プログラムの終了 */
    delete[] a;
    delete[] b;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        if(isPalindrome(String.valueOf(n))){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    static boolean isPalindrome(String str) {
        for (int i = 0, j = str.length() - 1; i < j; i++, j--) {
            if (str.charAt(i) != str.charAt(j)) {
                return false;
            }
        }
        return true;
    }
}

Measured memory_bytes: 22864
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.D_Challenge
{
    class ABC_092
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] ab = ReadInts();
            var grid = new bool[100, 100];
            for(int i = 50; i< 100; i++)
            {
                for(int j = 0; j < 100; j++)
                {
                    grid[i, j] = true;
                }
            }
            ab[0]--;
            ab[1]--;
            for(int i = 0; i < 100; i += 2)
            {
                if (i < 49)
                {
                    for (int j = 0; j < 100; j += 2)
                    {
                        if (ab[1] > 0)
                        {
                            grid[i, j] = !grid[i, j];
                            ab[1]--;
                        }
                    }
                }
                else if (50 < i)
                {
                    for (int j = 0; j < 100; j += 2)
                    {
                        if (ab[0] > 0)
                        {
                            grid[i, j] = !grid[i, j];
                            ab[0]--;
                        }
                    }
                }
                else continue;
            }

            Console.WriteLine("100 100");
            for (int i = 0; i < grid.GetLength(0); i++)
            {
                for(int j = 0; j < grid.GetLength(1); j++)
                {
                    char c = grid[i, j] ? '#' : '.';
                    Console.Write(c);
                }
                Console.WriteLine();
            }
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int main(){
    int n;
    cin>>n;
    double t,a;
    cin>>t>>a;
    double minimum=10000;
    int count=0;
    for(int i=0;i<n;i++){
        double x;
        cin>>x;
        x=t-x*0.006;
        double k=max(x,a)-min(x,a);
        if(minimum>k){
            minimum=k;
            count=i+1;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    ll a, b;
    cin >> a >> b;
    ll cnt = 0;
    ll k = 1;
    while(k < b) {
        k += a - 1;
        cnt++;
    }
    cout << cnt;
}

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





int main(){
  int a[6];
  int b[6]={1,5,10,50,100,500};
  int count=0;
  bool j=true;
  for(int i=0;i<6;i++){
    cin>>a[i];
    count+=a[i]*b[i];
  }
  if(count<1000){j=false;}
  
  cout<<(j?"1":"0")<<endl;
  

  
  return 0;
}



Measured memory_bytes: 3080
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}
fn gcd(a: usize, b: usize) -> usize {
    if a % b == 0 {
        b
    } else {
        gcd(b, a % b)
    }
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let gcd3 = |a: usize, b: usize, c: usize| gcd(a, gcd(b, c));
    parse!(it, k: usize);
    let mut ret = 0;
    for i in 1..=k {
        for j in 1..=k {
            for l in 1..=k {
                ret += gcd3(i, j, l);
            }
        }
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2084
import sys

n, m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(m)]
ans = [0] * n
check = [10] * n
for i in l:
    if check[i[0] - 1] == 10:
        ans[i[0] - 1] = i[1]
        check[i[0] - 1] = i[1]
    elif check[i[0] - 1] != i[1]:
        print(-1)
        sys.exit()
    if i[0] == 1 and i[1] == 0 and n != 1:
        print(-1)
        sys.exit()

if n > 1 and check[0] == 10:
    ans[0] = 1

for i in ans:
    print(i, end="")


Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {
	
	private static final long MOD = 1000000000 + 7;
	
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			long n = sc.nextLong();
			long k = sc.nextLong();
			
			long combination = 0;
			long start = 0;
			long end = 0;
			for(long i = 1; i <= n + 1; i++ ) {
				
				start += i-1;
				end += n+1-i;

//				System.out.println("##" + start + "," + end);
				if ( i >= k ) {				
					combination = add(combination,(end - start + 1));
				}
			}
			
			System.out.println(combination);
			
		}
	}

	public static long add(long a, long b) {
		long ans = a + b;
		
		if ( ans >= MOD ) {
			ans = ans % MOD;
		}
		
		return ans;
	}

}

Measured memory_bytes: 35892
/****19-Aug-2020*****/
#include<bits/stdc++.h>
using namespace std;
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define ss              set<string> //insert() .top()
#define si              set<int>
#define pii             pair<int,int>
#define vi              vector<int> //push_back()
#define mii             map<int,int>
#define pq              priority_queue<int> //insert()
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define M(arr,n,type)   type *arr=new type[n];
#define T(x)            int x; cin>>x; while(x--)
#define FOR	        for(int i=0;i<n;i++)
#define gcd(a, b)        __gcd(a, b)
#define lcm(a, b)        ((a)*((b)/gcd(a,b)))
#define Mamun           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
/*erase(start_index,delete_length)*/
/*int myfun(int a,int b)
{
    return a>b;
}
*/
/*sort(vect.rbegin(),vect.rend())*/

void solve(){
    int d,t,s;cin>>d>>t>>s;
    if(s*t>=d)
        cout<<"Yes";
    else cout<<"No";







}



int main()
{
    Mamun;
    //freopen("input.txt","r",stdin);


      solve();


    return 0;
}



Measured memory_bytes: 3572
declare var require: (x: string) => any;

function Main(input: string[]) {
  const [n, m] = input[0].split(' ').map(x => +x);
  const arr = new Int32Array(n).fill(n);
  input.forEach((s, i) => {
    if (i == 0 || i > m) return;
    const [a, b] = s.split(' ').map(x => +x - 1);
    arr[a] = Math.min(arr[a], b);
  });

  let ans = 0;
  arr.reduce((wall, cur, i) => {
    if (i >= wall) {
      ans++;
      return cur;
    } else {
      return Math.min(wall, cur);
    }
  }, n);

  console.log(ans);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8').split('\n'));


Measured memory_bytes: 30992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int count = 0;
  bool ok = true;
  for (int i = 1; i <= N; i++) {
    int p;
    cin >> p;
    if (p != i) {
      count++;
    }
    if (count > 2) {
      ok = false;
      break;
    }
  }
  if (ok) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3584
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int x,y; cin>>x>>y;
    cout<<x+y/2<<endl;
}


Measured memory_bytes: 3568
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<queue>
#define null NULL
#define maxn 2000
using namespace std;
/** 区间表示：[p->dl,p->dr]
 *  从0开始计数，[0,n-1]
 *  线段树RSQ
 *
 */

struct Node
{
    long long dl,dr,s,delta;
    Node *pl,*pr;
};
int n,q;

void build(Node *&p,int l,int r)
{
    p=(Node *)malloc(sizeof(Node));
    p->dl=l,p->dr=r,p->s=0,p->delta=maxn;
    p->pl=null,p->pr=null;
    int mid=(l+r)/2;
    if(r>l)
    {
        build(p->pl,l,mid);
        build(p->pr,mid+1,r);
    }
}

void preorder(Node *p)
{
    if(p!=null)
    {
        printf("%lld %lld %lld %lld\n",p->dl,p->dr,p->s,p->delta);
        preorder(p->pl);
        preorder(p->pr);
    }
}
///在其他节点更新和查询的过程中都要向下延迟修改
void pushdown(Node *&p,int delta)
{
    p->pl->s = p->delta*(p->pl->dr - p->pl->dl+1);
    p->pr->s = p->delta*(p->pr->dr - p->pr->dl+1);
    p->pl->delta = p->delta;
    p->pr->delta = p->delta;
    p->delta=maxn;
}
///当前区间的更新只更新到某些节点，下边节点的更新需要下次延迟修改
void update(Node *&p,int l,int r,int data)
{
    ///[l,r]必然位于[p->dl,p->dr]子区间
    ///当前节点的所有数据都是正确的！！
    ///延迟修改-lazy-tag技术
    ///此处下行的是之前的数据
    if(p->delta!=maxn && p->dr>p->dl)
        pushdown(p,p->delta);

    if(p->dl==l && p->dr==r)
    {
        p->s=data*(r-l+1);
        p->delta=data;
        return ;
    }
    int mid=(p->dl+p->dr)/2;
    if(r<=mid)
        update(p->pl,l,r,data);
    else if(l>mid)
        update(p->pr,l,r,data);
    else
        update(p->pl,l,mid,data),update(p->pr,mid+1,r,data);
    p->s=p->pl->s+p->pr->s;
}
///当前节点的所有数据都是正确的！！
///即使不正确，在进入到这个之前也被pushdown过了,，所以一定是正确的
long long query(Node *&p,int l,int r)
{
    ///一个查询区间最终必然被分成若干个小的区间和，最后一个定会完全和区间贴合
    if(p->delta!=maxn && p->dr>p->dl)
        pushdown(p,p->delta);

    if(p->dl==l &&p->dr==r)
        return p->s;
    int mid=(p->dl+p->dr)/2;
    ///判断查询区间与当前区间的位置关系
    //全部位于左侧
    if(r<=mid)
        return query(p->pl,l,r);
    //全部位于右侧
    else if(l>mid)
        return query(p->pr,l,r);
    //两个都有
    else
        return query(p->pl,l,mid)+query(p->pr,mid+1,r);
}

int main()
{
    int i,type,tx,ty,x;
    Node *tree=null;
    scanf("%d%d",&n,&q);
    build(tree,0,n-1);
    for(i=0;i<q;i++)
    {
        scanf("%d",&type);
        if(type==0)
        {
            scanf("%d%d%d",&tx,&ty,&x);
            update(tree,tx,ty,x);
        }else
        {
            scanf("%d%d",&tx,&ty);
            long long ans=query(tree,tx,ty);
            printf("%lld\n",ans);
        }
    }
    return 0;
}



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

int main () {
  int A1, A2, A3, a, b, c, answer;
  cin >> A1 >> A2 >> A3;
  
  a = A1 - A2;
  if (a < 0) {
    a *= -1;
  }
  b = A2 - A3;
  if (b < 0) {
    b *= -1;
  }
  c = A3 - A1;
  if (c < 0) {
    c *= -1;
  }
  if (min({a, b, c}) == a) {
    answer = a + min(b, c);
  }
  if (min({a, b, c}) == b) {
    answer = b + min(a , c);
  }
  if (min({a, b, c}) == c) {
    answer = c + min(a, b);
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e3+50;
ll n;
int a[maxn];
int main()
{
	cin>>n;
	int cnt=0;
	while(n)
	{
		a[cnt]=n%26;
		if(a[cnt]==0) a[cnt]=26;
		cnt++;
		n=(n-1)/26;
	}
	//for(int i=0;i<cnt;++i) cout<<a[i]<<" ";
	//cout<<endl; 
	for(int i=cnt-1;i>=0;--i)
	{
		printf("%c",a[i]+96);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 3628
#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)
#define LL long long

#define DIG 41

int n,k;
LL a[1000],s[1001];
int numd[DIG];
bool d[DIG];

int main(){
  cin>>n>>k;
  s[0]=0;
  REP(i,n){
    cin>>a[i];
    s[i+1]=s[i]+a[i];
  }
  REP(i,DIG)
    d[i]=false;

  LL tmp;
  int ind,cap=0;
  vector<int> v;
  REP(l,DIG){
    cap=0;
    ind = DIG-l-1;
    REP(i,n){
      FOR(j,i+1,n+1){
	tmp = s[j]-s[i];
	if(tmp%(1UL<<(ind+1)) < (1UL<<ind))continue;
	if(v.size()==0) cap++;
	REP(p,v.size()){
	  if(tmp%(1UL<<(v[p]+1)) < (1UL<<v[p]))break;
	  if(p == v.size()-1){
	    cap++;
	  }
	}
      }
    }
    if(cap>=k){
      d[ind]=true;
      v.push_back(ind);
    }
  }
  
  LL ret=0;
  REP(i,DIG){
    if(d[i])
      ret+=(1UL<<i);
  }
  cout<<ret<<endl;
  return 0;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t r, c, n;
    cin >> r >> c >> n;

    auto on_edge = [&](int64_t x, int64_t y) {
        return (x == 0 || x == r) || (y == 0 || y == c);
    };

    vector<pair<pair<int64_t, int64_t>, int64_t>> px0, pxr, py0, pyc;
    for (auto i : irange(0L, n)) {
        array<int64_t, 2> x, y;
        cin >> x[0] >> y[0] >> x[1] >> y[1];

        if (on_edge(x[0], y[0]) && on_edge(x[1], y[1])) {
            for (auto j : irange(0L, 2L)) {
                if (x[j] == 0) {
                    px0.emplace_back(make_pair(x[j], y[j]), i);
                } else if (x[j] == r) {
                    pxr.emplace_back(make_pair(x[j], y[j]), i);
                } else if (y[j] == 0) {
                    py0.emplace_back(make_pair(x[j], y[j]), i);
                } else if (y[j] == c) {
                    pyc.emplace_back(make_pair(x[j], y[j]), i);
                }
            }
        }
    }

    sort(px0.begin(), px0.end());
    sort(pxr.begin(), pxr.end());
    sort(py0.begin(), py0.end());
    sort(pyc.begin(), pyc.end());

    vector<bool> in_st(n, false);
    vector<int64_t> st;
    for (const auto& entry : px0) {
        auto idx = entry.second;
        if (in_st[idx]) {
            if (st.back() != idx) {
                cout << "NO" << endl;
                return 0;
            }
            st.pop_back();
        } else {
            st.push_back(idx);
            in_st[idx] = true;
        }
    }
    for (const auto& entry : pyc) {
        auto idx = entry.second;
        if (in_st[idx]) {
            if (st.back() != idx) {
                cout << "NO" << endl;
                return 0;
            }
            st.pop_back();
        } else {
            st.push_back(idx);
            in_st[idx] = true;
        }
    }
    for (const auto& entry : pxr | reversed) {
        auto idx = entry.second;
        if (in_st[idx]) {
            if (st.back() != idx) {
                cout << "NO" << endl;
                return 0;
            }
            st.pop_back();
        } else {
            st.push_back(idx);
            in_st[idx] = true;
        }
    }
    for (const auto& entry : py0 | reversed) {
        auto idx = entry.second;
        if (in_st[idx]) {
            if (st.back() != idx) {
                cout << "NO" << endl;
                return 0;
            }
            st.pop_back();
        } else {
            st.push_back(idx);
            in_st[idx] = true;
        }
    }

    cout << "YES" << endl;
}

Measured memory_bytes: 8484
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,sum=0,a,b;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a>>b;
		sum+=b-a+1;
	} 
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define MAX 2000001
#define VMAX 10000
int A[MAX];
int B[MAX];
void countsort(int A[],int B[],int n){
    int C[VMAX+1];
    for(int i=0;i<=VMAX;i++){
        C[i] = 0;
    }
    for(int j=0;j<n;j++){
        C[A[j]]++;
    }
    for(int i=1;i<VMAX;i++){
        C[i] = C[i]+C[i-1];
    }
    for(int j=n-1;j>=0;j--){
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    int k = A[0];
    for(int i=1;i<n;i++){
        if(A[i]>k)
            k = A[i];
    }
    countsort(A,B,n);
    for(int i=1;i<n+1;i++){
        if(i>1) cout<<" ";
        cout<<B[i];
    }
    cout<<endl;
    return 0;
}



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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M, S;
vector <Pli> Graph[250000];
ll Dist[250000];
bool visited[250000];

int Input1(){
  int U, V, A, B;
  cin >> U >> V >> A >> B;
  for (int i = A; i <= 2500; i++){
    int now = 2501 * U + i;
    int next = 2501 * V + i - A;
    Graph[now].push_back({B, next});
  }
  for (int i = A; i <= 2500; i++){
    int now = 2501 * V + i;
    int next = 2501 * U + i - A;
    Graph[now].push_back({B, next});
  }
  return 0;
}

int Input2(int i){
  int C, D; cin >> C >> D;
  for (int j = 0; j <= 2500; j++){
    int now = 2501 * i + j;
    int next = 2501 * i + min(j + C, 2500);
    Graph[now].push_back({D, next});
  }
  return 0;
}

int Solve(int i){
  ll ans = 1e18;
  for (int j = 0; j <= 2500; j++){
    int now = 2501 * i + j;
    if (!visited[now]) continue;
    ans = min(ans, Dist[now]);
  }
  cout << ans << endl;
  return 0;
}

int main(){
  cin >> N >> M >> S;
  for (int i = 0; i < M; i++) Input1();
  for (int i = 1; i <= N; i++) Input2(i);

  priority_queue <Pli, vector<Pli>, greater<Pli> > que;
  que.push({0, 2501 + min(S, 2500)});

  while (!que.empty()){
    Pli Q = que.top(); que.pop();
    if (visited[Q.se]) continue;
    visited[Q.se] = true;
    Dist[Q.se] = Q.fi;

    for (Pli next : Graph[Q.se]){
      if (visited[next.se]) continue;
      que.push({Q.fi + next.fi, next.se});
    }
  }

  for (int i = 2; i <= N; i++) Solve(i);

  return 0;
}


Measured memory_bytes: 28712
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 19 + 7
EPS = 10 ** -10

H, W, M = MAP()
row = [0] * (H+1)
col = [0] * (W+1)
se = set()
for i in range(M):
    h, w = MAP()
    row[h] += 1
    col[w] += 1
    se.add((h, w))

mxh = max(row)
hli = []
for h, cnt in enumerate(row):
    if cnt == mxh:
        hli.append(h)
mxw = max(col)
wli = []
for w, cnt in enumerate(col):
    if cnt == mxw:
        wli.append(w)

ok = 0
for h in hli:
    for w in wli:
        if (h, w) not in se:
            ok = 1
            break
    if ok:
        break
ans = mxh + mxw - 1 + ok
print(ans)


Measured memory_bytes: 167408
#include <iostream>
#include <algorithm>
typedef long long ll;

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

#define debug(x) cout << #x << "=" << x << endl;

#define MAX_N (int)1e+5

using namespace std;

int a[MAX_N];
int b[MAX_N];
int c[MAX_N];

int main(void){

  int N;
  cin >> N;
  REP(i,N){
    cin >> a[i];
  }
  REP(i,N){
    cin >> b[i];
  }
  REP(i,N){
    cin >> c[i];    
  }

  sort(a,a+N);
  sort(b,b+N);  
  sort(c,c+N);

  ll ans = 0;

  REP(i,N){
    auto above = lower_bound(a,a+N,b[i]);
    auto blw   = upper_bound(c,c+N,b[i]);
    ll ab = above - a;
    ll bl = blw - c;
    if(ab > 0 && bl < N){
      ans += ab * (((ll)N-bl));
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
using namespace std;
using ll = long long;
int main() {
	ll x; cin >> x;
	ll amari = x % 11;
	ll res = x / 11;
	res *= 2;
	if(amari>0)
		res++;
	if (amari >= 7)
		res++;
	cout << res << endl;
	//system("pause");
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Arrays;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String x= "ABC";
        String y = "ARC";
        if(a.equals(x)){
            System.out.println("ARC");
        }
        else{
            System.out.println("ABC");

        }

    

    }
   
    
       
    
}

Measured memory_bytes: 26892