akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using std::cerr;
using std::endl;

#define int long long

const int N = 2333, P = 1e9 + 7;

inline long long fpow(long long x, int y) {
  long long ret = 1;
  for ( ; y; y >>= 1, x = x * x % P)
    if (y & 1) ret = ret * x % P;
  return ret;
}

int n, m, fa[N], X, sum;

int find(int x) {
  return x == fa[x] ? x : fa[x] = find(fa[x]);
}

struct Edge {
  int x, y, c, p;
} E[N];
std::vector<std::pair<int, int>> G[N];

int dad[N], val[N];

void dfs(int x, int fa) {
  dad[x] = fa;
  for (auto i : G[x])
    if (i.first != fa) {
      val[i.first] = i.second;
      dfs(i.first, x);
    }
}

int vis[N];

inline int calc(int x, int y) {
  for (int i = x; i; i = dad[i])
    vis[i] = 1;
  int lca = 0;
  for (int i = y; i; i = dad[i])
    if (vis[i]) {
      lca = i; break;
    }
  int ret = 0;
  for (int i = x; i != lca; i = dad[i])
    ret = std::max(ret, val[i]);
  for (int i = y; i != lca; i = dad[i])
    ret = std::max(ret, val[i]);
  for (int i = x; i; i = dad[i])
    vis[i] = 0;
  return ret;
}

signed main() {
  std::cin >> n >> m >> X;
  for (int i = 1; i <= m; ++i) {
    std::cin >> E[i].x >> E[i].y >> E[i].c;
  }
  std::sort(E + 1, E + m + 1, [](Edge a, Edge b)
    { return a.c < b.c; });
  sum = X;
  for (int i = 1; i <= n; ++i)
    fa[i] = i;
  for (int i = 1; i <= m; ++i) {
    int x = find(E[i].x), y = find(E[i].y);
    if (x == y)
      continue;
    fa[x] = y;
    sum -= E[i].c;
    E[i].p = 1;
    G[E[i].x].push_back({ E[i].y, E[i].c });
    G[E[i].y].push_back({ E[i].x, E[i].c });
  }
  if (sum < 0) {
    puts("0");
    return 0;
  }
  dfs(1, 0);
  int cnt1 = 0, cnt2 = 0;
  for (int i = 1; i <= m; ++i) {
    if (E[i].p) continue;
    int w = calc(E[i].x, E[i].y);
    w = E[i].c - w;
    if (w == sum)
      ++cnt1;
    if (w > sum)
      ++cnt2;
  }
  long long ans = 0;
  if (sum == 0) {
    ans = ((fpow(2, n - 1) - 2) % P * fpow(2, m - n + 1) % P + 2 * (fpow(2, cnt1) - 1) % P * fpow(2, cnt2) % P) % P;
  } else {
    ans = 2 * (fpow(2, cnt1) - 1) % P * fpow(2, cnt2) % P;
  }
  ans = (ans % P + P) % P;
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

int main() {
	IN(int, n);
	vector<int> a(n);
	cin >> a;
	
	map<int, LL> mp;
	RF(e, a) { mp[e]++; }
	LL ans = 0;
	RF(c, mp) { ans += c.SE * (c.SE - 1) / 2; }
	
	RF(e, a) { OUT(ans - (mp[e] - 1)); }
}


Measured memory_bytes: 10240
def examB():
    W, H, N = LI()
    height = [0,H]; width = [0,W]
    for i in range(N):
        x, y, a = LI()
        if a==1:
            width[0] = max(width[0],x)
        elif a==2:
            width[1] = min(width[1],x)
        elif a==3:
            height[0] = max(height[0],y)
        elif a==4:
            height[1] = min(height[1],y)
    ans = max(width[1]-width[0],0)*max(height[1]-height[0],0)
    print(ans)

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MAX 100000
vector<int> G[MAX];
int id[MAX],pa[MAX],dp[MAX],used[MAX];
void dfs(int v,int d){
  dp[v]=d;
  for(int i=0;i<(int)G[v].size();i++){
    dfs(G[v][i],d+1);
    pa[G[v][i]]=v;
  }
}
signed main(){
  int n;
  cin>>n;
  for(int i=0,k;i<n;i++){
    cin>>id[i]>>k;
    G[id[i]].resize(k);
    for(int j=0;j<k;j++){
      cin>>G[id[i]][j];
      used[G[id[i]][j]]=1;
    }
  }
  memset(pa,-1,sizeof(pa));
  for(int i=0;i<n;i++){
    if(!used[i]) dfs(i,0);
  }
  for(int i=0;i<n;i++){
    cout<<"node "<<i<<": parent = "<<pa[i]<<", depth = "<<dp[i];
    if(pa[i]<0) cout<<", root, [";
    else if(!G[i].size()) cout<<", leaf, [";
    else cout<<", internal node, [";
    for(int j=0;j<(int)G[i].size();j++){
      if(j) cout<<", ";
      cout<<G[i][j];
    }
    cout<<"]"<<endl;
  }
  return 0;
}



Measured memory_bytes: 9492
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        string S;
        cin >> S;
        ll now = 0;
        ll ans = 0;
        rep(i, 0, len(S)) {
                if (S[i] == 'B') continue;
                ans += i - now;
                ++now;
        }
        cout << ans << endl;
}

