akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int N;

bool query(vector<bool> which) {
    cout << '?';

    for (int i = 1; i <= 2 * N; i++)
        if (which[i])
            cout << ' ' << i;

    cout << endl;
    string T;
    cin >> T;
    return T[0] == 'R';
}

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

    cin >> N;
    vector<bool> which(2 * N + 1, false);

    for (int i = 1; i <= N; i++)
        which[i] = true;

    bool initial = query(which);
    int low = 2, high = N + 1;

    while (low < high) {
        int mid = (low + high) / 2;

        which.assign(2 * N + 1, false);

        for (int i = mid; i < mid + N; i++)
            which[i] = true;

        bool result = query(which);

        if (result == initial)
            low = mid + 1;
        else
            high = mid;
    }

    int start = low, end = low + N - 1;
    which.assign(2 * N + 1, false);

    for (int i = start; i < end; i++)
        which[i] = true;

    vector<bool> answer(2 * N + 1, false);

    for (int i = 1; i <= 2 * N; i++)
        if (start <= i && i < end) {
            which[i] = false;
            which[start - 1] = which[end] = true;
            answer[i] = !query(which);
            which[start - 1] = which[end] = false;
            which[i] = true;
        } else {
            which[i] = true;
            answer[i] = query(which);
            which[i] = false;
        }

    cout << "! ";

    for (int i = 1; i <= 2 * N; i++)
        cout << (answer[i] ? 'R' : 'B');

    cout << endl;
}


Measured memory_bytes: 724
n = int(input())
ar = list(map(int,input().split()))
ans = 1
z = 0
p = 0
for i in ar:
    if ans != -1:
        ans *= i
    if i == 0:
        z+=1
    if ans > 1e18:
        ans = -1
if z:
    ans = 0
print(ans)

Measured memory_bytes: 21536
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long N = sc.nextLong();
		long A = sc.nextLong();
		long B = sc.nextLong();
		long cc = 0;
		if( N%(A+B)<=A ){
			cc = N%(A+B);
		}else{
			cc = A;
		}
		System.out.println(N/(A+B)*A+cc);
	}
}


Measured memory_bytes: 21844
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		try (Scanner s = new Scanner(System.in)) {
			int n = s.nextInt();
			int sum = 0;
			for (int i = 1; i <= n; i++) {
				sum += i;
			}
			System.out.println(sum);
		}
	}
}


Measured memory_bytes: 21844
def func1(lst, value):
    return [i for i, x in enumerate(lst) if x == value]

X,Y = [],[]
ans = 0

N = int(input())
for i in range(N):
    x,y = input().split(' ')
    X.append(float(x))
    Y.append(y)

btc = func1(Y,"BTC")
jpy = func1(Y,"JPY")

for i in btc:

    ans = ans + (X[i] * 380000.0)

for i in jpy:
    ans = ans + X[i]

print(ans)



Measured memory_bytes: 3064
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

nn = inputs[0][0]
aa = inputs[0][1]
bb = inputs[0][2]

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
end

if nn*aa > bb
  puts bb
else
  puts nn*aa
end


Measured memory_bytes: 1916
import math
A,B,H,M=map(int,input().split())
H=5*H+5*M/60
theta=6*abs(H-M) 
if theta>180:
    theta=360-theta
C=math.sqrt(A**2+B**2-2*A*B*(math.cos(math.radians(theta))))
print(C)

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

int main() {
  int N,K;
  cin>>N>>K;
  vector<int64_t> p(N);
  for(int i=0;i<N;i++){
    cin>>p.at(i);
  }
  vector<int64_t> z(N,1000000000);
  z.at(0)=0;
  for(int i=0;i<N;i++){
    int x=1;
    while(x<=K&&i+x<N){
      z.at(i+x)=min(z.at(i+x),z.at(i)+abs(p.at(i)-p.at(i+x)));
      x++;
    }
  }
  cout<<z.at(N-1)<<endl;
}

Measured memory_bytes: 1792
n, k = map(int, input().split())
A = [*map(int, input().split())]
P, M = [], [] # plus, minus
for a in A:
    if a < 0: M.append(a)
    else: P.append(a)

def mix():
    len_p = len(P); len_m = len(M)
    P.sort(reverse=True); M.sort()
    P.append(-1); M.append(1) # add endpoint
    pa, ma = [], []
    while len(pa) + len(ma) < k:
        if P[len(pa)] < -M[len(ma)]: ma.append(M[len(ma)])
        else: pa.append(P[len(pa)])
    if len(ma)%2 == 0: return pa + ma
    exist_pa = len(pa) > 0; exist_ma = len(ma) > 0
    remain_p = len_p > len(pa); remain_m = len_m > len(ma)
    if exist_pa & exist_ma & remain_p & remain_m:
        if abs(pa[-1] * P[len(pa)]) < abs(ma[-1] * M[len(ma)]):
            pa.pop(); ma.append(M[len(ma)])
        else:
            ma.pop(); pa.append(P[len(pa)])
        return pa + ma
    if exist_ma & remain_p:
        ma.pop(); pa.append(P[len(pa)])
        return pa + ma
    if exist_pa & remain_m:
        pa.pop(); ma.append(M[len(ma)])
        return pa + ma
    return pa + ma

