akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int X;
  cin >> X;
  int answer = 1;
  for (int b = 2; b <= X; ++b) {
    int bp = b * b;
    for (int p = 2;; ++p) {
      if (X < bp) break;
      answer = max(answer, bp);
      bp *= b;
    }
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector <int> cnt(n);
    forn (i, 0, k) {
        int t;
        cin >> t;
        forn (j, 0, t) {
            int x;
            cin >> x;
            cnt[x - 1]++;
        }
    }
    int s = 0;
    forn (i, 0, n)
        if (!cnt[i])
            s++;
    cout << s;
    return 0;
}

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

int main() {
    int K; cin >> K;
    priority_queue<ll, vector<ll>, greater<ll>> q;
    for (int i = 1; i < 10; i++) {
        q.emplace(i);
    }
    int count = 0;
    ll ans;
    while(true) {
        ll val = q.top();
        q.pop();
        count ++;
        if (count == K) {
            ans = val;
            break;
        }
        ll first = val % 10;
        if (first-1 >= 0) q.emplace(10*val + first - 1);
        if (first+1 <= 9) q.emplace(10*val + first + 1);
        q.emplace(10*val + first);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define ms(a,v) memset(a,v,sizeof(a))
#define unq(v) v.erase(unique(v.begin(),v.end()),v.end());
#define mp make_pair
#define write(x) cout<<(x)<<endl
using namespace std; typedef long long ll;
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; }
const int INF = 1 << 28; const ll LINF = 1ll << 60;
const int MAX = 1e5 + 5; const int MOD = 1e9 + 7; const double EPS = 1e-6;
const int dy[4] = { 0,1,0,-1 }; const int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

ll X, Y;

int main() {
    cin >> X >> Y;
    ll ratio = Y / X;
    int msb = 0;
    while (ratio > 1) {
        ratio >>= 1;
        msb++;
    }
    write(msb + 1);
}

Measured memory_bytes: 256
import math

s=int(input())

p=10**9+7

n1=math.ceil(s/9)
n2=s//3

ans=0

fact=[1]
for i in range(1,2500):
    fact.append((fact[i-1]*i)%p)


for n in range(1,n2+1):
    combi=(fact[s-2*n-1]*pow(fact[n-1],p-2,p)*pow(fact[s-3*n],p-2,p))%p
    ans=(ans+combi)%p

print(ans)

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

int main(){
    int K, N;
    cin >> K >> N;
    int A[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    int max_width = 0;
    for(int i = 0; i < N - 1; i++){
        max_width = max(max_width, A[i + 1] - A[i]);
    }
    max_width = max(max_width, A[0] + K - A[N - 1]);

    cout << K - max_width << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<random>

//使い方がよくわからない
#include<stack>
#include<queue>
#include<bitset>
#include<sstream>

#define rep(i,n) for(int i=0;i<(n);i++) 
#define rep1(i,n) for(int i=1;i<(n);i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]){
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n-1);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n-1) cin >> c[i];
    int ans = b[0];
    rep1(i,n){
        ans += b[i];
        if((a[i]-a[i-1])==1){
            ans += c[a[i]-2];
        }
    }
    co(ans);
    return 0;
}


Measured memory_bytes: 256
#import sys
from collections import deque


def main():
    #N, M, *AB = map(int, sys.stdin.buffer.read().split())
    N, M, *AB = map(int, open(0).read().split())
    
    g = [[] for _ in range(N + 1)]

    for A, B in zip(*[iter(AB)] * 2):
        g[A].append(B)
        g[B].append(A)

        #print("->", g)

    queue = deque([1])
    d = [0] * (N + 1)
    d[0] = 1
    d[1] = 1

    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] == 0:
                #d[i] = d[v] + 1
                d[i] = v
                queue.append(i)

    if all(d):
        print("Yes")
        print("\n".join(map(str, d[2:])))
    else:
        print("No")


if __name__ == '__main__':
	main()

exit()


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

using namespace std;

typedef long long ll;

const ll MOD = 1e9+7;