Measured memory_bytes: 3752
from collections import deque
n = int(input())
a = []
for i in range(n):
    a1 = list(map(int,input().split()))
    a.append(a1)
l = [[[] for i in range(n)] for i in range(n)]
c = 0
day = 0
for i in range(n):
    ap = [i,a[i][0]-1]
    ap.sort()
    for j in range(1,n-1):
        p = [i,a[i][j]-1]
        p.sort()
        l[ap[0]][ap[1]].append(p)
        ap = p
rl = [[0 for i in range(n)] for i in range(n)]
dl = [[0 for i in range(n)] for i in range(n)]
d = deque()
for i in range(n):
    for j in range(n):
        if i < j:
            if len(l[i][j]) > 0:
                for k in l[i][j]:
                    rl[k[0]][k[1]] += 1
#print(rl)
for i in range(n):
    for j in range(n):
        if i < j:
            if rl[i][j] == 0:
                d.append([[i,j],0])
al = []
key = 0
#print(l)
if len(d) == 0:
    key = 1
while len(d):
    #print(d)
    now,day = d.pop()
    day += 1
    if len(l[now[0]][now[1]]) == 0:
        al.append(day)
    else:
        for i in l[now[0]][now[1]]:
            if rl[i[0]][i[1]] == 1:
                rl[i[0]][i[1]] -= 1
                d.append([i,max(day,dl[i[0]][i[1]])])
            else:
                rl[i[0]][i[1]] -= 1
                dl[i[0]][i[1]] = max(day,dl[i[0]][i[1]])
    if day > n*(n-1)//2:
        key = 1
        break
md = 0
for i in range(n):
    md += sum(rl[i])
if key == 1 or md > 0:
    print(-1)
else:
    print(max(al))

Measured memory_bytes: 200452
#include <iostream>

using namespace std;

