akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
map<string, P> mp;
typedef bitset<256> bs;
int main(){
	bool zerodiv = false;
	int n, m; cin >> n;
	rep(i, n) {
		string s; int le, ri; cin >> s >> le >> ri;
		mp[s] = { le,ri };
	}
	stack<bitset<256>> q;
	cin >> m;
	rep(i, m) {
		string s; cin >> s;
		if (zerodiv)continue;
		bs b = 0;
		if ('0' <= s[0] && s[0] <= '9') {
			int u = stoi(s);
			b[u] = 1;
			q.push(b);
		}
		else if (s == "+") {
			bs c;
			c = q.top(); q.pop();
			b = q.top(); q.pop();
			bs nex = 0;
			rep(j, 256) {
				if (!b[j])continue;
				rep(k, 256) {
					if (!c[k])continue;
					nex[(j + k) % 256] = 1;
				}
			}
			q.push(nex);
		}
		else if (s == "-") {
			bs c;
			c = q.top(); q.pop();
			b = q.top(); q.pop();
			bs nex = 0;
			rep(j, 256) {
				if (!b[j])continue;
				rep(k, 256) {
					if (!c[k])continue;
					nex[(j - k+256) % 256] = 1;
				}
			}
			q.push(nex);
		}
		else if (s == "*") {
			bs c;
			c = q.top(); q.pop();
			b = q.top(); q.pop();
			bs nex = 0;
			rep(j, 256) {
				if (!b[j])continue;
				rep(k, 256) {
					if (!c[k])continue;
					nex[j*k % 256] = 1;
				}
			}
			q.push(nex);
		}
		else if (s == "/") {
			bs c;
			c = q.top(); q.pop();
			b = q.top(); q.pop();
			if (c[0]) {
				zerodiv = true; continue;
			}
			bs nex = 0;
			rep(j, 256) {
				if (!b[j])continue;
				rep(k, 256) {
					if (!c[k])continue;
					nex[j/k] = 1;
				}
			}
			q.push(nex);
		}
		else {
			Rep1(j, mp[s].first, mp[s].second) {
				b[j] = 1;
			}
			q.push(b);
		}
	}
	if (zerodiv)cout << "error" << endl;
	else cout << "correct" << endl;
	return 0;
}


Measured memory_bytes: 3224
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
B = list(map(int,readline().split()))
ans = 0 
ans += B[0]
for i in range(N-2):
    ans += min(B[i],B[i+1])
ans += B[N-2]
print(ans)

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

#define int long
signed main(){
	int k;
	int a,b;
	cin >> k;
	cin >> a >> b;
	int q = b/k;
	int val = q*k;
	if(val >= a){
		cout << "OK";
	}
	else
		cout << "NG";
	
	
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=998244353;
const ll MAX_N=500010;
const ll INF=100100100100100;

int main(){
    int a,b;
    cin>>a>>b;
    if(a<=9 && b<=9){
        cout<<a*b<<endl;
    }else{
        cout<<-1<<endl;
    }
    
}

Measured memory_bytes: 3192
// Problem : D - Not Divisible
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;


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

    long n;
    cin >> n;
    vector<bool> sieve(1000001, false);
    vector<long> a(n);
    for (long i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    
    long count = 0;
    for (long i = 0; i < n; i++) {
        if (!sieve[a[i]] && (i == n - 1 || a[i+1] != a[i])) count++;
        if (!sieve[a[i]]){
            long j = a[i];
            while (j <= (long)1e6) {
                sieve[j] = true;
                j += a[i];
            }   
        }
        
    }
    cout << count << "\n";
    
    return 0;
}


Measured memory_bytes: 5044
#include<bits/stdc++.h>
using namespace std;
int x[] = {-1,0,1,0};
int y[] = {0,1,0,-1};
int h, w, k;
int main(){
  cin >> h >> w >> k;
  int si, sj;
  vector<vector<int>> dist(h, vector<int> (w,1e9));
  vector<string> a(h);
  for(int i=0; i<h; i++){
    cin >> a[i];
    for(int j=0; j<w; j++){
      if(a[i][j] == 'S'){
        si = i;
        sj = j;
        dist[i][j] = 0;
        break;
      }
    }
  }
  queue<pair<int,int>> que;
  que.push({si, sj});
  int nowi, nowj;
  while(!que.empty()){
    tie(nowi, nowj) = que.front();
    que.pop();
    if(dist[nowi][nowj] > k) break;
    for(int t=0; t<4; t++){
      if(clamp(nowi+x[t], 0, h-1) == nowi+x[t] && clamp(nowj+y[t], 0, w-1) == nowj+y[t]){
        if(a[nowi+x[t]][nowj+y[t]] == '#') continue;
        if(dist[nowi+x[t]][nowj+y[t]] > dist[nowi][nowj] + 1){
          dist[nowi+x[t]][nowj+y[t]] = dist[nowi][nowj] + 1;
          que.push({nowi+x[t], nowj+y[t]});
        }
      }
    }
  }
  int maxlen = 1e9;
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(dist[i][j] <= k){
        maxlen = min({maxlen, i, j, h-1-i, w-1-j});
      }
    }
  }
  cout << 1 + (maxlen + k - 1) / k << endl;
}

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

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

    vector<vector<ll>> v(N,vector<ll> (3,0));
    cin >> v[0][0] >> v[0][1] >> v[0][2];
    for (int i=1;i<N;++i){
        cin >> a >> b >> c;
        v[i][0] = max(v[i-1][1],v[i-1][2]) + a;
        v[i][1] = max(v[i-1][0],v[i-1][2]) + b;
        v[i][2] = max(v[i-1][0],v[i-1][1]) + c;
    }
    cout << *max_element(v[N-1].begin(),v[N-1].end()) << endl;
}

