akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


int main(void) {
  ll N;
  cin >> N;
  vector<ll> v;
  ll i;
  map<ll, ll> mp;
  
  for(i=0; i<N; i++) {
    ll a;
    cin >> a;
    
    mp[a]++;
    if(mp[a]==1) v.push_back(a);
  }
  sort(v.begin(), v.end());
  
  
  
  ll ans=0;
  for(i=(ll)v.size()-1; i>=0; i--) {
    ll t=1;
    while(v[i]>=t) t<<=1;
    
    ll itr=lower_bound(v.begin(), v.end(), t-v[i])-v.begin();
    if(v[itr]+v[i]==t) {
      if(v[itr]==v[i]) {
        ans+=mp[v[i]]/2;
      }else {
        ans+=min(mp[v[itr]], mp[v[i]]);
        mp[v[itr]]-=min(mp[v[itr]], mp[v[i]]);
      }
    }
  }
  
  pt(ans);
  
}


Measured memory_bytes: 14320
from math import sqrt
def dist(l1,l2):
  return sqrt(sum([abs((n1-n2)**2) for n1,n2 in zip(l1,l2)]))
n,d = map(int,input().split())
ll = [list(map(int,input().split())) for _ in [0]*n]
ans = 0
for i in range(n):
  for j in range(i+1,n):
    if dist(ll[i],ll[j]) == int(dist(ll[i],ll[j])):
      ans += 1
print(ans)           

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

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  cout << x*y/2 << endl;
  
  return 0;
}


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

int main()
{
	long long int k,j,b[100000],n,a[100000],i,dp[100000],min;
	cin>>n>>k;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	dp[0]=0;
	for(i=1;i<k;i++)
	{
		dp[i]=abs(a[i]-a[0]);
//		cout<<1;
	}
	for(i=k;i<n;i++)
	{
		for(j=1;j<=k;j++)
			b[j]=0;
		for(j=1;j<=k;j++)
			{
				b[j]=dp[i-j]+abs(a[i]-a[i-j]);
			//	cout<<2;
			}
		min=b[1];
		for(j=1;j<=k;j++)
			{
				if(b[j]<min)
					min=b[j];
			//	cout<<3;
			}
//		cout<<4;
		dp[i]=min;
	}
	cout<<dp[n-1];
	return 0;
}

	


Measured memory_bytes: 2304
#include <stdio.h>
#include <string.h>

void subproc(int case_number, int max_weight);

int main()
{
	int case_number, max_weight;

	for (case_number = 1; ; case_number++) {
		scanf("%d", &max_weight);

		if (max_weight == 0) {
			break;
		}

		subproc(case_number, max_weight);
	}

	return 0;
}

int prices[1001];

void subproc(int case_number, int max_weight)
{
	int i,j;
	int number;
	int max_price, max_price_weight;

	memset(prices, 0, sizeof(prices));

	scanf("%d", &number);

	for (i = 0; i < number; i++) {
		int price, weight;
		scanf("%d,%d", &price, &weight);

		for (j = max_weight; j >= 0; j--) {
			if ((j == 0 || prices[j] > 0) && j + weight <= max_weight) {
				int total_price;
				total_price = prices[j] + price;

				if (prices[j + weight] < total_price) {
					prices[j + weight] = total_price;
				}
			}
		}
	}

	max_price = 0;
	max_price_weight = 0;
	for (i = 0; i <= max_weight; i++) {
		if (prices[i] > max_price) {
			max_price = prices[i];
			max_price_weight = i;
		}
	}

	printf("Case %d:\n%d\n%d\n", case_number, max_price, max_price_weight);
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
auto const INF = (ll)1e19;

int main(){
    ll n;
    cin >> n;
    ll _min = INF;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
          	_min = min(_min,(i-1)+(n/i-1)); 
        }
    }

    cout << _min;

    return 0;
}

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

using namespace std;

const int NS = ((int)5e5 + 4) * 40;
char in[NS], s[NS], t[NS], S[NS];
int fail[NS], kmp[NS], d[NS];
int inN, sN, tN, SN;

