akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int abcd;
    cin >> abcd;
    int a = abcd / 1000;
    int b = (abcd - a * 1000) / 100;
    int c = (abcd - a * 1000 - b * 100) / 10;
    int d = abcd - a * 1000 - b * 100 - c * 10;

    int array[3];
    array[0] = b;
    array[1] = c;
    array[2] = d;
    bool op[3] = {};
    REP(i, 8){
        int sum = a;
        REP(j, 3){
            if(((i >> j) & 0x01) == 0x01){
                sum += array[j];
                op[j] = true;
            }else{
                sum -= array[j];
                op[j] = false;
            }
        }
        if(sum == 7){
            cout << a;
            REP(i, 3){
                if(op[i] == true) cout << "+";
                else cout << "-";
                cout << array[i];
            }
            cout << "=7" << "\n";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf
import Debug.Trace

readInt = ( readLn :: IO Int )
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, k ] <- readInts
	idx <- fromJust . elemIndex 1 <$> readInts
	print $ minimum $ do
		l <- [ 0 .. k - 1 ]
		let
			r = k - 1 - l

			ll = max 0 $ idx - l
			rr = max 0 $ ( n - 1 - idx ) - r

			f a = ( a + ( k - 1 ) - 1 ) `div` ( k - 1 )
		return $ 1 + f ll + f rr

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

bool b[7400000];

int main(){
    int m, n;
    while(cin >> m >> n, m+n){
        memset(b, 0, sizeof(b));
        int year = m;
        for(int i = 0; i < n; i++){
            while(b[year])  year++;
            for(int j = year; j < 7400000; j += year)   b[j] = true;
        }
        while(b[year])  year++;
        cout << year << endl;
    }
    return 0;
}


Measured memory_bytes: 10276
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n  = Integer.parseInt(br.readLine());
		Card[] cards = new Card[n];
		for(int i = 0 ; i < n ; i++){
			cards[i] = new Card(br.readLine(),i);
		}
		quickSort(cards,0,n - 1);

		StringBuilder sb = new StringBuilder();
		boolean flag = true;
		for(int i = 0 ; i < n ; i ++){
			if(flag){
				flag = isStable(cards,i);
			}
			sb.append(cards[i].getStr());
			sb.append("\n");
		}

		if(flag){
			sb.insert(0, "Stable" + "\n");
		}else{
			sb.insert(0, "Not stable" + "\n");
		}

		System.out.print(sb.toString());
	}

	private static void quickSort(Card[] cards,int begin,int end){

		//????????\???????????§???????????´????????????
		if(end - begin < 1){
			return;
		}

		int q = partition(cards,begin,end);

		//??????
		quickSort(cards,begin,q - 1);
		//??????
		quickSort(cards,q + 1,end);
	}

	private static int partition(Card[] cards,int begin,int end){

		//???????????????
		int standardNum  = cards[end].getNum();
		Card tmpCard;
		//?????????????°????????????§???index
		int x = begin - 1;
		for(int i = begin ; i <  end ; i++){
			//?????????????°?????????´????????\?????????
			if(cards[i].getNum() <= standardNum){
				tmpCard = cards[i];
				cards[i] = cards[++x];
				cards[x] = tmpCard;
			}
		}

		//????????¨??????????????????????????¨????????????????????????????§??????????
		tmpCard = cards[end];
		cards[end] = cards[++x];
		cards[x] = tmpCard;
		return x;
	}

	private  static boolean isStable(Card[] cards,int i){
		if(i == 0){
			return true;
		}else if(cards[i].getNum() == cards[i - 1].getNum()
				  &&
				  cards[i].getFirstIndex() < cards[i - 1].getFirstIndex()
				  )
		{
			return false;
		}else{
			return true;
		}
	}
}

class Card{
	private String str;
	private int num;
	private int firstIndex;

	Card(String str,int firstIndex){
		this.str = str;
		this.num = Integer.parseInt(str.substring(2));
		this.firstIndex = firstIndex;
	}

	public String getStr() {
		return str;
	}
	public int getNum() {
		return num;
	}
	public int getFirstIndex() {
		return firstIndex;
	}

}

Measured memory_bytes: 49092
//By : BebekJK
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//Declare -> ordered_set NAMA;
//Nth smallest integer -> find_by_order(N-1)
//Number of elements less than N -> order_of_key(N)
//Delete N from the set -> erase(N)

#define endl '\n'
#define MOD 1000000007
#define PI 3.141592653
#define fi first
#define sc second
#define pb push_back
#define pbb pop_back

//#pragma GCC optimize("Ofast")
//#pragma GCC target ("string"...)
//#pragma GCC push_options
//#pragma GCC pop_options
//#pragma GCC reset_options
//#pragma GCC optimize ("O3")

typedef long long ll;
typedef long double ld;
typedef pair<int , int> pii;
typedef pair<long long , long long> pll;

void BOOST(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
}
void fcin(int &x){
	bool neg = false;
	register int c;
	x = 0;
	c = getchar();
	if(c=='-'){
		neg = true;
		c = getchar();
	}
	for(;(c>47 && c<58);c=getchar())x = (x<<1)+(x<<3)+c-48;
	if(neg)x*=-1;
}
ll pmod(ll a , ll b){
	if(b==0)return 1;
	ll temp = pmod(a , b/2);
	if(b%2==0)return(temp*temp)%MOD;
	return (((temp*temp)%MOD)*a)%MOD;
}
int main(){
//	BOOST();
	int x , n , p[105];
	bool vis[205];
	memset(vis , 0 , sizeof vis);
	cin>>x>>n;
	for(int i=1;i<=n;i++)cin>>p[i] , vis[p[i]] = true;	
	int inc = 0;
	while(true){
		if(!vis[x-inc]){
			cout<<x-inc<<endl;
			return 0;
		}
		else if(!vis[x+inc]){
			cout<<x+inc<<endl;
			return 0;
		}
		inc++;
	}
}







Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
typedef pair<int,int> P;
struct edge{int to, id;};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000

