akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <cassert>
using namespace std;
using VI = vector<int>;

int has_odd = false;
int xored = 0;
map<int, int> fix;
VI fixes;

int get_max_2pow(int a) {
    int ret = 2;
    while (a % 2 == 0) {
        a /= 2;
        ret *= 2;
    }
    return ret - 1;
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a % 2) {
            has_odd = true;
            xored ^= a;
        } else {
            int p = get_max_2pow(a);
            fix[p]++;
            xored ^= a;
        }
    }
    for (auto& f: fix) {
        fixes.push_back(f.first);
    }
    
    sort(fixes.begin(), fixes.end(), greater<>());
    int cnt = 0;
    for (int f: fixes) {
        if (f >= xored && f < xored << 1) {
            xored ^= f;
            cnt++;
        }
    }
    if (xored == 0) {
        cout << cnt << endl;
    } else if (xored == 1 && has_odd) {
        cout << cnt + 1 << endl;
    } else {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/rope"
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
#define lambdify(x) [&](auto &&...args){ return x(forward<decltype(args)>(args)...); }
template<typename T, typename U> T &ctmax(T &x, const U &y){ return x = max<T>(x, y); }
template<typename T, typename U> T &ctmin(T &x, const U &y){ return x = min<T>(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(auto i = 0; i < n; ++ i){
		cin >> a[i];
	}
	auto apply = [&](){
		static vector<int> b(n);
		fill(b.begin(), b.end(), 0);
		b.push_back(0);
		for(auto i = 0; i < n; ++ i){
			++ b[max(0, i - a[i])];
			-- b[min(n, i + a[i] + 1)];
		}
		for(auto i = 0; i < n; ++ i){
			b[i + 1] += b[i];
		}
		b.pop_back();
		swap(a, b);
	};
	if(k > ceil(sqrt(n))){
		for(auto i = 0; i < n; ++ i){
			cout << n << " ";
		}
		cout << "\n";
	}
	else{
		for(auto rep = 0; rep < k; ++ rep){
			apply();
		}
		for(auto x: a){
			cout << x << " ";
		}
		cout << "\n";
	}
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 5572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int cnt = 1;

	if(b != a) cnt++;
	if(c != a && c != b) cnt++;
	cout << cnt << "\n";
	return 0;
}

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

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

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

    int n;
    string s, t, u;
    cin >> n >> s;
    rep(i, n/ 2) {
        t += s[i];
    }
    t += t;
    if(t == s) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,p,ac=0,pena=0;cin>>n>>m;
  string s;
  lvector already_ac(n,0),penas(n,0);
  rep(i,m) {
    cin>>p>>s;p--;
    if(already_ac[p]==0) {
      if(s=="AC") {
        ac++;
        already_ac[p]=1;
        pena+=penas[p];
      }
      else penas[p]++;
    }
  }
  printf("%lld %lld\n",ac,pena);
  return 0;
}

Measured memory_bytes: 1792
//#include<bits/stdc++.h>
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#define ll long long
#define maxn 0x3f3f3f3f
using namespace std;

int a[200005];
int main()
{
    ios::sync_with_stdio(false);
//    int m;
//    cin>>m;
//    int ans=0;int t=0;
//    while(m!=1)
//    {
//        m/=2;
//        if(m&1)
//            ans=ans+t+1;
//        t+=1;
//    }
//    cout<<ans+


    int m,n;
    ll ans=0;
    cin>>n>>m;
    for(int i=0;i<n;i++)
        cin>>a[i];
    if(m>=n)
    {
        cout<<"0"<<endl;
        return 0;
    }
    sort(a,a+n);
    for(int i=n-1-m;i>=0;i--)
    {
        ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[1005][1005];
string s;
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>s;
		for(int j=0;j<m;j++){
			if(s[j]=='#'){
				a[i][j]=0;
			}
			else{
				a[i][j]=1000007;
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(i>0){
				a[i-1][j]=min(a[i][j]+1,a[i-1][j]);	
			}
			if(i<n-1){
				a[i+1][j]=min(a[i][j]+1,a[i+1][j]);
			}
			if(j>0){
				a[i][j-1]=min(a[i][j]+1,a[i][j-1]);
			}
			if(j<m-1){
				a[i][j+1]=min(a[i][j]+1,a[i][j+1]);	
			}
		}
	}
	for(int i=n-1;i>=0;i--){
		for(int j=m-1;j>=0;j--){
			if(i>0){
				a[i-1][j]=min(a[i][j]+1,a[i-1][j]);	
			}
			if(i<n-1){
				a[i+1][j]=min(a[i][j]+1,a[i+1][j]);
			}
			if(j>0){
				a[i][j-1]=min(a[i][j]+1,a[i][j-1]);
			}
			if(j<m-1){
				a[i][j+1]=min(a[i][j]+1,a[i][j+1]);	
			}
		}
	}
	int maks=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			maks=max(a[i][j],maks);
		}
	}
	cout<<maks<<endl;
}

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

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