ans_list = []
if k==n: ans_list = A
elif len(P) == n: ans_list = sorted(P, reverse=True)[:k]
elif len(M) == n: ans_list = sorted(M, reverse=k%2)[:k]
else: ans_list = mix()
MOD = 10**9 + 7
ans = 1
for a in ans_list: ans *= a; ans %= MOD
ans += MOD; ans %= MOD
print(ans)


Measured memory_bytes: 31868
#include <bits/stdc++.h>
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--)
 
int main() {
  int N, p;
  int answer = 0;
  int nem = 2;
  cin >> N;
  if (N == 1) {
    answer = 1;
    goto end;
  }
  for (int i = 1; i < 8; i++) {
    p = pow(2,i);
    if (N < p) {
      answer = nem;
      break;
    }
    nem = p;
  }
  end:
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 256
module WeightedDirectedGraph
  (Weight : sig
    type t
    val inf : t (* オーバーフローの恐れはないので，max_intとか突っ込んでも良い *)
    val zero : t
    val neg_inf : t (* オーバーフローの恐れはないので，min_intとか突っ込んでも良い *)
    val ( + ) : t -> t -> t
    val compare : t -> t -> int
  end) :
sig
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  val bellman_ford :
    (* 頂点数n *)
    int ->
    (* 辺のリスト
       頂点は0からn-1までの整数でなくてはならない *)
    (int * int * Weight.t) church_list ->
    (* 始点 *)
    int ->
    (* 頂点を受け取り，そこまでの距離を返す関数
       頂点に到達するパスが無ければinfを返し，
       そこに到達するまでに負閉路があればneg_infを返す *)
    (int -> Weight.t)
end =
struct
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  let bellman_ford n es s =
    (* 距離を覚えるやつ *)
    let d = Array.make n Weight.inf in
    (* 自己辺の最小のコスト *)
    let self = Array.make n Weight.inf in
    (* 始点より終点のインデックスが大きくなる辺を集めた隣接リスト *)
    let inc = Array.make n [] in
    (* 始点より終点のインデックスが小さくなる辺を集めた隣接リスト *)
    let dec = Array.make n [] in
    es.fold (fun ((u, v, c) as e) () ->
      match compare v u with
      | 0 -> if 0 < Weight.compare self.(u) c then self.(u) <- c
      | cmp when 0 < cmp -> inc.(u) <- e :: inc.(u)
      | _ -> dec.(u) <- e :: dec.(u)) ();
    (* 自己辺は最初に緩和する必要がある *)
    Array.iteri (fun v c ->
      if 0 < Weight.compare Weight.inf c then
        inc.(v) <- (v, v, c) :: inc.(v)) self;
    d.(s) <- Weight.zero;
    (* 残りの反復回数 *)
    let i = ref n in
    (* 更新が行われたか *)
    let is_modified = ref true in
    (* 各辺の処理 *)
    let f (u, v, c) =
      let open Weight in
      (* 原点から到達できない頂点は更新しない *)
      if 0 < Weight.compare inf d.(u) then
        let dv = if 0 <= Weight.compare neg_inf d.(u) then neg_inf else d.(u) + c in
        if 0 < Weight.compare d.(v) dv then
          (is_modified := true; d.(v) <- if !i <= succ n lsr 1 then neg_inf else dv) in
    while 0 < !i && !is_modified do
      is_modified := false;
      (* インデックスが増加する辺の処理 *)
      Array.iter (List.iter f) inc;
      (* インデックスが減少する辺の処理 *)
      for u = n - 1 downto 0 do
        List.iter f dec.(u)
      done;
      decr i
    done;
    Array.get d
end

module G = WeightedDirectedGraph (struct
  type t = int
  let zero = 0
  let inf = min_int
  let neg_inf = max_int
  let ( + ) = ( + )
  let compare x y = compare y x
end)

let () = Scanf.scanf "%d %d %d\n" @@ fun n m p ->
  let abc = Array.init m @@ fun _ ->
    Scanf.scanf "%d %d %d\n" @@ fun a b c -> a - 1, b - 1, c - p in
  let d = G.bellman_ford n { G.fold = fun f -> Array.fold_right f abc } 0 (n - 1) in
  if max_int <= d
  then print_endline "-1"
  else Printf.printf "%d\n" @@ max 0 d


Measured memory_bytes: 6204
int m[100][100];
main(n,i,j,s){
  for(;scanf("%d",&n),n;){
    for(i=0;i<n;i++)
      for(j=0;j<n;j++)
        scanf("%d",m[i]+j);
    for(i=0;i<n;m[i][j]=s,i++)
      for(s=j=0;j<n;j++)s+=m[i][j];
    for(i=0;i<n+1;m[j][i]=s,i++)
      for(s=j=0;j<n;j++)s+=m[j][i];
    for(i=0;i<n+1;puts(""),i++)
      for(s=j=0;j<n+1;j++)printf("%5d",m[i][j]);
  }
  return 0;
}

Measured memory_bytes: 624
#include <iostream>

using namespace std;

int main()
{
	double t,ti;

	while(cin >> t >> ti){

	if(t < 35.50 && ti < 71.00)
	{
		cout << "AAA" << endl;
	}
	else if(t < 37.50 && ti < 77.00)
	{
		cout << "AA" << endl;
	}
	else if(t < 40.00 && ti < 83.00)
	{
		cout << "A" << endl;
	}
	else if(t < 43.00 && ti < 89.00)
	{
		cout << "B" << endl;
	}
	else if(t < 50.00 && ti < 105.00)
	{
		cout << "C" << endl;
	}
	else if(t < 55.00 && ti < 116.00)
	{
		cout << "D" << endl;
	}
	else if(t < 70 && ti < 148.00)
	{
		cout << "E" << endl;
	}

	else
		cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
using namespace std;

typedef long long ll;
ll n, ans = 1, c, a[N];
int main()
{
	ll i;
	cin >> n;
	for (i = 0; i < n; i++) scanf("%lld", &a[i]);
	sort(a, a + n);
	for (i = n - 1; i >= 0; i--) {
		if (a[i] == a[i - 1]) {
			c++;
			ans *= a[i];
			if (c == 2) return !printf("%lld", ans);
			i--;
		}
	}
    cout << '0' << endl;
    return 0;
}

Measured memory_bytes: 1024
k = int(input())

res = []
start = ["1","2","3","4","5","6","7","8","9"]
now = []
for times in range(9):
    for i in start:
        if i[-1] == "0":
            now.append(i + "0")
            now.append(i + "1")
        elif i[-1] != "9":
            now.append(i + str(int(i[-1]) - 1))
            now.append(i + str(int(i[-1])))
            now.append(i + str(int(i[-1]) + 1))
        elif i[-1] == "9":
            now.append(i + "8")
            now.append(i + "9")
    res.extend(start)
    start = now[:]
    now = []

res.extend(start)
print(res[k - 1])

Measured memory_bytes: 62428
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC081A_PlacingMarbles
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            Console.WriteLine(s.Count(x => x == '1'));
        }
    }
}


