akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int X, Y, n, r, mod = 1000000007;
long long result = 1, rfact = 1, nrfact = 1;

long long func(int num, int count)
{
    if(count == 1)
        return num;
    long long temp;
    temp = func(num, count / 2) % mod;
    temp = (temp % mod * temp % mod) % mod;
    if(count % 2 != 0)
        temp = temp * num % mod;
    return temp;
}

int main()
{
    scanf("%d %d", &X, &Y);
    n = (X + Y) / 3;
    r = Y - n;
    if((X + Y) % 3 != 0 || min(X, Y) < n)
    {
        printf("0");
        return 0;
    }
    for(int i = 1; i <= n; i++)
    {
        result = (result * i) % mod;
    }
    for(int i = 1; i <= r; i++)
    {
        rfact = (rfact * i) % mod;
    }
    for(int i = 1; i <= n - r; i++)
    {
        nrfact = (nrfact * i) % mod;
    }
    result = (result * func(rfact, mod - 2) % mod * func(nrfact, mod - 2) % mod) % mod;
    printf("%d", result);
}

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

#define rep( i, n, m ) for (int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for (int i = ( n ); i < ( m ); i--)

int main( void ){
	int n, m;
	if(!scanf( "%d%d", &n, &m ))
		return -1;
	std::priority_queue<int> que;
	int k;
	rep( i, 0, n ){
		if(!scanf( "%d", &k ))
			return -1;
			que.push(k);
	}
	rep( i, 0, m ){
		k = que.top();
		que.pop();
		que.push(k/2);
	}
	long long int sum = 0;
	rep( i, 0, n ){
		sum+=que.top();
		que.pop();
	}
	std::cout << sum<<std::endl;
	return 0;
}


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


using namespace std;