// constant
// -----------------------------------------------------------------------------
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    ll N; cin >> N;
    ll min_v = ceill((ld)N / 1.08);
    ll max_v = floorl((ld)(N + 1) / 1.08);
    if (min_v <= max_v) {
        cout << min_v << "\n";
    } else {
        cout << ":(" << "\n";
    }
}


Measured memory_bytes: 3692
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int X;
int Y;
int main(){
  int res  = 0;
  rd(X);
  rd(Y);
  if(X==Y && Y==1){
    res += 4;
  }
  if(X <= 3){
    res += 4 - X;
  }
  if(Y <= 3){
    res += 4 - Y;
  }
  wt_L(res * 100000);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191123-1

// --- original code ---
// int X, Y;
// {
//   int res  = 0;
//   rd(X,Y);
//   if(X==Y==1) res += 4;
//   if(X <= 3) res += 4 - X;
//   if(Y <= 3) res += 4 - Y;
//   wt(res * 1d5);
// }


Measured memory_bytes: 764
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int n;
  cin >> n;
  while(n--){
    double x[4],y[4];
    for(int i=0;i<4;i++) cin >> x[i] >> y[i]; 
    if(abs((x[3]-x[2])*(y[1]-y[0])-(x[1]-x[0])*(y[3]-y[2])) < 1e-10)
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
int prime(int x) {
	if (x < 2)return 0;
	else if (x == 2) return 1;
	if (x % 2 == 0) return 0;
	for (int i = 3; i*i <= x; i += 2) {
		if (x%i == 0) return 0;
	}
	return 1;
}
int main(){
	int n;
	while (cin >> n, n) {
		if (prime(n))cout << 0 << endl;
		else { 
			int x = n, y = n;
			while (!prime(x)) {
				x--;
			}
			while (!prime(y)) {
				y++;
			}
			cout << y - x << endl;
		}
	}
}




Measured memory_bytes: 2976
A = [list(map(int,input().split())) for i in range(3)]

N = int(input())

for n in range(N):
    B = int(input())

    for i in range(3):
        for j in range(3):
            if A[i][j] == B:
                A[i][j] = 0

for i in range(3):
    if (A[i][0] == 0 and A[i][1] == 0) and A[i][2] == 0:
        print("Yes")
        exit()

    elif (A[0][i] == 0 and A[1][i] == 0) and A[2][i] == 0:
        print("Yes")
        exit()

if (A[0][0] == 0 and A[1][1] == 0) and A[2][2] == 0:
    print("Yes")

elif (A[0][2] == 0 and A[1][1] == 0) and A[2][0] == 0:
    print("Yes")

else:
    print("No")

Measured memory_bytes: 9144
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cctype>
#define REP(i,a,b) for(register int i=(a); i<(b); i++)
#define REPE(i,a,b) for(register int i=(a); i<=(b); i++)
#define PERE(i,a,b) for(register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
/*char buf[1<<21], *p1=buf, *p2=buf;
#define getchar() (p1==p2 && (p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <class T> inline void read(T&x) {
	x=0; char ch; do ch=getchar(); while(ch<=' ');
	while(ch>' ') {x=x*10+ch-'0'; ch=getchar();}
}*/
#define MAXN 200007
char N[107], *p;
int k;
int l;
int C(int i, int j) {
	if(i<j) return 0;
	int ans=1;
	REP(k,0,j) ans*=i--;
	while(j) ans/=j--;
	return ans;
}
int calc2(int i, int k) {
	int p=1;
	REP(j,0,k) p*=9;
	return C(l-i,k)*p;
}
int calc1(int i, int k) {
	if(k==0) return 1;
	int ans=0;
	ans += calc2(i+1,k);
	/*1..p[i]-1*/if(p[i]>'1') ans+=(p[i]-'1')*calc2(i+1,k-1);
	int t=i+1; while(p[t]=='0') t++;
	if(t<l) {
		/*p[i]*/ans+=calc1(t,k-1);
	} else if(k==1) ans++;
	return ans;
}
int main() {
	//memset(dp,-1,sizeof dp);
	scanf("%s", N); p=N;
	while(*p=='0') p++;
	scanf("%d", &k);
	l=strlen(p);
	int ans=0;
	ans = calc1(0,k);
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  long long L, T;
  cin >> N >> L >> T;
  vector<long long> X(N), W(N);
  for (int i = 0; i < N; i++){
    cin >> X[i] >> W[i];
  }
  vector<long long> X2(N);
  for (int i = 0; i < N; i++){
    if (W[i] == 1){
      X2[i] = (X[i] + T) % L;
    } else {
      X2[i] = (X[i] - T % L + L) % L;
    }
  }
  sort(X2.begin(), X2.end());
  long long sum1 = 0;
  for (int i = 0; i < N; i++){
    sum1 += X[i];
  }
  for (int i = 0; i < N; i++){
    if (W[i] == 1){
      sum1 += T;
    } else {
      sum1 -= T;
    }
  }
  long long sum2 = 0;
  for (int i = 0; i < N; i++){
    sum2 += X2[i];
  }
  int C = (sum2 - sum1) / L;
  for (int i = 0; i < N; i++){
    cout << X2[(i - C % N + N) % N] << endl;
  }
}

Measured memory_bytes: 5472
#include <stdio.h>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long double ld;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;
//typedef long long int;

int a[305][305];

int main() {
  std::ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) {
    cin >> a[i][j];
    --a[i][j];
  }
  vi used(m);
  vvi g(m);
  for (int i = 0; i < n; ++i) g[a[i][0]].push_back(i);
  int res = n;
  for (int t = 0; t < m; ++t) {
    int ma = 0, j = 0;
    for (int i = 0; i < m; ++i) if (!used[i] && ma < g[i].size()) {
      ma = g[i].size();
      j = i;
    }
    res = min(res, ma);
    if (t == m-1) break;
    used[j] = 1;
    for (int x : g[j]) {
      for (int i = 0; i < m; ++i) if (!used[a[x][i]]) {
        g[a[x][i]].push_back(x);
        break;
      }
    }
    g[j].clear();
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = k; i < j; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;

int main(){
    int n, m, k;
    while(cin >>n >>m >>k && (n || m || k)){
        int s = m * n;
        vector< vector<double> > dp(2, vector<double>(s + 5, 0));
        dp[0][0] = 1.0;

        REP(i, n){
            FOR(j, s + 5, i){
                FOR(k, m + 1, 1){
                    if(j + k > s + 5) break;
                    dp[1][j + k] += (dp[0][j] * (1.0 / m) * 1.0);
                }
            }
            FOR(j, s + 5, i){
                dp[0][j] = dp[1][j];
                dp[1][j] = 0;
            }
        }
        double ans = 0.0;
        FOR(i, s + 5, 1){
            if(i - k <= 1) ans += (dp[0][i] * 1.0);
            else ans += (dp[0][i] * (i - k) * 1.0);
        }
        printf("%.8lf\n", ans);
    }
    return 0;
}

Measured memory_bytes: 1436
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); i++)
#define swap(a, b) (a += b, b = a - b, a -= b)
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> a(N), b(N), c(N), abc(3 * N);
    rep(i, N)
    {
        cin >> b[i];
        a[i] = b[i] + 1;
        c[i] = b[i] - 1;
    }
    int j = 0, i = 0;
    while (i < N)
    {
        abc[i] = a[j];
        i++;
        j++;
    }
    i = N;
    j = 0;
    while (i < 2 * N)
    {
        abc[i] = b[j];
        i++;
        j++;
    }
    i = 2 * N;
    j = 0;
    while (i < 3 * N)
    {
        abc[i] = c[j];
        i++;
        j++;
    }
    sort(abc.begin(), abc.end());

    i = 0;
    j = i + 1;
    int count = 1, max = 0, ans, count1 = 0;
    while (j < 3 * N)
    {
        if (abc[i] == abc[j])
        {
            count++;
            j++;
        }
        else
        {
            if (max < count)
            {
                max = count;
                ans = abc[i];
            }
            i = j;
            j = i + 1;
            count = 1;
        }
    }
    count1 = 0;
    rep(i, N)
    {
        if (abs(ans - b[i]) == 1 || abs(ans - b[i]) == 0)
        {
            count1++;
        }
    }
    cout << count1 << endl;
}