Measured memory_bytes: 11220
from fractions import gcd
a, b = map(int, input().split())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


def coprime(a, b):
    return gcd(a, b) == 1


ans = 0
P = make_divisors(a)
Q = make_divisors(b)

kou = list(set(P) & set(Q))
n = len(kou)


ans = []
kou.sort()
for k in kou:
    flag = True
    for i in range(len(ans)):
        if coprime(ans[i], k) is False:
            flag = False
    if flag is True:
        ans.append(k)
print(len(ans))


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

int main()
{
  while(1){
    int m, nmin, nmax;
    cin >> m >> nmin >> nmax;
    if(m == 0 && nmin == 0 && nmax == 0) break;
    int P[m];
    for(int i = 0; i < m; i++)
      cin >> P[i];
    int x = -1;
    int ans;
    for(int i = nmin; i <= nmax; i++){
      if(x <= P[i-1]-P[i]){
        x = P[i-1]-P[i];
        ans = i;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1164
#include <iostream>
#include <utility>
#include <vector>
#include <unordered_set>
#include <map>
#include <queue>
#include <algorithm>
#define INF 1001001001
using namespace std;
typedef pair<int,int> P;

int main() {
    int V,E,r;
    cin >> V >> E >> r;

    vector< vector<int> > path(V);        //??£??\?????????
    map<P, int> w;         //???????????????

    int s,t,d;
    for(int i=0; i<E; i++) {
        cin >> s >> t >> d;
        path[s].push_back(t);
        w[P(s,t)] = d;
    }

    vector<int> distance(V,INF);      //?§????????????????????????§????????????????????????
    distance[r] = 0;
    unordered_set<int> Q;                     //????????????????????????????¢??????????????????????
    for(int i=0; i<V; i++) {Q.insert(i);}

    priority_queue<P, vector<P>, greater<P> > S;
    S.push(P(distance[r], r));

    while(Q.size() && S.size()) { 
        P tmp = S.top();
        S.pop();
        int u = tmp.second;
        if(Q.find(u) != Q.end()) {
            Q.erase(u);
            for(int v : path[u]) {
                    distance[v] = min(distance[v], distance[u] + w[P(u,v)]);
                    S.push(P(distance[v], v));
            }
        }
    }

    for(int i=0; i<V; i++) {
        if(distance[i] != INF) {
            cout << distance[i] << endl;
        } else {
            cout << "INF" << endl;
        }
    }
}


Measured memory_bytes: 45584
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

if ri() == 1:
  print('Hello World')
  exit()
else:
  print(ri()+ri())














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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int han = n / 2;
    int cnt = 0;
    for(int i = 0;i < han;i++){
        if(s[i] != s[n - 1 - i]){
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define MOD 1000000007 
#define INF 1000000000000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int n;
	cin >> n;
	vector <int> A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		A[i] -= (i + 1);
	}
	sort(all(A));
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += abs(A[i] - A[n / 2]);
	}
	cout << ans;
}


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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] NK = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            int[] p = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            Array.Sort(p);
            int sum = 0;
            for(int i = 0; i< NK[1];i++){
                sum += p[i];
            }            
            Console.WriteLine(sum);
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


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

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; }
typedef vector<vector<int>> Matrix;

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

int main(){
    int  K;
    cin >> K;
    int A, B, j = 0;
    cin >> A >> B;

    for(int i = A; i <= B; i++){
      if(i % K == 0){
        j= 1;
      }
    }
  
   if(j== 1){
         cout  << "OK" << endl;
      }
    else{
        cout  << "NG" << endl;
      }
}


Measured memory_bytes: 3624
/*
 *  author : Atul Anand   
 *  created on : Fri Apr 03 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        int K = in.nextInt();
        int X = in.nextInt();
        int l = -1000000;
        int r = 1000000;
        for(int i = Math.max(l, X - K + 1); i <= Math.min(r, X + K - 1); i++){
            print(i + " ");
        }
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 22612
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
void solve()
{
	ll i,tot=0,x,h,n;
	cin>>h>>n;
	while(n--)
	{
		cin>>x;
		tot+=x;
	}
	if(tot>=h)
	cout<<"Yes";
	else
	cout<<"No";
}
int main()
{
	fast();
	ll t;
	t=1;
	while(t--)
		solve();
}

Measured memory_bytes: 256
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

import collections
N, Q = rl()
edges = collections.defaultdict(list)
for i in range(N-1):
	a, b = rl()
	edges[a-1].append(b-1)
	edges[b-1].append(a-1)
root_cnts = [0] * N
for i in range(Q):
	p, x = rl()
	root_cnts[p-1] += x

cnts = [0] * N

queue = collections.deque()
queue.append([0, 0, -1])

while queue:
	n, c, p = queue.pop()
	c += root_cnts[n]
	cnts[n] = c
	for m in edges[n]:
		if m == p: continue
		queue.append((m, c, n))

print(*cnts)


Measured memory_bytes: 153304
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
vector<pair<int,int>> obstacles;
long long n,m,k,fact[200001],dp[3001];

long long mult(long long a , long long b){
	long long ret = (long long)a*b;
	return ret%1000000007;
}

long long inv(long long a , long long b){
	long long ret = 1;
	b -= 2;
	while(b){
		while(b % 2 == 0){
			a = mult(a,a);
			b /= 2;
		}
		ret = mult(ret,a);
		b -= 1;
	}
	return ret;
}

long long add(long long a , long long b){
	a += b;
	if(a >= 1000000007){
		a -= 1000000007;
	}
	if(a < 0){
		a += 1000000007;
	}
	return a;
}

int main(){
	cin >> n >> m >> k;
	obstacles.resize(k);
	for(int i = 0 ; i < k ; i += 1){
		cin >> obstacles[i].first >> obstacles[i].second;
	}
	obstacles.push_back({n,m});
	k++;
	sort(obstacles.begin(),obstacles.end());
	fact[0] = 1;
	for(int i = 1 ; i <= 200000 ; i += 1){
		fact[i] = mult(fact[i-1],i);
	}
	for(int q = 0 ; q < k ; q += 1){
		pair<int,int> i = obstacles[q];
		dp[q] = mult(fact[i.first+i.second-2],inv(mult(fact[i.first-1],fact[i.second-1]),mod));
		for(int qq = 0 ; qq < q ; qq += 1){
			pair<int,int> j = obstacles[qq];
			if(j.second > i.second){
				continue;
			}
			long long val = mult(fact[i.first+i.second-j.first-j.second],inv(fact[i.first-j.first],mod));
			dp[q] = add(dp[q],-mult(dp[qq],mult(val,inv(fact[i.second-j.second],mod))));
		}
	}
	cout << dp[k-1] << endl;
}

Measured memory_bytes: 1920
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ff first 
#define ss second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define testcase(t) int t;cin>>t;while(t--)
#define mp(x,y) make_pair(x,y)
#define in(x) insert(x)
#define rep(i,a,b)  for (__typeof((b)) i=(a);i<=(b);i++)
#define nrep(i,a,b)  for (__typeof((b)) i=(b);i>=(a);i--)
#define PI 3.14159265358979323846
#define SP(x) setprecision(x)
#define reflex ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define M 1000000007
#define sz(a) (int)a.size()
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(x) x.resize(distance(x.begin(), unique(all(x))))
#define mem(arr,val) memset(arr,val,sizeof(arr)) //For "0" and "-1"                  
#define inp0(a,n) rep(i,0,n-1) cin>>a[i];
#define inp1(a,n) rep(i,1,n) cin>>a[i]; 
#define prll(x) printf("%lld",x)
#define nth_ele(v,n) nth_element(v.begin(), v.begin()+n ,v.end())//O(N)
#define DEBUG(x) cerr << (#x) << ": " << (x) << endl
#define DEBUGV(x) for(auto IT:x) cout<<IT<<" "; cout<<endl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll gcd(ll n1, ll n2){if(n2!=0) return gcd(n2, n1%n2);else return n1;}
ll powerM(ll a,ll b){if(b==0) return 1;  if(b==1) return a%M; ll x=powerM(a,b/2)%M; if(b&1){return ((((a%M)*(x%M))%M)*(x%M))%M;}return ((x%M)*(x%M))%M;}
ll power(ll a,ll b){if(b==0) return 1;  if(b==1) return a; ll x=power(a,b/2); if(b&1){return ((((a)*(x)))*(x));}return ((x)*(x));}
 
const ll INF=1e18; 
const int SIZE = 200005;

int main(){
	reflex;
	int n;
	cin>>n;
	ll a[n+1],b[n+1],c[n+1];
	rep(i,1,n){
		cin>>a[i]>>b[i]>>c[i];
	}
	ll dp[n+2][2][2][2];
	dp[1][1][0][0]=a[1];
	dp[1][0][1][0]=b[1];
	dp[1][0][0][1]=c[1];
	rep(i,2,n){
		dp[i][1][0][0] = a[i]+max(dp[i-1][0][1][0], dp[i-1][0][0][1]);
		dp[i][0][1][0] = b[i]+max(dp[i-1][1][0][0], dp[i-1][0][0][1]);
		dp[i][0][0][1] = c[i]+max(dp[i-1][0][1][0], dp[i-1][1][0][0]);
		// cout<<dp[i][0][0][1]<<" "<<dp[i][1][0][0]<<" "<<dp[i][0][1][0]<<endl;
		
	}
	ll ans=0;
	ans=max(dp[n][0][0][1], max(dp[n][1][0][0], dp[n][0][1][0]));
	cout<<ans<<endl;
}

Measured memory_bytes: 8832
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N, M;

struct Data {
    int l, r;
    LL c;

    bool operator<(const Data &that) const {
	return r < that.r;
    }
} D[100011];

template<class T> struct RMQ {
    int n;
    vector<T> A; vector<int> I;
    RMQ(int n_=0): n(n_), A(n), I(2*n) {
	for (int i=0; i<n; i++) I[i+n] = i;
	for (int i=n; --i;) I[i] = I[2*i];
    }
    RMQ(const vector<T> &a): n(a.size()), A(a), I(2*n) {
	for (int i=0; i<n; i++) I[i+n] = i;
	for (int i=n; --i;) I[i] = (A[I[i*2+1]] < A[I[i*2]]? I[i*2+1]: I[i*2]);
    }
    void modify(int i, const T &v) {
	A[i] = v;
	for (i+=n; i>>=1;) I[i] = (A[I[i*2+1]] < A[I[i*2]]? I[i*2+1]: I[i*2]);
    }
    int min_i(int x, int y) {
	x += n; y += n;
	int p = -1;
	for (; x<y; x>>=1, y>>=1) {
	    if (y & 1) { --y; if (p < 0 || A[I[y]] < A[p]) p = I[y]; }
	    if (x & 1) { if (p < 0 || A[I[x]] < A[p]) p = I[x]; x++; }
	}
	return p;
    }
    T min_v(int x, int y) { return A[min_i(x, y)]; }
};

void MAIN() {
    scanf("%d%d", &N, &M);

    REP (i, M) {
	int l, r, c;
	scanf("%d%d%d", &l, &r, &c);
	l--;
	D[i].l = l;
	D[i].r = r;
	D[i].c = c;
    }

    sort(D, D+M);

    const LL INF = 1LL<<60;
    RMQ<LL> rmq(vector<LL>(N, INF));
    rmq.modify(0, 0);
    REP (i, M) {
	LL tmp = D[i].c + rmq.min_v(D[i].l, D[i].r);
	if (rmq.min_v(D[i].r-1, D[i].r) > tmp) {
	    rmq.modify(D[i].r-1, tmp);
	}
    }

    LL ans = rmq.min_v(N-1, N);
    if (ans >= INF) puts("-1");
    else printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 4096
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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


int main(void) {
	
	long long int n;
	long long int m;
	long long int total = 0;
	
	cin >> n >> m;
	vector<long long int>x(m), sa(m);
	FOR(i, 0, m - 1) {
		cin >> x[i];
	}
	sort(x.begin(), x.end());
	FOR(i, 0, m-2) {
		sa[i] = x[i + 1] - x[i];
		total += sa[i];
	}
	sort(sa.begin(), sa.end());
	n--;
	RFOR(i, sa.size() - 1, 0) {
		if (n == 0) {
			break;
		}
		else {
			total -= sa[i];
			n--;
		}
	}

	cout << total << endl;


	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>a(n); for(auto&&i:a)cin>>i;
	sort(a.rbegin(),a.rend());
	int ans=0;
	for(int i=1;i<n;++i){
		if(a.at(i-1)==a.at(i)){
			if(ans){
				cout<<1L*ans*a.at(i)<<"\n"s;
				return 0;
			}
			else ans=a.at(i),++i;
		}
	}
	cout<<"0\n"s;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define pp pair<int,int>
#define ff first
#define dd second
#define Q 100005
#define M 1005
#define N 200005

using namespace std; // zmienic na drzewo przedz

int n;

int mod = 1e9+7;

int tab[N];

main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    int left = 0;
    int ans = 1;

    string s; cin >> s;

    for (int i = 0; i < (2*n); ++i) {
        int color = ((s[i] == 'W') ^ (left & 1))?1:(-1);
        if (left == 0 and color == 1) {
            cout << 0 << endl; exit(0);
        }
       /// cout << "i color left " << i << " " << color << " " << left << endl;

        if (color == 1) {
            ans *= left;
        }
        left -= color;
        ans %= mod;
    }

    if (left > 0) {
        cout << 0 << endl; exit(0);
    }

    for (int i = 1; i <= n; ++i) {
        ans *= i;
        ans %= mod;
    }

    cout << ans << endl;

        
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

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

const ll mod = 1000000007;

template<int MOD> class Fp {
    ll val;
public:
    constexpr Fp(ll v = 0) noexcept : val(v % MOD) {
        if(val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator- () const noexcept { return val ? MOD - val : 0; }
    constexpr Fp operator+ (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator- (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator* (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator/ (const Fp& r) const noexcept { return Fp(*this) /= r; }
    //constexpr Fp operator-- (const Fp& r) const noexcept { return Fp(*this) -= 1; }
    //constexpr Fp operator++ (const Fp& r) const noexcept { return Fp(*this) += 1; }
    constexpr Fp& operator+= (const Fp& r) noexcept {
        val += r.val;
        if(val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator-= (const Fp& r) noexcept {
        val -= r.val;
        if(val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator*= (const Fp& r) noexcept {
        (val *= r.val) %= MOD;
        return *this;
    }
    constexpr Fp& operator/= (const Fp& r) noexcept {
        ll a = r.val, b = MOD, u = 1, v = 0;
        while(b){
            ll t = a/b;
            a -= t*b; swap(a, b);
            u -= t*v; swap(u, v);
        }
        (val *= u) %= MOD;
        if(val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator== (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator!= (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    constexpr bool operator> (const Fp& r) const noexcept {
        return this->val > r.val;
    }
    constexpr bool operator< (const Fp& r) const noexcept {
        return this->val < r.val;
    }
    friend constexpr ostream& operator<< (ostream &os, const Fp<MOD>& x){
        ll tmp = x.val;
        os << tmp;
        return os;
    }
    friend constexpr ostream& operator>> (istream &is, const Fp<MOD>& x){
        ll tmp;
        is >> tmp;
        x = Fp<MOD>(tmp);
        return is;
    }
    constexpr Fp<MOD> modpow(ll n) noexcept {
        if(n == 0) return 1;
        auto t = modpow(n>>1);
        t *= t;
        if(n & 1) t *= *this;
        return t;
    }
};
using mint = Fp<mod>;

int main(){
    ll n, m; cin >> n >> m;
    vector<ll> br(m+1);
    rep(i, m) cin >> br[i];
    br[m] = n+1;
    vector<mint> f(100001, 0);
    rep(i, f.size()){
        if(i == 0 || i == 1) f[i] = 1;
        else f[i] = (f[i-1] + f[i-2]);
    }
    ll step = 0;
    mint cnt(1);
    for(auto i : br){
        if(step == i){
            cnt = 0;
            break;
        }
        cnt *= f[i-1-step];
        step = i+1;
    }
    cout << cnt << endl;
    return 0;
}

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

// #pragma comment(linker, "/STACK:16777216")

using namespace std;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define int ll
#define pii pair<int, int>
const int SZ = 1e5 + 4;
const double EPS = 1e-7;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

struct custom_hash {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return x + FIXED_RANDOM;
    }
};

int a, b, c;

void read() {
    cin >> a >> b >> c;
}

void solve() {
    cout << (a + b + c >= 22 ? "bust" : "win");
}

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

    read();
    solve();

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ls x<<1
#define rs x<<1|1
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-6;
const ull hashp=1e7+19;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=3e5+100;
ll sum[maxn][64];
ll a[maxn];
void solve()
{
    int n;scd(n);
    rep1(i,n)scanf("%lld",&a[i]);
    for(int i=n;i;i--){
    	for(int j=62;~j;j--){
    		sum[i][j]=sum[i+1][j];
    		if(a[i]&(1ll<<j))sum[i][j]++;
		}
	}
	int ans=0;
	rep1(i,n-1){
		for(int j=62;~j;j--){
			if(a[i]&(1ll<<j))ans=(ans+1ll*(n-i-sum[i+1][j])*((1ll<<j)%mod)%mod)%mod;
			else {
				ans=(ans+1ll*sum[i+1][j]*((1ll<<j)%mod)%mod)%mod;
			}
		}
	}ac;
}
int main(){
    //IOS;
    //freopen("D://data.txt","r",stdin);
    solve();
    return 0;
}

Measured memory_bytes: 152576
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {
	
	public static class Pair implements Comparable<Pair> {
		int x, y;
		
		public Pair(int x, int y){
			this.x = x;
			this.y = y;
		}
		
		@Override public int compareTo(Pair arg0){
			return Integer.compare(this.x, arg0.x);
		}
	}

	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		final int m = sc.nextInt();
		
		int[] upper = new int[n];
		int[] lower = new int[n];
		for(int i = 0; i < n; i++){
			upper[i] = lower[i] = i;
		}
		
		Pair[] pair = new Pair[m];
		for(int i = 0; i < m; i++){
			final int x = sc.nextInt();
			final int y = sc.nextInt() - 1;
			
			pair[i] = new Pair(x, y);
		}
		Arrays.sort(pair);
		
		for(int i = 0; i < m; i++){
			//final int x = pair[i].x;
			final int y = pair[i].y;
			
			upper[y] = Math.max(upper[y], upper[y + 1]);
			lower[y + 1] = Math.min(lower[y], lower[y + 1]);
		}
		
		//System.out.println(Arrays.toString(upper));
		//System.out.println(Arrays.toString(lower));
		
		//System.out.println(upper_most + " " + lower_most);
		
		
		PrintWriter pw = new PrintWriter(System.out);
		for(int i = 0; i < n; i++){
			//pw.println(upper[i] + ", " + lower[i]);
			//*
			pw.print(i == 0 ? "" : " ");
			pw.print((upper[i] - lower[i]) + 1);
			//*/
		}
		pw.println();
		pw.flush();
		pw.close();
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

