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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

struct SegmentTree {
private:
    int n;
    vector<ll> node;
public:
    SegmentTree(vector<ll> v) {
        int sz = v.size();
        n = 1;
        while (n < sz) n *= 2;
        node.resize(2*n-1,0);
        for (int i = 0;i < sz;++i) node[i+n-1] = v[i];
        for (int i = n-2;i >= 0;--i) node[i] = max(node[2*i+1],node[2*i+2]);
    }
    void update(int x,ll val) {
        x += (n-1);
        node[x] = val;
        while (x > 0) {
            x = (x-1)/2;
            node[x] = max(node[2*x+1],node[2*x+2]);
        }
    }

    ll getmax(int a,int b,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return 0;
        if (a <= l && r <= b) return node[k];
        ll vl = getmax(a,b,2*k+1,l,(l+r)/2);
        ll vr = getmax(a,b,2*k+2,(l+r)/2,r);
        return max(vl,vr);
    }
};

int main() {
    int n;
    cin >> n;
    vector<int> h(n),a(n);
    SegmentTree seg(vector<ll>(n+10,0));
    for (int i = 0;i < n;++i) cin >> h[i];
    for (int i = 0;i < n;++i) cin >> a[i];
    for (int i = 0;i < n;++i) {
        ll mx = seg.getmax(0,h[i]);
        seg.update(h[i],mx+a[i]);
    }
    cout << seg.getmax(0,n+10) << endl;
    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int N,A,B,C;
LL dfs(VL &l, int v, int a, int b, int c){
	if (v == N) {
		if (a == 0 or b == 0 or c == 0) {
			return INT32_MAX;
		}
		else {
			return abs(A-a) + abs(B-b) + abs(C-c) - 30;
		}
	}
	return min(dfs(l,v+1,a,b,c), min(dfs(l,v+1,a+l[v],b,c) + 10, min(dfs(l,v+1,a,b+l[v],c) + 10, dfs(l,v+1,a,b,c+l[v]) + 10)));
}

int main(int argc, char const* argv[])
{
	cin >> N >> A >> B >> C;
	VL l(N);
	for (int i = 0; i < N; i++) {
		cin >> l[i];
	}

	cout << dfs(l,0,0,0,0) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int main()
{
    int N, X;
    cin >> N >> X;
    vint x(N);
    int Min = 1e9;
    int gcd = 0;
    rep(i, N)
    {
        cin >> x[i];
        //        Min = min(Min, x[i]);
        x[i] -= X;
        gcd = __gcd(gcd, x[i]);
    }

    cout << abs(gcd);
    return 0;
}

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

int main(void){
    int n;
    long long dv = 1;
    long long max = 1;
    bool flag = 0;
    for(int i = 0; i < 18; i++){
	max *= 10;
    }
    std::cin >> n;
    std::vector<long long> a(n);

    for(int i = 0; i < n; i++){
	std::cin >> a[i];
    }

    for(int i = 0; i < n; i++){
	if(a[i] == 0){
	    std::cout << 0 << std::endl;
	    flag = !flag;
	    break;
	}
    }

    bool flag2 = 0;

    if(!flag){
	for(int i = 0; i < n; i++){
    	    if(dv <= max / a[i] + 1&& dv * a[i] <= max){
    	        dv *= a[i];
    	    }
    	    else{
    	        std::cout << -1 << std::endl;
		flag2 = 1;
		break;
    	    }
    	}
	if(!flag2) std::cout << dv << std::endl;
    }
    return 0;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
	using namespace std;
	#define mod 1000000007
	#define fi first
	#define se second
	#define mp make_pair
	#define pb push_back
	#define ps push
	#define pll pair<long,long>
	typedef long long ll;
	#define PI 3.14159265
	
	
	const ll INF=(ll)1e16;
	
	
	int main()
	{
		ios::sync_with_stdio(0); 
		cin.tie(0); 
		cout.tie(0);
		
		ll n,k;
		cin>>n>>k;
		if(n==1)
		{
			if(k==0)
				{
					cout<<"0 0 1 1";
				}
			else
				{
					cout<<-1;
				}
				exit(0);
			
		}
		else if(k>=(1<<n))
		{
			cout<<-1;
			exit(0);
		
		}
		cout<<k<<" ";
		vector<ll> v;
		for(ll i=0;i<(1<<n);i++)
		{
			if(i==k)
				continue;
			cout<<i<<" ";
			v.pb(i);
		}
		cout<<k<<" ";
		reverse(v.begin(),v.end());
		for(auto i:v)
		{
			cout<<i<<" ";
		}
	}		


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

int main()
{
	double r;
	double PI = 3.14159265358979;
	cin >> r;

	double S = PI*r*r;
	double l = 2 * PI*r;

	printf("%lf %lf", S, l);

	return 0;
}

Measured memory_bytes: 3204
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  if (n == 1) {
    cout << 1 << '\n' << "1" << '\n';
  } else if (n == 2) {
    cout << 2 << '\n' << "1" << '\n' << "00" << '\n';
  } else {
    cout << n - 1 << '\n';
    for (int i = 2; i <= n; i++) {
      for (int j = 1; j <= i; j++) {
        if (j == 1 || j == i) cout << "0";
        else cout << "1";
      }
      cout << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
int keta(long n){
  if(n<10)return 1;
  else if(n<100)return 2;
  else if(n<1000)return 3;
  else if(n<10000)return 4;
  else if(n<100000)return 5;
  else if(n<1000000)return 6;
  else if(n<10000000)return 7;
  else if(n<100000000)return 8;
  else if(n<1000000000)return 9;
  else return 10;
}


int main(){
  long long n;
  cin >> n;
  long sqn = (long)sqrt((double)n) + 100;
  long i;
  int min = 12;
  for(i=1;i<=sqn;i++){
    if(n%i==0){
      if(min>max(keta(i),keta(n/i))) min = max(keta(i),keta(n/i));
    }
  }
  cout << min;
} 

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    if( N%9==0 && N/9<=9 ){
        std::cout << "Yes" << std::endl;
    }
    else if( N%8==0 && N/8<=9 ){
        std::cout << "Yes" << std::endl;
    }
    else if( N%7==0 && N/7<=9 ){
        std::cout << "Yes" << std::endl;
    }
    else if( N%6==0 && N/6<=9){
        std::cout << "Yes" << std::endl;
    }
    else if( N%5==0 && N/5<=9 ){
        std::cout << "Yes" << std::endl;
    }
    else if( N%4==0 && N/4<=9 ){
        std::cout << "Yes" << std::endl;
    }
    else if( N%3==0 && N/3<=9 ){
        std::cout << "Yes" << std::endl;
    }
    else if( N%2==0 && N/2<=9 ){
        std::cout << "Yes" << std::endl;
    }
    else if( N%1==0 && N/1<=9 ){
        std::cout << "Yes" << std::endl;
    }
    else{
        std::cout << "No" << std::endl;
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
int edge[max_n];
vector<vector<pii> > v;
void solve(int pre, int now, int prec){
  int col=1;
  for(auto j : v[now]){
    if(j.fi==pre) continue;
    if(prec==col) col++;
    edge[j.se] = col;
    solve(now, j.fi, col);
    col++;
  }
}
int main(){
  int n;  cin>>n;
  v.resize(n);
  vector<int> k(n-1);
  rep(i,0,n-1){
    int x,y;  cin>>x>>y;
    --x;  --y;
    v[x].pb(mp(y,i));
    v[y].pb(mp(x,i));
  }
  int st=-1;
  int ma=-1;
  rep(i,0,n){
    int st=v[i].size();
    chmax(ma, st);
  }
  cout << ma << endl;
  solve(-1, 0, -1);
  rep(i,0,n-1){
    cout << edge[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 8576
#include<stdio.h>

int P(int x){
  int i;
  if ( x < 2 ) return 0;
  else if ( x == 2 ) return 1;
  if ( x % 2 == 0 ) return 0;
  for ( i = 3; i*i <= x; i+=2 ){
    if ( x % i == 0 ) return 0;
  }
  return 1;
}

int main(){
  int n, x, i;
  int cnt = 0;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%d", &x);
    if ( P(x) ) cnt++;
  }
  printf("%d\n", cnt);
  
  return 0;
}



Measured memory_bytes: 2056
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


bool solve(){
	string str;
	cin>> str;
	int k,u,p,c;
	k = u = p = c = 0;

	for(int i=0;i<str.size();i++){
		if(str[i]=='K') k++;
		if(str[i]=='U') u++;
		if(str[i]=='P') p++;
		if(str[i]=='C') c++;
	}
	
	int ans = min(k, min(u, min(p, c)));
	
	cout<< ans<< endl;
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

 

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
#include <map>
using namespace std;

unsigned long long 
choose(unsigned long long n, unsigned long long k) {
	if (k > n) {
		return 0;
	}
	unsigned long long r = 1;
	for (unsigned long long d = 1; d <= k; ++d) {
		r *= n--;
		r /= d;
	}
	return r;
}

int main(void) {
	int n, a;
	cin >> n;
	map<long long, long long> mp;
	++mp[0];
	vector<long long> v(n + 1, 0);
	for (int i = 0; i < n; ++i) {
		cin >> a;
		v[i + 1] = v[i] + a;
		++mp[v[i + 1]];
	}
	long long ans = 0;
	for (auto x : mp) {
		long long num = x.second;
		if (x.second >= 2) {
			ans += choose(num, 2);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 14336
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;
typedef pair<long long int, pll> lpll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 

long long int A,B,C,N,K,res[200200]={},tmp=0;
pll ba[200200];
string S;

int main(){
    cout << fixed << setprecision(18);
    cin>>A>>B>>C;
    IFYES(B-A==C-B)
    
}




Measured memory_bytes: 256
MOD=pow(10, 9) + 7

n, k = map(int, input().split())
max_count = [0 for _ in range(n)]
min_count = [0 for _ in range(n)]

a_list = list(map(int, input().split()))
a_list.sort()

fac_list = [0 for _ in range(n)]
inv_fac_list = [0 for _ in range(n)]

fac_list[0] = 1
for i in range(1, n):
    fac_list[i] = i * fac_list[i-1] % MOD

inv_fac_list[n-1] = pow(fac_list[n-1],(MOD - 2), MOD)
for i in range(n-2, -1, -1):
    inv_fac_list[i] = inv_fac_list[i + 1] * (i + 1) % MOD


def combination(m, n):
    if n > m:
        return 0
    return (fac_list[m] * inv_fac_list[n] * inv_fac_list[m-n])%MOD


if __name__ == "__main__":
    for i in range(n):
        max_count[i] = combination(i, k-1)
        min_count[i] = combination(n-i-1, k-1)

    result = 0
    for i in range(n):
        result += (max_count[i] * a_list[i])%MOD
        result -= (min_count[i] * a_list[i])%MOD
    print(result%MOD)

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

ll pow_mod(ll a, ll n, ll p)
{
    ll res = 1;
    if(a == 1){
        return res;
    }
    while(n > 0){
        if(n & 1) res = res*a%p;
        a = a*a%p;
        n >>= 1;
    }
    return res;
}

int main()
{
    ll i,j;
    ll n,k;
    cin >> n >> k;
    ll MOD = 1e9+7;
    unordered_map<ll,ll> um;
    ll ans = 0;
    for(i = k;i >= 1;--i){
        ll i_number = k/i;
        ll tmp = pow_mod(i_number, n, MOD);
        for(j = 2*i;j <= k;j += i){
            tmp += MOD - um[j];
            tmp %= MOD;
        }
        um[i] = tmp;
    }
    for(auto x:um){
        ans += x.first*x.second%MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int sign(int x) { return (x > 0) - (x < 0); }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const deque<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const set<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, K;
int P[5500], C[5500];
signed main() {
    cin >> N >> K;
    rep(i, N) { cin >> P[i], P[i]--; }
    rep(i, N) { cin >> C[i]; }
    int ans = LLONG_MIN;
    rep(i, N) {
        vint v;
        int cur = i, pt = 0;
        do {
            cur = P[cur];
            pt += C[cur];
            v.emplace_back(pt);
        } while (cur != i);
        rep(j, v.size()) {
            if (j + 1 <= K) { chmax(ans, v[j] + max(0LL, pt) * ((K - j - 1) / (int) v.size())); }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3808
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll nCr(ll n,ll r){
  if(r == 1) return n;
  else if(r == 0) return 1;
  else return nCr(n-1,r-1)*n/r;
}

int main(){
  ll a,b; cin >> a >> b;
  
  if(a > b) cout << a-1 << endl;
  else cout << a << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  int ans = 1e+9;
  REP(i,n){
    int a;
    cin >> a;
    int cnt = 0;
    while(a%2==0){
      cnt++;
      a/=2;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
while(n,m=gets.split.map &:to_i)[0]>0
c=(1..n).map{{}}
m.times{a,b,t=gets.split.map &:to_i;c[a][b]=c[b][a]=t}
d=[s=0]
(y,z=d.flat_map{|i|[*c[i].select{|k,v|d-[k]==d}]}.min_by{|k,v|v};s+=z;d<<y)until d[n-1]
p s
end

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
  	bool res = true;
    rep(i,N){
        if(A[i]%2 == 0){
            if(A[i]%3 != 0 && A[i]%5 != 0){
                res = false;
                break;
            }
        }
    }
    if(res) cout <<  "APPROVED" << endl;
  	else cout <<  "DENIED" << endl;
}

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

int main (){
    string s;
    cin >> s;
    int i = 0;
    int count = 0, countcopy = 0;
    while (i < s.size()){
    if (s[i] == 'A' || s[i] == 'C' || s[i]  == 'T' || s[i] == 'G'){
        count++;
      if (i == s.size()-1 && count >= countcopy){
          countcopy = count;
      }
    } else {
        if (count >= countcopy){
            countcopy = count;
            count = 0;
        } else {
            count = 0;
        }
    }
        i++;
    }
    cout << countcopy << endl;
    return 0;
}




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

int main()
{
  	long long n;
  	cin>>n;
  	long long ans=0;
  	for(int i=1; (i*i)<=n ; ++i)
    {
    	ans=i*i;
    }
  	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

/////////////////////////////////////////////////////////////////////

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

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

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

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

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

mt19937_64 rnd(0);

const int LOG = 64;
const int N = (int)2e5 + 7;
const int MAXN = (int)1e6 + 7;
const int MOD = (int)1e9 + 7;
const int INF = (int)2e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e18;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

/////////////////////////////////////////////////////////////////////

void solve() {
	int n; cin >> n;
	cout << n + n * n + n * n * n;
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 3592
#include<cstdio>
typedef long long ll;
int main(){
	ll x;
	scanf("%lld",&x);
	ll sum = 0;
	ll a = x / 500;
	ll b = x % 500;
	sum += a * 1000;
	ll c = b / 5;
	sum += 5 * c;
	printf("%lld\n",sum);
	return 0;
}

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

typedef pair<int, int> P;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (!n) return 0;
    vector<P> stone;
    for (int i = 0; i < n; i++) {
      int color;
      cin >> color;
      if (i == 0) {
        stone.push_back(P(color, 1));
      } else if (i % 2 == 0) {
        if (stone[stone.size() - 1].first == color) {
          stone[stone.size() - 1].second++;
        } else {
          stone.push_back(P(color, 1));
        }
      } else {
        if (stone[stone.size() - 1].first == color) {
          stone[stone.size() - 1].second++;
        } else {
          stone[stone.size() - 1].second++;
          stone[stone.size() - 1].first = 1 - stone[stone.size() - 1].first;
          if (stone.size() > 1) {
            stone[stone.size() - 2].second += stone[stone.size() - 1].second;
            stone.pop_back();
          }
        }
      }
    }
    int ans = 0;
    for (int i = 0; i < stone.size(); i++) {
      if (stone[i].first == 0) ans += stone[i].second;
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3072
import numpy as np

def main():
  N = int(input())
  A = list(map(int,input().split()))
  A.sort()
  d = np.zeros(A[-1]+1, dtype=np.uint64)
  
  for i in range(N):
    a = A[i]
    a1 = A[i-1]
    if a != a1:
      d[a::a] += 1
    else:
      d[a] += 1
  print(np.count_nonzero(d[A] == 1))
  
main()

Measured memory_bytes: 51472
from collections import deque
h,w=map(int,input().split())
S=[input() for _ in range(h)]
inf=float("inf")
ans=0
for i in range(h):
    for j in range(w):
        if S[i][j]=="#":
            continue
        else:
            D=[[inf for _ in range(w)]for _ in range(h)]
            D[i][j]=0
            que=deque([(i,j)])
            while que:
                si,sj=que.popleft()
                for ni,nj in [(si+1,sj),(si-1,sj),(si,sj+1),(si,sj-1)]:
                    if 0<=ni<h and 0<=nj<w and S[ni][nj]!="#":
                        if D[ni][nj]>D[si][sj]+1:
                            D[ni][nj]=D[si][sj]+1
                            ans=max(ans,D[si][sj]+1)
                            que.append((ni,nj))
print(ans)

Measured memory_bytes: 48348
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map { it.toLong() }
    val A = readLine()!!.split(" ").map { it.toLong() }
    val dp = Array (60) { Array(2) { Array(2) { -1L } } }

    fun f(k: Int, u: Int, l: Int): Long {
        if (k < 0) {
            return 0
        }

        if (dp[k][u][l] >= 0) {
            return dp[k][u][l]
        }

        val s0 = A.map { (it and (1L shl k)) xor (0L shl k) }.sum()
        val s1 = A.map { (it and (1L shl k)) xor (1L shl k) }.sum()

        dp[k][u][l] = Math.max(dp[k][u][l], f(k - 1, Math.min(u, (K shr k).toInt().inv() and 1), l) + s0)

        if ((K shr k) and 1L == 1L || u == 0) {
            dp[k][u][l] = Math.max(dp[k][u][l], f(k - 1, u, Math.min(l, (K shr k).toInt() and 1)) + s1)
        }

        return dp[k][u][l]
    }

    println(f(59, 1, 0))
}


Measured memory_bytes: 130524
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int main(int argv, char** argc) {
  int M,D;
  int count = 0;
  cin >> M >> D;
  for(int j=1;j<M+1;j++)
    for(int i=1;i<D+1;i++){
      int d1 = i%10;
      int d10 = i/10;
      if(d1>=2 && d10>=2 && d1*d10 == j) count++;
    }
  printf("%d",count);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(),(v).end())
#define RSORT(v) sort((v).rbegin(),(v).rend())
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}



void solve(std::string a, std::string b){
    if(a == b){
        cout << "H" << endl;
    }else{
        cout << "D" << endl;
    }
}

int main(){
    std::string a;
    std::cin >> a;
    std::string b;
    std::cin >> b;
    solve(a, b);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>

#define pii pair<int, int>
#define pll pair<LL, LL>
#define F first
#define S second
#define B begin()
#define E end()
#define MOD 1000000007
#define itt iterator
#define ritt reverse_iterator
#define LL long long

#define PI (4 * atan(1))

using namespace std;

int k, a[100005], x;
LL mn, mx;

int main()
{
	// freopen("/Users/oakchawit/Documents/Computer/TestingArea/test.in", "r", stdin);
	// freopen("/Users/oakchawit/Documents/Computer/TestingArea/test.out", "w", stdout);

    scanf("%d", &k);
    for(int i = 0; i < k; ++i)
        scanf("%d", &a[k - i - 1]);

    for(int i = 0; i < k; ++i)
    {
    	x = a[i];

    	if(i == 0 && x != 2)
        {
            mn = -1;
            break;
        }
    	else if(i == 0)
    	{
    		mn = 2;
            mx = 3;
    		continue;
    	}

        mn += (mn % x == 0? 0: (x - (mn % x)));
        mx -= (mx % x);

        if(mn > mx)
        {
            mn = -1;
            break;
        }

        mx += (x - 1);
    }

    if(mn == -1)
    	printf("-1\n");
    else
    	printf("%lld %lld\n", mn, mx);
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int n,z,w,a[2010],i,dp[2010][2];
bool vis[2010][2];
int dfs(int cur,int turn)
{
  if (vis[cur][turn]) return dp[cur][turn];
  int res=abs(a[cur]-a[n]);
  vis[cur][turn]=1;
  if (turn==0)
  {
    for (int i=cur+1;i<n;i++)
      if (abs(a[i]-a[n])>res)
	res=max(res,dfs(i,1-turn)); 
  }
  else
  {
    for (int i=cur+1;i<n;i++)
      if (abs(a[i]-a[n])<res)
	res=min(res,dfs(i,1-turn)); 
  }
  return dp[cur][turn]=res;
}
int main()
{
  scanf("%d%d%d",&n,&z,&w);
  for (i=1;i<=n;i++) scanf("%d",&a[i]);
  a[0]=w;
  printf("%d\n",dfs(0,0));
}
//|an-w|  once
//ans=max|an-ai|????
//A:n,B:0
//A:ai(i<n),B:aj(j=n),A:ak,B:al,...

// |ai-an|>|an-w|,otherwise B take n
//B's turn
// |an-ai|>|aj-an|,otherwise B take n


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<climits>
#include<numeric>
#include<utility>
#define ul unsigned long long int
#define ll long long int
#define MAX 1000000+1
using namespace std;
#define F first
#define S second
#define pi 2*acos(0.0)
#define PB push_back
#define CL clear()



int main()
{

    ul k, n;
    ul sum = 0;
    cin >> k >> n;
    ul arr[n];
    for(ul i= 0; i < n; i++)
    {
        cin>>arr[i];
    }
    sort(arr, arr+n);
    vector<ul> v;
    for(ul i  = 1; i < n; i++)
    {

            v.push_back(arr[i]-arr[i-1]);


    }
    v.push_back(k+arr[0]-arr[n-1]);
    ul mx = 0;
    for(ul i = 0; i <(ul) v.size(); i++)
    {

        if(v[i]> mx)
        {
            sum+=mx;
            mx = v[i];
            continue;
        }
        sum+=v[i];
    }
    cout << sum;
    return 0;

}




Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+5;
int n,a[N],pos[N],nxt[N],cur=1;
vector<int> ans;
signed main(){
//	freopen("01-06.txt","r",stdin);
	int k;
	cin>>n>>k;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	for(int i=n;i>=1;--i)
		pos[a[i]]=i;
	for(int i=n;i>=1;--i)
		nxt[i]=pos[a[i]],pos[a[i]]=i;
	int p=1;
	while(1){
		if(nxt[p]<=p) ++cur;
		p=nxt[p]+1;
		if(p==n+1){
			break;
		}
	}
	k%=cur;cur=0;p=1;
	while(1){
		if(nxt[p]<=p) ++cur;
		if(cur==k) break;
		p=nxt[p]+1;
	}
	while(1){
		if(nxt[p]<=p) ans.push_back(a[p]),p++;
		else p=nxt[p]+1;
		if(p==n+1) break;
	}
	for(auto v:ans) cout<<v<<" ";
	return 0;
}


Measured memory_bytes: 9844
n=0
m=input()
c=[0 for i in xrange(m)]
ts=[0 for i in xrange(m)]


def dfs_visit(u):
    global n
    if ts[u]:return
    n = n + 1
    ts[u]=[u+1,n]
    for i in c[u]:dfs_visit(i-1)
    n = n + 1
    ts[u][2:]=[n]

def dfs():
    for i in range(m):
     l=map(int,raw_input().split())
     c[l[0]-1]=l[2:]
    for i in range(m):
     dfs_visit(i)
     print " ".join(map(str,ts[i]))

dfs()

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

template<typename T>
void Dump(const std::vector<T>& xs)
{
  for (int i = 0; i < xs.size()-1; ++i)
  {
    std::cout << xs[i] << ' ';
  }
  std::cout << xs.back() << std::endl;
}

template<typename T>
int BubbleSort(std::vector<T>* src)
{
  std::vector<T>& xs = *src;
  bool change {true};
  int count = {0};
  while (change) {
    change = false;
    for (int i = xs.size()-1; i > 0; --i)
    {
      if (xs[i] < xs[i-1]) {
        T buf = xs[i];
        xs[i] = xs[i-1];
        xs[i-1] = buf;

        change = true;
        ++count;
      }
    }
  }
  return count;
}

int main()
{
  int n {};
  std::vector<int> xs {};
  std::cin >> n;
  xs.resize(n);
  for (int i = 0; i < n; ++i)
  {
    std::cin >> xs[i];
  }

  int cnt{BubbleSort(&xs)};

  Dump(xs);
  std::cout << cnt << std::endl;

  return 0;
}

Measured memory_bytes: 1196
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdin =new Scanner(System.in);
		int n=stdin.nextInt();
		int a[]=new int[n+2];
		int i,j,k;
		int sum=0;
		int dis;
		a[0]=0;
		a[n+1]=0;
		for(i=1;i<n+1;i++)
			a[i]=stdin.nextInt();

		for(i=1;i<n+2;i++){
			dis=Math.abs(a[i]-a[i-1]);
			sum+=dis;
//			System.out.println("dis="+dis);
		}
//		System.out.println("sum="+sum);
		for(i=1;i<n+1;i++){
			int x=Math.abs(a[i]-a[i-1])+Math.abs(a[i+1]-a[i]);
			int y=Math.abs(a[i+1]-a[i-1]);
			System.out.println(sum+y-x);
		}
	}
}

Measured memory_bytes: 61620
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int n; cin >> n;
	vector<int> v(n);
	rep(i, n) cin >> v[i];

	ll tmp = 0;
	rep(i, n){
		tmp = tmp ^ v[i];
	}
	rep(i, n){
		ll a = tmp ^ v[i];
		if(i) cout << " ";
		cout << a;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3992
import java.util.*;
import java.math.BigDecimal;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Main main = new Main();
        main.resolve(scan);
        scan.close();
    }

    final private void resolve(Scanner scan) {
        String a = scan.next(), b = scan.next();
        BigDecimal ab = new BigDecimal(a);
        BigDecimal bb = new BigDecimal(b);
        System.out.println(ab.multiply(bb).toBigInteger().toString());
    }
}


Measured memory_bytes: 36016
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
using namespace std;
typedef long long ll;

int n,c,k,t[100005];

int main(){
	scanf("%d%d%d",&n,&c,&k);
	fore(i,0,n)scanf("%d",t+i);
	sort(t,t+n);
	int r=0,l,q=0;
	fore(i,0,n){
		if(!q||t[i]-k>l)l=t[i],q=c,r++;
		q--;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

llong n, m;
llong dp[1 << 14][1005];
llong v[1005];
llong b[1005];
llong c[1005];

int main() {
    for (int i = 0; i < (1 << 13); i++) {
        for (int j = 0; j < 1005; j++) {
            dp[i][j] = 1ll << 60ll;
            if (i == 0) dp[i][j] = 0;
        }
    }
    
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        cin >> v[i] >> b[i];
        
        for (int j = 0; j < b[i]; j++) {
            int temp;
            cin >> temp;

            c[i] |= (1 << (temp - 1));
        }
    }

    for (llong i = 1; i <= m; i++) {
        for (llong j = 0; j < (1 << n); j++) {
            dp[j][i] = min(dp[j][i], dp[j][i - 1]);
            dp[j | c[i]][i] = min(dp[j | c[i]][i], min(dp[j | c[i]][i - 1], dp[j][i - 1] + v[i]));
        }
    }

    if (dp[(1 << n) - 1][m] == (1ll << 60ll)) {
        cout << -1 << endl;
    }
    else {
        cout << dp[(1 << n) - 1][m] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 65792
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

char dn[1300000], * di = dn;
int keta1 = 1, keta2;
char C1[10] = { '1', '0', '0', '0', '0', '0' };
char C2[10] = { '0', '0', '0', '0', '0', '0' };

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


	int N, M;
	scanf("%d %d", &N, &M);

	if (N % 2) {
		int n = N - 1;
		keta2 = 0;
		while (n) {
			*(C2 + keta2) = '0' + n % 10;
			n /= 10;
			keta2++;
		}

		rep1(i, M) {
			for (int i = keta1 - 1; i >= 0; i--)* di++ = (*(C1 + i));
			*di++ = ' ';
			for (int i = keta2 - 1; i >= 0; i--)* di++ = (*(C2 + i));
			*di++ = '\n';

			C1[0]++;
			int tmp = 0;
			while (C1[tmp] > '9') {
				C1[tmp++] -= 10;
				C1[tmp]++;
				if (C1[keta1] != '0') keta1++;
			}
			C2[0]--;
			tmp = 0;
			while (C2[tmp] < '0') {
				C2[tmp++] += 10;
				C2[tmp]--;
				if (C2[keta2 - 1] == '0') keta2--;
			}
		}
	}
	else {
		int n = N;
		keta2 = 0;
		while (n) {
			*(C2 + keta2) = '0' + n % 10;
			n /= 10;
			keta2++;
		}
		rep1(i, (M + 1) / 2) {
			for (int i = keta1 - 1; i >= 0; i--)* di++ = (*(C1 + i));
			*di++ = ' ';
			for (int i = keta2 - 1; i >= 0; i--)* di++ = (*(C2 + i));
			*di++ = '\n';

			C1[0]++;
			int tmp = 0;
			while (C1[tmp] > '9') {
				C1[tmp++] -= 10;
				C1[tmp]++;
				if (C1[keta1] != '0') keta1++;
			}
			C2[0]--;
			tmp = 0;
			while (C2[tmp] < '0') {
				C2[tmp++] += 10;
				C2[tmp]--;
				if (C2[keta2 - 1] == '0') keta2--;
			}
		}
		C2[0]--;
		int tmp = 0;
		while (C2[tmp] < '0') {
			C2[tmp++] += 10;
			C2[tmp]--;
			if (C2[keta2 - 1] == '0') keta2--;
		}
		for (int i = (M + 1) / 2 + 1; i <= M; i++) {
			for (int i = keta1 - 1; i >= 0; i--)* di++ = (*(C1 + i));
			*di++ = ' ';
			for (int i = keta2 - 1; i >= 0; i--)* di++ = (*(C2 + i));
			*di++ = '\n';

			C1[0]++;
			int tmp = 0;
			while (C1[tmp] > '9') {
				C1[tmp++] -= 10;
				C1[tmp]++;
				if (C1[keta1] != '0') keta1++;
			}
			C2[0]--;
			tmp = 0;
			while (C2[tmp] < '0') {
				C2[tmp++] += 10;
				C2[tmp]--;
				if (C2[keta2 - 1] == '0') keta2--;
			}
		}
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 4128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;

ll saiki(ll n, ll x)
{
    if (n == 0)
        return 1;
    ll a = pow(2, n + 1) - 3;
    ll b = pow(2, n) - 1;

    if (x == 1)
        return 0;
    else if (x <= 1 + a)
        return saiki(n - 1, x - 1);
    else if (x == 2 + a)
        return b + 1;
    else if (x <= 2 * a + 2)
        return saiki(n - 1, x - a - 2) + b + 1;
    else if (x == 2 * a + 3)
        return 2 * b + 1;
}
int main()
{
    ll n, x;
    cin >> n >> x;
    cout << saiki(n, x) << endl;
}

Measured memory_bytes: 384
N = int(input())
h = list(map(int, input().split()))
 
def solve(List):
  if List.count(0) == len(List):
    return(0)
  if List.count(0) == 0:
    for i in range(len(List)):
      List[i] -= 1
    return(1 + solve(List))
  elif List[0] == 0:
    List.pop(0)
    return(solve(List))
  else:
    p = 0
    q = 1
    while p == 0:
      if List[q] == 0:
        p = q
      else:
        q += 1
    return(solve(List[:q]) + solve(List[q:]))
print(solve(h))

Measured memory_bytes: 3188
// Author: H. Gakhar
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, w;
	cin>>n>>w;
	ll dp[1000*n+1];
	for(int i=0; i<1000*n+1; i++) dp[i]=10000000000000;
	dp[0]=0;
	for(int i=0; i<n; i++)
	{
		int m , v;
		cin>>m>>v;
		for(int i=1000*n-v; i>=0; i--)
		{
			dp[i+v]=min(dp[i+v], dp[i]+m);
		} 
	}
	int mex=0;
	for(auto i=0; i<1000*n+1; i++) if(dp[i]<=w) mex=max(mex, i);
	cout<<mex;
	return 0;
}
 

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

typedef long long ll;
const int MAXN = 100010;

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x*10)+(ch^48);
	return x * f;
}

int n, K, a[MAXN];
ll suf[MAXN], pre[MAXN];
ll sum[MAXN], ans;

int main() {
	n = read(), K = read();
	for(int i = 1; i <= n; i++) a[i] = read();
	for(int i = n; i >= 1; i--) {
		suf[i] = suf[i+1];
		if(a[i] > 0) suf[i] += a[i];
	}
	for(int i = 1; i <= n; i++) {
		pre[i] = pre[i-1];
		if(a[i] > 0) pre[i] += a[i];
	}
	for(int i = 1; i <= n; i++) sum[i] = sum[i-1]+a[i];
	for(int i = 1; i <= n-K+1; i++) {
		ans = max(ans, sum[i+K-1]-sum[i-1]+pre[i-1]+suf[i+K]);
		//if(ans == 20) printf("%d\n", i);
		ans = max(ans, pre[i-1]+suf[i+K]);
		//if(ans == 20) printf("%d\n", i);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 2944
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($A,$B) = explode(" ",trim(fgets(STDIN)));
//$A  = explode(" ",trim(fgets(STDIN)));
$res = $N;
if (($N % 2)!=0) {
  $res = $N*2;
}
printf("%d\n",$res);


Measured memory_bytes: 3828
import java.util.*;

// ABC 76-D
// https://beta.atcoder.jp/contests/abc076/tasks/abc076_d

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int N = in.nextInt();
		char[] c = in.next().toCharArray();
		
		int[][] arr1 = new int[N][2];
		int[][] arr2 = new int[N][2];
		
		for (int i = 0; i < N; i++) {
			if (c[i] == 'W') {
				if (i == 0) {
					arr1[i][0]++;	
				} else {
					arr1[i][0] = arr1[i - 1][0] + 1;
					arr1[i][1] = arr1[i - 1][1];
				}
			} else {
				if (i == 0) {
					arr1[i][1]++;	
				} else {
					arr1[i][0] = arr1[i - 1][0];
					arr1[i][1] = arr1[i - 1][1] + 1;
				}
			}
		}
		
		for (int i = N - 1; i >= 0; i--) {
			if (c[i] == 'W') {
				if (i == N - 1) {
					arr2[i][0]++;
				} else {
					arr2[i][0] = arr2[i + 1][0] + 1;
					arr2[i][1] = arr2[i + 1][1]; 
				}
			} else {
				if (i == N - 1) {
					arr2[i][1]++;
				} else {
					arr2[i][0] = arr2[i + 1][0];
					arr2[i][1] = arr2[i + 1][1] + 1; 
				}
			}
		}
		
		int answer = N;
		
		for (int i = 0; i < N; i++) {
			int left = i == 0 ? 0 : arr1[i - 1][0];
			int right = i == N - 1 ? 0 : arr2[i + 1][1];
			
			answer = Math.min(answer, left + right);
		}
		
		System.out.println(answer);
	}
}

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

struct Node
{
    int source, target, value;
};
bool cmp(Node &a, Node &b)
{
    return a.value<b.value;
}
const int MAX = 100005;
int V, E, MIN = 0;
Node e[MAX];
vector<Node> Mst;

class DisjointSet
{
    public:
        vector<int> rank, p;//rank记录集合树高，rank[x]，则x为集合根，p指向父节点

    DisjointSet(){}
    DisjointSet(int size)
    {
        rank.resize(size, 0);
        p.resize(size, 0);
        for(int i=0; i<size; i++)
        {
            makeSet(i);
        }
    }

    void makeSet(int x)//创建仅包含元素x的新集合
    {
        p[x] = x;
        rank[x] = 0;
    }

    bool same(int x, int y)//判断x和y是否在同一集合
    {
        return findSet(x) == findSet(y);
    }

    void unite(int x, int y)//合并指定的元素及其集合
    {
        link(findSet(x), findSet(y));
    }

    void link(int x, int y)//合并函数
    {
        if(rank[x]>rank[y])//根据树的高度来确定合并策略
        {
            p[y] = x;
        }
        else
        {
            p[x] = y;
            if(rank[x]==rank[y])
            {
                rank[y]++;
            }
        }
    }

    int findSet(int x)//寻找x的集合的根
    {
        if(x!=p[x])
        {
            p[x] = findSet(p[x]);
        }
        return p[x];
    }

};

void kruskal()
{
    DisjointSet ds = DisjointSet(V);
    sort(e, e+E, cmp);
    for(int i=0; i<E; i++)
    {
        if(!ds.same(e[i].source, e[i].target))
        {
            ds.unite(e[i].source, e[i].target);
            MIN += e[i].value;
            Mst.push_back(e[i]);//记录最小生成树的边
            if(Mst.size()==V-1) break;
        }
    }
    cout << MIN << endl;
}
int main()
{
    scanf("%d %d", &V, &E);
    for(int i=0; i<E; i++)
    {
        cin >> e[i].source >> e[i].target >> e[i].value;
    }
    kruskal();

    return 0;
}



Measured memory_bytes: 4560