akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main()
{
    string r;
    cin >> r;
    string l="";
    int q;
    cin >> q;
    for(int i=0;i<q;i++){
        int t; cin >> t;
        if(t==1){
            swap(r,l);
        }
        if(t==2){
            int f;char c;
            cin>>f>>c;
            if(f==1){
                l+=c;
            }
            if(f==2){
                r+=c;
            }
        }
    }
    reverse(l.begin(),l.end());
    cout << l+r<< endl;
    return 0;
}


Measured memory_bytes: 1248
#include<iostream>
#include<unordered_map>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>


using namespace std;





int main()
{
    int a, b;
    char op;
    cin >> a >> op >> b;
    if (op == '+') {
        cout << a + b;
    }
    else {
        cout << a - b;
    }

}


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

int main(){
    ll n,m;
    cin >> n >> m;
    vector<pair<ll,ll>> ab(n);
    int a,b;
    for(int i=0;i<n;i++){
        cin >> a >> b;
        ab[i] = make_pair(a,b);
    }
    sort(ab.begin(),ab.end());

    ll ans = 0;
    for(int i=0;i<n;i++){
        if(ab[i].second > m){
            ans += ab[i].first*m;
            break;
        }
        else{
            ans += ab[i].first*ab[i].second;
            m -= ab[i].second;
        }

    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int a[200005],n,k;
bool check(int x){
    int now=0;
    for(int i=0;i<n;i++){
        now+=(a[i]-1)/x;
    }
    return now<=k;
}
int main(){
    cin>>n>>k;
    int maxn=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]>maxn)   maxn=a[i];
    }
    int l=0,r=1e9;
    while(r-l>1){
        int mid=(l+r)>>1;
        if(check(mid))
            r=mid;
        else
            l=mid;
    }
    cout<<r<<endl;
    return 0;
}

Measured memory_bytes: 4508
import itertools
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353


def get_factorials(max, mod=None):
    """
    階乗 0!, 1!, 2!, ..., max!
    :param int max:
    :param int mod:
    :return:
    """
    ret = [1]
    n = 1
    if mod:
        for i in range(1, max + 1):
            n *= i
            n %= mod
            ret.append(n)
    else:
        for i in range(1, max + 1):
            n *= i
            ret.append(n)
    return ret


def mod_invs(max, mod):
    """
    逆元のリスト 0 から max まで
    :param int max:
    :param int mod:
    """
    invs = [1] * (max + 1)
    for x in range(2, max + 1):
        invs[x] = (-(mod // x) * invs[mod % x]) % mod
    return invs


def factorial_invs(max, mod):
    """
    階乗 0!, 1!, 2!, ..., max! の逆元
    :param int max:
    :param int mod:
    """
    ret = []
    r = 1
    for inv in mod_invs(max, mod):
        r = r * inv % mod
        ret.append(r)
    return ret


class Combination:
    def __init__(self, max, mod):
        """
        :param int max:
        :param int mod: 3 以上の素数であること
        """
        self._factorials = get_factorials(max, mod)
        self._finvs = factorial_invs(max, mod)
        self._mod = mod

    def ncr(self, n, r):
        """
        :param int n:
        :param int r:
        :rtype: int
        """
        if n < r:
            return 0
        return self._factorials[n] * self._finvs[r] % self._mod * self._finvs[n - r] % self._mod


def test2(X):
    ret = 0
    for xs in itertools.permutations(X[:-1]):
        print(xs)
        a = 0
        ss = list(X)
        for x in xs:
            ret += ss[ss.index(x) + 1] - x
            a += ss[ss.index(x) + 1] - x
            ss.remove(x)
            print(ss)
        print(a)
        print()
    print(ret % MOD)
    print()
    print()


N = int(sys.stdin.buffer.readline())
X = list(map(int, sys.stdin.buffer.readline().split()))

inv2 = pow(2, MOD - 2, MOD)


def div2(n):
    return n % MOD * inv2 % MOD


def diff(A):
    ret = []
    for a, b in zip(A, A[1:]):
        ret.append(b - a)
    return ret


factorials = get_factorials(N + 10, MOD)
# test2(X)
# test(np.diff(X))

st = [0]
# 何回使うか
# わからんぽん
# https://oeis.org/A000254
for i in range(N + 1):
    st.append((i + 1) * st[-1] % MOD + factorials[i])

comb = Combination(max=N + 10, mod=MOD)
ans = 0
for i, d in enumerate(diff(X)):
    ans += d * st[i + 1] % MOD * comb.ncr(N, i + 1) % MOD * factorials[N - i - 1] % MOD
    ans %= MOD
ans *= pow(N, MOD - 2, MOD)
ans %= MOD
print(ans)

# for i in range(8):
#     N = i
#     counts = [0] * (N + 1)
#     for order in itertools.permutations(range(N)):
#         used = np.zeros(N)
#         a = 0
#         for i in order:
#             if used[:i].sum() == 0:
#                 a += 1
#                 used[i] = 1
#         counts[a] += 1
#     print(N)
#     print(counts)
#     print(counts * np.arange(N + 1))
#     print((counts * np.arange(N + 1)).sum())
#     print()


Measured memory_bytes: 59452
n = int(input())
a = [int(x) for x in input().split()]
a.sort()
y = a[-1]
m = None
x = None
for i in range(n - 1):
    k = a[i]
    l = max(k, y - k)
    if m is None or m > l:
        m = l
        x = k
print(y, x)


Measured memory_bytes: 14052
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
  int n, k;
  int ans = 0;
  cin >> n >> k;
  int p[n];

  for (int i = 0; i < n; i++)
  {
    cin >> p[i];
  }
  sort(p, p + n);
  
  for (int i = 0; i < k; i++)
  {
    ans += p[i];
  }

  cout << ans;
  
  
  return 0;
}


Measured memory_bytes: 3156
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n = sc.nextInt();
    static int a[] = new int[n];

    public static void main(String[] args) {
        for (int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }
        for (int i = n - 1; i >= 0; i--){
            System.out.print(a[i]);
            if (i != 0){
                System.out.print(" ");
            }
        }
        System.out.println();
    }
}