int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int little = min(x,y);
    ll ans = 0;
    if(a+b < 2*c){
        ans += (a+b) * little;
    }
    else{
        ans += (2*c) * little;
    }
    ll res = max(x,y) - little;
    if(x < y){
        ans += min(b,2*c) * res;
    }
    else{
     ans += min(a,2*c) * res;   
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include<algorithm>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<numeric>
#include<string>
#include<deque>
#include<vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
const double PI = acos(-1);  // PI = 3.141593...

int main() {
    int h, n;
    cin >> h >> n;
    vector<ll> mp(20002, INF);

    ll a, b;
    rep(i,n) {
        cin >> a >> b;
        mp[a] = min(mp[a], b);
        for(int j = a+1; j <= 2*h; j += 1) {
            mp[j] = min(mp[j], mp[j-a]+b);
        }
    }

    ll ans = INF;
    for(int i = h; i <= 20000; ++i) {
        if(ans > mp[i]) ans = mp[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
def main():
    N, Y = map(int, input().split())
    a = b = c = -1

    for i in range(N + 1):
        for j in range(N + 1 - i):
            k = N - i - j
            if 10000 * i + 5000 * j + 1000 * k == Y:
                a, b, c = i, j, k

    print(a, b, c)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import numpy as np


def cumprod(arr, MOD):
    L = len(arr)
    Lsq = int(L**.5 + 1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n - 1]
        arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n - 1, -1]
        arr[n] %= MOD
    return arr.ravel()[:L]


def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64)
    x[0] = 1
    fact = cumprod(x, MOD)
    return fact[-1]


N, M = map(int, input().split())
if N > M:
    N, M = M, N
if N + 1 < M:
    print(0)
    exit()
elif N + 1 == M:
    c = 1
else:
    c = 2
MOD = 10**9 + 7
# print("make_fact(N, MOD)", make_fact(N + 1, MOD), N)
ans = ((make_fact(N + 1, MOD) * make_fact(M + 1, MOD) % MOD) * c) % MOD
print(ans)


Measured memory_bytes: 14512
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();

		long[] s = new long[100007];
		int len = s.length;
		long mod = 1000000007;

		s[0] = 1;
		s[1] = 1;

		int i;
		for(i = 2; i < len; i++)
			s[i] = (s[i - 1] + s[i - 2]) % mod;

		int[] a = new int[m];

		for(i = 0; i < m; i++) {
			a[i] = scan.nextInt();
			if(i != 0) {
				if(a[i] - a[i - 1] == 1) {
					System.out.println(0);
					return;
				}
			}
		}
		if(m == 0) {
			System.out.println(s[n]);
		}else {

			int start;
			int end;
			long ans = 1;
			for(i = 0; i < m; i++) {
				if(i == 0) {
					start = 0;
					end = a[i] - 1;
				}else {
					start = a[i - 1] + 1;
					end = a[i] - 1;
				}
				ans = (ans * s[end - start]) % mod;
			}
			ans = (ans * s[n - (a[m - 1] + 1)]) % mod;
			System.out.println(ans);
		}


	}
}


Measured memory_bytes: 48220
#include <iostream>
#include<bits/stdc++.h>
#include <algorithm> 
#include<map>
#include<string>
#include<unordered_map>
#include <set>
#include <unordered_set>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long a,b,c,d;
	cin >> a>>b>>c>>d;
	long long ans = -1;
	vector<long long>arr;
	arr.push_back(a*c);
	arr.push_back(b*c);
	arr.push_back(a*d);
	arr.push_back(b*d);
	sort(arr.begin(), arr.end());
	cout << arr[3];
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
using namespace std;
int main()
{
    string s;
    cin>>s;
    ll maxx=0,c=0;
    for(ll i=0;s[i]!='\0';i++)
    {
        if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T')
        {
            c++;
            maxx=max(maxx,c);
        }
        else
        {
            c=0;
        }
    }
    cout<<maxx<<endl;
    return 0;
}


Measured memory_bytes: 256
// ABC128 B GuideBook  https://atcoder.jp/contests/abc128/tasks/abc128_b
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int N;
    cin >> N;
    vector<string> cities;
    map<string, int> dic; //ここがハッシュ連想配列
    for(int i = 0; i < N; i++) {
        string city;
        int point;
        cin >> city >> point;
        cities.push_back(city + to_string(999 - point));// to_string で数字を文字列にしてtempcityの後ろにくっつける
        dic[city + to_string(999 - point)] = i + 1;// レストランの番号を dic で管理
    }
    sort(cities.begin(), cities.end()); //昇順ソート
    for(int i = 0; i < N; i++) {
        cout << dic[cities[i]] << endl;
    }
    cout << "";
    return 0;
}


Measured memory_bytes: 256
s = input()

final_1 = []
final_2 = []

final_1_cnt = 0
final_2_cnt = 0

for i in range(len(s)):
    if i % 2 == 0:
        final_1.append('0')
        final_2.append('1')
    else:
        final_1.append('1')
        final_2.append('0')

    if final_1[i] == s[i]:
        final_2_cnt += 1
    else:
        final_1_cnt += 1

print(min(final_1_cnt, final_2_cnt))

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