int main(){
    scanf("%s %s", in + 1, t + 1); inN = strlen(in + 1), tN = strlen(t + 1);
    while(sN < tN * 5){
        for(int i = sN + 1; i <= sN + inN; ++i){
            s[i] = in[i - sN];
        }
        sN += inN;
    }
    for(int i = 1; i <= sN; ++i) s[sN + i] = s[i];
    sN *= 2;
    for(int i = 2, j = 1; i <= tN; ++i){
        while(j > 1 && t[i] != t[j]) j = fail[j - 1] + 1;
        if(t[i] == t[j]) fail[i] = j++;
    }
    for(int i = 1, j = 1; i <= sN; ++i){
        while(j > 1 && s[i] != t[j]) j = fail[j - 1] + 1;
        if(s[i] == t[j]){
            kmp[i] = j++;
            if(j > tN){
                j = fail[j - 1] + 1;
            }
        }
    }
    int ans = 0;
    for(int i = 1; i <= sN; ++i){
        if(kmp[i] == tN){
            d[i] = 1;
            if(i - tN >= 0) d[i] += d[i - tN];
            ans = max(ans, d[i]);
        }
    }
    memset(fail, 0, sizeof(fail));
    memset(kmp, 0, sizeof(kmp));
    memset(d, 0, sizeof(d));
    while(SN < 8000000){
        for(int i = SN + 1; i <= SN + inN; ++i){
            S[i] = in[i - SN];
        }
        SN += inN;
    }
    for(int i = 1; i <= SN; ++i) S[SN + i] = S[i];
    SN *= 2;
    for(int i = 2, j = 1; i <= tN; ++i){
        while(j > 1 && t[i] != t[j]) j = fail[j - 1] + 1;
        if(t[i] == t[j]) fail[i] = j++;
    }
    for(int i = 1, j = 1; i <= SN; ++i){
        while(j > 1 && S[i] != t[j]) j = fail[j - 1] + 1;
        if(S[i] == t[j]){
            kmp[i] = j++;
            if(j > tN){
                j = fail[j - 1] + 1;
            }
        }
    }
    int Ans = 0;
    for(int i = 1; i <= SN; ++i){
        if(kmp[i] == tN){
            d[i] = 1;
            if(i - tN >= 0) d[i] += d[i - tN];
            Ans = max(Ans, d[i]);
        }
    }
    if(Ans > ans) puts("-1");
    else printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 266496
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std;  
    using ll = long long;
    using P = pair<int,int>; 
    
    
    int main() {
     ll n,k;
     
     cin >> n>> k;
     
     
     ll b = n%k;
     
    
     
     	cout << min(b,k-b) << '\n';
        
     return 0;
    }

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var s string
  fmt.Scanf("%s", &s)
  
  ans := ""
  for _, v := range s {
    if v != 'B'{
      ans += string(v)
    }else{
      if len(ans) == 0 {
        continue
      }
      ans = ans[0:len(ans)-1]
    }
  }
  
  fmt.Printf("%s", ans)
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> ans(n,0);
    for (int i = n/2; i < n; i++) {
        ans[i] = a[i];
    }
    for (int i = (n/2-1); i >= 0; i--) {
        int sum = 0;
        for (int j = 2; j*(i+1) <= n; j++) {
            sum += ans[(i+1)*j-1];
        }
        ans[i] = abs(sum % 2 - a[i]);
    }

    vector<int> ans_;
    int ct = 0;
    rep(i,n) {
        if (ans[i] == 1) {
            ct++;
            ans_.push_back(i+1);
        }
    }
    cout << ct << endl;
    rep(i,ans_.size()) cout << ans_[i] << endl;
    return 0;
}

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

int MOD = (ll)1000000000 + 7;
ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
const int MAX = 500050;
typedef pair<int, int>P;

vector<int>v;
priority_queue<int>que;
vector<int>A, B, C;
int X, Y, Z, K;
vector<int>v1,v2,v3;
void solve() {
	REP(i, X)REP(j, 55)REP(k, 55) {
		v1.pb(A[i] + B[j] + C[k]);
	}
	REP(i, 55)REP(j, Y)REP(k, 55) {
		v2.pb(A[i] + B[j] + C[k]);
	}
	REP(i, 55)REP(j, 55)REP(k, Z) {
		v3.pb(A[i] + B[j] + C[k]);
	}
	VSORT(v1); VREVERSE(v1);
	VSORT(v2); VREVERSE(v2);
	VSORT(v3); VREVERSE(v3);
	if (v1[K - 1] > v2[K - 1] && v1[K - 1] > v3[K - 1]) {
		REP(i, K)print(v1[i]);
	}
	else if (v2[K - 1] > v3[K - 1]) {
		REP(i, K)print(v2[i]);
	}
	else REP(i, K)print(v3[i]);
	/*if (A[99] >= B[99] && A[99] >= C[99]) {
		REP(i, X)REP(j, 100)REP(k, 100) {
			que.push(A[i] + B[j] + C[k]);
		}
	}
	else if (B[99] >= C[99]) {
		REP(i, 100)REP(j, Y)REP(k, 100) {
			que.push(A[i] + B[j] + C[k]);
		}
	}
	else {
		REP(i, 100)REP(j, 100)REP(k, Z) {
			que.push(A[i] + B[j] + C[k]);
		}
	}
	REP(i, K) {
		print(que.top()); que.pop();
	}*/
}
signed main() {
	 cin >> X >> Y >> Z >> K;
	A.resize(X); B.resize(Y); C.resize(Z);
	REP(i, X)cin >> A[i];
	REP(i, Y)cin >> B[i];
	REP(i, Z)cin >> C[i];
	VSORT(A); VREVERSE(A);
	VSORT(B); VREVERSE(B);
	VSORT(C); VREVERSE(C);
	if (X <= 100 || Y <= 100 || Z <= 100) {
		REP(i, X) {
			REP(j, Y) {
				REP(k, Z) {
					que.push(A[i] + B[j] + C[k]);
				}
			}
		}
		REP(i, K) {
			print(que.top()); que.pop();
		}
	}
	//全部100個以上ある場合、二種類は必ず上位60個以内に収まる
	else {
		solve();
	}
}

Measured memory_bytes: 101860
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
vector<int> bi[100005];
int n,m,i,j,dp[100005];
void dfs(int x,int fa)
{
	int i;
	for (i=0;i<bi[x].size();i++)
	{
		if (bi[x][i]==fa) continue;
		dfs(bi[x][i],x);
		dp[x]^=dp[bi[x][i]]+1;
	}
}
int main()
{
	cin>>n;
	for (i=1;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		bi[x].push_back(y);
		bi[y].push_back(x);
	}
	dfs(1,0);
	if (dp[1]) cout<<"Alice"; else cout<<"Bob";
	return 0;
}

Measured memory_bytes: 12288
N = readline.chomp.split.map(&:to_s)[0]

if N.slice(0,2).to_i > 12 || N.slice(0,2).to_i == 0
	if N.slice(2,2).to_i > 12 || N.slice(2,2).to_i == 0
		print 'NA'
	else
		print 'YYMM'
	end
else
	if N.slice(2,2).to_i > 12 || N.slice(2,2).to_i == 0
		print 'MMYY'
	else
		print 'AMBIGUOUS'
	end
end


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