int main(void) {
    int64_t X;
    cin >> X;

    int64_t money = 100;
    int now = 0;
    while(money < X) {
        money += money / 100;
        ++now;
    }

    cout << now << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define MOD                1000000007
#define F                  first
#define S                  second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define REP(i,l,r)         for(int i=l;i<r;i++)
#define RER(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
#define test()             int x;cin >> x;while(x--)
using namespace std;
int32_t main(){

	FASTIO;
	int a,b;
	cin >> a >> b;
	if(a<b){
		cout << min(a,b-a) << endl;
	}
	else if(a==b){
		cout << "0";
	}
	else
	{
		int zz = a%b;
		cout << min(zz,b-zz) << endl;
	}
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;

vector<ll> l,r,d,u,x,y;
vector<ll> cand;

void makeit2(vector<ll>& v){
  if(!v.empty()){
    sort(all(v));
    ll a=v.front();
    ll b=v.back();
    v.clear();
    v.push_back(a);v.push_back(b);
  }
}
void makecand(vector<ll> a,vector<ll>b,int p){
  if(!a.empty()&&!b.empty()){
    cand.push_back((a[0]-b[0])/p);
    cand.push_back((a[1]-b[1])/p);
  }
}


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

  rep(i,n){
    ll p,q;cin>>p>>q;
    p*=2;q*=2;
    string s;cin>>s;
    if(s[0]=='L'){
      l.push_back(p);
      y.push_back(q);
    }
    if(s[0]=='R'){
      r.push_back(p);
      y.push_back(q);
    }
    if(s[0]=='D'){
      d.push_back(q);
      x.push_back(p);
    }
    if(s[0]=='U'){
      u.push_back(q);
      x.push_back(p);
    }
  }
  makeit2(l);makeit2(r);makeit2(d);makeit2(u);makeit2(x);makeit2(y);
  makecand(l,r,2);
  makecand(u,d,2);
  makecand(l,x,1);
  makecand(x,r,1);
  makecand(d,y,1);
  makecand(y,u,1);
  cand.push_back(0);
  cand.push_back(1<<30);
  ll ans=4e18;
  rep(i,cand.size()){
    cand[i]=abs(cand[i]);
    //cout<<cand[i]<<endl;
    ll xm,xM,ym,yM;
    xm=1e18;xM=-1e18;ym=1e18;yM=-1e18;
    if(!l.empty()){
      chmin(xm,l[0]-cand[i]);chmax(xM,l[1]-cand[i]);
    }
    if(!r.empty()){
      chmin(xm,r[0]+cand[i]);chmax(xM,r[1]+cand[i]);
    }
    if(!u.empty()){
      chmin(ym,u[0]+cand[i]);chmax(yM,u[1]+cand[i]);
    }
    if(!d.empty()){
      chmin(ym,d[0]-cand[i]);chmax(yM,d[1]-cand[i]);
    }
    if(!x.empty()){
      chmin(xm,x[0]);chmax(xM,x[1]);
    }
    if(!y.empty()){
      chmin(ym,y[0]);chmax(yM,y[1]);
    }
    chmin(ans,abs((xM-xm)*(yM-ym)));
    //cout<<abs((xM-xm)*(yM-ym))<<endl;
  }
  cout<<setprecision(10)<<(double)ans/4.0<<endl;
}


Measured memory_bytes: 2160
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

aa = []
for i in range(h):
    if a[i] != ["."]*w:
         aa.append(a[i])
        

import numpy as np

aaa = np.array(aa)

aaaa=[]
for i in range(aaa.T.shape[0]):
    if "".join(aaa.T[i]) != "."*aaa.T.shape[1]:
         aaaa.append(aaa.T[i])
            
tm = np.array(aaaa).T

for i in range(tm.shape[0]):
    print("".join(tm[i]))

Measured memory_bytes: 21656
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int vis[11];
int check(int n)
{
	while(n)
	{
		if(vis[n%10]==1)
			return 0;
		n/=10;
	}
	return 1;
}
int main()
{
	int n,k;
	int x;
	scanf("%d%d",&n,&k);

        for(int i=0;i<k;i++)
	    {
		   cin>>x;
		   vis[x]=1;
	    }
	    for(int i=n;;i++)
	    {
		   if(check(i))
		   {
                       cout<<i<<endl;
                        return 0;

                   }
	    }


	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MOD 100000
int dp[50][3001];
int main(){
	int n,m,s;
    while(scanf("%d%d%d",&n,&m,&s),(n|m|s)){
    	for(int i = 0; i < n*n+1; i++){
    		for(int j = 0; j < s+1; j++){
    			dp[i][j] = 0;
       		}
     	}
        dp[0][0] = 1;
 
        for(int i = 1; i < m+1; i++){
           	for(int j = n*n;j > 0; j--){
              	for(int k = i; k < s+1; k++){
                	dp[j][k] += dp[j-1][k-i];
                    dp[j][k] %= MOD;
            	}
            }
        }
       	printf("%d\n",dp[n*n][s]);
    }
    return 0;
}

Measured memory_bytes: 1612
#include <iostream>

using namespace std;

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


Measured memory_bytes: 3100
#include <iostream>
#include <cmath>

bool is_three_multiplied(int i){
    int ret = 0;
    while (i>0)
    {
        ret = (ret + i % 10) % 3;
        i /= 10;
    }

    return ret == 0;
}

int main(void){
    using namespace  std;
    int X;
    cin >> X;

    int ret = X;
    while(true){
        if(ret==2 || ret ==3 || ret ==5)
        {
            cout << ret << endl;
            return 0;
        }

        if(ret % 2 == 0){
            ret++;
            continue;
        }

        if(ret %5==0){
            ret++;
            continue;
        }

        if(is_three_multiplied(ret)){
            ret++;
            continue;
        }

        bool a = false;
        int border = ret / 2 + 2;
        for (int i = 3; i <= border;i+=2){
            if(ret %i==0){
                ret++;
                a = true;
                break;
            }
        }
        if(a)
            continue;

        break;
    }
       
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int x, y, amari;
    cin >> x >> y;
    if(x >= y){
        while(1){
            if(x % y == 0)break;
            amari = x % y;
            x = y;
            y = amari;
        }
        cout << y << endl;
    }else if(x < y){
        while(1){
            if(y % x == 0)break;
            amari = y % x;
            y = x;
            x = amari;
        }
        cout << x << endl;
    }
    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    ll n, m;
    cin >> n >> m;
    ll a[n];
    rep(i, n) cin >> a[i];

    unordered_map<ll, ll> um;
    ll s[n + 1];
    s[0] = 0;
    rep(i, n)
        s[i + 1] = s[i] + a[i];

    rep(i, n + 1)
    {
        um[s[i] % m]++;
    }

    ll sum = 0;
    for (auto x : um)
    {
        if (x.second == 1)
            continue;
        sum += (x.second * (x.second - 1)) / 2;
    }

    OP(sum);
    return 0;
}

Measured memory_bytes: 5260
n,x,m = map(int,input().split())
mod = m
num = []
ans = 0
cnt = 0
ch = x
while True:
    if ch not in num:
        num.append(ch)
    else:
        st = ch #ループの開始している配列の初めの数字
        break
    ch *= ch
    ch %= mod
for i in range(len(num)):
    if num[i] == st:
        stnum = i #ループ開始の最初の配列のの番号
        #print("重なり始め =",stnum)
        break
else:
    stnum = len(num) - 1
if 0 in num:
    ans = sum(num[:n])
else:
    #print("len(num) =",len(num),"stnum =",stnum)
    if (len(num)-stnum) != 0:
        rest = (n-stnum)%(len(num)-stnum)
        sho = (n-stnum)//(len(num)-stnum)
        #print("rest =",rest,"sho =",sho)
    else:
        rest = n
        sho = 0
    if n <= stnum + 1:
        ans = sum(num[:n])
    else:
        ans = sum(num[:stnum]) + sum(num[stnum:stnum+rest]) + sum(num[stnum:])*sho
print(ans)

Measured memory_bytes: 68492
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    int p[n];
    rep(i,n)cin>>p[i];
    vector<int> ord(n);
    rep(i,n)ord[i]=i;
    sort(ord.begin(),ord.end(),[&](int x, int y){
        return p[x]>p[y];
    });
    multiset<int> st;
    ll ans = 0;
    st.insert(n);
    st.insert(n);
    st.insert(-1);
    st.insert(-1);
    for(auto i : ord){
        auto itr = st.lower_bound(i);
        ll idx1 = *itr;
        ++itr;
        ll idx2 = *itr;
        --itr;
        --itr;
        ll idx3 = *itr;
        --itr;
        ll idx4 = *itr;
        ans += p[i]*(idx2-idx1)*(i-idx3);
        ans += p[i]*(idx3-idx4)*(idx1-i);
        st.insert(i);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5760
print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][int(input())-1])

Measured memory_bytes: 9028
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

cs_A = [0] #si=[0,i)の和 [a,b)の和=sb−sa
for i in A:
    cs_A.append(cs_A[-1] + i)
cs_B = [0] #si=[0,i)の和 [a,b)の和=sb−sa
for i in B:
    cs_B.append(cs_B[-1] + i)

def is_ok(mid, v):
    if v + cs_B[mid] <= K:
        return True
    else:
        return False

def meguru_bisect(v, ng, ok):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid, v):
            ok = mid
        else:
            ng = mid
    return ok