Measured memory_bytes: 5760
xs,ys,xt,yt = map(int, input().split())
n = int(input())
c = [(xs,ys, 0),(xt,yt,0)]
for i in range(n):
    x,y,r = map(int, input().split())
    c.append((x,y,r))

def circle_circle(ax,ay,ar,bx,by,br):
    d =((ax-bx)**2 + (ay-by)**2)**0.5
    return max(0, d-(ar+br))

def dijkstra(V, edges, root):
    import heapq

    visited = [False] * V
    nodes = [[] for i in range(V)]
    cost = [[] for i in range(V)]

    for e in edges:
        s, t, d = e
        nodes[s].append(t)
        cost[s].append(d)

    dist = [float('inf')] * V
    dist[root] = 0

    h = [(0, root)]
    while h:
        c, v = heapq.heappop(h)
        if visited[v]:
            continue
        visited[v] = True
        for i in range(n+1):
            t = nodes[v][i]
            nc = c + cost[v][i]
            if dist[t] > nc:
                dist[t] = nc
                heapq.heappush(h, (nc, t))
    return dist
edges = []
for i in range(n+1):
    for j in range(i+1, n+2):
        d = circle_circle(c[i][0],c[i][1],c[i][2],c[j][0],c[j][1],c[j][2])
        edges.append((i,j,d))
        edges.append((j,i,d))
dij = dijkstra(n+2, edges, 0)
print(dij[1])


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

const int maxn = 55;
char s[maxn][maxn];
int n, len[maxn];

int main(){
	scanf("%d", &n);
	for (int i=1; i<=n; i++){
		scanf("%s", s[i]+1);
		len[i] = strlen(s[i]+1);
	}
	for (int i=1; ; i++){
		bool check1 = false;
		for (int j=0; j<26; j++){
			bool check2 = true;
			for (int k=1; k<=n; k++){
				bool check3 = false;
				for (int l=1; l<=len[k]; l++)
					if (s[k][l] == 'a'+j){
						check3 = true; break;
					}
				if (!check3){
					check2 = false; break;
				}
			}
			if (check2){
				putchar('a' + j);
				for (int k=1; k<=n; k++)
					for (int l=1; l<=len[k]; l++)
						if (s[k][l] == 'a'+j){
							s[k][l] = ' '; break;
						}
				check1 = true; break;
			}
		}
		if (!check1) break;
	}
	return 0;
}

Measured memory_bytes: 128
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second
string s;
ll dp[100005][13];

ll f(ll index,ll mo)
{
    if(index==(s.size()))
    {
        if(mo==5)
            return 1;
        return 0;
    }
    if(dp[index][mo]!=-1)
        return dp[index][mo];
    if(s[index]=='?')
    {
        ll ret=0;
        for(ll dig=0;dig<10;dig++)
        {
            ret+=f(index+1,(10*mo+dig)%13);
            ret%=mod;
        }
        return dp[index][mo]=ret;
    }
    else
    {
        return dp[index][mo]=f(index+1,(10*mo+(s[index]-'0'))%13)%mod;
    }
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>s;
	memset(dp,-1,sizeof(dp));
	cout<<f(0,0);
    return 0;
}


//252908XL

Measured memory_bytes: 16848
from collections import defaultdict
c = defaultdict(int)

N = raw_input().split(' ')[0]
for i in range(int(N)):
    c[frozenset((sorted([int(k) for k in raw_input().split(' ')[0:3]])))] += 1


print(sum([i - 1 for i in c.values() if i > 1]))



Measured memory_bytes: 5284
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll A, B;
    cin >> A >> B;

    cout << (B - 1 + (A - 1) - 1) / (A - 1) << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+5;
int a[maxn];
int main(){
	int n;
	scanf("%d",&n);
	for (int i = 2; i <=n; ++i)
	{
		int t;scanf("%d",&t);
		a[t]++;
		/* code */
	}
	for (int i = 1; i <=n; ++i)
	{
		printf("%d\n",a[i] );
		/* code */
	}
	return 0;
}


Measured memory_bytes: 4380
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define Jrep(j,n) for(int j=0;j<(n);j++)
#define Jreps(j,n) for(int j=1;j<=(n);j++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;

