akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#define ll long long
#include<algorithm>
#include<string>
#include<vector>
#include<unordered_set>
using namespace std;
ll ans = 0;



int main()
{
    ll h, w;
    cin>>h>>w;
    char board[h][w];

    for(int i=0; i<h; ++i)
    {
        for(int j=0; j<w; ++j)
        {
            cin>>board[i][j];
        }
    }

    ll paths[h][w];
    for(int i=0; i<h; ++i)
    {
        for(int j=0; j<w; ++j)
        {
            if(i==0 && j==0)
            {
                paths[i][j] = 1;
                continue;
            }
            if(board[i][j] == '#')
            {
                    paths[i][j] = 0;
                    continue;
            }
            else
            {
                if(i==0)
                {
                    paths[i][j] = paths[i][j-1];
                    continue;
                }
                else if(j==0)
                {
                    paths[i][j] = paths[i-1][j];
                    continue;
                }
                else
                {
                    paths[i][j] = (paths[i-1][j] + paths[i][j-1])%(1000000000+7);
                    paths[i][j] = paths[i][j]%(1000000000+7);
                }
            }


        }
    }
    cout<<paths[h-1][w-1];
    return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vector<string> W(n); for(auto& e : W) cin >> e;

    map<string, bool> dic; dic[W[0]] = true;
    bool ok = true;
    rep(i, 1, n){
        string e = W[i];
        if(dic[e] or W[i-1].back() != W[i][0]){
            ok = false;
            break;
        }
        dic[e] = true;
    }

    cout << (ok ? "Yes":"No") << endl;

    return 0;
}


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

int main(){
	
	int x,c;
	int ans = 0; 
	
	cin >> x;
	for(c = 1;100*c<=x;c++){
		if(105*c>=x){
			ans = 1;
			break;  
		} 
	}
	cout << ans; 
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back
#define pp pair<int,int>
#define rep(i,l,r) for(int i=l;i<r;i++)

#define mod 1000000007
#define ll long long
vi g[100005];
vector<ll> dp(100005,0);//white
vector<ll> dp2(100005,0);//black root
void dfs(int src,int parent)
{
	dp[src] = 1;
	dp2[src] = 1;
	for(auto &x:g[src])
	{
		if(x!=parent)
		{
			dfs(x,src);

		
		dp2[src] *= dp[x];
		dp2[src] %=mod;
		dp[src] *= (dp2[x] + dp[x])%mod;
		dp[src] %= mod;
		}
	}
	if(g[src].size()==1 and g[src][0]==parent or g[src].size()==0)
	{
		dp[src] = 1;
		dp2[src] = 1;
	}



}

int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt.txt","r",stdin);
	// freopen("output.txt.txt","w",stdout);
	// #endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int u,v;cin>>u>>v;g[u].pb(v),g[v].pb(u);

	}
	dfs(1,-1);
	cout<<(dp[1]+dp2[1])%mod<<endl;


}

Measured memory_bytes: 14208
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
using namespace std;

int main() {
    long long a[3];
    long long temp;
    cin >> a[0] >> a[1] >> a[2];
    for(int i=0; i < 2; i++){
        for(int j=2; j>i; j--){
            if(a[j-1]>a[j]){
                temp = a[j-1];
                a[j-1] = a[j];
                a[j] = temp;
            }
        }
    }
    cout << a[0] << " " << a[1] << " "<< a[2] << endl;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1e9+7;
ll add(ll a,ll b){
    return ((a%mod)+(b%mod))%mod;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}
ll powm(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}
ll solve(ll x){
    ll ans=0;
    for(int i=1;i<=10;i++){
        ll n=x*i;
        ans+=(x%10);
    }
    return ans;
}
int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<ll>dp(3);
    for(int i=0;i<n;i++){
        vector<ll>A(3);
        vector<ll>B(3,0);
        for(int i=0;i<3;i++)cin>>A[i];
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                if(i!=j){
                    B[j]=max(B[j],dp[i]+A[j]);
                }
            }
        }
        //cout<<B[0]<<" "<<B[1]<<" "<<B[2]<<endl;
        dp=B;
    }
    cout<<max({dp[0],dp[1],dp[2]});
}

Measured memory_bytes: 256
// A C++ program to illustrate Caesar Cipher Technique 
#include <iostream> 
using namespace std; 
  
// This function receives text and shift and 
// returns the encrypted text 
string encrypt(string text, int s) 
{ 
    string result = ""; 
  
    // traverse text 
    for (int i=0;i<text.length();i++) 
    { 
        // apply transformation to each character 
        // Encrypt Uppercase letters 
        if (isupper(text[i])) 
            result += char(int(text[i]+s-65)%26 +65); 
  
    // Encrypt Lowercase letters 
    else
        result += char(int(text[i]+s-97)%26 +97); 
    } 
  
    // Return the resulting string 
    return result; 
} 
  