ans = 0
for i in range(0, N+1):
    v = cs_A[i]
    idx = meguru_bisect(v, M+1, -1)
    if 0 <= idx <= M:
        if v + cs_B[idx] <= K:
            ans = max(ans, i + idx) 
print(ans)

Measured memory_bytes: 47548
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N,  ans = -INF;
	vector<vector<int>> F, P;
	
	cin>>N;
	
	F.resize(N, vector<int>(10));
	P.resize(N, vector<int>(11));
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j < 10; j++)
		{
			cin>>F[i][j];
		}
	}
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= 10; j++)
		{
			cin>>P[i][j];
		}
	}
	
	for(int i = 1; i < (1<<10); i++){
		int sum = 0;
		
		// for(int j = 0; j < 10; j++){
			// int con = 0;
			
			// if(!((i>>j)&1)) continue;
			
			// for(int k = 0; k < N; k++){
				// if(F[k][j]) con++;
			// }
			// sum += P[][]
		// }
		
		for(int k = 0; k < N; k++){
			int con = 0;
			for(int j = 0; j < 10; j++){
				if(!((i>>j)&1)) continue;
				if(F[k][j]) con++;
			}
			sum += P[k][con];
		}
		// cout<<i<<" "<<ans<<" sum "<<sum<<endl;
		ans = max(ans, sum);
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  vector<int> V(N), W(N);
  for (int i = 0; i < N; ++i) {
    cin >> V[i] >> W[i];
  }

  int Q;
  cin >> Q;

  vector<int> v(Q), L(Q);
  for (int i = 0; i < Q; ++i) {
    cin >> v[i] >> L[i];
  }

  vector<vector<int>> special(1 << 9);
  for (int p = 1; p <= N; ++p) {
    if ((p >> 8) && (p >> 9) == 0) {
      special[p].resize(100000 + 1);
      vector<pair<int, int>> x;
      for (int t = p; t; t /= 2) {
        x.emplace_back(V[t - 1], W[t - 1]);
      }
      for (int s = 0; s < 1 << x.size(); ++s) {
        int sv = 0;
        int sw = 0;
        for (int j = 0; j < x.size(); ++j) {
          if (s >> j & 1) {
            sv += x[j].first;
            sw += x[j].second;
          }
        }
        if (sw <= 100000) special[p][sw] = max(special[p][sw], sv);
      }
      for (int i = 0; i < 100000; ++i) {
        special[p][i + 1] = max(special[p][i + 1], special[p][i]);
      }
    }
  }

  vector<int> ans(Q);
  for (int i = 0; i < Q; ++i) {
    if (v[i] >> 9) {
      vector<pair<int, int>> x;
      int t = v[i];
      for (; t >> 9; t /= 2) {
        x.emplace_back(V[t - 1], W[t - 1]);
      }
      for (int s = 0; s < 1 << x.size(); ++s) {
        int sv = 0;
        int sw = 0;
        for (int j = 0; j < x.size(); ++j) {
          if (s >> j & 1) {
            sv += x[j].first;
            sw += x[j].second;
            if (sw > L[i]) break;
          }
        }
        if (sw <= L[i]) ans[i] = max(ans[i], sv + special[t][L[i] - sw]);
      }
    } else {
      vector<pair<int, int>> x;
      for (int t = v[i]; t; t /= 2) {
        x.emplace_back(V[t - 1], W[t - 1]);
      }
      for (int s = 0; s < 1 << x.size(); ++s) {
        int sv = 0;
        int sw = 0;
        for (int j = 0; j < x.size(); ++j) {
          if (s >> j & 1) {
            sv += x[j].first;
            sw += x[j].second;
            if (sw > L[i]) break;
          }
        }
        if (sw <= L[i]) ans[i] = max(ans[i], sv);
      }
    }
  }

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

  return 0;
}


