akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define repi(i, n) for (int i = 0; i < (int)(n); i++)
#define repd(i, n) for (int i = (int)(n); i >= 0; i--)

int main() {
  int D, N;
  cin >> D >> N;
  if(N < 100){
      cout << int(pow(100, D) * N) << endl;
  }else{
      cout <<  int(pow(100, D) * 101)<< endl;
  }
  return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

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

        try{
            //入力
            int N = scan.nextInt();
            int[] h_ = new int [N];
            int sum = 0;
            for(int i = 0; i < N; i++){
                sum += h_[i] = scan.nextInt();
            }

            int count = 0;
            while(sum != 0){
                int l = getLeft(h_, N);
                int r = getRight(h_, N, l);
                for(int i = l; i <= r; i++){
                    h_[i]--;
                }
                sum -= r-l+1;
                count++;
            }

            System.out.println(count);

        }finally{
            scan.close();
        }
    }

    //左端取得
    static int getLeft(int[] h, int N){
        int l = 0;
        for(int i = 0; i < N; i++){
            if(h[i] != 0){
                l = i;
                break;
            }else{
            }
        }
        return l;
    }
    //右端取得
    static int getRight(int[] h, int N, int l){
        int r = 0;
        for(int i = l; i < N; i++){
            if(h[i] == 0){
                r = i-1;
                break;
            }else if(i == N-1){
                r = N-1;
            }
        }
        return r;
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    long long int N, K;
    long long int sum = 0;
    cin >> N >> K;
    vector<long long int> vec(N);
    
    if (K >= N) {
        cout << sum << endl;
        return 0;
    }
    
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    
    for (int i = 0; i < vec.size() - K; i++) {
        sum += vec.at(i);
    }
    cout << sum << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include<ctime>
#include<random>
#include<cstring>
#include<cstdlib>
#include<cstdint>
#include<fstream>
#include<strstream>
#include<vector>
#include<string>
#include<chrono>
#include<algorithm>

//#include "D:\Code\C++\Headers\zle_STL.h"
//#include "D:\Code\C++\Headers\zle_OLD.h"

#define ll long long

using namespace std;

int main() {
	string S;
	string T;
	cin >> S >> T;
	int ans = 0;
	for (int c = 0; c < S.size(); c++) {
		if (S[c] != T[c]) {
			ans++;
		}
	}
	cout << ans;
}


Measured memory_bytes: 3448
N = int(input())
A = [int(i) for i in input().split()]

Frag = True

for i in range(N):
    if A[i] % 2 == 1 or A[i] % 6 == 0 or A[i] % 10 == 0:
        pass
    else:
        Frag = False

if Frag == True:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int N;
    cin >> N;

    int x = 0;
    int y = 0;
    int last_t = 0;

    FOR(i, 0, N){
        int next_t, next_x, next_y;
        cin >> next_t >> next_x >> next_y;

        int t = next_t - last_t;

        int dist = abs(x - next_x) + abs(y - next_y);
        if(t >= dist){
            // 行ける
            int t_diff = t - dist;
            if(t_diff % 2 == 1){
                p("No");
                return 0;
            }else{
                // 無事行けた
                x = next_x;
                y = next_y;
                last_t = next_t;
            }
        }else{
            // 間に合わない
            p("No");
            return 0;
        }
    }
    p("Yes");
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int A = int.Parse(str[1]);
        int B = int.Parse(str[2]);
        int C = int.Parse(str[3]);
        int D = int.Parse(str[4]);
        long[,] DP = new long[B-A+2,N+1];
        Fact F = new Fact(10000);
        DP[0,0] = 1;
        for(int i=0;i<=B-A;i++){
            int d = A+i;
            long division = 1;
            for(int j=0;j<=D;j++){
                if(j == 0 || j >= C){
                    for(int k=0;k+j*d<=N;k++){
                        DP[i+1,k+j*d] = (DP[i+1,k+j*d] + DP[i,k]*F.GetConv(k+j*d,k)%Define.mod*division%Define.mod*F.rf[j]%Define.mod) % Define.mod;
                    }
                }
                if(j*d > N){
                    break;
                }
                division = division * F.GetConv((j+1)*d,d) % Define.mod;
            }
        }
        sb.Append(DP[B-A+1,N]+"\n");
    }
}
class Fact{
    public long[] f;
    public long[] rf;
    public Fact(int N){
        f = new long[N+1];
        rf = new long[N+1];
        for(int i=0;i<N+1;i++){
            if(i == 0){
                f[i] = 1;
            }
            else{
                f[i] = (f[i-1]*i)%Define.mod;
            }
        }
        for(int i=N;i>=0;i--){
            if(i == N){
                rf[i] = pow(f[N],Define.mod-2);
            }
            else{
                rf[i] = rf[i+1]*(i+1)%Define.mod;
            }
        }
    }
    public long pow(long N,long K){
        if(K == 0){
            return 1;
        }
        else if(K % 2 == 0){
            long t = pow(N,K/2);
            return t*t%Define.mod;
        }
        else{
            return N*pow(N,K-1)%Define.mod;
        }
    }
    public long GetFact(int N){
        return f[N];
    }
    public long GetConv(int N,int R){
        return ((f[N]*rf[R])%Define.mod*rf[N-R])%Define.mod;
    }
}
public static class Define{
    public const long mod = 1000000007;
}