/*UnionFind--------------------------*/
class UnionFind {
using i32 = int_fast32_t;
private:
    std::vector<i32> parent;
    std::vector<i32> siz;

public:
    UnionFind(i32 sz): parent(sz), siz(sz, 1) {
        for(i32 i = 0; i < sz; ++i) parent[i] = i;
    }
    void init(i32 sz) {
        for(i32 i = 0; i < sz; ++i) parent[i] = i;
    }
    /*Member Func------*/
    /*return root id*/
    i32 root(i32 x) {
        while(parent[x] != x) {
            x = parent[x] = parent[parent[x]];
        }
        return x;
    }
    /*merge two groups*/
    bool merge(i32 x, i32 y) {
        x = root(x);
        y = root(y);
        if(x == y) return false;
        //Merge Tech
        if (siz[x] < siz[y]) std::swap(x,y);
        siz[x] += siz[y];
        parent[y] = x;
        return true;
    }
    /*同じ集合にあるか*/
    bool issame(i32 x, i32 y) {
        return (root(x) == root(y));
    }
    /*xの属する集合の大きさ*/
    i32 size(i32 x) {
        return siz[root(x)];
    }
};

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n,q,x,y;
    bool com;
    cin >> n >> q;
    UnionFind UF(n);
    rep(_, q) {
        cin >> com >> x >> y;
        if(com) {
            cout << (UF.issame(x,y) ? 1 : 0) << '\n';
        }
        else UF.merge(x,y);
    }

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3332
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	int a;
	int b;
	int k;
	
	cin >> a >> b >> k;
	
	vector<int> vec1(100);
	vector<int> vec2(100);
	
	for (int i = 0; i < 100; i++ ) {
		vec1[i] = -1000;
	}
	for (int i = 0; i < 100; i++) {
		vec2[i] = -1000;
	}
	
	for (int i = 0; i < k; i++) {
		if (a+i > b-i) {
			break;
		}
		
		vec1[i] = a + i;
		if (vec1[i] == b-i) {
			break;
		}
		vec2[i] = b - i;
	}
	
	sort(vec1.begin(), vec1.end());
	sort (vec2.begin(), vec2.end());
	
	
	for (int i = 0; i < 100; i++) {
		if (vec1[i] != -1000) {
			cout << vec1[i] << "\n";
		}
	}
	for (int i = 0; i < 100; i++) {
		if (vec2[i] != -1000) {
			cout << vec2[i] << "\n";
		}
	}
	
	return 0;
}

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

int main()
{
    int t;
    t=1;
    while(t--)
    {
        string s,t;
        cin>>s;
        cin>>t;
        int n=s.size(); int m = t.size(), ans=INT_MAX;
        int i=0,j=0;
        for(int i=0;i<=n-m;i++)
        {
            string l = s.substr(i,m);int k=0;
            for(int j=0;j<m;j++)
            {
                if(l[j]!=t[j])  k++;
            }
            ans=min(k,ans);
        }
        cout<<ans<<"\n";
    }
}

Measured memory_bytes: 3500
#include<bits/stdc++.h>
const double PI=3.14159265358979323846;
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "

int main(void){
    int a,b;cin>>a>>b;
    int sum=1;
    int cnt=0;
    for(int i=1;sum<b;){
        sum=sum+a-1;
        cnt++;
    }
    co(cnt);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
		int x,y,s;
	while(1){
		cin >>x>>y>>s;
		if(x==0&&y==0&&s==0)break;
		int k;
		int max=0;
		for(int i = 1;i<s;i++){
			for(int j=1;j<s;j++){
				if(s==i*(100+x)/100+j*(100+x)/100){
					k=i*(100+y)/100+j*(100+y)/100;
					if(k>max) max=k;
				}
			}
		}
		cout<<max <<endl;
	}


	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>

int
main (void)
{
    int k= 0;
    char wins[16]={0,};
    int win_cnt = 0;
    int ret;
    char ans[][8] = {"YES", "NO"};

    gets(wins);
    for (int i = 0; i < 15; i++) {
        if (wins[i] == 'o') {
            win_cnt++; k++;
        } else if (wins[i] == 'x') {
             k++;
        }
    }

    ret = (15-k+win_cnt >= 8) ? 0 : 1;

    printf("%s\n", ans[ret]);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define M 1000000007
#define pb push_back
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define NAYAN freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);



int dp[100][100001];
int wt[100001];
int val[100001];
int n,w;

int solve(int n,int w)
{
    if(w<0)
        return -999999999999;
    if(n<0 || w==0)
        return 0;
    if(dp[n][w]!=-1)
        return dp[n][w];

    int x=solve(n-1,w);
    int y=val[n]+solve(n-1,w-wt[n]);
    dp[n][w]=max(x,y);
    return dp[n][w];
}
signed main()
{
    boost
 //   #ifndef ONLINE_JUDGE 
 //   NAYAN
 //   #endif
   
    //int n;
    cin >> n  >> w;
   // int a[n];
    memset(dp,-1,sizeof(dp));
    int i;
    for(i=0;i<n;i++)
    {
        cin >> wt[i] >> val[i];
    }
    int ans=solve(n-1,w);
    cout << ans << endl;

}

Measured memory_bytes: 78464
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String input = sc.next();
        String[] inArray = input.split("");
        String[] outArray = new String[inArray.length];
        int count = 0;
        int inArraycount = 0;
        String currentStr = "";
        int precount = 0;
        for(int i = 0; i < inArray.length; i++) {
            currentStr = inArray[inArraycount];
            if(count == 0){
               precount = 0;
            }else{
                precount = count-1;
            }
            if(currentStr.equals("B")){
                outArray[precount] = "";//一個前の文字を空に
                count = precount;
            }else {
                outArray[count] = currentStr;
                count++;
                
            }
            inArraycount++;
        }
        
        //output
        for(int i = 0; i < outArray.length; i++){
            if(outArray[i]==null){
                 System.out.print("");
            }else{
                System.out.print(outArray[i]);      
            }
            
        }
    }
}

Measured memory_bytes: 23892
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.Exerwizerds2019
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            string s = Read();
            int rCnt = 0;
            for(int i = 0; i < n; i++)
            {
                if (s[i] == 'R') rCnt++;
            }
            if (rCnt > n - rCnt)
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#include <iostream>