using namespace std;    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,dp[100010]={};
    cin>>n;
    int h[100010];
    reps(i,n){
	cin>>h[i];
    }
    dp[2]+=abs(h[1]-h[2]);
    for(int i=3;i<=n;i++){
	dp[i]+=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
    }
    cout<<dp[n]<<'\n';
    
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
#define UB upper_bound
#define LB lower_bound
const int NUM = 2e5 + 5;
int dp[3000][3000];
int choice[3000][3000];
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin >> num_tests;
    while(num_tests-->0){
        string s,t; cin >> s >> t;
        int n = s.size(), m = t.size();
        if(s[0] == t[0])
            dp[0][0] = 1, choice[0][0] = 2;
        else dp[0][0] = 0;
        FOR(i,0,n){
            FOR(j,0,m){
                if(i > 0){
                    if(dp[i][j] < dp[i-1][j]){
                        dp[i][j] = dp[i-1][j];
                        choice[i][j] = 0;
                    }
                }
                if(j > 0){
                    if(dp[i][j] < dp[i][j-1]){
                        choice[i][j] = 1;
                        dp[i][j] = dp[i][j-1];
                    }
                }
                if(s[i] == t[j]){
                    int add = 1;
                    if(i > 0 and j > 0)
                        add = 1 + dp[i-1][j-1];
                    if(dp[i][j] < add)
                    {
                        choice[i][j] = 2;
                        dp[i][j] = add;
                    }
                }
            }
        }
        string ans ;
        int x = n-1, y = m-1;
        while(x >= 0 and y >= 0){
            if(choice[x][y] == 0) x--;
            else if(choice[x][y] == 1) y--;
            else{
                ans.pb(s[x]);
                x--; y--;
            }
        }
        reverse(all(ans));
        cout << ans ;
    }   
}

Measured memory_bytes: 144256
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int A = sc.nextInt();
		int H[] = new int[N];
		for(int i = 0; i < N; i++) {
			H[i] = sc.nextInt();
		}
		int ans = 0;
		double min = Double.MAX_VALUE;
		for(int i = 0; i < N; i++) {
			if(Math.abs(((double)T - (double)H[i] * 0.006) - (double)A) < min) {
				min = Math.abs(((double)T - (double)H[i] * 0.006) - (double)A);
				ans = i + 1;
			}
		}
		System.out.println(ans);
	}
}


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

bool cmp(int ha, int wa, int hb, int wb){
  int pa = ha * ha + wa * wa;
  int pb = hb * hb + wb * wb;
  if(pa < pb) return true;
  if(pa > pb) return false;
  return ha < hb;
}

int main(){
  int h, w;

  while(cin >> h >> w, h || w){
    int ansH = 999, ansW = 999;

    for(int H = 1; H <= 150; H++){
      for(int W = H + 1; W <= 150; W++){
        if(H == h && W == w) continue;
        if(!cmp(h, w, H, W)) continue;
        if(!cmp(H, W, ansH, ansW)) continue;
        ansH = H;
        ansW = W;
      }
    }
    cout << ansH << " " << ansW << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define pw(x) (1LL<<(x))
static const int fast_io = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 0;}();
static const int precise_doubles = [](){cout<<fixed<<setprecision(20);return 0;}();
typedef pair<int, int> PII;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) - iterator to kth largest, order_of_key(k) - #things < k
typedef long double LD;
typedef long long LL;
#define EVAL(x) x
#define SPA(x) EVAL({cout << #x" = " << x << ' ';})
#define NEWL EVAL({cout << '\n';})
#define SPAR(a, b) EVAL({cout<<#a" = ";for(auto it=a;it!=b;)cout<<*(it++)<<" ";cout<<'\n';})
#define SPAV(v) EVAL({cout<<#v" = ";for(auto it=v.begin();it!=v.end();)cout<<*(it++)<<" ";cout<<'\n';})
const int INF = 0x3f3f3f3f; // 1.0e9
const LL LINF = 0x3f3f3f3f3f3f3f3fll; // 4.5e18
const LD eps = 1e-20;
const int mod = 1e9 + 7;
inline int msum(int x, int y) {return (x+y<mod ? x+y : x+y-mod);}
inline int mdif(int x, int y) {return (x>=y ? x-y : x-y+mod);}
inline int mprod(int x, int y) { return (1ll*x*y) % mod; }
inline int mpow(int x, LL y) {LL r=1;while(y){if(y&1)r=mprod(r,x);x=mprod(x,x);y>>=1;}return r;}
inline int minv(int x) { return mpow(x, mod-2); }
#define DIE EVAL({cout << -1 << '\n'; exit(0);})
//------------------------------------------------------------------------------------------------------

const int N = 44;
const int SUM = 17;

int n, x, y, z;
vector<int> dp;

bool haiku(int mask) {
    if((mask & (1<<(z-1))) == 0) return false;
    if((mask & (1<<((y+z)-1))) == 0) return false;
    if((mask & (1<<((x+y+z)-1))) == 0) return false;
    return true;
}

int main() {
    cin >> n >> x >> y >> z;
    int sum = x+y+z;
    int max_mask = (1<<(sum-1));
    dp.resize(max_mask);
    dp[0] = 1;
    REP(iteration, n) {
        vector<int> newdp(max_mask);
        REP(mask, max_mask) {
            FOR(d, 1, 11) {
                int newmask = (mask << d) | (1 << (d-1));
                if(haiku(newmask)) continue;
                newmask &= (max_mask-1);
                newdp[newmask] = msum(newdp[newmask], dp[mask]);
            }
        }
        dp = newdp;
    }
    int bad = 0;
    REP(i, max_mask) {
        bad = msum(bad, dp[i]);
    }
    cout << mdif(mpow(10, n), bad) << '\n';
}






