Measured memory_bytes: 18912
n =int(input())
a =int(input())
b =int(input())
c =int(input())
d =int(input())
e =int(input())
sample_list = []
sample_list.append(a)
sample_list.append(b)
sample_list.append(c)
sample_list.append(d)
sample_list.append(e)
z = 4
if n % min(sample_list) == 0:
  x = n // min(sample_list)
  print(z + x)
else:
  y = n // min(sample_list)
  print(z + y + 1)

    






Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;


int main() {
    
    
    int n;
    cin >> n;
    vector<int> v(n);
    map<int, int> m0;
    map<int, int> m1;
    
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
        if (i % 2)
        {
            m1[v[i]]++;
        }
        else
        {
            m0[v[i]]++;
        }
    }
    
    vector<pair<int, int>> mpv0;
    vector<pair<int, int>> mpv1;
    
    for (auto itr = m0.begin(); itr != m0.end(); ++itr)
    {
        mpv0.push_back(make_pair((n / 2) - itr->second, itr->first));
    }
    
    for (auto itr = m1.begin(); itr != m1.end(); ++itr)
    {
        mpv1.push_back(make_pair((n / 2) - itr->second, itr->first));
    }
    sort(mpv0.begin(), mpv0.end());
    sort(mpv1.begin(), mpv1.end());
    
    int ret = mpv0[0].first + mpv1[0].first;
    if (mpv0[0].second == mpv1[0].second)
    {
        if (mpv0.size() < 2 || mpv1.size() < 2)
        {
            ret = min(mpv0[0].first + (n / 2), (n / 2) + mpv1[0].first);
        }
        else
        {
            ret = min(mpv0[0].first + mpv1[1].first, mpv0[1].first + mpv1[0].first);
        }
    }
    
    
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 6520
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	static int N = 3;
	static int N2 = 9;

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

	private void run() {
		Scanner scanner = new Scanner(System.in);
		Puzzle puzzle = new Puzzle();
		for (int i = 0; i < N2; i++) {
			int v = scanner.nextInt();
			puzzle.map[i] = v;
			if (v == 0) {
				puzzle.space = i;
			}
		}
		System.out.println(slove(puzzle));
	}

	int[][] dxy = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

	private int slove(Puzzle in) {
		Puzzle u = new Puzzle();
		Puzzle v = new Puzzle();
		Deque<Puzzle> deque = new ArrayDeque<Puzzle>();
		Set<Puzzle> set = new HashSet<Main.Puzzle>();
		set.add(in);
		deque.offer(in);
		while (!deque.isEmpty()) {
			u = deque.poll();
			if (isTrue(u)) {
				return u.count;
			}
			int y = u.space / N;
			int x = u.space % N;
			for (int[] a : dxy) {
				int dy = y + a[0];
				int dx = x + a[1];
				if (dy < 0 || dx < 0 || N <= dy || N <= dx)
					continue;
				v = u.clone();
				swap(v, u.space, dy * N + dx);
				v.space = dy * N + dx;
				if (!set.contains(v)) {
					set.add(v);
					v.count++;
					deque.offer(v);
				}
			}
		}
		return -1;
	}

	private boolean isTrue(Puzzle u) {
		for (int i = 0; i < N2 - 1; i++) {
			if (u.map[i] != i + 1) {
				return false;
			}
		}
		return true;
	}

	private void swap(Puzzle v, int space, int i) {
		int t = v.map[i];
		v.map[i] = v.map[space];
		v.map[space] = t;

	}
	class Puzzle implements Cloneable {
		int[] map = new int[N2];
		int space;
		int count = 0;

		@Override
		public Puzzle clone() {
			try {
				Puzzle clonePuzzle = (Puzzle) super.clone();
				clonePuzzle.map = Arrays.copyOf(map, N2);
				return clonePuzzle;
			} catch (CloneNotSupportedException e) {
				throw new InternalError();
			}
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + getOuterType().hashCode();
			result = prime * result + Arrays.hashCode(map);
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Puzzle other = (Puzzle) obj;
			if (!getOuterType().equals(other.getOuterType()))
				return false;
			if (!Arrays.equals(map, other.map))
				return false;
			return true;
		}

		private Main getOuterType() {
			return Main.this;
		}

	}
}



