akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <iostream>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  l64 s[n][2], g[m][2];
  for (int i = 0; i < n; ++i) {
    cin >> s[i][0] >> s[i][1];
  }
  for (int i = 0; i < m; ++i) {
    cin >> g[i][0] >> g[i][1];
  }
  for (int i = 0; i < n; ++i) {
    int best_id;
    u64 best_dist;
    for (int j = 0; j < m; ++j) {
      u64 dist = abs(s[i][0]-g[j][0]) + abs(s[i][1]-g[j][1]);
      if (j == 0 || dist < best_dist) {
        best_id = j;
        best_dist = dist;
      }
    }
    cout << best_id+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#define llint long long

using namespace std;

llint n;
llint a[100005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	llint ans = 0;
	for(int i = 2; i <= n; i++){
		if(a[i] > a[i-1]) ans++;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3932
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using Double = long double;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N = 4;
        vector<Int> A(N);
        for (int i = 0; i < N; ++i) cin >> A[i];

        Int tapu = 13333333;
        for (uint mask = 0; mask < 1 << N; ++mask) {
//            if (__pop_count(mask) == 2) {
            if (__builtin_popcount(mask) == 2) {
                Int u = 0, shi = 0;
                for (int i = 0; i < N; ++i) {
                    if (mask >> i & 1) {
                        u += A[i];
                    } else {
                        shi += A[i];
                    }
                }

                Int nichia = abs(u - shi);
                chmin(tapu, nichia);
            }
        }
        cout << tapu << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}



Measured memory_bytes: 3220
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用

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

bool finish = false;

void dfs(vector<string> vec, vector<ll>& eage, stack<ll>& s, ll befo) {
	// v から行ける各頂点 next_v について
	for (int i = 0; i < vec[0].size(); i++) {
		if (befo == i + 1)
			continue;
		if (finish)
		{
			return;
		}
		if (vec[s.top() - 1][i] == '1')
		{
			if (abs(eage[s.top() - 1] - eage[i]) == 1)
				continue;
			else if (eage[s.top() - 1] == eage[i])
			{
				cout << -1 << endl;
				finish = true;
				return;
			}
			else if (!(eage[s.top() - 1] > eage[i]) || eage[i] == -1)
			{
				eage[i] = eage[s.top() - 1] + 1;
				befo = s.top();
				s.push(i % (vec[0].size()) + 1);
				dfs(vec, eage, s, befo); // 再帰的に探索
			}
			else if (i == vec[0].size() - 1)
			{
				s.pop(); return;
			}
		}
	}

	s.pop();
}

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

	int n;
	cin >> n;
	vector<string> s(n);
	vector<ll> group(n, -1);
	stack <ll> st;
	vector<vector<ll>> wa(n, vector<ll>(n, INF));

	rep(i, n)
	{
		cin >> s[i];
	}
	rep(i, n)
	{
		rep(j, n)
		{
			if (s[i][j] == '1')
				wa[i][j] = 1;
		}
	}
	group[0] = 1;
	st.push(1);
	dfs(s, group, st, -1);
	ll ans = 0;

	if (!finish)
	{
		for (int k = 0; k < n; k++) {       // 経由する頂点
			for (int i = 0; i < n; i++) {    // 始点
				for (int j = 0; j < n; j++) {  // 終点
					wa[i][j] = min(wa[i][j], wa[i][k] + wa[k][j]);
				}
			}
		}
		rep(i, n)
		{
			rep(j, n)
			{
                if(i!=j)
				ans = max(ans, wa[i][j]);
			}
		}
		cout << ans+1 << endl;
	}

	return 0;
}

Measured memory_bytes: 1152
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

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

int main() {
	string s, t;
	cin >> s >> t;
	if (s == t) {
		cout << "H" << endl;
	}
	else {
		cout << "D" << endl;
	}
}


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

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

using namespace std;
using ll = long long;

int check(int x) {
  int res = 8;
  if(x >= 1800) res = 1;
  else if(x >= 1600) res = 2;
  else if(x >= 1400) res = 3;
  else if(x >= 1200) res = 4;
  else if(x >= 1000) res = 5;
  else if(x >= 800) res = 6;
  else if(x >= 600) res = 7;

  return res;
}

int main(void)
{
  int x;
  cin >> x;
  cout << check(x) << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-b)<=d&&abs(b-c)<=d||abs(c-a)<=d)cout<<"Yes"<<endl;
  else cout << "No" <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
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; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;