Measured memory_bytes: 26376
#include <stdio.h>
#define Max 100
int n, A[Max][Max] = {0};

void print(int A[][Max]) {
  for ( int i = 0; i < n; ++i ) {
    for ( int j = 0; j < n; ++j ) {
      printf("%d", A[i][j]);
      if ( j < n - 1 ) printf(" ");
      if ( j == n - 1 ) putchar('\n');
    }
  }
}

int main(void) {
  int k, u, v;
  scanf("%d", &n);
  for ( int i = 0; i < n; ++i ) {
    scanf("%d", &u);
    scanf("%d", &k);
    for ( int j = 0; j < k; ++j ) {
      scanf("%d", &v);
      A[u - 1][v - 1] = 1;
    }
  }
  print(A);
}



Measured memory_bytes: 1968
l,r = map(int,input().split())
mod = 2019
ans = (l*r)%mod
if r - l >= 2018:
  ans = 0
else:
  for i in range(l,r):
    for j in range(i+1,r+1):
      ans = min(ans,(i*j)%mod)

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int f=0;
	while(a>0 && c>0){
		if(f==0){
			c-=b;
			f=1;
		}else{
			a-=d;
			f=0;
		}
	}
	if(a<=0)cout<<"No"<<endl;
	else cout <<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n==1)
		cout<<"Hello World"<<endl;
	else{
		int a,b;
		cin>>a>>b;
		cout<<a+b<<endl;
	}
} 

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