Measured memory_bytes: 107008
#include<iostream>
#include<stdlib.h>
using namespace std;

int main(){
	long num, k_time, ans=0;
	cin >> num >> k_time;
	long enemy[num];
	for(long i=0; i<num ;i++){
		cin >> enemy[i];
	}
	qsort(enemy,num,sizeof(long),
		[](const void* a, const void* b){
			long arg1 = *static_cast<const int*>(a);
			long arg2 = *static_cast<const int*>(b);
			if(arg1 < arg2) return -1;
			if(arg1 > arg2) return 1;
			return 0;
		}
	);
	
	for(long i=0; i<num-k_time ;i++){
		ans += enemy[i];
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3324
N = int(input())
S = input()
divide = 0
count = 0
for i in range(1000):
    num = str(i)
    while(len(num)<3):
        num = "0"+num
    flag = [0,0,0]
    for j in range(3):
        for k in range(divide,N):
            if num[j] == S[k]:
                flag[j] = 1
                divide = k+1
                break
    divide = 0      
    if(flag == [1,1,1]):
        count +=1
print(count)

Measured memory_bytes: 44128
S = input()

n = 0

ans = 0

counter = 0

while n != len(S):
    if S[n] == 'A' or S[n] == 'C' or S[n] == 'T' or S[n] == 'G':
        counter += 1
    else:
        counter = 0
    if ans < counter:
        ans = counter
    n += 1

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define M 1000005
#define P 1000000007
#define LL long long
using namespace std;
int A[M],B[M],n;
char str[M]; 
vector<int>edge[M];
void dfs(int x,int f,int v){
	v+=A[x];
	B[x]=v;
	for(int i=0;i<edge[x].size();i++){
		int y=edge[x][i];
		if(y==f)continue;
		dfs(y,x,v);
	}
}
int main(){  
	int n,m,a,b;cin>>n>>m;
	for(int i=1;i<n;i++){
		scanf("%d %d",&a,&b);
		edge[a].push_back(b);
		edge[b].push_back(a); 
	}
	while(m--){
		scanf("%d %d",&a,&b);
		A[a]+=b;
	}
	dfs(1,0,0);
	for(int i=1;i<=n;i++)printf("%d ",B[i]);puts("");
	return 0;
}

Measured memory_bytes: 51584
/* ex4_3
   moka223711 */

#include <stdio.h>

int main(void){
    // 高さがn(n+1)/2[m](n=1,2,…,999)の999本の塔が西から順に立っている
    // 雪に埋もれていない塔の高さから雪が何m積もっているか求める
    // 雪に埋もれていない西側の塔の高さをh_west、東側の塔の高さをh_eastとする
    
    int h_west, h_east, dif, ans;
    scanf("%d %d", &h_west, &h_east);
    
    // 東側の塔の高さから西側の塔の高さを引き、差difを求める
    dif = h_east - h_west;
    // ここでdifは東側の塔がdif番目の塔であることを表す
    
    // 差difから東側の塔の高さを求めて、雪に埋もれていない塔の高さを引くことで
    // 雪が何m積もっているかを求める
    ans = dif * (dif + 1) / 2 - h_east;
    printf("%d", ans);
    
    return 0;
}


Measured memory_bytes: 128
input_lines = gets.chop.split.map(&:to_i)
input_lines2 = gets.chop.split.map(&:to_i)

n = input_lines[0]
k = input_lines[1]
count = 0
lines2Count = 0
lastNumCount = 0

for arrayRow in 0...input_lines2.size
    for arrayRow2 in (arrayRow+1)...input_lines2.size
        if input_lines2[arrayRow] > input_lines2[arrayRow2]
            lines2Count = lines2Count + 1
        end
        if input_lines2[arrayRow2] > input_lines2[arrayRow]
            lastNumCount = lastNumCount + 1
        end
    end
end


decreaseK = k
a = k/2
b = k%2 + a
sumK = (k + 1) * a
if k%2 == 1
    sumK = sumK + b
end

decreaseK = k - 1
a = decreaseK/2
b = decreaseK%2 + a
sumL = (decreaseK + 1) * a
if decreaseK%2 == 1
    sumL = sumL + b
end


count = lines2Count*sumK + lastNumCount*sumL
puts count%(10**9+7)

Measured memory_bytes: 1916
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] d = new int[N];
		long sum = 0;
		for (int i = 0; i < N; i++) {
			d[i]=sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (i != j ) {
					sum += d[i]*d[j];
				}
			}
		}
		System.out.println(sum / 2);
	}

}

Measured memory_bytes: 35864
n=int(input())
if n <=111:
  print(111)
elif n<=222:
  print(222)
elif n<=333:
  print(333)
