akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;

#define int long long

signed main(){
	const int MAX = 2100;
	static int field[MAX][MAX];
	int con = 0;
	
	for(int i = 0; i < 2; i++){
		int x, y, w, h;
	
		cin>>x>>y>>w>>h;
		
		for(int j = y; j < y+h; j++){
			for(int k = x; k < x+w; k++){
				field[j][k]++;
			}
		}
	}
	
	for(int i = 0; i < MAX; i++){
		for(int j = 0; j < MAX; j++){
			if(field[i][j] == 1) con++;
		}
	}
	
	cout<<con<<endl;
}


Measured memory_bytes: 26672
n=int(input())
import collections
d=collections.defaultdict(int)
import sys
sys.setrecursionlimit(10000)

def luca(n):
    if n in d:
        return d[n]
    if n==1:
        return 1
    else:
        tmp=luca(n//2)*2+1
        d[n]=tmp
        return tmp

print(luca(n))

Measured memory_bytes: 3316
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] s=new int[n+1];
		for(int i=0; i<m; i++){
			int l=sc.nextInt()-1;
			int r = sc.nextInt()-1;
			s[l]++;
			s[r+1]--;
		}
		int count=0;
		if(s[0]>=m){
			count++;
		}
		for(int i=0; i<n-1; i++){
			s[i+1]+=s[i];
			if(s[i+1]>=m){
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 64000
#include<bits/stdc++.h>
#define PI 3.141592653589793238462
using namespace std;
typedef long long ll;
typedef long double db;
int main(){
    string s;cin>>s;
    if(s[s.length()-1]=='s'){
        cout<<s<<"es"<<endl;return 0;
    }
    else cout<<s<<"s"<<endl;
}

Measured memory_bytes: 3600
require 'set'; require 'prime'
INF=Float::INFINITY
MOD=10**9+7
n,m = gets.chomp.split.map(&:to_i)
a=Set.new
m.times do |i|
  a.add gets.chomp.to_i
end

dp=Array.new(n, 0)
dp[0] = 1
dp[1] = a.include?(1) ? 0 : 1
2.upto(n).each do |i|
  next if a.include?(i)
  dp[i] = (dp[i-1] + dp[i-2]) % MOD
end

puts dp[n] % MOD


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

using namespace std ;

int n , k ;
int arr[12] ;
int ans = 1e9 ;

void solve(int x)
{
    if(x >= n)
    {
        ans = min(ans , x) ;
        return ;
    }
    for(int i = 0 ; i <= 9 ; ++i)
    {
        if(i == 0 && x == 0)
            continue;
        if(arr[i] == 0)
            solve(x*10+i) ;
    }
    return ;
}

int main()
{
    cin>>n>>k ;
    for(int i = 0 ; i < k ; ++i)
    {
        int x ;
        cin>>x ;
        arr[x] = 1 ;
    }
    solve(0) ;
    return cout<<ans<<"\n" , 0 ;
}


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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int n, ans = 0;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            ans += a[i] * a[j];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
long long a [100010];
int main (){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%lld",&a[i]);
int zero =0;
for(int i=0;i<n;i++)if(a[i]==0) zero ++;
if(zero >0){
// a[i] contains 0
printf("0\n");
return 0;
}
long long prod =1;
for(int i=0;i<n;i++){
if(a[i ] <=1000000000000000000/ prod ){
// This condition is equivalent to prod*a[i] <=10ˆ18
prod *=a[i];
}else{
printf("-1\n");
return 0;
}
}
printf("%lld\n",prod );
}


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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

int main() {
    bool vis[4] = {0, 0, 0, 0};
    int a, b;
    cin >> a >> b;
    vis[a] = vis[b] = 1;
    cont (i, 3) {
        if (!vis[i]) {
            cout << i << ln;
        }
    }
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[[int(i) for i in input().split()] for m in range(n)]
c=[[int(i) for i in input().split()] for m in range(m)]
for i in a:
    ans=float('inf')
    for x,j in enumerate(c):
        dis=abs(i[0]-j[0])+abs(i[1]-j[1])
        if ans>dis:
            ans=dis
            point=(x+1)
    print(point)

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

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

  for (int i = 1; i <= N; i++) {
    t = floor((double)i * 1.08);
    if (N == t) {
      cout << i << endl;
      break;
    }
  }
  
  if (N != t) {
    cout << ":(" << endl;
  }
  return 0;
}


Measured memory_bytes: 3608
N = int(input())
A = [0] + list(map(int, input().split())) + [0]

dist = 0
for x, y in zip(A[:-1], A[1:]):
    dist += abs(x - y)

for i in range(1, N + 1):
    l, m, r = A[i - 1], A[i], A[i + 1]
    d = dist
    d -= abs(l - m)
    d -= abs(r - m)
    d += abs(r - l)
    print(d)

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;
ll a[maxn];
ll b[maxn];
void run_case()
{
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i + 1];
        a[i + 1] += a[i];
    }
    for (int i = 0; i < m; i++)
    {
        cin >> b[i + 1];
        b[i + 1] += b[i];
    }
    int ans = 0;
    // for (int i = 1; i <= m; i++)
    // {
    //     DBG(b[i]);
    // }
    //DBG(b[m]);
    for (int i = 0, j = m; i <= n; i++)
    {
        //  DBG(ans);
        if (a[i] > k)
            break;
        while (a[i] + b[j] > k)
        {
            j--;
            //DBG(j);
        }
        ans = max(i + j, ans);
        //DBG(ans);
    }
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 6792
A, B, C = [int(i) for i in input().split()]
t, a, s = [A, B, C]
ans = 0


while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
    if A == B == C:
        ans = -1
        break
    t = B / 2 + C / 2
    a = A / 2 + C / 2
    s = A / 2 + B / 2
    A = t
    B = a
    C = s
    ans += 1

print(ans)

Measured memory_bytes: 3064
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline

N, *ab = map(int, read().split())

if N == 2:
    print(1, 2)
    exit()

graph = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(ab)] * 2):
    graph[a].append(b)
    graph[b].append(a)