int main() {
  int N,K;
  cin>>N>>K;
  int z=0;
for(int i=0;i<N;i++){
  int x=0;
  cin>>x;
  if(x<=K-x){
    z+=x;
  }
  else{
z+=K-x;
  }
}
   cout<<2*z<<endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    ll N, T;
    cin >> N >> T;

    vector<ll> c_all;

    rep(i, N) {
        ll c, t;
        cin >> c >> t;
        if (t > T) continue;

        c_all.pb(c);
    }

    sort(ALL(c_all));

    // repv(c_all) cout << *it << " ";
    // cout << endl;

    if (SZ(c_all) == 0) {
        cout << "TLE" << endl;
    } else {
        cout << c_all[0] << endl;
    }

    return 0;
}

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

#define pb push_back
#define all(a) (a).begin(), (a).end()

using ll = long long;
using pii = pair<int, int>;

const int N = 2e3 + 10;
int d[N][N];
int ans[N];

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int n, x, y; cin >> n >> x >> y;
    for (int i = 1; i <= n; ++i) {
        for (int j = i; j <= n; ++j) {
            d[i][j] = (j - i);
        }
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = i; j <= n; ++j) {
            d[i][j] = min(d[i][j], abs(i - x) + abs(j - y) + 1);
            d[i][j] = min(d[i][j], abs(i - y) + abs(j - x) + 1);
        }
    }
    // for (int i = x; i >= 1; --i) {
    //     for (int j = y; j <= n; ++j) {
    //         d[i][j] = min(d[i][j], (x - i) + (j - y) + 1);
    //     }
    // }

    // for (int i = x; i <= y; ++i) {
    //     for (int j = x + 1; j <= y; ++j) {
    //         d[i][j] = min(d[i][j], (i - x) + (y - j) + 1);
    //     }
    // }

    for (int i = 1; i <= n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            ++ans[d[i][j]];
        }
    }

    for (int i = 1; i < n; ++i) {
        cout << ans[i] << '\n';
    }
}

Measured memory_bytes: 15360
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  list($d,$x) = explode(" ", trim(fgets(STDIN)));
  $ans=$n+$x;
  for ($i=0; $i<$n; $i++) {
    list($a) = explode(" ", trim(fgets(STDIN)));
    $ans+=intdiv($d-1,$a);
  }
  echo $ans;

  

Measured memory_bytes: 16016
def calc_sum_of_digits(num):
	ans = 0

	while True:
		if num // 10 == 0:
			ans += num
			break

		ans += num % 10
		num //= 10

	return ans


def main():
	N = int(input())
	min_sum = 1000

	for A in range(1, N):
		B = N - A

		A_sum = calc_sum_of_digits(A)
		B_sum = calc_sum_of_digits(B)

		if A_sum + B_sum < min_sum:
			min_sum = A_sum + B_sum

	print(min_sum)

  
if __name__ == "__main__":
  	main()

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

int main(){
    vector<int> A(3);
    for(int i = 0;i < 3;i++){
      cin >> A[i];
    }
    int ans;
    sort(A.begin(),A.end());
    ans = A[0] -A[1];
    ans = ans + A[1] - A[2];
    if(ans < 0){
        ans = ans*-1;
    }
    cout << ans << endl;
}

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

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var X = ReadLong();
            var A = ReadLong();
            var B = ReadLong();

            X -= A;

            return X % B;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 27516
#include<stdio.h>
#define N 2000000
  
int n;
int p(int i){
  return i/2;
}
 
int l(int i){
  return 2*i;
}
  
int r(int i){
  return 2*i+1;
}   
  
  
void maxheapify(int h[],int i){
  int largest=0,aa,le,ri;
  le = l(i);
  ri = r(i);
  if(le <= n && h[le] > h[i]){
    largest = le;
  }
  else{
    largest = i;
   }
  if(ri <= n && h[ri] > h[largest]){
    largest = ri;
  }
  if(largest != i){
    aa = h[i];
    h[i] = h[largest];
    h[largest] = aa;
    maxheapify(h,largest);
  }
}
 
 void buildMaxHeap(int  h[]){
  int i;
  for(i = (n/2); i > 0; i--){
    maxheapify(h,i);
  }
}


void heapIncreaseKey(int A[], int i, int key){
  int tmp;
  if (key < A[i]){
    return; 
  }
 
  A[i] = key;
  while (i > 1 && A[p(i)] < A[i]){
    tmp = A[i];
    A[i] = A[p(i)];
    A[p(i)] = tmp;
    i = p(i);
  }
}

 
void maxHeapInsert(int A[], int key){
  n = n + 1;
  A[n] = -1;
  heapIncreaseKey(A, n, key);
}
 


int heapExtractMax(int A[]){
  int max;
  if(n < 1)
    return 0; 
  max = A[1];
  A[1] = A[n];
  n = n - 1;
  maxheapify(A, 1);
  return max;
}
    
  
int main(){
  int i,w;
  int S[N];
  char c[30];

  for(i = 1;i < N;i++){
    scanf("%s",c);

  if(strcmp(c,"end")==0){
      break;
    }
 
    if(c[0]=='i'){
      scanf("%d",&w);
      maxHeapInsert(S,w);
    }
 
    else{
      printf("%d\n",heapExtractMax(S));
    }
  }

  return 0;
}

Measured memory_bytes: 4732
#include <stdio.h>

int extgcd(int a, int b, int* x, int* y) {
    int d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        *y -= (a / b) * *x;
    } else {
        *x = 1; *y = 0;
    }
    return d;
}

int main(void) {
	int a, b, x, y;
	scanf("%d %d\n", &a, &b);
	
	extgcd(a, b, &x, &y);
	printf("%d %d\n", x, y);
	
	return 0;
}

Measured memory_bytes: 600
dp = [True]  # i円の買い物ができるか
x = int(input())
for i in range(99):
    dp.append(False)