Measured memory_bytes: 768
import sys
import math
from collections import deque
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()
a = IL()

num = sum(a)
if num > N:
  print(-1)
else:
  print(N-num)

Measured memory_bytes: 68328
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;



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

  ll a, b;
  cin >> a >> b;

  if (a>=b){
    ll sb = 0;
    REP(i,a){
      sb += b*pow(10,i);
    }
    cout << sb << "\n";
  } else {
    ll sa = 0;
    REP(i,b){
      sa += a*pow(10,i);
    }
    cout << sa << "\n";
  }

  return 0;
}


Measured memory_bytes: 512
"""
できるだけ右端に寄せればいいのでは？
区間の終わりが来た時にキューの中身を空にして全部終わりにする
"""
from collections import deque

N,M = map(int,input().split())

a = []
b = []

for i in range(M):

    A,B = map(int,input().split())
    a.append([A-1,i])
    b.append([B-1,i])

q = deque([])
end = [False] * (M)
ans = 0

ai = 0
bi = 0
a.sort()
b.sort()
a.append([float("inf"),0])
b.append([float("inf"),0])

for i in range(2*M):

    #print (a[ai],b[bi])

    if a[ai][0] < b[bi][0]:
        q.append(a[ai][1])
        ai += 1
    else:
        if end[b[bi][1]]:
            bi += 1
        else:
            loop = len(q)
            ans += 1
            for j in range(loop):

                now = q.popleft()
                end[now] = True
            bi += 1

print (ans)


Measured memory_bytes: 77272
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
typedef std::numeric_limits< double > dbl;
using namespace std;
const long long N=200005, INF=2000000000000000000;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    msi mp;
    while(n--)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<mp.size();
}

Measured memory_bytes: 19184
#include<bits/stdc++.h>
#define LL long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define For(i,a,b) for(int i=a;i>=b;i--)
#define debug

using namespace std;

int read(){
    char c=getchar(); int flag=1, x=0;
    while(!isdigit(c)){ if(c=='-') flag=-1; c=getchar(); }
    while( isdigit(c)){ x=x*10+(c-'0'); c=getchar(); }
    return flag*x;
}


signed main(){

    int A=read(), B=read();
    cout<<max(0,A-2*B);
    
    return 0;
}


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