// Driver program to test the above function 
int main() 
{ 
    int n;
    string text;
    cin >> n;
    cin >> text; 
     
    cout << encrypt(text, n); 
    return 0; 
} 

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int h,w,n;
    cin >> h >> w >> n;
    int a[n];
    REP(i,n){
        cin >> a[i];
    }
    vector<int>b;
    REP(i,n){
        REP(j,a[i]){
            b.push_back(i+1);
        }
    }
    int answer[h][w];
    int k= 0;
    REP(i,h){
        if(i%2==0){
            REP(j,w){
                answer[i][j]=b[k];
                k++;
            }   
        }
        else{
            FORR(j,w-1,0){
                answer[i][j]=b[k];
                k++;
            }
        }
    }
    REP(i,h){
        REP(j,w){
            cout << answer[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define qrep(i, q) for(auto i : q)
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int maxn = 100005;
const int inf = 0x3f3f3f3f;

int main()
{
	//std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
	ll a;
	ld b,n;
	cin >> a >> b >> n;
	if(n >= b)
		cout << (ll)floor(a*((b-1)/b));
	else
		cout << (ll)floor(a*(n/b));
	return 0;
}


Measured memory_bytes: 3780
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,m;
  cin >> n;
  map<string,int> p;
  rep(i,n){
    string s;
    cin >> s;
    p[s]++;
  }
  cin >> m;
  rep(i,m){
    string s;
    cin >> s;
    p[s]--;
  }
  int ans = 0;
  for(auto i:p) ans = max(ans,i.second);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#define M 1010
#define N 1000000
#define LL long long
#pragma GCC optimize(2)
using namespace std;
LL n,v,s;
int main()
{
	cin>>n>>v>>s;
	if(n<=v*s) cout<<"Yes";
	else cout<<"No"; 
	return 0;
}
/*
*/


Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <utility>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >> n;
  vector<int> b(n);
  for(int i = 0;i < n;i++)cin >> b[i];

  vector<int> ans;

  for(int i = n;i >= 1;i--){
   int mx = -1;
   for(int j = 0;j < b.size();j++){
     if(b[j] >= mx && j + 1 == b[j] && b[j] <= i){
       mx = b[j];
     }
   }
   if(mx == -1){
     cout << -1 << endl;
     return 0;
   } 
   ans.push_back(mx);
   vector<int> new_b;
   for(int j = 0;j < b.size();j++){
     if(!(j+1 == mx && b[j] == mx))new_b.push_back(b[j]);
   }
   b = new_b;
  }

  reverse(ans.begin(),ans.end());

  for(int i = 0;i < n;i++)cout << ans[i] << endl;

}

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

int main(){
    int N; cin >> N;
    vector<int> A(N);
    for( int &k : A)cin >> k;

    int maxA = 0, secondA = -1, maxitr = 0;

    for( int i = 0; i < N; i++ ){
        if( maxA < A[i] ){
            secondA = maxA;
            maxA = A[i];
            maxitr = i;
        }
        else if( secondA < A[i] ){
            secondA = A[i];
        }
    }

    for( int i = 0; i < N; i++ ){
        if( maxitr == i ){
            cout << secondA << endl;
        } else {
            cout << maxA << endl;
        }
    }
}

Measured memory_bytes: 2432
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)

S = ns()
if S == 'ABC':
    print('ARC')
else:
    print('ABC')


Measured memory_bytes: 9028
#ifdef LOCAL
#  define _GLIBCXX_DEBUG
#else
#  define cerr __get_ce
#endif
#include <bits/stdc++.h>
#define ff first
#define ss second
#define szof(x) ((int)x.size())

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
int const INF = (int)1e9 + 1e3;
ll const INFL = (ll)1e18 + 1e6;
mt19937 tw(9450189);
uniform_int_distribution<ll> ll_distr;
ll rnd(ll a, ll b) { return ll_distr(tw) % (b - a + 1) + a; }


void solve() {
	int n;
	cin >> n;
	vector<vector<int>> graph(n);
	for (int i = 0; i < n - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	// set<int> st;
	// st.insert(0);
	// vector<int> sz(n);
	// vector<bool> used(n);
	// used[0] = true;
	// int cnt = 0;
	// for (int i = 0; i < n; ++i) {
	// 	while (szof(st) && *st.begin() <= i) {
	// 		cnt++;
	// 		int v = *st.begin();
	// 		st.erase(st.begin());
	// 		for (int to : graph[v]) {
	// 			if (!used[to]) {
	// 				used[to] = true;
	// 				st.insert(to);
	// 			}
	// 		}
	// 	}
	// 	sz[i] = cnt;
	// }

	function<int(int, int, int)> dfs2 = [&](int v, int p, int largest) {
		if (v > largest) {
			return 0;
		}
		int ret = 1;
		for (int to : graph[v]) {
			if (to != p) {
				ret += dfs2(to, v, largest);
			}
		}
		return ret;
	};

	vector<int> ans(n);
	function<void(int, int, int, int)> dfs = [&](int v, int p, int largest, int sz) {
		// cerr << v + 1 << " " << largest + 1 << " " << sz << endl;
		if (largest < v) {
			vector<int> add;
			int sum = 0;
			for (int to : graph[v]) {
				if (to != p) {
					add.push_back(dfs2(to, v, largest));
					sum += add.back();
				}
			}
			// cerr << "sum: " << v + 1 << " " << sum << endl;
			// for (int num : add) {
			// 	cerr << num << " ";
			// }
			// cerr << endl;
			largest = v;
			ans[v] = sz + 1 + sum;
			int cnt = 0;
			for (int to : graph[v]) {
				if (to != p) {
					dfs(to, v, largest, sz + sum - add[cnt] + dfs2(to, v, v) + 1);
					++cnt;
				}
			}
		} else {
			ans[v] = sz;
			for (int to : graph[v]) {
				if (to != p) {
					dfs(to, v, largest, sz);
				}
			}
		}
	};

	dfs(0, 0, -1, 0);
	for (int i = 1; i < n; ++i) {
		cout << ans[i] - 1 << " ";
	}
	cout << "\n";
}


int main() {
#ifdef LOCAL
	auto start_time = clock();
	cerr << setprecision(3) << fixed;
#endif
	cout << setprecision(15) << fixed;
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int test_count = 1;
	// cin >> test_count;
	for (int test = 1; test <= test_count; ++test) {
		solve();
	}
	
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}


Measured memory_bytes: 50816
class Factorial():
    def __init__(self,n,mod):
        self.mod = mod
        self.factorial = [0 for _ in range(n+1)]
        self.inv = [0 for _ in range(n+1)]
        self.factorial[0] = 1
        self.inv[0] = 1
        for i in range(n):
            self.factorial[i+1] = self.factorial[i]*(i+1)%mod
        self.inv[n] = pow(self.factorial[n],mod-2,mod)
        for i in range(n)[::-1]:
            self.inv[i] = self.inv[i+1]*(i+1)%mod

    def comb(self,m,k):
        return self.factorial[m]*self.inv[k]*self.inv[m-k]%self.mod

def factorization(n):
    if n == 1: return [1]
    res = []
    x = n
    y = 2
    while y*y <= x:
        while x % y == 0:
            res.append(y)
            x //= y
        y += 1
    if x > 1: res.append(x)
    return res

from collections import Counter

MOD = 1000000007
N,M = map(int,input().split())

ans = 1

if M > 1:

    F = factorization(M)
    C = Counter(F)

    fact = Factorial(200000,MOD)

    for v in C.values():
        ans *= fact.comb(N+v-1,v)
        ans %= MOD

print(ans)

Measured memory_bytes: 19316
N = int(input())
A = list(map(int, input().split()))

s = [0]*(N+1)
for i in range(N):
    s[i+1] = s[i] + A[i]

ans = float('inf')
for i in range(1,N):
    ans = min(abs(s[N]-s[i]-s[i]),ans)
print(ans)

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

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

    vector<long long> mods(2019, 0);
    mods[0]++;
    int num = 0;
    int digit = 1;
    
    for(auto i = s.rbegin(); i != s.rend(); i++){
        int tmp = *i - '0';
        num = (num  + tmp * digit) % 2019;
        digit = digit * 10 % 2019;
        mods[num]++;
    }

    long long ans = 0;
    for(auto x : mods){
        ans += x * (x - 1) / 2;
    }

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

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

#define MAX_N 2000000
int prime[MAX_N];



int main(){
	prime[1] = 1;
	prime[2] = 0;
	prime[3] = 0;
	for(int i = 2; i<=MAX_N;i++){
		if(prime[i] == 0)
			for(int j=2*i;j<=MAX_N;j=j+i)
				prime[j] = 1;
	}
	
	int n;
	int num=0;
	while(true){
		cin >> n;
		if (cin.eof() ==1)
			break;	
		for(int k = 1;k<=n; k++){
			if(prime[k]==0)
				num++;
		}
		cout << num << endl;
		num = 0;
	}
	return 0;
}

Measured memory_bytes: 8680
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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 Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    int N;
    cin >> N;
    vec<pair<int, int> > A(N);
    REP(i, N){
        int Ai;
        cin >> Ai;
        A[i] = make_pair(Ai, i+1);
    }
    sort(ALL(A));
    REP(i, N){
        if(i!=0){
            cout << " ";
        }
        cout << A[i].se;
    }
    cout << el;
}



Measured memory_bytes: 1664
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int k, n;
	cin >> k >> n;
	VI a(n);
	REP(i, n) { cin >> a[i]; }
	int max = 0;
	REP(i, n - 1) { chmax(max, a[i + 1] - a[i]); }
	chmax(max, a[0] + (k - a[n - 1]));
	cout << k - max << endl;
	return 0;
}


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