Measured memory_bytes: 80928
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
 
int main(){
    int A, B;
    cin >> A;
    cin >> B;
    cout << 6 - A - B << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[1001];
	int i, len, ans;
	
	while(1){
		ans=0;
		scanf("%s",&str);
		if(str[0]== '0')break;
		len = strlen(str);
		for (i = 0; i < len; i++) {
			ans += (str[i] -'0');
		}
		printf("%d\n",ans);
	}
		
	return 0;
}


Measured memory_bytes: 2076
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {

	long double dt = 0.006;

	in(ll, N, T, A);

	ll dm = INF;
	ll p = 0;
	loop(i, N) {
		in(ll, H);
		auto d = abs(A * 1000 - (T * 1000 - H * 6));
		if (dm > d) {
			p = i;
			dm = d;
		}
	}

	out(p + 1);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.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; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))

int main() {

    // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

	int N; 
	string S;
	cin >> N >> S;
	int res = 0;
	for (int i = 0; i < N - 2; i++) {
		if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
			++res;
		}
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
template <typename T> inline void read(T &x)
{
	int f = 1; x = 0; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
	x *= f;
}
const int N = 2e5 + 5;
int n, a[N];
int main(){
	read(n);
	for (int i = 1; i <= n; i++) read(a[i]);
	
	LL ans = 0;
	int maxv = 0;
	for (int i = 1; i <= n; i++)
	{
		if (a[i] < maxv)
		{
			ans += maxv - a[i];
			a[i] = maxv;
		}
		maxv = max(maxv, a[i]);
	}
	printf ("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 4392
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;


typedef vector<pair<int, int>> vpi;
typedef vector<tuple<int, int, int>> vti;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, d, i, j, k;
    cin >> n >> d;
    vvi x(n, vi(d));
    for (i=0;i<n;i++) for (j=0;j<d;j++){
        cin >> x[i][j];
    }
    int cnt = 0;
    for (i=0;i<n-1;i++){
        for (j=i+1;j<n;j++){
            float dist = 0;
            for (k=0;k<d;k++){
                dist += pow(x[i][k] - x[j][k], 2);
            }
            dist = sqrt(dist);
            if (floor(dist) == dist) cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<cctype>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;int k;
inline LL read()
{
	char c;LL d=1,f=0;
	while(c=getchar(),!isdigit(c)) if(c=='-') d=-1;f=(f<<3)+(f<<1)+c-48;
	while(c=getchar(),isdigit(c)) f=(f<<3)+(f<<1)+c-48;
	return d*f;
}
signed main()
{
	k=read();
	for(register int i=1;i<=k;i++) printf("ACL");
}

Measured memory_bytes: 1584
#include <cstdio>
#include <cstring>

#define N 100005

int n;
int lch[3][N], rch[3][N];
char s[N];

int gao(int flag, int l, int r) {
    if (l < 0 || r < 0 || l >= r) return 0;
    int cnt = 0, p = -10, node = ++n;
    for (int i = l + 1; i < r; ++i) {
        if (0 == cnt && s[i] == ',') {
            p = i;
            break;
        }
        if ('(' == s[i]) ++cnt;
        if (')' == s[i]) --cnt;
    }
    lch[flag][node] = gao(flag, l + 1, p - 1);
    rch[flag][node] = gao(flag, p + 1, r - 1);
    return node;
}

int gaogao(int v1, int v2, int flag) {
    if (0 == flag) {
        if (0 == v1 && 0 == v2) return 0;
    } else {
        if (0 == v1 || 0 == v2) return 0;
    }
    int node = ++n;
    lch[2][node] = gaogao(lch[0][v1], lch[1][v2], flag);
    rch[2][node] = gaogao(rch[0][v1], rch[1][v2], flag);
    return node;
}

void zaigao(int flag, int x) {
    putchar('(');
    if (lch[flag][x]) zaigao(flag, lch[flag][x]);
    putchar(',');
    if (rch[flag][x]) zaigao(flag, rch[flag][x]);
    putchar(')');
}

int main() {
    char op[10];
    while (EOF != scanf("%s", op)) {
        memset(lch, 0, sizeof(lch));
        memset(rch, 0, sizeof(rch));
        n = 0;
        scanf("%s", s);
        int root1 = gao(0, 0, strlen(s) - 1);
        scanf("%s", s);
        int root2 = gao(1, 0, strlen(s) - 1);
        int root = gaogao(root1, root2, op[0] == 'i');
        zaigao(2, root);
        puts("");
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
using namespace std;
int main(void)
{
	int  n,a;
	cin >> n;
	vector<int> num(n);
	for(int i=0;i<n;i++) cin >> num[i];
	for(int i=0;i<n;i++){
		for(int j=i;0<j;j--){
			if(num[j]<num[j-1]){
				a=num[j-1];
				num[j-1]=num[j];
				num[j]=a;
			}
		}
		cout << num[0];
		for(int j=1;j<n;j++){
			cout << " " << num[j];
		}
		cout << endl;
	} 
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

template <class T> T up(T a, T div) { return (a + div - 1) / div; }

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

    ll N, C, K;
    cin >> N >> C >> K;
    vector<ll> v(N);
    for (auto &&i : v) {
        cin >> i;
    }
    ll ans = 0;
    SORT(v);

    ll mn  = v[0];
    ll cap = 1;
    FOR(i, 1, N) {
        if (cap < C && v[i] <= mn + K) {
            cap++;
        } else {
            ans++;
            cap = 1;
            mn  = v[i];
        }
    }
    if (0 < cap)
        ans++;

    print(ans);

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<deque>
#include<string>
#include<stdio.h>
using namespace::std;
#define int long long
int  v[3001][3001][2];
vector<int> d;
int dp(int l, int r, int f)
{
	if (l == r)
		return d[r];
	if (v[l][r][f] == 0)
		v[l][r][f] = max(-dp(l + 1, r, f ^ 1) + d[l], -dp(l, r - 1, f ^ 1) + d[r]);
	return v[l][r][f];

 }
signed main()
{
	int n;
		cin >> n;
	d.resize(n);

	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		d[i] = x;
	}

cout << dp(0, n - 1, 1);
}
/*
2 3

0 - 0
1 - 0
2 - 1
3 - 1
4 - 1
5 - 0

*/






Measured memory_bytes: 139776
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 1e5;
const ll bits = 62;
const ll mod = 1e9+7;
const ld pi = 3.14159265358979323846;

struct item{
    ll a,b;

    bool operator < (item other){
        return a < other.a;
    }
};

ll dp[N];


int main(){
    FASTIO;
    PRECISION;

    ll h,n;
    cin>>h>>n;

    vector<item>arr(n);

    for(int i=0;i<n;i++){
        cin>>arr[i].a>>arr[i].b;
    }

    // sort(arr.begin(),arr.end());

    for(int i=0;i<=h;i++){
        dp[i] = inf;
    }

    dp[h]=0;

    for(int i=h;i>=0;i--){
        for(int j=0;j<n;j++){
            // if(i+arr[j].a<=h)
            dp[i] = min(dp[i],arr[j].b + dp[min(h,i+arr[j].a)]);
        }
    }



    cout<<dp[0]<<"\n";

    

}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    const int H = 99, W = 99;
    vector<string> res(H, string(W, '#'));

    vector<pair<int, int>> white, black;

    for (int r = 0; r < H; r++) {
        res[r][0] = '.';
        if (r % 6 < 3) {
            for (int c = 1; c < W - 1; c++)
                res[r][c] = '.';
        }
        if (r % 3 == 1) {
            for (int c = 2; c < W - 2; c += 2) {
                (r % 6 == 1 ? black : white).emplace_back(r, c);
            }
        }
    }

    assert(white.size() >= 499 && black.size() >= 499);

    int A, B;
    cin >> A >> B;
    for (int w = 0; w < A - 1; w++) {
        res[white[w].first][white[w].second] = '.';
    }
    for (int w = 0; w < B - 1; w++) {
        res[black[w].first][black[w].second] = '#';
    }

    cout << H << " " << W << "\n";
    for (string str : res)
        cout << str << "\n";

    return 0;
}



Measured memory_bytes: 256
import java.util.*;


public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    long ans = 0;
    long[] p = new long[n+1];
    for (int i =1; i<=n; i++){
      
      for(int j =i; j<=n; j+=i){
        p[j] += 1;
      }
      ans += p[i] * i;
    }
    System.out.println(ans);
    
    scanner.close();
    return;
  }
}


Measured memory_bytes: 116052
N=int(input())
a=list(map(int,input().split()))

a.sort(reverse=True)

pt_alice = 0
pt_bob = 0
alices_turn = True
for i in range(N):
    if alices_turn:
        pt_alice += a[i]
    else:
        pt_bob += a[i]
    alices_turn = not alices_turn

print(pt_alice-pt_bob)

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

int N;

int main(){
  cin >> N;

  for(int i = 1; i < 10; i++){
    for(int j = 1; j < 10; j++){
      if(i * j == N){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//int v[100001],v1[100001];
string a[100005],b;

int main()
{
    ll c,d,e,sum=0;
    cin>>c;
    for(int i=0; i<c; i++)
    {
        cin>>a[i];
        sort(a[i].begin(),a[i].end());
    }
    sort(a,a+c);
    int sum1=0;
    for(int i=1; i<c; i++)
    {
        //cout<<a[i]<<endl;
        if(a[i]==a[i-1])
        {
            sum1++;
            sum+=sum1;
        }
        else
        {
            sum1=0;
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 7296
codePlace, implePlace = map(int, input().split(" "))

priceDict = {
    1:300000,
    2:200000,
    3:100000
}

totalPrice = priceDict[codePlace] if codePlace in priceDict.keys() else 0
totalPrice += priceDict[implePlace] if implePlace in priceDict.keys() else 0
totalPrice += 400000 if codePlace == 1 and implePlace == 1 else 0

print(totalPrice)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        while(s.hasNextInt()) {
            int m = s.nextInt();
            int f = s.nextInt();
            int r = s.nextInt();
            int sum = m + f;
            char ret = 'F';
            if(m == -1 && f == -1 && r == -1) {
                return;
            } else if(m == -1 || f == -1) {
                ret = 'F';
            } else if(sum >= 80) {
                ret = 'A';
            } else if(sum >= 65) {
                ret = 'B';
            } else if(sum >= 50 || (sum >= 30 && r >= 50)) {
                ret = 'C';
            } else if(sum >= 30) {
                ret = 'D';
            }
            System.out.println(ret);
        }
    }
}

Measured memory_bytes: 19452
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>

using namespace std;

int parent[100000];

void init(int N){
    for(int i = 0; i < N; i++){
        parent[i] = i;
    }
}

int find(int node){
    int temp = parent[node];
    if(temp == node){
        return temp;
    }
    else{
        int newParent = find(temp);
        parent[node] = newParent;
        return newParent;
    }
}

void unite(int i, int j){
    int pi = find(i);
    int pj = find(j);

    if(pi != pj){
        parent[pi] = pj;
    }
}

int main(){

    int N, M;
    cin >> N >> M;

    init(N);

    int X, Y, Z;
    for(int i = 0; i < M; i++){
        cin >> X >> Y >> Z;
        unite(X - 1, Y - 1);
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        if(parent[i] == i){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a) (a).begin(),(a).end()
#define ll long long
long long min(long long x,long long y){return (x<y ? x:y);}
long long max(long long x,long long y){return (x>y ? x:y);}
#define ld long double
int stoi(string s) {return atoi(s.c_str());}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
#define LINEY "YES\n"
#define Liney "Yes\n"
#define LINEN "NO\n"
#define Linen "No\n"

//1---2---3---4

int main(){
  int num_e[4];  REP(i,4){num_e[i]=0;}
  int a,b;
  REP(i,3){
    cin >> a>>b;
    num_e[a-1]++;
    num_e[b-1]++;
  }
  bool r = true;
  REP(i,4){
    if(num_e[i]>2){r =false;break;}
  }
  cout << (r?LINEY:LINEN);
  
}

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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

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

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
signed main(){
	int n;
	cin>>n;
	int a[5];
	rep(i,5)a[i]=-1;
	int m;
	cin>>m;
	bool re=true;
	rep(i,m){
		int s,c;
		cin>>s>>c;
		s--;
		if(a[s]==-1||a[s]==c)a[s]=c;
		else re=false;
	}
	if(n>1){
		if(a[0]==0)re=false;
		else if(a[0]==-1&&n)a[0]=1;
	}
	if(re==false){
		cout<<-1<<endl;
		return 0;
	}
	rep(i,n){
		if(a[i]==-1)cout<<0;
		else cout<<a[i];
	}
	cout<<endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())

cnt = [0] * (n + 1)

for i in range(1, n + 1):
    cnt[i % k] += 1

if k % 2 == 0:
    ans = 0
    ans += cnt[0] * cnt[0] * cnt[0]
    if k // 2 <= n:
        ans += cnt[k // 2] * cnt[k // 2] * cnt[k // 2]
    print(ans)
else:
    print(cnt[0] * cnt[0] * cnt[0])



Measured memory_bytes: 64740
import numpy as np
import sys
#import copy


def xnxn(n=0):
    """
    args:
        int n: a number of lows to read
    example:
        input   1
        retrun  1

        input   1 2 3
        return  [1,2,3]
        input   1 2 3
                4
        return  [[1,2,3],
                [4]]
    """
    if n == 0:
        temp = list(map(int, input().split()))
        if len(temp) == 1:
            return temp[0]
        elif len(temp) > 1:
            return temp
    else:
        temp = [list(map(int, input().split())) for _ in range(n)]
        return temp


def sp_xnxn(n=0):
    """
    args:
        int n: a number of lows to read
    example
        input   1
        retrun  [1]

        input   123
        return  [1,2,3]

        input   123
                4
        return  [[1,2,3],
                [4]]
    """
    if n == 0:
        return [int(k) for k in xsxs()]
    else:
        return [[int(k) for k in xsxs()] for _ in range(n)]


def xsxs(n=0):
    """
    args:
        int n: a number of lows to read
    example:
        input   AA
        retrun  AA

        input   A BBB CC
        return  ["A","BBB","CC"]

        input   A BB CCC
                D
        return  [["A","BBB","CC"],
                ["D"]]
    """
    if n == 0:
        temp = list(input().split())
        if len(temp) == 1:
            return temp[0]
        elif len(temp) > 1:
            return temp
    else:
        return [list(input().split()) for _ in range(n)]


def sp_xsxs(n=0):
    """
    args:
        int n: a number of lows to read
        example:
            input   A
            retrun  ["A"]

            input   ABC
            return  ["A","B","C"]

            input   ABC
                    D
            return  [["A","B","C"],
                    ["D"]]
    """
    if n == 0:
        return [s for s in xsxs()]
    else:
        return [[s for s in xsxs()] for _ in range(n)]


def p_num(a):

    if a == 1:
        return [[a, 1]]
    else:
        tmp = 2
        ans = []
        while tmp < np.sqrt(a) + 1:
            n = 0
            p = [tmp]

            while a % tmp == 0:
                a = int(a / tmp)
                # p.append(tmp)
                n += 1
                c = 1
            if n != 0:
                p.append(n)
                ans.append(p)
            tmp += 1
            c = 0
        if c == 0 and a != 1:
            ans.append([a, 1])
        return ans


n = xnxn()

if n == 1:
    print(0)
    sys.exit()
else:
    a = p_num(n)
    c = 0
    for num in a:
        i = 1
        while num[1] - i > -1:
            num[1] -= i
            i += 1
            c += 1
    print(c)


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N, K;
    cin >> N >> K;
    vector<ll> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    sort(all(H));
    ll ans = 1LL << 60;
    for (int i = 0; i < N - K + 1; i++) {
        ans = min(ans, abs(H[i + K - 1] - H[i]));
    }
    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

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

int BubbleSort(int elem[], int num)
{
    int i, j;
    int tmp;
    int cnt = 0;
    bool flag = false;

    for (i = 0; i < num; i++) {
        flag = false;
        for (j = num - 1; j > i; j--) {
            if (elem[j] < elem[j-1]) {
                swap(elem[j], elem[j-1]);
                ++cnt;
                flag = true;
            }
        }
        if (flag == false) {
            break;
        }
    }

    return cnt;
}

int main(void)
{
    int i;
    int num;
    int elem[100];
    int cnt;

    scanf("%d", &num);
    for (i = 0; i < num; i++) {
        scanf("%d", &elem[i]);
    }

    cnt = BubbleSort(elem, num);

    printf("%d", elem[0]);
    for (i = 1; i < num; i++) {
        printf(" %d", elem[i]);
    }
    printf("\n%d\n", cnt);

    return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<string>;
using P =pair<int,int>;
const ll mod=1000000007;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

int main(){
    int h,w;
    cin>>h>>w;
    int si,sj;
    cin>>si>>sj;
    int ti,tj;
    cin>>ti>>tj;
    --si,--sj,--ti,--tj;

    Field s(h);
    rep(i,h)cin>>s[i];
    const int INF=1e9;
    vector<vector<int>> dist(h,vector<int>(w,INF));
    deque<P> q;
    dist[si][sj]=0;
    q.emplace_back(si,sj);
    while(!q.empty()){
        int i=q.front().first;
        int j=q.front().second;
        q.pop_front();
        int d=dist[i][j];
        rep(v,4){
            int ni=i+dy[v],nj=j+dx[v];
            if(ni<0||ni>=h||nj<0||nj>=w)continue;
            if(s[ni][nj]=='#')continue;
            if(dist[ni][nj]<=d)continue;
            dist[ni][nj]=d;
            q.emplace_front(ni,nj);
        }
        for(int ei=-2;ei<=2;++ei){
            for(int ej=-2;ej<=2;++ej){
                int ni=ei+i,nj=j+ej;
                if(ni<0||ni>=h||nj<0||nj>=w)continue;
                if(s[ni][nj]=='#')continue;
                if(dist[ni][nj]<=d+1)continue;
                dist[ni][nj]=d+1;
                q.emplace_back(ni,nj);
            }
        }
    }
    int ans=dist[ti][tj];
    if(ans==INF)ans=-1;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9432
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    set<long long> s;
    int n;
    cin >> n;
    vector<int>an(n);
    for(int i = 0; i < n; i++){
        cin >> an.at(i);
        s.insert(an.at(i));
    }
    if(n == s.size()){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}



Measured memory_bytes: 10368
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main()
{

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

  ll ans = 0;

  if(!(a == b && a == c && b == c))
  {
    while(a % 2 == 0 && b % 2 == 0 && c % 2== 0)
    {
      ll as = a / 2;
      ll bs = b / 2;
      ll cs = c / 2;

      a = bs + cs;
      b = cs + as;
      c = as + bs;

      ans++;
    }
  }
  else
  {
    if(a % 2)
    {
      ans = 0;
    }
    else
    {
      ans = -1; 
    }
  }
  


  cout << ans << endl;
  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1000000007;

ll factorial[3000002];
ll iFactorial[3000002];

ll bigMode( ll base, ll b ){
    ll ans = 1;
    while( b ){
        if( b%2 == 1 ){
            ans = (ans*base)%MOD;
        }
        base = (base*base)%MOD;
        b /= 2;
    }
    return ans%MOD;
}

void fun(  ){
    factorial[0] = 1;
    iFactorial[0] = 1;
    for( int i = 1; i < 3000002; i++ ){
        factorial[i] = (i*factorial[i-1])%MOD;
        iFactorial[i] = (iFactorial[i-1]*bigMode(i, MOD-2))%MOD;
    }
}

int main(){
    fun();
    ll r1,r2,c1,c2;
    while( cin >> r1 >> c1 >> r2 >> c2 ){
        ll ans = 0;
        for( int i = r1 ; i <= r2; i++ ){
            ll r = i+c2+1;
            ll c = c2;
            ///if( r < c )swap( r,c );
            ll tempAns = factorial[r]%MOD;
            tempAns = (tempAns*iFactorial[c])%MOD;
            tempAns = (tempAns*iFactorial[r-c])%MOD;
            r = i+c1;
            c = c1-1;
            ///if( r < c )swap(r,c);
            ll tempAns1;
            tempAns1 = factorial[r];
            tempAns1 = (tempAns1*iFactorial[c])%MOD;
            tempAns1 = (tempAns1*iFactorial[r-c])%MOD;
            tempAns = tempAns - tempAns1;
            if( tempAns < 0 ){
                tempAns = (tempAns+MOD)%MOD;
            }
            ans = (ans+tempAns)%MOD;
        }
        cout << ans%MOD << endl;
    }
}
/*
7 2
0 1 0 0 0 1 0
*/


Measured memory_bytes: 47104
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input()) # n=1
def inpm(): return map(int,input().split()) # x=1,y=2
def inpl(): return list(map(int, input().split())) # a=[1,2,3,4,5,...,n]
def inpls(): return list(input().split())  # a=['1','2','3',...,'n']
def inplm(n): return list(int(input()) for _ in range(n)) # x=[] 複数行
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return sorted([list(map(int, input().split())) for _ in range(n)]) # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 
def graph():
    n=inp()
    g=[[] for _ in range(n)]
    for i in range(n):
        a = inp()
        a -= 1
        g[i].append(a)
        g[a].append(i)
    return n,g

def main():
    h,n = inpm()
    a = inpl()
    if h <= sum(a):
        print('Yes')
    else:
        print('No')
    
if __name__ == "__main__":
    main()




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

class P
{
    static void Main()
    {
        int[][] a = { new int[] { 1, 3, 5, 7, 8, 10, 12 }, new int[] { 4, 6, 9, 11 }, new int[] { 2 } };
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        for (int i = 0; i < 3; i++)
        {
            if (a[i].Contains(s[0]) && a[i].Contains(s[1]))
            {
                Console.WriteLine("Yes");
                return;
            }
        }
        Console.WriteLine("No");
    }
}

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

using std::cin;
using std::cout;
using std::endl;
using std::vector;

int
main()
{
  int N;
  cin >> N;
  vector<int> d(N);
  for (int n = 0; n < N; n++)
  {
    cin >> d[n];
  }
  long power = 0;
  for (int x = 0; x < N - 1; x++)
  {
    for (int y = x + 1; y < N; y++)
    {
      power += d[x] * d[y];
    }
  }
  cout << power << endl;
  return 0;
}


Measured memory_bytes: 256
#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,a;
  cin >> n >> a;
  n = n % 500;
  if (n<=a){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
  int a, b;
  scanf("%d", &a);
  scanf("%d", &b);

  if (a>b){
    if (b == 1) {
      printf("Bob");
    }else{
      printf("Alice");
    }
  }else if (a<b){
    if (a == 1) {
      printf("Alice");
    }else{
      printf("Bob");
    }
  }
  else if (a==b) printf("Draw");

  return 0;
}


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

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)

using namespace std;

using ll = long long;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);

    constexpr int L_MAX = 100000;

    int N;
    cin >> N;
    vector<int> V(N), W(N);
    FOR(i, 1, N + 1) cin >> V[i] >> W[i];

    int N_upper = min((1 << 9) - 1, N);
    vector<vector<ll>> dp(N_upper + 1, vector<ll>(L_MAX + 1));
    FOR(i, 1, N_upper + 1) {
        FOR(j, 1, L_MAX + 1) {
            dp[i][j] = dp[i / 2][j];
            if (j >= W[i]) {
                amax(dp[i][j], dp[i / 2][j - W[i]] + V[i]);
            }
        }
    }

    int Q;
    cin >> Q;
    vector<int> lowers(1 << 9);
    vector<ll> sum_V(1 << 9);
    vector<ll> sum_W(1 << 9);
    REP(_, Q) {
        int v, L;
        cin >> v >> L;

        int j = 1;
        while (v > N_upper) {
            lowers[j] = v;
            j <<= 1;
            v /= 2;
        }
        ll result = dp[v][L];
        FOR(bit, 1, j) {
            int mask = bit & -bit;
            int bit_prev = bit ^ mask;
            sum_V[bit] = sum_V[bit_prev] + V[lowers[mask]];
            sum_W[bit] = sum_W[bit_prev] + W[lowers[mask]];
            if (sum_W[bit] <= L) {
                amax(result, dp[v][L - sum_W[bit]] + sum_V[bit]);
            }
        }
        cout << result << '\n';
    }
    cout << flush;

    return 0;
}


Measured memory_bytes: 407376
#define DEBUG 0

/**
 * File    : A.cpp
 * Author  : Kazune Takahashi
 * Created : 5/22/2019, 4:30:59 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int A, B, C;

int main()
{
  cin >> A >> B >> C;
  if ((A < C && C < B) || (B < C && C < A))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n,m=[int(x) for x in input().split()]
a=[]
b=[]
for i in range(n): a.append([int(x) for x in input().split()])
for j in range(m): b.append(int(input()))
for a_row in a:
	print(sum([x*y for x,y in zip(a_row,b)]))


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

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

  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }

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

  int kagamimochi = N;
  int prev = 0;
  for (int i = 0; i < N; i++) {
    if (prev == d.at(i)) {
      kagamimochi--;
    }
    prev = d.at(i);
  }

  cout << kagamimochi << endl;
}

Measured memory_bytes: 3620