akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

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

    char p = 'a';
    while(true){
        if(p=='a'){
            if(a.empty()){
                cout << 'A';
                break;
            }
            p = a.front();
            a.erase(a.begin());
        }
        else if(p=='b'){
            if(b.empty()){
                cout << 'B';
                break;
            }
            p = b.front();
            b.erase(b.begin());
        }
        else{
            if(c.empty()){
                cout << 'C';
                break;
            }
            p = c.front();
            c.erase(c.begin());
        }
    }
}

Measured memory_bytes: 256
/*
Hanit Banga
*/

#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
#include <map>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false)

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

const int N = 1e5 + 5;

ll a[N], b[N], tree_ctr[3*N], tree_sum[3*N], inv[N], ans[N], steps[N];
map <ll, int> m;
set <int> pos[N];

void update(ll *tree, int i, int l, int r, int p, ll x);
ll query(ll *tree, int i, int l, int r, int ql, int qr);

int main()
{
	int n;
	cin >> n;
	
	int x = 0;
	ll sum = 0;
	for (int i = 1; i <= n; ++i)
	{	
		cin >> a[i];
		b[i] = a[i];
		sum += a[i];
	}

	sort(b + 1, b + n + 1);
	for (int i = 1; i <= n; ++i)
	{
		if (m.find(b[i]) == m.end())
		{
			m[b[i]] = x++;
			inv[x] = b[i];
		}
	}

	for (int i = 1; i <= n; ++i)
		pos[m[a[i]]].insert(i);

	int p = n + 1;
	vector <int> elems;
	for (int i = x - 1; i >= 0; --i)
	{
		if (pos[i].empty())
			continue;

		for (auto &j : pos[i])
		{
			update(tree_ctr, 1, 1, n, j, 1);
			update(tree_sum, 1, 1, n, j, a[j]);
		}

		if (*pos[i].begin() < p)
		{
			elems.pb(*pos[i].begin());
			p = *pos[i].begin();
			steps[p] = query(tree_sum, 1, 1, n, p + 1, n) - a[p] * query(tree_ctr, 1, 1, n, p + 1, n);
		}
	}

	int t = elems.size();
	for (int i = 1; i < t; ++i)
		ans[elems[i - 1]] = steps[elems[i]] - steps[elems[i - 1]];
	
	ans[elems[t - 1]] = sum - steps[elems[t - 1]];
	for (int i = 1; i <= n; ++i)
		cout << ans[i] << '\n';
}

void update(ll *tree, int i, int l, int r, int p, ll x)
{
	tree[i] += x;
	if (l == r)
		return;

	int mid = (l + r) / 2;
	if (p <= mid)
		update(tree, 2*i, l, mid, p, x);
	else
		update(tree, 2*i + 1, mid + 1, r, p, x);
}

ll query(ll *tree, int i, int l, int r, int ql, int qr)
{
	if (ql > r or qr < l)
		return 0;

	if (ql <= l and r <= qr)
		return tree[i];

	int mid = (l + r) / 2;
	return query(tree, 2*i, l, mid, ql, qr) + query(tree, 2*i + 1, mid + 1, r, ql, qr);
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n,a,b;cin>>n>>a>>b;){
		cout<<min(a,b)<<' '<<max(a+b-n,0)<<endl;
	}
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef vector<int> vii;
typedef vector<double> vdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef set<int> sii;
typedef set<double> sdd;
typedef set<ll> sll;
typedef set<ld> sld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef pair<double, double> pdd;

#define feach(i, a) for(auto  &i : a)
#define allo(a, n) (a), (a) + (n)
#define all(a) (a).begin(), (a).end()

const int MAXN = 2e3 + 1;
const int mod = 1e9;
const double PI = atan2(0, -1);
const int INF32 = 2e9 + 1;
const ll INF64 = 1e18 + 1;
random_device rd;
mt19937_64 rnd(rd());
uniform_int_distribution<ll> uid(-1e9, 1e9);

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

void time() {
    cerr << (double) clock() / CLOCKS_PER_SEC << '\n';
}