int main(){
  int i,H,W,N,fh,fw,l=0,r,u=0,d;
  char S[200001],T[200001];
  scanf("%d",&H);
  d=H-1;
  scanf("%d",&W);
  r=W-1;
  scanf("%d",&N);
  scanf("%d",&fh);
  fh--;
  scanf("%d",&fw);
  fw--;
  scanf("%s",S);
  scanf("%s",T);

  for(i=N-1;i>=0;i--){
    switch(T[i]-'A'){
      case 3://d
        if(u!=0)u--;
        break;
      case 11://l
        if(r!=W-1)r++;
        break;
      case 17://r
        if(l!=0)l--;
        break;
      case 20://u
        if(d!=H-1)d++;
        break;
    }
    switch(S[i]-'A'){
      case 3://d
        d--;
        break;
      case 11://l
        l++;
        break;
      case 17://r
        r--;
        break;
      case 20://u
        u++;
        break;
    }
    if(l>r||u>d){
      printf("NO\n");
      return 0;
    }
  }
  if((l<=fw&&fw<=r) && (u<=fh&&fh<=d)){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

bool board[100][100];

int main(int argc, char *argv[]) {
	int A, B;
	cin >> A >> B;

	for (int y = 0; y < 50; y++) {
		for (int x = 0; x < 100; x++) {
			board[x][y] = false;
		}
	}

	for (int y = 50; y < 100; y++) {
		for (int x = 0; x < 100; x++) {
			board[x][y] = true;
		}
	}

	A--;
	int px = 1, py = 1;
	while (A > 0) {
		board[px][py] = true;
		px += 2;
		A--;
		if (px >= 100) {
			py += 2;
			px = 1;
		}
	}

	B--;
	px = 1, py = 51;
	while (B > 0) {
		board[px][py] = false;
		px += 2;
		B--;
		if (px >= 100) {
			py += 2;
			px = 1;
		}
	}

	cout << 100 << " " << 100 << endl;
	for (int y = 0; y < 100; y++) {
		for (int x = 0; x < 100; x++) {
			if (board[x][y]) cout << ".";
			else cout << "#";
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <math.h>
using namespace std;


int calc_count(string str){
  int counter = 0;
  for(int i = 1; i < str.size(); i++){
    if(str[i] == str[i-1]){
      counter++;
    }
  }
  return counter;
}

int calc_switch_counter(string str){
  int counter = 0;
  for(int i = 1; i < str.size(); i++){
    if(str[i] != str[i-1]){
      counter++;
    }
  }
  return counter;
}

int main(){
  int N,K;
  string str;
  cin >> N >> K;
  cin >> str;  
  int improve_score = 2;
  unsigned long long ans = 0;
  ans = calc_count(str);
  int switch_counter = calc_switch_counter(str);
  for(int i = 0; i < K; i++){
    if(switch_counter >= 2){
      ans += 2;
      switch_counter -= 2;
    } else if(switch_counter == 1){
      ans += switch_counter;
      switch_counter = 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main() {
	int q,c[100], a[100], n[100];
	cin >> q;
	for (int i = 0; i < q; i++)cin >> c[i] >> a[i] >> n[i];

	for (int i = 0; i < q; i++) {
		int cnt = 0;
		if (c[i] != 0) {
			while (c[i] > 0 && a[i] > 0 && n[i] > 0) {
				c[i]--; a[i]--; n[i]--;
				cnt++;
			}
			while (c[i] > 1 && a[i] > 0) {
				c[i] -= 2; a[i]--;
				cnt++;
			}
			while (c[i] > 2) {
				c[i] -= 3;
				cnt++;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define ins insert
#define sz(x) (long long)x.size()
typedef long long ll;
typedef long double ld;
const int N = 1e5 + 5;
const ld pi = 3.141592653;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;
const ll INF = __LONG_LONG_MAX__;

using namespace std;

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

struct point { ll x, y; }; 

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int T = 1;
        //cin>>T;
        while(T--)
        {
                ll n, i;
                cin>>n;
                vector< struct point> pt(n);
                vector< ll > a(n), b(n);
                for(i = 0; i<n; i++){
                        cin>>pt[i].x>>pt[i].y; 
                        a[i] = pt[i].x + pt[i].y;
                        b[i] = pt[i].x - pt[i].y;
                }
                sort(a.begin(), a.end());
                sort(b.begin(), b.end());
                cout<< max(abs(a.front() - a.back()), abs(b.front() - b.back()));
        }
        return 0;
}

Measured memory_bytes: 9524
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<complex>

using namespace std;




typedef complex<double> P;

const double eps = 1e-8;

int calc(double a, double b, double c,pair<double,double>& ans){
	//cout << a <<" "<< b <<" "<< c << endl;
	double rt;
	if ((rt=b*b - 4 * a*c) < 0)return 0;
	rt = sqrt(rt);
	ans.first = (-b - rt) / (2 * a);
	ans.second = (-b + rt) / (2 * a);
	if (ans.first < 0 && ans.second < 0)return 0;
	else if (ans.first < 0){
		swap(ans.first, ans.second);
		return 1;
	}
	else if (ans.second < 0)return 1;
	return 2;

}

struct Dog{
	P pos;
	P v;
	double max_v;
	int cnt;
	Dog(double x,double y,double s){
		pos.real(x); pos.imag(y); max_v = s; cnt = 0;;
	}
};
const double INF = 1e9;
int main(){
	int N, M;
	double x, y, v;
	while (true){
		cin >> N >> M;
		if (N == 0 && M == 0)return 0;

		vector<Dog> dog;
		for (int i = 0; i < N; i++){
			cin >> x >> y >> v;
			dog.push_back(Dog(x, y, v));
		}
		for (int i = 0; i < M; i++){
			cin >> x >> y;
			P FP(x, y);
			cin >> x >> y;
			P FU(x, y);
			double res = INF;
			int index = -1;
			for (int j = 0; j < N; j++){
				pair<double, double> T;
				int num = calc(FU.real()*FU.real() + FU.imag()*FU.imag() - dog[j].max_v*dog[j].max_v,
					2*(FP.real() - dog[j].pos.real())*FU.real() + 2*(FP.imag() - dog[j].pos.imag())*FU.imag(),
					(FP.real() - dog[j].pos.real())*(FP.real() - dog[j].pos.real()) + (FP.imag() - dog[j].pos.imag())*(FP.imag() - dog[j].pos.imag()), T);
		//		cout << T.first << " " << T.second << endl;
				if (num == 2){
					double t = min(T.first, T.second);
					if (t < eps)dog[j].v.real(0), dog[j].v.imag(0);
					dog[j].v = (FP - dog[j].pos) / t + FU;
					if (t < res){
						res = t;
						index = j;
					}
				}
				else  if (num == 1){
					double t = T.first;
					if (t < eps)dog[j].v.real(0), dog[j].v.imag(0);
					dog[j].v = (FP - dog[j].pos) / t + FU;
					if (t < res){
						res = t;
						index = j;
					}
				}
				else{
					dog[j].v.real(0), dog[j].v.imag(0);
				}
		//		cout << res << endl;
			}
			dog[index].cnt++;
			for (int j = 0; j < N; j++){
				dog[j].pos = dog[j].pos + dog[j].v*res;
			}
		}

		for (int i = 0; i < N-1; i++){
			cout << dog[i].cnt << " ";
		}
		cout << dog[N - 1].cnt << endl;

	}



	return(0);
}

Measured memory_bytes: 1248
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    string s;
    cin >> s;
    int n = s.length();

    deque<int> deq;
    for(int i = 0; i < n; ++i){
        int num = s[i] - '0';
        if(deq.empty()) deq.push_back(num);
        else{
            if(num == deq.back())   deq.push_back(num);
            else    deq.pop_back();
        }
    }
    int ans = n - (int)deq.size();
    cout << ans << endl;
}

Measured memory_bytes: 720
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 10000000007; //10^9+7

ll n,y;

int main(){
  cin>>n>>y;
  int sum=y/1000;
  REP(ten,2002)REP(five,2002){
    int one=n-ten-five;
    if(one<0)continue;
    if(sum==one+five*5+ten*10){
      print(ten<<" "<<five<<" "<<one);
      return 0;
    }
  }
  print("-1 -1 -1");
  return 0;
}

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

#define INF 100000000
#define MOD9(a) (a%1000000009)
#define MOD7(a) (a%1000000007)
#define ABS(a) (a<0?-(a):a)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define REP(i,a) for(int i=0;i<a;i++) 

using namespace std;
int main(){
  vector<int> v;
  int n;
  cin >> n;

  REP(i, n){
    int po;
    cin >> po;
    if(i % 2 == 0){
      v.push_back(po);  
    }else{
      v.insert(v.begin(), po); 
    }
  }

  if(n % 2 == 0){
    REP(i, n){
      cout << v[i] << " ";
    }
  
  }else{
    REP(i, n){
      cout << v[n-1-i] << " ";
    }
  
  }
  cout << endl;

}



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int ans;
int main(void){
	int n; cin>>n;
	int m=n;
	int k=0;
	if(m/10!=0){
		m=m/10;
		k++;
		ans=ans+9;
	}
	if(m/10!=0){
		m=m/10;
		k++;
	}
	if(m/10!=0){
		m=m/10;
		k++;
		ans=ans+900;
	}
	if(m/10!=0){
		m=m/10;
		k++;
	}
	if(m/10!=0){
		m=m/10;
		k++;
		ans=ans+90000;
	}
	int t=1;
	for(int i=0;i<k;i++){
		t=t*10;
	}
	if(m!=0){
		if(k%2==0){
			ans=ans+n-t+1;
		}
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() 
{
        //   #ifndef ONLINE_JUDGE
        //        freopen("input.txt", "r", stdin);
        //        freopen("output.txt", "w", stdout);
        //    #endif
    int n,k;
cin >> n >> k;
int a[n + 1];
int i;
for (i = 1; i <= n; i++)
{
    cin >> a[i];
    }
    vector<int> dp(n+1,INT_MAX);
    int j;
    dp[1]=0;
    for(i=2;i<=n;i++)
    {
        for(j=i-1;(j>=1&&(i-j)<=k);j--)
        {
            dp[i]=min(dp[i],(dp[j]+abs(a[i]-a[j])));
        }
    }
    // for(i=1;i<=n;i++)
    // {
    //     cout<<dp[i]<<" ";
    // }
    cout<<dp[n]<<endl;
}

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


int main() {
  int a, b, c, d;
  if (a > c) {
    swap(c, a);
    swap(b, d);
  }
  
  scanf("%d %d %d %d", &a, &b, &c, &d);
  if (a > c) {
    swap(c, a);
    swap(b, d);
  }
  if (c >=b)
    printf("0");
  else if (a <= c && c <= b && b <= d)
    printf("%d", b-c);
  else if (a<=c && d <= b)
    printf("%d", d-c);
  
  return 0;
  
}



Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
int n;
set<int> we;
signed main()
{
	scanf("%d",&n);int t;
	for(register int i(1);i<=n;i++)
	{
		scanf("%d",&t);
		//((we.find(t))-(we.end()))?(we.erase(t)):(we.insert(t));
		if((we.find(t))!=(we.end())){we.erase(t);}else{we.insert(t);}
	}
	printf("%d",we.size()),we.clear();
	return putchar(10),0;
}

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

void trip(int y,int x,vector<vector<int>>&mp){
	mp.at(y).at(x)=0;
	for(int dy=-1;dy<=1;++dy){
		for(int dx=-1;dx<=1;++dx){
			int nxy=y+dy,nxx=x+dx;
			if(nxy<0||nxy>=mp.size()||nxx<0||nxx>=mp.at(nxy).size()||!mp.at(nxy).at(nxx))continue;
			trip(nxy,nxx,mp);
		}
	}
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	while(true){
		int w,h; cin>>w>>h;
		if(w==0&&h==0)break;
		vector<vector<int>>mp(h,vector<int>(w));
		for(auto&&i:mp)for(auto&&j:i)cin>>j;
		int cnt=0;
		for(int y=0;y<h;++y){
			for(int x=0;x<w;++x){
				if(mp.at(y).at(x)){
					trip(y,x,mp);
					++cnt;
				}
			}
		}
		cout<<cnt<<"\n"s;
	}
}



Measured memory_bytes: 3488
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long long ll;

int a[100005], b[100005];

int main()
{
 	//freopen("input.txt", "r", stdin);
 	//freopen("output.txt", "w", stdout);
 	ios_base::sync_with_stdio(0); cin.tie(0);
 	int A, B, M;
 	cin >> A >> B >> M;
 	for (int i = 1; i <= A; i++) cin >> a[i];
 	for (int i = 1; i <= B; i++) cin >> b[i];

 	int mn1 = a[1], mn2 = b[1];
 	for (int i = 1; i <= A; i++) mn1 = min(mn1, a[i]);
 	for (int i = 1; i <= B; i++) mn2 = min(mn2, b[i]);

 	int ans = mn1 + mn2;
 	for (int i = 1; i <= M; i++)
 	{
 	 	int x, y, c;
 	 	cin >> x >> y >> c;
 	 	ans = min(ans, a[x] + b[y] - c);
 	}
 	cout << ans << '\n';
 	return 0;
}

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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  int n,m;cin>>n>>m;
  int x,y;

  int cnt[n];
  fill(cnt, cnt+n, 1);
  int red[n]={};
  red[0]=1;

  rep(i, m){
    cin>>x>>y;x--;y--;
    if (red[x] and cnt[x]==1){
      red[x]=0;
      cnt[x]--;
      red[y]=1;
      cnt[y]++;
    }
    else if (red[x] and cnt[x]!=1){
      cnt[x]--;
      cnt[y]++;
      red[y]=1;
    }
    else{
      cnt[x]--; cnt[y]++;
    }
  }
  int ans=0;
  rep(i, n){
    if (red[i]) ans++;
  }
  cout << ans << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 1792
import Control.Applicative ((<$>))
import Control.Monad (replicateM)

main :: IO ()
main = do
  [n, x] <- map read <$> words <$> getLine
  solve n x <$> replicateM n readLn >>= print

solve :: Int -> Int -> [Int] -> Int
solve n x ms = n + (x - sum ms) `div` (minimum ms)


Measured memory_bytes: 1020
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
typedef pair<int, ll> Pil;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;
int const POW_MAX = 1e5;

// nCr
ll po[POW_MAX + 2];
ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
ll mod_inv (ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}
ll comb(int n, int r) {
  return (((po[n] * mod_inv(po[r])) % MOD) * mod_inv(po[n - r])) % MOD;
}
// greatest common divisor
ll gcd(ll a, ll b) {
  while (a % b != 0) {
    ll tmp = a;
    a = b;
    b = tmp % b;
  }
  return b;
}

int const N_MAX = 1e5;

int N;
vector<vector<ll>> vs;
map<int, vector<Pil>> tree;
int ans[N_MAX + 1];
map<int, int> read;

int main() {
  scanf("%d", &N);

  rep(i, N - 1) {
    int u, v;
    ll w;
    scanf("%d %d %lld", &u, &v, &w);
    tree[u].push_back(Pil(v, w));
    tree[v].push_back(Pil(u, w));
  }

  queue<int> Q;
  Q.push(1);
  read[1] = 1;
  while (!Q.empty()) {
    int i = Q.front();
    Q.pop();
    vector<Pil> xs = tree[i];
    for (Pil x : xs) {
      if (read[x.first]) continue;

      if (x.second % 2 == 0) {
        ans[x.first] = ans[i];
      } else {
        ans[x.first] = 1 - ans[i];
      }
      Q.push(x.first);
      read[x.first]++;
    }
  }
  for (int i = 1; i < N + 1; i++) {
    printf("%d\n", ans[i]);
  }
}


Measured memory_bytes: 18432
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc149/tasks/abc149_e>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N,M; cin >> N >> M;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    
    sort(A.begin(),A.end());
    ll l = 0, r = INF;
    while(r-l>1){
        ll m = (l+r)/2;
        
        ll x = 0;
        for(int i = 0; i < N;i++){
            ll it = lower_bound(A.begin(),A.end(),m-A[i]) - A.begin();
            x += N-it;
        }
        if(x >= M){
            l = m;
        }else{
            r = m;
        }
    }
    
    vector<ll> cusum(N+1);
    reverse(A.begin(),A.end());
    for(int i = 0; i < N;i++) cusum[i+1] = cusum[i] + A[i];
    reverse(A.begin(),A.end());

    ll left = M;
    for(int i = 0; i < N;i++){
        ll it = lower_bound(A.begin(),A.end(),r-A[i]) - A.begin();
        res += cusum[N-it] + A[i]*(N-it);
        left -= N-it;
    }
    res += l*left;
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n,k;cin>>n>>k;
  if(n%k==0){
    P(0);
  }else{
    P(1);
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
const double eps = 1e-10;
const int maxn = 1e5 + 100;

int main() {
#ifdef ac
    //freopen("in.txt" , "r" , stdin);
//    freopen("out.txt" , "w" , stdout);
#endif
    string s,ss;
    cin >> s;
    for(int i=0;i<s.size();++i) {
        if(s[i]=='0'||s[i]=='1')ss.push_back(s[i]);
        else if(ss.empty()) continue;
        else ss.erase(ss.end()-1);
    }
    cout << ss <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);
const double eps=1e-8;

vector<bool> NEWS(4,1);
string str;

int main(){
	cin>>str;
	for(int i=0;i<str.size();i++){
		if(str[i]=='N') NEWS[0]=0;
		else if(str[i]=='E') NEWS[1]=0;
		else if(str[i]=='W') NEWS[2]=0;
		else if(str[i]=='S') NEWS[3]=0;
	}
	if(NEWS[0]==NEWS[3]&&NEWS[1]==NEWS[2]) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n;
  cin >>  n;
  if(n/100 == 7 || n%100/10 == 7 || n % 10 == 7){
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}


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

int main(){
	int n,m,p,i,j,k,ac=0,wa=0,a[100100],w[100100];
	string s;
	cin>>n>>m;
	for(i=0;i<=n;i++){
        a[i]=0;
        w[i]=0;
	}
	for(j=1;j<=m;j++){
		cin>>p>>s;
		if(a[p]==0){
            if(s=="AC"){
                ac++;
                a[p]=1;
            }
            else{
                w[p]++;
            }
		}
	}
	for(k=1;k<=n;k++){
		if(a[k]==1){
			wa=wa+w[k];
		}
	}
	cout<<ac<<" "<<wa;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int mod=1e9+7;
#define N 505
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,m,cnt[N],ans,fac[N],inv[N];
int dp[2][N][N]; // 区间长度到i，区间个数j，区间长度和 k。 
inline int qpow(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}
	return ans;
}
void init(int n){
	fac[0]=1;
	for(int i=1;i<=n;++i){
		fac[i]=1LL*fac[i-1]*i%mod;
	}
	inv[n]=qpow(fac[n],mod-2);
	for(int i=n-1;i>=0;--i){
		inv[i]=1LL*inv[i+1]*(i+1)%mod;
	}
}
inline int C(int n,int m){
	return 1LL*fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=n;++i){
		++cnt[read()];
	}
	init(m);
	dp[(m+1)&1][0][0]=1;
	for(int i=m;i>=1;--i){
		memset(dp[i&1],0,sizeof(dp[i&1]));
		for(int j=0;j<=m/i;++j){
			for(int k=j*i;k<=m;++k){
				if(!dp[(i+1)&1][j][k])continue;
				int lim=min((m-k)/i,m-j);
				for(int p=0;p<=lim;++p){
					dp[i&1][j+p][k+p*i]=(dp[i&1][j+p][k+p*i]+1LL*dp[(i+1)&1][j][k]*inv[p])%mod;
				}
			}
		}
		for(int j=0;j<=m;++j){
			for(int k=j*(i-1);k<=m;++k){
				dp[i&1][j][k]=1LL*dp[i&1][j][k]*qpow(k-j*(i-1),cnt[i])%mod;
			}
		}
	}
	for(int j=0;j<=m;++j){
		for(int k=0;k<=m;++k){
			ans=(ans+1LL*fac[j]*dp[1][j][k]%mod*C(m-k+1,j)*((m-k)&1?-1:1))%mod;
		}
	}
	printf("%d\n",(ans+mod)%mod);
	return 0;
}



Measured memory_bytes: 5728
from collections import Counter
n, a, b, c = map(int, input().split())
L = [int(input()) for _ in range(n)]


def base_n(x, n, zero_padding=8):
    retval = [[], ['0']][x == 0]
    while x > 0:
        x, r = divmod(x, n)
        retval.append(str(r))
    cnt = zero_padding - len(retval)
    pad = ['', '0'*cnt][cnt > 0]
    return pad+''.join(retval[::-1])

ans = 10**8
for i in range(4**n):
    base_4 = base_n(i, 4, n)
    n_bamboo = n - base_4.count("0")
    ctr = Counter(base_4)
    if n_bamboo < 3 or any(k not in ctr.keys() for k in "123"):
        continue

    cost = 0
    for x, y in zip([a, b, c], "123"):
        cost += abs(x - sum(L[idx]for idx, v in enumerate(base_4)
                            if v == y))+(ctr[y]-1)*10
    if ans > cost:
        ans = cost
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <ctime>

using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define RN cout << "\r\n";
#define fi first
#define se second
typedef long long int ll;
typedef pair<ll, ll> P;


// start combination mod n
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

int main() {
    int a;
    cin >> a;
    vector<int> c;
    c.resize(a);
    REP(i, a) {
        int number;
        cin >> number;
        c[i] = number - i;
    }
    sort(ALL(c));
    int bounce = c[c.size() / 2];
    int bounce2 = c[c.size() / 2 + 1];

    ll ans = 0;
    for (int d : c) {
        ans += abs(bounce - d);
    }
    ll ans2 = 0;
    for (int d : c) {
        ans2 += abs(bounce2 - d);
    }
    cout << min(ans, ans2);
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int main()
{
	int N;
	cin>>N;
	while(N--)
	{
		int x;
		cin>>x;
		v.push_back(x);
	}
	sort(v.begin(),v.end());
	cout<<v[v.size()/2]-v[v.size()/2-1]<<endl;
	return 0;
}

Measured memory_bytes: 892
/*************************************************************************
    > File Name: d.cpp
    > Author: Amano Sei
    > Mail: amano_sei@outlook.com 
    > Created Time: 2020年01月19日 星期日 21时41分06秒
 ************************************************************************/

#include <cstdio>

int cnt[10][10];

inline int firstbit(int x){
    while(x/10)
        x/= 10;
    return x;
}

int main(){
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
        cnt[firstbit(i)][i%10]++;
    register long long ans = 0;
    for(int i = 0; i < 10; i++)
        for(int j = 0; j < 10; j++)
            ans += cnt[i][j]*cnt[j][i];
    printf("%lld\n", ans);
    return 0;
}



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

int n, m, ans, match[9][9];

bool check(int y){
  int win=0, lose=0;
  rep(x, n){
    if(match[y][x]==1) win++;
    else if(match[y][x]==-1) lose++;
  }
  return (win<=(n-1)/2 && lose<=(n-1)/2);
}

void dfs(int cur){
  int x = cur%n;
  int y = cur/n;

  if(cur==n*n){
    ans++; return;
  }

  if(x==y || match[y][x]!=0){
    if(check(y)) dfs(cur+1);
    return;
  }

  match[y][x] = 1; match[x][y] = -1;
  if(check(y)) dfs(cur+1);

  match[y][x] = -1; match[x][y] = 1;
  if(check(y)) dfs(cur+1);

  match[y][x] = match[x][y] = 0;
}

int main() {
  while(cin>>n){
    if(n==0) return 0;

    memset(match, 0, sizeof(match));

    cin >> m;
    rep(i, m){
      int x, y; cin >> x >> y;
      x--; y--;
      match[x][y] = 1;
      match[y][x] = -1;
    }

    ans = 0;
    dfs(0);
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 3084
N = int(input())
H = list(map(int, input().split()))
# H[N-2],H[N-3],...,H[0]について
for i in range(N - 2, -1, -1):
    if H[i] > H[i + 1] + 1:
        print("No")
        exit()
    if H[i] == H[i + 1] + 1:
        H[i] -= 1
print("Yes")


Measured memory_bytes: 20656
fun main(args:Array<String>) {
	val n = readLine()!!.toInt()
	val x6 = listOf(6, 36, 216, 1296, 7776, 46656)
	val x9 = listOf(9, 81, 729, 6561, 59049)
	val step = (x6+x9+1).sorted()
	val dp = IntArray(n+1){it}
	for(i in dp.indices){
		step.filter{i+it<=n}.forEach {
			dp[i+it]=Math.min(dp[i+it],dp[i]+1)
		}
	}
	println(dp[n])
}

Measured memory_bytes: 40440
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll H, N;
  cin >> H >> N;
  ll sum = 0;
  rep(i,N) {
    ll A; cin >> A;
    sum += A;
  }
  printf("%s", sum >= H ? "Yes" : "No");
}



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

class Dice{
    private:
        std::vector<int> d;
    public:
        Dice(std::vector<int> a) {
            d = a;
            d.push_back(0); // tmp用
        }

        void N() {
            d.at(6) = d.at(1 - 1);
            d.at(1 - 1) = d.at(2 - 1);
            d.at(2 - 1) = d.at(6 - 1);
            d.at(6 - 1) = d.at(5 - 1);
            d.at(5 - 1) = d.at(6);
        }

        void S() {
            d.at(6) = d.at(1 - 1);
            d.at(1 -1 ) = d.at(5 - 1);
            d.at(5 - 1) = d.at(6 - 1);
            d.at(6 - 1) = d.at(2 - 1);
            d.at(2 - 1) = d.at(6);
        }

        void W() {
            d.at(6) = d.at(1 - 1);
            d.at(1 - 1) = d.at(3 - 1);
            d.at(3 - 1) = d.at(6 - 1);
            d.at(6 - 1) = d.at(4 - 1);
            d.at(4 - 1) = d.at(6);
        }

        void E() {
            d.at(6) = d.at(1 - 1);
            d.at(1 - 1) = d.at(4 - 1);
            d.at(4 - 1) = d.at(6 - 1);
            d.at(6 - 1) = d.at(3 - 1);
            d.at(3 - 1) = d.at(6);
        }

        void R() {
            // 右回転
            d.at(6) = d.at(2 -1);
            d.at(2 - 1) = d.at(4 - 1);
            d.at(4 - 1) = d.at(5 - 1);
            d.at(5 - 1) = d.at(3 - 1);
            d.at(3 - 1) = d.at(6);
        }

        void L() {
            // 左回転
            d.at(6) = d.at(2 - 1);
            d.at(2 - 1) = d.at(3 - 1);
            d.at(3 - 1) = d.at(5 - 1);
            d.at(5 - 1) = d.at(4 - 1);
            d.at(4 - 1) = d.at(6);
        }

        int get_dice_1() {
            return d.at(1 - 1);
        }
        int get_dice_2() {
            return d.at(2 - 1);
        }
        int get_dice_3() {
            return d.at(3 - 1);
        }
 };

int main(void) {
    using namespace std;

    vector<int> a(6);
    for (int i = 0; i < 6; i++) {
        cin >> a.at(i);
    }

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        Dice dice(a);
        int a1, a2;
        cin >> a1 >> a2;
        int flg1 = false;
        for (int j = 0; j < 4; j++) {
            if (dice.get_dice_1() == a1) {
                flg1 = true;
                break;
            } else {
                dice.N();
            }
        }
        // flg1がfalseなら右回転させる
        if (!flg1) {
            dice.R();
            dice.N();
            if (dice.get_dice_1() == a1) {
                flg1 = true;
            } else {
                dice.S();
                dice.L();
            }
        }
        // まだダメなら左回転させる
        if (!flg1) {
            dice.L();
            dice.N();
        }
        // 1面は合ったので、あとは右回転させ続ける
        for (int j = 0; j < 4; j++) {
            if (dice.get_dice_2() == a2) {
                printf("%d\n", dice.get_dice_3());
                break;
            } else {
                dice.R();
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3204
import math
import decimal
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

class Library():
    @staticmethod
    def Swap(a,b):
        return [b,a]

    @staticmethod
    def myRound(a,dig=0): # 四捨五入
        p = 10 ** dig
        return (a * p * 2 + 1) // 2 / p

    @staticmethod
    def Roundup(a,dig=0): # 切り上げ
        if a < 0:
            return int(a)
        else:
            return int(a + 0.9)

    @staticmethod
    def Gcd(a,b): #最大公約数
        if (a<b):
            a,b = Library.Swap(a,b)
        if (b==0):
            return a
        else:
            return Library.Gcd(b,a%b)

    @staticmethod
    def Lcm(a,b): #最小公倍数
        return a//Library.Gcd(a,b)*b

    @staticmethod
    def Divisors(a): # 約数列挙
        divisors = []
        for i in range(1,int(a**0.5)+1):
            if a%i==0:
                divisors.append(i)
                if i!=a//i:
                    divisors.append(a//i)
        divisors.sort()
        return divisors

class Prime():
    # コンストラクタ
    # エラストテネスの篩
    def __init__(self,num):
        self.num = num
        self.sieve = [0 for i in range(self.num + 1)]
        self.sieve[0] = -1
        self.sieve[1] = -1
        for i in range(2,self.num + 1):
            if self.sieve[i] == 0:
                self.sieve[i] = i
                for j in range(i + i,self.num + 1,i):
                    self.sieve[j] = i
    
    # 素数判定
    def isPrime(self,num = None):
        if num is None:
            num = self.num
        if self.sieve[num] == num:
            return True
        else:
            return False
    
    # 素数列挙
    def PrimeNum(self,num = None):
        if num is None:
            num = self.num
        prime = []
        for i in range(2,num):
            if self.sieve[i] == i:
                prime.append(i)
        return prime
    
    # 素因数分解
    def PrimeFact(self,num = None):
        if num is None:
            num = self.num
        fact = []
        while self.sieve[num] != num:
            fact.append(self.sieve[num])
            num //= self.sieve[num]
        fact.append(num)
        return fact

def main():
    n = int(input())
    mp = {}
    for i in range(1,n+1):
        s = i % 10
        t = i
        while t >= 10:
            t //= 10
        if t * 10 + s in mp.keys():
            mp[t * 10 + s] += 1
        else:
            mp[t * 10 + s] = 1
    ans = 0
    for i in range(1,10):
        for j in range(1,10):
            if j * 10 + i in mp.keys() and i * 10 + j in mp.keys():
                ans += mp[j * 10 + i] * mp[i * 10 + j]
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 63592
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		int n, m, d, i, j, k, counter = 0;
		boolean flag;
		String str;
		try (Scanner sc = new Scanner(System.in)) {
			n = sc.nextInt();
			m = sc.nextInt();
			d = sc.nextInt();
			char[][] stage = new char[n][m];
			for(i = 0; i < n; i++) {
				str = sc.next();
				for(j = 0; j < m; j++) {
					stage[i][j] = str.charAt(j);
				}
			}
			for(i = 0; i < n; i++) {
				for(j = 0; j < m; j++) {
					for(k = 0, flag = true; k < d; k++) {
						if(i + k < n) {
							if(stage[i + k][j] == '#') {
								flag = false;
								break;
							}
						}else {
							flag = false;
						}
					}
					if(flag) {
						counter++;
					}
					for(k = 0, flag = true; k < d; k++) {
						if(j + k < m) {
							if(stage[i][j + k] == '#') {
								flag = false;
								break;
							}
						}else {
							flag = false;
						}
					}
					if(flag) {
						counter++;
					}
				}
			}
			System.out.println(counter);
		}
	}
}


Measured memory_bytes: 28164
import sys

stdin = sys.stdin


def na(): return map(int, stdin.readline().split())


def ns(): return stdin.readline().strip()


n,m = map(int,stdin.readline().split())

deg = [0]*n
for i in range(m):
    x, y = map(int, stdin.readline().split())
    deg[x-1] += 1
    deg[y-1]  += 1
for i in range(n):
    print(deg[i])

Measured memory_bytes: 3064