int N, M, Q, MAX = 0;
vector<int> v(10);
vector<vector<int>> q(50, vector<int>(4));
void choose(int n, int d){
    int score = 0;
    if(d == M){
        vector<int> a(N);
        rep(i, M){
            for(int j = v.at(i); j < N; j++){
                a.at(j)++;
            }
        }
        rep(i,Q){
            if(a.at(q.at(i).at(1)-1)-a.at(q.at(i).at(0)-1) == q.at(i).at(2)) score += q.at(i).at(3);
        }
        MAX = max(MAX, score);
        return;
    }
    for(int i = n; i < N+1; i++){
        v.at(d) = n;
        choose(i, d+1);
    }
}

int main() {
    cin >> N >> M >> Q;
    rep(i, Q){
        rep(j,4){
            cin >> q.at(i).at(j);
        }
    }
    choose(0,0);
    cout << MAX << endl;
}


Measured memory_bytes: 3632
abc = list(map(int, input().split()))
K = int(input())
tmp = [i for i in range(K)]
ans = 'No'

for i in range(K + 1):
    for j in range(K + 1):
        for k in range(K + 1):
            if i + j + k == K:
                tmpabc = []
                tmplst = [i, j, k]
                for l in range(3):
                    tmpabc.append(abc[l] * (2 ** tmplst[l]))
                if tmpabc[0] < tmpabc[1] and tmpabc[1] < tmpabc[2]:
                    ans = 'Yes'
                    break

