akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    int v[n];
    vector<int> a[n];
    for (int i = 0; i < n; i++)
        cin >> v[i];
    while (m--)
    {
        int u, v;
        cin >> u >> v;
        a[u - 1].push_back(v - 1);
        a[v - 1].push_back(u - 1);
    }
    // for (int i = 0; i < n; i++)
    // {
    //     for (int j = 0; j < a[i].size(); j++)
    //     {
    //         cout << a[i][j] << " ";
    //     }
    // }
    // cout << endl;

    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        int s = a[i].size();
        if (s == 0)
        {
            cnt++;
            continue;
        }

        int t = true;
        for (int j = 0; j < s; j++)
        {
            if (v[i] <= v[a[i][j]])
            {
                t = false;
                break;
            }
        }
        if (t)
        {

            cnt++;
        }
    }
    cout << cnt;
}

Measured memory_bytes: 9076
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

def solve():
    delta = sum(B) - sum(A)
    if delta < 0:
        return False
    aup = [0] * N
    bup = [0] * N
    for i in range(N):
        d = B[i] - A[i]
        if d > 0:
            aup[i] = d // 2 + d % 2
            bup[i] = d % 2
        elif d < 0:
            bup[i] = -d
    #print('delta:', delta)
    #print('Aup:', aup)
    #print('Bup:', bup)
    adelta = delta - sum(aup)
    bdelta = delta - sum(bup)
    return adelta >= 0 and bdelta >= 0 and 2 * adelta == bdelta

print('Yes' if solve() else 'No')

Measured memory_bytes: 4596
N = gets.to_i
F_CACHE = [1]
M_CACHE = [1]
MOD = 10 ** 9 + 7

def extgcd(a, b)
  if b.zero?
    [1, 0, a]
  else
    x, y, d = extgcd(b, a % b)

    [y, x - (a / b) * y, d]
  end
end

def mod_inverse(a, m)
  x, y, _ = extgcd(a, m)
  (m + x % m) % m
end

(1..(N + 1)).inject(1) do |res, n|
  v = (res * n) % MOD

  F_CACHE << v
  M_CACHE << mod_inverse(v, MOD)

  v
end

class Integer
  def combination(k)
    return 1 if k.zero?
    return 0 if self < k

    # (self - k + 1..self).inject(:*) / k.factorial
    self.factorial * M_CACHE[k] * M_CACHE[self - k]
    # self.factorial * mod_inverse(k.factorial, MOD) * mod_inverse((self - k).factorial, MOD)
  end

  def permutation(k)
    return 1 if k.zero?

    (self - k + 1..self).inject(:*)
  end

  def factorial
    return F_CACHE[self] if F_CACHE[self]
    return 1 if self.zero?

    (1..self).inject(:*)
  end
end

A = gets.split.map(&:to_i)
counter = Hash.new
l = r = -1

A.each_with_index do |a, i|
  if counter[a]
    l = counter[a]
    r = i
    break
  else
    counter[a] = i
  end
end

1.upto(N + 1) do |k|
  puts ((N + 1).combination(k) - (l + N - r).combination(k - 1)) % MOD
end


Measured memory_bytes: 18708
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

bool mat[2001][2001];
int mat2[2001][2001], mat3[2001][2001], mat4[2001][2001];

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

  int n, m, q; cin >> n >> m >> q;
  rep(i, n) {
    rep(j, m) {
      char c; cin >> c;
      mat[i][j] = (c == '1');
    }
  }

  rep(i, n+1) rep(j, m+1) mat2[i][j] = 0;
  rep(i, n) {
    rep(j, m) {
      if (i+1<n && mat[i][j] && mat[i+1][j]) {
        mat2[i+2][j+1]++;
      }
    }
  }
  rep(i, n) {
    rep(j, m+1) {
      mat2[i+1][j] += mat2[i][j];
    }
  }
  rep(j, m) {
    rep(i, n+1) {
      mat2[i][j+1] += mat2[i][j];
    }
  }

  rep(i, n+1) rep(j, m+1) mat4[i][j] = 0;
  rep(i, n) {
    rep(j, m) {
      if (j+1<m && mat[i][j] && mat[i][j+1]) {
        mat4[i+1][j+2]++;
      }
    }
  }
  rep(i, n) {
    rep(j, m+1) {
      mat4[i+1][j] += mat4[i][j];
    }
  }
  rep(j, m) {
    rep(i, n+1) {
      mat4[i][j+1] += mat4[i][j];
    }
  }

  rep(i, n+1) rep(j, m+1) mat3[i][j] = 0;
  rep(i, n) {
    rep(j, m) {
      if (mat[i][j]) mat3[i+1][j+1] = 1;
    }
  }
  rep(i, n) {
    rep(j, m+1) {
      mat3[i+1][j] += mat3[i][j];
    }
  }
  rep(j, m) {
    rep(i, n+1) {
      mat3[i][j+1] += mat3[i][j];
    }
  }

  /*
  rep(i, n+1) {
    rep(j, m+1) {
      cerr << mat3[i][j] << ' ';
    }
    cerr << endl;
  }

  rep(i, n+1) {
    rep(j, m+1) {
      cerr << mat2[i][j] << ' ';
    }
    cerr << endl;
  }

  rep(i, n+1) {
    rep(j, m+1) {
      cerr << mat4[i][j] << ' ';
    }
    cerr << endl;
  }*/

  while(q--) {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    auto v = mat3[x2][y2] - mat3[x2][y1-1] - mat3[x1-1][y2] + mat3[x1-1][y1-1];
    auto e1 = mat2[x2][y2] - mat2[x2][y1-1] - mat2[x1][y2] + mat2[x1][y1-1];
    auto e2 = mat4[x2][y2] - mat4[x2][y1] - mat4[x1-1][y2] + mat4[x1-1][y1];
    //debug(v); debug(e1); debugln(e2);
    cout << v-e1-e2 << '\n';
  }

}