int main(){
  int n;
  int ans=0;
  cin >> n;
  for (int i=0;i<n; ++i){
    int a;
    cin >> a;
    while(a%2==0){
      a=a/2;
      ans ++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define RI register int
const int N=1000005;
int n,ans,he,ta,q[N];
char S[N],T[N];
int main()
{
	scanf("%d",&n);
	scanf("%s",S+1),scanf("%s",T+1);
	if(!strcmp(S+1,T+1)) {puts("0");return 0;}
	he=1;
	for(RI i=n,j=n;i>=1;--i) {
		if(T[i]==T[i-1]) continue;
		while(j&&(S[j]!=T[i]||j>i)) --j;
		if(!j) {puts("-1");return 0;}
		while(he<=ta&&q[he]-(ta-he)>i) ++he;
		q[++ta]=j;if(i!=j) ans=max(ans,ta-he+1);
	}
	printf("%d\n",ans+1);
	return 0;
}

Measured memory_bytes: 6144
n=int(input())
a=list(map(int,input().split()))
b=0
c=0
for i in range(n):
  if a[i]%2==0:
    if a[i]%4==0:
      c+=1
    else:
      b+=1
if c==0:
  print("Yes") if n==b else print("No")
elif b==0:
  print("Yes") if n<=2*c+1 else print("No")
else:
  print("Yes") if n<=2*c+b else print("No")

Measured memory_bytes: 14252
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.util.*;
 
public class Main
{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
//        int n = sc.nextInt();
//        BigDecimal base = new BigDecimal("1");
//        long m = (long) Math.pow(10,18);
//        BigDecimal mm = new BigDecimal(m);
//
//        for (int i = 0;i<n;++i)
//        {
//            BigDecimal a = sc.nextBigDecimal();
//            //System.out.println(base+" * "+a);
//            base = a.multiply(a);
//            if (base.compareTo(mm) > 0)
//            {
//                base = new BigDecimal(-1);
//                break;
//            }
//        }
//
//        System.out.println(base);
        BigDecimal a = sc.nextBigDecimal();
        BigDecimal b = sc.nextBigDecimal();
        BigDecimal ans = a.multiply(b);
        System.out.println(ans.setScale(0,BigDecimal.ROUND_DOWN));
 
        sc.close();
    }
}

Measured memory_bytes: 37544
#include <stdio.h>

using namespace std;

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

	for(int i = 1; i<= n; i++)
	{
		if(i%3 == 0){
			printf(" %d",i);
		}else{
			x = i;
			do{
				if(x%10 == 3){
					printf(" %d",i);
					break;
				}
				x /=10;
			}while(x);
		}
	}
	printf("\n");
}


Measured memory_bytes: 2724
#include <iostream>
#include <algorithm>

int main(int argc, const char *argv[]) {
    std::string str;
    std::cin >> str;
    int q;
    std::cin >> q;
    std::string command, p;
    int a, b;
    for (int i = 0; i < q; i++) {
        std::cin >> command >> a >> b;
        if (command == "replace") {
            std::cin >> p;
            str.replace(a, b - a + 1, p);
        } else if (command == "reverse") {
            std::reverse(str.begin() + a, str.begin() + b + 1);
        } else if (command == "print") {
            std::cout << str.substr(a, b - a + 1) << std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3204
// luogu-judger-enable-o2
// SeptEtavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define re register
#define ll long long
#define il inline
#define rep(i,s,t) for(re int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(re int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define pt(ch) putchar(ch)
#define pti(x) printf("%d",x)
#define ptll(x) printf("%lld",x)
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
using namespace std;
// c_ints
il int ci(){
	re char ch;int f=1;
	while(!isdigit(ch=getchar()))f= ch=='-'?-1:1 ;
	re int x= ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}
enum{N=100024};
int fa[N],dis[N];
void fd(int x){
	if( fa[x]==x ) return ;
	fd(fa[x]);
	dis[x]+= dis[fa[x]];
	fa[x]= fa[fa[x]];
}
int main(){
	int n=ci(), m=ci();
	rep(i,1,n) fa[i]= i;
	while( m-- ){
		int l=ci(), r=ci(), d=ci();
		fd(l), fd(r);
		if( fa[l]==fa[r] ){
			if( dis[r]-dis[l]!=d ){
				puts("No");
				return 0;
			}
		}
		else{
			int fl=fa[l], fr=fa[r];
			int x= dis[l]+d-dis[r];
//			printf("%d %d\n",fl,fr);
//			if( x<0 ){
//				puts("No");
//				return 0;
//			}
			dis[fr]= x;
			fa[fr]= fl;
		}
//		printf("fa :");rep(i,1,n) printf("%d ",fa[i]); pt('\n');
//		printf("dis:");rep(i,1,n) printf("%d ",dis[i]); pt('\n');
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
const int N=200050;
char s[N],t[N];
int main()
{
	int n,m,q,x,y;
	scanf("%i %i %i",&n,&m,&q);
	scanf("%i %i",&x,&y);
	int D=n-x+1,U=x,R=m-y+1,L=y;
	scanf("%s",s+1);
	scanf("%s",t+1);
	for(int i=1;i<=q;i++)
	{
		switch(s[i])
		{
			case 'L': L--;break;
			case 'R': R--;break;
			case 'U': U--;break;
			case 'D': D--;break;
		}
		if(min({L,R,D,U})<=0) return 0*printf("NO\n");
		//printf("%i %i %i %i\n",L,R,U,D);
		switch(t[i])
		{
			case 'L': R++;break;
			case 'R': L++;break;
			case 'U': D++;break;
			case 'D': U++;break;
		}
		L=min(L,m);
		R=min(R,m);
		U=min(U,n);
		D=min(D,n);
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数


int main()
{
  int n, k ;
  cin >> n >> k ;
  int cnt = 0 ;
  
  REP(i,n){
    int a ;
    cin >> a ;
    if(a>=k){
      cnt++ ;
    }
  }
  
  cout << cnt <<endl ;
    


  return 0 ;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define lli long long int
#define DBG false
using namespace std;
 
int main(){
    int n;
    lli cr=0, cg=0, cb=0, sum=0;
    cin >> n; 
    string s;
    cin >> s;
 
    for(int i=0; i<n; i++){
        if(s[i] == 'R') cr++;
        else if(s[i] == 'G') cg++;
        else if(s[i] == 'B') cb++;
    }
    sum = cr * cg * cb;
 
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            int k = j + (j - i);
            if(k >= n) break;
            if(s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) sum--;
        }
    }
 
    cout << sum << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define V vector
#define pb push_back
#define mkp make_pair
#define pi pair<int,int>//struct pi {int fi,se;};
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define ln length()
#define sz size()
const int N=100005;
///////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

int32_t main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    //int t;cin>>t;while(t--)
    {
        int i,j,k,n,m,ans=0,cnt=0,sum=0;
        cin>>n;
        if(n >= 30){
            cout << "Yes"<<endl;
        }else{
            cout << "No"<<endl;
        }
    }
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
main(){
    string s1,s2;
    cin>>s1>>s2;
    int cnt=0;
    for(int i=0;i<s1.size();i++){
        if(s1[i]==s2[i]){
            cnt++;
        }
    }
    cout<<cnt<<"\n";


return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N; cin >> N;
  vector<ll> A(N); REP(i, N) cin >> A[i];
  ll a = pow(10, 18);
  ll res = 1;
  sort(all(A));
  REP(i, N) {
    if(A[i] == 0) {
      res = 0;
      break;
    }
    res = res * A[i];
    if(res > a || res <= 0) {
      res = -1;
      break;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
vector<vector<ll>> dp;
ll sol(ll W,vector<ll>& w,vector<ll>& v,ll i){
	if(i<0)
	return 0;
	if(W==0)
	return 0;
	if(dp[W][i]!=-1)
	return dp[W][i];
	else {
		if(w[i]<=W)
		dp[W][i]=max(v[i]+sol(W-w[i],w,v,i-1),sol(W,w,v,i-1));
		else 
		dp[W][i]=sol(W,w,v,i-1);
		return dp[W][i];
	}
}
int main(){
	ll n,W;
	cin>>n>>W;
	dp.resize(W+1,vector<ll>(n+1,-1));
	vector<ll> v(n),w(n);
	for(int i=0;i<n;i++)
	cin>>w[i]>>v[i];
	cout<<sol(W,w,v,n-1);
}

Measured memory_bytes: 85168
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll N, P; cin >> N >> P;
  vector<pair<ll, ll>> res;
  for (ll i = 2; i * i <= P; i++) {
    if (P % i) continue;
    res.emplace_back(i, 0);
    while (P % i == 0) {
      P /= i;
      res.back().second++;
    }
  }
  if (P != 1) res.emplace_back(P, 1);
  ll gcd = 1;
  for(auto p : res) {
  	while (p.second >= N) {
      gcd *= p.first;
      p.second -= N;
    }
  }
  cout << gcd;
}

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

int main(){
    int n;
    std::cin >> n;
    
    std::string ans;
    
    while(n != 0){
        bool even = (n%2 == 0);
        ans.push_back(even ? '0' : '1');
        if(!even && n < 0){
            n = n/(-2) + 1;
        }else{
            n /= -2;
        }
    }
    std::reverse(ans.begin(), ans.end());
    
    std::cout << (ans.empty() ? "0" : ans) << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<map>
using namespace std;
#define REP(i,st,ed) for(int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(int i=st,i##end=ed;i>=i##end;--i)
int read(){
	int x=0,f=1;
	char c=getchar();
	while((c<'0')||(c>'9')){if(c=='-')f=-1;c=getchar();}
	while((c>='0')&&(c<='9'))x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
const int maxn=200005;
int n,m;
int Begin[maxn],Next[maxn<<1],to[maxn<<1],e;
int col[maxn];
void add_edge(int u,int v){
	to[++e]=v,Next[e]=Begin[u],Begin[u]=e;
}
bool flag=0;
void dfs(int u){
	for(int i=Begin[u];i;i=Next[i]){
		int v=to[i];
		if(col[v]==col[u])flag=1;
		else if(!col[v])col[v]=col[u]^3,dfs(v);
	}
}
int main(){
	n=read();
	m=read();
	REP(i,1,m){
		int u,v;
		u=read(),v=read();
		add_edge(u,v),add_edge(v,u);
	}
	col[1]=1;
	dfs(1);
	if(flag){
		printf("%lld\n",1ll*n*(n-1)/2-m);
	}else{
		int c1=0,c2=0;
		REP(i,1,n)
			c1+=(col[i]==1),c2+=(col[i]==2);
		printf("%lld\n",1ll*c1*c2-m);
	}
	return 0;
}

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

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; }

using ll = long long;

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

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

int main() {
  ll A,B,C,K;
  cin>>A>>B>>C>>K;
  ll ans=0LL;
  if(K<=A)ans=K;
  if(A<K&&K<=A+B)ans=A;
  if(A+B<K)ans=A-(K-A-B);
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;

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

int main() {

    int N;
    string S;
    cin >> N >> S;
    rep(i,S.length()){
        S[i] += N;
        if(S[i]>90) S[i] -= 26;
    }
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

vector<int> cal(string str){
	int size = str.size();
	vector<int> ret(26,0);
	for(int i=0;i<size;++i){
		ret[ str[i]-'a' ]++;
	}
	return ret;
}
void solve(){
	int N;
	string str;
	cin>>N>>str;
	int ans = 0;
	for(int i=0;i<N-1;++i){
		string A,B;
		A = str.substr(0,i+1);
		B = str.substr(i+1,N-i-1);
		vector<int> histA,histB;
		histA = cal(A);
		histB = cal(B);
		int res = 0;
		for(int i=0;i<26;++i){
			if(histA[i] && histB[i]){
				++res;
			}
		}
		ans = max(ans,res);
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
n=int(input())

dp=[float('inf')]*(n+1)
dp[0]=0

for i in range(1,n+1):
  
  power=1
  while(power<=i):
    dp[i]=min(dp[i],dp[i-power]+1)
    power*=6
  
  power=1
  while(power<=i):
    dp[i]=min(dp[i],dp[i-power]+1)
    power*=9

print(dp[n])



Measured memory_bytes: 9520
//#include <bits/stdc++.h>                          //include all library
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <string.h>
#include <functional> // greater<int> はfunctionalヘッダ
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)          //REP(i, 10){...} //i=0～i=9までのループ
#define REPR(i, n) for(int i = n;i >= 0;i--)        //REPR(i, 10){...} //i=10～i=0までのループ
#define FOR(i, m, n) for(int i = m;i < n;i++)       //FOR(i, 3, 10){...} //i=3～i=9までのループ
#define FORR(i, m, n) for(int i = m;i >= n;i--)     //FORR(i, 10, 3){...} //i=10～i=3までのループ
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define PI 3.141592653589
#define npos -1


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

	//高速化のために和をあらかじめ計算しておく
	int sum[N+1];
	sum[0]=0;
	for(int i=0; i<N; i++) sum[i+1]=sum[i]+v[i];

	int maxi=0;

	//a,bはそれぞれA,Bの試行回数を表す
	for(int a=0; a<=min(N, K); a++){
		for(int b=0; b<=min(N, K); b++){
			if(a+b > min(N, K)) break;
			int total = sum[a] + (sum[N]-sum[N-b]);

			vector<int> minus(0);
			if(a!=0) for(int k=0; k<a; k++) if(v[k]<0) minus.pb(v[k]);
			if(b!=0) for(int k=0; k<b; k++) if(v[N-1-k]<0) minus.pb(v[N-1-k]);
			sort(minus.begin(), minus.end());

			if(K-a-b!=0 and (int)minus.size()!=0) for(int k=0; k<min(K-a-b, (int)minus.size()); k++) total-=minus[k];

			maxi = max(maxi, total);
		}
	}
	cout << maxi << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653

int main(){
	ll n,k,b; cin >> n >> k;
	vector<ll> conn(n);
	REP(i,n) {
		cin >> b;
		conn[i] = b-1;
	}
	vector<ll> loopcnt(n,-1);
	loopcnt[0]=0;
	ll cnter = 0;
	ll nowat = 0;
	ll loop;
	while (cnter<210000){
		nowat = conn[nowat];
		cnter++;
		if (loopcnt[nowat]!=-1) {
			loop=cnter-loopcnt[nowat];
			break;
		}
		else{
			loopcnt[nowat]=cnter;
		}
	}
	if (k>=cnter) k -= ((k-cnter)/loop+1)*loop;
	REP(i,n) if (k==loopcnt[i]) cout << i+1 << endl;
}

Measured memory_bytes: 6428
import numpy as np
import sys
import math

s=input()
t=[]
for i in range(4):
    t.append(int(s[i]))
temp=0
for i in range(2):
    temp+=(t[0]+t[1] if i==0 else t[0]-t[1])
    for j in range(2):
        temp+=(t[2] if j==0 else -t[2])
        for k in range(2):
            temp+=(t[3] if k==0 else -t[3])
            if temp==7:
                print(s[0]+('+' if i==0 else '-')+s[1]+('+' if j==0 else '-')+s[2]+('+' if k==0 else '-')+s[3]+'=7')
                sys.exit()
            else:
                temp-=(t[3] if k==0 else -t[3])
        temp-=(t[2] if j==0 else -t[2])
    temp=0

Measured memory_bytes: 13356
#include <stdio.h>
int main(void) {
	int h, n;
	scanf("%d%d", &h, &n);
	for (int i = 0; i < n; i++)
	{
		int a;
		scanf("%d", &a);
		h -= a;
	}
	if (h <= 0) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <cstring>
#include <cmath>
#include <string>
#include <numeric>

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  inputInt2(N,M);
  priority_queue<int> pq;
  fN(i,N){int a; cin >> a; pq.push(a);}
  
  //main
  fN(i,M){int m = pq.top(); pq.pop(); pq.push(m/2);}
  
  long ans = 0;
  fN(i,N){ans += pq.top(); pq.pop();}
  
  // output
  output(ans);
  
  return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(void){
	int N,M;cin >> N >> M;
	int A[N];
	double check=0;
	int ans=0;
 
	for(int i=0; i<N; i++){
		cin >> A[i];
		check+=A[i];
	}
	check = check/(4*M);
	sort(A, A+N, greater<int>());
	for(int i=0; i<M;i++){
		if(A[i] >= check)ans++;
		if(ans == M){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

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

int main() {
    int n,d,x;
    cin >> n;
    cin >> d >> x;
    int a[n]={};
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        int s = 1;
        while(s<=d){
            ans++;
            s += a[i];
        }
    }
    ans += x;
    cout << ans << endl;
}



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

signed main(){
  int N;
  cin>>N;
  std::vector<int> a(N),b(N),c(N),bb(N);
  for(int i=0;i<N;i++)cin>>a[i];
  for(int i=0;i<N;i++)cin>>b[i];
  for(int i=0;i<N;i++)cin>>c[i];
  sort(a.rbegin(),a.rend());
  sort(b.rbegin(),b.rend());
  sort(c.rbegin(),c.rend());
  int j=0;
  int l=0;
  int ans=0;
  for(int i=0;i<N;i++){
    for(j;j<N;j++){
      if(b[i]>=c[j]){
        bb[i]=j;
        break;
      }
    }
    if(j==N)bb[i]=N;
  }
  j=0;
  for(int i=0;i<N;i++){
    for(j;j<N;j++){
      if(a[i]<b[j])l+=bb[j];
      else{
        ans+=l;
        break;
      }
    }
    if(j==N)ans+=l;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=998244353;
const int siz=1e5;
const long inf=1e9;
int main(){
	int N,S; cin>>N>>S;
	int a;
	long ans = 0, res;
    long dp[N+1][S+1] = {}; dp[0][0] = 1;
	rep(i,0,N){
		cin>>a;
		rep(j,0,S+1){
            if(j < a) res = 0;
            else if(j == a) res = i + 1;
			else res = dp[i][j-a];
			if(j == S) (ans += res * (N - i)) %= mod;
            dp[i+1][j] = (dp[i][j] + res) % mod;
		}
	}cout<<ans<<endl;
}

Measured memory_bytes: 70656
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public static int N;
	public static Set<Integer> availablenum;
	void run() {
		Scanner sc = new Scanner(System.in);

		N = sc.nextInt();
		int K = sc.nextInt();

		availablenum=new HashSet<Integer>();


		for (int i = 0; i < K; i++) {
			availablenum.add(sc.nextInt());
		}

		while(!isValid(N)) {
			++N;
		}

		System.out.println(N);

	}

	public static boolean isValid(int N) {


		while(N>0) {

			int lastdigit=N%10;

			if(availablenum.contains(lastdigit)) {
				return false;
			}

			N/=10;

		}

		return true;

	}

	//以下テンプレート

	public static int[] extgcd(int a, int b) {

		int x0 = 1;
		int x1 = 0;

		int y0 = 0;
		int y1 = 1;

		while (b != 0) {
			int q = a / b;
			int r = a % b;

			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;

			a = b;
			b = r;

			x0 = x1;
			x1 = x2;

			y0 = y1;
			y1 = y2;
		}

		return new int[] { a, x0, y0 };

	}

	static int gcd(int a, int b) {

		if (b == 0)
			return a;

		if (a < b) {
			int t = a;
			a = b;
			b = t;
		}

		return gcd(b, a % b);

	}

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

	static void swap(int[] a) {
		int t;

		t = a[0];
		a[0] = a[1];
		a[1] = t;

		return;
	}

	static <T> void output(List<T> list) {

		for (int i = 0; i < list.size(); i++) {
			System.out.print(list.get(i));

			if (i != list.size() - 1) {
				System.out.print(" ");
			} else {
				nl();
			}
		}

	}

	static void output(String[][] str) {

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				print(str[i][j]);
			}

			nl();
		}

	}

	static void output(boolean flg, String Yes, String No) {

		if (flg) {
			pln(Yes);
		} else {
			pln(No);
		}

	}

	static void output(String[][] str, int digit) {

		String dig = "%" + String.valueOf(digit) + "s";

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				System.out.printf(dig, str[i][j]);
			}
			nl();
		}

	}

	static void pln(String str) {
		System.out.println(str);
	}

	static void pln(int x) {
		System.out.println(x);
	}

	static void print(String str) {
		System.out.print(str);
	}

	static void print(int x) {
		System.out.print(x);
	}

	static void print(String str, int times) {
		for (int i = 0; i < times; i++) {
			print(str);
		}
	}

	static void print(int x, int times) {
		for (int i = 0; i < times; i++) {
			print(x);
		}
	}

	static void nl() {
		System.out.println();
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

ll fc(ll a, int i){
  a++;
  ll now = 1LL << i;
  ll ac = a /(now*2);
  ll ta = a % (now*2);
  ac *= now;
  // cerr << "t" << a << i << " " << ac << endl;
  if(ta >= now) ac += ta-now;
  return ac;
}

int main(){
  ll a, b;
  cin >> a >> b;
  if(a > 0) a--;
  int sz = 1;
  ll tmp = b;
  while(tmp > 1){
    tmp /= 2;
    sz++;
  }
  ll ans = 0;
  rep(i, sz){
    ll ac = fc(a, i), bc = fc(b, i);
    // cerr << ac << " " << bc << endl;
    ll add = 1LL << i;
    if((bc-ac) % 2 != 0) ans += add;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define all(t) (t).begin(),(t).end()
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	ll ans=1000000000000000;
	ll n,x;
	cin >> n >> x;
	ll a[2010];
	FOR(i,n){
		cin >> a[i];
	}	
	ll v[2010][2010];

	FOR(i,n)v[i][0]=a[i];
	FOR(i,n){
		for(int j=1;j<n;j++){
			v[i][j]=min(v[i][(j-1)%n],a[(i+n-j)%n]);
		}
	}

	FOR(i,n){
		ll sum=0;
		FOR(j,n){
			sum+=v[j][i];
		}
		chmin(ans,sum+i*x);
	}

	cout << ans << endl;
	
	
}

Measured memory_bytes: 31744
N = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in range(len(a)-2):
    c = a[i+1]
    a_sub = a[i:i+3]
#     print(a_sub, c)
#     print(sorted(a_sub))
    if sorted(a_sub)[1] == c:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <stdio.h>
int main(){
  int h, w, n;
  int k = 1;
  scanf("%d%d%d", &h, &w, &n);
  int a[10010];
  int c[110][110];
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);

  for (int i = 0; i <= h; i+=2) {
    for (int j = 0; j < w; j++) {
      c[i][j] = k;
      a[k]--;
      if (a[k] == 0) k++;
    }
    for (int j = w - 1; j >= 0; j--) {
      c[i+1][j] = k;
      a[k]--;
      if (a[k] == 0) k++;
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      printf("%d ", c[i][j]);
    }
    printf("\n");
  }
  return 0;
}

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

int main() {
  int a,b;cin>>a>>b;
  if(a>b) rep(i,a) cout << b;
  if(a<b) rep(i,b) cout << a;
  if(a==b) rep(i,a) cout << a;
}

Measured memory_bytes: 256