signed main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> diff(n);
    for(auto& x : a)
        cin >> x;
    for(auto& x : b)
        cin >> x;
    for(ll i = 0; i < n; ++i)
        diff[i] = a[i] - b[i];
    ll plus_sum = 0;
    vector<ll> minus;
    for(ll i = 0; i < n; ++i){
        if(diff[i] < 0)
            plus_sum += diff[i];
        else
            minus.push_back(diff[i]);
    }
    sort(minus.begin(), minus.end());
    reverse(minus.begin(), minus.end());

    ll count = n - minus.size();
    if(plus_sum == 0){
        cout << 0 << endl;
        return 0;
    }
    for(ll i = 0; i < (ll)minus.size(); ++i){
        plus_sum += minus[i];
        if(plus_sum >= 0){
            cout << count + i + 1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3576
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_C&lang=ja
//幅優先探索
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}

template< typename T >
struct edge {
	int src, to;
	T cost;
	edge(int _to, T _cost) : src(-1), to(_to), cost(_cost) {}
	edge(int _src, int _to, T _cost) : src(_src), to(_to), cost(_cost) {}
	edge &operator=(const int &x) {
		to = x;
		return *this;
	}
	operator int() const { return to; }
};

template< typename T>
struct node {
	vector<edge<T>> edges;
    ll dist=-1;
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< node< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in");
    //std::ifstream in("./input.txt");
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll n; cin>>n;
    WeightedGraph<ll> graph(n+1);
    FOR(i,1,n+1){
        ll u,k; cin>>u>>k;
        REP(j,k){
            ll v; cin>>v;
            graph.at(u).edges.emplace_back(v,1);
        }
    }

    queue<ll> st;
    st.push(1);
    graph.at(1).dist=0;
    while(not st.empty()){
        auto cn = st.front();
        st.pop();
        auto& node = graph.at(cn);
        for(const auto& nn:node.edges){
            if(graph.at(nn).dist>=0) continue;
            graph.at(nn).dist = node.dist + 1;
            st.push(nn.to);
        }
    }

    FOR(i,1,n+1){
        cout<<i<<" "<<graph.at(i).dist<<endl;
    }
    return 0;
}


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

using namespace std;

#define sz(s) (int)s.size()
#define pb push_back
#define ll long long

const int inf = (int)1e9 + 7;
const int N = 107;

struct edge  {
    int a, b, c, f;
};

vector < int > gr[N];
vector < edge > e;
int lim, s, t;
ll maxflow, x;
int pt[N], d[N];

void add_edge (int a, int b, int c) {
    edge ed;
    ed.a = a; ed.b = b; ed.c = c; ed.f = 0;
    gr[a].pb(sz(e));
    e.pb(ed);

    ed.a = b; ed.b = a; ed.c = c; ed.f = c;
    gr[b].pb(sz(e));
    e.pb(ed);
}

bool bfs () {
    for (int i = s; i <= t; i++) {
        d[i] = inf;
    }
    d[s] = 0;
    queue < int > q;
    q.push(s);
    while (!q.empty() && d[t] == inf) {
        int v = q.front(); q.pop();
        for (int i = 0; i < sz(gr[v]); i++) {
            int id = gr[v][i];
            int to = e[id].b;
            if (d[to] == inf && e[id].c - e[id].f >= lim) {
                d[to] = d[v] + 1;
                q.push(to);
            }
        }
    }
    while (!q.empty()) q.pop();
    return d[t] != inf;
}

bool dfs (int v, int flow) {
    if (flow == 0) return false;
    if (v == t) return true;
    for (; pt[v] < sz(gr[v]); pt[v]++) {
        int id = gr[v][pt[v]];
        int to = e[id].b;
        if (d[v] + 1 == d[to] && e[id].c - e[id].f >= flow) {
            int pushed = dfs(to, flow);
            if (pushed) {
                e[id].f += flow;
                e[id ^ 1].f -= flow;
                return true;
            }
        }
    }
    return false;
}

void dinic () {
    for (lim = (1 << 30); lim >= 1;) {
        if (!bfs()) {
            lim >>= 1;
            continue;
        }
        for (int i = s; i <= t; i++) {
            pt[i] = 0;
        }
        int pushed;
        while (pushed = dfs(s, lim)) {
            maxflow += lim;
        }
    }
}

int a[N];


main() {
    int n; scanf ("%d", &n);
    t = n + 1;
    for (int i = 1; i <= n; i++) {
        scanf ("%d", a + i);
        if (a[i] > 0) x += a[i];
    }
    for (int i = 1; i <= n; i++) {
        if (a[i] <= 0) {
            add_edge(s, i, -a[i]);
        } else {
            add_edge(i, t, a[i]);
        }
        for (int j = i; j <= n; j += i) {
            add_edge(i, j, inf);
        }
    }
    dinic();
    cout << x - maxflow;
}


Measured memory_bytes: 256
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())

rem = pow(10,9)+7

#n = ip()                                     #入力整数1つ
#x,y= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[input() for i in range(x)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
s = 0
for i in range(len(a)-1):
    if a[i] != a[i+1]:s+=1
print(s)

Measured memory_bytes: 13788
/*
	Bakul Gaur (caesar1551)
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PrePro ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define fr(i,n) for(ll i = 0; i < n; i++)
#define fre(i,a,b) for(ll i = a; i <= b; i++)
#define fb(i,n) for(ll i = n; i >= 0; i--)
#define fbe(i,a,b) for(ll i = a; i >= b; i--)
#define umap(x,y) unordered_map<x,y>
#define uset(x) unordered_set<x>
#define vv(x) vector<x>
#define pp(x,y) pair<x,y>
#define prar(a,n) fr(i,n){cout << a[i] << " ";}
#define inar(a,n) fr(i,n){cin >> a[i];}
#define mk make_pair
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define MAX 1000001
inline ll gcd(ll a, ll b){
	if(b == 0){
		return a;
	}
	return gcd(b,a%b);
}
inline ll pwr(ll a, ll b, ll modulo = mod){
	if(a == 0 && b == 0){
		return 0;
	}
	ll ans = 1;
	while(b > 0){
		if(b&1){
			ans = ((ans%modulo) * (a%modulo))%modulo;
		}
		b >>= 1;
		a = ((a%modulo) * (a%modulo))%modulo;
	}
	return (ans+modulo)%modulo;
}
inline ll modInverse(ll a, ll p){
	// Only if p is prime.
	return pwr(a,p-2,p);
}



/* #############
   START SOLVING 
   ############# */



