akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

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

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  string S;
  cin >> N >> S;
  int ans = 10000000;
  vector<int> black(N), white(N);
  if (S[0] == '#')
    black[0] = 1;
  else
    white[0] = 1;
  for (int i = 1; i < N; i++)
  {
    black[i] += black[i - 1];
    white[i] += white[i - 1];
    if (S[i] == '#')
      black[i]++;
    else
      white[i]++;
  }
  for (int i = 0; i <= N; i++)
  {
    int tmp = 0;
    if (i == 0)
    {
      tmp = white[N - 1];
    }
    else
    {
      tmp = black[i - 1] + (white[N - 1] - white[i - 1]);
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;

  return 0;
}

// 累積和　あるiより左を全て白　右を全て黒にするとしたときに何個変えなければいけないかを記録し最小で更新していく．
// 黒のすぐ左側に白が来てはいけないからあるiより左は全て白，右は全て黒といった状況が出来る．


Measured memory_bytes: 2196
def nCk(n, k):
    if n < k:
        return 0
    elif k == 0:
        return 1
    elif k == 1:
        return n
    elif k == 2:
        return n * (n - 1) // 2
    else:
        return n * (n - 1) * (n - 2) // 6


def solve(N, K):
    if K == 0:
        return 1

    M = len(str(N))
    hd, tl = divmod(N, 10 ** (M - 1))

    res = nCk(M - 1, K) * (9 ** K)
    if hd == 0:
        return res

    res += solve(tl, K - 1)
    res += (hd - 1) * nCk(M - 1, K - 1) * (9 ** (K - 1))

    return res


N, K = map(int, open(0).read().split())
print(solve(N, K))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";

int main(){
  ll d,g; cin >> d >> g;
  ll ans=0;
  vector<vector<ll>> v(d, vector<ll>(2, 0));
  rep(i,d){
    ll p,c; cin >> p >> c;
    v[i][0]=p; v[i][1]=c;
    ans+=p;
  }
  
  for(ll i=0; i<(1<<d); i++){
    ll zan = g;
    ll candidate = 0;
    map<ll,ll> completed;
    for(ll j=0; j<d; j++){
      if(i & (1<<j)){
        candidate+=v[j][0];
        zan -= v[j][1]+v[j][0]*(j+1)*100;
        completed[j]=1;
      }
    }
    if(zan<=0){
      ans=min(ans,candidate);
      continue;
    }
    for(ll k=d;k>0; k--){
      if(completed[k-1]==1) continue;
      for(ll q=1; q<v[k-1][0]; q++){
        candidate+=1;
        zan-=k*100;
        if(zan<=0) break;
      }
      if(zan<=0) break;
    }
    if(zan<=0) ans=min(ans, candidate); 
  }

  cout << ans;
  return 0;
}


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

int H, W;
char str[101][101];

bool in(int x, int y) {
  return 0<=x && x<W && 0<=y && y<H;
}

void dfs(int x, int y, char key) {
  /*
    for(int i=0; i<H; i++) {
      for(int j=0; j<W; j++) {
	cout << str[i][j];
      }
      cout << endl;
    }
    cout << endl;
  */
  const int dx[] = {-1,1,0,0};
  const int dy[] = {0,0,-1,1};
  
  str[y][x] = '-';
  for(int i=0; i<4; i++) {
    int nx = x+dx[i], ny = y+dy[i];
    if(in(nx, ny) && str[ny][nx] == key && str[ny][nx] != '-')
      dfs(nx, ny, key);
  }
}

int main() {
  int n, m;
  
  while(cin >> n >> m && (n|m)) {
    H = n, W = m;
    for(int i=0; i<n; i++)
      for(int j=0; j<m; j++) cin >> str[i][j];
    
    int ans = 0;
    char key;
    for(int i=0; i<n; i++) {
      for(int j=0; j<m; j++) {
	if(str[i][j] != '-') {
	  key = str[i][j];
	  dfs(j, i, key);
	  ans ++;
	}
      }
    }
    /*
    for(int i=0; i<n; i++) {
      for(int j=0; j<m; j++) {
	cout << str[i][j];
      }
      cout << endl;
    }
    */
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1944
from bisect import bisect_left
from collections import deque

n = int(input())
ans = []
ans.append(int(input()))
ans = deque(ans)
for i in range(n-1):  
  temp = int(input())
  if temp <= ans[0]:
    ans.appendleft(temp)
  else:
    ans[bisect_left(ans, temp)-1]=temp
print(len(ans))
  

Measured memory_bytes: 13124
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N, D, X; cin >> N >> D >> X;
    vector<int>A(N);
    int ans = X;
    rep(i, N) {
        cin >> A[i];
        REQ(j, 1, D+1, A[i])ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
package main

import "fmt"

func main() {
	var n int

	fmt.Scan(&n)
	dp := make([][]int, n+1, n+1)
	dp[0] = []int{0, 0, 0}

	for i := 1; i <= n; i++ {
		var a, b, c int
		fmt.Scan(&a)
		fmt.Scan(&b)
		fmt.Scan(&c)

		dp[i] = make([]int, 3, 3)
		dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a
		dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + b
		dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c
	}

	fmt.Println(max(dp[n][0], dp[n][1], dp[n][2]))
}

func max(ns ...int) int {
	if len(ns) == 1 {
		return ns[0]
	} else {
		m := max(ns[1:]...)
		if ns[0] > m {
			return ns[0]
		} else {
			return m
		}
	}
}


Measured memory_bytes: 10112
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n,m;
    scanf("%d %d", &n, &m);
    vector<int> viHeight(n);
    for (int i = 0; i < n; i++){
        scanf("%d", &viHeight[i]);
    }
    vector<char> viHigher(n, 1);  
    for(int i = 0; i < m; i++){
        int n1,n2;
        scanf("%d %d", &n1, &n2);
        if(viHeight[n1 - 1] >= viHeight[n2 - 1]){
            viHigher[n2 - 1] = 0;
        }
        if(viHeight[n1 - 1] <= viHeight[n2 - 1]){
            viHigher[n1 - 1] = 0;
        }
    }
    
    int nCount = 0;
    for(int i = 0; i < n; i++){
        nCount += viHigher[i];
    }
    printf("%d", nCount);
    return 0;
}


Measured memory_bytes: 3404
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<climits>
#include<string>
#include<sstream>

#define pii pair<int,int>
#define ll long long
#define MOD 1000000007
#define in2d(i,j,H,W)(0<=i&&i<H&&0<=j&&j<W)

using namespace std;
struct UFT{
	vector<int>par;
	int getpar(int i){
		if(par[i]==i)return i;
		return par[i]=getpar(par[i]);
	}
	void unite(int i,int j){
		int t=getpar(i);
		par[t]=getpar(j);
	}
	bool uf(int i,int j){
		return getpar(i)==getpar(j);
	}
	UFT(int n){
		par=vector<int>(n);
		for(int i=0;i<n;i++)par[i]=i;
	}
	~UFT(){
		delete &par;
	}
};
struct SegT{
	vector<ll>container;
	int n;
	void update(int i,ll x){
		int ii=i+n-1;
		container[ii]=x;
		while(ii>0){
			ii=(ii-1)/2;
			//////////////////////////////////////////
			container[ii]=max(container[2*ii+1],container[2*ii+2]);
			//////////////////////////////////////////
		}
	}
	ll get(int l,int r,int l2=0,int r2=-1,int k=0){
		if(r2==-1)r2=n;
		if(r2<=l||r<=l2)return 0;
		if(l<=l2&&r2<=r)return container[k];
		ll vl=get(l,r,l2,(l2+r2)/2,2*k+1);
		ll vr=get(l,r,(l2+r2)/2,r2,2*k+2);
		///////////////////////////
		return max(vl,vr);
		///////////////////////////
	}
	////////////////new///////////////////////
	SegT(vector<int> &A){
		n=pow(2,(int)log2(A.size())+1);
		container=vector<ll>(2*n,0);
		for(int i=0;i<A.size();i++)update(i,A[i]);
	}
	~SegT(){
		delete &container;
	}

};
int main(){
	cout<<fixed<<setprecision(11);
	int N;cin>>N;
	double ans=0;
	for(int i=1;i<=N;i++)if(i&1)ans++;
	cout<<ans/N<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

ll dp[110][100100];
ll weight[110],value[110];

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,W;
    cin>>N>>W;

    REP(i,N) cin>>weight[i]>>value[i];
    
    REP(i,110) REP(j,100100) dp[i][j]=1LL<<60;

    dp[0][0]=0;
    for(int i=0;i<N;i++){
        for(int sum_v=0;sum_v<100100;sum_v++){
            if(sum_v-value[i]>=0) chmin(dp[i+1][sum_v],dp[i][sum_v-value[i]]+weight[i]);
            chmin(dp[i+1][sum_v],dp[i][sum_v]);
        }
    }
    
    ll res=0;
    REP(i,100100) if(dp[N][i]<=W) res=i;
    cout<<res<<endl;
}


Measured memory_bytes: 86272
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;



void solve() {
    ll n, a, b;
    cin >> n >> a >> b;
    if ((b - a) % 2 == 0) {
        cout << (b - a) / 2 << endl;
    }
    else {
        ll r1 = a + (b - a - 1) / 2;
        ll r2 = (n - b + 1) + (n - (a + n - b + 1)) / 2;
        cout << min(r1, r2) << endl;
    }
}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


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

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

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

	int ans = 0;
	bool breaked = false;
	while(!breaked){
		rep(i, n){
			if(a[i] % 2 != 0) {
				breaked = true;
				break;
			}
			a[i] /= 2;
		}
		if(!breaked) ans++;
	}

	cout << ans << endl;
}


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

int main(){ 
    Int N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;

    vector<Int> vl, vr;

    rep(i,N) {
        if (S[i] == 'o') {
            vl.push_back(i);
            break;
        }
    }
    for(Int j = vl[0] + C + 1; j < N; j++) {
        if (S[j] == 'o' && vl[vl.size()-1] + C < j) {
            vl.push_back(j);
        }
    }

    rep(i,N) {
        if (S[N-1-i] == 'o') {
            vr.push_back(N-1-i);
            break;
        }
    }
    for(Int j = vr[0] - C - 1; j >= 0; j--) {
        if (S[j] == 'o' && vr[vr.size()-1] - C > j) {
            vr.push_back(j);
        }
    }

    if (vl.size() == K && vr.size() == K) {
        reverse(vr.begin(), vr.end());
        rep(i,K) {
            if (vl[i] == vr[i]) cout << vl[i] + 1 << endl;
        }
    }
}


Measured memory_bytes: 8164
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>

//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//// 任意長整数型
//using Bint = mp::cpp_int;
//// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
//
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int,int> P;

const int MOD = 1000000007;

int main(int argc, const char * argv[]) {
    ll N; cin >> N;
    if(N%2==1){
        cout << 0 << endl;
        return 0;
    }
    ll sum = 0;
    ll five = 5;
    while(2*five<=N){
        sum += N/(2*five);
        five *= 5;
    }
    cout << sum << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
const int mod = 1e9+7;
ll qpow(ll a,ll b){ll res=1;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int main()
{
    double a,l;
    cin>>l;
    a = l/3;
    printf("%.10lf\n",a*a*a);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
int a[100001];
int ans[100001];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++){		
			ans[a[i]-1]++;
			ans[a[i]]++;
			ans[a[i]+1]++;
	}

	sort(ans,ans+100001,greater<int>());
	cout<<ans[0]<<endl;
	return 0;

}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-       

n = int(input())
t = [int(input()) for i in range(n)]


def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(a, b):
	return a * b // gcd (a, b)

tmplcm = t[0]
for i in range(1,n):
    tmplcm = lcm(tmplcm,t[i])
print(tmplcm)

Measured memory_bytes: 3060
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;


int main(void){
    int N;
    cin >> N;
    vector<ll> A(N+1);
    ll dp[N+1][2];
    for(int i = 1; i <= N; i++){
        cin >> A.at(i);
    }
    
    dp[1][1] = -A.at(1) - A.at(2);
    dp[1][0] = A.at(1) + A.at(2);
    
    for(int i = 2; i <= N-1; i++){
        dp[i][1] = max(dp[i-1][1] +2 * A.at(i) - A.at(i+1), dp[i-1][0] -2 * A.at(i) - A.at(i+1) );
        dp[i][0] = max(dp[i-1][1] + A.at(i+1), dp[i-1][0] + A.at(i+1) );
    }
    
    cout << max(dp[N-1][0], dp[N-1][1]) << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	ll a, b, n;
	cin >> a >> b >> n;
	ll mx = min(b - 1, n);
	cout << mx * a / b << '\n';
 	return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




string S;
//---------------------------------------------------------------------------------------------------
int solve() {
    int N = S.length();
    int ans = 0;
    rep(i, 2, N) if (i % 2 == 0) {
        string A = S.substr(0, i / 2);
        string B = S.substr(i / 2, i / 2);
        if (A == B) ans = max(ans, i);
    }
    return ans;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> S;
    cout << solve() << endl;
}

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

					#define mp make_pair
					#define pb push_back
					#define sqr(x) (x) * (x)
					#define sors(s) sort(s.begin(), s.end())
					#define sz(s) s.size()
					#define B begin()
					#define E end()
					#define F first
					#define S second
					#define I insert
					#define N 222222
					#define M 1000000007
					
					using namespace std;
					typedef long long ll;
					typedef vector<int> vi;
					typedef pair<int,int> pii;
					typedef set<int> si;
					typedef set<string> ss;
					typedef multiset<int> mi;
					typedef map<string, int> msi;
     				typedef vector<pair<int, int>> vii;
     				int n, t, k, a[N];
					int main()
					{
						cin >> n >> k;
						for(int i = 1; i <= n; i++)
						{
							cin >> a[i];
							if(a[i] >= k) t++;
						}
						cout << t;		
					}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  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;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  set<int> s;
  rep(i, 3) {
    int a;
    cin >> a;
    s.insert(a);
  }
  int n = s.size();
  cout << n << endl;
}

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

int main() {
    int N,s=0,l,r;
    cin >> N;

    rep(i,N) {
        cin >> l >> r;
        s += r-l+1;
    }

    cout << s << endl;
}

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

int main() {
  string S;
  cin >> S;
  string T;
  cin >> T;
  bool ans = true;
  int Tim = S.size();
  for(int i = 0; i < Tim ; i++) {
    if(S.at(i) == T.at(i)) {
      continue;
    }
    else {
      ans = false;
      break;
    }
  }
  if(ans) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <stack>
#include <set>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;

void solve() {
	int n; cin >> n;
	if (n >= 30)cout << "Yes";
	else cout << "No";

}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t; cin >> t;
	// while (t--)
	solve();

}

Measured memory_bytes: 3648
a,b,c=map(int,input().split())
p=a%2!=b%2 or b%2!=c%2
a,b,c=[a+((a%2==b%2)^(a%2==c%2)),b+((b%2==a%2)^(b%2==c%2)),c+((c%2==a%2)^(c%2==b%2))]
a,b,c=sorted([a,b,c])
print((c-a)//2+(c-b)//2+p)

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
bool f[105],q[105];
int main()
{
	int n;
	int now=0;
	int ans=0;
	char s[105];
	scanf("%d",&n);
	scanf("%s",s);
	for(int i=0;i<n;i++)
	{
		f[s[i]-'a']=true;
		memset(q,false,sizeof(q));
		for(int j=i+1;j<n;j++)
		{
			q[s[j]-'a']=true;
		}
		now=0;
		for(int j=0;j<26;j++)
		{
			if(f[j]&&q[j])
			now++;
		}
		/*printf("%d ",now);
		*/ans=max(ans,now);
		/*printf("%d ",ans);
		
	*/
	}
	printf("%d\n",ans);
	return 0;
 } 

Measured memory_bytes: 256
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    K,A,B=pin()
    t=(B-A)/2
    if K<A or B-A<=2:
        print(K+1)
        return
    K-=(A-1)
    cnt=A
    p,q=K%2,K//2
    cnt+=(B-A)*q+p
    print(cnt)

#%%submit!
resolve()


Measured memory_bytes: 38256
import bisect,collections,copy,heapq,itertools,math,string
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()
x = sorted(LIST())
dx = [x[i+1]-x[i] for i in range(m-1)]
dx.sort(reverse=True)

if n >= m:
    print(0)
else:
    print(x[m-1]-x[0]-sum(dx[0:n-1]))

Measured memory_bytes: 21552
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
    int to;
    ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

int main() {
    COME_LET_THE_GAMES_BEGIN();
    string a, b;
    cin >> a >> b;
    bool x = (a == "H"), y = (b == "H");
    if (!x)y = !y;
    if (y)puts("H");
    else puts("D");
}

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

using namespace std;
long long n;
long long a[210000],pre[210000];
int  main()
{
    cin>>n;
    long long ans=0;
    pre[0]=0;
    for(long long i=1; i<=n; i++)
    {
        cin>>a[i];
        pre[i]=pre[i-1]+a[i];
    }
    sort(pre,pre+n+1);
    //for(int i=0;i<=n;i++)cout<<pre[i]<<endl;
    for(int i=0;i<=n;i++){
        long long cnt=1;
        while(i<n&&pre[i+1]==pre[i]){
            cnt++;
            i++;
        }
        ans+=(cnt*(cnt-1))/2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int myXOR(int x, int y) 
{ 
   return (x | y) & (~x | ~y); 
}
void solve() {
    int n;
    cin >> n;
    int v[n];
    for(int i=0;i<n;i++)
        cin >> v[i];
    //sort(v, v+n);
    int ans = myXOR(v[0], v[1]);
    for(int i=2;i<n;i++) {
        ans = myXOR(ans, v[i]);
    }
    if(ans == 0)
    cout << "Yes" << '\n';
    else
    cout << "No" << '\n';
    return ;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

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

int main() {
  int N,n=0;
  cin >> N;
  vector<int>d(N);
  for(int i=0;i<N;i++){
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  for(int i=N-2;i>=0;i--){
    if(d.at(i)==d.at(i+1))
      d.at(i+1)=0;
  }
  for(int i=0;i<N;i++){
    if(d.at(i)!=0)
      n++;
  }
  cout << n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long mod2 = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int N, A, B;
  cin >> N >> A >> B;

  int ans = 0;
  for (int i = 1; i <= N; i++)
  {
    int sum = 0;
    int x = i;
    while (x > 0)
    {
      sum += x % 10;
      x /= 10;
    }
    if (A <= sum && sum <= B) ans += i;
  }
  
  
  cout << ans << endl;
}

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

#define pb push_back

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll INF = (ll)1<<62;
const ll MOD = 1e9+7;

int main(){
	ll H;
	cin>>H;
	ll ans = 0, curr_n = 1;
	while(H){
		//cout<<H<<"\n";
		ans += curr_n;
		curr_n*=2;
		H/=2;
	}
	cout<<ans<<"\n";
	return 0;
}

/*
4
2 2
1 1 1 1

2
1 1

3
1 1
*/

Measured memory_bytes: 256
s = input()
if ((int(s[2]) == 1 and int(s[3]) <= 2) or (int(s[2]) == 0 and int(s[3]) != 0)) and((int(s[0]) == 1 and int(s[1]) <= 2) or (int(s[0]) == 0 and int(s[1]) != 0)):
    print("AMBIGUOUS")
elif (int(s[0]) == int(s[1]) == int(s[2]) == int(s[3]) == 0) or (int(s[0]) >= 1 and int(s[1])>=3 and int(s[2])>=1 and int(s[3])>=3) or (int(s[0])==int(s[1])==0 and int(s[2])>=1 and int(s[3])>=3) or (int(s[2])==int(s[3])==0 and int(s[0]) >= 1 and int(s[1])>=3):
    print("NA")
elif (int(s[2]) == 1 and int(s[3]) <= 2) or (int(s[2]) == 0 and int(s[3]) != 0):
    print("YYMM")
elif (int(s[0]) == 1 and int(s[1]) <= 2) or (int(s[0]) == 0 and int(s[1]) != 0):
    print("MMYY")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e6 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

ll a[N];
int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    ll k, n;
    cin >> k >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i ++) {
    	cin >> a[i];
    	if (i > 1) {
    		ans = max(ans, a[i] - a[i - 1]);
		}
	}
	ans = max(ans, k - a[n ] + a[1]);
	cout << k - ans;
    return (0);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    int64_t q;
    cin >> q;

    string s2;
    int64_t m = 0;
    for (auto _ : irange(0L, q)) {
        int64_t t;
        cin >> t;

        if (t == 1) {
            ++m;
        } else {
            int64_t f;
            char c;
            cin >> f >> c;

            if ((f + m) % 2 == 0) {
                s.push_back(c);
            } else {
                s2.push_back(c);
            }
        }
    }

    if (m % 2 > 0) {
        swap(s, s2);
    }

    for (auto c : s2 | reversed) {
        cout << c;
    }
    cout << s << endl;
}

Measured memory_bytes: 960
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!

	V<int> cost = {-1,2,5,5,4,5,6,3,7,6};
	int N,M;
	cin>>N>>M;
	V<int> ds;
	rep(i,M){
		int x;
		cin>>x;
		ds.pb(x);
	}
	V<int> dp(N+1,-1);
	V<int> use(N+1,-1);
	dp[0] = 0;
	rep(i,N){
		for(int d: ds){
			int ni = i + cost[d];
			if(ni>N) continue;
			if(make_tuple(dp[ni],use[ni]) < make_tuple(dp[i]+1,d)){
				dp[ni] = dp[i]+1;
				use[ni] = d;
			}
		}
	}
	int x = N;
	string ans;
	while(x != 0){
		ans += '0'+use[x];
		x -= cost[use[x]];
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
import sys
N, K = map(int, input().split())


d = list(map(int, input().split()))
d_set = set(d)

num_set = set([1,2,3,4,5,6,7,8,9,0])
enable = num_set - d_set
#print(type(enable))
#print(enable)


def dfs(s):
  #print(s)
  global ans
  # すでにN以上の場合はこの先を探索しない
  if s != "":
    if int(s) >= N:
      #print(s)
      ans.append(int(s))
      return

  for num in enable:
    if len(s) == 0 and num == 0:
      continue
    else:
      (dfs(s+str(num)))
    
  return

ans = []
dfs("")
#print(ans)
print(min(ans))

Measured memory_bytes: 5472
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        a: i64,
        b: i64,
    }
    puts!("{}\n", if b % a == 0 { a + b } else { b - a });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
import java.io.*;
import java.util.*;

public class Main{

    
    public static void main(String[] args){
		new Main().run();
    }

    void run(){
      Scanner sc=new Scanner(System.in);
      int N=sc.nextInt();
      long W=sc.nextLong();
      long[] w=new long[N];
      int[] v=new int[N];
      for(int i=0;i<N;++i){
          w[i]=sc.nextLong();
          v[i]=sc.nextInt();
      }
      long[] dp=new long[100001];
      Arrays.fill(dp,1L<<60);
      dp[0]=0;
      for(int i=0;i<N;++i){
          for(int j=dp.length-v[i]-1;j>=0;--j){
    	      dp[j+v[i]]=Math.min(dp[j+v[i]],dp[j]+w[i]);
          }
      }
      long ans=0;
      for(int i=0;i<dp.length;++i){
          if(dp[i]<=W)ans=Math.max(ans,i);
      }
      System.out.println(ans);
    }
}


Measured memory_bytes: 23124
#include<cstdio>
#include<list>
#include<algorithm>
using namespace std;

int main(){
    int q, x;
    char com[20];

    list<int> v;
    scanf("%d", &q);
    for(int i = 0; i < q; i++){
        scanf("%s", com);
        if(com[0] == 'i'){
            scanf("%d",&x);
            v.push_front(x);
        }else if(com[6] == 'L'){
            v.pop_back();
        }else if(com[6] == 'F'){
            v.pop_front();
        }else if(com[0] == 'd'){
            scanf("%d", &x);
            for(list<int>::iterator it = v.begin(); it != v.end(); it++){
                if(*it == x){
                    v.erase(it);
                    break;
                }
            }
        }
    }

    int i = 0;
    for(list<int>::iterator it = v.begin(); it != v.end(); it++){
        if(i++) printf(" ");
        printf("%d", *it);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 33916
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#define llong long long
#define pb(a) push_back(a)
#define SORT(strVec) sort(strVec.begin(), strVec.end());
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;

int main(){
  int N,i,ii,A,ans;
  cin>>N;
  vector<int> intVec,ansVec;
  rep(i,N){
    int a;
    cin>>a;
    intVec.push_back(a);
  }
  ans=0;
  for(ii=1;ii!=2;ii=A){
    A=intVec[ii-1];
    ansVec.push_back(A);
    ans++;
    //cout<<ans<<endl;
    if(100001<ans){
      cout<<-1<<endl;
      exit(0);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()0
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=100009;
 
// Happy Coding!



void solve(){
    int n;
    cin>>n;
    
    priority_queue<double,vector<double>,greater<double>> pq;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        pq.push(x);
    }
    if(n==0){cout<<0<<endl;return ;}
    
    
    while(pq.size()>1){
        double a=pq.top();
        pq.pop();
        double b=pq.top();
        pq.pop();
        double sum=(a+b)/2;
        pq.push(sum);
    }
    
    cout<<pq.top()<<endl;
}

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

Measured memory_bytes: 3780
chomp($n = <>);
chomp($line = <>);
@kabu = split(/ /, $line);

$money = 1000;
$buy = 0;
$start = $n - 2;

for $i (0 .. $n - 2){
	if($kabu[$i] < $kabu[$i + 1]){
		$start = $i;
		$buy = int($money / $kabu[$i]);
		$money -= $buy * $kabu[$i];
		last;
	}
}

for $i ($start .. $n - 2){
	if($kabu[$i] < $kabu[$i + 1]){
		$now = int($money / $kabu[$i]);
		$buy += $now;
		$money -= $now * $kabu[$i];
	}else{
		$money += $buy * $kabu[$i];
		$buy = 0;
	}
}

$money += $kabu[$#kabu] * $buy;

print "$money\n";


Measured memory_bytes: 4808
#include <stdio.h>

int main()
{
  int n, x, a, b, c, k;
  while (1) {
    fscanf(stdin, "%d %d", &n, &x);
    if (n==0 && x==0) break;
    k=0;
    for (a=1; a<=n; a++) {
      for (b=a+1; b<=n; b++) {
        for (c=b+1; c<=n; c++) {
          if (a+b+c==x) {
            k++;
          }
        }
      }
    }
    printf("%d\n", k);
  }
  return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
int main()
{
    int N;
    cin >> N;
    vint A(N);
    cin >> A;
    vint cmp;
    for(int bit = 0; bit < (1<<N); bit++){
        int cnt = 0;
        for(int i=0; i<N; i++){
            if(bit & (1<<i)){
                cnt += A[i];
            }
        }
        cmp.pb(cnt);
    }
    int Q;
    cin >> Q;
    REP(i,Q){
        int m;
        cin >> m;
        if(0 != count(cmp.begin(),cmp.end(),m)){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
}


Measured memory_bytes: 6960
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def main():
    n_ans = [0]*50
    n = int(input())
    if n==1:
        print(0)
        return
        
    facs = factorization(n)

    curr_n = 1
    for i in range(41):
        curr_sum = (curr_n+1)*(curr_n+2)//2
        if i < curr_sum:
            n_ans[i] = curr_n
        else:
            curr_n+=1
            n_ans[i] = curr_n
    # print(n_ans)
            
    ans = 0
    for fac in facs:
        cnt = fac[1]
        ans += n_ans[cnt]
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9512
import Control.Applicative ((<$>))
import Control.Monad (unless)
import Data.List (unfoldr)

main :: IO ()
main = do
  n <- readLn
  unless (n == 0) $ do
    print $ solve n
    main

solve :: Int -> Int
solve n = f 0 0 ls ls
  where ls = takeWhile (<= n) ps
        f ct sm [] [] = ct
        f ct sm (x:xs) [] | sm < n = ct
                          | sm == n = f (ct+1) (sm-x) xs []
                          | otherwise = f ct  (sm-x) xs []
        f ct sm (x:xs) (y:ys) | sm < n = f ct (sm+y) (x:xs) ys
                              | sm == n = f (ct+1) (sm-x) xs (y:ys)
                              | otherwise = f ct (sm-x) xs (y:ys)

ps :: [Int]
ps = 2 : unfoldr f 3
  where f x | x == 0 = Nothing
            | isP x = Just (x, x+2)
            | otherwise = f (x+2)

isP :: Int -> Bool
isP x = all ((/=0).(mod x)) . takeWhile ((<= x).(^2)) $ ps



Measured memory_bytes: 4172
#include <stdio.h>

int main(){
  int i,n,a[101],b[101],max=0,A=0,B=0,k=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %d",&a[i]);
  }
  for(i=0;i<n;i++){
    scanf(" %d",&b[i]);
  }
  for(i=0;i<n-1;i++){
    A+=a[i+1];
    B+=b[i];
    if(max<A-B){
      max=A-B;
      k=i+1;
    }
  }
  max=0;
  for(i=0;i<=k;i++){
    max+=a[i];
  }
  for(i=k;i<=n-1;i++){
    max+=b[i];
  }
  printf("%d",max);
  return 0;
}


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

int main() {
	int n, cnt = 0;
	cin >> n;
	vector < int > a(n + 1);
	for ( int i = 1; i <= n; i++ ) {
		cin >> a[i];
	}
	for ( int i = 2; i < n; i++ ) {
		if ( a[i] < a[i - 1] || a[i] < a[i + 1] ) {
			if ( a[i] > a[i - 1] || a[i] > a[i + 1] ) {
				cnt++;
			} 
		}
	}
	cout << cnt;
}


Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as V
import Data.Array.IArray (listArray, accumArray, (!))
import Data.Array.MArray
import Data.Array.ST (STUArray, runSTUArray)
import Data.Array.Unboxed (UArray)
import Data.List (sortOn, sortBy, unfoldr, partition, foldl')
import Data.Char (isSpace)
import Control.Monad.ST (ST)
import Control.Monad.Trans.State (StateT(..))
import qualified Data.ByteString.Char8 as B
import Data.Bits (shiftL, shiftR, (.|.), xor)
import Debug.Trace (trace)

-- utility functions

tr x = trace (show x) x

--   Input functions
readInt = B.readInt . B.dropWhile isSpace

readInts :: Int -> B.ByteString -> [Int]
readInts n = take n . unfoldr readInt

readIntsV :: Int -> B.ByteString -> V.Vector Int
readIntsV n = V.unfoldrN n readInt

readIntsA :: Int -> B.ByteString -> UArray Int Int
readIntsA n bs = runSTUArray $ do
  arr <- newArray_ (0,n-1)
  go arr 0 bs
  return arr
  where
    go :: STUArray s Int Int -> Int -> B.ByteString -> ST s ()
    go arr i bs
      | i==n = return ()
      | otherwise = do
        let Just (x,bs') = readInt bs
        writeArray arr i x
        go arr (i+1) bs'

readTsV :: Int -> B.ByteString -> V.Vector (Int,Int)
readTsV n = V.unfoldrN n $ runStateT ((,) <$> StateT readInt <*> StateT readInt)

readTs :: Int -> B.ByteString -> [(Int,Int)]
readTs n = take n . unfoldr readT where
  readT = runStateT ((,) <$> StateT readInt <*> StateT readInt)

-- main

calcBit :: Int -> Int -> Int -> Int
calcBit s t 0
  | odd s = (div (t-s+1) 2`mod`2) `xor` ((t-s+1)`mod`2)
  | even s = calcBit (s+1) t 0
calcBit s t i
  | samePeriod s t = calcBit' i (s`mod`m) (t`mod`m)
  | otherwise = calcBit' i (s`mod`m) (m-1) `xor` calcBit' i 0 (t`mod`m)
  where
    m = 1 `shiftL` (i+1)
    start1 = 1 `shiftL` i
    samePeriod a b = a`div`m == b`div`m
    calcBit' :: Int -> Int -> Int -> Int
    calcBit' i a' b'
      | b' < start1 = 0
      | otherwise = if even (b'-(max a' start1)+1) then 0 else (1`shiftL`i)

solv a b = foldl' (.|.) 0 [calcBit a b i| i<-[0..40]] where

main = do
  [a,b] <- map read . words <$> getLine
  print $ solv a b


Measured memory_bytes: 508
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        s: String,
        t: String,
    }

    let s = s.chars().collect::<Vec<_>>();
    let t = t.chars().collect::<Vec<_>>();

    if s.len() + 1 != t.len() {
        println!("No");
        return;
    }
    for i in 0..s.len() {
        if s[i] != t[i] {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


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

// int score(int i, int j, vector<int>&A)
// {
//     if(i > j)
//         return 0;
//     if(i + 1 == j)
//         return max(A[i] , A[j]) - min(A[i], A[j]);
//     if(dp[i][j] != INT_MIN)
//         return dp[i][j];
//     int scorei = A[i] - score(i + 1, j, A);
//     int scorej = A[j] - score(i, j - 1, A);
//     dp[i][j] = max(scorei, scorej);
//     return max(scorei, scorej);
// }

int main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    for(int i = 0; i < n; i++)
        cin >> A[i];
    vector<vector<long>> dp(n, vector<long>(n));
    for(int len = 1; len <= n; len++)
    {
        for(int i = 0; i <= n - len; i++)
        {
            int j = i + len - 1;
            if(len == 1)
                dp[i][j] = A[i];
            else if(len == 2)
                dp[i][j] = max(A[i] , A[j]) - min(A[i], A[j]);
            else
            {
                long scorei = A[i] - dp[i + 1][j];
                long scorej = A[j] - dp[i][j - 1];
                dp[i][j] = max(scorei, scorej);
            }
        }
    }
    cout << dp[0][n - 1];
    return 0;
}

Measured memory_bytes: 70656
from typing import List

n = int(input())
numbers = list(map(int, input().split()))

count = 0

def halfen(i: int)->int:
    return i >> 1

def isAllEven(l: List[int])->bool:
    for i in l:
        if(i % 2 == 1 or i == 0):
            return False
    return True

while True:
    if not isAllEven(numbers):
        break
    numbers = list(map(halfen, numbers))
    count += 1

print(count)


Measured memory_bytes: 10172
#include<stdio.h>
#include<math.h>
#include<bits/stdc++.h>

using namespace std;
int main(){
    int a,b;
    cin>>a>>b;

    int x,y,z;
    x=a+b;
    y=a-b;
    z=a*b;
    //cout<<x<<" "<<y<<" "<<z<<endl;
    y=x>y?x:y;
    z=z>y?z:y;
    cout<<z;


    return 0;


}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String []args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();

        if(n%2==0){
            String a =s.substring(0, n/2);
            String b =s.substring(n/2,n);
            if(Objects.equals(a, b)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int(i)=int (a);i<=int (b);i++)
#define ff(i,a,b) for(int(i)=int (a);i<int (b);i++)
#define F(i,a,b) for(int(i)=int (a);i>=int (b);i--)
#define foreach(i,x) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vt vector
#define ll long long
#define lower(p,x) lower_bound(all(p),x)
#define upper(p,x) upper_bound(all(p),x)
#define ms(a,x) memset(a,x,sizeof a)
#define minn(a,b,c,d) min(a,min(b,min(c,d))) 
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
const double pi=acos(-1.0);//NOTE:PI
const double eps=1e-5;
const int INF=1e9,mod=1e9+7,N=1e6+6;
ll a[N];
ll dp[55][55][2500];
ll n,k;
ll back(ll pos,ll take,ll sum){
	if(pos==n) {
		if((double)sum/take==k) return 1;
		return 0;	
	}
	if(dp[pos][take][sum]!=-1) return dp[pos][take][sum];
	return dp[pos][take][sum]=back(pos+1,take+1,sum+a[pos])+back(pos+1,take,sum);

}
int main(){
	cin>>n>>k;ms(dp,-1);
	ff(i,0,n) cin>>a[i];
	cout<<back(0,0,0);
}


Measured memory_bytes: 59648