int h, a, ans;

int main() {

	cin >> h >> a;

	ans = h / a;
	if (h % a != 0)ans++;

	cout << ans << endl;

	return 0;
}

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

struct ST
{
	int S;
	int T;

	ST()
	{
		S = T = 0;
	}
};

int main()
{
	string str;
	cin >> str;
	ST st[100005];
	int j = 0;
	for (int i = 0; i < str.size(); i++)
	{
		if (str[i] == 'S')
		{
			st[j].S++;
			i++;
			while (i < str.size()&&str[i] == 'S')
			{
				st[j].S++;
				i++;
			}
			i--;
		}
		else
		{
			st[j].T++;
			i++;
			while (i < str.size() && str[i] == 'T')
			{
				st[j].T++;
				i++;
			}
			i--;
			j++;
		}
	}

	int ans = str.size();
	int ys = 0;
	for (int i = 0; i < j; i++)
	{
		ys += st[i].S;
		if (ys <= st[i].T)
		{
			ans -= ys * 2;
			ys = 0;
		}
		else 
		{
			ans -= st[i].T * 2;
			ys -= st[i].T;
		}
	}
	cout << ans << endl;

}

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

int main() {
  int n, m, a, b;
  std::cin >> n >> m;
  std::vector<int> c(n, 0);
  
  for (int i = 0; i < m; i++) {
    std::cin >> a;
    std::cin >> b;
    c.at(a-1) += 1;
    c.at(b-1) += 1;
  }
  for (int i = 0; i < n; i++) {
    std::cout << c.at(i) << '\n';
  }
}


Measured memory_bytes: 256
# numが100で何回割れるか
def getDevide100Count(num: int):
    n = 0
    while num % 100 == 0:
        num = num / 100 
        n += 1
    return n


d, n = map(int, input().split())
count = 0
i = 0
while count != n:
    i += 1
    if getDevide100Count(i) == d:
        count += 1

print(i)

Measured memory_bytes: 9088
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int i = 1;
		do{
			int x = i;
			if (x % 3 == 0) {
				System.out.print(" " + i);
				continue;
			}
			while (true){
				if (x % 10 == 3){
					System.out.print(" " + i);
					break;
				}
				x /= 10;
				if (x != 0) continue;
				else break;
			}

		}while (++i <= n);
			System.out.println();
	}
}

Measured memory_bytes: 28732
# coding: utf-8
# Your code here!

class Node:
    def __init__(self, id):
        self.id = id
        self.children = []
        self.parent = -1
        self.depth = 0
        self.ntype = None
    
    def __str__(self):
        return 'node {}: parent = {}, depth = {}, {}, {}'\
            .format(self.id, self.parent, self.depth, self.ntype, self.children)

N = int(input())
nodes = [Node(i) for i in range(N)]

for _ in range(N):
    elm = [int(i) for i in input().split()]
    if elm[1] > 0:
        nodes[elm[0]].children = elm[2:]
        nodes[elm[0]].ntype = 'internal node'
        for n in elm[2:]:
            nodes[n].parent = elm[0]
    else:
        nodes[elm[0]].ntype = 'leaf'

root = 0
for node in nodes:
    if node.parent == -1:
        node.ntype = 'root'
        root = node.id
        break
        
def dfs(id, depth):
    node = nodes[id]
    node.depth = depth
    if node.children:
        for child in node.children:
            dfs(child, depth+1)
    else:
        return

dfs(root, 0)

for node in nodes:
    print(node)
    


Measured memory_bytes: 43984
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e9+7
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

ll n, t;
ll a[100100], d[100100];
ll q, x;