k0 = list(range(3, N + 1, 3))
k1 = list(range(1, N + 1, 3))  # 1番多い
k2 = list(range(2, N + 1, 3))

start = ab[0]
color = 1  # 1が黒
queue = deque([(start, color)])
colors = [0] * (N + 1)
colors[start] = 1
while queue:
    V, c = queue.popleft()
    c = -c
    for v in graph[V]:
        if colors[v] == 0:
            colors[v] = c
            queue.append((v, c))

black = colors.count(1)
white = N - black
three = (N - 3) // 3 + 1
if black <= three:
    b = k0[:black]
    w = k1 + k2 + k0[black:]
    answer = [b.pop() if i == 1 else w.pop() for i in colors[1:]]
    print(' '.join(map(str, answer)))
elif white <= three:
    w = k0[:white]
    b = k1 + k2 + k0[white:]
    answer = [b.pop() if i == 1 else w.pop() for i in colors[1:]]
    print(' '.join(map(str, answer)))
else:
    answer = [0] * (N + 1)
    for i in range(1, N + 1):
        if colors[i] == 1:
            if k1:
                answer[i] = k1.pop()
            else:
                answer[i] = k0.pop()
        else:
            if k2:
                answer[i] = k2.pop()
            else:
                answer[i] = k0.pop()
    print(' '.join(map(str, answer[1:])))


Measured memory_bytes: 70488
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

class segtree{
public:
	static const int N=1<<22;
	int dp_max[1<<23];
	int lazy[1<<23];
	segtree(){
		memset(dp_max,0,sizeof(dp_max));
		memset(lazy,0,sizeof(lazy));
	}

	void lazy_eval(int k){
		dp_max[k]+=lazy[k];
		if(k<N-1){
			lazy[k*2+1]+=lazy[k];
			lazy[k*2+2]+=lazy[k];
		}
		lazy[k]=0;
	}
	void lazy_upd(int k){
		dp_max[k]=max(dp_max[k*2+1],dp_max[k*2+2]);
	}

	void update(int a,int b,int v,int k=0,int l=0,int r=N){
		lazy_eval(k);
		if(r<=a || b<=l)return;
		if(a<=l && r<=b){
			lazy[k]+=v;
			lazy_eval(k);
			return;
		}
		int mid=(l+r)/2;
		update(a,b,v,k*2+1,l,mid);
		update(a,b,v,k*2+2,mid,r);
		lazy_upd(k);
	}

	int find(int v,int k=0,int l=0,int r=N){
		lazy_eval(k);
		if(l+1==r){
			return l;
		}
		int pos;
		int mid=(l+r)/2;
		lazy_eval(k*2+1);
		if(dp_max[k*2+1]>=v){
			pos=find(v,k*2+1,l,mid);
			lazy_eval(k*2+2);
		}else{
			pos=find(v,k*2+2,mid,r);
			lazy_eval(k*2+1);
		}
		lazy_upd(k);
		return pos;
	}

	int find2(int v,int k=0,int l=0,int r=N){
		lazy_eval(k);
		if(l+1==r){
			return dp_max[k];
		}
		int val;
		int mid=(l+r)/2;
		lazy_eval(k*2+1);
		if(mid>v){
			val=find2(v,k*2+1,l,mid);
			lazy_eval(k*2+2);
		}else{
			val=find2(v,k*2+2,mid,r);
			lazy_eval(k*2+1);
		}
		lazy_upd(k);
		return val;
	}
};

int m,n;
int a[2500005],b[2500005];
segtree seg;

void init(){
	int m0,n0,md,nd;
	scanf("%d%d%d%d%d%d",&m,&n,&m0,&md,&n0,&nd);
	a[0]=m0;
	b[0]=n0;
	for(int i=1;i<m;i++){
		a[i]=(a[i-1]*58+md)%(n+1);
	}
	for(int i=1;i<n;i++){
		b[i]=(b[i-1]*58+nd)%(m+1);
	}
	sort(a,a+m);
}

int main(void){
	init();
	for(int i=0;i<m;i++){
		seg.update(i,i+1,a[i]);
	}
	ll ans=0;
	sort(b,b+n);
	reverse(b,b+n);
	for(int i=0;i<n;i++){
		if(b[i]==0)break;
		int cnt=seg.find(1);
		//printf("cnt%d %d\n",cnt,m-cnt);

		ans+=max(min(m-cnt,b[i]),0);
		if(m-cnt<=b[i]){
			seg.update(cnt,m,-1);
		}else{
			int vmin=seg.find2(m-b[i]);
			int p1=seg.find(vmin);
			int p2=seg.find(vmin+1);
			//printf("%d %d %d\n",p1,p2,vmin);
			seg.update(p2,m,-1);
			seg.update(p1,p1+b[i]-max(0,(m-p2)),-1);
		}
	}
	printf("%lld\n",ans);
	return 0;
}


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

 
int main() {
   int p,q,r;
   cin>>p>>q>>r;

   int ans=min(r+q,min(p+q,p+r));
   cout<<ans<<endl;
}

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