elif n<=444:
  print(444)
elif n<=555:
  print(555)
elif n<=666:
  print(666)
elif n<=777:
  print(777)
elif n<=888:
  print(888)
else :
  print(999)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int h,n;
int a[1005],b[1005];
int dp[2][10005];

int main(void){
	scanf("%d%d",&h,&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&a[i],&b[i]);
	}
	for(int i=0;i<=h;i++){
		dp[0][i]=INF;
		dp[1][i]=INF;
	}
	dp[0][h]=0;
	int cur=0,nxt=1;
	for(int i=0;i<n;i++){
		for(int j=h;j>=0;j--){
			dp[nxt][j]=min(dp[nxt][j],dp[cur][j]);
			dp[cur][max(0,j-a[i])]=min(dp[cur][max(0,j-a[i])],dp[cur][j]+b[i]);
		}
		swap(cur,nxt);
		for(int i=0;i<n;i++){
			dp[nxt][i]=INF;
		}
		dp[nxt][h]=0;
	}
	printf("%d\n",dp[cur][0]);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int n,a[100000],num[100010];
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]<=n)num[a[i]]++;
    }
    int cnt=0;
    for(int i=0;i<n;i++){
        if(a[i]>n) continue;
        if(num[a[i]]>=a[i]){
            cnt+=a[i];
            num[a[i]]=0;
        }
    }
    cout<<n-cnt<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

