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

typedef long long ll;
typedef pair< ll , ll >pll;

int main()
{
    std::ios::sync_with_stdio(false);

    ll n, h;


    cin >> n >> h;

    vector< pll >v(n);

    for (int i = 0; i < n; i++) cin >> v[i].second >> v[i].first;

    sort(v.begin(), v.end());

    ll ans = h;
    ll bsum = 0, amax = 0;

    for (int i = n-1; i >= 0; i--) {
        bsum += v[i].first;
        amax = max(amax, v[i].second);
        ll tmp = n-i;
        if (bsum < h) tmp += (h-bsum+amax-1)/amax;

        ans = min(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4") // wonderful

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


int main()
{
	
	string s; cin >> s;
	int count = 1;
	for (int i = 0; i < s.size(); i++) {

		if (count % 2 == 0) {
			if (s[i] == 'R') {
				cout << "No";
				return 0;
			}
		} else {
			if (s[i] == 'L') {
				cout << "No";
				return 0;
			}
		}
		count++;
	}
	cout << "Yes";
	return 0;

}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
bool chkx(vector<int> a,int x);

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0;i<n;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  int ans = 0;
  for(int i = 0;i<k;i++){
    ans += a.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3640
#include <stdio.h>
#define MAX_2N (2 * 123456)

int isPrime[MAX_2N + 1];

void sieve()
{
  int p, q;
  for (p = 2; p <= MAX_2N; p++) isPrime[p] = 1;
  for (p = 2; p <= MAX_2N; p++) {
    if (isPrime[p]) {
      for (q = p + p; q <= MAX_2N; q += p) {
        isPrime[q] = 0;
      }
    }
  }
}

int chebyshev(int n)
{
  int cnt = 0, p;
  for (p = n + 1; p <= n + n; p++) {
    if (isPrime[p]) cnt++;
  }
  return cnt;
}

int main()
{
  int n;
  sieve();
  for (;;) {
    scanf("%d", &n);
    if (n == 0) break;
    printf("%d\n", chebyshev(n));
  }
  return 0;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-5;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int dp[310][310][310];
int main(){
	string s;cin>>s;
	int K;cin>>K;
	int n=s.length();
	for(int i=0;i<n;i++){
		dp[i][i+1][0]=1;
	}
	for(int l=2;l<=n;l++){
		for(int i=0;i<=n-l;i++){
			int j=i+l;
			for(int k=0;k<=K;k++){
				chmax(dp[i][j][k],dp[i+1][j][k]);
				chmax(dp[i][j][k],dp[i][j-1][k]);
				if(s[i]==s[j-1]){
					chmax(dp[i][j][k],dp[i+1][j-1][k]+2);
				}else{
					if(k)chmax(dp[i][j][k],dp[i+1][j-1][k-1]+2);
				}
			}
		}
	}
	int ans=0;
	for(int k=0;k<=K;k++){
		chmax(ans,dp[0][n][k]);
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 112768
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

char s[4];

int main(void) {
    scanf("%s", s);

    REP(i, 0, 3) {
    	if (s[i] == '1') s[i] = '9';
    	else s[i] = '1';
    }

    printf("%s\n", s);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int N, M, num, time, vol = 0;
    cin >>N;
    int ps[N];
    for(int i = 0; i < N; i++){
        cin >>ps[i];
    }
    cin >>M;
    class drinks{
    public:
        int p,t;
    };
    drinks ds[M];
    for(int i = 0; i < M; i++){
        cin >>num >>time;
        vol = 0;
        for(int j = 0; j < N; j++){
            if(j != num - 1){
                vol += ps[j];
            }else{
                vol += time;
            }
        }
        cout << vol << endl;
    }



}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int i,j,k,s,o=0;
int main()
{
    cin>>k>>s;
    for (i=0;i<=k;i++)
        for (j=0;j<=k;j++)
            if (s-i-j<=k && s-i-j>=0) o++;
    cout<<o<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>

using namespace std;

struct Node{
	int data;
	Node* prev;
	Node* next;
};

class List{
public:
	List(){
		motherNode = new Node();
		motherNode->data = -1;
		motherNode->prev = motherNode;	
		motherNode->next = motherNode;
		num_of_node = 0;
		current = 0;
	};

	void insertFromLast(int x){	
		Node* tmpNode = motherNode->prev;
		if(tmpNode == motherNode){
			motherNode->next = new Node();
			motherNode->next->data = x;
			motherNode->next->next = motherNode;
			motherNode->next->prev = motherNode;
			motherNode->prev = motherNode->next;
			current = motherNode->next;
		}else{	
			while(tmpNode != motherNode && tmpNode->data > x){
				tmpNode = tmpNode->prev;
			}
			Node* nextNode = tmpNode->next;
			tmpNode->next = new Node();
			tmpNode->next->data = x;
			tmpNode->next->next = nextNode;
			tmpNode->next->prev = tmpNode;
			nextNode->prev = tmpNode->next;
		}
		num_of_node++;
	}

	
	int upDist(int a){
		int to_move = a%num_of_node,count = 0,ret;

		if(to_move > num_of_node-(to_move-3)){	
			return downDist(num_of_node-to_move);
		}

		Node* tmp = current;
		while(count < to_move){
			tmp = tmp->next;
			if(tmp != motherNode){
				count++;
			}
		}

		ret = tmp->data;
		if(tmp->next == motherNode){
			current = motherNode->next;
		}else{
			current = tmp->next;
		}

		tmp->prev->next = tmp->next;
		tmp->next->prev = tmp->prev;
		delete tmp;
		num_of_node--;
		return ret;
	}

	
	int downDist(int a){
		int to_move = a%num_of_node,count = 0,ret;

		if(to_move > num_of_node-(to_move-3)){	
			return upDist(num_of_node-to_move);
		}

		Node* tmp = current;
		while(count < to_move){
			tmp = tmp->prev;
			if(tmp != motherNode){
				count++;
			}
		}

		ret = tmp->data;
		if(tmp->next == motherNode){
			current = motherNode->next;
		}else{
			current = tmp->next;
		}

		tmp->prev->next = tmp->next;
		tmp->next->prev = tmp->prev;
		//delete tmp;
		num_of_node--;
		return ret;
	}

	void showList(){
		Node* tmpNode = motherNode->next;
		printf("%d",tmpNode->data);
		tmpNode = tmpNode->next;
		while(tmpNode != motherNode){
			printf(" %d",tmpNode->data);
			tmpNode = tmpNode->next;
		}
		printf("\n");
	}

private:
	Node* motherNode;
	Node* current; 
	int num_of_node;
};

int main(){

	int N,M,Q,a;

	scanf("%d %d %d",&N,&M,&Q);
	int checkTable[N];
	List list;

	for(int i=0; i < N; i++){
		checkTable[i] = 1;
		list.insertFromLast(i);
	}


	for(int i=0; i < M; i++){
		scanf("%d",&a);

		if(a % 2 == 0){ 
			checkTable[list.upDist(a)] = 0;
		}else{
			checkTable[list.downDist(a)] = 0;
		}
	}

	int query;
	for(int i=0; i < Q; i++){
		scanf("%d",&query);

		printf("%d\n",checkTable[query]);
	}

    return 0;
}

Measured memory_bytes: 9724
import math

a,b,h,m = map(int,input().split())
s = (60*h + m)*60
s1 = (60*(h-12) + m)*60
sm = 60*m

if h <= 11:
  thetaa = s*(math.pi/(6*3600))
  thetab = (60*m*math.pi)/1800
  theta = abs(thetaa - thetab)
  print(math.sqrt(a**2 + b**2 -2*a*b*math.cos(theta)))
  
else:
  thetaa = s1*(math.pi/(6*3600))
  thetab = (60*m*math.pi)/1800
  theta = abs(theataa - thetab)
  print(math.sqrt(a**2 + b**2 -2*a*b*math.cos(theta)))

Measured memory_bytes: 9536
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

const long long P = 1000000007;

int main() {
  int n, m;
  cin >> n >> m;
  vector<long long> x(n), y(m);
  for (int i = 0; i < n; i++)
    cin >> x[i];
  for (int i = 0; i < m; i++)
    cin >> y[i];
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  long long dpx[100001] = {0};
  long long dpy[100001] = {0};
  dpx[0] = 0;
  dpy[0] = 0;
  long long sumx = 0;
  long long sumy = 0;
  for (int i = 1; i < n; i++) {
    dpx[i] = (dpx[i - 1] + i * (x[i] - x[i - 1])) % P;
    sumx = (sumx + dpx[i]) % P;
  }
  for (int i = 1; i < m; i++) {
    dpy[i] = (dpy[i - 1] + i * (y[i] - y[i - 1])) % P;
    sumy = (sumy + dpy[i]) % P;
  }
  cout << (sumx * sumy) % P << endl;
  return 0;
}


Measured memory_bytes: 3328
from collections import deque
N = int(input())
E = {}
for i in range(N):
  E[i] = []
  
for i in range(N-1):
  a,b = list(map(int, input().split()))
  a,b = a-1, b-1
  E[a].append(b)
  E[b].append(a)

# DFS for tree

def dfs(startp, depth):
  visited = [False for i in range(N)]
  d = deque()
  d.append(startp)

  while len(d) > 0:
    p = d.pop()
    visited[p] = True
    for q in E[p]:
      if visited[q]:
        continue
      d.append(q)
      depth[q] = depth[p] + 1

distf = [0 for i in range(N)]
dists = [0 for i in range(N)]

dfs(0, distf)
dfs(N-1, dists)

#print(distf)
#print(dists)
cntf, cnts = 0,0
for i in range(N):
  if distf[i] <= dists[i]:
    cntf += 1
  else:
    cnts += 1
    
print("Fennec" if cntf > cnts else "Snuke")

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

total = sum(A)
def is_4M(x):
    a = total / (4*M)
    if x < a:
        return False
    return True

cnt = 0
for a in A:
    if is_4M(a):
        cnt += 1

if cnt >= M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		long sum=0;
		int i=0;
		long count =0;
		long beforeCount =0;
		while (i<S.length()) {
			count =0;
			if (S.charAt(i)=='<') {
				while(i<S.length()&&S.charAt(i)=='<') {
					i++;
					count++;
				}
				sum +=count*(count+1)/2;
				beforeCount = count;
			} else if (S.charAt(i)=='>') {
				while(i<S.length()&&S.charAt(i)=='>') {
					i++;
					count++;
				}
				if (beforeCount<count) {
					sum +=count*(count+1)/2-beforeCount;
				} else {
					sum +=count*(count-1)/2;
				}
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 28784
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

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

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

    ll ans = 0;
    for (ll i = 1; i <= N; i++)
    {
        bool odd_digit = (1 <= i && i <= 9) || (100 <= i && i<= 999) || (10000 <= i && i <= 99999);
        if (odd_digit) {
            ans += 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
a, b, c, x, y = list(map(int, input().split(" ")))

res = 10**10
for i in range(0, max(x, y)*2+2, 2):
    a_piza = max(0, x - (i // 2))
    b_piza = max(0, y - (i // 2))
    res = min(res, a_piza*a + b_piza*b + i*c)

print(res)


Measured memory_bytes: 9152
#include <iostream>
#include <queue>
#include <vector>
#include <stack>
#include <list>
#include <queue>
#include <algorithm>
#include <set>
#include <cmath>

#define ll long long

using namespace std;
ll factorial(int n)
{
    ll sum=1;
  for(int i=n;i>0;i--)
    sum*=i;
    return sum;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    cout<<pow(n,3)<<'\n';
}










Measured memory_bytes: 4316
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    w, a, b = MI()
    if b < a:
        temp = a
        a = b
        b = temp
    ans = max(0, b-a-w)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9136
import sys
input = sys.stdin.readline

def main():
    S = input().strip()


    ans = []
    for s in S:
        if s == 'B':
            if len(ans) > 0:
                ans.pop()
        else:
            ans.append(s)

    print("".join(ans))




if __name__ == '__main__':
    main()




Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
//型名省略
typedef long long ll;
typedef vector<long long> vl;
typedef vector<vector<long long>> vvl;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rep2(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define all(A) A.begin(), A.end()
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}


//main関数
int main() {
    ll k,a,b; cin >> k >> a >> b;

    rep2(i,a,b+1){
        if(i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 1000006;
const ll MOD = 1000000007;

int n, a;
int c1, c2, c4;
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n;
    REP (i, n) {
        cin >> a;
        if (a % 4 == 0) {
            c4++;
        } else if (a % 2 == 0) {
            c2++;
        } else {
            c1++;
        }
    }

    if (c1 <= c4) {
        cout << "Yes" << endl;
    } else if (c2 == 0 && c1 <= c4 + 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	unsigned long long int N, M;
	unsigned long long int answer = 0;
	scanf("%llu %llu", &N, &M);
	if(N * 2 <= M){
		answer = N + (M - N * 2) / 4;
	}else{
		answer = M / 2;
	}
	printf("%llu", answer);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  rep(i,365)
    cout<<1<<endl;
}

Measured memory_bytes: 3592
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int BA = 0;
    int XA = 0;
    int BX = 0;
    int ans = 0;
    for (int i = 0; i < N; i++) {
      String s = sc.next();
      char first = s.charAt(0);
      char last = s.charAt(s.length()-1);
      if (first == 'B' && last == 'A') {
        BA++;
      } else if (last == 'A') {
        XA++;
      } else if (first == 'B') {
        BX++;
      }
      for (int j = 0; j < s.length()-1; j++) {
        if (s.charAt(j) == 'A' && s.charAt(j+1) == 'B') {
          ans++;
        }
      }
    }
    //System.err.println(""+ans+" BA " +BA+ " XA " + XA+" BX " +BX);

    if (BA > 0) {
      ans += BA-1;
      if (BX > 0) {
        ans++;
        BX--;
      }
      if (XA > 0) {
        ans++;
        XA--;
      }
    }
    ans += Math.min(XA, BX);
    System.out.println(ans);
  }
}

Measured memory_bytes: 29952
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, n,m) for (int i = (int)(n); i < (int)(m); i++)

#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

typedef long long ll;

vector<string> split(string,string);

//template<typename T>
//void swap(T*,T*);
//char ToUpper (char cX) { return toupper(cX); }

bool isR(string s);

int main()
{
    string s;
    cin >>s;
    int N = s.size();
    rep(i,N)
    {
        cout << "x";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#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=1e9+7;
const int size=1e5+1;
const long inf=1e14;
int main(){
	int N; cin>>N;
	int A[N]; map<int,int> mp;
	rep(i,0,N){ cin>>A[i]; mp[A[i]] = i + 1; }
	int k = 0; int cnt = 0;
	for(pair<int,int> p:mp){ k++; cnt += (p.second % 2 != k % 2); }
	cout<<cnt / 2<<endl;
}

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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


/*
--------------------------------------------

	type

--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;

/*
--------------------------------------------

	container

--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())

/*
--------------------------------------------

	repetition

--------------------------------------------
*/
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

/*
--------------------------------------------

	constant

--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))



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

	cout << (6 - A - B) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> namespace mp = boost::multiprecision; //mp::cpp_intで宣言
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////

int a[3]={3,5,7};
bool check(ll n){
    bool c[3];memset(c,false,sizeof(c));
    while(n>0){
        ll m=n%10;
        rep(i,0,2)if(a[i]==m)c[i]=true;
        n/=10;
    }
    bool res=true;
    rep(i,0,2)if(c[i]==false)res=false;
    return res;
}

vector<ll>v;
void calc(ll val,int n){
    if(n==-1){
        if(check(val))v.pb(val);
        return;
    }
    rep(i,0,2){
        calc(val+(ll)pow(10,n)*a[i],n-1);
    }
}

int main(){
    ll n;cin>>n;
    rep(i,0,8){
        calc(0,i);
    }
    sort(v.begin(),v.end());
    ll ans=upper_bound(v.begin(),v.end(),n)-v.begin();
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int count = 0;
		for (; a <= b; a++) {
			StringBuilder sb = new StringBuilder(String.valueOf(a));
			if (sb.toString().equals(sb.reverse().toString())) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 37972
import itertools

n, m, q = map(int, input().split())
s = [list(int(i) for i in input().split()) for j in range(q)]
ans = []

for v in itertools.combinations_with_replacement(range(1, m+1), n):
  tmp = 0
  for i in range(q):
    if v[s[i][1]-1] - v[s[i][0]-1] == s[i][2]:
      tmp += s[i][3]
  ans.append(tmp)
  
print(max(ans))

Measured memory_bytes: 12628
// AOJ 1282: Bug Hunt
// 2017.10.22 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <ctype.h>

#define HASHSIZ 2003
typedef struct { char x; int id, v; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash + HASHSIZ;

int lookup(char x, int id)
{
	long long t;
	HASH *hp;
	
	t = x; t = ((t << 32LL) + id) % HASHSIZ;
	hp = hash + (int)t;
	while (hp->x) {
		if (hp->x == x && hp->id == id) return hp->v;
		if (++hp == hashend) hp = hash;
	}
	return -1;
}

void insert(char x, int id, int v)
{
	long long t;
	HASH *hp;
	
	t = x; t = ((t << 32LL) + id) % HASHSIZ;
	hp = hash + (int)t;
	while (hp->x) {
		if (hp->x == x && hp->id == id) { hp->v = v; break; }
		if (++hp == hashend) hp = hash;
	}
	hp->x = x, hp->id = id, hp->v = v;
}

int range['z'+1];
char buf[130], *p;

char *parse(int *val, char *p)
{
	char x;
	int v, w;

	if (isdigit(*p)) {
		v = 0; while (isdigit(*p)) v = 10*v + (*p++ - '0');
		*val = v;
		return p;
	}
	x = *p, p += 2;   // [
	if ((p = parse(&v, p)) == NULL) return NULL;
	if (range[x] < 0) { range[x] = v; return p; }
	
	if (v >= range[x]) return NULL;
	p++;			  // ]
	if (*p == ']' || *p < ' ') {
		if ((*val = lookup(x, v)) < 0) return NULL;
		return p;
	}
	p++;			  // =
	if ((p = parse(&w, p)) == NULL) return NULL;
	insert(x, v, w);
	return p;
}

int main() 
{
	int i, err, v;

	while (1) {
		memset(hash, 0, sizeof(hash)), memset(range, -1, sizeof(range));
		for (err = 0, i = 1; fgets(p=buf, 128, stdin) && *p != '.'; i++) {
			if (!err && parse(&v, p) == NULL) err = i;
		}
		if (i == 1) break;
		printf("%d\n", err);
	}
	return 0; 
}

Measured memory_bytes: 1724
l_num = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(l_num[K-1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int a,b,c;

int main()
{
    scanf("%d%d%d",&a,&b,&c);
    for(int i=1;i<=b;i++)
      if(a*i%b==c)  {printf("YES\n");return 0;}
    printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int N;
string S;

int main() {
  cin >> N >> S;
  vector<int> count_W(N + 10), count_E(N + 10);
  rep(i, N) {
    if (S[i] == 'W') count_W[i]++;
    if (S[i] == 'E') count_E[i]++;
  }
  rep(i, N) {
    if (i == 0) continue;
    count_W[i] += count_W[i - 1];
  }
  repR(i, N) {
    if (i == N - 1) continue;
    count_E[i] += count_E[i + 1];
  }
  int ans = N;
  rep(i, N) {
    int ans1;
    if (i == 0) {
      ans1 = count_E[1];
    } else if (i == N - 1) {
      ans1 = count_W[N - 2];
    } else {
      ans1 = count_W[i - 1] + count_E[i + 1];
    }
    ans = min(ans, ans1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3076
// https://atcoder.jp/contests/abc157/tasks/abc157_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    map<int, int> mp;
    bool flag = true;
    REP(i, M) {
        int s, c;
        cin >> s >> c;
        s--;
        if (mp.count(s) > 0 && mp[s] != c) {
            flag = false;
        }
        mp[s] = c;
        if (N >= 2 && s == 0 && c == 0) {
            flag = false;
        }
    }
    if (!flag) {
        cout << "-1\n";
    } else {
        int minv = pow(10, N - 1);
        if (N == 1) {
            minv = 0;
        }
        int maxv = pow(10, N);
        FOR(i, minv, maxv) {
            flag = true;
            string s = to_string(i);
            for (auto &x : mp) {
                if (s[x.first] != '0' + x.second) {
                    flag = false;
                }
            }
            if (flag) {
                cout << s << endl;
                break;
            }
        }
    }

    return 0;
}


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

int main(){
	int n,f=0,num=0;
	string s;
	cin>>n>>s;
	lp2(i,n){
		if(f==1){
			if(s[i]=='x')break;
			else {
				f=0;
				num++;
			}
		}
		else if(s[i]=='x'){
			f=1;
			num++;
		}
		else {
			f=0;
			num++;
		}
		//cout<<num<<endl;
	}
	cout<<num<<endl;
	return 0;
}



Measured memory_bytes: 3364
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define F first
#define S second
using namespace std;


signed main(){
    int mod = 1e9 + 7;
    int h, w;
    cin >> h >> w;
    vector <string> s(h,"");
    for(int i = 0; i  < h ;i++){
            cin >> s[i];
    }
    int dp[h][w];
    for (int k = 0; k < h; ++k) {
        for (int i = 0; i < w; ++i) {
            dp[k][i] = s[k].at(i) == '.' ? 0 : - 1;
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(dp[i][j] == -1){
                dp[i][j] = 0;
            } else if(i == 0 && j == 0){
                dp[i][j] = 1;
            } else if(i == 0){
                dp[i][j] = dp[i][j-1];
            } else if(j == 0){
                dp[i][j] = dp[i - 1][j];
            } else {
                dp[i][j] = (dp[i][j - 1] + dp[i -1][j]) % mod;
            }
        }
    }
    
    cout<<dp[--h][--w]<<endl;
    
    
    
    
}



Measured memory_bytes: 9088
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int window = sc.nextInt();
        int curtain = sc.nextInt();
        int ans = window - curtain * 2;
        System.out.println(ans > 0 ? ans : 0);
    }
}

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

void rect(int n,int m){
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < m ; j++){
            cout << '#';
        }
        puts("");
    }
    
    
}

int main(){
    int n,m;
    
    while(true){
        cin >> n >> m;
        if(!n&&!m) break;
        rect(n,m);
        puts("");
    }
    
    
    return 0;
}

Measured memory_bytes: 1120
N = int(input())
L = list(map(int,input().split()))
L.append(0)
s = 0
ans = 0
if L == [0]*(N+1):
  print(0)
while s <= N-1:
  if L[s] == 0:
    s += 1
    continue
  for i in range(s,N+1):
    if L[i] > 0:
      L[i] -= 1
    else:
      ans += 1
      break
  if L == [0]*(N+1):
    print(ans)
    exit()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	string a, b; cin >> a >> b;
	ll c = stol(a + b);
	ll d = sqrt(c);
	cout << ((c == d * d) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	class C implements Comparable<C>{
		String s;
		int freq;
		
		public C(String s, int freq) {
			this.s = s;
			this.freq = freq;
		}

		@Override
		public int compareTo(C o) {
			if(this.freq < o.freq) return 1;
			else if(this.freq > o.freq) return -1;
			return this.s.compareTo(o.s);
		}
		
	}

	private void doit() {
		while (true) {
			int n = Integer.parseInt(sc.nextLine());
			if(n == 0)break;
			String [][] data = new String [n][];
			for(int i = 0; i < n; i++){
				data[i] = sc.nextLine().split(" ");
			}
			char c = sc.nextLine().charAt(0);
			HashMap<String, Integer> map = new HashMap<String, Integer>();
			for(int i = 0; i < n; i++){
				for(int j = 0; j < data[i].length; j++){
					if(c == data[i][j].charAt(0)){
						if(map.containsKey(data[i][j])){
							map.put(data[i][j], map.get(data[i][j]) + 1);
						}
						else{
							map.put(data[i][j], 1);
						}
					}
				}
			}
			ArrayList<C> list = new ArrayList<Main.C>();
			for(String str: map.keySet()){
				list.add(new C(str, map.get(str)));
			}
			Collections.sort(list);
			if(list.size() == 0){
				System.out.println("NA");
				continue;
			}
			StringBuilder sb = new StringBuilder();
			for(int i = 0; i < Math.min(5, list.size()); i++){
				sb.append(" " + list.get(i).s);
			}
			System.out.println(sb.substring(1));
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

Measured memory_bytes: 35048
url = "https://atcoder.jp//contests/abc047/tasks/abc047_b"

def main():
    w, h, n = list(map(int, input().split()))
    xya = [list(map(int, input().split())) for _ in range(n)]
    x, y = [0, w], [0, h]
    for low in xya:
        if low[2] == 1 and x[0] < low[0]:
            x[0] = low[0]
        elif low[2] == 2 and x[1] > low[0]:
            x[1] = low[0]
        elif low[2] == 3 and y[0] < low[1]:
            y[0] = low[1]
        elif low[2] == 4 and y[1] > low[1]:
            y[1] = low[1]
    xs = x[1] - x[0]
    ys = y[1] - y[0]
    if xs < 0 or ys < 0:
        print(0)
    else:
        ans = xs * ys
        print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 9124
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll mod = 1e9 + 7;

ll f[2500001];
ll finv[2500001];

void init() {
  f[0] = f[1] = 1;
  for(int i = 2;i < 2500001; ++i) {
    f[i] = (f[i-1] * i) % mod;
  }
  ll finv_max = 1;
  ll a = mod - 2;
  ll x = f[2500000];
  while(a > 0){
    if(a & 1) {
      finv_max = (finv_max * x) % mod;
    }
    x = (x * x) % mod;
    a >>= 1;
  }
  finv[2500000] = finv_max;
  for(int i = 2500000;i > 0;--i){
    finv[i-1] = (finv[i] * i) % mod;
  }
}

ll conv(int n, int k){
  ll res = 1LL;
  res = (res * f[n]) % mod;
  res = (res * finv[n-k]) % mod;
  res = (res * finv[k]) % mod;
  return res;
}

ll calc(int r, int c){
  ll res = 0LL;
  for(int i = 0;i <= c;++i){
    res = (res + conv(r+i+1, r)) % mod;
  }
  return res;
}


int main(void){
  init();
  int r1,c1,r2,c2;
  cin >> r1 >> c1 >> r2 >> c2;
  ll res = 0;
  res = (res + calc(r2,c2)) % mod;
  res = (res - calc(r2, c1-1) + mod) % mod;
  res = (res - calc(r1-1, c2) + mod) % mod;
  res = (res + calc(r1-1, c1-1)) % mod;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 39296
#include <stdio.h>
int main(void){
	int tim[5],mod[5];
	int m=0,sum=0,i;
	
	for(i=0;i<5;i++){
		scanf("%d",&tim[i]);
		mod[i] = tim[i] % 10;
		if(mod[i] == 0) continue;
		if(mod[i] < mod[m]) m = i;
	}
	for(i=0;i<5;i++){
		if(mod[i]==0 || i == m) sum = sum + tim[i];
		else sum = sum + tim[i]/10 * 10 + 10;
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

const int MAX = 100000;

typedef struct people {
	vector<pair<int, int> > distance; // 対象とその距離
	bool isCheck; // もうこの人の整合性を調べたか否か
	int point; // 座標
} People;

int main() {
	int N, M, L, R, D;
	cin >> N >> M;
	static People p[MAX]; // p[i]はi番目の人
	for (int i = 0;i < N;i ++) {
		p[i].isCheck = false;
		p[i].point = 0;
	}
	for (int i = 0;i < M;i ++) {
		cin >> L >> R >> D;
		p[L - 1].distance.push_back(make_pair(R - 1, D));
		p[R - 1].distance.push_back(make_pair(L - 1, -D));
	}
	// ここまでで、p[i]には自分より左右の人の距離が定義されている
	queue<pair<int, int> > que; // queにはこれから調べる人と期待される座標を入れる
	pair<int, int> tmp; // 今調べている人
	for (int i = 0;i < N;i ++) {
		if (!p[i].isCheck) { // まだ調べていないなら
			p[i].isCheck = true;
			p[i].point = 0;
			for (int j = 0;j < p[i].distance.size();j ++) {
				que.push(p[i].distance[j]);
			}
		}
		while (!que.empty()) { // 調べる座標があるなら
			tmp = que.front();
			que.pop();
			if (p[tmp.first].isCheck) { // 既に調べているなら、矛盾確認を
				if (p[tmp.first].point != tmp.second) { // 矛盾
					cout << "No";
					return 0;
				}
			} else { // まだ調べていないなら
				p[tmp.first].isCheck = true; // 調べ終わった
				p[tmp.first].point = tmp.second;
				for (int j = 0;j < p[tmp.first].distance.size();j ++) {
					que.push(make_pair(p[tmp.first].distance[j].first, p[tmp.first].distance[j].second + tmp.second)); // 次の調べる座標を
				}
			}
		}
	}
	cout << "Yes"; // 最後まで矛盾が出てこなかった
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

サンプルを見ると分かるが、解が存在する時、全ての人の座標を増減させてもそれもまた解になる
また、ND<=xより、0<=x<=10^9に全ての人を存在させることは解があるなら必ず可能
そこで、まず一人について座標を定義してしまう
この時、他の人が矛盾してないか式を元に考える
全ての人を見ていくだけなのでO(N+M)でできる、のかな
*/

Measured memory_bytes: 11636
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
	if(number1 > number2){
		swap(number1,number2);
	}
	if(number1 == 0 || number1 == number2){
		return number2;
	}else{
		return gcd(number2 % number1,number1);
	}
}

ll i,j,k,ii,jj,r,l;
ll n,m,num,sum,ans;
ll a,b,c,d,e,g,h,w;
ll x[500005],y[500005],z[500005];
bool ng[500005];
char s[500005];

int main(){
	cin >> n>> k;
	for(i=1;i<=n;i++){
		cin >> x[i];
	}
	for(i=1;i<=n;i++){
		x[i] += x[i-1];
	}
	for(i=1;i<=n;i++){
		for(j=0;j<i;j++){
			z[num] = x[i] - x[j];
			num++;
		}
	}
	bool check = false;
	for(i=42;i>=0;i--){
		c = 0;
		for(j=0;j<num;j++){			
			if(!ng[j] && ((1ll << i) & z[j]))c++;
		}
		if(c >= k){
			check = true;
			for(j=0;j<num;j++){
				if(!((1ll << i) & z[j]))ng[j] = true;
			}
			ans += (1ll << i);
		}else{
			continue;
		}
	}
	p(ans);


	return 0;

}

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

int main(){

	int i = 1;
	int a,b;

	for(;;){
		cin >> a >> b;
		if(a == 0 && b == 0)break;

		if(a < b) cout << a << " " << b << endl;
		else cout << b << " " << a << endl;

		i++;
	}

	return 0;
}


Measured memory_bytes: 3084
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int H = scan.nextInt();
        int A = scan.nextInt();
        int ans = (int)Math.ceil((double)H/A);
        os.println(ans);
    }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_mutiset tree<int,null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(int i=vv;i<n;i++)
#define FORR(i,n,vv) for(int i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define INF 1000000000000000000ll
#define PRECISE cout.precision(18);
#define all(v) v.begin(),v.end()
#define BS(v,n) binary_search(all(v),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(all(v),greater <ll>())
#define uni(v) v.resize(unique(all(v)-v.begin())
#define F first
#define S second
#define GET(i,p) get<p>(i)


int main(){

    FAST
//	PRECISE


ll n;
cin>>n;
ve <ll> v(1000000+1,-1);
FOR(i,0,n){
	ll x;
	cin>>x;
	v[x]++;
}
ll ans=0;


FOR(i,1,1000000+1){
	if(v[i]!=-1){
		if(v[i]==0)
		ans++;
		for(ll j=i;j<=1000000;j+=i){
			v[j]=-1;
		}
	}
}
cout<<ans;

return 0;
 }



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

int main() {
  int N;
  int K;
  int N_buff=1;
  cin>>N>>K;
  for(int i=0;i<N;i++){
  if(N_buff<K){
    N_buff*=2;
  }else{
  N_buff+=K;
  }
  }
  cout<< N_buff<<endl;
  // ここにプログラムを追記
  
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>
#include<queue>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
    int to;
    T cost;
    Edge() {};
    Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
    int n;
    bool directed;
    vector<vector<Edge<T>>> edges;
public:

    Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)){};
    Graph() {};

    void add(int to, T cost) {
        emplace_back(to, cost);
    }

    int size() {
        return n;
    }
};


int main() {

    int H,N;

    cin >> H >> N;

    vi A(N);

    long long sum = 0;

    REP(i,N){
        cin >> A[i];
        sum += A[i];
    }

    cout << ((H<=sum)?"Yes":"No") << endl;



    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;

bool check(ll t, ll k, vector<ll>&a, vector<ll>&f, vector<ll>&pr) {
  //cout << t << endl;
  for (int i = 0; i < 1000001; i++) pr[i] = 0;
  for (int i = 0; i < f.size(); i++) {
    ll index = min(t/f[i], 1000000LL);
    pr[index]++;
  }
  for (int i = 1; i < 1000001; i++) pr[i] += pr[i-1];
  ll cnt = 0;
  for (int i = 0; i < 1000001; i++) cnt += max(0LL, pr[i] - a[i]);
  //cout << "fin" << endl;
  if (cnt <= k) return true;
  else return false;
}

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

  ll n, k;
  cin >> n >> k;
  vector<ll> a(1000001), f(n);
  for (int i = 0; i < n; i++) {
    ll p;
    cin >> p;
    a[p]++;
  }
  for (int i = 0; i < n; i++) {
    cin >> f[i];
  }
  for (int i = 1; i < 1000001; i++) a[i] += a[i-1];

  vector<ll>pr(1000001);

  ll ok = 1000000000000000001LL, ng = -1, mid;
  while (abs(ok - ng) > 1) {
    mid = (ok + ng) / 2;
    if (check(mid, k, a, f, pr)) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
}


Measured memory_bytes: 17408
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int main(void) {
	int num, i;
	ll m, a, ans = 0;
	cin >> num >> m;
	vector<ll> d(num + 1, 0);
	for (i = 0; i < num; i++) {
		cin >> a;
		d[i + 1] = (a + d[i]) % m;
	}
	sort(d.begin(), d.end());
	for (a = 0, i = 0; i < num; i++) {
		if (d[i] == d[i + 1])
			a++;
		else
			a = 0;
		ans += a;
	}
	cout << ans << "\n";
	return 0;
}

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

int main(){
    int n;
    while(cin>>n){
        int ans=0;
        for(int a=0;a<10;a++){
            for(int b=0;b<10;b++){
                for(int c=0;c<10;c++){
                    for(int d=0;d<10;d++){
                        if(a+b+c+d==n)ans++;
                    }
                }
            }
        }
         
        cout<<ans<<endl;
    }
    return 0;
}

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

typedef vector< ll > 	vi;
typedef vector< vi > 	vvi;
typedef pair< ll,ll > 	ii;

#define pb 		push_back
#define all(c) 		(c).begin(),(c).end()
#define present(c,x) 	((c).find(x) != (c).end())
#define rep(i,n)        for(ll i=0LL; i<(n); i++)

#define MOD 	1000000007
#define INF 	(int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))

//Maths functions
ll Digit(ll N){ll res=0;while(N) res++, N/=10;return res;}
ll Gcd(ll a,ll b){ return b?Gcd(b,a%b):abs(a); }


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

	ll n;
	cin>>n;
	cout<<ceil((double)n/(double)2);
	
	return 0;
}

Measured memory_bytes: 256
// -*- coding: utf-8 -*-
// @Date    : 2019-11-09 18:32:56

#include <bits/stdc++.h>
#define greeting cerr << "What's your problem?\n"

using namespace std;
typedef long long ll;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& v)
{
	for(auto i : v)
		os << i << " ";
	return os;
}

template<typename T>
ostream& operator << (ostream& os, const set<T>& v)
{
	for(auto i : v)
		os << i << " ";
	return os;
}

#define locala
int main()
{
#ifdef local
	freopen("data.in", "r", stdin);
	freopen("ans.out", "w", stdout);
#endif	
	int x, y;
	scanf("%d%d", &x, &y);
	if(x > 9 || y > 9)
		return 0*printf("-1\n");
	printf("%d\n", x*y);
	return 0;
}

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

#define int long long

#define For(i,a,b) for (int i = a; i <= (b); ++i)
#define For2(i,a,b) for (int i = a; i >= (b); --i)

#define test int _t; cin >> _t; while (_t--)

#define pii pair<int, int>
#define mpii map<int, int>
#define all(a) a.begin(), a.end()
#define pb push_back
#define fi first
#define se second
#define mp make_pair

#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define INF 2147483647
#define EPS 1e-9

#define DEBUG

//#define FILEOPEN

using namespace std;

#ifdef DEBUG

    #define debug(args...)     (Debugger()) , args

    class Debugger {
        public:
        Debugger(const std::string& _separator = " | ") :
        first(true), separator(_separator){}

        template<typename T> Debugger& operator , (const T& v) {
            if(!first) cerr << separator;
            cerr << v;
            first = false;
            return *this;
        }
        ~Debugger() { cerr << endl; }
        
        private:
        bool first;
        string separator;
    };

#else
    #define debug(args...)                
#endif

int a[2005];
bitset<5000005> b;
int s[5000005], len;

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	#ifdef FILEOPEN
		freopen("input.in", "r", stdin);
		freopen("input.out", "w", stdout);
	#endif
	int n;
	cin >> n;
	For(i,1,n) cin >> a[i];
	b[0] = 1;
	For(i,1,n) b = b | (b << a[i]);
	len = 0;
	For(i,1,5000000) if (b[i]) s[++len] = i;
	cout << s[(len + 1) >> 1];
}

Measured memory_bytes: 21036
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
local function tostringxx(o, depth) depth = depth or 0 if depth > 10 then return "<too deep!>" end if o == _G then return "<_G>" end local indent0 = (" "):rep((depth) * 2) local indent1 = (" "):rep((depth+1) * 2) local indent2= (" "):rep((depth+2) * 2) if type(o) == 'table' then local keys = {} local types = {} for k in pairs(o) do types[type(k)] = true table.insert(keys, k) end local types_count = 0 local lasttype for k in pairs(types) do types_count = types_count + 1 lasttype = k end if types_count == 1 and (lasttype == 'string' or lasttype == 'number') then table.sort(keys) end local inside = {} for i=1,#keys do local k = keys[i] local v = o[k] if type(k) == 'string' then k = string.format('%q', k) end table.insert(inside, indent1 .. '['..tostring(k)..'] = ' .. tostringxx(v, depth + 1)) end return '{\n' .. table.concat(inside, ',\n') .. '\n' .. indent0 .. '}' else if type(o) == 'string' then o = string.format('%q', o) end return tostring(o) end end
local function richtraceback() local x = 2 while true do local info = debug.getinfo(x) if not info then break end local fname = '<' .. info.short_src .. ":" .. info.linedefined .. ">" if info.name then fname = info.name end print(info.short_src .. ":" .. info.currentline .. ": in " .. ("%q"):format(fname)) print(" LOCALS:") local p = 1 while true do local name, val = debug.getlocal(x,p) if not name then break end print(" " .. name .. ": " .. tostringxx(val, 3)) p = p + 1 end print(" UPVALUES:") for p=1,info.nups do local name, val = debug.getupvalue(info.func,p) if not name then break end print(" " .. name .. ": " .. tostringxx(val, 3)) end x = x + 1 end end
local function myassert(b) if not b then richtraceback() error("assertion failed") end end 
----
local S = read.l():gsub("%s", ""):reverse():totable()
local N = #S
local X = {}
local ten = 1
for i=1,N do
    X[i] = ten * tonumber(S[i]) % 2019
    ten = ten * 10 % 2019
end
local A = {}
A[0] = 0
for i=1,N do
    A[i] = math.floor((A[i-1] + X[i]) % 2019)
end
--print(tostringxx(A))
local set = {}
for i=0,N do
    --print(i, A[i])
    set[A[i]] = (set[A[i]] or 0) + 1
end
--print(tostringxx(set))
local ans = 0
for k,v in pairs(set) do
    ans = ans + v * (v - 1) // 2
end
print(ans)

Measured memory_bytes: 15368
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpll vector<pll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(x) x.begin(),x.end()
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	map<string,ll> m;
	m["MON"]=1;
	m["TUE"]=2;
	m["WED"]=3;
	m["THU"]=4;
	m["FRI"]=5;
	m["SAT"]=6;
	m["SUN"]=7;
	string s;
	cin>>s;
	ll res=m["SUN"]-m[s];
	if(!res){
		res+=7;
	}
	cout<<res;
}

Measured memory_bytes: 256