print(ans)

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

int n, a, ans;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if ((a - 1) == ans)
			ans++;
	}
	cout << (ans? n - ans: -1);
}


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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

ll  A, B;
ll  C, D;

map<ll,ll>  memo;
vector<int> base = {2,3,5};

ll  calc(ll  n) {
    if (n == 0)         return  0;
    if (n == 1)         return  D;
    if (memo.count(n))  return  memo[n];

    ll &res = memo[n];
    res = 1e18;

    if (res / D >= n)
        res = D * n;

    for(int x : base)   {
        ll  v = n / x;
        int c;

        if (x == 2) c = A;
        if (x == 3) c = B;
        if (x == 5) c = C;

        res = min(res,calc(v) + c + (n - v * x) * D);   if (n % x)  v++;
        res = min(res,calc(v) + c + (v * x - n) * D);
    }
    return  res;
}

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

    while (itest--) {
        ll  n;  cin >> n;   
        cin >> A >> B;
        cin >> C >> D;

        cout << calc(n) << "\n";
        memo.clear();
    }
}

Measured memory_bytes: 4360
#include <stdio.h>

int main(void){
  int i;
  long long sum=0;

  int n;
  scanf("%d",&n);

  long a[n];
  for(i=0;i<n+1;i++){
    scanf("%ld",&a[i]);
  }

  long b;
  for(i=0;i<n;i++){
    scanf("%ld",&b);

    if(b>a[i]){
      if(b>=a[i]+a[i+1]){
        sum+=a[i]+a[i+1];
        a[i+1]=0;
      }else{
        sum+=b;
        a[i+1]-=b-a[i];
      }
    }else{
      sum+=b;
    }
  }

  printf("%lld\n",sum);

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};