void solve() {
    int n;
    cin >> n;
    int a[n];

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        //a[i] = uid(rnd);
        //cout << a[i] << ' ';
    }
    //cout << endl;

    vii ans_odd, ans_even;
    ll sum_odd = 0, sum_even = 0;

    for (int i = 0; i < n; i++) {
        if (i % 2) {
            if (a[i] > 0) {
                sum_odd += a[i];
                ans_odd.push_back(i);
            }
        } else {
            if (a[i] > 0) {
                sum_even += a[i];
                ans_even.push_back(i);
            }
        }
    }

    ll sum;
    vii ans;

    if (sum_even == 0 and sum_odd == 0) {
        sum = -INF64;
        ans.push_back(-1);

        for (int i = 0; i < n; i++) {
            if (a[i] > sum) {
                sum = a[i];
                ans.back() = i;
            }
        }

    } else if (sum_odd > sum_even) {
        sum = sum_odd;
        ans = ans_odd;
    } else {
        sum = sum_even;
        ans = ans_even;
    }

    cout << sum << '\n';
    vii to_print;
    for (int i = n - 1; i > ans.back(); i--)
        to_print.push_back(i + 1);

    for (int i = int(ans.size()) - 2; i >= 0; i--) {
        for (int j = 0; j < (ans[i + 1] - ans[i] - 2) / 2; j++)
            to_print.push_back(ans[i] + 3);
        to_print.push_back(ans[i] + 2);
    }

    for (int i = 1; i - 1 < ans.front(); i++)
        to_print.push_back(1);

    cout << to_print.size() << '\n';
    feach(i, to_print)
        cout << i << '\n';
}

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

    solve();
    //time();

    return 0;
}


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