int main(){
	cin >> n >> t >> q;
	FOR(i, 1, n + 1){
		cin >> a[i] >> d[i];
	}
	REP(i, q){
		ll goal;
		ll ga = -1, pa = -1;
		cin >> x;

		if (d[x] == 1){
			for (ll j = x + 1; j < n; j++){
				if (d[x] != d[j]){
					ga = j;
					break;
				}
				else pa = j;
			}
		}
		else{
			for (ll j = x - 1; j >= 1; j--){
				if (d[x] != d[j]){
					ga = j;
					break;
				}
				else pa = j;
			}
		}

		if (ga == -1){
			if (d[x] == 1) cout << a[x] + t << endl;
			else cout << a[x] - t << endl;
		}
		else{
			ll goal;
			if (pa == -1){
				goal = (a[ga] + a[x]) / 2;
			}
			else{
				goal = (a[ga] + a[pa]) / 2;
			}
			if (d[x] == 1){
				if (goal - a[x] <= t)cout << goal << endl;
				else cout << a[x] + t << endl;
			}
			else {
				if (a[x] - goal <= t)cout << goal << endl;
				else cout << a[x] - t << endl;
			}
		}
	}
}

Measured memory_bytes: 2720
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
const ll mod=998244353;
char s[100005];
int main()
{
	int n;sc(n);
	getchar();scs(s+1);
	int m=strlen(s+1);
	rep(i,1,min(n,m))pf("%c",s[i]);
	if(strlen(s+1)>n)pf("...");
	pf("\n");
}


Measured memory_bytes: 3720
#include <iostream>
#include <cstdlib> 
#include <cmath>   
#define MAX 2500000  
using std::cout;   
using std::cin;    
using std::endl;


int n, cnt=0;
int L[MAX], R[MAX];
int S[MAX];
void merge(int *a, int left, int mid, int right){
  int n1=mid-left;
  int n2=right-mid;
  for(int i=0;i<n1;i++)
    L[i]=a[left+i];
  for(int i=0;i<n2;i++)
    R[i]=a[mid+i];
  L[n1]=(int)INFINITY;
  R[n2]=(int)INFINITY;  int i=0,j=0;
  for(int k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j]){
      a[k]=L[i++];
    }else{
      a[k]=R[j++];
    }
  }
}