int main(){
	int n, x, a, b, c, count;
	while(1){
		count = 0;
		std::cin >> n >> x;
		if(!n && !x)
			break;
		for(a=1; a + (a+1) + (a+2) <= x; a++)
			for(b=a+1; a + b + (b+1) <=x; b++)
				 for(c=b+1; a + b + c <= x && c <= n; c++)
				 	if(a + b + c == x)
				 		count++;
		std::cout << count << std::endl;
	}
	return 0;
}

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

int main() {
    long long a, b, c, d, e, n;
    cin >> n;
    cin >> a >> b >> c >> d >> e;
    long long MinMove = min(a, min(b, min(c, min(d, e))));
    long long ans = ((n + (MinMove-1)) / MinMove) + 4;
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll INFl = 1e18;
typedef pair<int,int> pii;
typedef vector<int> vi;
const int N = (1 << 20);

vi G[N];
bool odw[N];
//vi odl[N];
//int d[N];
int ans[N];

void bfs(int v) {
	odw[v] = true;
	queue<int> Q;
	Q.push(v);
	while (!Q.empty()) {
		int x = Q.front();
		Q.pop();
		for (auto it : G[x]) {
			if (!odw[it]) {
				odw[it] = true;
				ans[it] = x;
				Q.push(it);
			}
		}
	}
}

int main(){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n, m; cin >> n >> m;
	for (int i = 1; i <= m; i ++) {
		int a, b; cin >> a >> b;
		G[a].pb(b);
		G[b].pb(a);
	}
	int spojne = 0;
	for (int i = 1; i <= n; i ++) {
		if (!odw[i]) {
			bfs(i);
			spojne ++;
		}
	}
	if (spojne > 1) {
		cout << "No\n";
	}
	else {
		cout << "Yes\n";
		for (int i = 2; i <= n; i ++) {
			cout << ans[i] << '\n';
		}
	}
	
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000000 + 7
#define PI 3.14159265359

const long long INF = 100000;
typedef pair<int,int> P;
typedef long long ll;

using Graph = vector<vector<int>>;
ll A, B;
ll func(ll x) {
	return A*x / B - A * (x/B);
}
int main() {
	string S,T;
	cin >> S >> T;
	T.pop_back();

	if (S == T) cout << "Yes" << endl;
	else cout << "No" << endl;
	
}

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

#define int long long

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

signed main() {
	int N;
	cin >> N;
	vector<int> D(N);
	for (int i = 0; i < N; i++)cin >> D[i];

	int tmp = 1;
	for (int i = 0; i < N; i++) {
		tmp--;
		if (tmp < 0) {
			cout << "no" << endl;
			return 0;
		}
		tmp = max(D[i] / 10,tmp);
	}
	tmp = 1;
	for (int i = N - 1; i >= 0; i--) {
		tmp--;
		if (tmp < 0) {
			cout << "no" << endl;
			return 0;
		}
		tmp = max(D[i] / 10, tmp);
	}
	cout << "yes" << endl;
	return 0;
}


Measured memory_bytes: 5172
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb(x) push_back(x);
#define mp(x,y) make_pair(x,y)
#define mem(dp,a) memset(dp,a,sizeof dp);
#define all(a) a.begin(),a.end()
#define sall(a) sort(all(a))
#define X first
#define Y second
typedef long long int ll;
typedef pair<ll,ll> pp;

#define debug(x) cout << #x << " :: "<< x <<"\n";
#define debug2(x,y) cout << #x << " :: "<< x << "\t" << #y << " :: " << y << "\n";
#define debug3(x,y,z) cout << #x << " :: "<< x << "\t" << #y << " :: " << y << "\t" << #z << " :: " << z << "\n";
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree< pp , null_type,less< pp >, rb_tree_tag,tree_order_statistics_node_update>

ll power(ll b, ll exp){
    ll res = 1;
    while(exp > 0){
        if(exp % 2){
            res = 1LL * res * b % mod;
        }
        b = 1LL * b * b % mod;
        exp /= 2;
    }
    return res;
}

int main()
{
    boost
    ll L,R,d;
    cin >> L >> R >> d;
    cout << (R/d) - ((L-1)/d) ;
    return 0;
}


Measured memory_bytes: 3608
import java.util.*;
import java.io.*;
class Main {
    int retrunN( int n ){
        int i = 0;
        int sum = 0;
        while ( i <= n){
            sum += i++;
        }
        return sum;
    }
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        Main At = new Main();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int result = 0;
        result = At.retrunN(b - a) - b;
        System.out.println(result);

    }
}

Measured memory_bytes: 23636
N = int(input())
A =[0]*N
S =[[] for i in range(N)]
ans = 0
for i in range(N):
    A[i] = int(input())
    for j in range(A[i]):
        S[i].append(list(map(int, input().split())))
form = "0" + str(N) + "b"
for i in range(2**N):
    p = list(map(int, list(format(i,form))))
#    print([[p[j] == 0 or p[S[j][k][0]-1] == S[j][k][1] for k in range(len(S[j]))] for j in range(N)])
    if all([all([p[j] == 0 or p[S[j][k][0]-1] == S[j][k][1] for k in range(len(S[j]))]) for j in range(N)]):
        ans = max(ans,sum(p))
print(ans)

Measured memory_bytes: 3192
n,m = map(int,input().split())
array = []

for i in range(m):
  p,y = map(int,input().split())
  array.append((p,y,i))
  
array.sort()


ans = []
last_p = -1
index = 1
for i in range(m):
  p,y,j = array[i]
  
  if p != last_p:
    index = 1
    
  number = str(p).zfill(6) + str(index).zfill(6)
  ans.append((j,number))
  
  last_p = p
  index += 1
  
for t in sorted(ans):
  print(t[1])
  
  

Measured memory_bytes: 81752
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
typedef vector<pa> V;
int n,d1,d2;
V ans;
int O(pa x){
	return ((x.fi+x.se)%2+2)%2;
}
pa r45(pa x){
	if (O(x)==0) return mp((x.fi+x.se)/2,(x.fi-x.se)/2);
	else return mp((x.fi+x.se+1)/2,(x.fi-x.se+1)/2);
}
pa r045(pa x){
	return mp(x.fi+x.se,x.fi-x.se);
}
pa r145(pa x){
	return mp(x.fi+x.se-1,x.fi-x.se);
}
V solve(V a,int d1,int d2){
	if (d1>d2) swap(d1,d2);
	if (d1==0 && d2==0) return a;
	if (d1==0){
		if (d2&1){
			int cnt[2];
			cnt[0]=cnt[1]=0;
			FOR(i,0,SZ(a)-1) ++cnt[O(a[i])];
			int t=((cnt[0]>=cnt[1])?0:1);
			V ans;
			ans.clear();
			FOR(i,0,SZ(a)-1) if (O(a[i])==t) ans.pb(a[i]);
			return ans;
		}
		else{
			V a0,a1;
			a0.clear();
			a1.clear();
			FOR(i,0,SZ(a)-1)
				if (O(a[i])==0) a0.pb(r45(a[i]));
				else a1.pb(r45(a[i]));
			V ans0=solve(a0,d1,d2/2);
			V ans1=solve(a1,d1,d2/2);
			V ans;
			ans.clear();
			FOR(i,0,SZ(ans0)-1) ans.pb(r045(ans0[i]));
			FOR(i,0,SZ(ans1)-1) ans.pb(r145(ans1[i]));
			return ans;
		}
	}
	if (d1%2==1 && d2%2==1){
		int cnt[2];
		cnt[0]=cnt[1]=0;
		FOR(i,0,SZ(a)-1) ++cnt[O(a[i])];
		int t=((cnt[0]>=cnt[1])?0:1);
		V ans;
		ans.clear();
		FOR(i,0,SZ(a)-1) if (O(a[i])==t) ans.pb(a[i]);
		return ans;
	}
	if (d1%2==0 && d2%2==0){
		V a0,a1;
		a0.clear();
		a1.clear();
		FOR(i,0,SZ(a)-1)
			if (O(a[i])==0) a0.pb(r45(a[i]));
			else a1.pb(r45(a[i]));
		V ans0=solve(a0,d1/2,d2/2);
		V ans1=solve(a1,d1/2,d2/2);
		V ans;
		ans.clear();
		FOR(i,0,SZ(ans0)-1) ans.pb(r045(ans0[i]));
		FOR(i,0,SZ(ans1)-1) ans.pb(r145(ans1[i]));
		return ans;
	}
	if (d2%2!=0) swap(d1,d2);
	V a0,a1;
	a0.clear();
	a1.clear();
	FOR(i,0,SZ(a)-1)
		if (O(a[i])==0) a0.pb(r45(a[i]));
		else a1.pb(r45(a[i]));
	V ans0=solve(a0,0,d2/2);
	V ans1=solve(a1,0,d2/2);
	V ans;
	ans.clear();
	if (SZ(ans0)>=SZ(ans1)){
		FOR(i,0,SZ(ans0)-1) ans.pb(r045(ans0[i]));
	}
	else{
		FOR(i,0,SZ(ans1)-1) ans.pb(r145(ans1[i]));
	}
	return ans;
}
int main(){
	cin>>n>>d1>>d2;
	V t;
	t.clear();
	FOR(i,0,n*2-1)
		FOR(j,0,n*2-1)
			t.pb(mp(i,j));
	ans=solve(t,d1,d2);
	FOR(i,0,n*n-1) printf("%d %d\n",ans[i].fi,ans[i].se);
	return 0;
}

Measured memory_bytes: 18404
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 1001
 
void count(char *A,char *B){
  int i,j,x[N][N];
 
  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      x[i][j]=0;
    }
  }
  for(i=0; i<strlen(A); i++){
    for(j=0; j<strlen(B); j++){
      if(A[i]==B[j])x[i+1][j+1]=x[i][j]+1;
      else if(x[i][j+1]>x[i+1][j]) x[i+1][j+1]=x[i][j+1];
      else x[i+1][j+1]=x[i+1][j];
    }
  }
  printf("%d\n",x[strlen(A)][strlen(B)]);
}
 