int main(){
  char S[11],T[12];
  cin >> S >> T;
  
  for (int i=0;S[i]!='\0';++i){
    if (S[i]!=T[i]){
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  long long N;
  cin >> N;
  vector<long long> a(N), ans(N);
  rep(i, N)
  {
    cin >> a[i];
  }
  long long S;
  S = a[0];
  rep(i, N - 1)
  {
    S = S xor a[i + 1];
  }
  rep(i, N)
  {
    ans[i] = S xor a[i];
  }
  rep(i, N)
  {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 6332
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
#define N_ 101000
vector<int>E[N_];
int n, Deg[N_], D[N_];
void DFS(int a, int pp) {
	int i;
	for (i = 0; i < E[a].size(); i++) {
		int x = E[a][i];
		if (x == pp)continue;
		DFS(x, a);
	}
	vector<int>T;
	int s = 0;
	for (i = 0; i < E[a].size(); i++) {
		int x = E[a][i];
		if (x == pp)continue;
		T.push_back(D[x]);
		s += D[x];
	}
	if (!pp) {
		int c = 0;
		for (i = 0; i < T.size(); i++)if (!T[i])c++;
		D[a] = s + max(c - 1, 0);
	}
	else {
		int c = 0;
		for (i = 0; i < T.size(); i++)if (!T[i])c++;
		D[a] = s + max(c - 1, 0);
	}
}
int main() {
	int i, a, b;
	scanf("%d", &n);
	for (i = 1; i < n; i++) {
		scanf("%d%d", &a, &b);
		a++, b++;
		E[a].push_back(b);
		E[b].push_back(a);
		Deg[a]++, Deg[b]++;
	}
	int Mx = 0, root = 0;
	for (i = 1; i <= n; i++) {
		if (Deg[i] > Mx)Mx = Deg[i], root = i;
	}
	if (Mx <= 2) {
		printf("%d\n", 1);
		return 0;
	}
	DFS(root, 0);
	printf("%d\n", D[root]);
}

Measured memory_bytes: 14976
#include <iostream>

int main()
{
    std::string T;
    std::cin >> T;

    for (int i = 0; i < T.length(); ++i)
    {
        bool ok = true;
        if ((i % 2) == 0) {
            // 偶数
            switch (T[i])
            {
            case 'R':
            case 'U':
            case 'D':
                break;
            default:
                ok = false;
                break;
            }
        }
        else {
            switch (T[i]) {
            case 'L':
            case 'U':
            case 'D':
                break;
            default:
                ok = false;
                break;
            }
        }
        if (ok == false) {
            std::cout << "No";
            return 0;
        }
    }

    std::cout << "Yes";
    return 0;
}


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

using namespace std;

int find(vector<int>& nodes, int x){
    if(nodes[x]==x) return x;
    int new_x=find(nodes, nodes[x]);
    nodes[x]=new_x;
    return new_x;
}

void unite(vector<int>& nodes, int x, int y){
    int new_x=find(nodes, x);
    int new_y=find(nodes, y);
    nodes[new_x]=new_y;
}

int main(){
    int n, m; cin >> n >> m;
    vector<pair<int, int>> edges(m);
    for(int i=0; i<m; ++i){
        int a, b; cin >> a >> b;
        --a; --b;
        edges[i]=make_pair(a, b);
    }
    vector<int> nodes(n);
    for(int i=0; i<n; ++i){
        nodes[i]=i;
    }

    vector<int> size(n, 1);
    vector<long long> ans(m);
    ans[m-1]=(long long)n*((long long)n-1)/2;
    for(int i=m-2; i>=0; --i){
        int a=edges[i+1].first;
        int b=edges[i+1].second;
        int g_a=find(nodes, a);
        int g_b=find(nodes, b);
        if(g_a==g_b){
            ans[i]=ans[i+1];
        } else{
            long long s_a=size[g_a];
            long long s_b=size[g_b];
            ans[i]=ans[i+1]-s_a*s_b;
            unite(nodes, a, b);
            size[g_a]+=s_b;
            size[g_b]+=s_a;
        }
    }

    for(int i=0; i<m; ++i){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3712
#include<cstdio>
#include<algorithm>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
#define _rep(i,s,t) for(register int i=s;i>=t;--i)
#define Rep(i,s,t) for(register int i=s;i<t;++i)
using namespace std;
namespace IO{
    #define gc getchar()
    #define pc(x) putchar(x)
    template<typename T>inline void read(T &x){
        x=0;int f=1;char ch=gc;
        while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=gc;}
        while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=gc;
        x*=f;return;
    }
    template<typename T>inline void write(T x=0){
        T wr[51];wr[0]=0;
        if(x<0)pc('-'),x=-x;
        if(!x)pc(48);
        while(x)wr[++wr[0]]=x%10,x/=10;
        while(wr[0])pc(48+wr[wr[0]--]);
        return;
    }
}
using IO::read;
using IO::write;
const int N=2e6+11;
int n,m,lg2,x,y,tot;
int a[N],b[N],c[N],p[N],sz[N],fac[N],ifac[N];
int nxt[N],las[N],to[N];
inline void add(int x,int y){
	nxt[++tot]=las[x];
	las[x]=tot;
	to[tot]=y;
}
const int mod=924844033;
inline int fp(int a,int b=mod-2,int res=1){
	if(b>=mod-1)b-=mod-1;
	if(b<0)b+=mod-1;
	while(b){
		if(b&1)res=1ll*res*a%mod;
		a=1ll*a*a%mod,b>>=1;
	}
	return res;
}
inline void dft(int *a,int n,int f){
	Rep(i,0,n)
		if(i<p[i])
			swap(a[i],a[p[i]]);
	for(register int i=1,gn;i<n;i<<=1){
		gn=fp(5,(mod-1)/(i<<1)*f);
		for(register int j=0,w;w=1,j<n;j+=(i<<1))
			for(register int k=j,x,y;k<i+j;++k,w=1ll*w*gn%mod){
				x=a[k],y=1ll*w*a[i+k]%mod;
				a[k]=(x+y)%mod,a[i+k]=(x-y+mod)%mod;
			}
	}
	if(f==-1){
		int inv=fp(n);
		Rep(i,0,n)
			a[i]=1ll*a[i]*inv%mod;
	}
}
inline void dfs(int x,int fa){
	sz[x]=1;
	for(register int e=las[x];e;e=nxt[e]){
		if(to[e]==fa)continue;
		dfs(to[e],x);
		sz[x]+=sz[to[e]];
		--a[n-sz[to[e]]];
		--a[sz[to[e]]];
	}
}
int main(){
	scanf("%d",&n);
	rep(i,2,n){
		scanf("%d%d",&x,&y);
		add(x,y),add(y,x);
	}
	dfs(1,0);
	fac[0]=1;
	rep(i,1,n)
		fac[i]=1ll*fac[i-1]*i%mod;
	ifac[n]=fp(fac[n],mod-2);
	_rep(i,n,1)
		ifac[i-1]=1ll*i*ifac[i]%mod;
	a[n]=n;
	rep(i,0,n)
		b[i]=1ll*(mod+a[n-i])*fac[n-i]%mod;
	rep(i,0,n)
		c[i]=ifac[i];
	int d=1,lg=-1;
	for(;d<=n+n;d<<=1,++lg);
	Rep(i,0,d)
		p[i]=(p[i>>1]>>1)|((i&1)<<lg);
	dft(b,d,1),dft(c,d,1);
	Rep(i,0,d)
		a[i]=1ll*b[i]*c[i]%mod;
	dft(a,d,-1);
	int ans;
	rep(i,1,n){
		ans=1ll*a[n-i]*ifac[i]%mod;
		ans=(ans+mod)%mod;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 38144
class Node:
    def __init__(self, data):
        self.data = data
        self.next = None

class HashTable:
    def __init__(self, capacity):
        capacity = 2**capacity
        self.table = [None]*capacity
        self.mask = capacity - 1
    
    def insert(self, data):
        node = Node(data)
        remainder = hash(data) & self.mask
        node.next, self.table[remainder] = self.table[remainder], node
    
    def find(self, data):
        remainder = hash(data) & self.mask
        node = self.table[remainder]
        while node:
            if node.data == data:
                return True
            node = node.next
        return False      

    
if __name__ == "__main__":
    n = int(input())
    dictionary = HashTable(20)
    for _ in range(n):
        operation, string = input().split()
        if operation == "insert":
            dictionary.insert(string)
            continue
        print("yes" if dictionary.find(string) else "no")


Measured memory_bytes: 143124
#include<bits/stdc++.h>
//#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
#define data data1
// std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// int myRand(int R) {
// 	int val=rng() % R;
//       assert(val>=0);
//       return val;
// }
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int MOD=MOD1;

int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      { 
           int n,k;
           cin>>n>>k;
           int a[n];
           rep(i,0,n)cin>>a[i];
           sort(a,a+n);
           int sum=accumulate(a,a+k,0LL);  
           cout<<sum<<endl;
      }      
      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 3652
#include<iostream>
#include<climits>
#include<cmath>
using namespace std;
int main(){
  long long int n;
  cin >> n;
  long long int m = 10e12;
  for(long long int i=1; i<=10e6; i++){
    if(n % i == 0){
      long long int tmp = (i-1) + (n/i -1);
      if(tmp < m){
          m = tmp;
      }
    }
  }
  cout << m << endl;
  return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] L = new int[3];
        Arrays.setAll(L, i -> sc.nextInt());
        Arrays.sort(L);
        int res = L[2] - L[1];
        L[1] = L[2];
        L[0] += res;
        int inc = (int)Math.ceil((double)(L[2] - L[0]) / 2.0);
        res += inc;
        L[0] += inc * 2;
        if(L[0] > L[1]) res++;
        System.out.println(res);
    }
}


Measured memory_bytes: 28244
gets.to_i.times do
  num = 0.0
  bits = gets.hex

  (7..30).each do |i|
    num += 2 ** (i - 7) * bits[i]
  end

  6.downto(0)do |i|
    num += 0.5 ** (7 - i) * bits[i]
  end

  num *= (-1)**bits[31]

  p num
end

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

using namespace std;

int main(int argc, char *argv[]) {
	set<char> chars = {
		'a',
		'b',
		'c',
		'd',
		'e',
		'f',
		'g',
		'h',
		'i',
		'j',
		'k',
		'l',
		'm',
		'n',
		'o',
		'p',
		'q',
		'r',
		's',
		't',
		'u',
		'v',
		'w',
		'x',
		'y',
		'z'
	};

	string s;
	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		chars.erase(s[i]);
	}

	if (chars.size() == 0) {
		cout << "None" << endl;
	} else {
		cout << *(chars.begin()) << endl;
	}
	return 0;
}


Measured memory_bytes: 512
n,w=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
dp=[[float('inf')]*(10**5+1) for i in range(n+1)]
dp[0][0]=0
for i in range(1,n+1):
  for j in range(10**5+1):
    if j-l[i-1][1]>=0:
      dp[i][j]=min(dp[i-1][j-l[i-1][1]]+l[i-1][0],dp[i][j])
    dp[i][j]=min(dp[i][j],dp[i-1][j])
for i in range(10**5+1):
  if w>=dp[n][10**5-i]:
    print(10**5-i)
    exit()

Measured memory_bytes: 312376
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;

int digitsum(int n){
    int answer = 0;
    while(n!=0){
        answer+=n%10;
        n/=10;
    }
    return answer;
}
int main(){
    int n;
    cin >> n;
    int answer = __INT32_MAX__;

    FOR(i,1,n/2+1){
        answer=min(answer,digitsum(i)+digitsum(n-i));
    }
    cout << answer << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<stdio.h>
using namespace std;

#define rep(i,n) for(long long i = 0; i < n; i++)

typedef long long ll;
typedef unsigned long long int ulli;

const ll INF = ll(1e18) + 1;

//--------------------------------------------------

ulli gcd(ulli a, ulli b) {
	return (b <= 0) ? a : gcd(b, a % b);
}

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

//---------------------------------------------------
typedef pair<int, int> P;

void Main()
{
	int bingo[3][3], n;
	int ok[3][3];
	rep(i, 3)rep(j, 3) {
		cin >> bingo[i][j];
		ok[i][j] = 0;
	}
	cin >> n;
	vector<int> b(n);
	rep(i, n) {
		cin >> b[i];
		rep(k, 3)rep(j, 3) {
			if (b[i] == bingo[k][j]) ok[k][j] = 1;
		}
	}
	auto isBingo = [&](int a, int b, int c, int d, int e, int f) {
		if (ok[a][b] && ok[c][d] && ok[e][f]) return true;
		else return false;
	};

	if (isBingo(0, 0, 0, 1, 0, 2)) {
		cout << "Yes" << endl;
		return;
	}
	if (isBingo(0, 0, 1, 0, 2, 0)) {
		cout << "Yes" << endl;
		return;
	}if (isBingo(1, 0, 1, 1, 1, 2)) {
		cout << "Yes" << endl;
		return;
	}if (isBingo(2, 0, 2, 1, 2, 2)) {
		cout << "Yes" << endl;
		return;
	}if (isBingo(1, 1, 2, 1, 2, 1)) {
		cout << "Yes" << endl;
		return;
	}if (isBingo(0, 2, 1, 2, 2, 2)) {
		cout << "Yes" << endl;
		return;
	}
	if (isBingo(0, 0, 1, 1, 2, 2)) {
		cout << "Yes" << endl;
		return;
	}
	if (isBingo(2, 0, 1, 1, 0, 2)) {
		cout << "Yes" << endl;
		return;
	}

	cout << "No" << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	Main();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{

  int money,friend,price;

  scanf("%d %d %d",&money,&friend,&price);
 

  if(money-price >= 0) printf("0\n");
  if( (money-price) < 0 && friend >= -1*(money-price)) printf("%d\n",-1*(money-price));
  if(money-price < 0 && friend < -1*(money-price)) printf("NA\n");
						       
  return 0;

}

Measured memory_bytes: 1804
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

map<int,int> a;
int main(){
    int ai;
    int ans=1;
    rep(i,3){
        cin>>ai;
        ++a[ai];
    }
    cout<<a.size()<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int m,f,r,gr;
	char a[8]=" ABCDEF";
	while(1)	{
		scanf("%d %d %d",&m,&f,&r);
		if(m==-1 && f==-1 && r==-1)	break;
		gr=6;
		if(m+f>=30)	gr=4;
		if(gr==4 && r>=50)	gr=3;
		if(m+f>=50)	gr=3;
		if(m+f>=65)	gr=2;
		if(m+f>=80)	gr=1;
		if(m==-1 || f==-1)	gr=6;
		printf("%c\n",a[gr]);
	}
	return 0;
}


Measured memory_bytes: 2748
#include <bits/stdc++.h>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF=INT_MAX;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const int MAX_SIZE=400007;
LL segMax[MAX_SIZE - 1], segAdd[MAX_SIZE - 1];
int n;

//??????[a, b)??????x???????????????.
void add(int a, int b, int x, int k = 0, int l = 0, int r = n)
{
	if (r <= a || b <= l) return;
	
	if (a <= l && r <= b){
		segAdd[k] += x;
		while (k){
			k = (k - 1) / 2;
			segMax[k] = max(segMax[k * 2 + 1] + segAdd[k * 2 + 1], segMax[k * 2 + 2] + segAdd[k * 2 + 2]);
		}
		return;
	}
	
	add(a, b, x, k * 2 + 1, l, (l + r) / 2); 
	add(a, b, x, k * 2 + 2, (l + r) / 2, r); 
}

LL getMax(int a, int b, int k = 0, int l = 0, int r = n)
{
	if (r <= a || b <= l) return 0LL;
	
	if (a <= l && r <= b) return (segMax[k] + segAdd[k]); 
	
	LL left = getMax(a, b, k * 2 + 1, l, (l + r) / 2);
	LL right = getMax(a, b, k * 2 + 2, (l + r) / 2, r); 
	
	return (max(left, right) + segAdd[k]);
	
}
int main(){
	CLR(segMax);CLR(segAdd);
	int N;
	cin>>N;
	n=100003;
	REP(i,N){
		int l,r;
		cin>>l>>r;
		add(l,r+1,1);
	}
	int res=0;
	REP(i,100002){
		if(getMax(i,i+1)+1>=i){
			res=i;
		}
		//if(i<=10)cout<<i<<" "<<getMax(i,i+1)<<endl;
	}
	
	cout<<res-1<<endl;
	return 0;
}

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

#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <iterator>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define INF (1 << 30)
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back

#if DEBUG
#define _DEBUG(x) cout << #x << ": " << x << endl
#define _DDEBUG(x, y) cout << #x << ": " << x << ", " << #y << ": " << y << endl
#else
#define _DEBUG(x) ;
#define _DDEBUG(x, y) ;
#endif

#define ll long long
#define ull unsigned long long
#define MOD 1000000007

/** FOR VECTOR DEBUG */
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v)
{
    if (!v.empty())
    {
        out << '[';
        copy(v.begin(), v.end(), ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

/* template end */

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

    int arr[3];
    REP(i, 3)
    cin >> arr[i];

    int ans = INF;
    for (int i = 0; i < 3; i++)
    {
        int b = (i + 1) % 3;
        int c = (i + 2) % 3;
        ans = min(ans,
                  min(abs(arr[i] - arr[b]) + abs(arr[b] - arr[c]),
                      abs(arr[i] - arr[c]) + abs(arr[b] - arr[c])));
    }

#if DEBUG
    cout << "** RESULT **" << endl; // debug
#endif
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

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

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

mint f(int n){ 
  if(n == 0)return 1;
  mint x = f(n / 2); 
  x *= x; 
  if(n % 2 == 1)x *= 2;
  return x;
}

mint choose(int n, int a){
  mint x = 1, y = 1;
  for(int i = 0; i < a; ++i){
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}

mint fact[1010];
mint inv_fact[1010];
void init(){
  fact[0] = 1;
  for(int i = 1; i < 1010; ++i){
    fact[i] = fact[i - 1] * i;
  }

  inv_fact[1010 - 1] = fact[1010 - 1].inv();
  for(int i = 1010 - 1; i >= 1; --i){
    inv_fact[i - 1] = inv_fact[i] * i;
  }
}

mint comb(int n, int k){
  if(n < k)return 0;
  else return fact[n] * inv_fact[n - k] * inv_fact[k];
}

mint mod_pow(mint n, ll k){
  if(k == 0)return 1;
  mint a = mod_pow(n, k / 2);
  a *= a;
  if(k % 2)a *= n;
  return a;
}

int main(){
  init();
  int n, k;
  cin >> n >> k;

  mint ans = mod_pow((mint)k, n);
  for(int i = 1; i <= k; ++i){
    if(i % 2)ans -= comb(k, i) * mod_pow((mint)(k - i), n);
    else ans += comb(k, i) * mod_pow((mint)(k - i), n);
  }

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



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
/*
ll Comb(ll n, ll k){
  ll f[105][105];
  rep(i,105) f[0][i] = f[i][0] = 1;
  REP(i,1,105){
    REP(j,1,105){
      f[i][j] = f[i-1][j] + f[i][j-1];
      if(i+j==n && j==k) return f[i][j];
    }
  }
  return 1;
}
*/

ll Comb(int n, int k){
  ll C[n+1][n+1];
  for(int i=0; i<n+1; i++){
    for(int j=0; j<n+1; j++){
      if(j==0 || j==i){
        C[i][j] = 1;
      }else{
        C[i][j] = C[i-1][j-1] + C[i-1][j];
      }
    }
  }
  return C[n][k];
}


int main(){
  int N, A, B;
  cin >> N >> A >> B;
  vector<ll> v(N);
  rep(i,N){
    cin >> v[i];
  }
  sort(ALLOF(v));
  reverse(ALLOF(v));

  ll mx = -1;
  ll mxn = 1;
  
  ll sum = 0;
  rep(i,N){
    sum += v[i];
    if(A<=i+1 && i+1<=B){
      if(mx*(i+1) < sum*mxn){
        mx = sum;
        mxn = i+1;
      }
    }
  }

  printf("%.15lf\n", mx/(double)mxn);

  ll cnt1 = 0, cnt2 = 0;
  rep(i,N){
    if(v[i] == v[mxn-1]){
      cnt1++;
      if(i < mxn){
        cnt2++;
      }
    }
  }

  sum = 0;
  rep(i,A-1){
    sum += v[i];
  }
  
  ll ret = 0;
  REP(i,A,B+1){
    sum += v[i-1];
    if(sum*mxn != mx*i) break;
    ll cnt = 0;
    rep(j,i){
      if(v[i-1] == v[j]) cnt++;
    }
    ret += Comb(cnt1,cnt);
  }

  cout << ret << endl;
  
  return 0;
}



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

int main(){
    long long N, M;
    cin >> N >> M;
    long long sum = 0;
    for(long long i =0; i < M; i++){
        long long a;
        cin >> a;
        sum += a;
    }
    if(N - sum >= 0) cout << N - sum << endl;
    else cout << -1 << endl;    
}

Measured memory_bytes: 3636
N,M=map(int,input().split())
AB=[[] for _ in range(N)]
for _ in range(M):
  a,b=map(int,input().split())
  AB[a-1].append(b)
  AB[b-1].append(a)

def dfs(n,seen):
  global ans
  seen.append(n)
  if len(seen)==N:
    ans+=1
  else:
    for i in AB[n-1]:
      if i not in seen:
        dfs(i,seen)
  seen.remove(n)

ans=0
dfs(1,[])
print(ans)

Measured memory_bytes: 3064
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

//var myOut = main();
//if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next(), k = next();
  var a = nexts(n);
  var g = xArray("[]",n);
  for(var i = 1; i < n; i++){
    g[a[i]-1].push(i);
  }
  var ans = 0;
  if(a[0] !== 1)ans = 1;
  dfs(0,0);
  return ans;
  function dfs(v,depth){
    var dmax = depth;
    for(var i = 0; i < g[v].length; i++){
      var V = g[v][i];
      var d = dfs(V,depth+1);
      if(dmax < d)dmax = d;
    }
    if(v && depth > 1 && dmax >= depth+k-1)ans++, dmax = depth-1;
    return dmax;
  }
}

if (process.argv[2] === "--stack-size=262144" || process.argv.length < 3) require("child_process").fork("Main.js", ["1"], { execArgv: ["--stack-size=480000"] });
else {
  var myOut = main();
  if(myOut !== undefined)console.log(myOut);
}

Measured memory_bytes: 74320
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int main() {
	IO;
	ll n,m;
	cin>>n>>m;
	vector<ll> sum(100002);
	for(int i=0;i<m;++i) {
		int a,b;
		cin>>a>>b;
		sum[a]++;
		sum[b+1]--;
	}
	
	for(int i=1;i<=n;++i) {
		sum[i]+=sum[i-1];
	}
	
	int mx=*max_element(all(sum));
	if(mx==m) {
		cout<<count(all(sum), mx)<<"\n";
	}else {
		cout<<"0\n";
	}
	return 0;
}


Measured memory_bytes: 3996
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int N, M, s, t;
double ex[600], res;
vector<int>v[600];

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> s >> t;
		v[s - 1].push_back(t - 1);
	}
	for (int i = N - 2; i >= 0; i--) {
		for (int j : v[i]) {
			ex[i] += ex[j];
		}
		ex[i] /= v[i].size();
		ex[i] += 1;
	}
	res = ex[0];
	for (int i = 0; i < N - 1; i++) {
		if (v[i].size() == 1)continue;
		double EX[600];
		for (int j = i + 1; j < N; j++) {
			EX[j] = ex[j];
		}
		EX[i] = 0;
		double mx = 0;
		for (int j : v[i]) {
			EX[i] += EX[j];
			mx = max(mx, EX[j]);
		}
		EX[i] -= mx;
		EX[i] /= v[i].size() - 1;
		EX[i] += 1;
		for (int j = i - 1; j >= 0; j--) {
			EX[j] = 0;
			for (int k : v[j]) {
				EX[j] += EX[k];
			}
			EX[j] /= v[j].size();
			EX[j] += 1;
		}
		res = min(res, EX[0]);
	}
	printf("%.10f\n", res);
}

Measured memory_bytes: 1408
li = list(map(int,input().split()))
s=list(input())
cnt = 0
b = 0
for i in s:
    if i == "a":
        if cnt < li[1] + li[2]:
            cnt += 1
            print("Yes")
        else:
            print("No")
    elif i == "b":
        b += 1
        if cnt < li[1] + li[2]:
            if b <= li[2]:
                cnt += 1
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    else:
        #cnt -= 1
        print("No")

Measured memory_bytes: 4708
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 200;

vector<pii> G[N];
int R[8];
int D[N];
int D2[8][8];

int dijkstra(int f, int t, int n) {
	rep(i,n) D[i]=INF;
	priority_queue<pii, vector<pii>, greater<pii>> Q;
	Q.push(pii(0,f));
	D[f]=0;
	while(!Q.empty()){
		pii p=Q.top();Q.pop();
		for(auto i:G[p.second]) {
			if(D[i.second]>D[p.second]+i.first){
				D[i.second]=D[p.second]+i.first;
				Q.push(i);
			}
		}
	}
	return D[t];
}

int main() {
	int n,m,r;cin>>n>>m>>r;
	rep(i,r) {cin>>R[i];R[i]--;}
	rep(i,m) {
		int a,b,c;cin>>a>>b>>c;a--;b--;
		G[a].push_back(pii(c,b));
		G[b].push_back(pii(c,a));
	}
	rep(i,r) rep(j,r) D2[i][j]=-1;
	vi p(r);rep(i,r) p[i]=i;
	int ans=INF;
	do {
		int tmp=0;
		rep(i,r-1) {
			int &d2=D2[p[i]][p[i+1]];
			if(d2==-1) {
				d2=dijkstra(R[p[i]],R[p[i+1]],n);
				D2[p[i+1]][p[i]]=d2;
			}
			tmp+=d2;
		}
		ans=min(tmp,ans);
	}while(next_permutation(p.begin(), p.end()));
	cout<<ans<<endl;
}


Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;


/*vectorの要素を全部確認するやつだよ。


for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}


*/


/*for文でx,yを上下左右確認するやつだよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}
*/

/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}


*/

/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; i++) {
	for (int j = 0; j < w; j++) {

	}
}

*/

int main(void) {
	string s; cin >> s;
	int a, b, c, d;
	a = s[0] - '0';
	b = s[1] - '0';
	c = s[2] - '0';
	d = s[3] - '0';


	if ((a + b + c + d) == 7) cout << s[0] << '+' << s[1] << '+' << s[2] << '+' << s[3] << "=7" << endl; 
	else if ((a + b + c - d) == 7) cout << s[0] << '+' << s[1] << '+' << s[2] << '-' << s[3] << "=7" << endl; 
	else if ((a + b - c + d) == 7) cout << s[0] << '+' << s[1] << '-' << s[2] << '+' << s[3] << "=7" << endl;
	else if ((a - b + c + d) == 7) cout << s[0] << '-' << s[1] << '+' << s[2] << '+' << s[3] << "=7" << endl;
	else if ((a + b - c - d) == 7) cout << s[0] << '+' << s[1] << '-' << s[2] << '-' << s[3] << "=7" << endl;
	else if ((a - b - c + d) == 7) cout << s[0] << '-' << s[1] << '-' << s[2] << '+' << s[3] << "=7" << endl;
	else if ((a - b + c - d) == 7) cout << s[0] << '-' << s[1] << '+' << s[2] << '-' << s[3] << "=7" << endl;
	else if ((a - b - c - d) == 7) cout << s[0] << '-' << s[1] << '-' << s[2] << '-' << s[3] << "=7" << endl;
	


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n , c,k;
    cin>>n>>c>>k;
    ll t[n];
    for(int i=0;i<n;i++)
    {
        cin>>t[i];
    }
    sort( t , t+n);
    int index =0;
    ll ans =0;
    while( index < n)
    {
        ll curr = t[index];
        ll cap =1;
        while( curr + k >= t[index] && cap <= c  && index<n )
        {
           
            index++;
            cap++;
        }
        ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 4356
/**********************************************************************
File    .cpp
Author  Takahiro Yamazaki
**********************************************************************/
/**********************************************************************
Include Libraries
**********************************************************************/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
/**********************************************************************
Declare variables
**********************************************************************/
/**********************************************************************
Declare instance
**********************************************************************/
/**********************************************************************
Proto_type_Declare functions
**********************************************************************/
/**********************************************************************
Main
**********************************************************************/
int main() {
  int n,m;
  cin >> n >> m;
  int a[110000];
  rep(i,m) cin >> a[i];

  int ans = n;
  rep(i,m) ans -= a[i];
  if (ans < 0) ans = -1;
  printf("%d\n", ans);
}
/**********************************************************************
Functions
**********************************************************************/


Measured memory_bytes: 3768
n = int(input())
s = list(map(int,input().split()))
c = 0
for i in range(n-2):
    if s[i+1] != min(s[i],s[i+1],s[i+2]) and s[i+1] != max(s[i],s[i+1],s[i+2]):
        c += 1
print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <functional>
#include <utility>
#include <vector>
using namespace std;
int main(void){
    int n,m;
    cin>>n>>m;
    pair<long int,long int> a[110000];
    for(int i=0;i<n;i++){
        cin>>a[i].first>>a[i].second;
    }
    
    sort(a,a+n);
    
    long int ans=0;
    long int dai=0;
    
    while(m!=0){
        if(m-a[dai].second>0){
            m-=a[dai].second;
            ans+=a[dai].first*a[dai].second;
            dai++;
        }
        else{
            ans+=a[dai].first*m;
            m=0;
        }
    }
    
    cout<<ans<<endl;
    
    
    
    
    
    
    
    
    
    
}

Measured memory_bytes: 1920
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

int main() {
    int N;
    cin >> N;

    if (N==0) {
        cout << 0 << endl;
    }
    
    if (N>0) {
        int m = 0;
        long max = 0;
        while (true) {
            max += pow(4,m);
            //cout << max << endl;
            if (N<=max) {
                max += 1 - pow(4,m);
                //cout << "break" << endl;
                break;
            }
            m += 1;
        }
        m += 1;
        m = 2*m-1; // m桁目が1で確定
        
        // N-maxをm-1桁の2進数に変換
        N -= max;
        //cout << N << " " << m << endl;
        vector<int> data(m, 0);
        //trans(N, m-1);
        data[0] = 1;
        m -= 1;
        for (int i=0;i<m;i++) {
            if (N>=pow(2,m-1-i)) {
                if (i%2!=0) {
                    data[i+1] = 1;
                }
                N -= pow(2,m-1-i);
            }
            else {
                if (i%2==0) {
                    data[i+1] = 1;
                }
            }
        }
    
        for (int i=0;i<m+1;i++) {
            cout << data[i];
        }
        cout << endl;
    }
    
    if (N<0) {
        N = -N;
        int m = 0;
        long max = 0;
        while (true) {
            max += 2*pow(4,m);
            if (N<=max) {
                max += 1 - 2*pow(4,m);
                break;
            }
            m += 1;
        }
        m += 1;
        m = 2*m; // m桁目が1で確定
        
        // N-maxをm-1桁の2進数に変換
        N -= max;
        //cout << N << " " << m << endl;
        vector<int> data(m, 0);
        //trans(N, m-1);
        data[0] = 1;
        m -= 1;
        for (int i=0;i<m;i++) {
            if (N>=pow(2,m-1-i)) {
                if (i%2!=0) {
                    data[i+1] = 1;
                }
                N -= pow(2,m-1-i);
            }
            else {
                if (i%2==0) {
                    data[i+1] = 1;
                }
            }
        }
        
        for (int i=0;i<m+1;i++) {
            cout << data[i];
        }
        cout << endl;
    }
}

Measured memory_bytes: 512
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;

constexpr char cs[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'};

void dfs(string str, int N, size_t pre, size_t lim, priority_queue<string, vector<string>, greater<string>>& q) {
  size_t size = str.size();
  if (size != N) {
    for (size_t c = 0; c <= lim; ++c) {
      size_t mx = max(pre, c);
      dfs(str + cs[c], N, mx, mx + 1, q);
    }
  } else {
    q.push(str);
  }
}

int main() {
  int N;
  cin >> N;
  
  priority_queue<string, vector<string>, greater<string>> q;
  dfs("a", N, 0, 1, q);
  while (!q.empty()) {
    cout << q.top() << endl;
    q.pop();
  }
  
  return 0;
}


Measured memory_bytes: 7796
import java.util.Scanner;

class Solver {

    private final int N;
    private final int[] A;

    Solver(Scanner in){
        N = in.nextInt();
        A = new int[N];
        for (int i = 0; i < A.length; i++) {
            A[i] = in.nextInt();
        }
    }

    void solve() {
        int counter = 0;
        for (int value : A) {
            counter += Integer.numberOfTrailingZeros(value);
        }
        System.out.println(counter);
    }
}

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

        new Solver(in).solve();

        in.close();
    }
}

Measured memory_bytes: 33908