int main(){
  int T_hp, T_atack, A_hp, A_atack;
  cin >> T_hp >> T_atack >> A_hp >> A_atack;

  int T_judge = (T_hp/A_atack) + (T_hp%A_atack == 0?0:1);
  int A_judge = (A_hp/T_atack) + (A_hp%T_atack == 0?0:1);
  if ( T_judge >=A_judge ) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3100
#include<iostream>
    using namespace std;
    int n,flag[101];
    int main()
    {
        
        cin>>n;
        for(int i=0;i<n;i++){
            int d;
            cin>>d;
            flag[d]=1;
        }
        int ans=0;
        for(int i=0;i<101;i++){
            ans+=flag[i];
        }
        cout<<ans<<endl;
    }

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=2e9;
const ll lnf=9e18;

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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

template<typename T>
struct Comb{
  vector<T> fac,finv,inv,sinv;
  // Comb() {}
  Comb(int MAX_N):fac(MAX_N,1),finv(MAX_N,1),inv(MAX_N,1),sinv(MAX_N,1) {init(MAX_N);}
  void init(int MAX_N){
    fac.assign(MAX_N,1),finv.assign(MAX_N,1),inv.assign(MAX_N,1),sinv.assign(MAX_N,1);
    sinv[0]=0;
    for(int i=2;i<MAX_N;i++){
      fac[i]=fac[i-1]*i;
      inv[i]=-inv[mod%i]*(mod/i);
      finv[i]=finv[i-1]*inv[i];
      sinv[i]=sinv[i-1]+inv[i];
    }
  }
  T com(int n,int k){ //1≦k≦n≦10^7
    if (n<k) return 0;
    if (n<0||k<0) return 0;
    return fac[n]*finv[k]*finv[n-k];
  }
  T per(int n,int k){ //1≦k≦n≦10^7
    if (n<k) return 0;
    if (n<0||k<0) return 0;
    return fac[n]*finv[n-k];
  }
};
Comb<mint> comb(300000);

int main(){
  int n; cin >> n;
  vector<ll> a(n+1);
  rep(i,n+1) cin >> a[i];
  map<int,int> mp;
  int cnt=0;
  rep(i,n+1){
    if(mp.count(a[i])) cnt=n+1-(i-mp[a[i]]+1);
    mp[a[i]]=i;
  }
  rep1(i,n+1){
    cout << mint(comb.com(n+1,i)-comb.com(cnt,i-1)) << endl;
  }
  
}

Measured memory_bytes: 17984
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
//const long long INF = 1LL << 60;
 int INF = 500000;
 int MAX = 1e5+10;
 ll mod = 1e9+7;

int main(){
  double n,k;
  cin >> n >> k;
  double win = 0,point = 0;
  for(int i=1;i<=n;i++){
    point = i;
    double count = 0;
    while(point <k){
      point*=2;
      count++;
    }
    win += (double)((1.0/n)*pow(0.5,count));
  }
  printf("%.12lf\n",win);
}

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

using namespace std;
int main()
{
    string s;
    cin>>s;
    int s1=(s[0]-'0')*10;
    s1+=(s[1]-'0');
    int s2=(s[2]-'0')*10;
    s2+=(s[3]-'0');
    if(s1>0&&s1<13){
        if(s2<13&&s2>0){
            cout<<"AMBIGUOUS"<<endl;
            return 0;
        }
        else
            cout<<"MMYY"<<endl;
            return 0;
    }
    else if(s2>0&&s2<13){
        if(s1<13&&s1>0){
            cout<<"AMBIGUOUS"<<endl;
            return 0;
        }
        else
            cout<<"YYMM"<<endl;
            return 0;
    }
    else
        cout<<"NA"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stdio.h>
#include <string.h>

#define rep(i, n) for (int i = 0; i < n; ++i)
typedef unsigned long long ll;

using namespace std;

int main()
{
    ll x;
    cin >> x;
    ll big, small;
    big = x / 500;
    x %= 500;
    small = x / 5;
    cout << big * 1000 + small * 5 << endl;
    return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    ll m = max(a, c);
    ll n = min(b, d);
    cout << max(0LL, n - m) << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int n;
  cin >> n;

  bool can = false;
  re(i, 10) {
    re(j, 10) {
      if(i * j == n) can = true;
    }
  }

  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

using namespace std;

template <long long Mod> struct ModInt { /* {{{ */
  long long v;
  constexpr ModInt(const long long x = 0) {
    v = x % Mod;
    if (v < 0) {
      v += Mod;
    }
  }
  constexpr ModInt operator+(const ModInt rhs) const { return ModInt(*this) += rhs; }
  constexpr ModInt operator-(const ModInt rhs) const { return ModInt(*this) -= rhs; }
  constexpr ModInt operator*(const ModInt rhs) const { return ModInt(*this) *= rhs; }
  constexpr ModInt operator/(const ModInt rhs) const { return ModInt(*this) /= rhs; }
  const ModInt &operator+=(const ModInt rhs) {
    v += rhs.v;
    if (v >= Mod) {
      v -= Mod;
    }
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) {
    if (v < rhs.v) {
      v += Mod;
    }
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) {
    v = v * rhs.v % Mod;
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  friend ostream &operator<<(ostream &s, ModInt<Mod> m) {
    s << m.v;
    return s;
  }
  friend istream &operator>>(istream &s, ModInt<Mod> m) {
    s >> m.v;
    return s;
  }
}; /* }}} */

const int mod = 1e9 + 7;
using modint = ModInt<mod>;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> S(N), T(M);
  for (auto &s : S) cin >> s;
  for (auto &t : T) cin >> t;

  vector<vector<modint>> dp(N + 5, vector<modint>(M + 5));
  vector<vector<modint>> dps(N + 5, vector<modint>(M + 5));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (S[i] == T[j]) {
        dp[i + 1][j + 1] = dps[i][j] + 1;
      }
      dps[i + 1][j + 1] = dps[i + 1][j] + dps[i][j + 1] - dps[i][j] +
                          dp[i + 1][j + 1];
    }
  }
  cout << dps[N][M] + 1 << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 63232
# -*- coding: utf-8 -*-
h,w = map(int, input().split())
al = [list(input()) for _ in range(h)]
cnt = 0

q = []
for hi in range(h):
    for wi in range(w):
        if al[hi][wi]=="#":
            q.append((hi,wi))

while len(q)>0:
    nq = []
    cnt += 1
    for hi,wi in q:
        for d in [[1,0],[0,1],[-1,0],[0,-1]]:
            if h>hi+d[0]>=0 and w>wi+d[1]>=0:
                if al[hi+d[0]][wi+d[1]]==".":
                    al[hi+d[0]][wi+d[1]] = "#"
                    nq.append((hi+d[0], wi+d[1]))
    q = nq

print(cnt-1)


Measured memory_bytes: 127916
#include<bits/stdc++.h>
#define ll long long
#define itn int
using namespace std;
const ll inf=12345678987654321;
const int N=101000;
const int M=200100;
int n,m,cnt;
int h[N],vis[N],ins[N];
ll dis[N];
queue<int>q;
struct node
{
	int to,nxt,val;
}a[M*2];
void add(int x,int y,itn z)
{
	a[++cnt].to=y;
	a[cnt].nxt=h[x];
	a[cnt].val=z;
	h[x]=cnt;
}
bool spfa(int x)
{
	ll curmax=0,curmin=0;
	q.push(x); dis[x]=0; ins[x]=1;
	while(!q.empty())
	{
		int now=q.front();
		q.pop();
		for(int i=h[now];i;i=a[i].nxt)
		{
			int t=a[i].to;
			if(dis[t]==inf)
			{
				dis[t]=dis[now]+a[i].val;
				curmax=max(curmax,dis[t]);
				curmin=min(curmin,dis[t]);
				if(curmax-curmin>1000000000)
					return false;
				vis[t]=1;
				if(!ins[t]) q.push(t);
			}
			else if(dis[t]!=dis[now]+a[i].val) return false;
		}
		ins[now]=0;
	}
	return true;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=100000;i++) dis[i]=inf;
	for(int i=1;i<=m;i++)
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		add(x,y,z); add(y,x,-z);
	}
	for(int i=1;i<=n;i++)
		if(!vis[i])
		{
			vis[i]=1;
			bool flag=spfa(i);
			if(!flag)
			{
				printf("No\n");
				return 0;
			}
		}
	printf("Yes\n");
	return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

template<typename T>
T gcd(T a, T b){
    if(b == 0){return a;}
    return gcd(b, a % b);
}

template<typename T>
T lcm(T a, T b){
    T g = gcd(a, b);
    return a / g * b;
}

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

    int N;
    std::cin >> N;

    ll res = 1ll;
    for(int i=0;i<N;++i){
        ll t;
        std::cin >> t;

        res = lcm(res, t);
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))
pos = 0
visit = [0] * n
move = []
loop = []
while visit[pos] != 2:
    if visit[pos] == 0:
        move.append(pos)
    else:
        loop.append(pos)
    visit[pos] += 1
    pos = a[pos] - 1