int main(){
  int n,i,j;
  char A[N],B[N];
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%s",A);
    scanf("%s",B);
    count(A,B);
  }
 
  return 0; 
}

Measured memory_bytes: 4524
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k = map(int, read().split())
ans = 0
for i in range(1, n + 1):
    cnt = 0
    check = i
    while k > check:
        check *= 2
        cnt += 1
    if cnt == 0:
        ans += 1 / n
    else:
        ans += 0.5 ** cnt * (1 / n)
print(ans)


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


def main():
    import sys
    input = sys.stdin.readline

    a, b, c, k = map(int, input().split())
    ans = 0
    ans += min(a, k)

    k -= a

    if k > 0:
        k -= b

    if k > 0:
        ans -= k

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9072
#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;
	cin >> n;
	
	vector<int> h(n);
	for(int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	
	int diff = 0;
	int sum = 0;
	for(int i = 0; i < n - 1; ++i) {
		diff += min(h[i], h[i + 1]);
	}
	
	for(auto x : h) {
		sum += x;
	}
	
	cout << sum - diff << endl;
	
	return 0;
}


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

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a = Array.ConvertAll(line, int.Parse);
            if (a.Sum() == 0) break;
            var x = getTimes(a[0], a[1]);
            var y = getTimes(a[2], a[3]);
            var z = getTimes(a[4], a[5]);
            Console.WriteLine(Lcm(Lcm(x, y), z));
        }
    }
    public static int getTimes (int a, int m)
    {
        var rtime = 0; var x = 1;
        while (true)
        {
            var nx = (a * x) % m;
            rtime++;
            if (nx == 1) return rtime;
            else x = nx;
        }
    }
    public static int Gcd(int a, int b)
    {
        if (a < b)
            return Gcd(b, a);
        while (b != 0)
        {
            var wk = a % b;
            a = b;
            b = wk;
        }
        return a;
    }
    public static long Lcm (long a , long b)
    {
        return a * b / Gcd((int)a, (int)b);
    }
}