Measured memory_bytes: 2560
#include<stdio.h>
int main(void)
{
    int x,y;


    while(1){
    scanf("%d %d",&x,&y);

    if(x > y ){
        printf("%d %d\n",y,x);
    }
    if(y > x ){
        printf("%d %d\n",x,y);
    }
    if(x == y && x > 0 && y > 0){
        printf("%d %d\n",x,y);
    }
    if(x == 0 && y == 0)break;
    }
     return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
 
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define pow10(n) stoll("1"+string(n,'0'))
//fill(all(arr),1)
//if(map.count(key)){}
//bitset<20>(n);
//int mini=min({a,b,c,d,e});
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int main(){
    FIO
    string s;
    cin>>s;
    if(s[0]=='7'||s[1]=='7'||s[2]=='7')cout<<"Yes";
    else cout<<"No";
    
    
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>	// vectorを使うにはこれが必要
using namespace std;

int main(){
	// resize関数を使って動的にサイズを変えれる
	vector< vector<int> > arr;
  int H, W;
  cin >> H >> W;
  int h, w;
  cin >> h >> w;

  int counter = 0;


  for(int i = 0; i < H; i++){
    for(int j = 0; j< W; j++){
      if(i<h or j<w){
        int q = 0;
      }else{
        counter++;
      }
    }
  }
  cout << counter << endl;
}


Measured memory_bytes: 256
import numpy as np

N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
B = [list(map(int, input().split())) for _ in range(M)]

for (x, y) in A:
    d = np.array([])
    for (a, b) in B:
        d = np.append(d, abs(x-a) + abs(y-b))
    print(np.argmin(d) + 1)





Measured memory_bytes: 12424
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        if(Solve())
        {
            Console.WriteLine("Yes");
        } else
        {
            Console.WriteLine("No");
        }
    }

    static bool Solve()
    {
        int t = int.Parse(Console.ReadLine());
        for (int i = 1; i <= 9; i++)
        {
            for (int j = 1; j <= 9; j++)
            {
                if (i * j == t) return true;
            }
        }
        return false;
    }
}