void solve(){
	ll n, w;
	cin >> n >> w;
	vv(ll) weight(n), val(n);
	ll sum_val = 0;
	fr(i,n){
		cin >> weight[i] >> val[i];
		sum_val += val[i];
	}
	vv(vv(ll)) dp(n+1,vv(ll)(sum_val+1));
	dp[0][0] = 0;
	fre(i,1,sum_val){
		dp[0][i] = INT_MAX;
	}
	ll ans = 0;
	//dp[i][j] = Least weight to get j value from first i objects
	fre(i,1,n){
		fre(j,0,sum_val){
			dp[i][j] = dp[i-1][j];
			if(j >= val[i-1]){
				dp[i][j] = min(dp[i][j], weight[i-1] + dp[i-1][j-val[i-1]]);
			}
			if(dp[i][j] <= w){
				ans = max(ans,j);
			}
		}
	}
	cout << ans << endl;
}
int main(){
	PrePro
	/* #ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif */
    ll t = 1;
    // cin >> t;
    fr(i,t){
    	// cout << "Case #" << i+1 << ": ";
    	solve();
    	// cout << endl;
    }
	return 0;
}

Measured memory_bytes: 83072
abc = list(map(int,input().split()))
a = abc[0]
b = abc[1]
c = abc[2]
k = int(input())

for i in range(4):
    if 2 ** i * b > a:
        n0 = i
        break

if 2 ** (k-n0) * c > 2 ** n0 * b:
    ans = "Yes"
else:
    ans = "No"
    
print(ans)

Measured memory_bytes: 9164
#include<iostream>
using namespace std;
const int Max = 100001;
int main(){
	int a[Max];
	int n,Count=0;
	cin>>n;
	for(int i=105;i<=n;i++)
		for(int j=1;j<=i;j++)
			if(!(i%j)) a[i]++;
	
	for(int i=105;i<=n;i++)
		if(a[i]==8 &&(i%2)) Count++;
	cout<<Count;
}

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