int main() {
	int n;

	while (cin >> n&&n) {
		int s[100];
		for (int i = 0; i < n; i++) {
			cin >> s[i];
		}
		for (int i = 0; i < n - 1; i++) {
			for (int j = n - 1; j > i; j--) {
				if (s[j] > s[j - 1])swap(s[j], s[j - 1]);
			}
		}
		int sum = 0;
		for (int k = 1; k < n - 1; k++)sum += s[k];
		cout << sum / (n-2) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>

using namespace std;
typedef pair<int, int> P;

int n;
vector<int> G[10005];
set<P> S;
int ass[10005];
int deg[10005];
int c[10005];

int main(void)
{
  cin >> n;
  int u, v;
  for(int i = 0; i < n-1; i++){
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for(int i = 0; i < n; i++) cin >> c[i];
  sort(c, c+n);

  int ans = 0;
  for(int i = 1; i <= n; i++){
    deg[i] = G[i].size();
    S.insert(make_pair(G[i].size(), i));
  }
  for(int i = 0; i < n; i++){
    P p = *S.begin();
    int v = p.second;
    ans += c[i] * deg[v];
    ass[v] = c[i];
    S.erase(S.begin());
    for(int j = 0; j < G[v].size(); j++){
      if(S.count(make_pair(deg[G[v][j]], G[v][j]))){
        S.erase(make_pair(deg[G[v][j]], G[v][j]));
        deg[G[v][j]]--;
        S.insert(make_pair(deg[G[v][j]], G[v][j]));
      }
    }
  }
  cout << ans << endl;
  for(int i = 1;i <= n; i++) cout << ass[i] <<" "; cout<< endl;

  return 0;
}


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

typedef long long ll;


int main(){
    string s,t;
    cin>>s>>t;
    int s_len = s.length(),t_len = t.length();
    int dp[3005][3005];
    for(int i = 0;i <= s_len;i++){
        for(int j = 0;j <= t_len;j++){
            dp[i][j]=0;
        }
    }
    for(int i = 0;i <= s_len;i++){
        for(int j = 0;j <= t_len;j++){
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
            dp[i][j+1]=max(dp[i][j+1],dp[i][j]);
            if(i<s_len&&j<t_len&&s[i]==t[j]){
                dp[i+1][j+1]=max(dp[i][j]+1,dp[i+1][j+1]);
            }
        }
    }
    
#ifdef __DEBUG__
    for(int i = 0;i <= s_len;i++){
        for(int j = 0;j <= t_len;j++){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }
#endif
    
    string ret;
    ret.reserve(min(s_len,t_len));
    int i = s_len,j = t_len;
    while(i>0&&j>0){
        if(dp[i][j]==dp[i][j-1]){
            j--;
        }else if(dp[i][j]==dp[i-1][j]){
            i--;
        }else{
            ret.push_back(s[i-1]);
            i--;j--;
        }
    }
    reverse(ret.begin(),ret.end());
    cout<<ret<<endl;
}


Measured memory_bytes: 35456
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
b=sorted(a)    
n_max=b[-1]
n_max2=b[-2]

for i in range(N):
    if a[i]==n_max:
        print(n_max2)
    else:
        print(n_max)

Measured memory_bytes: 15080
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m; cin>>n>>m;
    vector<pair<int,int>> v;
    for(int i=0;i<m;i++){
        int p,y; cin>>p>>y;
        v.push_back(pair<int,int>(p,y));
    }
    vector<pair<int,int>>cv = v;
    sort(begin(cv),end(cv),[](auto x, auto y){return x.second<y.second;});
    map<int,int> num;
    vector<int> el(n+1,1);
    for(auto x:cv){
        num[x.second]=el[x.first];
        el[x.first]++;
    }
    for(auto x:v){
        printf("%06d%06d\n",x.first,num[x.second]);
    }
}

Measured memory_bytes: 8180
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

const INF = int.max / 4;

struct P {
    int v, cost;
}

class Edge {
    int from, to, cap, cost;
    this() {}
    this(int from, int to, int cap, int cost) {
        this.from = from;
        this.to = to;
        this.cap = cap;
        this.cost = cost;
    }
    Edge rev;
    override string toString() {
        return "Edge " ~ [from, to, cap, cost].to!string;
    }
}

class PrimalDual {
    int V;
    Edge[][] G;
    int[] H;
    int[] dist;
    Edge[] preve;
    void addEdge(int from, int to, int cap, int cost) {
        //writeln([from, to, cap, cost]);
        auto a = new Edge(from, to, cap, cost),
             b = new Edge(to, from, 0, -cost);
        a.rev = b;
        b.rev = a;
        G[from] ~= a;
        G[to] ~= b;
    }
    this(int V) {
        this.V = V;
        this.G = new Edge[][V];
        this.H = new int[V];
        this.dist = new int[V];
        this.preve = new Edge[V];
    }

    int min_cost_flow(int s, int t, int flow) {
        int ret = 0;
        H[] = 0;
        while (flow > 0) {
            //writeln([s, t, flow]);
            dist[] = INF;
            dist[s] = 0;
            BinaryHeap!(Array!P, "a.cost > b.cost") PQ;
            PQ.insert(P(s, 0));
            while (!PQ.empty) {
                P p = PQ.front; PQ.removeFront;
                if (dist[p.v] < p.cost) continue;
                foreach (Edge e; G[p.v]) {
                    if (e.cap > 0 && dist[e.to] > dist[p.v] + e.cost + H[p.v] - H[e.to]) {
                        dist[e.to] = dist[p.v] + e.cost + H[p.v] - H[e.to];
                        preve[e.to] = e;
                        PQ.insert(P(e.to, dist[e.to]));
                    }
                }
            }
            if (dist[t] == INF) return -1;
            foreach (v; 0 .. V) H[v] += dist[v];
            int d = flow;
            for (int v = t; v != s; v = preve[v].from) {
                d = min(d, preve[v].cap);
            }
            flow -= d;
            ret += d * H[t];
            for (int v = t; v != s; v = preve[v].from) {
                auto e = preve[v];
                e.cap -= d;
                e.rev.cap += d;
            }
        }
        return ret;
    }
}

void main() {
    int N; scanf("%d\n", &N);
    int[] A = readln.chomp.split(" ").map!((x) => x.to!int - 1).array;
    auto G = new PrimalDual(2 * N + 2);
    foreach (i; 0 .. N) {
        foreach (j; 0 .. N) {
            if (A[i] == j) continue;
            G.addEdge(i + 1, j + N + 1, 1, abs(i - j) * (A[i] + 1));
        }
    }
    foreach (i; 0 .. N) {
        G.addEdge(0, i + 1, 1, 0);
    }
    foreach (i; 0 .. N) {
        G.addEdge(i + N + 1, 2 * N + 1, 1, 0);
    }
    writeln(G.min_cost_flow(0, 2 * N + 1, N));
}

Measured memory_bytes: 2884
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
typedef long long int64;
int main(){
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int64 a,b,c,d;
  cin>>a>>b>>c>>d;
  int64 res=b*d;
  res=max(res,a*c);
  res=max(res,a*d);
  res=max(res,b*c);
  cout<<res<<'\n';
  return 0;
}
//2020.09.13 20:00:37


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())

using namespace std;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}


using ll = long long;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int clamp(int n, int a, int b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

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

    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A*N, B) << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t H, count;
    cin >> H;
    for (count = 0; H > 0; count++){
        H /= 2;
    }
    cout << int64_t(pow(2, count)) - 1 << endl;
}


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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n' //toggle off for interactive problems
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long
// #define pow mypow

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9+5;
const int MOD = 1e9+7;

int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	int x; cin >> x;
	if (x == 0) cout << 1 << endl;
	else if (x == 1) cout << 0 << endl;
	return 0;
}


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

long long int res(vector<long long int> &va,vector<long long int> &we,long long int n,long long int w)
{
    long long int a[n+1][w+1];
    for(long long int i=0;i<=w;i++){
    a[0][i]=0;
    }
    for(long long int i=1;i<=n;i++)
    {
        for(long long int j=0;j<=w;j++)
        {
            if(j>=we[i-1])
            a[i][j]=max(a[i-1][j],a[i-1][j-we[i-1]]+va[i-1]);
            else
            a[i][j]=a[i-1][j];
        }
    }
    return a[n][w];
}
int main() {
	long long int n,w;
	cin>>n>>w;
	vector<long long int> we(n);
	vector<long long int> va(n);
	for(long long int i=0;i<n;i++)
	{
	    cin>>we[i]>>va[i];
	}
	cout<<res(va,we,n,w)<<endl;
	return 0;
}