Measured memory_bytes: 9480
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define MOD 998244353
int a[3030];
lli dp[3030][3030];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0,s=0;lli res=0ll;
    cin>>n>>s;
    for(int i=0;i<n;++i)
        cin>>a[i];
    for(int i=0;i<n;++i)
    {
        for(int j=0;j<sizeof(dp[0]);++j)
            dp[i+1][j]=dp[i][j];
        dp[i+1][a[i]]=(dp[i+1][a[i]]+i+1)%MOD;
        for(int j=0;a[i]+j<=s;++j)
            dp[i+1][a[i]+j]=(dp[i+1][a[i]+j]+dp[i][j])%MOD;
        res=(res+dp[i+1][s])%MOD;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 71936
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long x=sc.nextLong();
		long[]a=new long[n];
		for(int i=0;i<n;i++){
			a[i]=sc.nextLong();
		}
		long sum_time=Long.MAX_VALUE;
		long[][] b=new long[n][n];
		for(int i=0;i<n;i++){
			b[0][i]=a[i];
		}
		
		for(int k=0;k<n;k++){
			if(k!=0){
			for(int i=0;i<n;i++){
				int pre=0;
				if(i-k<0)pre=i-k+n;
				else pre=i-k;
				
				b[k][i]=Math.min(b[k-1][i], a[pre]);
			}
			}
			long sum=0;
			for(int i=0;i<n;i++){
				sum+=b[k][i];
			}
			sum+=(long)k*x;
			if(sum<sum_time)sum_time=sum;
		}
		System.out.println(sum_time);
		
	}

}


Measured memory_bytes: 82632
use proconio::input;