Measured memory_bytes: 13140
#include<stdio.h>
#include<math.h>
int main(){
  int a, n, min = 30;
  scanf("%d", &n);
  for(int i = 0; i < n; ++i){
    int j = 1;
    scanf("%d", &a);
    if(a % 2){
      min = 0;
      break;
    }
    //if(a > pow(2, min)) continue;
    while(1){
      a /= 2;
      //printf("%d\n", a);
      if(a % 2) break;
      j++;
    }
    if(j < min) min = j;
  }
  printf("%d\n", min);
  return 0;
}

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

using namespace std;

typedef long long ll;

ifstream fin ("hps.in");
ofstream fout ("hps.out");

#define f first
#define s second
#define pb push_back

int h, a;


int main()
{
  cin >> h >> a;
  cout << (h + a - 1) / a;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

    int N, Y;
    cin >> N >> Y;

    int res10000 = -1, res5000 = -1, res1000 = -1;

    for(int a = 0; a <= N; ++a){
        for(int b = 0; b + a <= N; ++b){
            int c = N - a - b;
            int total = 10000*a + 5000*b + 1000*c;
            if(total == Y){
                res10000 = a;
                res5000  = b;
                res1000  = c; 
            }
        }
    }

    cout << res10000 << " " << res5000 << " " << res1000 << endl;
}


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

int main(){
    int N;
    cin >> N;
    if(N == 1){
        cout << "Hello World" << endl;
    }else{
        int A,B;
        cin >> A >> B;
        cout << A + B << endl;
    }
    
}

Measured memory_bytes: 256
N = int(input())
S = input()
Rnum = 0
Gnum = 0
Bnum = 0
for i in S:
    if i == 'R':
        Rnum += 1
    elif i == 'G':
        Gnum += 1
    else:
        Bnum += 1

ans = Rnum*Gnum*Bnum