Measured memory_bytes: 82516
using System;
using System.Linq;

namespace C {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            long[] a = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            int ans = 0;
            for(int i = 0; i < N; ++i) {
                long tmp = a[i];
                while(tmp % 2 == 0) {
                    ans++;
                    tmp /= 2;
                }
            }

            Console.WriteLine(ans);
        }
    }
}


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

using namespace std;

int main(){

    string s;
    cin >> s;

    int year = atoi((s.substr(0,4)).c_str());
    int month1 = atoi((s.substr(5,2)).c_str());

	if(year <= 2018){
      cout << "Heisei" << endl;
    }else if(year == 2019){
      if(month1 <= 4){
        cout << "Heisei" << endl;
      }else cout << "TBD" << endl;
    }else cout << "TBD" << endl;

    return 0;
}

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

const LL MOD = 1e9 + 7;

inline LL mod_add(LL a, LL b) {
    return (a + b) % MOD;
}

inline LL mod_sub(LL a, LL b) {
    return (a + MOD - b) % MOD;
}

inline LL mod_mul(LL a, LL b) {
    return ((a % MOD) * (b % MOD)) % MOD;
}

LL mod_bipow(LL x, LL y) {   // power using bisection method
    if (y == 0) return 1;
    else if (y == 1) return x % MOD;
    else if (y % 2 == 0) {
        LL val = mod_bipow(x, (LL)(y / 2));
        return mod_mul(val, val);
    } else {
        LL val = mod_bipow(x, (LL)(y / 2));
        return mod_mul(mod_mul(val, val), x);
    }
}

LL mod_inv(LL x) {   // compute x^{-1}=x^{MOD-2} (when MOD is a prime number) using Fermat theorem
    return mod_bipow(x, MOD - 2);
}

LL mod_div(LL a, LL b) {   // using a/b=a*b^{-1}
    return mod_mul(a, mod_inv(b));
}

map<LL, LL> factorize(LL n) {
    map<LL, LL> prime_factors;
    LL m = n;
    FOR(i, 2, (LL)(sqrt(n) + 1)) {
        if (m < i) break;   // 全て割り切った
        while (m % i == 0) {
            prime_factors[i]++;
            m /= i;
        }
    }
    if (m != 1) {   // 残りの素因数(必ず1つの素数となる)
        prime_factors[m]++;
    }
    return prime_factors;
}

int main() {
    LL N;
    cin >> N;
    map<LL, LL> pfs_all;
    FOR(i, 2, N + 1) {
        map<LL, LL> pfs = factorize(i);
        EACH(pf, pfs) {
            pfs_all[pf.first] += pf.second;
        }
    }
    LL ans = 1;
    EACH(pf, pfs_all) {
        //$(pf.first);
        //$(pf.second);
        ans = mod_mul(ans, mod_add(pf.second, 1));
        //$(ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cfloat>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <iomanip>

using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
// #define req(j, n) for (ll j = 1; j < (n+1); j++)
// #define rer(k, n) for (ll k = 1; k < (n+1); k++)





int main()
{
    int N;
    cin >> N;
    int v;
    vector<int> ans(10050);
    for (int i=1; i < 105; i++) {
        for (int j=1; j<105; j++) {
            for (int k=1; k<105; k++) {
                v = i*i+j*j+k*k+i*j+j*k+k*i;
                if (v < 10050) {
                    ans[v] += 1;
                }
            }
        }
    }
    for (int i=0; i<N; i++) {
        cout << ans[i+1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3536
sx, sy, tx, ty = map(int, input().split())

dif_x = tx - sx
dif_y = ty - sy

route_one_forward = 'U'*dif_y + 'R'*dif_x
route_two_back = 'D'*dif_y + 'L'*dif_x
route_three_forward = 'L' + 'U'*(dif_y + 1) + 'R'*(dif_x + 1) + 'D'
route_four_back = 'R' + 'D'*(dif_y + 1) + 'L'*(dif_x + 1) + 'U'

route_all = route_one_forward + route_two_back + route_three_forward + route_four_back
print(route_all)

Measured memory_bytes: 3060
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if x[mid] >= n:
        rr = mid
    else:
        ll = mid+1


N,K,S = m()


if N == K:
    print(jo([S for i in range(N)]))
else:
    if S % 2 == 0:
        if S != 10**9:
            print(jo([S//2 if i <= K else S+1 for i in range(N)]))
        else:
            print(jo([S//2 if i <= K else 1 for i in range(N)]))
    else:
        if S == 1:
            if S != 10**9:
                print(jo([S if i < K else S+1 for i in range(N)]))
            else:
                print(jo([S if i < K else S//2+1 for i in range(N)]))
        else:
            if S != 10**9:
                print(jo([(S//2+1 if i%2==0 else S//2) if i <= K else S+1 for i in range(N)]))
            else:
                print(jo([(S//2+1 if i%2==0 else S//2) if i <= K else S//3+1 for i in range(N)]))











Measured memory_bytes: 15560