void mergeSort(int *a, int left, int right){
  if(left+1 < right){
    //cnt++;
    int mid=(left+right)/2;
    mergeSort(a, left, mid);
    mergeSort(a, mid, right);
    merge(a, left, mid, right);
  }
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++)
    cin >> S[i];
  mergeSort(S,0,n);
  for(int i=0;i<n;i++){
    if(i) cout << " ";
    cout << S[i];
  }
  cout << endl;
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 7004
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  int N = s.size();

  vector<int> R(N+2), L(N+2);
  int cnt = 0;
  REP(i, N){
    if(s[i] == '<') cnt++;
    else cnt = 0;
    R[i+1] = cnt;
  }
  cnt = 0;
  RREP(i, N){
    if(s[i] == '>') cnt++;
    else cnt = 0;
    L[i] = cnt;
  }

  int ans = 0;
  REP(i, N+1){
    ans += max(R[i], L[i]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 8708
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
long long weird_abs(bool flip, long long a, long long b)
{
    return flip ? a - b : b - a;
}
int main()
{
    while(cin>>n)
    {
        ll x[n+2],y[n+2];
        for(int i=0; i<n; i++)
        {
            cin>>x[i]>>y[i];
        }
        ll ans=-1e18;
        for (int mask = 0; mask < (1 << 4); mask++)
        {
            ll values[n+2];
            ll pre[n+2];
            ll suf[n+2];
            for (int i = 0; i < n; i++)
            {
                values[i] = weird_abs(mask & 1, 0, x[i]) + weird_abs(mask & 2, 0, y[i]) ;
            }
            pre[0]=values[0];
            for(int i=1; i<n; i++)
            {
                pre[i]=max(pre[i-1],values[i]);
            }
            suf[n-1]=values[n-1];
            for(int i=n-2; i>=0; i--)
            {
                suf[i]=max(suf[i+1],values[i]);
            }
            for (int i = 0; i < n; i++)
            {
                ll cur_v = weird_abs(mask & 1, x[i], 0) + weird_abs(mask & 2, y[i], 0) ;
                ll left = i == 0 ? -1e18 : pre[i - 1];
                ll right = i == n - 1 ? -1e18 : suf[i + 1];
                ll req=max(cur_v + left, cur_v + right);
                ans = max(ans,req);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 11492
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=61
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef pair<int,int> pairii;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  int n;
  cin>>n;
  vector<int> v(n);
  rep(h,n)cin>>v[h];
  int cnt=0;
  int mi=1e7+1;
  rep(i,n){
    if(mi>=v[i]){cnt++;cerr<<mi<<v[i];}
    mi=min(mi,v[i]);
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    string ans(3, ' ');
    for(int i=0; i<3; ++i){
        string s;
        cin >> s;
        ans[i] = s[i];
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

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

  string t = "AKIHABARA";

  int i = 0;
  int j = 0;
  for (int j = 0; j < s.size(); j++) {
    if (i == t.size()) {
      cout << "NO" << endl;
      return 0;
    }
    if (t[i] == s[j]) {
      i++;
    } else if (t[i] == 'A') {
      i++;
      j--;
    } else {
      cout << "NO" << endl;
      return 0;
    }
  }

  if (i >= t.size() - 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
using namespace std;
const int N = 1e5+5;
void fast(){std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
ll n;
int main()
{
	fast();
	cin>>n;
	cout<<n*(n-1)/2;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define MAX INT_MAX
#define MIN INT_MIN
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
void solve() {
	int h, n, sum = 0;
	cin >> h >> n;
	vector <int> v(n);
	for(int i=0;i<n;i++) {
		cin >> v[i];
		sum += v[i];
	}
	if(sum >= h)
		cout << "Yes";
	else
		cout << "No";
    return;
}
int32_t main() {
    FO;
    solve();
    return 0;
}


Measured memory_bytes: 1024
/*~~~~~~~~~~~~~~~~~~~~~~
  Code by gkothyari 
~~~~~~~~~~~~~~~~~~~~~~~*/    
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

#define rep(i,n) 			  for(int i=0;i<(n);i++)
#define FOR(i,a,b) 			  for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) 		  for(int i=(a);i>=(b);i--)
#define DEBUG(x) 			  cout << '>' << #x << ':' << x << endl;
#define foreach(it, c)        for( typeof( (c).begin()) it = (c).begin();  it != (c).end(); ++it)
#define endl 				  "\n"
#define pb                    push_back
#define eb                    emplace_back
#define ll					  long long
#define ld					  long double
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MAX                   1e9
#define MIN                   -1e9
#define vi                    vector<int>
#define vvi                   vector<vi>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(v)                v.begin(),v.end()
#define max(x,y)              (x>y)?x:y
#define min(x,y)              (x<y)?x:y
#define mid(s,e)              (s+(e-s)/2)
#define mini                  INT_MIN
#define sqr(x) 				  ((x)*(x))
#define ones(x) 			  __builtin_popcount(x)
#define onesll(x) 			  __builtin_popcountll(x)
#define PI                    acos(-1.0)
typedef vector<pii> vpii;
const int INF = 0x3f3f3f3f, MOD = 1e9 + 7;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}

int main()
{
	cout<<fixed<<setprecision(15);
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ios_base:: sync_with_stdio(false); cin.tie(0);
	    
	ll n,i,count=0;
	vector<int> v;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++){
		cin>>a[i];
		v.push_back(a[i]);
	}
	sort(v.begin(),v.end());
	for(i=0;i<n;i++){
		if(a[i]!=v[i])
			count++;
	}
	if(count<=2)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;



	return 0;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <boost/multiprecision/cpp_int.hpp> 
using namespace boost::multiprecision; 
#define int int128_t
#define fr(a,b) for(int i=a;i<b;i++)
#define frn(a,b) for(int i=a;i>=b;i--)
 
int32_t main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int x;
	cin>>x;
	int a = 100;
	int t = 0;
	while(a<x){
		a = a*101;
		a = a/100;
		t++;
	}
	cout<<t;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <string>
#include <sstream>
#include <cstdio>
#include <cstring>
#define INF 0x3f3f3f3f
#define lb long double
#define LINF 0x3f3f3f3f3f3f3f3f
#define ull unsigned long long
#define random(x) (rand()%x)
#define rep(i, a, b) for(int i=a;i<b;i++)
#define req(j, a, b) for(int j=a;j<b;j++)
#define mem(a, b) memset(a, b, sizeof(a))
#define PI 3.14

using namespace std;
typedef long long ll;
const int maxn = 1e6+5;
const double eps = 1e-14;
const double pi = acos(-1);
const ll mod = 1e9 + 7;
const int hash_mod = 19260817;

int gw; //个位
int d[9];
int cf(int x)
{
    while(x!=0)
    {
        gw=x%10;
        x=(x-gw)/10;
        d[gw]++;//计数器加1
    }
}

int arr[1000];
int main()
{
    string s ;
    cin >>s;
    int l = s.size();
    int len1 = l-1 ;
    int sum =0 ;
    if(l % 2 == 1)
        l++;
    for(int i=0;i<(l)/2;i++)
    {
        if(s[i]!=s[len1])
        {
            sum++;
            len1--;
        }else{
            len1--;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
	par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
signed main(){
  int a;
  cin>>a;
  V<int> b(a);
  fo(i,a){
    cin>>b[i];
  }
  Sort(b);
  int c=0;
  fo(i,a-1){
    c+=b[i];
  }
  if(c>b[a-1])
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int m=sc.nextInt();
		int d=sc.nextInt();

		int count=0;


		for(int i=10;i<=d;i++){
			int d10=i/10;
			int d1=i%10;
			if(d1>=2 && d10>=2 && d1*d10<=m){
				count++;
			}
		}


		System.out.println(count);


	}
}


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

int main(){
    int a;
    cin >> a;
    int ans = 0;
    if(a/1000 == 2)++ans;
    if((a%1000)/100 == 2)++ans;
    if( (((a%1000)%100)/10) == 2)++ans;
    if( (((a%1000)%100)%10) == 2)++ans;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t N;

    std::cin >> N;

    N %= 10;

    std::string yomi;
    switch (N) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            yomi = "hon";
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            yomi = "pon";
            break;
        case 3:
            yomi = "bon";
            break;
    }

    std::cout << yomi << std::endl;

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;
string s;
int cnt[3];
bool ok(string s,int a, int b, int c){
	if(s == "ABC")return true;
	string nxt;
	char to;
	int abc;
	if(a < b && a < c)to = 'A', abc=a,b-=a,c-=a;
	else if(b < a && b < c)to = 'B', abc=b,a-=b, c-=b;
	else if(c < a && c < b)to = 'C', abc=c,a-=c, b-=c;
	else return false;
	if(abc == 0)return false;
	int p = 0;
	while(p < s.size()){
		if(p+2 < s.size() && s[p] == 'A' && s[p+1] == 'B' && s[p+2] == 'C'){
			nxt += to;
			p += 3;
			abc--;
		}
		else{
			nxt += s[p];
			p++;
		}
	}
	if(abc != 0)return false;
	return ok(nxt, a, b, c);
}

int main(){
	cin >> s;
	for(int i = 0;i < s.size();i++){
		cnt[s[i]-'A']++;
	}
	if(ok(s, cnt[0], cnt[1], cnt[2]))cout << "Yes" << endl;
  else cout << "No" << endl;
	return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; ++i) cin >> a[i];
    int low = 0, high = 1000000010;
    while(high - low > 1) {
        int len = (high + low)/2;
        long long int cut_num = 0;
        for(int i = 0; i < n; ++i) {
            cut_num += (a[i]-1)/len;
        }
        if(cut_num <= k) high = len;
        else low = len;
    }
    cout << high << '\n';
}


Measured memory_bytes: 4400
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
#define NUM 1000000010
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,minus=0;
    bool zero=false;
    cin>>n;
    ll sum=0,mini=NUM;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        mini=min(mini,abs(a[i]));
        if(a[i]<0) minus++;
        if(a[i]==0) zero=true;
        sum+=abs(a[i]);
    }
    if(minus%2==1&&!zero) sum-=2*mini;
    cout<<sum<<endl;
}

Measured memory_bytes: 4024
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << (x) << endl
using namespace std;

using ull = unsigned long long;
using ll = long long;

using Int = ll;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

const Double PI  = 3.141592653589793238463;
const Int MOD = 1000000007;
const Int INF = numeric_limits<Int>::max() / 3;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec){
        is >> x;
    }
    return is;
}

set<Int> prime_factors(Int a){
    set<Int> xs;
    for(Int i = 2; i * i <= a; i++){
        if(a % i == 0){
            xs.insert(i);
            do{
                a /= i;
            }while(a % i == 0);
        }
    }
    if(a != 1){
        xs.insert(a);
    }
    return xs;
}

Int solve(Int a, Int b){
    set<Int> xs = prime_factors(a);
    set<Int> ys = prime_factors(b);
    set<Int> zs;
    set_intersection(begin(xs), end(xs), begin(ys), end(ys) ,inserter(zs, end(zs)));
    return zs.size() + 1;
}

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    Int a, b;
    cin >> a >> b;
    cout << solve(a, b) << "\n";
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,M=map(int,input().split())
    print('Yes' if N==M else 'No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;

	double con = 0.0;
	int water = 0, sugar = 0;
	
	//水入れる回数
	for (int w = 0; w <= 30; w++) {
		for (int x = 0; x <= 30; x++) {
			//砂糖入れる回数
			for (int y = 0; y <= ceil((double)f / c); y++) {
				for (int z = 0; z <= ceil((double)f / d); z++) {
					int water_weight = a * w + b * x;
					int sugar_weight = c * y + d * z;
					int total = 100 * water_weight + sugar_weight;
					if (total <= f && sugar_weight <= water_weight * e) {
						if (con < (double)sugar_weight / total) {
							con = (double)sugar_weight / total;
							water = 100 * water_weight;
							sugar = sugar_weight;
						}
					}
				}
			}
		}
	}

	if (con == 0.0) water = 100 * a;

	cout << water + sugar << " " << sugar << endl;

	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

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

		int n = sc.nextInt();
		int ans = s(n, 0);
		
		System.out.println(ans);

		sc.close();
	}
	
	static int s(int n, int c) {
		if (n < 6)
			return n + c;
		int a = 1;
		while (a * 6 <= n)
			a *= 6;
		
		int b = 1;
		while (b * 9 <= n)
			b *= 9;
		
		return Math.min(s(n - a, c + 1), s(n - b, c + 1));
	}
}


Measured memory_bytes: 22868
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
    string in;
    cin >> in;
    int ans = 1000;
    for (int i = 0; i <= in.size() - 3; i++)
    {
        int sub;
        sub = stoi(in.substr(i, 3));
        ans = min(ans, abs(753 - sub));
    }
    cout << ans << endl;
    return 0;
}


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

const int N = 1e5 + 5, mod = 1e9+7;
using ll = long long;

ll quick_pow(ll a, ll b, ll mod) {
    ll res = 1;
    a %= mod;
    while (b) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}



int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin>>n;
    vector<int> a(n);
    for (int i = 0; i < n; i++){
        a[abs(2*i-n+1)]++;
    }
    for (int i = 0; i < n; i++){
        int x;
        cin>>x;
        a[x]--;
    }
    
    int ok = 1;
    for (int i = 0; i < n; i++){
        if(a[i]!=0) ok = 0;
    }
    if(ok){
        cout<<quick_pow(2, n/2, mod)<<endl;
    }else{
        cout<<0<<endl;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 640
//
//  AOJ0096.c
//
//
//  Created by 中野 優 on 2014/02/23.
//
//

#include <stdio.h>
long long int main(void){
    long int ans[50],temp,n,i=0,j;
    while(scanf("%d",&n)!=EOF){
        temp=0;
        if(n<=1000){
            ans[i]=(n+3)*(n+2)*(n+1)/6;
        } else if (n<=2000) {
            for(j=0;j<n-1000;j++) temp+=2*(j+2)*(j+1);
            ans[i]=(n+3)*(n+2)*(n+1)/6 - temp;
        } else if(n<3000){
        	for(j=0;j<3000-n;j++) temp+=2*(j+2)*(j+1);
            ans[i] = (4003-n)*(4002-n)*(4001-n)/6 - temp;
        } else {
            ans[i]= (4003-n)*(4002-n)*(4001-n)/6;
        }
        i++;
    }
    for(j=0;j<i;j++) printf("%d\n",ans[j]);
    return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
//setprecision(10);
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

llong extgcd(llong a,llong b,llong& x,llong& y){
    llong d=a;
    if(b!=0){
        d=extgcd(b,a%b,y,x);
        y-=(a/b)*x;
    }
    else{
        x=1;y=0;
    }
    return d;
}

llong  mod_inverse(llong  a,llong m){
    long long int x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    llong y; cin>>y;
    llong a,b,c;
    a=-1; b=-1; c=-1;
    //a10000 b5000 c1000
    for(int i=0; i<=y/10000; i++)
    {
        for(int j=0; j<=(y-10000*i)/5000; j++)
        {

            if((y-10000*i-5000*j)/1000==n-i-j)
            {
                a=i; b=j; c=n-i-j;
                break;
            }
        }
    }
    cout<<a<<" "<<b<<" "<<c<<" "<<endl;
    return  0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
typedef long long ll;

const double PI = 3.141592653589793;


int main() {
	// fios;
	int n , m;
	cin >> n >> m;
	int a[m];
	int sum(0);
	for(int i = 0; i < m; i++) {
		cin >> a[i];
		sum += a[i];
	}
	if(sum > n) {
		puts("-1");
	} else {
		cout << n - sum << endl;
	}
}

Measured memory_bytes: 3604
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

X, Y = LI()

flag = False

for i in range(X+1):
    if i*2 + (X-i)*4 == Y:
        flag = True

YesNo(flag)


Measured memory_bytes: 67244
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 87;
ll n, k, a[N];
ll c0, cn, cp;
ll solvene()
{
    vector<ll> x(a, a + cn);
    vector<ll> y(a + n - cp, a + n);
    ll lo = x[0] * y.back();
    ll hi = x.back() * y[0];
    //cerr << "lo hi "<< lo << ' '<< hi << endl;
    reverse(x.begin(), x.end());
    reverse(y.begin(), y.end());
    //cerr << "x= "; for (ll t : x) cerr << t << ' '; cerr << endl;
    //cerr << "y= "; for (ll t : y) cerr << t << ' '; cerr << endl;
    while (lo <= hi) {
        ll mi = lo + (hi - lo) / 2;
        ll c = 0;
        for (ll i = 0, j = 0; i < x.size(); ++i) {
            for (; j < y.size() && x[i] * y[j] <= mi; ++j);
            //cerr << "i,j,x[i] " << i << ' ' << j << ' ' << x[i]<< endl;
            c += j;
        }
        //cerr << "mi, c "<< mi << ' ' << c << endl;
        if (c < k)
            lo = mi + 1;
        else
            hi = mi - 1;
    }
    return lo;
}
ll solvenp(ll k)
{
    vector<ll> x(a, a + cn);
    reverse(x.begin(), x.end());
    vector<ll> y(a + n - cp, a + n);
    ll lo = LLONG_MAX;
    ll hi = LLONG_MIN;
    if (x.size() >= 2) {
        lo = min(lo, x[0] * x[1]);
        hi = max(hi, x[cn - 1] * x[cn - 2]);
    }
    if (y.size() >= 2) {
        lo = min(lo, y[0] * y[1]);
        hi = max(hi, y[cp - 1] * y[cp - 2]);
    }
    while (lo <= hi) {
        ll mi = lo + (hi - lo) / 2;
        ll c = 0;
        for (ll i = cp - 1, j = 0; i >= 0; --i) {
            for (; j < i && y[i] * y[j] <= mi; ++j);
            c += min(j, i);
        }
        for (ll i = cn - 1, j = 0; i >= 0; --i) {
            for (; j < i && x[i] * x[j] <= mi; ++j);
            c += min(j, i);
        }
        //cerr << "mi, c " << mi << ' ' << c << endl;
        if (c < k)
            lo = mi + 1;
        else
            hi = mi - 1;
    }
    return lo;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] == 0)
            ++c0;
        else if (a[i] > 0)
            ++cp;
        else
            ++cn;
    }
    sort(a, a + n);
    ll ne = cn * cp;
    ll n0 = c0 * (c0 - 1) / 2 + c0 * (n - c0);
    ll np = cp * (cp - 1) / 2 + cn * (cn - 1) / 2;
    ll ans;
    if (k <= ne) {
        ans = solvene();
    } else if (k <= ne + n0) {
        ans = 0;
    } else {
        ans = solvenp(k - ne - n0);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 6088
#include <algorithm>
#include <iostream>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define pb push_back

ll power(int x, unsigned int y){
    ll res = 1;
    while(y > 0){
        if(y & 1) res = res * x;
        y >>= 1;
        x *= x;
    }
    return res;
}

// Check for number of Cases!!
void solve() {
    int n, k;
    cin >> n >> k;

    int arr[n+1];

    for(int i = 1; i <= n; i++) {
        cin >> arr[i];
    }

    ll dp[n+1];
    fill_n(dp, n+1, LONG_MAX);

    dp[1] = 0;

    for(int i = 2; i <= n; i++) {
        for(int j = 1; j < i && j <= k; j++) {
            dp[i] = min(dp[i], dp[i-j] + abs(arr[i-j] - arr[i]));
        }
    }

    cout << dp[n];
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t = 1;
    // cin >> t;
    while(t--) {
      solve();
    }
}

Measured memory_bytes: 4788
#include<stdio.h>

int main()
{
	int m,f,r;
	while(1){
		scanf("%d %d %d",&m,&f,&r);
		if(m + f + r == -3)
		break;
		if(m == -1 || f == -1)
			printf("F\n");
		if(m != -1 &&f != -1){
			if(m + f < 30){
				printf("F\n");
			}else if(30 <= m + f && m + f < 50 && 50 <= r){
				printf("C\n");
			}else if(30 <= m + f && m + f < 50 && r < 50){
				printf("D\n");
			}else if(50 <= m + f && m + f < 65){
				printf("C\n");
			}else if(65 <= m + f && m + f < 80){
				printf("B\n");
			}else{
				printf("A\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

/*
*/

template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt() : x(0) { }
	ModInt(signed sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
	ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }

	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
	ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }

	ModInt inverse() const {
		signed a = x, b = MOD, u = 1, v = 0;
		while (b) {
			signed t = a / b;
			a -= t * b; std::swap(a, b);
			u -= t * v; std::swap(u, v);
		}
		if (u < 0) u += Mod;
		ModInt res; res.x = (unsigned)u;
		return res;
	}
};
typedef ModInt<1000000007> mint;

ll n,m;
string s;
mint dp[5010],dp2[5010];

void init(){
	cin>>n>>s;
	m = s.size();
	dp[0]=1;
}

int main(void){
	init();
	rep(tmp,n){
		reg(i,0,n){
			if(i>0)dp2[i]+=dp[i-1]*2;  // 0,1
			if(i+1<=n)dp2[i]+=dp[i+1];  // delete
			if(i==0)dp2[0]+=dp[0];  // delete
		}
		reg(i,0,n){
			dp[i]=dp2[i];
			dp2[i]=0;
		}
	}
	mint ans = dp[m];
	rep(i,m)ans/=2;
	cout<<ans.get()<<endl;
	return 0;
}

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

using namespace std;

typedef long long int ll;

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

  ll n, k;
  cin >> n >> k;
  vector < ll > a(n), v;
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n; i++){
    ll sum = 0;
    for(int j = i; j < n; j++){
      sum += a[j];
      v.push_back(sum);
    }
  }

  for(ll bt = 40; bt >= 0; bt--){
    vector < ll > tmp;
    for(auto i : v){
      if((i >> bt) & (ll)1) tmp.push_back(i);
    }

    if(tmp.size() >= k) v = tmp;
  }

  ll ans = v[0];
  for(int i = 1; i < v.size(); i++) ans &= v[i];

  cout << ans << '\n';
}


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

using namespace std;


int main() {
    string s , ans ; cin>>s;
    ans = "";
    for(char c : s){
        if(c != 'B')ans.push_back(c);
        else{
            if(ans.empty())continue;
            ans.pop_back();
        }
    }
    cout<<ans<<"\n";
    
}

Measured memory_bytes: 256