int main() {
    int n;
    string s,t;
    cin >> n >> s >>t;
    string ans="";
    for(int i=0; i<n; ++i){
        ans.push_back(s[i]);
        ans.push_back(t[i]);
    }
    cout << ans << endl;
}

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;
  int B[n-1];
  rep(i, n-1) cin >> B[i];
  int ans = 0;
  ans += B[0];
  ans += B[n-2];
  rep(i, n-2) ans += min(B[i], B[i+1]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define el "\n"
#define sp " "
typedef long long ll;



main()
{
	ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n;
cin>>n;
string t;
cin>>t;
vector<ll> s[3];
for(ll i=0;i<t.size();i++)
{
	if(t[i]=='R')
	s[0].push_back(i);
	if(t[i]=='G')
	s[1].push_back(i);
	if(t[i]=='B')
	s[2].push_back(i);
}
ll ans=0;
for(ll i=0;i<n;i++)
{
	for(ll j=i+1;j<n;j++)
	{
		if((t[i]=='R' && t[j]=='G')||((t[i]=='G' && t[j]=='R')))
		{
		//	cout<<"shub";
			ans+=s[2].end()-lower_bound(s[2].begin(),s[2].end(),j);
			if(find(s[2].begin(),s[2].end(),2*j-i)!=s[2].end())
			ans--;
		}
			if((t[i]=='R' && t[j]=='B')||((t[i]=='B' && t[j]=='R')))
		{
			ans+=s[1].end()-lower_bound(s[1].begin(),s[1].end(),j);
			if(find(s[1].begin(),s[1].end(),2*j-i)!=s[1].end())
			ans--;
			
		}
			if((t[i]=='B' && t[j]=='G')||((t[i]=='G' && t[j]=='B')))
		{
			ans+=s[0].end()-lower_bound(s[0].begin(),s[0].end(),j);
			if(find(s[0].begin(),s[0].end(),2*j-i)!=s[0].end())
			ans--;
		}
		
	}
}
cout<<ans;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
const ll mo = 998244353;
ll mypow(ll a, ll b)
{
  ll res = 1;
  a %= mo;
  while (b)
  {
    if (b & 1)
      res = res * a % mo;
    a = a * a % mo;
    b >>= 1;
  }
  return res;
}
int main()
{
ll n ;
cin >> n ;
vector<ll> d(n);
rep(i, n){
  cin >> d[i];
}
vector<ll> a(n+10);
rep(i,n){
  a[d[i]]++;
}
if(d[0]!=0){
cout << ans << endl;
return 0;
}
if(a[0]!=1){
cout << ans << endl;
return 0;
}
ll en=0;
rep(i,n){
  if(a[i]==0&&en==0)en++;
  else if(a[i]!=0&&en==1){
    cout << ans << endl;
    return 0;
  }
}
ans=1;
rep(i,n-1){
  if(a[i+1]==0)break;
  ans*=mypow(a[i],a[i+1]);
  ans%=mo;
}

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


Measured memory_bytes: 1792
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int vis[100];
int s[100];
int check(int x)
{
    while(x)
    {
        if(vis[x%10])
            return 0;
        x/=10;
    }
    return 1;
}
int main()
{
    int n,k;
    memset(vis,0,sizeof(vis));
    scanf("%d%d",&n,&k);
    for(int i=0;i<k;i++)
    {
        scanf("%d",&s[i]);
        vis[s[i]] = 1;
    }
    if(k==0)
        printf("%d\n",n);
    else
    {
        for(int i=n;;i++)
        {
            if(check(i))
            {
                printf("%d\n",i);
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    ll n;
    cin >> n;
    vector<ll> l(n);
    rep(i, n) cin >> l[i];

    sort(all(l));

    ll sum = 0;
    rep(i, n - 1) sum += l[i];
    if(l[l.size() - 1] < sum)
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Run(args));
        }

        private static string Run(string[] args)
        {
            var s = Console.ReadLine();
            switch (s)
            {
                case "Sunny":
                    return "Cloudy";
                case "Cloudy":
                    return "Rainy";
                case "Rainy":
                    return "Sunny";
                default:
                    return "";
            }
        }
    }
}


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


int main()
{
  string s, t;
  cin >> s >> t;
  for(char c = 'a'; c <= 'z'; c++)
  {
    if(s + c == t)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    ll n; cin >> n;
    vector<ll> h(n); rep(i, n) cin >> h[i];
    ll ans = 0;
    while(1) {
        bool fl = true;
        rep(i, n) if(h[i] != 0) fl = false;
        if(fl) break;
        ll id = 0;
        while(id < n) {
            if(h[id] == 0) {
                id++;
                continue;
            }
            while(h[id] != 0) h[id]--, id++;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
int h,n;
cin>>h>>n;
int arr[n];
int x;
int sum=0;
for(int i=0;i<n;i++){
cin>>arr[i];
sum+=arr[i];
}
if(sum>=h){
    cout<<"Yes"<<endl;
}
else{
   cout<<"No"<<endl;
}

}


Measured memory_bytes: 640
S = input()
x=[]
t=0
c=[0]
for s in S:
  x.append(s)
for i in range(len(x)):
  if x[i]=="A" or x[i]=="T" or x[i]=="C" or x[i]=="G":
    t+=1
  else:
    c.append(t)
    t=0
c.append(t)
print(max(c))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
    int n,ans=0;
    cin >> n;
    vec(a,n);
    vector<int> b;
    REP(i,n){
        cin >> a[i];
        ans += a[i];
        if(a[i]%10 != 0){
            b.push_back(a[i]);
        }
    }
    int s = b.size();
    sort(b.begin(),b.end());
    if(ans % 10 != 0){
        cout << ans << endl;
    }
    else if(s == 0){
        cout << 0 << endl;
    }
    else{
        cout << ans-b[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	n := int(math.Sqrt(float64(x)))
	for i := 2; i <= n; i++ {
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	cnt := make([]int, 100001)
	// N=3が最小
	cnt[3] = 1
	for i := 4; i < 100001; i++ {
		cnt[i] = cnt[i-1]
		if isPrime(i) && isPrime((i+1)/2) {
			cnt[i]++
		}
	}

	q := nextInt()
	for i := 0; i < q; i++ {
		l, r := nextInt(), nextInt()
		puts(cnt[r] - cnt[l-1])
	}
}


Measured memory_bytes: 4352
N, M = map(int, input().split())
res = ["?" for _ in range(N)]


for _ in range(M):
    s, c = map(int, input().split())
    if res[s - 1] == "?" or res[s - 1] == str(c):
        res[s - 1] = str(c)
    else:
        print(-1)
        exit()

if res[0] == "0" and N != 1:
    print(-1)
    exit()

if res[0] == "?" and N == 1:
    res[0] = "0"

if res[0] == "?":
    res[0] = "1"

for i in range(len(res)):
    if res[i] == "?":
        res[i] = "0"

print(int("".join(res)))


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

m = 1000000007

result = 1
t = [0, 0, 0]
for i in range(N):
    a = A[i]
    f = -1
    k = 0
    for j in range(3):
        if t[j] == a:
            k += 1
            if f == -1:
                t[j] += 1
                f = j
    result *= k
    result %= m
print(result)


Measured memory_bytes: 20768
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define int unsigned long long
#define double long double
#define floot10 cout<<fixed<<setprecision(10)
#define Int unsigned long long

int min(int a,int b){
  if(a<b) return a;
  return b;
}
int max(int a,int b){
  if(a>b) return a;
  return b;
}

int gcd(Int a, Int b) {
  return b != 0 ? gcd(b, a % b) : a;
}
int lcm(Int a, Int b) {
  return a / gcd(a, b)*b;
}
// a x + b y = gcd(a, b)
int extgcd(Int a, Int b, Int &x, Int &y) {
  Int g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
 
signed main(){
  int n;
  cin>>n;
  int ans;
  lp(i,n){
    int a;
    cin>>a;
    if(i==0)ans=a;
    else ans=lcm(a,ans);
    //cout<<ans<<endl;
  }
  cout<<ans<<endl;
  return 0;
}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n;
int f[100][10];
int p[100][11];

void input(){
    cin >> n;
    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++){
            cin >> f[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<11;j++){
            cin >> p[i][j];
        }
    }
}

bool isallzero(int* data, int n){
    for(int i=0;i<n;i++){
        if(data[i] != 0) return false;
    }
    return true;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    ll ans = -10000000000;
    for(int bit=0;bit<(1<<10);bit++){
        int c[n] = {};
        ll tmp = 0;
        for(int i=0;i<n;i++){
            for(int j=0;j<10;j++){
                if((bit&(1<<j)) && f[i][j]) c[i]++;
            }
        }
        if(isallzero(c, n)) continue;
        for(int i=0;i<n;i++){
            tmp += p[i][c[i]];
        }
        ans = max(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  string s;cin>>s;bool flag=true;
  std::map<char, bool> map;
  //cout<<"i"<<s<<endl;
  rep(i,0,s.size()){
    //cout<<"i"<<s[i]<<endl;
    auto itr = map.find(s[i]);
    if( itr != map.end() ) {
      //cout<<"n"<<s[i]<<endl;
    	flag=false;
    	break;
    } else {
      // cout<<"y"<<s[i]<<endl;
    	map[s[i]]=true;
    }
  }
  flagfunc(flag,"yes","no");
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

pub fn digit_sum(mut n: u64) -> u64 {
    let mut sum = 0;
    let d = 10;
    while n != 0 {
        sum += n % d;
        n /= d;
    }
    sum
}

fn main() {
    input! {
        n: u64
    }
    println!("{}",
        if n % digit_sum(n) == 0 {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int n,arr[200007];
priority_queue<int>q;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++) cin>>arr[i];
    sort(arr,arr+n);
    long long cnt=0;
    q.push(arr[n-1]);
    for(int i=n-2;i>=0;i--){
        cnt+=1ll*q.top(); q.pop();
        q.push(arr[i]);
        q.push(arr[i]);
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 5040
from collections import defaultdict, deque
from itertools import combinations

N, M, Q = map(int, input().split())
ABCD = [tuple(map(int, input().split())) for _ in range(Q)]

D = defaultdict(dict)
for a, b, c, d in ABCD:
  D[b-1][(a-1, c)] = d

for j in range(N-1, 0, -1):
  for x, y in combinations(D[j], 2):
    if x[0] == y[0]:
      continue
    if x[0] > y[0]:
      x, y = y, x
    if x[1] > y[1]:
      if (x[0], x[1] - y[1]) not in D[y[0]]:
        D[y[0]][(x[0], x[1] - y[1])] = 0

for j in range(1, N):
  if (j-1, 0) not in D[j]:
    D[j][(j-1, 0)] = 0

que = deque([([1], 0)])
memo = set([(1,)])
ans = 0
while que:
  L, score = que.popleft()
  if len(L) == N:
    if score > ans:
      ans = score
  else:
    for a, c in D[len(L)]:
      l = L[a] + c
      if L[-1] <= l <= M:
        x = tuple(L + [l])
        if x not in memo:
          memo.add(x)
          que.append((L + [l], score + sum(d for v, d in D[len(L)].items() if l - L[v[0]] == v[1])))
print(ans)

Measured memory_bytes: 34824
class Node:
    def __init__(self, index):
        self.count = 0
        self.fr = -1
        self.index = index


N, Q = map(int, input().split())
node = [Node(i) for i in range(N)]
for i in range(N - 1):
    fr, to = map(int, input().split())
    node[to - 1].fr = fr - 1

for i in range(Q):
    fr, c = map(int, input().split())
    node[fr - 1].count += c

print(node[0].count, end=' ')

for i in range(1, N):
    node[i].count += node[node[i].fr].count
    if not i == N:
        print(node[i].count, end=' ')
    else:
        print(node[i].count)

Measured memory_bytes: 91624
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <fstream>

using namespace std;

template<class T> inline T cabs(const T &x) { return x > 0 ? x : (-x); }
template<class T> inline T gcd(const T &x, const T &y) { return (y == 0) ? x : gcd(y, x % y); }
template<class T> inline T _sgn(const T &x) { return (x > 0) - (x < 0); }

#define dbg(x) cout << #x << " = " << (x) << endl
#define dbg2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define dbg3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl
#define dbg4(x,y,z,w) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #w << " = " << w << endl

#define out(x) cout << (x) << endl
#define out2(x,y) cout << (x) << " " << (y) << endl
#define out3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define out4(x,y,z,w) cout << (x) << " " << (y) << " " << (z) << " " << (w) << endl

const int maxN = 100000 + 10;

static int rmq1[maxN][20]; // max
static int rmq2[maxN][20]; // min

inline void init_rmq(int A[], int &nA)
{
	for(int i = 0; i < nA; ++i) rmq1[i][0] = A[i], rmq2[i][0] = A[i];

	for(int j = 1, tmp = 1; tmp < nA;tmp = (1 << j++)) {
		for(int i = 0; i + tmp < nA; ++i) {
			rmq1[i][j] = max(rmq1[i][j - 1], rmq1[i + tmp][j - 1]);
			rmq2[i][j] = min(rmq2[i][j - 1], rmq2[i + tmp][j - 1]);
		}
	}
}

inline int max_rmq(int L, int R)
{
	int x = 0;
	while( (1 << x) <= (R - L + 1) ) ++x;
	--x;

	return max(rmq1[L][x], rmq1[R + 1 - (1 << x)][x]);
}

inline int min_rmq(int L, int R)
{
	int x = 0;
	while( (1 << x) <= (R - L + 1) ) ++x;
	--x;

	return min(rmq2[L][x], rmq2[R + 1 - (1 << x)][x]);
}

int N, T;
int A[maxN];

int main()
{
    scanf("%d %d", &N, &T);
    for(int i = 0; i < N; i ++)
        scanf("%d", &A[i]);
    init_rmq(A, N);
    int cnt = 0, mx = 0;
    for(int i = N - 1; i > 0; i --) {
        int low = A[i] - min_rmq(0, i - 1);
        if( low > 0 ) {
            if( mx < low ) {
                cnt = 1;
                mx = low;
            } else {
                if( mx == low ) {
                    cnt ++;
                } else {
                    ;
                }
            }
        }
    }
    out(cnt);
    return 0;
}


Measured memory_bytes: 16384
n = int(input())
al = []
bl = []
for _ in range(n):
    a,b = map(int, input().split())
    al.append(a)
    bl.append(b)

al.sort()
bl.sort()

if n%2 == 1:
    mmin = al[n//2]
    mmax = bl[n//2]
    print(mmax-mmin+1)
else:
    mmin = (al[n//2]+al[n//2-1])/2
    mmax = (bl[n//2]+bl[n//2-1])/2
    ans = (mmax-mmin)*2+1
    ans = round(ans+0.1)
    print(ans)

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

// 0:R????????°????????§???, 1:L????????°????????§???
int dp[2001][2001][2];

void calc(string s, int K)
{
    int S=s.size();
    memset(dp,0,sizeof(dp));
    rep(i,S)
    {
        rep(j,K+1)
        {
            if(j%2==0)
            {
                // ??????????????????
                dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][0]+(s[i]=='R'));
                dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][1]+(s[i]=='L'));
                // ????????????
                if(j<K)
                {
                    dp[i+1][j+1][0] = max(dp[i+1][j+1][0], dp[i][j][0]+(s[i]=='L'));
                    dp[i+1][j+1][1] = max(dp[i+1][j+1][1], dp[i][j][1]+(s[i]=='R'));
                }
            }
            else
            {
                // ??????????????????
                dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][0]+(s[i]=='L'));
                dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][1]+(s[i]=='R'));
                // ????????????
                if(j<K)
                {
                    dp[i+1][j+1][0] = max(dp[i+1][j+1][0], dp[i][j][0]+(s[i]=='R'));
                    dp[i+1][j+1][1] = max(dp[i+1][j+1][1], dp[i][j][1]+(s[i]=='L'));
                }
            }
        }
    }

    // rep(k,2)
    // {
    //     printf(" k= %d\n", k);
    //
    //     rep(i,S+1)rep(j,K+1) printf("dp[%d][%d][%d] = %d\n", i,j,k,dp[i][j][k]);
    //     printf("\n");
    // }
    // printf("\n\n");
}



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

    string x="",y="";
    rep(i,s.size())
    {
        if(s[i]=='L' || s[i]=='R') x+=s[i];
        else
        {
            if(s[i]=='U') y+='L';
            else y+='R';
        }
    }

    int X=x.size(), Y=y.size();
    // 0:R????????°????????§???, 1:L????????°????????§???
    int dx[2001]={};
    // 0:D????????°????????§???, 1:U????????°????????§???
    int dy[2001]={};

    calc(x,K);
    rep(i,K+1) dx[i]=max(2*dp[X][i][0]-X, 2*dp[X][i][1]-X);
    calc(y,K);
    rep(i,K+1) dy[i]=max(2*dp[Y][i][0]-Y, 2*dp[Y][i][1]-Y);

    int ans=0;
    rep(i,K+1)rep(j,K+1)if(i+j<=K)
    {
        // printf("(%d, %d) dx,dy %d %d\n", i,j,dx[i],dy[j]);
        ans=max(ans,dx[i]+dy[j]);
    }

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

Measured memory_bytes: 34440
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
//		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		HashMap<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			putCntMap(map, Integer.parseInt(sa[0]));
			putCntMap(map, Integer.parseInt(sa[1]));
		}
		br.close();

		for (Integer key : map.keySet()) {
			if (map.get(key) % 2 == 1) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}

	static void putCntMap(Map<Integer, Integer> map, Integer key) {
		if (map.containsKey(key)) {
			map.put(key, map.get(key) + 1);
		} else {
			map.put(key, 1);
		}
	}
}


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

int main() {
  //input
  int D, T, S;
  cin >> D >> T >> S;
  //calc
  string ans = D <= S * T ? "Yes" : "No";
  //output
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define lld long long int
#define ld long double
#define mod 1000000007
#define modd 998244353
#define all(v) v.begin(),v.end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define ar array
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
lld n,m;
lld arr[300000];
map<lld,bool> ma;
map<lld,bool> mb;
lld sumd(lld a){
    lld sum=0;
    while(a){sum+=a%10;
    a/=10;}
    return sum;
}
deque<ar<lld,2> > que;
int main()
{
     ios;
     lld TESTS,q,a,s,b,l,r,c,k,p,h,w,d,x,y,z,xs,ys,t;
     TESTS=1;
     //cin>>TESTS;
     while(TESTS--)
     {
         cin>>k;
         que.push_back({1,1});
         ma[1]=true;
         mb[1]=true;
         while(!que.empty()){
             ar<lld,2> cur=que.front();
             que.pop_front();
             if (cur[0]==0){
                cout<<cur[1];
                return 0;
             }
             if (!ma[(cur[0]*10)%k]){
                ma[(cur[0]*10)%k]=true;
                que.push_front({(cur[0]*10)%k,cur[1]});
             }
             if (!mb[(cur[0]+1)%k]){
                mb[(cur[0]+1)%k]=true;
                que.pb({(cur[0]+1)%k,cur[1]+1});
             }
         }
     }
    return 0;
}


Measured memory_bytes: 14464
N, Q = gets.split.map(&:to_i)
memo = Array.new(N, 0)
s = gets.chomp.split('')

cnt = 0
1.upto(N) do |i|
  if s[i-1] == "A" && s[i] == "C"
    cnt += 1
  end
  memo[i] = cnt
end
# p memo
Q.times do
  s, t = gets.split.map(&:to_i)
  puts memo[t-1] - memo[s-1]
end


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

int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  long long fir=0;
  long long sec=0;
  
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  
  sort(A.begin(),A.end());
  
  for (int i=1; i<N; i++) {
    if (A[i-1] == A[i]) {
      sec = fir;
      fir = A[i];
      i++;
    }
  }
  
  cout << fir * sec << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std; 
#define ll long long
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}
int H, W;
int N;
int sr, sc;
string S, T;
string dis = "LRUD";

int main(){
    cin >> H >> W >> N;
    cin >> sr >> sc >> S >> T;
    reverse(S.begin(), S.end());
    reverse(T.begin(), T.end());

    bool flag = true;
    int l = 1, r = W;
    int u = 1, d = H;

    for(int i = 0; i < N; i++){
        if(T[i] == 'L') r = min(W, r + 1);
        if(T[i] == 'R') l = max(1, l - 1);
        if(T[i] == 'U') d = min(H, d + 1);
        if(T[i] == 'D') u = max(1, u - 1);
        
        if(S[i] == 'L') l++;
        if(S[i] == 'R') r--;
        if(S[i] == 'U') u++;
        if(S[i] == 'D') d--;
        if(r < l || d < u) flag = false;
    }
    if(l > sc || sc > r || u > sr || sr > d) flag = false;

    cout << (flag ? "YES" : "NO") << endl;
    return 0;
}

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

int main()
{
    int h, n;
    cin >> h >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    vector<ll> dp(h + 1, INT32_MAX);
    dp[0] = 0;

    for (int i = 1; i <= h; ++i)
    {
        rep(j, n)
        {
            dp[i] = min(dp[i], dp[max(i - a[j], 0)] + b[j]);
        }
    }
    cout << dp[h] << endl;
}

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

int main()
{
  int A, B, K;
  cin >> A >> B >> K;
  int cnt = 0;
  int i = min(A, B);
  // O(min(A, B))のアルゴリズム
  while (i > 0)
  {
    if (A % i == 0 && B % i == 0)
    {
      cnt++;
    }
    if (cnt == K)
    {
      break;
    }
    i--;
  }
  cout << i << endl;
}

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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;

struct Point {
	double x, y;
	Point() {};
	Point(double _x, double _y) : x(_x), y(_y) {};
};

int n, q;
Point p[4];

Point operator - (const Point &a, const Point &b){
	return Point(a.x - b.x, a.y - b.y);
}

double dot(Point a, Point b){
	return a.x * b.x + a.y * b.y;
}

double cross(Point a, Point b){
	return a.x * b.y - a.y * b.x;
}

const double EPS = 1e-10;

double dist(const Point &p, const Point &q){
	double dx = p.x - q.x;
	double dy = p.y - q.y;

	return sqrt(dx * dx + dy * dy);
}

bool eq(double a, double b){
	return fabs(a - b) < EPS;
}

void direction(Point a, Point b, Point c){
	double crs = cross(b - a, c - a);
	double ab = dist(a, b);
	double ac = dist(a, c);

	if(eq(crs, 0)){
		double cosAlpha = dot(b - a, c - a) / ab / ac;
		if(eq(cosAlpha, -1)){
			cout << "ONLINE_BACK\n";
		} else {
			if(ab < ac){
				cout << "ONLINE_FRONT\n";
			} else {
				cout << "ON_SEGMENT\n";
			}
		}
		return;
	}

	if(crs > 0){
		cout << "COUNTER_CLOCKWISE\n";
	} else if(crs < 0){
		cout << "CLOCKWISE\n";
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> p[0].x >> p[0].y >> p[1].x >> p[1].y;

	cin >> q;

	while(q--){
		cin >> p[2].x >> p[2].y;
		direction(p[0], p[1], p[2]);
	}

	return 0;
}


Measured memory_bytes: 3308
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const int INF = 1000000000;
const int MOD = 1000000007;

void selectionSort(vs &ar) {
	int i, j, k, n = ar.size();
	for (i = 0; i < n - 1; i++) {
		k = i;
		for (j = i + 1; j < n; j++) {
			if (ar[j][1] < ar[k][1])
				k = j;
		}
		if (k != i)
			swap(ar[i], ar[k]);
	}
}

void bubleSort(vs &ar) {
	int i, j, n = ar.size();
	for (i = 0; i < n - 1; i++) {
		for (j = 0; j < n - 1 - i; j++) {
			if (ar[j][1] > ar[j + 1][1])
				swap(ar[j], ar[j + 1]);
		}
	}
}

void printVs(vs &ar) {
	for (int i = 0; i < ar.size(); i++) {
		if (i > 0) cout << " ";
		cout << ar[i];
	}
	cout << "\n";
}

int main() {FIN
    
    int n, i;
    cin >> n;
    vs ar1(n), ar2;
    for (i = 0; i < n; i++)
		cin >> ar1[i];
	ar2 = ar1;
	
	bubleSort(ar1);
	selectionSort(ar2);
	
	printVs(ar1);
	cout << "Stable\n";
	printVs(ar2);
	cout << (ar1 == ar2 ? "Stable" : "Not stable") << "\n";
	
    
    return 0;
}



Measured memory_bytes: 3236
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b&&b!=c)||(a==c&&c!=b)||(b==c&&c!=a))
    {
        cout<<"Yes\n";
    }
    else
        cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

vector<vector<int>> split_by_val(const vector<int>& vD, int val){
    vector<vector<int>> vvD;
    vector<int> tmp;
    for(uint i=0; i<vD.size(); ++i){
        if(vD[i]==val){
            vvD.push_back( tmp );
            tmp.resize(0);
            continue;
        }
        tmp.push_back( vD[i] );
    }
    vvD.push_back( tmp );
    return vvD;
}

int main(){
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    
    uint N, M; cin >> N >> M;
    vector<int> vX(M);
    for(uint i=0; i<M; ++i){ cin >> vX[i]; }
    sort(vX.begin(), vX.end());
    
    vector<int> vD(M-1); // val, idx
    for(uint i=0; i<M-1; ++i){ vD[i] = vX[i+1]-vX[i]; }
    
    vector<pair<int, int>> vDiff(M-1); // val, idx
    for(uint i=0; i<M-1; ++i){ vDiff[i] = make_pair(vX[i+1]-vX[i], i); }
    sort(vDiff.begin(), vDiff.end(), greater<pair<int, int>>());
    
    for(uint i=0; i<min(N-1, M-1); ++i){
        vD[ vDiff[i].second ] = INT_MAX;
    }
    vector<vector<int>> vvD = split_by_val(vD, INT_MAX);
    
    int sum=0ll;
    for(uint i=0; i<vvD.size(); ++i){
//        sum += vvX[i][ vvX[i].size()-1 ] - vvX[i][0];
        sum += std::accumulate(vvD[i].begin(), vvD[i].end(), 0);
    }
    cout << sum << endl;
    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int n;
int main() {
    cin>>n;
    int ans = 0;
    for(int i=1;i<=n; i=i+2){
        int cnt = 0;
        FOR(j,1,i+1){
            if(i%j==0){
                cnt++;
            }
        }
        if(cnt==8){
            //DEBUG(i);
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

  static int a[101010][3];
  for (int i = 0; i, i < N; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> a[i][j];
    }
  }

  static int dp[101010][3];

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (j != k) {
          dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + a[i][k]);
        }
      }
    }
  }

  cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;
  return 0;
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  string s, t; cin>>s>>t;
  string res = t+s;
  cout<<res;
  

  return 0;
}


Measured memory_bytes: 256
s=input()
t=input()
s_list=[]
t_list=[]
x=""
y=""
for i in range(len(s)):
    s_list.append(s[i])
for i in range(len(t)):
    t_list.append(t[i])
s_list.sort()
t_list.sort(reverse=True)
for i in range(len(s)):
    x+=s_list[i]
for i in range(len(t)):
    y+=t_list[i]
if(x<y):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064