if len(move) > k:
    print(move[k]+1)
else:
    print(loop[(k-(len(move)-len(loop)))%len(loop)]+1)


Measured memory_bytes: 32864
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
    string a,b,c;
    cin >> a >> b >> c;
    if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0])cout << "YES" << endl; else cout << "NO" << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline
from itertools import combinations_with_replacement
def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N,M,Q = MI()
    a = [0]*Q
    b = [0]*Q
    c = [0]*Q
    d = [0]*Q
    for i in range(Q):
        a[i],b[i],c[i],d[i] = MI()
    dsum = 0
    max = 0

    l =list(combinations_with_replacement(range(1,M+1), N))
    for j in l:
        j = list(j)
        dsum = 0
        for k in range(Q):
            if j[b[k]-1]-j[a[k]-1] == c[k]:
                dsum += d[k]
        if max < dsum:
            max = dsum 
    print(max)




if __name__ == "__main__":
	main()

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

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

    rep(i, n) h -= a[i];
    if(h > 0) cout << "No" << endl;
    else cout << "Yes" << endl;


    return 0;
}

Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main()
{
	long int n, a, b;	//a青b赤
	cin >> n >> a >> b;
	if (a == 0) {
		cout << 0 << endl;
	}
	else {
		long int rem = n % (a + b);
		if (rem >= a) {
			cout << a*(n / (a + b)) + a << endl;
		}
		else if (rem < a) {
			cout << a*(n / (a + b)) + rem << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int32_t main(){_
    //freopen("input","r",stdin);
	int r,g,b;
	cin >> r >>  g >> b;
	int x = g*10 + b;
	if(x % 4 == 0) rc("YES");
	rc("NO");
}

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

signed main(void)
{
	int n, c, k, cnt, ans;
	long long tmp;
	cin >> n >> c >> k;
	vector<long long> t(n);
	bool ok;

	rep(i, n) cin >> t[i];
	sort(t.begin(), t.end());
	ok = true;
	ans = 0;
	cnt = 0;
	tmp = t[0];
	rep(i, n)
	{
		if (t[i] <= tmp + k)
		{
			cnt++;
			if (cnt > c)
				ok = false;
		}
		else
			ok = false;
		if (!ok)
		{
			tmp = t[i];
			ans++;
			cnt = 1;
			ok = true;
		}
	}
  	ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n, m;
	cin >> n >> m;
	
	vector<string> a(n), b(m);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	for(int i = 0; i < m; ++i) {
		cin >> b[i];
	}
	
	for(int px = 0; px < n; ++px) {
		for(int py = 0; py < n; ++py) {
			int cnt = 0;
			
			for(int tx = 0; tx < m; ++tx) {
				for(int ty = 0; ty < m; ++ty) {
					if( px + m - 1 >= n || py + m - 1 >= n ) continue;
					
					if( a[px + tx][py + ty] == b[tx][ty] ) {
						cnt++;
					}									
				}
			}
			
			if( cnt == m * m ) {
				cout << "Yes" << endl;
				return 0;
			}
		}			
	}
	
	cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<sstream>
#include<cmath>
#include<iterator>
#include<bitset>
#include<stdio.h>
using namespace std;
#define _for(i,a,b) for(int i=(a);i<(b);++i)
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
typedef long long LL;
const int INF = 1 << 30;
const int maxn = 1000005;

int n;

int main()
{

    while(~scanf("%d",&n)){
        int sum=0;
        for(int i=0;i<n;++i){
            int x;scanf("%d",&x);
            int t=x&(-x);
            sum+=log2(t);
        }
        printf("%d\n",sum);

    }


	return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut l: [isize;n],
    }

    let mut ans = 0;
    l.sort();
    for i in 0..l.len() {
        for j in 0..i {
            let ret = lower_bound(&l, l[i] + l[j], |x, y| x >= y);
            ans += ret - i as isize - 1;
        }
    }

    println!("{}", ans);
}

fn lower_bound(v: &Vec<isize>, key: isize, compare: fn(isize, isize) -> bool) -> isize {
    let mut ng = -1;
    let mut ok = v.len() as isize;
    while (ok - ng).abs() > 1 {
        let mid = (ok + ng) / 2;
        if compare(v[mid as usize], key) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    ok
}


Measured memory_bytes: 2148
#include <cstdio>
#pragma warning(disable : 4996)
int mod = 1000000007, n, m, a[109], b[109], pw[109], e[32777], t[32777], c[2][32777];
int main() {
	scanf("%d%d", &n, &m); pw[0] = 1;
	for (int i = 1; i <= 105; i++) pw[i] = 2 * pw[i - 1] % mod;
	for (int i = 0; i < m; i++) scanf("%d%d", &a[i], &b[i]), a[i]--, b[i]--;
	for (int i = 0; i < 1 << n; i++) {
		for (int j = 0; j < m; j++) {
			if ((i & (1 << a[j])) && (i & (1 << b[j]))) e[i]++;
			if ((i & (1 << a[j]) ? 1 : 0) + (i & (1 << b[j]) ? 1 : 0) == 1) t[i]++;
		}
	}
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 1 << n; j++) {
			if (!(j & (1 << i))) continue;
			for (int k = j; k > 0; k = (k - 1) & j) {
				c[i][j] = (c[i][j] + 1LL * c[i][j - k] * pw[e[k]]) % mod;
			}
			c[i][j] = (pw[e[j]] - c[i][j] + mod) % mod;
		}
	}
	int ret = 0;
	for (int i = 1; i < 1 << n; i += 2) {
		int u = (1 << n) - i - 1;
		for (int j = u; j > 0; j = (j - 1) & u) {
			if ((j & 2) && e[i | j] == e[i] + e[j]) {
				ret = (ret + 1LL * c[0][i] * c[1][j] % mod * pw[m - e[i | j] - t[i | j]]) % mod;
			}
		}
	}
	printf("%d\n", (pw[m] - ret + mod) % mod);
	return 0;
}

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

int main() {

  long long int N, K;
  cin >> N >> K;
  vector<long long int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  sort(H.begin(), H.end());
  if (K >= N) {
    cout << 0 << endl;
  }
  else {
    long long int S = 0;
    for (int i = 0; i < N - K; i++) {
      S += H.at(i);
    }
    cout << S << endl;
  }
}


Measured memory_bytes: 1792
s=list(input())
s=[int(s[i]) for i in range(len(s))]

s1=[0 for __ in range(len(s))]
s2=[0 for __ in range(len(s))]

for i in range(len(s)):
    if i%2 == 0:
        s1[i]=1
    else:
        s2[i]=1

ans1=0
ans2=0
for i in range(len(s)):
    if s1[i] != s[i]:
        ans1=ans1 + 1
    else:
        ans2=ans2 + 1
print(min(ans1,ans2))

Measured memory_bytes: 5404
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N,K = LI()
P = LI()
C = LI()

for i in range(N):
    P[i] -= 1

# 何回で自分に戻ってくるか
ret = [0]*N
for i in range(N):
    p = i
    c = 1
    while True:
        if P[p] == i:
            ret[i] = c
            break
        else:
            p = P[p]
            c += 1

val = [[0]*(N+1) for _ in range(N)]
for i in range(N):
    p = i
    temp = 0
    for j in range(1,N+1):
        p = P[p]
        temp += C[p]
        val[i][j] = temp


ans = -float('inf')
for i in range(N):
    if val[i][ret[i]] <= 0:
        temp_max = max(val[i][1:min(N,K)+1])
    else:
        temp1 = val[i][ret[i]]*(K//ret[i]) + max(val[i][:K-ret[i]*(K//ret[i])+1])
        temp2 = -float('inf')
        if K//ret[i] >= 1:
            temp2 = val[i][ret[i]]*(K//ret[i]-1) + max(val[i][:ret[i]+1])
        temp_max = max(temp1,temp2)
    ans = max(ans,temp_max)

print(ans)

Measured memory_bytes: 271376
#include <bits/stdc++.h>
using namespace std;
long long int n,ans;

void solve(long long int x){
  if( x<2 ) return;
  if( n/(x-1) == n%(x-1) ) ans += x-1;
}

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int x,a,b,c,n,f,I;
  vector<int> y;
  int dam;
  while(1){
    I=0;
    f=0;
    y.clear();
    cin >> n >> a >> b >> c >> x;
    if(n==0&&a==0&&b==0&&c==0&&x==0)break;
    for(int i=0;i<n;i++){
      cin >> dam;
      y.push_back(dam);
    }
    while(1){
      if(y[I]==x){
	I++;
	if(I==n){
	  cout << f << endl;
	  break;
	}
      }
      x=(a*x+b)%c;
      f++;
      if(f==10001){
	cout << -1 << endl;
	break;
      }
    }
  }
  return 0;
}
  

Measured memory_bytes: 1216
def joinstring(O, E) : 
  if len(O) - len(E) > 0 : 
    str = "".join([i + j for i, j in zip(O, E)])
    str += O[-1]
    return str
  else : 
    str = "".join([i + j for i, j in zip(O, E)])
  return str


O = input()
E = input()

print(joinstring(O, E))

Measured memory_bytes: 3064
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random

# List of ints
def LI(): return list(map(int, sys.stdin.readline().split()))

# Single int
def I(): return int(sys.stdin.readline())

# List, which contains Lists of chars (not strings)
def LS():return list(map(list, sys.stdin.readline().split()))

# Single List of chars (not strings)
def S(): return list(sys.stdin.readline())[:-1]

# List of "n" integers from "n" lines.
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
# List of "n" Lists of integers
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l


# Runtime Complexity: O(?)
# Space Complexity: O(?)
# Solution
A, B = LI()

low = 0
high = A * 12.5 + B * 10

min_price = float('inf')

while low <= high:
    mid = low + ((high - low) // 2)

    a = math.floor(mid * 0.08)
    b = math.floor(mid * 0.1)

    if a < A or b < B:
        low = mid + 1
    elif a == A and b == B:
        min_price = mid
        high = mid - 1
    elif a > A or b > B:
        high = mid - 1

if min_price == float('inf'):
    print(-1)
else:
    print(int(min_price))

Measured memory_bytes: 4720
N,M = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(M)]
to = set()
fr = set()
for a,b in src:
    if a == 1: to.add(b)
    if b == N: fr.add(a)
print('POSSIBLE' if to&fr else 'IMPOSSIBLE')

Measured memory_bytes: 37176
import sys 
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n,k = IL()
    a = list(IL())
    chk = [0]*n
    save = []
    current = 0
    for step in range(1,k+1):
        if chk[current]<2:
            if chk[current]==1:
                save.append(current+1)
            chk[current] += 1
            current = a[current]-1
        else:
            break
    else:
        print(current+1)
        exit()
    x = k-step+1
    x %= len(save)
    print(save[x])
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 33912
n='0'+input()

X=[]
for i in range(len(n)):
    X.append(int(n[i]))
cnt=0
i=len(n)-1
while i>=0:
    if X[i]>5:
        cnt+=10-X[i]
        X[i-1]+=1
        
    elif X[i]==5:
        cnt+=5
        if X[i-1]>=5:
            X[i-1]+=1
    else:
        cnt+=X[i]
    i-=1
print(cnt)
            

Measured memory_bytes: 13680
#include <bits/stdc++.h>
#include <boost/integer/common_factor_rt.hpp>
using namespace std;
using ll=long long;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int k;
  cin >> k;
  int sum=0;
  while(a>=b){
    b=b*2;
    sum++;
  }
  while(b>=c){
    c=c*2;
    sum++;
  }
  if(sum<=k)
  cout << "Yes" << endl;
  else
  cout << "No" << endl;
}



Measured memory_bytes: 3632
n = int(input())

def make_divisors(n):
    global divisors
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

divisors = []

make_divisors(n)

ans = 0

for i in range(len(divisors)):
    k = divisors[i]
    if n / k < k -1:
        ans += k -1

print(ans)


Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
int main(){
    long N,i;
    cin >> N;
    long min = N;
    for(i=1;i<=(1e6);i++){
        if(((N%i)==0)&&(min>(i+(N/i)-2))){
                min = (i+(N/i)-2);
        }
    }
    cout << min << endl;
}

Measured memory_bytes: 256
#import <stdio.h>
#import <stdlib.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
typedef long long Int;
int desc(const void *a, const void *b) {
    Int d = *(Int *)b - *(Int *)a;
    return (d > 0) ? 1 : (d < 0) ? -1 : 0;
}
int main() {
    Int n;
    scanf("%lld", &n);
    Int *a = (Int *)malloc(sizeof(Int) * 2*n);
    rep(i, 2 * n) scanf("%lld", a + i);
    qsort(a, 2 * n, sizeof(Int), desc);
    Int ans = 0;
    rep(i, n) ans += a[2 * i + 1];
    printf("%lld\n", ans);
}


Measured memory_bytes: 7240
s = input()
l = len(s)
fin_ans = 0
#print(s)
for i in range(2**(l-1)):###*
    ans = 0
    left = 0
    right = 1
    for j in range(l):
        if (i>>j) & 1 == 0 and right<l:
            right += 1
        elif right<l:
            ans += int(s[left:right])
            left = right
            right += 1
    ans += int(s[left:right])
    fin_ans += ans
    #print(bin(i),ans,fin_ans)
print(fin_ans)    

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

int main() {
    string s;
    cin >> s;
    int ans = 0, tmp = 0;
    rep(i, s.size()) {
        if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') {
            tmp++;
        } else {
            tmp = 0;
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    string A, B; cin >> A >> B;
    if (A.size() != B.size()) {
        cout << (A.size() > B.size() ? "GREATER" : "LESS") << "\n";
    } else if (A.at(0) == B.at(0)) {
        cout << "EQUAL" << "\n";
    } else {
        cout << (A.at(0) > B.at(0) ? "GREATER" : "LESS") << "\n";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
  long int X,Y;
  scanf("%ld %ld",&X,&Y);
  //printf("%d %d\n",X,Y);
  int count = 0;
  while(X <= Y){
    X *= 2;
    count++;
  }
  printf("%d\n",count);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int sheep = sc.nextInt();
        int wolf = sc.nextInt();
        if (sheep <= wolf)
            System.out.println("unsafe");
        else
            System.out.println("safe");
    }

}



Measured memory_bytes: 35520
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int field[100][100];
int h,w;
int dy[]={-1,0,0,1},dx[]={0,-1,1,0};
int dfs(int y,int x,int cnt){
    if(y<0||y>=h||x<0||x>=w||field[y][x]==0)return cnt;
    cnt++;
    field[y][x]=0;
    int Max=0;
    for(int i=0;i<4;i++)Max=max(dfs(y+dy[i],x+dx[i],cnt),Max);
    field[y][x]=1;
    return Max;
}
int main(){
    while(cin>>w>>h,h||w){
        for(int i=0;i<h;i++)
            for(int j=0;j<w;j++)
                cin>>field[i][j];

        int Max=0;
        for(int i=0;i<h;i++)
            for(int j=0;j<w;j++)
                Max=max(Max,dfs(i,j,0));

        cout<<Max<<endl;
    }
}

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

int main(void){
	string a;	
	while(cin >> a){
		if(cin.eof())
			break;
		int ans[2]={0};
		for(int i=0;i<a.size()-2;i++){
			if(a[i]=='J'&&a[i+1]=='O'&&a[i+2]=='I')
				ans[0]++;
			if(a[i]=='I'&&a[i+1]=='O'&&a[i+2]=='I')
				ans[1]++;
		}
		cout << ans[0] << endl;
		cout << ans[1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;


int main() {
	int N,X,T;
	scanf("%d%d%d",&N,&X,&T);
	int tmp = (N/X) + (N%X!=0);
	printf("%d",T*tmp);
}	



Measured memory_bytes: 3812
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let (h, n) = input_tuple();
    let a_vec = input_vec();
    let mut sum = 0;
    for a in a_vec {
        sum += a;
    }
    if sum >= h {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 6396
N = int(input())
P = list(map(int, input().split()))

count = 1
if N == 1:
  print(count)
else:
  min = P[0]
  if P[1] <= P[0]:
    count+=1
    min = P[1]

  for i in range(2,N):
    if P[i] <= min:
      count+=1
      min = P[i]
  print(count)


Measured memory_bytes: 24744
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int n = sc.nextInt();
		int a = 0;
		for (int i = 0; i < n; i++) a += sc.nextInt();
		System.out.println(a>=h?"Yes":"No");
	}
}


Measured memory_bytes: 50808
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
typedef long long ll;

bool judge(ll x)
{
    for(int i=1;i<=9;++i)
    {
        if(x%i==0&&x/i<=9)
            return true;
    }
    return false;
}
int main()
{
    ll n;
    cin>>n;
    cout<<(judge(n)?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def divisors(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

def main():
    N = int(readline())
    ans = 0
    for i in range(1,N+1,2):
        div = divisors(i)
        if len(div)==8:
            ans += 1

    print(ans)




if __name__ == '__main__':
    main()


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

int main()
{
  int N;
  int res=0;
  cin >> N;

  if(N<105) {
    cout << 0 << endl;
    return 0;
  }

  for(int n=105; n<=N; n++){
    if(n%2==0) continue;
    int range=(int)(sqrt(n)+1e-9);
    int cnt=0;
    for(int i=1; i<=range; i++){
      if(n%i==0) {
        cnt++;
        if(i*i != n) cnt++;
      }
    }
    if(cnt==8) res+= 1;
  }

  cout << res << endl;
}


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

using namespace std;

#define  N 100100

void solve() {

    string s;
    cin >> s;
    int n = s.size();
    if (n == 2) {
        if (s[0] == s[1]) {
            cout << "1 2" << endl;
        } else cout << "-1 -1" << endl;
        return;
    }
    for (int i = 2; i < n; i++) {
        if (s[i] == s[i - 1] || s[i] == s[i - 2] || s[i - 1] == s[i - 2]) {
            cout << i - 1 << ' ' << i + 1 << endl;
            return;
        }

    }
    cout << "-1 -1" << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifdef qwerty
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif


    int T = 1;
    //cin >> T;
    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 512
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.15f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

int binarySearch(alias pred, T)(in T[] arr, bool isLower = true)
{ 
	int ok, ng;
	if (isLower) { ok = cast(int)arr.length; ng = -1; }
	else		 { ok = -1; ng = cast(int)arr.length; }
	while (abs(ok-ng) > 1)
	{
		auto mid = (ok+ng) / 2;
		if (unaryFun!pred(arr[mid]))
			ok = mid;
		else ng = mid;
	}
	return ok;
}

void main()
{
	auto N = RD;
	auto S = RD!string;

	auto pos = new long[][](26);
	foreach (i; 0..N)
	{
		auto num = S[i] - 'a';
		pos[num] ~= i;
	}

	long ans;
	foreach (i; 0..N-1)
	{
		auto num = S[i] - 'a';
		auto pi = pos[num].binarySearch!((long a) => a > i)();
		foreach (j; pos[num][pi..$])
		{
			auto len1 = j - i;
			auto len2 = N - j;
			auto len = min(len1, len2);
			if (len <= ans) continue;
			foreach (k; 0..len)
			{
				if (S[i+k] != S[j+k]) break;
				ans = max(ans, k+1);
			}
		}
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 2428
import sys,collections;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
print(700+ s.count("o")*100)

Measured memory_bytes: 3436
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;



signed main(){
    int m;
    cin >> n >> m;
    pq(a);
    REP(i,n){
        int t;
        cin >> t;
        a.push(t);
    }
    REP(i,m){
        int t  = a.top();
        t /= 2;
        a.pop();
        a.push(t);
    }
    int ans = 0;
    REP(i,n){
        ans += a.top();
        a.pop();
    }
    print(ans);
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
using namespace std;

typedef long long ll;
const int N=1e5+5;
const ll p=1000000007;

int main()
{
    string s;
    cin>>s;
    if(s.size()%2)
    {
                cout<<"No"<<endl;
                return 0;

    }
    for(int i=0;i<s.size();i++)
    {
        if(i%2)
        {
            if(s[i]!='i')
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
        else
        {
            if(s[i]!='h')
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int dx[]={1,0,-1,0,-1,-1,1,1},dy[]={0,1,0,-1,-1,1,-1,1}; 
const int mod = 1e9+7;
const ll N = 1e5+5;

void solve(){
	int n;
	cin>>n;
	vector<int>dp(n+1,1e9),v={1};
	for(int i=6;i<=n;i*=6)v.pb(i);
	for(int i=9;i<=n;i*=9)v.pb(i);
	dp[0]=0;
	for(int i=1;i<=n;++i){
		for(int j=0;j<sz(v);++j){
			if(i-v[j]>=0){
				umin(dp[i],dp[i-v[j]]+1);
			}
		}
	}
	cout<<dp[n];


}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}

Measured memory_bytes: 3668
import java.util.Scanner;
import java.util.Arrays;

public class Main {

	static Scanner s = new Scanner(System.in);

	public static void main(String[] args) {
		int X = s.nextInt();
		int Y = s.nextInt();
		int Z = s.nextInt();
		int count = 0;

		while (X >= Y+2*Z) {
			X = X - Y - Z;
			if (0 <= X) {
				count++;
			}
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <algorithm>
#include <sstream>
#include <vector>

int main(void)
{
    int N;
    std::cin >> N;
    std::vector<int> a(N);
    for(int i=0; i<N; ++i)
    {
        std::cin >> a[i];
    }
    std::sort(a.begin(), a.end());
    int count = 0;
    for(int i=0; i<N;)
    {
        int c = 0;
        int r = a[i];
        for(int j=0; r==a[i+j] && j<N; ++j)
            ++c;
        if(c < r)
            count += c;
        else
            count += c-r;
        i += c;
    }
    std::cout << count << std::endl;
    return 0;
}


Measured memory_bytes: 768
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_E
# Combinatorial - Edit Distance (Levenshtein Distance)

a = gets.chomp
b = gets.chomp

dp = Array.new(a.length + 1) { Array.new(b.length + 1, -1) }

(0..a.length).each do |i|
  dp[i][0] = i
end
(0..b.length).each do |i|
  dp[0][i] = i
end

(1..a.length).each do |i|
  (1..b.length).each do |j|
    dp[i][j] = [dp[i - 1][j] + 1, dp[i][j - 1] + 1,
                dp[i - 1][j - 1] + (a[i - 1] == b[j - 1] ? 0 : 1)].min
  end
end

puts dp[a.length][b.length]



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

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

    string res = "Yes";
    if (s.at(0) == s.at(1) && s.at(1) == s.at(2)) res = "No";

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3596