int a[100000+1], b[100000+1], s[100000+1];

int main()
{
	int i, j;
	
	for (i=2; i<=100000; i++) a[i]=1;
	
	for (i=2; i<=int(sqrt(100000)); i++)
	{
	  if (a[i]==1)
	    for (j=i+i; j<=100000; j+=i) a[j] = 0;
    }
    
    b[1]=0; b[2]=0;
    for (i=3; i<=100000; i++)
       if (a[i]==1&&a[(i+1)/2]==1) b[i]=1;
    
    s[1]=0; s[2]=0;
    for (i=3; i<=100000; i++)
       s[i]=s[i-1]+b[i];
    
    int q, l, r;
    cin >> q;
    
    for (i=1; i<=q; i++)
	{
    	cin >> l >> r;
    	cout << s[r] - s[l-1] << endl;
    }
    return 0;
}

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

int main(){
    int N,sum=0;
    cin>>N;
    int a[10000];
    for(int i=0;i<N;i++){
        cin>>a[i];
        int cnt=0;
        while(a[i]%2==0){
            cnt++;
            a[i]/=2;
        }
        sum+=cnt;
    }

    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

const int INF = 5000*100*3;
const int max_x = 102;
const int max_y = 12000;

int dp[max_x+10][max_y+10];

void solve(int n){
    // init
    for(int j=0;j<max_x+10;j++) for(int k=0;k<max_y+10;k++) dp[j][k] = INF;
    vector<int> p(n);
    for(int i=0;i<n;i++) cin >> p[i];

    dp[0][0] = 0;
    for(int i=0;i<n;i++){
        const int &pi = p[i];
        for(int x=n;x>=0;x--){
            for(int y=max_y;y>=0;y--){
                if(pi%1000<=500){
                    if(pi%1000>0 && y-(500-pi%1000)>=0 && x-1>=0)
                        dp[x][y] = min(dp[x][y],dp[x-1][y-(500-pi%1000)]+pi);
                    if(y+(pi%1000+500)<=max_y && x-1>=0)
                        dp[x][y] = min(dp[x][y],dp[x-1][y+(pi%1000+500)]+pi);
                }else{
                    if(y+(pi%1000-500) <= max_y && x-1>=0) dp[x][y] = min(dp[x][y], dp[x-1][y + (pi%1000-500)] + pi);
                    if(y-(1000-pi%1000)>=0) dp[x][y] = min(dp[x][y], dp[x][y-(1000-pi%1000)] + pi);
                }
            }
        }
    }

    for(int i=100;i>=0;i--){
        int mn = INF;
        for(int j=0;j<=max_y;j++){
            if(dp[i][j] < INF){
                mn = min(mn,dp[i][j]);
            }
        }
        if(mn != INF){
            cout << i << " " << mn << endl;
            return;
        }
    }
}

int main(){
    while(1){
        int n; cin >> n;
        if(n==0) break;
        solve(n);
    }
}



Measured memory_bytes: 8332
#include <bits/stdc++.h>
using namespace std;
# define M_PI 3.14159265358979323846
using ll = long long int;
const int MOD = 1e9 + 7;
int main()
{
    int n;
    cin>>n;
    unordered_map<int,int> mp;
    for(int i=0;i<n-1;i++)
    {
        int temp;
        cin>>temp;
        if(mp[temp]==0)
        {
            mp[temp]=1;
        }
        else
        {
            mp[temp]+=1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        cout<<mp[i]<<endl;
    }
}

Measured memory_bytes: 11444
#include <bits/stdc++.h>
#ifdef __mr__
    #include "prettyprint.hpp"
#else
    #define endl                    '\n'
#endif
#define len(x)                      (uint)(x).size()
#define int                         int32_t
#define uint                        uint32_t
#define ulong                       uint64_t
#define long                        int64_t
#define maxof(x)                    numeric_limits<x>::max()
#define minof(x)                    numeric_limits<x>::min()
#define uset                        unordered_set
#define umap                        unordered_map
using namespace std;
const uint mod7 = uint(1000000007);
const uint mod9 = uint(1000000009);
const int inf31 = maxof(int);
const uint inf32 = maxof(uint);
const long inf63 = maxof(long);
const ulong inf64 = maxof(ulong);


int main(int argc, char const *argv[]) {
    #ifndef __mr__
        ios::sync_with_stdio(0);cin.tie(0);
    #endif
    uint n, k;
    cin >> n >> k;
    vector<long> arr(n);
    for (uint i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    if (k == n) {
        if (accumulate(arr.begin(), arr.end(), long(0)) > 0)
            cout << accumulate(arr.begin(), arr.end(), long(0)) << endl;
        else
            cout << 0 << endl;
        return 0;
    }
    long allpos = 0;
    for (uint i = 0; i < n; ++i) {
        if (arr[i] >= 0)
            allpos += arr[i];
    }
    long knegi = 0;
    long msum = 0;
    for (uint i = 0; i < n; ++i) {
        if (i < k) {
            if (arr[i] < 0)
                knegi += arr[i];
            continue;
        } else if (i == k) {
            msum = allpos + knegi;
        }
        if (arr[i - k] < 0)
            knegi -= arr[i - k];
        if (arr[i] < 0)
            knegi += arr[i];
        msum = max(msum, allpos + knegi);
    }
    long kposi = 0;
    for (uint i = 0; i < n; ++i) {
        if (i < k) {
            if (arr[i] > 0)
                kposi += arr[i];
            continue;
        } else if (i == k) {
            msum = max(msum, allpos - kposi);
        }
        if (arr[i - k] > 0)
            kposi -= arr[i - k];
        if (arr[i] > 0)
            kposi += arr[i];
        msum = max(msum, allpos - kposi);
    }
    cout << msum << endl;
    return 0;
}


Measured memory_bytes: 1024
fn read<T: std::str::FromStr>() -> T {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  read::<String>().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
  (0..n).map(|_| read_vec()).collect()
}

fn main() {
  let n: u64 = read();
  let s: String = read();

  let mut ans = 0;
  let mut memory_char = ' ';
  for i in s.chars() {
    if i != memory_char {
      ans += 1;
      memory_char = i;
    }
  }
  println!("{}", ans);
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
typedef long long ll;
typedef long double ld;

int main() {
	int b = 0; ll ans = 0;
	char c[200001];
	scanf("%s", c);
	rep(i, strlen(c)) {
		if (c[i] == 'B')b++;
		else ans += b;
	}
	printf("%lld", ans);
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define ENDL "\n"
#define PRINT(x) cout << (x) << ENDL

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
inline void out(int n) {printf("%d\n", n);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


int N;
int d[100000];

signed main(){
    cin >> N;
    REP(i, N) cin >> d[i];
    sort(d, d + N);
    PRINT(d[N / 2] - d[N / 2 - 1]);
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <stdio.h>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	vector <long long> v(3);
	cin>>v[0]>>v[1]>>v[2];
	long long k;
	cin>>k;
	sort(v.begin(),v.end());
	while(k>0){
		v[2]=v[2]*2;
		
		k--;
	}
	cout<<v[0]+v[1]+v[2]<<endl;
	return 0;
	
}


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

int main(){
    int n; cin >> n;
    int s = 0;
    vector<int> a(n,0);
    rep(i,n){ int x; cin >> x; a[x]++; s = max(s, x); }

    bool check = 1;
    rep(i,s+1){
        if(i < (s+1)/2){ if(a[i] > 0) check = 0; }
        else if(i == (s+1)/2 && s%2){ if(a[i] != 2) check = 0; }
        else if(i == (s+1)/2){ if(a[i] != 1) check = 0; }
        else { if(a[i] < 2) check = 0; }
    }
    cout << (check ? "Possible" : "Impossible") << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>

using namespace std;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

signed main()
{
	omajinai;

	int N, M, Q; cin >> N >> M >> Q;

	vi nxt(N), prv(N);

	vector<bool> answer(N);

	rep(i, N) {
		nxt[i] = i + 1 >= N ? 0 : i + 1;
		prv[i] = i - 1 < 0 ? N - 1 : i - 1;
	}

	int now_pos = 0;

	rep(i, M) {
		int a; cin >> a;

		if (a % 2 == 0) {
			rep(_, a) now_pos = nxt[now_pos];
		} else {
			rep(_, a) now_pos = prv[now_pos];
		}

		prv[nxt[now_pos]] = prv[now_pos];
		nxt[prv[now_pos]] = nxt[now_pos];

		answer[now_pos] = true;

		now_pos = nxt[now_pos];
	}

	rep(i, Q) {
		int q; cin >> q;
		cout << !answer[q] << endl;
	}
}

Measured memory_bytes: 2796
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    int c = a + b;
    if(c % 2 == 1)
    {
        cout << (c+1) / 2 << endl;
    }
    else cout << c / 2 << endl;
}
  


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        vector<int>V;
        for(int i=0;i<n;i++){
            int sum=0;
            for(int j=0;j<5;j++){
                int a;
                cin>>a;
                sum+=a;
            }
            V.push_back(sum);
        }
        sort(V.begin(),V.end());
        cout<<V[n-1]<<" "<<V[0]<<endl;
    }
}

Measured memory_bytes: 1220
if __name__ == '__main__':
	N = int(input())
	K = int(input())
	X = list(map(int, input().split()))
	ans = 0
	for x in X:
		if x <= (K/2):
			ans = ans + x*2
		else :
			ans = ans + (K-x)*2
	print(ans)

Measured memory_bytes: 3060
def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))
    vis = [0 for i in range(n)]
    vis[0] = 1
    fst = [1]
    st = a[0]-1
    while True:
        if vis[st] == 0:
            vis[st] = 1
            fst.append(st+1)
            st = a[st]-1
        else:
            st = fst.index(st+1)
            loop = fst[st:]
            break
    if k < len(fst):
        print(fst[k])
    else:
        k = k - len(fst) + 1
        k = k%len(loop)
        print(loop[k-1])
    

if __name__ == "__main__":
    main()


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

using namespace std;
#define BUF (10005)
#define ll long long 

int n, m;
int A[10];
int dp[BUF];
int num[10] = {0,2,5,5,4,5,6,3,7,6};
vector<int> v;
int main(void){
	cin >> n >> m;
	for(int i=0;i<m;i++) cin >> A[i];
	sort(A, A+m);
	//for(auto x : A) cout << x;

	for(int i=0;i<=n;i++) dp[i] = -1;
	dp[0] = 0;

	for(int i=1;i<=n;i++){
		int tmp=-1;
		for(int j=0;j<m;j++){
			int k = i-num[A[j]];
			if(k>=0 && dp[k]>=0){
				tmp = max(tmp, dp[k]+1);
			} 
		}
		dp[i] = tmp;
	}
	
	int i = n;
	while(1){
		if(i<=0) break;
		for(int j=m-1;j>=0;j--){
			int tmp = i-num[A[j]];
			//cout << dp[tmp] << " "; 
			if(tmp>=0 && (dp[tmp]==(dp[i]-1)) ){
				//cout << "pushback\r\n";
				v.push_back(A[j]);
				i=tmp;
				break;
			}
		}
	}

	for(auto x : v) cout << x;
	cout << endl;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


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


ll MOD = 1000000007;

struct node {
	vector<int> link;
	vector<ll> a;
	vector<ll> b;
	vector<ll> s;
};

ll inf = 1e18;
ll N, M, S;
ll amax;
vector<node> nod;
int main() {
	cin >> N >> M >> S;
	nod.resize(N);
	amax = 0;
	rep(i, M) {
		ll u, v, a, b;
		cin >> u >> v >> a >> b;
		u--; v--;
		nod[u].link.emplace_back(v);
		nod[v].link.emplace_back(u);
		nod[u].a.push_back(a);
		nod[u].b.push_back(b);
		nod[v].a.push_back(a);
		nod[v].b.push_back(b);
		amax = max(amax, a);
	}
	rep(i, N) {
		ll c, d;
		cin >> c >> d;
		nod[i].link.emplace_back(i);
		nod[i].a.push_back(-c);
		nod[i].b.push_back(d);
		nod[i].s.resize(amax * (N - 1) + 1);
		rep(j, amax * (N - 1) + 1) nod[i].s[j] = inf;
	}
	queue<ll> nq;
    queue<ll> sq;
	ll st = min(S, amax * (N - 1));
	nod[0].s[st] = 0;
	nq.push(0);
	sq.push(st);
	while (!nq.empty()) {
        ll n = nq.front();
        ll s = sq.front();
        nq.pop();
        sq.pop();
        rep(i, nod[n].link.size()) {
            if (s - nod[n].a[i] < 0) continue;
			ll ns = min(s - nod[n].a[i], amax * (N - 1));
            ll nt = nod[n].s[s] + nod[n].b[i];
            ll nn = nod[n].link[i];
            if (nod[nn].s[ns] > nt) {
                nod[nn].s[ns] = nt;
                nq.push(nn);
                sq.push(ns);
            }
        }
	}
	repi(i,1, N) {
		ll res = inf;
		rep(j, nod[i].s.size()) res = min(res, nod[i].s[j]);
		cout << res << endl;
	}
	return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int N, M, Q; 
vector<int> a, b, c, d;
int ans = 0;
void dfs(vector<int> e) {
  if(e.size() == N) {
    int tmp = 0;
    REP(i, Q) {
      if(e[b[i] - 1] - e[a[i] - 1] == c[i]) {
        tmp += d[i];
      }
      if(ans < tmp) ans = tmp;
    }
    return;
  }

  int bef = 0;
  if(e.size() != 0) bef = e[e.size() - 1];
  for(int i = 1; i <= M; ++i) {
    if(bef > i) continue;
    e.push_back(i);
    dfs(e);
    e.pop_back();
  }
}

int main() {
  cin >> N >> M >> Q;
  a.resize(Q); b.resize(Q); c.resize(Q); d.resize(Q);
  REP(i, Q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  vector<int> f;
  dfs(f);
  cout << ans << endl;
}


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

 
int main()
{ int n;
cin>>n;
int dp[n],h[n];
dp[0]=0;
  for( int i=0;i<n;i++)
    { cin>>h[i];}
     dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
    { dp[i] = min( dp[i-1]+ abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2])); }
       cout<<dp[n-1];
      return 0; }

Measured memory_bytes: 1024
<?php

fscanf(STDIN, '%d', $N);
fscanf(STDIN, '%s', $S);
fscanf(STDIN, '%d', $K);

$l = $S[$K-1];

$array = str_split($S);

for ($i=0; $i < $N; $i++) { 
    if ( $array[$i] != $l ) {
        $array[$i] = "*";
    }
}

echo implode("", $array);


Measured memory_bytes: 4856
import re

def check1(s):
    if s[0] == "A":
        return 1
    else:
        return 0

def check2(s):
	temp = s.lstrip(s[0]+s[1]).rstrip(s[-1]) 
	if temp.count("C") == 1:
		return 1
	else:
		return 0

def check3(s):
	if re.sub("[AC]","",s).islower() == True:
		return 1
	else:
		return 0

s = str(input())

if check1(s) + check2(s) + check3(s) == 3:
	print("AC")
else:
	print("WA")

Measured memory_bytes: 3188
#include <stdio.h>
int main(void) {
    int i,n;
    scanf("%d", &n);
    for (i=3;i<=n;i++){
        if (i%3==0){
        printf(" %d",i);
    }else{
        int temp=i;
        do{
            if(temp % 10 == 3){
                printf(" %d", i);
                break;
                }
            temp /= 10;
        }while(temp > 0);
    }
  }
  printf("\n");
  return 0;
}

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

int n;
int c;
string p[5];

int rec(int id,int st,int pos){
  if(id == 10){
    return pos + n;
  }
 
  int res = 10000;
  for(int i=1;i<n;i++){
    if(pos+i>=res)return res;
    if(!((st>>i)&1)){
      int nxt = (st >> i) | c;
      res = min(res,rec(id+1,nxt,pos+i));
    }
  }
  return res;
}

int main(){
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  while(cin >> n,n){
    for(int i=0;i<5;i++)cin >> p[i];

    c = 0;
    for(int i=1;i<n;i++){
      bool f = true;
      for(int j=0;j<5;j++){
	for(int k=0;k<n;k++){
	  if(k+i>=n)break;
	  if(p[j][k] == p[j][k+i] && p[j][k] == 'X')f = false;
	}
      }
      if(!f)c |= 1<<i;
    }
    cout << rec(1,c,0) << endl;
  }
}
      

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
//#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvector(name,typ,m,n)vector<vector<typ> > name(m,vector<typ> (n))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
ll ceil(ll a,ll b){
    return ((a+b-1)/b);
}
const int INF = 1000000000;
const ll INF64 = 9223372036854775807ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//mapは、if関数などで覗いただけで構成されるので注意しよう！
int main(){
    string d,s,dd;
    std::cin >> d>>s>>dd;
    std::cout << 'A'<<s[0]<<'C' << std::endl;
}

Measured memory_bytes: 256
$debug=0
def aux(rc)
  rc.each{|r|
    r.push r.sum
  }
  cl=rc[0].length
  rl=rc.length

  cs=[]
  cl.times{|j|
    puts "j: #{j}" if $debug&2==2
    s=0
    rl.times{|i|
      s+=rc[i][j]
    }
    puts "s: #{s}" if $debug&2==2
    cs << s
    puts "cs: #{cs.to_s}" if $debug&2==2
  }
  rc << cs

end

def main
  rc=[]
  if $debug&1==1
    #fh=File.new("ITP1_7_C1.txt", "r")
    fh=File.new("ITP1_7_C2.txt", "r")
  else
    fh=STDIN
  end
  r,c=fh.gets.split.map(&:to_i)
  r.times {
    rc << fh.gets.chomp.split.map(&:to_i)
  }

  rc1=aux(rc)

  s = rc1.map{|r|
    r.map(&:to_s).join(" ")
  }
  s.each {|ln|
    puts ln
  }
end

if $0 == __FILE__ then
  main
end


Measured memory_bytes: 7092
#include <stdio.h>
#include <stdlib.h>
int cmp(const void *a,const void *b)
{
  if(*(int*)a > *(int*)b)
    return 1;
  else if(*(int*)a < *(int*)b)
    return -1;
  else
    return 0;
}

int main(void){
  long int n,k,h[200005],sum=0;
  scanf("%ld %ld",&n,&k);
  for(int i=0;i<=n-1;i++){
    scanf("%ld",&h[i]);
  }
  qsort(h,n,sizeof(long int),cmp);
  for(int i=0;i<n-k;i++){
    sum+=h[i];
  }
  printf("%ld\n",sum);

  return 0;
}

Measured memory_bytes: 4640
#include <cassert>
#include <vector>
#include <iostream>
using namespace std;
int main(){
  int L;
  cin >> L;
  int t = L, l = 0;
  while(t > 0){
    ++l;
    t /= 2;
  }
  long long N = l, M = 2*l - 2;
  vector<int> U, V, C;
  for(int i = 0; i < l-1; ++i){
    U.push_back(i+1);
    V.push_back(i+2);
    C.push_back(0);
    if(i < l-1){
      U.push_back(i+1);
      V.push_back(i+2);
      C.push_back((1<<i));
    }
  }
  for(int i = 0; i < l; ++i){
    if(((L>>i) & 1) && ((L-(1<<i)) > 0)){
      M += 1;
      U.push_back(i+1);
      V.push_back(l);
      C.push_back(L-(1<<i));
      L -= (1<<i);
    }
  }
  assert(N <= 20);
  cout << N << " " << M << endl;
  for(int i = 0; i < M; ++i) cout << U[i] << " " << V[i] << " " << C[i] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

using namespace std;

#define LL long long

int a,b;

int main() {
    scanf("%d%d",&a,&b);
    if(a > 9 || a < 1) {
        puts("-1");
        return 0;
    }
    if(b > 9 || b < 1) {
        puts("-1");
        return 0;
    }
    printf("%d",a * b);
    //system("pasue");
    return 0;
}

Measured memory_bytes: 256
def check(l):

	for j in range(0,10):
		if(j==3 or j== 5 or j==7):
			if(str(j) not in l):return(0)
		else:
			if(str(j) in l):return(0)
	else:
		#print(i)
		return(1)


n=int(input())
c=0
i=357
while(i < n+1):
	l=list(str(i))
	for j in range(len(l)):
		x=int(l[j])
		if(x !=3 and x!=5 and x!=7):
			#print(x,i,j)
			if(x<3):
				dx=3-x
			elif(x<5):
				dx=5-x
			elif(x<7):
				dx=7-x
			else:
				dx=10-x
			i+=dx*10**(len(l)-j-1)-1
			break
	l=list(str(i))
	#print(i)
	c+=check(l)
	i+=1
	
print(c)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,mx,cnt;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int a;
        scanf("%d",&a);
        if(a>=mx){
            cnt++;
            mx=a;
        }
    }
    printf("%d",cnt);
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

const int mod = 1000000007;

ll fact(ll x) {
  ll ret = 1;
  for(int i = 2; i <= x; i++) {
    ret *= i;
    ret %= mod;
  }
  return ret;
}

int main() {
  ll N, M;
  cin >> N >> M;
  if (N > M) swap(N, M);
  if (M - N > 1) {
    cout << 0 << endl;
    return 0;
  }
  if (M == N) {
    cout << 2 * fact(M) * fact(M) % mod << endl;
  } else {
    cout << fact(M) * fact(N) % mod << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
class UnionFind {
    public:
        //親の番号を格納する。親だった場合は-(その集合のサイズ)
         vector<int> Parent;

        //作るときはParentの値を全て−1にする
        //こうすると全てバラバラになる
        UnionFind(int N){
            Parent = vector<int>(N+1, -1);
        }

        //Aがどのグループに属しているか調べる
        int root(int A) {
            if(Parent[A] < 0) return A;
            return Parent[A] = root(Parent[A]);
        }

        //自分のいるグループの頂点数を調べる
        int size(int A){
            return -Parent[root(A)];//親をとってきたい
        }

        //AとBをくっつける
        bool connect(int A, int B){
            //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
            A=root(A);
            B=root(B);
            if(A==B){
                return false;
            }

            if(size(A) < size(B)) swap(A,B);

            Parent[A] += Parent[B];
            Parent[B]=A;
            return true;
        }
};
int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(m),b(m);
    rp(i,m){
        cin >> a.at(i) >> b.at(i);
        //a.at(i)--;
        //b.at(i)--;
    }
    UnionFind uni(n);
    vector<ll> ans(m,0ll); 
    ans.at(m-1)=(ll) n*(n-1)/2;
    for(int i=m-1; i>=1; i--){
        ans[i-1]=ans[i];
        int as=uni.size(a[i]),bs=uni.size(b[i]);
        if(uni.connect(a[i],b[i])){
            //cout << "here" << endl;
            ans[i-1] -= (ll)as*bs;
        }
    }
    rp(i,m) cout << ans[i] << endl;
    return 0;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, A, B;
  cin >> N >> A >> B;
  ll ans = 0;
  ll r = A + B * (N - 1);
  ll l = B + A * (N - 1);
  ans = r - l + 1;
  cout << max(0LL, ans) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));//p^num
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


void solve(){
    ll N;
    cin >> N;
    auto res = prime_factorize(N);
    ll ans = 0;
    for(auto x : res){
        int cur = 1;
        while(x.second > 0 && x.second >= cur){
            x.second -= cur;
            ans++;
            cur++;
        }
    }
    cout << ans << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % moder;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), moder - 2, moder) % moder * mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/


P dat[1000000];
int size_ = 1;
void init(int x) {
	while (size_ < x)size_ *= 2;
	rep(i, 2 * size_ - 1)dat[i] = { 0,inf };
}
void eval(int k, int l, int r) {
	if (dat[k].second != inf) {
		dat[k].first = dat[k].second;
		if (r - l > 1) {
			dat[k * 2 + 1].second = dat[k].second / 2;
			dat[k * 2 + 2].second = dat[k].second / 2;
		}
		dat[k].second = inf;
	}
}
void update(int a, int b, int k, int x, int l, int r) {
	eval(k, l, r);
	if (r <= a || b <= l)return;
	if (a <= l && r <= b) {
		dat[k].second = x * (r - l);
		eval(k, l, r);
	}
	else {
		update(a, b, k * 2 + 1, x, l, (l + r) / 2);
		update(a, b, k * 2 + 2, x, (l + r) / 2, r);
		dat[k].first = dat[k * 2 + 1].first + dat[k * 2 + 2].first;
	}
}
int query(int a, int b, int k, int l, int r) {
	eval(k, l, r);
	if (r <= a || b <= l)return 0;
	if (a <= l && r <= b) {
		return dat[k].first;
	}
	int lv = query(a, b, k * 2 + 1, l, (l + r) / 2);
	int rv = query(a, b, k * 2 + 2, (l + r) / 2, r);
	return lv + rv;
}
signed main() {
	int n, q;
	cin >> n >> q;
	init(n);
	rep(i, q) {
		int a; cin >> a;
		if (!a) {
			int s, t, x; cin >> s >> t >> x;
			update(s, t + 1, 0, x, 0, size_);
		}
		else {
			int s, t; cin >> s >> t;
			cout << query(s, t + 1, 0, 0, size_) << endl;
		}
	}
}


Measured memory_bytes: 7216