Measured memory_bytes: 52608
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
using namespace std;

int main () {
	int n; 
	cin >> n;
	string s; 
	cin >> s;
	for(int i = 0; i < s.length(); i++) {
		int cur = (tolower(s[i])) - 'a';
		if(cur + n < 26) cout << (char)(65 + cur + n);
		else {
			int left = (cur + n) - 26;
			cout << (char)(65 + left);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

    int k;
    cin >> k;

    int maxNum = max(a, max(b, c));
    int num = maxNum;
    for (int i = 0; i < k; i++)
    {
        num *= 2;
    }
    
    int ans = a + b + c + num - maxNum;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#ifdef LOKO
#include<Joeon>
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; rep(i, 0, l) cout<<' '<<i<<':'<<*(x+i)<<endl;
#else
#define D(x)
#define R(x, l)
#endif
#define pb push_back
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef LOKO
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	string str;
	cin>>str;
	if (str[0] == str[1] && str[1] == str[2]) puts("Yes");
	else if (str[1] == str[2] && str[2] == str[3]) puts("Yes");
	else puts("No");
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>

using namespace std;

int main() {
int a,b;
cin >> a >> b;
if(a+b>=10){
  cout << "error" << endl;
}
else{
  cout << a+b << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<memory.h>
#include<map>
#include<set>
#include<queue>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
char str[100005];
int n;
int s[30];
int main()
{
	cin>>n;
	scanf("%s",str+1);
	rep(i,1,n)
	{
		s[str[i]-'a'+1]++;
	}
	typedef long long LL;
	LL ans=1;
	rep(i,1,26)ans=ans*(s[i]+1)%1000000007;
	cout<<(ans+1000000006)%1000000007<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const int N = 3e5+6;
const int mod = 1e9+107;
const int inf = 1e8;
void solve(){
    string s;
    cin>>s;
    if(s[1]=='R')s[1] = 'B';
    else s[1] = 'R';
    cout<<s<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    int k;
    cin >> k;
    int even = k / 2;
    int odd = (k + 1) / 2;
    cout << even * odd << endl;
    return 0;
}


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

int main() {

    vector<double> money(10);
    vector<string> u(10);
    int n;
    const double btc = 380000.0;
    long double sum = 0.0;
    cin >> n;

    for(int i = 0; i < n; i++) cin >> money.at(i) >> u.at(i);
    
    for(int i = 0; i < n; i++) {
        if(u.at(i) == "JPY") sum += money.at(i);
        else if(u.at(i) == "BTC") sum += money.at(i) * btc;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
    int n,t,a,ind=-1;
    float man=10000000;
    cin>>n>>t>>a;
    for(int i=1;i<=n;i++)
    {
        float tot;
        cin>>tot;
        tot=t-tot*0.006;
        tot=fabs(tot-a);
        if(tot<man)
        {
            man=tot;
            ind=i;
        }
    }
    cout<<ind<<endl;

}


Measured memory_bytes: 384
input_lines = raw_input()
n1_n2_n3 = input_lines.rstrip().split(" ")
n1 = int(n1_n2_n3[0])
n2 = int(n1_n2_n3[1])
n3 = int(n1_n2_n3[2])
num_list = []
num_list.append(n1)
num_list.append(n2)
num_list.append(n3)
num_list.sort()
print str(num_list[0]) + " " + str(num_list[1]) + " " + str(num_list[2])

Measured memory_bytes: 6372
#include <iostream>
#include <set>
#include <map>

using namespace std;

bool likes(int i, set<int> dislike)	{
	int temp = i;
  	int digit;
  	while (temp != 0)	{
    	digit = temp % 10;
      	temp /= 10;
     	if (dislike.count(digit) != 0)
          	return false;
    }
  	return true;
}

int main()	{
  	int n, k;
  	set<int> dislike;
  	cin >> n >> k;
  	int temp;
  	for (int i = 0; i < k; i++)	{
    	cin >> temp;
      	dislike.insert(temp);
    }
  	for (int i = n;; i++)	{
    	if (likes(i, dislike))	{
        	cout << i << endl;
          	break;
        }
    }
  	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define G 9.8

/*
ツ与ツつヲツづァツづェツづつ「ツづゥツ：
v=9.8t
y=4.9t^2

ツづ慊つクツ、ツ陳地ツつオツつスツ篠柯(=5*N-5)=yツづヲツづィ
h=4.9t^2
t=sqrt(h/4.9)
ツづづ按づゥツ。

ツつアツづ個篠楪づ個堕ャツ度9.8tツつェツ環づゥツつスツづ淞づ個堕ャツ度ツづーツ陳エツつヲツづづェツづ篠つ「ツつ「ツつゥツづァ
Vin > 9.8 * sqrt(h/4.9)
ツつキツづ按づュツつソ
Vin > 9.8 * sqrt((5*N-5)/4.9)
ツづーツ鳴楪つスツつケツづ篠つ「ツつ「ツ。
*/

int main(void){
	int i; double v;
	while(scanf("%lf",&v)==1){
		i=1;
		while(v > G*sqrt((5*i-5)/(G/2))) i++;
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		long a = GetInt();
		long b = GetInt();

		if(a > 0 && b > 0)
			Console.WriteLine("Positive");
		else if(a < 0 && b < 0)
			Console.WriteLine(((b - a + 1) % 2 == 0) ? "Positive" : "Negative");
		else
			Console.WriteLine("Zero");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
using ll = long long;

struct Card {
	char suit;
	ll number;
	ll index;
};

// p < r < A.size()
// after this operation: p,...,q-1, q, q+1, ..., r
// A[p],...,A[q-1] <= A[q]
// A[q] < A[q+1], ..., A[r]
// returns q
// r = p+1であれば, かならず整列される.
//
ll Partition(vector<Card> &A, ll p, ll r) {
	Card x = A[r];// pivot 
	ll i = p-1;
	for (ll j=p; j<r; ++j) {
		if (A[j].number <= x.number) {
			i++;
			Card t = A[j];
			A[j] = A[i];
			A[i] = t;
		}
	}
	A[r] = A[i+1];
	A[i+1] = x; 
	return i+1;
}

void QuickSort(vector<Card> &A, ll p, ll r) {
	if (p < r) {
		ll q = Partition(A, p, r);
		QuickSort(A, p, q-1);
		QuickSort(A, q+1, r);
	}
}

bool IsStable(const vector<Card> &A) {
	for (ll i=1; i<A.size(); ++i) {
		if (A[i-1].number == A[i].number && A[i-1].index > A[i].index) {
			return false;
		}	
	}
	return true;
}

int main() {
	ll n;
	cin >> n;
	vector<Card> A(n);
	for(ll i=0;i<n;++i) {
		scanf(" %c %lld", &A[i].suit, &A[i].number); // \n
		A[i].index = i;
	}

//	cout << endl;
//	for(ll i=0;i<n;++i) {
//	 cout  << A[i].suit << " " << A[i].number << endl;;
//	}
	QuickSort(A, 0, A.size()-1);
	if (IsStable(A)) cout << "Stable";
	else cout << "Not stable";
	cout << endl;
	for(ll i=0;i<n;++i) {
	 cout  << A[i].suit << " " << A[i].number << endl;;
	}
	return 0;
}




Measured memory_bytes: 5140
s=input()
q=int(input())
flag=0
t=['' for _ in range(2)]
cnt=0
for _ in range(q):
  a=list(input().split())
  if a[0]=='1':
    flag=1-flag
    cnt+=1
  else:
    if a[1]=='1':t[flag]+=a[2]
    else:t[1-flag]+=a[2]
ans=t[0][::-1]+s+t[1]
if cnt%2:ans=ans[::-1]
print(ans)

Measured memory_bytes: 10212
#include<cstdio>
#include<utility>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#define MAX_V 100001
#define INF 100000000000000.0
using namespace std;
struct edge{int to;double cost;};
typedef pair<double,int> P;

int V;
vector<edge> G[MAX_V];
double d[MAX_V];

void dijkstra(int s){
    priority_queue<P,vector<P>,greater<P> > que;
    fill(d,d+V,INF);
    d[s]=0;
    que.push(P(0.0,s));

    while(!que.empty()){
        P p=que.top(); que.pop();
        int v=p.second;
        if(d[v]<p.first) continue;
        for(int i=0;i<G[v].size();i++){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}

int main(){
    int n;
    double x[1002],y[1002],r[1002],dis;
    edge a;
    scanf("%lf %lf %lf %lf",&x[0],&y[0],&x[1],&y[1]);
    scanf("%d",&n);
    r[0]=r[1]=0.0;
    for(int i=0;i<n;i++){
        scanf("%lf %lf %lf",&x[2+i],&y[2+i],&r[2+i]);
    }
    V=n+2;
    for(int i=0;i<V;i++){
        for(int j=i+1;j<V;j++){
            dis=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
            a={j,max(0.0,dis-(r[i]+r[j]))};
            G[i].push_back(a);
            a.to=i;
            G[j].push_back(a);
        }
    }
    dijkstra(0);
    printf("%.10f\n",d[1]);
}

Measured memory_bytes: 24852
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)

using namespace std;

int A,B;

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

    cin >> A;
    cin >> B;
    if(A <= 8 && B <= 8){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }


    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> arr(n);
    rep(i,n) {
        cin >> arr.at(i);
    }
    vector<bool> jud(1e9);
    rep(i,n) {
        if(jud.at(arr.at(i))){
            cout << "NO" << endl;
            return 0;
        }
        else {
            jud.at(arr.at(i)) = true;
        }
    }
    cout << "YES" << endl;
    return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    int k,n;
    
    cin >> s >> k;
    n = (int)s.size();
    
    vector<string> ans;
    
    for(int i = 0; i < n; i++){
        for(int j = 1; j <= 5; j++){
            if(i + j <= n){
                ans.push_back(s.substr(i,j));
            } else {
                break;
            }
        }
    }
    
    int m = (int)ans.size();
    
    vector<int> ans_n(m);
    
    sort(ans.begin(), ans.end());
    
    ans_n[0] = 1;
    for(int i = 1; i < m; i++){
        if(ans[i] == ans[i-1]) ans_n[i] = ans_n[i-1];
        else ans_n[i] = ans_n[i-1] + 1;
    }
    
    auto itr = lower_bound(ans_n.begin(), ans_n.end(), k) - ans_n.begin();
    
    cout << ans[itr] << endl;
    
}



Measured memory_bytes: 1788
#include<cstdio>
#define min(a,b) a<b?a:b
typedef long long LL;
int main()
{
	LL a,b,T,ans=0;
	bool flag=0;
	LL mi=1111111111;
	scanf("%lld",&T);
	while(T--) {
		scanf("%lld%lld",&a,&b);
		if(a!=b) flag=1;
		ans+=a;
		if(a>b)
			mi=min(b,mi);
	}
	if(!flag)
		ans=mi;
	printf("%lld",ans-mi);
}

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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


void solve(ll A, ll B, ll C) {
    if (A > B) swap(A, B);
    if (B > C) swap(B, C);
    if (A > B) swap(A, B);

    cout << C * 10 + B + A << endl;
}


void main_(istream &cin) {
    ll C;
    ll A;
    ll B;
    cin >> A;
    cin >> B;
    cin >> C;
    solve(A, B, C);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





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

int main() {
    ll N, M; cin >> N >> M;
    vector<ll> A(N); for (int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    ll ok = 0, ng = (ll)2e5 + 1, kumiawase = 0;
    while (ng - ok != 1) {
        ll c = (ok + ng) / 2;
        ll k = 0;
        int j = 0;
        // 尺取わからんからにぶたん
        for (int i = 0; i < N; i++) {
            if (A[i] + A[N-1] >= c) {
                int ngi = -1, oki = N-1;
                while (oki - ngi != 1) {
                    int ci = (ngi + oki) / 2;
                    if (A[i] + A[ci] >= c) {
                        oki = ci;
                    } else {
                        ngi = ci;
                    }
                }
                k += N - oki;
            }
        }
        if (k >= M) {
            ok = c;
            kumiawase = k;
        } else {
            ng = c;
        }
    }
    // ok がkumiawase >= Mとなる最大の幸福度上昇,
    // kumiawaseがok以上のペア数となった
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] + A[N-1] >= ok) {
            int ngi = -1, oki = N-1;
            while (oki - ngi != 1) {
                int ci = (oki + ngi) / 2;
                if (A[i] + A[ci] >= ok) {
                    oki = ci;
                } else {
                    ngi = ci;
                }
            }
            ans += A[i] * (N - oki);
        }
    }
    cout << ans * 2 - (kumiawase - M) * ok << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<"[@"<<__LINE__<<"] "<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
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;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T>inline int bs(int g,int k,T c){while(abs(k-g)>1){int m=(g+k)/2;(c(m)?k:g)=m;}return k;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}
template<typename T> istream& operator>>(istream& s,vector<T>& v){for(T& x:v)s>>x;return s;}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    cin >> h;
    set<int> st;

    for(int i = 0; i < m; ++i){
        int a, b;
        cin >> a >> b;
        --a; --b;
        if(h[a] < h[b]){
            st.insert(a);
        }else if(h[a] > h[b]){
            st.insert(b);
        }else{
            st.insert(a);
            st.insert(b);
        }
    }
    
    cout << n-st.size() << '\n';
    
    
    return 0;
}


Measured memory_bytes: 6372
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};

vector<lint> G[60]; // MAX_V,隣接リスト
lint root;

lint parent[7][60]; // logMAX_V,MAX_V
lint depth[60];

void LCAdfs(lint v,lint p,lint d){
    parent[0][v]=p;
    depth[v]=d;
    rep(i,G[v].size()) if(G[v][i]!=p) LCAdfs(G[v][i],v,d+1);
}

void LCAinit(lint V){
    LCAdfs(root,-1,0);
    for(int k=0;k+1<7;k++){
        for(int v=0;v<V;v++){
            if(parent[k][v]<0) parent[k+1][v]=-1;
            else parent[k+1][v]=parent[k][parent[k][v]];
        }
    }
}

lint LCA(lint u,lint v){
    if(depth[u]>depth[v]) swap(u,v);
    for(int k=0;k<7;k++){
        if((depth[v]-depth[u])>>k&1) v=parent[k][v];
    }
    if(u==v) return u;
    for(int k=7-1;k>=0;k--){
        if(parent[k][u]!=parent[k][v]){
            u=parent[k][u];
            v=parent[k][v];
        }
    }
    return parent[0][u];
}

vector<int> path(int s,int t){
    int lca=LCA(s,t);
    vector<int> ps,pt;
    int now=s;
    while(true){
        if(now==lca) break;
        ps.push_back(now);
        now=parent[0][now];
    }
    now=t;
    while(true){
        pt.push_back(now);
        if(now==lca) break;
        now=parent[0][now];
    }
    reverse(pt.begin(),pt.end());
    ps.insert(ps.end(),pt.begin(),pt.end());
    return ps;
}

int edge[2500];

int main(void){
    int N;
    cin >> N;
    rep(i,N-1){
        int u,v;
        cin >> u >> v;
        u--,v--;
        G[u].push_back(v);
        G[v].push_back(u);
        edge[u*50+v]=i;
        edge[v*50+u]=i;
    }
    LCAinit(N);
    lint ans=(1LL<<(N-1));
    lint minus=0;
    int M;
    cin >> M;
    int u[M],v[M];
    rep(i,M) cin >> u[i] >> v[i];
    rep(i,M) u[i]--,v[i]--;
    int edgecnt[N-1]={};
    rep(i,(1<<M)){
        if(i==0) continue;
        int pick=Flagcount(i);
        rep(j,M) if(i&(1<<j)){
            vector<int> way=path(u[j],v[j]);
            rep(k,way.size()-1) edgecnt[edge[way[k]*50+way[k+1]]]++;
        }
        int vtx=0;
        rep(j,N-1) if(edgecnt[j]) vtx++;
        lint cnt=(1LL<<(N-1-vtx));
        if(pick%2) minus+=cnt;
        else minus-=cnt;
        rep(j,N-1) edgecnt[j]=0;
    }
    cout << ans-minus << endl;
}

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


void koch(int d, pair<float, float> left, pair<float, float> right){
    if(d == 0){
        return;
    }else{
        d--;
    }
    pair<float, float> s, t, u;

    s.first  = (right.first + 2 * left.first) / 3;
    // cout << right.first << " " << left.first << " " << s.first << endl;
    s.second = (right.second + 2 * left.second) / 3;

    t.first  = (2 * right.first + left.first) / 3;
    t.second = (2 * right.second + left.second) / 3;

    float tmpx = t.first - s.first;
    float tmpy = t.second - s.second;
    u.first  = tmpx / 2 - sqrt(3) / 2 * tmpy + s.first;
    u.second = sqrt(3) / 2 * tmpx + tmpy / 2 + s.second;

    koch(d, left, s);
    printf("%f %f\n", s.first, s.second);

    koch(d, s, u);
    printf("%f %f\n", u.first, u.second);

    koch(d, u, t);
    printf("%f %f\n", t.first, t.second);

    koch(d, t, right);
    // printf("%f %f\n", right.first, t.second);
    return;

}

int main(){
    int n; cin >> n;
    pair<float, float> right, left;
    left.first = 0;
    left.second = 0;
    right.first = 100;
    right.second = 0;

    // cout << left.first << " " << left.second << endl;
    printf("%f %f\n", left.first, left.second);
    koch(n, left, right);
    printf("%f %f\n", right.first, right.second);
    return 0;

}


Measured memory_bytes: 3128
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():


    h, w = LI()
    n = I()
    a = [0] + LI()

    board = [[0 for _ in range(w)] for _ in range(h)]


    zahyo = [0,0]
    pr = True
    for color in range(1, len(a)):
        for i in range(a[color]):
            board[zahyo[0]][zahyo[1]] = color
            if pr:
                if zahyo[1] == w-1:
                    zahyo[0] += 1
                    pr = False
                else:
                    zahyo[1] += 1
            else:
                if zahyo[1] == 0:
                    zahyo[0] += 1
                    pr = True
                else:
                    zahyo[1] -= 1


    for line in board:
        print(*line)
            


                    


main()


Measured memory_bytes: 10460
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,m,ans=0;
  	cin >> n >> m;
    if(n==1&&m==1){
      ans++;
    }else if((n==1&&m>=3)||(n>=3&&m==1)){
      ans=max(n,m)-2;
    }else if(n>=3&&m>=3){
      ans=n*m-2*n-2*(m-2);
    }
    cout << ans << endl;
  	return 0;
}


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

int main() {
	long long N, ANS = 0;
	string S;
	cin >> N >> S;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			for (int k = 0; k < 10; k++) {
				bool check1 = false, check2 = false, check3 = false;
				for (int l = 0; l < N; l++) {
					if (!check1) {
						if (S[l] - '0' == i) check1 = true;
					}
					else if (!check2) {
						if (S[l] - '0' == j) check2 = true;
					}
					else if (!check3) {
						if (S[l] - '0' == k) check3 = true;
					}
				}
				if (check3) ANS++;
			}
		}
	}
	cout << ANS << endl;
}

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

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

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

int main(void){
  int N, i;
  //int c0, c1, c2, c3;
  char S[10010];
  //char S[];
  //char a0[2], a1[2], a2[3], a3[2];
    //char* a0, a1, a2, a3;

  int c0 = 0;
  int c1 = 0;
  int c2 = 0;
  int c3 = 0;

  scanf("%d", &N);
  for(i=0;i<N;i++){
    scanf("%s", &S);
  
  
    if(strcmp(S,"AC") == 0){
      c0 += 1;
    }
    if(strcmp(S, "WA")== 0){
      c1 += 1;
    }
    if(strcmp(S,"TLE") == 0){
      c2 += 1;
    }
    if(strcmp(S,"RE") == 0){
      c3 += 1;
    }
    
  }
  
  printf("AC x %d \n", c0);
  printf("WA x %d\n", c1);
  printf("TLE x %d\n", c2);
  printf("RE x %d\n", c3);
  return 0;
}
  

Measured memory_bytes: 1740
#include <bits/stdc++.h> 
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define mc map<char, int>
#define ms map<string, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define mod 1000000007LL
//#define mod 998244353 
using namespace std;
int power(int x, int y) ;
int gcd(int a, int b) ;
#define pi 3.141592653589

signed main() {
    quickie 
    int a ;
    string s ;
    cin >> a >> s ;
    if(a<3200) cout << "red\n" ;
    else cout << s <<"\n" ;
}

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

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    string ans = "";
    while(n > 0){
        ll dif = (n-1) % 26;
        ans += ('a' + dif);
        if(n == 26) break;
        --n;
        n /= 26LL;
    }
    for(int i = ans.size()-1; i >= 0; --i){
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
int main()
{
	int a, b, c, d, a1, a2;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	a1=a*b;
	a2=c*d;
	if(a1>=a2)
		printf("%d\n",a1);
	else
		printf("%d\n",a2);
	return 0;
}

Measured memory_bytes: 1692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;
using Tree = vector<pair<int, int>>;

int main()
{
    int n, k;
    cin >> n >> k;
    int tmp = (n - 1) * (n - 2) / 2;
    if (tmp < k)
        cout << -1;
    else
    {
        cout << n - 1 + tmp - k << "\n";
        for (int i = 2; i < n + 1; i++)
        {
            cout << 1 << " " << i << "\n";
        }
        int hoge = tmp - k;
        for (int i = 2; i < n + 1; i++)
        {
            for (int j = i + 1; j < n + 1; j++)
            {
                if (hoge == 0)
                    return 0;
                cout << i << " " << j << "\n";
                hoge--;
            }
        }
    }
}


Measured memory_bytes: 256
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define LL long long
#define INF 1e18
#define MAXN 100005
 
LL min(LL x, LL y) {if(x<y) return x; return y;}
 
int n, m, s, t, u, v;
LL a, b, f=1e15, ans[MAXN];
 
struct Graph {
	int cnt,head[MAXN],vis[MAXN];
	LL dis[MAXN];
	struct Edge {
		int next, to;
		LL dis;
	}edge[MAXN*2];
	queue<int> q;
	void addedge(int u, int v, LL dis) {
		edge[++cnt].next=head[u];
		edge[cnt].to=v;
		edge[cnt].dis=dis;
		head[u]=cnt;
	}
	void spfa(int s) {
		for(int i=1; i<=n; i++) dis[i]=INF;
		memset(vis, 0, sizeof(vis));
		q.push(s); vis[s]=1; dis[s]=0;
		while(!q.empty()) {
			int x=q.front(); q.pop();
			vis[x]=0;
			for(int i=head[x]; i; i=edge[i].next) {
				int to=edge[i].to;
				if(dis[to]>dis[x]+edge[i].dis) {
					dis[to]=dis[x]+edge[i].dis;
					if(!vis[to]) q.push(to), vis[to]=1;
				}
			}
		}
	}
}g1,g2;
 
int main()
{
	
	scanf("%d %d %d %d", &n, &m, &s, &t);
	for(int i=1; i<=m; i++) {
		scanf("%d %d %lld %lld", &u, &v, &a, &b);
		g1.addedge(u, v, a),g1.addedge(v, u, a);
		g2.addedge(v, u, b),g2.addedge(u, v, b);
	}
	g1.spfa(s);  g2.spfa(t);
	ans[n+1]=INF;
	for(int i=n; i>=1; i--)
		ans[i]=min(ans[i+1], g1.dis[i]+g2.dis[i]);
	for(int i=1; i<=n; i++)
		printf("%lld\n", f-ans[i]);
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
    int x, y, z;
    cin >> x >> y >> z;
    int ansx, ansy, ansz;
    ansx = y;
    ansy = x;
    x = y;
    y = ansy;
    ansx = z;
    ansz = x;
    cout << ansx << " " << ansy << " " << ansz << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <unistd.h>
#include <map>

#define pii pair<int,int>
#define REP(i, n) for (long long i = 0; i < (n); i++) 
using namespace std;

typedef long long ll;
static const ll INF = 1000000000000000000LL;
static const ll MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    string res = "Yes";
    if(s[0] == s[1] && s[1] == s[2])res = "No";
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

int MOD_BIG = 1000000007;
int MOD_BIG2 = 998244353;
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

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

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

int main() {
    
    ll N;
    cin >> N;
    vector<ll> ps(1);
    vector<ll> pn(1);
    ll a = 2;
    while (N >= a*a) {
        if (N % a == 0) {
            if (ps.back() != a) {
                ps.push_back(a);
                pn.push_back(1);
            } else {
                pn[pn.size() - 1] += 1;
            }
            N /= a;
        } else {
            a++;
        }
    }
    if (N != 1 && N != ps.back()) {
        ps.push_back(N);
        pn.push_back(1);
    } else if (N == ps.back()) {
        pn[pn.size() - 1] += 1;
    }
    int ans = 0;
    FOR(i, 1, ps.size()) {
        int cnt = 1;
        while (pn[i] >= cnt) {
            ans++;
            pn[i] -= cnt;
            cnt++;
        }
        //cerr << ps[i] << ", " << ans << endl;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main () {
  long long a, b;
  cin >> a >> b;
  if (a <= 0 && b >= 0) cout << "Zero", exit(0);
  if (a > 0) cout << "Positive", exit(0);
  if (abs (b - a) & 1) cout << "Positive", exit(0);
  cout << "Negative", exit(0);
}

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

int main(){
	int n,i,t=0,h=0;
	string tstr,hstr;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> tstr >> hstr;

		if(tstr==hstr){
			t++;h++;
		}
		else if(tstr>hstr)t+=3;
		else h+=3;


	}

	cout <<t<<' '<<h<<endl;
	return 0;
}

Measured memory_bytes: 3172
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

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


const int NM = 201001;//ここを問題の制約を見ながらいじる．配列の確保に使う．
ll P[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
ll dp[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
ll A[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．


ll MOD = 1000000007;
int digit_length(int num)
{
    int count = 0;
    while (num) {
        num = num / 10;
        ++count;
    }
    return count;
}


ll gcd(ll a, ll b) {
    ll v0 = a, v1 = b, v2 = a % b;
    while (v2 != 0) {
        v0 = v1;
        v1 = v2;
        v2 = v0 % v1;
    };
    return v1;
}


// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

ll lcm(ll a, ll b) {
    return( (a % MOD) *modinv(gcd(a, b), MOD) * (b % MOD)) % MOD;
}
       // Main program
void solve() {
    ll  H,N;
    cin >> H;
    cin >> N;
    ll sum = 0;
    //ll MOD = 1000000007;

    for (ll i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }

    if (H <= sum) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    return;
    //ll  N;
    //cin >> N;
    //ll sum = 0;

    //ll Top = 0;
    //ll Bottom = 0;
    //ll Len = 0;

    //for (ll i = 1; i < N; i++) {
    //    Len = digit_length(i);
    //    Top = i / Len;
    //    Bottom = i %10;

    //    if (i < 10) {
    //        sum++;
    //        for (ll j = 1; j < 6; j++) {
    //            if (i >= Bottom * pow(10,j) + Top) {
    //                sum++;
    //            }
    //        }
    //    }
    //    else if (i < 100) {
    //        //sum++;
    //        for (ll j = 1; j < 6; j++) {
    //            if (i >= Bottom * pow(10, j) + Top) {
    //                sum++;
    //            }
    //        }
    //    }
    //    else if (i < 1000) {
    //        //sum+=10;
    //        for (ll j = 1; j < 6; j++) {
    //            if (i >= Bottom * pow(10, j) + Top) {
    //                sum++;
    //            }
    //        }
    //    }
    //    else if (i < 10000) {
    //        sum += 100;
    //    }
    //    else if (i < 100000) {
    //        sum += 1000;
    //    }
    //    else if (i < 1000000) {
    //        sum += 10000;
    //    }
    //}
    //cout << sum;
    //   
    //return;

}

int main() {
    solve();
    return 0;
}







Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll x;

int main() {
	cin >> x;
	for (int i = x;; i++) {
		bool flag = false;
		for (int j = 2; j * j <= i; j++) {
			if (!(i % j)) {
				flag = true;
				break;
			}
		}
		if (!flag) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
n, a, b = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)

ans = 0
1.upto(n-1) do |i|
    if (c = (x[i] - x[i-1]) * a) > b
        ans += b
    else
        ans += c
    end
end

puts ans

Measured memory_bytes: 8452
/*
	简单容斥
*/
#include <iostream>
#include <cstdio>
#define N 200005

using namespace std;

const int mod = 1e9 + 7;

int n, m, A, B;
int fac[N], ifac[N];

inline int perm(int s, int r) { return 1LL * fac[s] * ifac[s - r] % mod; }
inline int comb(int s, int r) {	return 1LL * perm(s, r) * ifac[r] % mod; }
inline int calc(int a, int b, int c, int d) { return comb(c - a + d - b, c - a); }

inline int fpm(int bs, int mi) {
	int res = 1;
	while(mi) {
		if(mi & 1) res = 1LL * res * bs % mod;
		bs = 1LL * bs * bs % mod, mi >>= 1;
	}
	return res;
}

int main() {
	cin >> n >> m >> A >> B;

	fac[0] = 1;
	for(int i = 1; i <= n + m; ++i) fac[i] = 1LL * i * fac[i - 1] % mod;
	ifac[n + m] = fpm(fac[n + m], mod - 2);
	for(int i = n + m; i; --i) ifac[i - 1] = 1LL * i * ifac[i] % mod;
	
	int ans = calc(1, 1, n, m);
	for(int i = 1; i <= B; ++i) {
		ans = (ans - 1LL * calc(1, 1, n - A, i) * calc(n - A + 1, i, n, m)) % mod;
		if(ans < 0) ans += mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c,d,e,k;
	cin>>a>>b>>c>>d>>e>>k;
	int sum=0;
	if((max(a,b)-min(a,b))<=k){
		sum++;
	}
	if((max(b,c)-min(b,c))<=k){
		sum++;
	}
	if((max(c,d)-min(c,d))<=k){
		sum++;
	}
	if((max(d,e)-min(d,e))<=k){
		sum++;
	}
	if((max(a,c)-min(a,c))<=k){
		sum++;
	}
	if((max(a,d)-min(a,d))<=k){
		sum++;
	}
	if((max(a,e)-min(a,e))<=k){
		sum++;
	}
	if((max(b,d)-min(b,d))<=k){
		sum++;
	}
	if((max(b,e)-min(b,e))<=k){
		sum++;
	}
	if((max(c,e)-min(c,e))<=k){
		sum++;
	}
	
	if(sum==10){
		cout<<"Yay!"<<endl;
	}
	else{
		cout<<":("<<endl;
	}
}

Measured memory_bytes: 256
S = input().strip()
T = input().strip()

# 後ろから見ていく
for i in range(len(S)-len(T), -1, -1):
  flag = True
  for di in range(len(T)):
    if S[i+di] == '?' or S[i+di] == T[di]:
      continue
    else:
      flag = False
      break
  if flag:
    ans = [None]*len(S)
    for j in range(len(S)):
      if i <= j < i+len(T):
        ans[j] = T[j-i]
      elif S[j] == '?':
        ans[j] = 'a'
      else:
        ans[j] = S[j]
    print(*ans, sep='')
    exit()
print('UNRESTORABLE')

Measured memory_bytes: 3064
c = []
for i in range(3):
    c.append(list(map(int, input().split())))
jud = True
h1 = c[0][0] - c[1][0]
h2 = c[1][0] - c[2][0]
w1 = c[0][0] - c[0][1]
w2 = c[0][1] - c[0][2]
for i in range(3):
    if c[0][i] - c[1][i] != h1:
        jud = False
    if c[1][i] - c[2][i] != h2:
        jud = False
for i in range(3):
    if c[i][0] - c[i][1] != w1:
        jud = False
    if c[i][1] - c[i][2] != w2:
        jud = False
if jud:
    print("Yes")
else:
    print("No")

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

int main(){
    ll c[3][3];
    rep(i,3)rep(j,3) cin>>c[i][j];
    ll b[3]={c[0][0],c[0][1],c[0][2]};
    bool flag=1;
    for(ll i=1;i<3;i++){
        ll a=c[i][0]-b[0];
        rep(j,3){
            if(a+b[j]!=c[i][j]) flag=0;
        }
    }
    cout<<(flag?"Yes":"No")<<endl;
    return 0;
}

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

template<class T,class F>
struct SWAG{

  struct node{
    T val;
    T acm;
    node(){}
    node(T v,T a):val(v),acm(a){}
  };
  
  stack<node> front_stack,back_stack;
  F f;
  
  SWAG(F f):f(f){}
  
  size_t size()const{
    return front_stack.size() + back_stack.size();
  }
  bool empty()const{
    return front_stack.empty() && back_stack.empty();
  }

  T fold(){
    assert(!empty());
    if(front_stack.empty()){
      return back_stack.top().acm;
    }
    else if(back_stack.empty()){
      return front_stack.top().acm;
    }
    else{
      return f(front_stack.top().acm,back_stack.top().acm);
    }
  }

  void push(T const& v){
    if(back_stack.empty()){
      back_stack.emplace(v,v);
    }
    else{
      T cal{f(back_stack.top().acm,v)};
      back_stack.emplace(v,cal);
    }
  }

  void pop(){
    assert(!empty());
    if(front_stack.empty()){
      front_stack.emplace(back_stack.top().val,back_stack.top().val);
      back_stack.pop();
      while(!back_stack.empty()){
        T cal{f(front_stack.top().acm,back_stack.top().val)};
        front_stack.emplace(back_stack.top().val,cal);
        back_stack.pop();
      }
    }
    front_stack.pop();
  }

};

signed main(){

  // https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/all/DSL_3_A
  int n;
  int64_t s;
  cin>>n>>s;
  vector<int64_t> a(n);
  for(auto& ai:a)cin>>ai;

  auto sum = [](auto a,auto b){return a+b;};
  SWAG<int64_t,decltype(sum)> sw(sum);

  int ans = n+1;
  for(int i=0;i<n;++i){
    sw.push(a[i]);
    if(sw.fold()<s)continue;
    while(!sw.empty()&&sw.fold()>=s){
      sw.pop();
    }
    ans = min(ans,(int)sw.size()+1);
  }

  if(ans == n+1)cout<< 0 <<endl;
  else cout<< ans <<endl;

}


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

ll table[10][10];

int main(){
    int n;
    cin >> n;
    rep(i,n){
        int keta = to_string(i + 1).size();
        int a = (i + 1) / int(pow(10,keta - 1));
        int b = (i + 1) % 10;
        table[a][b]++;
    }
    ll ans;
    rep(i,9){
        rep(j,9){
            ans += table[i+1][j+1] * table[j+1][i+1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, p = map(int, input().split())
la = [int(i) % 2 for i in input().split()]

n0 = sum(1 for a in la if a % 2 == 0)
n1 = sum(1 for a in la if a % 2 == 1)


def combi(n, k):
    c = 1
    for i in range(1, n + 1):
        c *= i
    for i in range(1, k + 1):
        c //= i
    for i in range(1, n - k + 1):
        c //= i
    return c


def answer():
    if p == 0:
        c0 = 2 ** n0
        c1 = 0
        for i in range(0, n1 + 1, 2):
            c1 += combi(n1, i)
        return c0 * c1
    else:
        c0 = 2 ** n0
        c1 = 0
        for i in range(1, n1 + 1, 2):
            c1 += combi(n1, i)
        return c0 * c1

print(answer())


Measured memory_bytes: 9172