for i in range(100, x + 1):
    if(i < 106):
        dp.append(True)
    else:
        if(dp[i - 100] or dp[i - 101] or dp[i - 102] or dp[i - 103] or dp[i - 104] or dp[i - 105]):
            dp.append(True)
        else:
            dp.append(False)
if(dp[x]):
    print(1)
else:
    print(0)


Measured memory_bytes: 9804
#include <iostream>
#include <vector>

int main () {
  std::vector<int> divisors;
  int a, b, c;
  std::cin >> a >> b >> c;
  for(a; a <= b; ++a) {
    if(c % a == 0)
      divisors.push_back(a);
  }
  std::cout << divisors.size() << std::endl;
  return 0;
}

Measured memory_bytes: 3140
from fractions import gcd
A, B = map(int, input().split())
g = gcd(A, B)
def prime_factor(n):
    ass = set()
    for i in range(2,int(n**0.5)+1):
        if n%i == 0:
            ass.add(i)
        while n % i==0:
            n = n//i
    if n != 1:
        ass.add(n)
    return ass
ass = prime_factor(g)
print(len(ass)+1)

Measured memory_bytes: 64492
# -*- coding: utf-8 -*-
# map(int, input().split())
N = int(input())

mod = pow(10,9)+7

def pow_mod(x,n,mod):
    ans = 1
    for i in range(n):
        ans = (ans*x)%mod

    return ans

ans = pow_mod(10,N,mod)
ans = (ans-2*pow_mod(9,N,mod))%mod
ans = (ans+pow_mod(8,N,mod))%mod

print(ans%mod)

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

def is_valid(A):
    counts = {}
    for a in A:
        if a in counts:
            counts[a] += 1
        else:
            counts[a] = 1
    if len(A) % 2 == 1:
        if counts[0] != 1:
            return False
        
        for i in range(1, len(A) // 2 + 1):
            if 2 * i not in counts or counts[2 * i] != 2:
                return False
        return True
    else:
        for i in range(1, len(A) // 2 + 1):
            if 2 * i - 1 not in counts or counts[2 * i - 1] != 2:
                return False
        return True
    return True
        
if is_valid(A):
    print(2 ** (N // 2) % 1000000007)
else:
    print(0)

Measured memory_bytes: 14436
#!/usr/bin/env runghc
import Control.Applicative

calc r i n k
	 | i==n = r
	 | otherwise = calc (mod (r+k) i) (i+1) n k

main = do
	[n,k,m] <- map read . words <$> getLine
	if n/=0 then do
		putStrLn $ show $ ((mod ((calc 0 1 n k)+m) n)+1)
		main
	else return ()

Measured memory_bytes: 7424
package main

import "fmt"

func main() {
	var n, m, c int
	fmt.Scan(&n, &m, &c)
	b := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&b[i])
	}

	a := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
	}
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			fmt.Scan(&a[i][j])
		}
	}

	cnt := 0
	for i := 0; i < n; i++ {
		sum := 0
		for j := 0; j < m; j++ {
			sum += a[i][j] * b[j]
		}
		if sum > -c {
			cnt++
		}
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 1856
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 C = sc.nextInt();
      if(A==B&&B!=C){
        System.out.println("Yes");
        return;
      }
      if(A==C&&A!=B){
        System.out.println("Yes");
        return;
      }
      if(B==C&&A!=B){
        System.out.println("Yes");
        return;
      }
      System.out.println("No");
      

    }
  
  private static long lcm(long m, long n) {
    return m * n / gcd(m, n);
}
  
  private static long gcd(long m, long n) {
    if(m < n) return gcd(n, m);
    if(n == 0) return m;
    return gcd(n, m % n);
}
}


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

using namespace std;

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

        if(a <= b * 2){
                cout << "0" << endl;
        }
        else if (a > b * 2){
                cout << a - b * 2 << endl;
        }
        return 0;
}

Measured memory_bytes: 3572
n,m,x=map(int,input().split())
b=2**n
lst=[]
for i in range(n):
  lst.append(list(map(int,input().split())))
Cost=[]
for i in range(1,b+1):
  skill=[0]*m
  cost=0
  s=(str(bin(i))[2:]).zfill(n)
  for k in range(n):
    if s[k]=='1':
      for l in range(m):
        skill[l]+=lst[k][l+1]
      cost+=lst[k][0]
  for j in range(m):
    if skill[j]<x:
      break
    if j==m-1 and x<=skill[j]:
      Cost.append(cost)


if len(Cost)==0:
  print('-1')
else:
  print(min(Cost))
      

Measured memory_bytes: 85748
// https://atcoder.jp/contests/abc146/tasks/abc146_b

#include <bits/stdc++.h>
using namespace std;
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n'
#define int long long
#define all(x) (x).begin(), (x).end()

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

    int n;
    cin >> n;

    string s;
    cin >> s;

    for(char x: s) {
        char ree = (((x-'A')+n)%26)+'A';
        cout << ree;
    }
    cout << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    double ans;
    REP(i,N) cin >> A[i];
    REP(i,N){
        ans = ans + 1.0/A[i];
    }
    cout <<  setprecision(15) << 1/ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

	static Set<Integer> set=new TreeSet<Integer>();
	static Set<Integer> prime=new TreeSet<Integer>();
	static{
		int[] a={2,5};
		int idx=0;
		int gd=6;
		for(;gd<300000;){
			set.add(gd);
			gd+=a[idx];
			idx=1-idx;
		}
		idx=0;
		for(Integer b:set){
//			System.out.println(b);
			boolean p=true;
			for(Integer c:set){
				if(c*c>b)break;
//				System.out.println("  "+c);
				if(b%c==0&&set.contains(b/c)){
					p=false;
					break;
//					System.out.println(" "+b);
				}
			}
			if(p){
				prime.add(b);
//				System.out.println(b);
			}
		}
		
	}
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		for(;;){
			int n=cin.nextInt();if(n==1)break;
			System.out.print(n+":");
			for(Integer a:set){
				if(n%a==0&&prime.contains(a)){
					System.out.print(" "+a);
				}
			}
			System.out.println();
		}

	}

}