int main(){
    ll X; cin>>X;
    ll a=100;
    ll ans=0;
    while(a<X){
        a*=1.01;
        ans++;
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 3632
# ref: http://lethe2211.hatenablog.com/entry/2014/12/30/011030
# ref: http://d.hatena.ne.jp/simezi_tan/20101019/1287462266
from heapq import heappop,heappush

if __name__ == '__main__':
    def id(s):
        # edges = [C1 C2 C3...Cm L1 L2 L3...Ln H D]
        # len(edges) = m+n+1+1
        if s[0]=="H": return ne-2
        if s[0]=="D": return ne-1
        num = int(s[1:])
        if s[0]=="C": return num-1
        return num-1+m
    while(True):
        m,n,k,d = map(int, input().split())
        if not m: break
        ne = m+n+2
        cs = list(map(int, input().split()))
        edges = [[] for _ in range(ne) ]
        for i in range(d):
            s1,s2,di = input().split()
            t1,t2,ca = id(s1),id(s2),int(di)*k
            edges[t1].append([t2,ca])
            edges[t2].append([t1,ca])
        que = []
        cost = [float('inf')]*(ne<<m)
        cost[(ne-2)<<m] = 0
        ans = float('inf')
        heappush(que,[0,(ne-2)<<m])
        while(que):
            cc,state = heappop(que)
            vis_cak = state&(2**m-1)
            cur_pos = state>>m
            if cur_pos == ne-1: ans = min(ans,cc)
            if cost[state]>cc: continue
            for ss,dd in edges[cur_pos]:
                nxt_cost = cc+dd
                nxt_pos = ss
                nxt_bit = vis_cak
                # calc cakeshop (visit one time only)
                if 0<=nxt_pos and nxt_pos<m:
                    if 1<<nxt_pos & vis_cak: continue
                    nxt_cost -= cs[nxt_pos]
                    nxt_bit ^= 1 << nxt_pos
                # combine next_position and visited_cakeshop
                new_state = (nxt_pos<<m) + nxt_bit
                if cost[new_state] > nxt_cost:
                    heappush(que,[nxt_cost,new_state])
                    cost[new_state] = nxt_cost
        print(ans)
        


Measured memory_bytes: 6040
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    u32 a, b;
    std::cin >> a >> b;
    if (a==1) a=14;
    if (b==1) b=14;
    std::cout << (a>b ? "Alice" : a==b ? "Draw" : "Bob") << '\n';
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> a(N), b(N), c(N), d(N);
    vector<pair<ll, ll>> red, blue;
    vector<bool> isUsed(N, false);
    REP(i, N)
    {
        cin >> a[i] >> b[i];
        red.push_back(make_pair(a[i], b[i]));
    }
    REP(i, N)
    {
        cin >> c[i] >> d[i];
        blue.push_back(make_pair(c[i], d[i]));
    }
    sort(ALL(blue));

    ll ans = 0;
    REPV(it, blue)
    {
        ll bx = it->first, by = it->second;
        priority_queue<pair<ll, ll>> q;
        REP(i, N)
        {
            if (!isUsed[i])
            {
                ll rx = red[i].first, ry = red[i].second;
                if (rx < bx && ry < by)
                {
                    q.push(make_pair(ry, i));
                }
            }
        }
        if (!q.empty())
        {
            ans++;
            ll maxIndex = q.top().second;
            isUsed[maxIndex] = true;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256