fn main() {
    input! {
        k: u32,
        a: u32,
        b: u32,
    }

    let ans = (0..=1000).any(|m| (a..=b).contains(&(m * k)));
    println!("{}", if ans { "OK" } else { "NG" });
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
const int inf = 1001001001;

int main() {
    int n;
    cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];
    deque<int> d;
    rep(i,n) {
        int p = lower_bound(d.begin(),d.end(),a[i]) - d.begin();
        if (p == 0) d.push_front(a[i]);
        else d[p-1] = a[i];
    }
    cout << d.size() << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

#define REP(i, n) for(int i = 0; i < n; i++)
#define VREP(vec, vecs) for(auto& vec : vecs)

using namespace std;
typedef long long ll;

int main() {
	int n, m, tmp;

	while (true) {
		cin >> n >> m;
		if (!n && !m) break;

		vector<ll> count(n);

		REP(i, m) REP(j, n) {
			cin >> tmp;
			count[j] += tmp;
		}
		ll ans = 0;
		VREP(cur, count) ans = max(ans, cur);

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


Measured memory_bytes: 3048
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N;
	cin >> N;
	int ans = 1;
	vector<int>A(N);
	rep(i, N)cin >> A[i];
	rep(i, N) {
		if (A[i] == 0) {
			cout << 0;
			return 0;
		}
	}
	rep(i, N) {
		int a = log10(ans) + log10(A[i]);
		if (a > 18) {
			cout << -1;
			return 0;
		}

		if (ans * A[i] > (int)1e18) {
			cout << -1;
			return 0;
		}
		else ans *= A[i];
	}
	cout << ans;
}

Measured memory_bytes: 4112
#include <stdio.h>

int main(void) {
   int  N,A,B,C,D,price_X,price_Y,i;
   scanf( "%d %d %d %d %d" , &N,&A,&B,&C,&D );
   price_X=0;
   price_Y=0;
   i = 0 ;
   while(i < N){
	   price_X += B ;
	   i+= A ;
   }
   i = 0 ;
   while(i < N){
	   price_Y += D ;
	   i+= C ;
   }
   if( price_X < price_Y ){
	     printf("%d\n" , price_X);
      }else{
    	 printf("%d\n" , price_Y);
      }
   return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
/**
  0 1 2 3 4 5 6 7 8 9
  . . x . . x . x . . (3, 2)
  . . x . x . . x . . (2, 3)

  x . x . . . x . . x (2, 4, 3)
  x . x . . x . . . x (2, 3, 4) [3]
  x . . x . x . . . x (3, 2, 4) [2]
  x . . x . . . x . x (3, 4, 2) [3]
  */
const int maxn = 100100, lg = 62;
int p[lg][maxn], r[maxn];
long long x[maxn], d[maxn];
int main(){
	int n; cin >> n;
	for(int i = 0; i < n; i++) cin >> x[i];
	for(int i = 0; i + 1 < n; i++) d[i] = x[i + 1] - x[i];
	for(int i = 0; i < n - 1; i++) p[0][i] = i;
	int m; cin >> m;
	long long k; cin >> k;
	for(int i = 0; i < m; i++){
		int v; cin >> v; v--;
		swap(p[0][v - 1], p[0][v]);
	}
	for(int i = 1; i < lg; i++){
		for(int j = 0; j < n - 1; j++){
			p[i][j] = p[i - 1][p[i - 1][j]];
		}
	}
	for(int i = 0; i < n - 1; i++) r[i] = i;
	for(int i = lg - 1; i >= 0; i--){
		if((k>>i)&1){
			k ^= 1ll<<i;
			for(int j = 0; j < n - 1; j++){
				r[j] = p[i][r[j]];
			}
		}
	}
	assert(k == 0);
	long long now = x[0];
	cout << now << endl;
	for(int i = 0; i < n - 1; i++){
		now += d[r[i]];
		cout << now << endl;
	}
	return 0;
}


Measured memory_bytes: 27392
#include<iostream>
using namespace std;
int main(){

 	int a, b, c, x, y, n;
	n = 0;
	cin >> a >> b>> c;		
	for(x=a;x<=b;x++){
		if( c % x == 0){ n++;
		}
	}
	cout << n << endl;

	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  int a,b,k;
  cin>>a>>b>>k;
  int cnt=0;
  for(int i=min(a,b);;i--){
    if(a%i||b%i)continue;
    cnt++;
    if(cnt==k){
	 cout<<i<<endl;
	 return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<ll> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  ll L;
  cin >> L;
  vector<vector<int>> nxt(60, vector<int>(N));
  int j = 0;
  for (int i = 0; i < N; i++) {
    while (j + 1 < N && x[j + 1] - x[i] <= L) {
      ++j;
    }
    nxt[0][i] = j;
  }
  for (int k = 1; k < 60; k++) {
    for (int i = 0; i < N; i++) {
      nxt[k][i] = nxt[k - 1][nxt[k - 1][i]];
    }
  }
  int Q;
  cin >> Q;
  for (int q = 0; q < Q; q++) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    if (a > b) {
      swap(a, b);
    }
    ll res = 0;
    for (int k = 59; k >= 0; k--) {
      int a2 = nxt[k][a];
      if (a2 < b) {
        a = a2;
        res += 1ll << k;
      }
    }
    cout << (res + 1) << endl;
  }
  return 0;
}


Measured memory_bytes: 25080
#include<cstdio>

int main(){
    int n; long long p;
    scanf("%d%lld",&n,&p);
    long long ans = 1;
    for(long long i = 2; i*i <= p; i++){
        if(p%i==0){
            int cnt = 0;
            while(p%i==0) p /= i, cnt++;
            int time = cnt/n;
            for(int j = 0; j < time; j++) ans *= i;
        }
    }
    if(p!=1 && n==1) ans *= p;
    printf("%lld\n",ans);
    return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int n;
    cin >> n;
    int count = 0;
    for(int a=1;a<n;a++){
        for(int b=1;b<n;b++){
            if(n>a*b)count++;
            else break;
        }
    }
    COUT(count);
}

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

int N;
string s;
int L[500010], R[500010];
int dp[700010];

int n;
int v[1400010];

void init(int n_) {
  for (n = 1; n < n_; n <<= 1);
  for (int i = 0; i < 2*n-1; i++) v[i] = -1;
}
void update(int i, int x) {
  v[(i += n-1)] = x;
  while (i) {
    i = (i-1)/2;
    v[i] = max(v[i*2+1], v[i*2+2]);
  }
}
int query(int a, int b, int i, int l, int r) {
  if (a <= l && r <= b) return v[i];
  if (r <= a || b <= l) return -1;
  return max(query(a, b, i*2+1, l, (l+r)/2), query(a, b, i*2+2, (l+r)/2, r));
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> s;
  int l = -1, r = 0;
  while (l < N) {
    while (r < s.size() && s[r] == '1') r++;
    if (l >= 0) R[l] = r-l-1;
    L[r] = r-l-1;
    l = r++;
  }
  vector<int> ps;
  for (int i = 1; i+1 < N; i++) {
    if (s[i-1] == '1' && s[i] == '0' && s[i+1] == '1') {
      ps.emplace_back(i);
    }
  }
  if (ps.size() == 0) {
    cout << 0 << endl;
    return 0;
  }

  vector<pii> vs;
  for (int i = 0; i < ps.size(); i++) {
    int p = ps[i];
    if (i-1 >= 0 && p-L[p]-1 == ps[i-1] && L[p] > 1) {
      vs.emplace_back(pii(p-L[p]+1, p+1));
    }
    vs.emplace_back(pii(p-L[p], p+1));
    if (i+1 < ps.size() && p+R[p]+1 == ps[i+1] && R[p] > 1) {
      vs.emplace_back(pii(p-1, p+R[p]-1));
    }
    vs.emplace_back(pii(p-1, p+R[p]));
  }
  sort(vs.begin(), vs.end(), [&](pii a, pii b) {
    return a.second < b.second;
  });
  vs.erase(unique(vs.begin(), vs.end()), vs.end());

  init(vs.size());
  for (int i = 0; i < vs.size(); i++) {
    int l = 0, r = i;
    while (r-l > 1) {
      int m = (l+r)/2;
      if (vs[m].second < vs[i].first) l = m;
      else r = m;
    }
    if (vs[l].second < vs[i].first) {
      dp[i] = dp[l] + (vs[i].second-vs[i].first-1);
    } else {
      dp[i] = vs[i].second-vs[i].first-1;
    }
    dp[i] = max(dp[i], query(0, i, 0, 0, vs.size()));
    update(i, dp[i]);
  }
  cout << dp[vs.size()-1] << endl;
  
  return 0;
}

Measured memory_bytes: 15380
inpl = input()
c1 = 0
c2 = 0

for i in range(1,len(inpl)+1):
    if i % 2 != 0:
        if inpl[i-1] == '0':
            c1 += 1
    else:
        if inpl[i-1] == '1':
            c1 += 1

for i in range(1,len(inpl)+1):
    if i % 2 != 1:
        if inpl[i-1] == '0':
            c2 += 1
    else:
        if inpl[i-1] == '1':
            c2 += 1
print(c1 if c1 < c2 else c2)

Measured memory_bytes: 3188
n,l=map(int,input().split())
ans=float('inf')
for i in range(1,n+1):
  ans=min(ans,abs(l+i-1))
  
#print(ans)

s=(l*n+n*(n-1)//2)
if s<=0:
  print(s+ans)
  
else:
  print(s-ans)

Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int H = in.nextInt();
            int N = in.nextInt();
            int A = 0;
            for (int i = 0; i < N; i++) {
                A += in.nextInt();
            }
            out.println(A >= H ? "Yes" : "No");
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 31220
import numpy as np
N,Q = map(int,input().split())
S = input()
ans = np.zeros(N+1)
for i in range(N):
  ans[i+1] = ans[i] + (1 if S[i:(i+2)] == 'AC' else 0) 
for i in range(Q):
  l,r = map(int,input().split())
  print(int(ans[r-1] - ans[l-1]))


Measured memory_bytes: 14028
#include <bits/stdc++.h>
using namespace std;
bool vis[1005],used[505*505];
int p[505],N,M,a[505][505],g[505][505],qwq[505][505];vector<int> A[505],B[505];
int dfs(int now){
	for (int i=0;i<N;i++)
		if (g[now][i]&&!vis[i]){
			vis[i]=1;
			if (p[i]==-1||(dfs(p[i]))) {p[i]=now;return 1;}	
		}
		return 0;
}
int main(){
	scanf("%d%d",&N,&M);
	int x;
	for (int i=0;i<N;i++)
		for (int j=0;j<M;j++){
			scanf("%d",&a[i][j]);
			a[i][j]--;
		}
	for (int i=0;i<M;i++){//进行M-1次匹配
		for (int j=0;j<N;j++) 
			for (int k=0;k<N;k++) g[j][k]=0,qwq[j][k]=-1;
		for (int j=0;j<N;j++)
			for (int k=0;k<M;k++)
				if (!used[a[j][k]]){
					int x=a[j][k];
					g[j][x/M]=1;
					qwq[j][x/M]=x;
				}
		for (int j=0;j<N;j++) p[j]=-1;
		for (int j=0;j<N;j++){
			memset(vis,0,sizeof(vis));
			assert(dfs(j));//如果没有增广路了就退出 
		}
		for (int j=0;j<N;j++){
			int x=qwq[p[j]][j];
			assert(x!=-1);//找到与其匹配的点 
			used[x]=true;
			A[p[j]].push_back(x);
			B[i].push_back(x);
		}
	}
	for (int i=0;i<N;i++){ 
		for (int j=0;j<M;j++) printf("%d ",A[i][j]+1);
		printf("\n");
	}
	for (int i=0;i<M;i++) sort(B[i].begin(),B[i].end());
	for (int i=0;i<N;i++){
		for (int j=0;j<M;j++)
			printf("%d ",B[j][i]+1);
		printf("\n");
	}
	//puts("wqsb");
	return 0;
}

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

using namespace std;

typedef long long LL;

const int MOD = 1e9 +7;
const int N = 1e5 + 10;
int a[N], b[N];

int mypow(LL a, LL b) {
    LL ret = 1;
    while (b) {
        if (b & 1) ret = ret * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return ret;
}


int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d",  a + i);
        b[i] = abs((n - i - 1) - i);
    }
    sort(a, a + n);
    sort(b, b + n);
    bool flag = true;
    for (int i = 0; i < n; i++) if (a[i] != b[i]) {
        flag = false;
        break;
    }
    if (!flag) puts("0");
    else printf("%d\n", mypow(2, n / 2));
    return 0;
}


Measured memory_bytes: 1024
dis = [int(input()) for i in range(5)]
n,c = 10,11
for i,k in enumerate(dis):
  if c>(k%10) and k%10>=1:
    c = (k%10)
    n = i
for i,k in enumerate(dis):
  if i == n:
    continue
  else:
    if k%10==0:
      continue
    else:
      dis[i]=int(k/10)*10+10
ans = 0
for i in dis:
  ans+=i
print(ans)

Measured memory_bytes: 3064
let memoize n f =
  let dp = Hashtbl.create n in
  let rec get x =
    try Hashtbl.find dp x with
    | Not_found ->
        let result = f get x in
        Hashtbl.add dp x result;
        result in
  get

let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let dp = memoize (4 * n) @@ fun dp (i, n, b) ->
    if (i + 1) / 2 < n then -12345678901234567 else
    match (i, n, b) with
    | (_, 0, true) -> 0
    | (0, _, _) -> -12345678901234567
    | (i, n, false) -> as_.(i - 1) + dp (i - 1, n - 1, true)
    | (i, n, true) -> max (dp (i - 1, n, true)) (dp (i - 1, n, false)) in
  Printf.printf "%d\n" @@ max (dp (n, n / 2, true)) (dp (n, n / 2, false))


Measured memory_bytes: 90480
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

typedef pair<int,pii> state;

const int MAXN=3005;
int dp[MAXN][MAXN];
pii bt[MAXN][MAXN];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    string s,t; cin>>s>>t;
    FOR(i,MAXN) FOR(j,MAXN) {
        dp[i][j] = 0;
        bt[i][j] = {-1,-1};
    };

    s.append("$");
    t.append("$");

    FOR(i,s.length())
    FOR(j,t.length()) {
        int val = dp[i][j];
        pii pos = {i,j};
        dp[i+1][j] |= MAX(val);
        if(RELAXED)
            bt[i+1][j] = bt[i][j];
        dp[i][j+1] |= MAX(val);
        if(RELAXED)
            bt[i][j+1] = bt[i][j];
        if(s[i]==t[j]) {
            dp[i+1][j+1] |= MAX( val+1 );
            if(RELAXED)
                bt[i+1][j+1] = pos;
        }
    }

    cerr<<dp[s.length()][t.length()]-1<<endl;
    pii st = bt[s.length()][t.length()];
    string ans;
    while(st.first >= 0) {
        ans += s[st.first];
        st = bt[st.first][st.second];
    }
    reverse(ans.begin(), ans.end());
    ans.erase(prev(ans.end()));
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 106112