Measured memory_bytes: 37372
#include<bits/stdc++.h>
using namespace std;
int a[1000]= {0};
int number(int n){
    int i=0;
    while(n!=0){
        i++;
        n/=10;
    }
    return i;
}
int pan(int num){
    int i;
    for(i=1;i<=num/2;i++){
        if(i*i==num){
            return 1;
        }
    }
    return 0;
}
int main()
{
    long long int i,j,n,m;
    cin>>n>>m;
    int shu=number(m);
    int num=1;
    for(i=0;i<shu;i++){
        num*=10;
    }
    num*=n;
    num+=m;
    if(pan(num)==1)
        cout<<"Yes";
    else
        cout<<"No";
}


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

int main(){
  int n;
  cin >> n;
  vector<int> ans;
  int sum = 0;
  for(int i = 1; i <= n; i++){
    if(sum < n) {
      ans.push_back(i);
      sum += i;
    } else {
      break;
    } 
  }
  int s = sum - n;
  for(auto x : ans) {
    if(x != s) cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int I=X;I<Y;I++)
#define REP(I,X,Y) for(int I=Y-1;I>=X;I--)
#define INF 1000000007
using namespace std;

vector<int> data(100010,-1);

int root(int x){
  if(data[x] == -1)return x;
  else return data[x] = root(data[x]);
}

bool same(int x,int y){
  if(root(x) == root(y))return 1;
  else return 0;
}

int unite(int x,int y){
  if(!same(x,y))data[root(x)] = y;
  return 0;
}


int main(){
  int N,M,L,R,D;
  bool ans = 1;
  cin >> N >> M;
  vector<vector<pair<int,int>>> adj(N+1);
  int X[N+1];
  FOR(i,0,N+1)X[i] = INF;
  FOR(i,0,M){
    cin >> L >> R >> D;
    unite(L,R);
    adj[L].push_back(make_pair(R,D));
    adj[R].push_back(make_pair(L,-D));
  }
  set<int> s;
  FOR(i,1,N+1)s.insert(root(i));
  for(auto x:s){
    X[x] = 0;
    queue<int> que;
    que.push(x);
    while(que.size()){
      for(auto p:adj[que.front()]){
        if(X[p.first] == INF){
          que.push(p.first);
          X[p.first] = X[que.front()] + p.second;
        }
        else{
          if(X[p.first] != X[que.front()] + p.second)ans = 0;
        }
      }
      que.pop();
    }
  }
  if(ans)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 9728
#include <iostream>
#include <string>
using namespace std;
int res=0;
int main()
{
    int A,B,C,X;
    scanf("%d%d%d%d", &A, &B, &C, &X);
    for (int i = 0; i <= A; ++i) {
        for (int j = 0; j <= B; ++j) {
            for (int k = 0; k <= C; ++k) {
                int total=500*i+100*j+50*k;
                if(total==X) {
                    ++res;
            }
            }


            }
            }

        std::cout << res << '\n';
    }


Measured memory_bytes: 256
S = str(input())
S = list(S)

count = 0
list_count = []
for s in S:
    if s == 'A' or s == 'T' or s == 'C' or s == 'G':
        count += 1
        list_count.append(count)
    else:
        count = 0

if len(list_count) == 0:
    print('0')
else:
    print(max(list_count))

Measured memory_bytes: 3060
#include <iostream>
#include <complex>
#include <utility>
#include <vector>
using namespace std;

typedef complex<double> Point, Vector;
typedef pair<Point, Point> Segment, Line;
typedef vector<Point> Polygon;

#define X real()
#define Y imag()
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

double cross(Vector a, Vector b){
    return a.X * b.Y - a.Y * b.X;
}

double convexArea(Polygon pol){
    int n = pol.size();
    if(n == 0) return 0.0;
    Point basep = pol[0];

    double S = 0.0;
    for(int i=1; i<n-1; i++){
        Vector a = pol[i] - basep;
        Vector b = pol[i+1] - basep;
        S += cross(a, b) / 2;
    }

    return S;
}

int main(){
    int n; cin>>n;
    Polygon pol;
    while(n--){
        double x, y; cin>>x>>y;
        pol.emplace_back(x, y);
    }

    printf("%.1f\n", convexArea(pol));
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int a, b, sum = 0;
	cin >> a >> b;
	sum = a + b;
	if (sum % 3 == 0)
		cout << "Possible"<<endl;
	else if (sum == 0)
		cout << "Impossible"<<endl;
	else if (b % 3 == 0 || a % 3 == 0)
		cout << "Possible"<< endl;
	else
		cout << "Impossible"<<endl;
return 0;
}

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

int N;
ll A[100005][3];
ll dp[100005][3];

ll f (int i, int t)
{
	if (i == N) return 0;

	if (t != -1 && dp[i][t] != -1) return dp[i][t];

	ll ans = 0;
	for (int j = 0; j < 3; ++j)
		if (j != t)
			ans = max(ans, A[i][j] + f(i+1, j));

	return dp[i][t] = ans;
}

int main()
{
	ios::sync_with_stdio(false);
	memset(dp, -1, sizeof(dp));

	cin >> N;

	for (int i = 0; i < N; ++i)
		cin >> A[i][0] >> A[i][1] >> A[i][2];

	cout << f(0, -1) << endl;

	return 0;
}

Measured memory_bytes: 12800
#include<iostream>
#include <string>
#include<vector>

using namespace std;

int main(){

	int N,count =0;
	cin >> N;
	for(int i = 1; i <= N; i++){
		count = count + 800;
		if( i%15 == 0 ){
			count = count - 200;
		}
	}
	cout << count << endl;

	return 0;

}

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

int main() {
	string s;
	cin >> s;
	int ans = 0;
	stack<char>cube;
	for (int i = 0; i < s.length(); i++) {
		char t = s.at(i);
		if (cube.size() == 0)cube.push(t);
		else if (cube.top() != t) {
			ans++;
			cube.pop();
		}
		else cube.push(t);
	}
	ans *= 2;
	cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string.h>
using namespace std;

int D[100][6];
void spin(int n,char c)
{
  if(c=='E'){
    swap(D[n][0],D[n][3]);swap(D[n][3],D[n][5]);swap(D[n][5],D[n][2]);
  }
  else if(c=='W'){
    swap(D[n][0],D[n][2]);swap(D[n][2],D[n][5]);swap(D[n][5],D[n][3]);
  }
  else if(c=='S'){
    swap(D[n][0],D[n][1]);swap(D[n][0],D[n][4]);swap(D[n][4],D[n][5]);
  } 
  else if(c=='N'){
    swap(D[n][0],D[n][1]);swap(D[n][1],D[n][5]);swap(D[n][5],D[n][4]);
  }
}
int main()
{
  int n,an[100];
  char SWS[10]={"SSSSWSSSS"};
  cin>>n;
  for(int i=0;i<6;i++)cin>>D[0][i];
  for(int j=1;j<n;j++){
    for(int i=0;i<6;i++)cin>>D[j][i];
    for(int i=0;i<10;i++){
      if(D[0][1]==D[j][1])break;
      spin(j,SWS[i]);
    }
    if(D[0][1]!=D[j][1] || D[0][4]!=D[j][4])an[j]=0;
    else{
      for(int i=0;i<4;i++){
	if(D[0][0]==D[j][0] &&D[0][2]==D[j][2] &&D[0][3]==D[j][3] &&D[0][5]==D[j][5]){
	  an[j]=1;
	  break;
	}
	spin(j,'W');
	if(i==3)an[j]=0;
      }
    }
  }
  for(int i=1;i<n;i++){
    if(an[i]==1){
      cout<<"No"<<endl;
      break;
    }
    if(i==n-1)cout<<"Yes"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;
ll dp[4][2][105];

int main(){
    string s; cin >> s;
    int k; cin >> k;
    rep(i,4) rep(j,2) rep(l,105) dp[i][j][l] = 0;
    dp[0][1][0] = 1;
    for(int i=0;i<s.length();i++){
        int d = (int)(s[i]-'0');
        if(d==0){
            rep(j,k+1){
                dp[j][1][i+1] += dp[j][1][i];
            }
            rep(j,k){
                dp[j+1][0][i+1] += 9*dp[j][0][i];
            }
            rep(j,k+1){
                dp[j][0][i+1] += dp[j][0][i];
            }
        }else{
            rep(j,k){
                dp[j+1][1][i+1] += dp[j][1][i];
            }
            rep(j,k){
                dp[j+1][0][i+1] += 9*dp[j][0][i];
                dp[j+1][0][i+1] += (d-1)*dp[j][1][i];
            }
            rep(j,k+1){
                dp[j][0][i+1] += dp[j][0][i];
                dp[j][0][i+1] += dp[j][1][i];
            }
        }
    }
    cout << dp[k][1][s.length()] + dp[k][0][s.length()] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

template <typename T> T mod_div (T a, T b, T m);

int main() {
	uint N, K;
	cin >> N >> K;
	
	vector<int> A(N);
	for(uint i=0; i<N; i++) cin >> A[i];
	
	if(K == 1) {
		cout << 0;
		return 0;
	}
	
	sort(A.begin(), A.end());

	ll mod = pow(10, 9) + 7;

	ll ans = 0;
	ull cmb = 1;
	ll maxS = accumulate(A.begin() + (K - 1), A.end(), (ll)0);
	ll minS = accumulate(A.begin(), A.end() - (K - 1), (ll)0);
	
	for(uint i=K; i<=N; i++) {
		if(K - 2 > 0 && i > K) {
			cmb = cmb * (i - 2) % mod;
			cmb = mod_div(cmb, (ull)(i - K), (ull)mod);
		} else {
			cmb = 1;
		}			
		
		//cout << i << " " << maxS << " " << minS << " " << cmb << endl;
		
		ll fX = (maxS - minS) % mod;
		fX = (fX * cmb) % mod;
		ans = (ans + fX) % mod;
		
		maxS -= A[i-1];
		minS -= A[N-i];
		
	}
	
	cout << ans;
	
	return 0;
}

template <typename T> T mod_pow(T n, T r, T m) {
	T ret = 1;
	T tmp = n;
	
	while(r != 0) {
		if(r % 2) {
			ret *= tmp;
		}
		tmp *= tmp;
		tmp %= m;
		ret %= m;
		r /= 2;
	}
	return ret;
}

template <typename T> T mod_inv (T a, T m) {
	return mod_pow(a, m - 2, m);
}

template <typename T> T mod_div (T a, T b, T m) {
	return a * mod_inv(b, m) % m;
}

Measured memory_bytes: 640
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
xyu = [readChars() for i in range(n)]

class mydict:
	def __init__(self):
		self.d = {}
	def add(self,key,value):
		if key in self.d:
			self.d[key].append(value)
		else:
			self.d[key]=[value]
	def p(self):
		print("{")
		for key in self.d:
			print(key,self.d[key])
		print("}")
	def mysort(self):
		for i in self.d:
			self.d[i].sort()
	def getDict(self):
		return self.d;

ud = mydict()
rl = mydict()
for x,y,u in xyu:
	if u=="U" or u=="D":
		ud.add(int(x),[int(y),u])
	else:
		rl.add(int(y),[int(x),u])
ud.mysort()
rl.mysort()
#ud.p()
#rl.p()
ans = float("inf")

tar = ud.getDict()
for key in tar:
	beu = "-1"
	bev = "-1"
	for v in tar[key]:
		if beu=="U" and v[1]=="D":
			ans = min(ans,(int(v[0])-int(bev))*5)
		beu = v[1]
		bev = v[0]
tar = rl.getDict()
for key in tar:
	s = ""
	beu = "-1"
	bev = "-1"
	for v in tar[key]:
		if beu=="R" and v[1]=="L":
			ans = min(ans,(int(v[0])-int(bev))*5)
		beu = v[1]
		bev = v[0]

xy = mydict()
for x,y,u in xyu:
	xy.add(int(x)+int(y),[int(x),u])
#xy.p()
xy.mysort()
d = xy.getDict()
for key in d:
	beu = "-1"
	bex = -1
	for arr in d[key]:
		if beu=="R" and arr[1]=="U":
			ans = min(ans,(arr[0]-bex)*10)
		if beu=="D" and arr[1]=="L":
			ans = min(ans,(arr[0]-bex)*10)
		beu = arr[1]
		bex = arr[0]
mxy = mydict()
for x,y,u in xyu:
	mxy.add(int(y)-int(x),[int(x),u])
mxy.mysort()
#mxy.p()
d = mxy.getDict()
for key in d:
	beu = "-1"
	bex = -1
	for arr in d[key]:
		if beu=="R" and arr[1]=="D":
			ans = min(ans,(arr[0]-bex)*10)
		if beu=="U" and arr[1]=="L":
			ans = min(ans,(arr[0]-bex)*10)
		beu = arr[1]
		bex = arr[0]

if ans==float("inf"):
	print("SAFE")
else:
	print(ans)




Measured memory_bytes: 239916
N, M, K = map(int, input().split())
A_list=list(map(int, input().split()))
B_list=list(map(int, input().split()))

import itertools
A_acum=list(itertools.accumulate(A_list))
B_acum=list(itertools.accumulate(B_list))
A_acum.insert(0, 0)
B_acum.insert(0, 0)


"""
A_acum=[0]
B_acum=[0]
for i in range(1, N+1):
	A_acum[i]=A_acum[i-1]+A_list[i-1]
for j in range(1, M+1):
	B_acum[i]=B_acum[i-1]+B_list[i-1]
"""
ans=0
j=M
for i in range(len(A_acum)): #iは読んだAの本の数
	if K<A_acum[i]:
		break
	res = K - A_acum[i] #残り時間

	while res<B_acum[j] and j>0:
		j-=1

	ans=max(ans, i+j)

print(ans)





Measured memory_bytes: 47600
n = gets.to_i
atoz = ("a".."z")
ans = atoz.each_with_object({}) { |c, h| h[c] = 50 }

n.times do
  s = gets.chomp
  ans.each do |k, v|
    count = s.count(k)
    ans[k] = count if count <= v
  end
end

puts ans.map { |k, v| k * v }.join


Measured memory_bytes: 14192
import java.util.*;
import java.lang.*;
import java.io.*;
class Main
{
    static int dp[];
    static ArrayList<Integer>arr;
    public static void main (String[] args)
    {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        if(n>=1000 && n<=1998){
            System.out.println("ABD");
        }else{
            System.out.println("ABC");
        }
    }
}

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

namespace practice
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int n  = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            List<int> nums = new List<int>();
            for(int i = 0;i < n; i++)
            {
                nums.Add(int.Parse(input[i]));
            }
            for(int j = n-1;j >= 1;j--)
            {
                Console.Write(nums[j] + " ");
            }
            Console.WriteLine(nums[0]);
        }
    }
}


Measured memory_bytes: 17940
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
from decimal import *
        
N = INT()

w = []

n = "a"

def DFS(n):
    if len(n) == N:
        w.append(n)
    else:
        for i in range(len(set(n))+1):
            m = n + ascii_lowercase[i]
            DFS(m)

DFS(n)
print(*w, sep= "\n")


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, c;
    cin >> n >> c;

    vector<vector<int64_t>> u(2 * 100000L + 1, vector<int64_t>(c));
    for (auto i : irange(0L, n)) {
        int64_t s, t, c;
        cin >> s >> t >> c;
        --c;

        s *= 2;
        t *= 2;

        if (u[s][c] == 0) {
            u[s - 1][c] = 1;
        } else {
            ++u[s][c];
        }

        if (u[t - 1][c] == 1) {
            u[t - 1][c] = 0;
            ++u[t][c];
        }
        --u[t][c];
    }

    int64_t d = 0, ans = 0;
    for (const auto& uu : u) {
        d = accumulate(uu.begin(), uu.end(), d);

        ans = max(ans, d);
    }

    cout << ans << endl;
}

Measured memory_bytes: 54912
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	h := nextInt()
	n := nextInt()
	alist := make([]int, n)

	asum := 0
	for i := 0; i < n; i++ {
		alist[i] = nextInt()
		asum += alist[i]
	}

	if asum < h {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1920
// 未解決

#include <bits/stdc++.h>

#include <iostream>
using namespace std;

#define EACH(i, a) for (auto &&i : a)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RFOR(i, a, b) for (int i = (int)b - 1; i >= (int)a; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREPS(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(x) (x).begin(), (x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF (1L << 30)
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << *i << " ";
  cout << endl;
}
template <class T>
void pvp(T a, T b) {
  for (T i = a; i != b; ++i)
    cout << "(" << i->first << ", " << i->second << ") ";
  cout << endl;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}

using ll = long long;
#define int ll

//**********

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

  int r;
  cin >> r;
  cout << r * 3.1415926535 * 2 << endl;

  return 0;
};


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

int num, land[1080][1080];
int xs[] = { 1, 1, 0, -1, -1, -1, 0, 1 };
int ys[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
void dfs(int x, int y) {
    land[x][y] = 0;
    for (int i = 0; i < 8; i++) {
        int tx = x + xs[i];
        int ty = y + ys[i];
        if (land[tx][ty])dfs(tx, ty);
    }
}

int main() {
    int w, h;
    while (1) {
        cin >> h >> w;
        if (w == 0 || h == 0)
            break;
        num = 0;
        for (int i = 1; i <= w; i++) {
            for (int j = 1; j <= h; j++) {
                cin >> land[i][j];
            }
        }
        for (int i = 1; i <= w; i++) {
            for (int j = 1; j <= h; j++) {
                if (land[i][j]) {
                    num++;
                    dfs(i, j);
                }
            }
        }
        cout << num << endl;
    }
    return 0;
}

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

int n;

void call(){
	int i = 1;
	while( ++i <= n ){
		int x = i;

		if( x % 3 == 0 ){
			cout << " " << i;
			continue;
		}

		while( x != 0){
			if( x % 10 == 3){
				cout << " " << i;
				break;
			}
			x /= 10;
		}
	}

	cout << endl;
}

int main(void){
	cin >> n;

	call();

	return 0;
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	string s;
	cin>>s;
	int n = s.length();
	for(int i=0;i<n-1;i++){
		if(s[i] == s[i+1]){
			printf("Bad\n");
			return 0;
		}
	}
	printf("Good\n");
	return 0;
};

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int a, b;
  while (cin >> a >> b) {
    int deg[100] = {};
    deg[0]++; deg[1]++;
    deg[a - 1]++; deg[b - 1]++;
    while (cin >> a >> b, a) {
      deg[a - 1]++; deg[b - 1]++;
    }
    bool ok = true;
    for (int i = 0; i < 100; i++) {
      ok &= deg[i] % 2 == 0;
    }
    cout << (ok ? "OK" : "NG") << endl;
  }

  return 0;
}


Measured memory_bytes: 3140
#include<stdio.h>

int main(void){
    int A,B,i,j;
    int sum,sub,mul;
    int a[3];
    scanf("%d%d",&A,&B);
    sum = A+B;
    sub = A-B;
    mul = A*B;
    // printf("%d %d %d\n",sum,sub,mul);
    a[0] = sum;
    a[1] = sub;
    a[2] = mul;
    for(i=0;i<2;i++){
        for(j=i+1;j<3;j++){
            if(a[i]<a[j]){
                int t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
        }
    }
    printf("%d\n",a[0]);
    return 0;
}

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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define REP64(i, s,  n) for(int64 i = s;i < (n);i++)
#define INF 999999999
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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

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

//---------------------------------------------------------------
//---------------------------------------------------------------

int N, MA, MB;
int A[50],B[50],C[50];

int dp[50][500][500];

int NOT_FOUND = 888888;

int check(int i, int a, int b) {
//    cout << "start --> [" << i << "][" << a <<"][" << b << "]" << endl;
	if(dp[i][a][b] != INF)	{
//	    cout << "return from dp : " << dp[i][a][b] << endl;
	    return dp[i][a][b];
	}
	if((a != 0 || b != 0) and  a * MB == b * MA) {
//	    cout << "return 0" << endl;
	    return 0;
	}
	if(i >= N) {
//	    cout << "return NOT_FOUND" << endl;
	    return NOT_FOUND;
	}
	int ans = min(check(i+1, a + A[i], b + B[i]) + C[i], check(i+1, a, b));
	dp[i][a][b] = ans;
	
//    cout << "end  --> [" << i << "][" << a <<"][" << b << "] = " << ans << endl;
	return ans;
}

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

	cin >> N >> MA >> MB;
	REP(i, 0, N)	cin >> A[i] >> B[i] >> C[i];
	
	REP(i, 0, 50)	REP(j, 0, 500)	REP(k, 0, 500)	dp[i][j][k] = INF;
	
	int ans = check(0, 0, 0);
	if(ans == NOT_FOUND)	ans = -1;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 49152
n = int(input())
c = 0
p = list(map(int, input().split(' ')))
for i in range(1, n - 1):
    if p[i - 1] < p[i] < p[i + 1] or p[i + 1] < p[i] < p[i - 1]:
        c += 1
print(c)

Measured memory_bytes: 2940
//use std::convert::TryInto;
#![allow(dead_code)]

fn main(){
    input::<usize>();
    let mut ai: Vec<usize> = input_vec();

    ai.sort();
    let mut sieve = vec![0; 1000001];
    for &e in &ai {
        if sieve[e]>1 {continue;}
        let mut c = 0;
        while c < 1000001 {
            sieve[c] += 1;
            c += e;
        }
    }

    let mut count = 0;
    for &e in &ai {
        if sieve[e] == 1 {
            count += 1;
        }
    }
    println!("{}", count);
}

fn print_all(v: &Vec<i32>){
    for val in v {
        println!("v: {}", val);
    }
}


/*
 * input function
 */
fn input<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


fn input_vec<T: std::str::FromStr>() -> Vec<T> {
    input::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap()).collect()
}

fn input_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| input_vec()).collect()
}

Measured memory_bytes: 8300