for i in range(1, N//2 + 1):
    for j in range(N):
        if j + 2*i >= N:
            break
        else:
            if S[j] != S[j+i] and S[j+i] != S[j+2*i] and S[j] != S[j+2*i]:
                ans -= 1

print(ans)

Measured memory_bytes: 9172
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ld long double
#define int long long
#define dbgvi(x) cout << #x << " = "; for(int i = 0; i < (x.size()); ++i) cout << x[i] << " ";
using namespace std;

void no(){
    cout << "No\n";
}

void yes(){
    cout << "Yes\n";
}

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



void solve(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(b > a || b > d){
        no();
        return;
    }
    if(c >= b){
        yes();
        return;
    }
    int l = c + 1;
    int r = b - 1;
    if(l > r){
        yes();
        return;
    }
    l = (l - (a % b) + b) % b;
    r = (r - (a % b) + b) % b;
    int g = gcd(b, d);
    if(l > r){
        int l1 = l;
        int r1 = b - 1;
        int l2 = 0;
        int r2 = r;
        int k1 = ((l1 + g - 1) / g) * g;
        int k2 = ((l2 + g - 1) / g) * g;
        if(k1 <= r1 || k2 <= r2){
            no();
        } else {
            yes();
        }
        return;
    }
    int k = ((l + g - 1) / g) * g;
    if(k <= r){
        no();
        return;
    } else {
        yes();
        return;
    }
}


signed main(){
    int t = 1;
    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    cin >> t;
    //freopen("skyscraper.in", "r", stdin);
    //freopen("skyscraper.out", "w", stdout);
    //cin >> t;
    while(t--){
        solve();
    }
}


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

namespace AOJ {
    public class Problem {
        public static void Main() {
            var data = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(data[0] < data[1] && data[1] < data[2] ? "Yes" : "No");
        }
    }
}


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

int main()
{
    string str;
    cin >> str;
    int a,b;
    a = (str.at(0)-'0')*10+str.at(1)-'0';
    b = (str.at(2)-'0')*10+str.at(3)-'0';
    if((1 <= a && a <= 12) && (1 <= b && b <= 12)){
        cout << "AMBIGUOUS" << endl;
    }else if(1 <= a && a <= 12){
        cout << "MMYY" << endl;
    }else if(1 <= b && b <= 12){
        cout << "YYMM" << endl;
    }else{
        cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>

#define rep(i, j) for(int i = 0; i < j; i++)
// sp_rep
#define sp_rep(i, j) for(int i = 1; i <= j; i++)
#define all(i) i.begin(), i.end()
#define ll long long

using namespace std;

string Num2Str(int num)
{
	stringstream ss;
	ss << num;
	return ss.str();
}

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

	// code
	int n;
	while (cin >> n && n!=0) {
		int cnt = 0, sum = 0;
		sp_rep(i, n) {
			for (int j = i; j < n; j++) {
				sum += j;
				if (sum == n) cnt++;
			}
			sum = 0;
		}
		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 1200
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <vector>
#include <stdio.h>
#include <iostream>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <random>
#include <time.h>
#include <cassert>


#define prev askdnsajd
#define rank asasdmdnasd
#define next lsjndajbs
#define hash asmdklansd
#define index asdklnas
#define right sld
#define left sldl

using namespace std;

typedef long long ll;
typedef long double dbl;

template<class T>
void print(vector<T> s){
    for (T x : s)
        cout << x << " ";
    cout << endl;
}

mt19937 mrand(random_device{} ());
int rnd() {
    return mrand();
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(77);
    int n;
    cin >> n;
    vector<dbl> s(n);
    dbl summa = 0;
    for (int i = 0; i < n; i++){
        cin >> s[i];
        summa += 1.0 / s[i];
    }
    cout << 1 / summa << endl;
    return 0;
}

Measured memory_bytes: 256
import collections
n = int(input())
v = list(map(int, input().split()))
odd = []
even = []
for i in range(n):
    if i % 2 == 0:
        even.append(v[i])
    else:
        odd.append(v[i])
o = collections.Counter(odd)
o_list = list(o.items())
o_sorted = sorted(o_list, key=lambda x: x[1], reverse=True)
e = collections.Counter(even)
e_list = list(e.items())
e_sorted = sorted(e_list, key=lambda x: x[1], reverse=True)

if len(o_sorted) == 1 and len(e_sorted) == 1:
    if o_sorted[0][0] != e_sorted[0][0]:
        print(0)
    else:
        print(o_sorted[0][1])
else:
    if o_sorted[0][0] != e_sorted[0][0]:
        a = n//2-o_sorted[0][1]
        b = n//2-e_sorted[0][1]
        print(int(a+b))
    else:
        a = n//2-o_sorted[1][1]
        b = n//2-e_sorted[0][1]
        c = n//2-o_sorted[0][1]
        d = n//2-e_sorted[1][1]
        ans = min(a+b, c+d)
        print(int(ans))


Measured memory_bytes: 24672
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int c = Integer.parseInt(in.next());
            int k = Integer.parseInt(in.next());
            int ans = 0;

            int mx = 0;
            int cnt = 0;
            mx = Math.max(a, Math.max(b, c));
            if (mx == a) {
                cnt = 1;
            } else if (mx == c) {
                mx = c;
                cnt = 3;
            } else {
                mx = b;
                cnt = 2;
            }
            for (int i = 0; i < k; i++) {
                mx *= 2;
            }

            if (cnt == 1) {
                ans = mx + b + c;
            } else if (cnt == 2) {
                ans = a + mx + c;
            } else {
                ans = a + b + mx;
            }
            // 出力
            out.println(ans);

        }

    }
}



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

using namespace std;

int main (int argc, char **argv) {
  // 整数の入力
  int a;
  vector<int> vec;

  cin >> a;

  vec.resize(a);

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

  sort(vec.begin(), vec.end());

  cout << vec[a-1] - vec[0] << endl;


  return 0;
}

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

int main() {
    int h, w; cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    for(int i=0; i<h; i++) {
        for(int j=0; j<w; j++) {
            cin >> a[i][j];
        }
    }

    vector<bool> b(h, false);
    vector<bool> c(w, false);
    for(int i=0; i<h; i++) {
        for(int j=0; j<w; j++) {
            if(a[i][j] == '#') {
                b[i] = true;
                c[j] = true;
            }
        }
    }
    for(int i=0; i<h; i++) {
        if(b[i]) {
            for(int j=0; j<w; j++) {
                if(c[j]) cout << a[i][j];
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll n; cin>>n;
	ll k; cin>>k;
	vector<ll> h(n);
	REP(i,n) {
		cin>>h[i];
		h[i]*=-1;
	}
	sort(h.begin(),h.end());
	ll sum=0;
	FOR(i,k,n){
		sum-=h[i];
	}
	cout<<sum<<endl;
	return 0;
}


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

int N;
vector<int> g[100001];
const string f = "Fennec", s = "Snuke";

bitset<100001> w, b;
int dist_w[100001], dist_b[100001];

void ok(int v, int c) {

    int p=0;
    if (c == 0) p = N-1;
    else p = 0;

    for (auto t : g[v]) {
        if (t == p) continue;
        else {
            if (c == 0 and !w[t]) {
                w[t] = 1;
                dist_w[t] = min(dist_w[t], dist_w[v] + 1);
                ok(t, c);
            }
            if (c == 1 and !b[t]) {
                b[t] = 1;
                dist_b[t] = min(dist_b[t], dist_b[v] + 1);
                ok(t, c);
            }
        }
    }
}



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

    cin >> N;

    rep(i, N) { dist_w[i] = dist_b[i] = 1e8; }

    w[0] = 1;
    b[N-1] = 1;
    dist_w[0] = 0;
    dist_b[N-1] = 0;

    rep(i, N-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    ok(0, 0);
    ok(N-1, 1);

    w[0] = 0;
    b[N-1] = 0;

    int same=0;
    for (int i=1; i<N-1; ++i) {
        if (w[i] and b[i]) {
            if (dist_w[i] > dist_b[i]) w[i] = 0;
            else if (dist_w[i] <= dist_b[i]) b[i] = 0;
        }
    }

    //cout << same << endl;

    if (w.count() == b.count()) {

        // if (same > 0) cout << f << endl;
        // else cout << s << endl;

        cout << s << endl;
    }
    else if (w.count() > b.count()) {
        cout << f << endl;
    }
    else {
        cout << s << endl;
    }

}


Measured memory_bytes: 12800
h,w,k=map(int, input().split())
c = [list(input()) for i in range(h)]
ans = 0
for i in range(2**h):
    for j in range(2**w):
        black = 0
        for i2 in range(h):
            for j2 in range(w):
                if c[i2][j2]=='#' and i>>i2&1==0 and j>>j2&1==0:
                    black +=1
        if black == k:
            ans+=1
print(ans)


Measured memory_bytes: 68356
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*Coding Space*/
ll dp[1002][1002][2][2][2]; // 0 : +   1 : - 
int main(){
  fill_n(dp[0][0][0][0], 1002*1002*2*2*2, -LLINF);
  fill_n(dp[0][0][0][0], 8,0);
  ll n,m; cin >> n >> m;
  rep(i,n){
    ll x,y,z; cin >> x >> y >> z;
    rep(tm,m+1)rep(t1,2)rep(t2,2)rep(t3,2){
      dp[i+1][tm][t1][t2][t3] = max(dp[i+1][tm][t1][t2][t3],dp[i][tm][t1][t2][t3]);
      dp[i+1][tm+1][t1][t2][t3] = max(dp[i+1][tm+1][t1][t2][t3], dp[i][tm][t1][t2][t3] + (t1==0?x:-x)+(t2==0?y:-y)+(t3==0?z:-z));
    }
  }
  ll ans = -LLINF;
  rep(a,2)rep(b,2)rep(c,2) ans = max(ans,dp[n][m][a][b][c]);
  cout << ans << endl;
}


Measured memory_bytes: 62976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

int main(void) {
	string s;
	cin >> s;
	rep(i,s.size()-1){
		if(s[i] == s[i+1]){
			cout << "Bad\n";
			return 0;
		}
	}
	cout << "Good\n";
}


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

int main(){
    int N;
    cin >> N;
    long long int A[N];
    for(int i=0; i<N; i++){
        cin >> A[i];
        if(A[i]==0){
            cout << 0 << endl;
            return 0;
        }
    }
    long long int a=1;
    long long int b=1e18;
    for(int i=0; i<N; i++){
        if(b/A[i] < a){
            cout << -1 << endl;
            return 0;
        }
        a*=A[i];
    }
    cout << a << endl;
    return 0;
}

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

typedef long long ll;
const int NMAX = 2e5 + 10;
const int MOD = 1e9 + 7;
int main(int argc, char const *argv[])
{
	char s[NMAX],t[NMAX];
	scanf("%s%s",s,t);
	int len = strlen(s);
	int ans = 0;
	for(register int i = 0;i < len;i++)
		ans += (s[i] != t[i]?1:0);
	printf("%d\n",ans );
	return 0;
}

Measured memory_bytes: 4200
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int ans=0,sum=0;
	for(int i=1;i<=n;i++){
		if(a[i]%2==0){
			sum++;
			if(a[i]%3==0||a[i]%5==0){
				ans++;
			}
		}
	}
	if(sum==ans){
		cout<<"APPROVED"<<endl;
	}else{
		cout<<"DENIED"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
s=input()
flag = True
ki=['R','U','D']
gu=['L','U','D']
for i in range(len(s)):
  if((i+1)%2==0):
    if s[i] not in gu:
      flag=False
  else:
    if s[i] not in ki:
      flag=False
if(flag==True):
  print("Yes")
else:
  print("No")
      
    

Measured memory_bytes: 3060
r, c = ARGF.gets.split.map(&:to_i)

arr= []
r.times do |i|
  arr << ARGF.gets.split.map(&:to_i)
end

vec = []
c.times do |i|
  vec << ARGF.gets.to_i
end

r.times do |i|
  sum = 0
  c.times do |j|
    sum += arr[i][j] * vec[j]
  end
  puts sum
end

Measured memory_bytes: 6124
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repm(i,m,n) for (int i = m; i < (n); i++)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  int R;
  cin >> R;
  
  if (R < 1200) {
    cout << "ABC" << endl;
  }
  else if (R < 2800) {
    cout << "ARC" << endl;
  }
  else {
    cout << "AGC" << endl;
  }
}

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

using namespace std;

int N, A;
int a[55];
long long dp[55][3003];
long long ans;

int main() {
    cin >> N >> A;
    for(int i = 1; i <= N; i++)
    	cin >> a[i];
    dp[0][0] = 1;
    for(int i = 1; i <= N; i++) {
        for(int j = i - 1; j >= 0; j--) {
            for(int k = 0; k <= 2500; k++) {
                int cur = k + a[i];
                dp[j + 1][cur] += dp[j][k];
            }
        }
    }
   	for(int i = 1; i <= N; i++) {
    	ans += dp[i][A * i];
   	}
    cout << ans;
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  ll k;
  cin>>s>>k;
  if(k==1){
    cout<<s[0]<<'\n';
  }
  else{
    rep(i,k){
      if(s[i]!='1'){
        cout<<s[i]<<'\n';
        return(0);
      }
    }
    cout<<s[k-1]<<'\n';
  }
  return(0);
}


Measured memory_bytes: 256
from math import ceil

N, A, B = map(int, input().split())
H = [int(input()) for i in range(N)]

A -= B  # 爆発は追加ダメージ扱いとする

# にぶたん
ok, ng = 10 ** 9, 0
while abs(ok - ng) > 1:
    X = (ok + ng) // 2

    h = [max(hi - B * X, 0) for hi in H]
    h = [ceil(hi / A) for hi in h]

    if sum(h) <= X:
        ok = X
    else:
        ng = X

print(ok)


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int n, q;
  string s;
  cin >> n >> q >> s;

  vector<ll> num(n, 0);
  rep(i, n-1) if(s.substr(i, 2) == "AC") ++num[i];
  num.insert(num.begin(), 0);
  rep(i, n) num[i+1] += num[i];
  vector<ll> ans(q);
  rep(i, q) {
    int l, r; cin >> l >> r;
    ans[i] = num[r-1]-num[l-1];
  }
  for(auto x : ans) cout << x << endl;
}

Measured memory_bytes: 5092
#include<stdio.h>
#include<string.h>
int main(void)
{
   int s, smt34, smt12;

   scanf("%d", &s);

   smt34 = s % 100;
   smt12 = s / 100;
   char cs[][10]= {"YYMM", "MMYY", "AMBIGUOUS", "NA"};

   if((smt34 <=12 && smt34 > 0) && (smt12 <= 12 && smt12 > 0))
      printf("%s", cs[2]);

   else if(smt12 <= 12 && smt12 > 0)
      printf("%s", cs[1]);

   else if(smt34 <=12 && smt34 > 0)
      printf("%s",cs[0]);

   else printf("%s", cs[3]);

   return 0;
   
}


Measured memory_bytes: 128
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;
typedef long long ll;

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

    int res = 0;
    if (n % (d * 2 + 1) != 0) res = n / (d * 2 + 1) + 1;
    else res = n / (d * 2 + 1);

    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
 
using namespace std;
int N;
string S;
int x[8];
int y[8];
long double slen;
int fp[8];

int fact(int);
void sum_len(int, int, long double);

int main()
{
  int i;

  cin >> N;
  for (i=0; i<N; i++) {
    cin >> x[i] >> y[i];
  }

  for (i=0; i<N; i++) fp[i] = -1;
  for (i=0; i<N; i++) {
    fp[0] = i;
    sum_len(i, 1, 0.0);
  }

  printf("%Lf\n", slen/fact(N), 0);
  return 0;
}
int fact(int m) {
  int i;
  int ret=1;
  for (i=m; i>=2; i--) {
    ret *= i;
  }
  return ret;
}

void sum_len(int p, int ni, long double lp) {
  int pn;
  int i, j;
  long double len;
  long double xlen(int, int);

// printf("%d ", p);
  if (ni>=N) {
    slen +=lp;
// printf("%Lf\n", lp);
    return;
  }

  for (pn=0; pn<N; pn++) {
    for (j=0; j<ni; j++) {
      if (fp[j] == pn) break;
    }
    if (j<ni) continue;
    fp[ni] = pn;
    len = xlen(x[p]-x[pn], y[p]-y[pn]);
    sum_len(pn, ni+1, lp+len);
  }
}
long double xlen(int p1, int p2) {
  return sqrt((long double)(p1*p1+p2*p2));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  ll n,k;
  cin >> n >> k;

  ll a[n],f[n];
  rep(i,n){
    cin >> a[i];    
  }
  rep(i,n) cin >> f[i];
  sort(a,a+n);
  sort(f,f+n);
  reverse(f,f+n);
  ll lb=-1;
  ll ub=1e18;
  while(ub-lb>1){
    ll mid=(ub+lb)/2;
    ll sum=0;
    bool ok=true;
    rep(i,n){
      sum+=max(a[i]-(mid/f[i]),0LL);
      //      cout << sum << endl;
      if(sum>k){
	ok=false;
	break;
      }
    }
    //    cout << "l u m sum " <<lb << " " << ub << " " << mid << " " << sum << endl;
    if(ok) ub=mid;
    else lb=mid;
  }
  cout << ub << endl;
  
  
  return 0;
    

}


Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<set>
#define MAX 30
#include<string>
#include<vector>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		int k;
		cin>>k;
		vector<string> vec;
		vector<int> ind;
		set<string> st;
		bool isDone[10001];
		for(int i=0;i<10001;i++){
			isDone[i] = false;
		}
		
		for(int i=0;i<n;i++){
			string s;
			cin>>s;
			vec.push_back(s);
			ind.push_back(i);
		}
		sort(vec.begin(),vec.end());
//		cout<<"---"<<endl;
		do{
			int hash = 0;
			for(int i=0;i<k;i++){
				hash = hash*10 + ind[i];
			}
			if(isDone[hash]) continue;
			isDone[hash] = true;
			string t="";
			for(int i=0;i<k;i++){
				t+=vec[ind[i]];
			}
			st.insert(t);
//			cout<<"------"<<endl;
		}while(next_permutation(ind.begin(),ind.end()));
		cout<<st.size()<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define P pair<ll,ll>
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int main(){
	ll a;
	string b;
	cin >> a >> b;
	ll ans = a * (b[0]-'0') + a/10 * (b[2]-'0') + a/100 * (b[3]-'0');
	double rest = a%10 * 0.1 * (b[2]-'0') + a%100 * 0.01* (b[3]-'0');
	cout << ans + (int)rest << endl;
}

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

int main(void){
	int H,W;
	while(1){
		cin>>H>>W;
		if(H==0&&W==0)return 0;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(i%2==0&&j%2==1)cout<<'.';
				else if(i%2==1&&j%2==0)cout<<'.';
				else cout<<'#';
			}
			cout<<endl;
		}
		cout<<endl;
	}
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
int main()
{
   
    LL n,k;
    LL count=0;
    cin>>n>>k;
    while(n--)
    {
        LL x,y;
        cin>>x>>y;
        LL dist=x*x+y*y;
        if(dist<=k*k)
            count++;
    }
    cout<<count;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	int n;cin>>n;
	vi a(n);
	rep(i,n){
		cin>>a[i];
		a[i]--;
	}
	int m=0,cnt=0;
	rep(i,n+1){
		if(m==1){
			cout<<cnt<<endl;
			return 0;
		}
		if(cnt==n){
			cout<<-1<<endl;
			return 0; 
		}
		cnt++;
		m=a[m];
	}
}

Measured memory_bytes: 768
use strict;
use warnings;

sub main {
    chomp(my $N = <STDIN>);
    chomp(my $B = <STDIN>);
    my @B = split(/ /,$B);
    print solver($N,\@B);
}
main() unless caller;

sub solver {
    my ($N,$B) = @_;
    my $ans = $B->[0] + $B->[-1];
    for my $i(0..$N-2){
        if($B->[$i] <= $B->[$i+1]){
            $ans += $B->[$i];
        }else{
            $ans += $B->[$i+1];
        }
    }
    return $ans;
}

Measured memory_bytes: 640