int main(){
    int N;
    cin >> N;
    set<int> st;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        st.insert(a);
    }
    cout << (st.size() == N ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 9600
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

#define QUERY_MAX 2000000

enum type {
    COMMAND_EXTRACT = 'e',
    COMMAND_INSERT = 'i',
};

#define ROOT_NODE 1
static int heap[QUERY_MAX+50];
int hidx = ROOT_NODE;

// max-heap
int cmp(int a, int b) {
    return a > b;
}

void swap(int *a, int *b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
}

void insert(int val) {
    int node = hidx;
    heap[hidx++] = val;
    int parent;
    while((parent = node/2)) {
        if(cmp(heap[parent], heap[node])) break;
        swap(&heap[parent], &heap[node]);
        node = parent;
    }
    return;
}

int extract(void) {
    int ans = heap[ROOT_NODE];
    heap[ROOT_NODE] = heap[--hidx];
    int node = ROOT_NODE;
    while(1) {
        int cur = node;
        int left = node*2;
        int right = node*2+1;
        if(left < hidx && !cmp(heap[cur], heap[left])) cur = left;
        if(right < hidx && !cmp(heap[cur], heap[right])) cur = right;
        if(cur == node) break;
        swap(&heap[cur], &heap[node]);
        node = cur;
    }
    return ans;
}

int main(void) {
    static int ans[QUERY_MAX];
    int aidx = 0;
    while(1) {
        char command[12] = {0};
        int val;
        scanf("%s", command);
        if(command[0] == 'e' && command[1] == 'n') break;
        switch(command[0]) {
            case COMMAND_EXTRACT:
                ans[aidx++] = extract();
                break;
            case COMMAND_INSERT:
                scanf("%d", &val);
                insert(val);
                break;
            default:
                break;
        }
    }

    int i;
    for(i = 0; i < aidx; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}


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

int main() {
  string s;cin>>s;
  int n=s.size();
  int x=1e9,y=0;
  rep(i,n){
    if(s[i]=='A')x=min(x,i+1);
    if(s[i]=='Z')y=max(y,i+1);
  }
  cout<<y-x+1<<endl;
}

Measured memory_bytes: 3736
#include<cstdio>
#include<cstring>
inline long long min(long long x,long long y){
	return x<y?x:y;
}
using namespace std;
long long a,b,f[100002],n,k,ans;
int main(){
	scanf("%lld%lld",&k,&n);
	for(int i=1;i<=k;++i)f[i]=1e18;
	f[0]=0;
	for(int i=1;i<=n;++i){
		scanf("%lld%lld",&a,&b);
		for(int j=a;j<=k;++j){
			f[j]=min(f[j],f[j-a]+b);
			
		}
		for(int j=0;j<=k;++j)if(j>=k-a)f[k]=min(f[k],f[j]+b);
	}
	printf("%lld",f[k]);
}



Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readInt >>= print . head . filter ( ( == 0 ) . ( `mod` 111 ) ) . flip drop [ 0 .. ]

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 998244353

ll N,K;
string S;
ll dp[303][303][303];
vector<ll> A;
ll cnt[303];

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

  cin>>S>>K;
  N=S.size();
  ll T=1;
  rep(i,N){
    if(S[i]=='1'){
      ll sum=0;
      repl(j,i,N)if(S[j]=='0')sum++;
      A.push_back(sum+1);
    }else T++;
  }
  dp[T][0][0]=1;
  ll M=A.size();
  rep(i,M)cnt[A[i]]++;
  for(ll i=T;i>0;i--){
    rep(j,M+1)rep(k,M+1){
      if(dp[i][j][k]==0)continue;
      repl(x,1,M+1-j){
        if(j+x>M)break;
        if(A[j+x-1]>i)break;
        (dp[i-1][j+x][k+max(0LL,x-cnt[i])]+=dp[i][j][k])%=mod;
      }
      (dp[i-1][j][k]+=dp[i][j][k])%=mod;
    }
  }
  ll res=0;
  rep(k,min(M+1,K+1)){
    (res+=dp[0][M][k])%=mod;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 57924
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

struct rest {
	ll id;
	string s;
	ll p;
};

bool cmp(rest a, rest b) {
	if (a.s == b.s) { return a.p > b.p; }
	return a.s < b.s;
}


int main() {

	ll N, K;
	cin >> N >> K;

	vector<vector<ll>> b(K + 1, vector<ll>(K + 1, 0));

	repn(i, N) {
		ll x, y;
		char c;
		cin >> x >> y >> c;

		x = x % (2 * K) + 1;
		y = y % (2 * K) + 1;

		ll p = 1;
		if (x > K) { p *= -1; x -= K; }
		if (y > K) { p *= -1; y -= K; }
		if (c == 'W') { p *= -1; }

		
	
		b[x][y] += p;

	}

	vector<vector<ll>> B(K + 1, vector<ll>(K + 1, 0));

	repn(i, K){
		repn(j, K) {
			B[i][j] = B[i - 1][j] + B[i][j - 1] - B[i - 1][j - 1] + b[i][j];
			//cout << b[i][j]<<B[i][j];
		}
		//cout << endl;
	}

	ll ans = -N;

	repn(i, K)repn(j, K) {
		ll v = B[K][K] - 2 * B[K][j] - 2 * B[i][K] + 4 * B[i][j];
		//cout << v << endl;
		v = abs(v);
		ans = max(v, ans);
	}

	cout << (ans + N) / 2;

	system("PAUSE");

	

}


Measured memory_bytes: 16248
C = -(10**15 + 7)


def main():
    from collections import defaultdict
    N = int(input())
    K = N//2
    A = [int(i) for i in input().split()]
    dp = defaultdict(lambda: C)
    for i in range(N+1):
        dp[i, 0] = 0
        if i != 0:
            dp[(i, 1)] = max(dp[i-1, 1], A[i-1])
    for i in range(2, N+1):
        for j in range(i//2-1, (i+1)//2 + 1):
            if j < 0:
                continue
            # A_i(1-index)でj個選ばなければいけない
            dp[i, j] = max(dp[i, j], dp[i-2, j-1] + A[i-1],
                           dp[i-3, j-1] + A[i-1], dp[i-4, j-1] + A[i-1])
    print(max(dp[N, K], dp[N-1, K], dp[N-2, K]))
    # for i in range(N+1):
    #     for j in range(K+1):
    #         print("{:>4}".format(dp[i, j] if dp[i, j] != C else "C"),
    #               end=" " if j != K else "\n")


if __name__ == '__main__':
    main()


Measured memory_bytes: 224868
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
#include <numeric>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define PI 3.14159265358979l

int gcd(int a, int b) {
	if (a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}


int main() {
	string s;
	cin >> s;
	int ss = s.size();
	vector<int> w, b;
	rep(i, ss) {
		if (i % 2 == 0) {
			w.push_back('1');
			b.push_back('0');
		}
		else {
			w.push_back('0');
			b.push_back('1');
		}
	}
	
	int bc = 0, wc = 0;
	rep(i, ss) {
		if (s[i] != w[i])wc++;
		if (s[i] != b[i])bc++;
	}
	
	cout << min(wc, bc) << endl;
	cin >> s;
	return 0;
}

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

void	sort(char **S, int N)
{
	char	*temp;

	for (int i = 0; i <(N - 1); i++)
	{
		for (int j = (N - 1); i < j; j--)
		{
			for (int k = 0; S[i][k] || S[j][k]; k++)
			{
				if ((S[j][k] - S[i][k]) < 0)
				{
					temp = S[i];
					S[i] = S[j];
					S[j] = temp;
					break;
				}
				else if ((S[j][k] - S[i][k]) > 0)
					break;
			}
		}
	}
}

int		main(void)
{
	int		N;
	int		L;
	char	escape;

	scanf("%d %d", &N, &L);
	// printf("N:%d ",N);
	// printf("L:%d\n",L);
	char	**S;

	S = (char **)malloc(sizeof(char *) * (N + 1));
	for (int i = 0; i < N; i++)
	{
		S[i] = (char *)malloc(L + 1);
	}
	S[N] = NULL;
	for (int i = 0; i < N; i++)
	{
		if (i != 0)
			scanf("%c", &escape);
		scanf("%s", S[i]);
	}
	sort(S, N);
	for (int i = 0; S[i]; i++)
		printf("%s",S[i]);
	free(S);
	return (0);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

vs a;
int h,w;
bool b1,b2;

void dfs(int i,int j,int &t){
	t++;
	a[i][j]='#';
	for(int k=0;k<4;k++){
		int x=i+dx[k],y=j+dy[k];
		if(x>=0&&x<h&&y>=0&&y<w){
			if(a[x][y]=='B') b1=1;
			if(a[x][y]=='W') b2=1;
			if(a[x][y]=='.') dfs(x,y,t);
		}
	}
}

int main(){
	while(1){
		cin>>w>>h;
		if(h==0) break;
		a=vs(h);
		for(int i=0;i<h;i++) cin>>a[i];
		int x=0,y=0;
		for(int i=0;i<h;i++) for(int j=0;j<w;j++) if(a[i][j]=='.'){
			b1=0,b2=0;
			int t=0;
			dfs(i,j,t);
			if(b1&&!b2) x+=t;
			if(!b1&&b2) y+=t;
		}
		cout<<x<<' '<<y<<endl;
	}
}


Measured memory_bytes: 3448
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    ll n,m;cin >> n >> m;
    vector<pair<ll,ll>> p(n);
    rep(i,n){
        cin >> p[i].first >> p[i].second;
    }

    sort(p.begin(), p.end());
    ll ans = 0;
    for(int i=0;i<n;++i){
        if(m - p[i].second >=0){
            m -= p[i].second;
            ans += p[i].first * p[i].second;
        }else{
            ans += m * p[i].first;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1920
W,H,N = map(int,input().split())
x_a=0
y_a=0
x_b=W
y_b=H
for i in range(N):
  x,y,a = map(int,input().split())
  if a ==1:
    x_a=max(x_a,x)
  elif a ==2:
    x_b=min(x_b,x)
  elif a==3:
    y_a=max(y_a,y)
  elif a==4:
    y_b=min(y_b,y)
print((x_b-x_a)*(y_b-y_a) if x_b-x_a > 0 and y_b-y_a > 0 else '0')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vi l(N);
  rep(i,N) {
    cin >> l[i];
  }
  sort(rng(l));
  int ans = 0;
  rep(i,N) {
    srep(j,i+1,N) {
      if(l[i]==l[j]) continue;
      srep(k,j+1,N) {
        if(l[j]==l[k]) continue;
        if(l[i]+l[j]>l[k]) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
#[allow(dead_code)]
pub struct Scanner<'a> {
    _buf: &'a str,
    iter: ::std::str::SplitWhitespace<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    pub fn new(buf: &'a str) -> Self {
        Scanner {
            _buf: buf,
            iter: buf.split_whitespace(),
        }
    }

    pub fn array<T>(&mut self, n: usize) -> Vec<T>
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        let mut res = Vec::with_capacity(n);
        for _ in 0..n {
            res.push(self.value());
        }
        res
    }

    pub fn value<T>(&mut self) -> T
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        self.next().parse().unwrap()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.next().chars().collect()
    }

    fn next(&mut self) -> &str {
        self.iter.next().unwrap()
    }
}

fn main() {
    let mut _input = String::new();
    {
        use ::std::io::Read;
        ::std::io::stdin().read_to_string(&mut _input).unwrap();
    }
    let mut sc = Scanner::new(&_input);

    let n = sc.value::<i64>();
    let a = sc.array::<i64>(n as usize);

    let mut ans = 0_i64;
    let mut pre = -1_i64;
    let mut k   = 0_i64;
    for e in a {
        if e != pre {
            ans += k / 2;
            pre  = e;
            k    = 1;
        }
        else {
            k += 1;
        }
    }
    ans += k / 2;

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


Measured memory_bytes: 4352
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
 
ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
   
	ll a,b;
	
	cin >> a >> b;
	
	if(a<b){
		cout << 0 << endl;
	}else{
		cout << 10 << endl;
	}
   
return 0;   
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <iomanip>
#include <cstring>
#include <climits>
#include <cstdio> 

#define nl '\n'

using namespace std;

long long k, x;

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

int main(){

    cin >> k;

    for(long long i = 1; i < k+1; i++) {
        for(long long j = 1; j < k+1; j++) {
            for(long long z = 1; z < k+1; z++) {
                x += gcd(i, gcd(j, z));
            }
        }
    }

    cout << x;
}
 
//g++ -std=c++14 comp.cpp -o c && c.exe
//g++ -std=c++14 comp.cpp -o c; ./c.exe
//g++ -std=c++14 comp.cpp && ./a.out

//Surely this is going to AC

Measured memory_bytes: 3632
N=int(input())
A=list(map(int,input().split()))
c=0
d=True
while d:
  for i in range(N):
    if A[i]%2==1:
      d= False
      break
  if d:
    c+=1
    A=[int(j//2) for j in A]
    

print(c)

Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>

using namespace std;

typedef pair<int,bool> Pair;

int main(){

  int N;
  double A;
  double sum = 0;

  cin >> N;

  for (int i = 0; i < N;++i){
    
    cin >> A;
    sum += (1.0/A);

  }

  cout << (1.0/sum) << endl;

  return 0;

}

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }
template<typename T = i64>
void OUT(T& x) { cout << x << endl; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

#ifdef _DEBUG
signed Main()
#else
signed main()
#endif
{
	auto a = IN();
	auto s = IN<string>();
	cout << (a >=3200 ? s : "red") << endl;

	return 0;
}


Measured memory_bytes: 256
/*
      author  : nishi5451
      created : 14.08.2020 16:52:26
*/

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


int main(){
    string a,b;
    cin >> a >> b;
    a += b;
    int n = atoi(a.c_str());
    for(int i=1; i*i<=n; i++){
        if(i*i==n){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3560
#include <cstdio>
#include <cstdlib>
#pragma warning(disable : 4996)
struct Node {
	int key;
	Node *p, *l, *r;
};
Node *root, *NIL;
void insert(int key_) {
	Node *x = root, *y = NIL, *z;
	z = (Node*)malloc(sizeof(Node));
	z->key = key_, z->l = NIL, z->r = NIL;
	while (x != NIL) {
		y = x;
		x = (z->key < x->key) ? x->l : x->r;
	}
	z->p = y;
	if (y == NIL) root = z;
	else if (z->key < y->key) y->l = z;
	else y->r = z;
}
void walk1(Node *x) { if (x == NIL) return; walk1(x->l); printf(" %d", x->key); walk1(x->r); }
void walk2(Node *x) { if (x == NIL) return; printf(" %d", x->key); walk2(x->l); walk2(x->r); }
int n, v; char c[8];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", &c);
		if (c[0] == 'i') scanf("%d", &v), insert(v);
		else walk1(root), printf("\n"), walk2(root), printf("\n");
	}
}

Measured memory_bytes: 26024
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);
ll gcd(ll a,ll b){
if(a==0||b==0)return max(a,b);
if(b>a)swap(a,b);
 while(1){
        if(a%b!=0){
            ll tmp=b;b=a%b;
            a=tmp;
        }else{
            return b;
        }
    }
}
int main() {
    ll n,k;
    cin>>n>>k;
    vector<ll> a;
    ll com=0;
    ll ma=0;

    rep(i,n) {
        ll aa;
        cin >> aa;
        a.push_back(aa);
        if (aa > ma)ma = aa;
        if(i==0){
            com=aa;
        }else{
            com = gcd(com,aa);
        }

    }
    
    if(k<=ma&&k%com==0){
        cout<<"POSSIBLE"<<endl;
    }else{
        cout<<"IMPOSSIBLE"<<endl;
    }


    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

string s;

signed main() {
	cin >> s;
	if ((s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) || (s[0] == s[1] && s[2] == s[3] && s[0] != s[2])||(s[0]==s[3]&&s[1]==s[2]&&s[0]!=s[1]))cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 9
#define S 172
using namespace std;
int n,a[N],b[N];
double ans1,ans2;
int dp[(1<<N)][10][S];

int main(){
  cin>>n;
  while(n--){
    for(int i=0;i<N;i++)cin>>a[i];
    for(int i=0;i<N;i++)cin>>b[i];
    memset(dp,0,sizeof(dp));
    dp[0][0][0]=1;
    for(int i=0;i<(1<<N);i++){
      for(int j=0;j<N;j++){
	if(__builtin_popcount(i)!=j)continue;
	for(int k=0;k<S;k++){
	  if(!dp[i][j][k])continue;
	  for(int l=0;l<N;l++){
	    if(i&(1<<l))continue;
	    if(a[l]<b[j]){
	      dp[(i|(1<<l))][j+1][k+a[l]+b[j]]+=dp[i][j][k];
	    }else dp[(i|(1<<l))][j+1][k]+=dp[i][j][k];
	  }
	}
      }
    }
    ans2=1;
    for(int i=1;i<=9;i++)ans2*=i;
    ans1=0;
    for(int i=86;i<S;i++)ans1+=dp[(1<<N)-1][N][i];
    ans1/=ans2;
    printf("%.5f %.5f\n",(1-ans1),ans1);
  }
  return 0;
}

Measured memory_bytes: 4636
import math
a=input().split()
A,B=int(a[0]),int(a[1])
flg=0
for i in range(1,1001):
    if(math.floor(i*0.08)==A and math.floor(i*0.10)==B):
        print(i)
        flg=1
        break
if(flg==0):
    print(-1)

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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N,M; cin >> N >> M;
    vector<int> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];
    int sum = accumulate(ALL(A),0);
    int ans = 0;
    for(int i = 0; i < N; ++i) {
        if(A[i]*4*M >= sum) ans++;
    }
    Yn(ans>=M);


    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		new Main().solve(new Scanner(System.in));
	}
	
	public void solve(Scanner sc) {
		String c = sc.next();
		if(c.matches("[aeiou]")) {
			System.out.println("vowel");
		} else {
			System.out.println("consonant");
		}
	}
}


Measured memory_bytes: 10068
s = gets.chomp
q = gets.to_i

is_front = true

res = s.split("")

q.times{
	t,f,c = gets.chomp.split

	if t == "1" then
		is_front = ! is_front
	elsif (is_front && f == "1") || (! is_front && f == "2") then
		res.unshift(c)
	else
		res << c
	end
}

if ! is_front then
	res.reverse!
end

puts res.join

Measured memory_bytes: 28796
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846

void solve()
{
    int n,m;cin>>n>>m;
    vector<int> v;int sum=0;
    for(int i=0;i<m;i++)
    {
        int x;cin>>x;
        sum+=x;
        v.push_back(x);
    }
    if(sum>n)
        cout<<-1<<nl;
    else
    {
        cout<<n-sum<<nl;
    }
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t=1;
    //cin>>t;
    //int i=1;
    while(t--)
    {
        //cout<<"Case #"<<i<<": ";
        solve();
        //i++;
    }
    return 0;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,i=0,j,c=0,p,h[1000010],m=0;
    string s;
    cin >> n >> s;
    c=s.size();
    for(i=0;i<c-2;i++)
    {
        if(s.substr(i,3)=="ABC")
        {
            m++;
        }
    }
    cout << m << endl;
    return 0;

}


Measured memory_bytes: 3612
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
#ifdef _MSC_VER
#define __builtin_popcount __popcnt
#endif
int A, B, e, a[10], b[10], c, d[10], p[10];
int main() {
	cin >> A >> B >> c; p[0] = 1;
	for (int i = 1; i < 10; i++) p[i] = p[i - 1] * 10;
	while (A) a[e++] = A % 10, A /= 10; e = 0;
	while (B) b[e++] = B % 10, B /= 10;
	int ret = 0;
	for (int i = 0; i < 512; i++) {
		if (__builtin_popcount(i) <= c) {
			int f = 1;
			for (int j = 0; j < 10; j++) d[j] = a[j];
			for (int j = 0; j < 9; j++) {
				if (d[j] < b[j]) {
					if (~i & (1 << j)) d[j + 1]--;
					d[j] += 10;
				}
				else if (i & (1 << j)) f = 0;
			}
			if (f) {
				int res = 0;
				for (int j = 0; j < 10; j++) res += (d[j] - b[j]) * p[j];
				ret = max(ret, res);
			}
		}
	}
	cout << ret << endl;
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int h, n;
    cin >> h >> n;
    vec a = ivec(n);
    yn(sum_(a) >= h);

    return 0;
}


Measured memory_bytes: 1792
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

n, m = nm()
lis = [[] for i in range(n)]
for i in range(m):
    a, b = nm()
    lis[a - 1].append(b)
    lis[b - 1].append(a)
visited = [0] * n


def dfs(v, n, visited):
    count = 1
    for i in range(n):
        if visited[i] == 0:
            count = 0
    if count == 1:
        return 1
    res = 0
    for i in lis[v]:
        if visited[i - 1] == 1:
            continue
        visited[i - 1] = 1
        res += dfs(i - 1, n, visited)
        visited[i - 1] = 0
    return res


visited[0] = 1
print(dfs(0, n, visited))


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        vector<int> A(N); cin >> A;
        int a2 = 0, a4 = 0, other = 0;
        rep(i, N) {
            if(A[i] % 4 == 0) a4++;
            else if(A[i] % 2 == 0) a2++;
            else other++;            
        }
        if(a2 == 0 and a4 > 0) a4++;
        cout << (a4 >= other ? "Yes" : "No") << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define fi first
#define se second
#define N 300100

using namespace std;
typedef pair<int,int> Pair;

int w, h, n, ans;
int x[N], y[N], X[N];
Pair dot[N];

int sta[N], stb[N], topa, topb;
int posa[N], posb[N];

struct SegmentTree {
	int n;
	int Max[N << 2];
	int add[N << 2];
	#define ls rt << 1
	#define rs rt << 1 | 1
	#define mid ((l + r) >> 1)

	void init(int x) {
		n = x;
		memset(Max, 0, sizeof Max);
		memset(add, 0, sizeof add);
	}

	void Add(int rt, int val) {
		add[rt] += val;
		Max[rt] += val;
	}

	void pushdown(int rt) {
		if (!add[rt]) return void();
		Add(ls, add[rt]);
		Add(rs, add[rt]);
		add[rt] = 0;
	}

	void Modify(int l, int r, int len) { Modify(1, 0, n, l, r, len); }
	void Modify(int rt, int l, int r, int L, int R, int val) {
		if (L <= l && r <= R) return Add(rt, val);
		pushdown(rt);
		if (mid >= L) Modify(ls, l, mid, L, R, val);
		if (mid < R) Modify(rs, mid + 1, r, L, R, val);
		Max[rt] = max(Max[ls], Max[rs]);
	}

	int query(int rt, int l, int r, int pos) {
		if (l == r) return Max[rt];
		pushdown(rt);
		if (mid >= pos) return query(ls, l, mid, pos);
		else return query(rs, mid + 1, r, pos);
	}

	int query() { return Max[1]; }
	#undef mid
}St;

int ask(int pos) { return St.query(1, 0, n, pos); }

void work() {
	int mid = (h + 1) / 2;
	sort(dot + 1, dot + n + 1);
	for (int i = 1; i <= n; ++i)
		x[i] = dot[i].fi, y[i] = dot[i].se;

	for (int i = 1; i <= n; ++i) X[i] = x[i];
	int tot_X = unique(X + 1, X + n + 1) - X - 1;
	for (int i = 1; i <= n; ++i)
		x[i] = lower_bound(X + 1, X + tot_X + 1, x[i]) - X;

	St.init(tot_X);
	sta[topa = 0] = -inf;
	stb[topb = 0] = -inf;
	X[0] = 1;

	for (int l = 1, r; l <= n; l = r + 1) {
		r = l;
		while (r < n && x[r + 1] == x[r]) ++r;

		int maxd = 1, minu = h;
		for (int i = l; i <= r; ++i) {
			if (y[i] <= mid) maxd = max(maxd, y[i]);
			if (y[i] >= mid) minu = min(minu, y[i]);
		}

		int up = minu - mid, dn = mid - maxd;
		ans = max(ans, (X[x[l]] - X[x[l - 1]] + h - 1) << 1);
		ans = max(ans, (X[x[l]] + St.query()) << 1); // update ans
		St.Modify(posa[topa], x[l] - 1, up + dn - X[posa[topa]]);

		while (sta[topa] >= up) {  // update stack_up
			St.Modify(posa[topa - 1], posa[topa] - 1, up - sta[topa]);
			--topa;
		}
		posa[++topa] = x[l];
		sta[topa] = up;

		while (stb[topb] >= dn) { // update stack_down
			St.Modify(posb[topb - 1], posb[topb] - 1, dn - stb[topb]);
			--topb;
		}
		posb[++topb] = x[l];
		stb[topb] = dn;
	}
}

int main() {
	scanf("%d%d%d", &w, &h, &n), ++w, ++h;
	for (int i = 1; i <= n; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		dot[i] = make_pair(x + 1, y + 1);
	}

	dot[++n] = make_pair(1, 1);
	dot[++n] = make_pair(w, 1);
	dot[++n] = make_pair(1, h);
	dot[++n] = make_pair(w, h);

	work();
	for (int i = 1; i <= n; ++i)
		swap(dot[i].fi, dot[i].se);
	swap(w, h);
	work();

	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 20224
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int toInt(string s){
  int res=0;
  for(int i=0;i<s.size();i++){
    res*=10;
    res+=s[i]-'0';
  }
  return res;
}

int main(void){

  string s;
  cin >> s;
  
  int cnt=0,n=toInt(s);
  for(int i=0;i<s.size();i++){
    if(s[i]=='0')continue;
    int a=toInt(s.substr(0,i));
    int b=toInt(s.substr(i,s.size()-i));
    if(a>b)break;
    if((a+b)%2==0 && (b-a)%2==0)cnt++;
  }

  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 1188
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;


int main(){
  	int n,k,mi_c = 1000000;
  	cin >> n >> k;
  	int c[n],t[n];
  
  	rep(i,0,n){
     	cin >> c[i] >> t[i]; 
      	if(t[i] <= k) mi_c = min(mi_c,c[i]);
    }
  
  	if(mi_c == 1000000){
      cout << "TLE" << endl;
    }
  	else{
      cout << mi_c << endl;
    }
  
	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstdio>

using namespace std;

const long long INF = 100000000;
const long long MOD = 1000000007;

std::vector<bool> IsPrime;

void sieve(size_t max)
{
  if (max + 1 > IsPrime.size())
  {                                // resizeで要素数が減らないように
    IsPrime.resize(max + 1, true); // IsPrimeに必要な要素数を確保
  }
  IsPrime[0] = false; // 0は素数ではない
  IsPrime[1] = false; // 1は素数ではない

  for (size_t i = 2; i * i <= max; ++i)     // 0からsqrt(max)まで調べる
    if (IsPrime[i])                         // iが素数ならば
      for (size_t j = 2; i * j <= max; ++j) // (max以下の)iの倍数は
        IsPrime[i * j] = false;             // 素数ではない
}

int main()
{
  long long N, M;
  cin >> N >> M;
  vector<long long> G[N + 1];
  for (int i = 0; i < M;i++){
    long long a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for (int i = 1; i <= N;i++){
    cout << G[i].size() << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
int a,b,c;
cin >> a >> b >>c;
if(a < b){
if(b < c){
	cout << a << " " << b << " "<< c << endl;}
	else if(c < a){
	cout << c << " "<< a << " "<< b << endl;}
	else{
	cout << a << " "<< c <<" "<< b << endl;}
}
else{
if(a < c){
cout << b << " "<< a << " "<< c << endl;}
else if(c < b){
	cout << c << " "<< b << " " << a << endl;}
	else{
	cout << b << " "<< c << " "<< a << endl;}
}
}



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

int main()
{
    string s;
    cin >> s;
    int count = 0;
    long long int size = s.size();
    long long int i;
    for (i = 0; i < size; i++)
    {
        count += s[i] - '0';
        count = count % 9;
    }
    if (count == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3708
#include <stdio.h>
#define MAX 100000
int main(){
	int n1,n2,cnt=0,i=0,j=0;
	int s[MAX],key;
	int right,left,mid;
	
	
	scanf("%d",&n1);
	
	for(i=0;i<n1;i++){
		scanf("%d",&s[i]);
	}
	
	scanf("%d", &n2);
	

	for(j=0;j<n2;j++){
		scanf("%d",&key);
		left = 1;
		right = n1;
		while(left < right){
			mid = (left+right)/2;
			//printf("left:%d\nmiddle:%d\nright:%d\n\ncnt:%d\n",left,mid,right,cnt);
			if( s[mid] > key ) right = mid;
			
			else if( s[mid] < key ) left = mid + 1;
			
			else if(s[mid]==key){
				cnt++;
				break;
			}
		}
	}
	printf("%d\n",cnt);
	return 0;
}
		


Measured memory_bytes: 2188