akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
const int INF = 1 << 29;
const ll LINF = 1l << 61;
const ld PI = abs(acos(-1));
#define pq priotity_queue
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define cbuf(buf, init) memset(buf, init, sizeof(buf))

template <class T>
constexpr T modp(T x, T y)
{
    return (y + x % y) % y;
}
template <class T>
constexpr T sq(T x)
{
    return x * x;
}
template <class T>
constexpr double divd(T x, T y)
{
    static_cast<double>(x) / static_cast<double>(y);
}

template <class T>
T nextInput()
{
    T t;
    cin >> t;
    return t;
}

#define netint nextInput<ll>()
#define netstr nextInput<string>()

template <class T>
void print(T&& t)
{
    cout << forward<T&&>(t) << endl;
}

void print(double t) { cout << fixed << setprecision(14) << t << endl; }

//

int main()
{
    //
    ll A = netint, B = netint;
    ll cnt = 0;
    rep(i, A, B + 1)
    {
        stringstream ss;
        ss << i;
        string r = ss.str();
        if (r[0] == r[4] && r[1] == r[3]) {
            cnt++;
        }
    }

    print(cnt);
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * @author varun on 7/1/2018
 * @project CompetitiveProgramming
 */
public class Main {
    private boolean check(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] % 2 != 0) {
                return false;
            }
        }
        return true;
    }

    public static void main(String args[]) {
        Main o = new Main();
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.nextLine().trim());
        int[] numbers = new int[N];
        for (int i = 0; i < N; i++) {
            numbers[i] = scanner.nextInt();
        }

        int ans = 0;
        while(o.check(numbers)) {
            ans++;
            for (int i = 0; i < numbers.length; i++) {
                numbers[i] /= 2;
            }
        }
        System.out.println(ans);
    }
}


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

#define int ll

#define pb push_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

const int MAX = 2E5 + 100;
int t[4*MAX], x[4*MAX];

void build_tree(int v, int l, int r) {
	if(l == r) {
		t[v] = 0;
		return;
	}
	int mid = (l + r)/2;
	build_tree(2*v + 1, l, mid);
	build_tree(2*v + 2, mid + 1, r);
}

int query(int v, int l, int r, int tl, int tr) {
	if(tr < tl)
		return 0;
	if(tl == l && tr == r)
		return t[v];
	int mid = (l + r)/2;
	return max(query(2*v + 1, l, mid, tl, min(tr, mid)), query(2*v + 2, mid + 1, r, max(mid + 1, tl), tr));
}

void update(int v, int l, int r, int pos, int val) {
	if(l == pos && r == pos) {
		t[v] = val;
		return;
	}
	int mid = (l + r)/2;
	if(pos > mid)
		update(2*v + 2, mid + 1, r, pos, val);
	else
		update(2*v + 1, l, mid, pos, val);
	t[v] = max(t[2*v + 1], t[2*v + 2]);
}

int32_t main() {
	int n;
	cin >> n;
	vi h(n), a(n);
	for(int i = 0; i < n; i++)
		cin >> h[i];
	for(int i = 0; i < n; i++)
		cin >> a[i];
	vi dp(n + 1);
	build_tree(0, 0, n - 1);
	for(int i = 0; i < n; i++) {
		//debug(i);
		dp[i] = a[i] + query(0, 0, n - 1, 0, h[i] - 1);
		// debug(i, i);
		update(0, 0, n - 1, h[i] - 1, dp[i]);
	}
	int res = 0;
	for(int i = 0; i < n; i++)
		res = max(res, dp[i]);
	cout << res << '\n';
}


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

arr=[0]*n

x=1

while 6*(x**2)<=n:
    y=x
    while (x**2)+3*(y**2)+(2*x*y)<=n:
        z=y
        while (x**2)+(y**2)+(z**2)+(x*y)+(y*z)+(z*x)<=n:
            r=(x**2)+(y**2)+(z**2)+(x*y)+(y*z)+(z*x)-1
            if x==y and y==z:
                arr[r]+=1
            elif x==y or y==z or z==x:
                arr[r]+=3
            else:
                arr[r]+=6
            z+=1
        y+=1
    x+=1
for ans in arr:
    print(ans)


Measured memory_bytes: 74376
#include<bits/stdc++.h>
using namespace std;
int main()
{ int n,m;
 cin>>n>>m;
 int a[m];
 for(int i=0;i<m;i++)
 {
     cin>>a[i];
 }
 int sum=0;
 for(int i=0;i<m;i++)
 {
     sum+=a[i];
 }
 if(sum>n)
 {
     cout<<-1;
 }
 else
 {
     cout<<n-sum;
 }
 

}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <array>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    
    vector<int> a(m);
    
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }
    
    int p[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    
    struct R {
        R() : len(-1) {
            fill(c.begin(), c.end(), 0);
        }
        
        int len;
        std::array<int, 9> c;   
    
        bool operator<(const R& rhs) const {
            if (len == -1) {
                return true;
            } else if (rhs.len == -1) {
                return false;
            } else if (len == rhs.len) {
                return c < rhs.c;
            } else {
                return len < rhs.len;
            }
        }
    };
    
    vector<R> dp(n + 1);
    
    dp[0].len = 0;
    
    for (int i = 0; i < n; i++) {
        if (dp[i].len == -1) {
            continue;
        }
        
        for (int k : a) {
            int s = i + p[k];
            
            if (s <= n) {
                R st = dp[i];
                st.len++;
                
                st.c[9 - k]++;
                
                dp[s] = max(dp[s], st);
            }
        }
    }
    
    string ans;
    
    for (int i = 0; i < 9; i++) {
        ans += string(dp[n].c[i], '9' - i);
    }
    
    cout << ans << endl;
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int i = 0; i < 1000; ++i) {
        string t = to_string(i);
        if (t.size() == 1) t = "00" + to_string(i);
        else if (t.size() == 2) t = "0" + to_string(i);
        bool flag = false;
        int start = 0;
        for (int j = 0; j < n; ++j) {
            if (s[j] == t[0]) {
                flag = true;
                start = j + 1;
                break;
            }
        }
        if (!flag) continue;
        flag = false;
        for (int j = start; j < n; ++j) {
            if (s[j] == t[1]) {
                flag = true;
                start = j + 1;
                break;
            }
        }
        if (!flag) continue;;
        flag = false;
        for (int j = start; j < n; ++j) {
            if (s[j] == t[2]) {
                flag = true;
                break;
            }
        }
        if (flag) ans++;
    }
    cout << ans << endl;
}


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

typedef long long ll;

using namespace std;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int ABC[3]; for (int i = 0; i < 3; ++i) cin >> ABC[i];
    sort(ABC, ABC+3, greater<int>());

    int res;
    if ((ABC[0] * 3) % 2 == accumulate(ABC, ABC+3, 0) % 2) {
        res = ((ABC[0] - ABC[1]) + (ABC[0] - ABC[2])) / 2;
    } else {
        ABC[0] += 1;
        res = ((ABC[0] - ABC[1]) + (ABC[0] - ABC[2]) + 1) / 2;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
using namespace std;

#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
       ll n,l;
       cin>>n>>l;
       ll maxx=101;
       ll s=0;
       for(int i=1;i<=n;i++)
       {
       	  maxx=min(abs(l+i-1),maxx);
       	  s+=l+i-1;
       }  
       if(maxx==0)
         cout<<s;
        else
        {
           if(l>=0)
           	  s-=maxx;
           	else
           		s+=maxx;
           	cout<<s;
        } 
    }
    return 0;
}

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

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

    int ans_max = min(a, b);
    int ans_min = max(0, a + b - n);


    cout << ans_max << " " << ans_min << endl;

    return 0;
}


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

dp = [0] * n
dp[0] = a[0]

def gcd(a, b):
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)

for i in range(n - 1):
    dp[i + 1] = gcd(dp[i], a[i + 1])

print(dp[n - 1])

Measured memory_bytes: 14252
def main():
    s = input()
    t = input()
    s2 = s * 2
    sett = list(set((t)))
    settindex = {}
    for i in sett:
        settindex[i] = sett.index(i)
        if i not in s:
            print(-1)
            return
    lens = len(s)
    # index[i文字目以降][settのindex]に何文字目にあるかが格納される
    index = [[-1] * len(sett) for _ in range(lens)]
    ans = 0
    n = 0
    for i in t:
        j = settindex[i]
        if index[n][j] == -1:
            index[n][j] = s2[n:].index(i)
        ans += index[n][j] + 1
        n += index[n][j] + 1
        n %= lens
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 33024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

// ??????a, b?????????????????????cost??????????????????
struct Edge
{
	int a, b, cost;
	bool operator<(const Edge& o) const {
		return cost < o.cost;
	}
};

// ????????°??¨?????????????????¨????????????????????°??????
struct Graph
{
	int n;  // ????????°
	vector<Edge> es;  // ?????????

					  // ????????????????????§??????????°???¨?????¨??????????????????????¨??????????
					  // ??°??????????????£????????¨??????????°???¨????£?????????????????????¨??????
	int kruskal() {
		// ?????????????°??????????????????????
		sort(es.begin(), es.end());

		UnionFind uf(n);
		int min_cost = 0;

		for (int ei = 0; ei < es.size(); ei++) {
			Edge& e = es[ei];
			if (!uf.same(e.a, e.b)) {
				// ????????????????????????????????§???????????????????????????????????¨??????
				min_cost += e.cost;
				uf.unite(e.a, e.b);
			}
		}

		return min_cost;
	}
};

// ?¨??????\???????????°?????????????????????
Graph input_graph() {
	Graph g;
	int m;
	cin >> g.n >> m;
	for(int i = 0; i < m; i++){
		Edge e;
		cin >> e.a >> e.b >> e.cost;
		g.es.push_back(e);
	}
	return g;
}


int main()
{
	Graph g = input_graph();
	cout << g.kruskal() << endl;
	return 0;
}

Measured memory_bytes: 4492
def choose_animal(last_animal:, last_say:, two_last_animal:)
  if last_animal == 0
    if last_say == 'o'
      two_last_animal
    else
      (two_last_animal + 1) % 2
    end
  else
    if last_say == 'o'
      (two_last_animal + 1) % 2
    else
      two_last_animal
    end
  end
end

N = gets.to_i
string = gets.chomp.split("")

# 0:羊　1:狼
flag = false
[[0, 0], [0, 1], [1, 0],[1, 1]].each do |first, second|
  tmp = Array.new(N)
  tmp[0] = first
  tmp[1] = second

  (2..(N-1)).each do |i|
    tmp[i] = choose_animal(last_animal: tmp[i-1], last_say: string[i-1], two_last_animal: tmp[i-2])
  end
  last_animal = choose_animal(last_animal: tmp[N-1], last_say: string[N-1], two_last_animal: tmp[N-2])
  two_last_animal = choose_animal(last_animal: first, last_say: string[0], two_last_animal: second)
  if last_animal == first && two_last_animal == tmp[N-1]
    flag = true
    result = tmp.map do |j|
      if j == 0
        'S'
      else
        'W'
      end
    end.join
    puts result
    break
  end
end

if !flag
  puts '-1'
end

Measured memory_bytes: 13148
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  m = min(m, 100);
  vector<int> b(n);
  for (int k = 0; k < m; ++k) {
    fill(b.begin(), b.end(), 0);
    for (int i = 0; i < n; ++i) {
      int L = max(0, i - a[i]), R = min(n - 1, i + a[i]);
      b[L]++;
      if (R + 1 < n) b[R + 1]--;
    }
    int64 sum = 0;
    for (int i = 0; i < n; ++i) {
      sum += b[i];
      a[i] = sum > n ? n : sum;
    }
  }
  for (int i = 0; i < n; ++i) {
    printf("%d%c", a[i], " \n"[i + 1 == n]);
  }
  return 0;
}


Measured memory_bytes: 4528
package main

import (
	"fmt"
	"sort"
)

func main() {
	var x, n int
	fmt.Scanf("%d", &x)
	fmt.Scanf("%d", &n)

	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &nums[i])
	}

	sort.Ints(nums)

	answer := x
LOOP:
	for i := 0; i < n; i++ {
		if x == nums[i] {
			for j := 1; j < n; j++ {
				if i-j < 0 {
					answer = x - j
					break LOOP
				} else if x-j != nums[i-j] {
					answer = x - j
					break LOOP
				} else if i+j >= n {
					answer = x + j
					break LOOP
				} else if x+j != nums[i+j] {
					answer = x + j
					break LOOP
				}
			}

			answer = nums[0] - 1
            break LOOP
		}
	}

	fmt.Println(answer)
}


Measured memory_bytes: 1828
#!/usr/bin/python3
import bisect
# from collections import Counter, deque, OrderedDict, defaultdict
# from copy import copy, deepcopy # pythonのみ．copyは1次元，deepcopyは多次元．
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import unittest
from io import StringIO
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    A, B, Q = map(int, input().split())
    INF = 10**20
    s = [-INF]+[int(input()) for _ in range(A)]+[INF]
    t = [-INF]+[int(input()) for _ in range(B)]+[INF]

    for i in range(Q):
        x=int(input())
        saind = bisect.bisect_left(s,x)
        sa = s[saind-1]
        sb = s[saind]
        taind = bisect.bisect_left(t,x)
        ta = t[taind-1]
        tb = t[taind]

        res = 10**20

        for ss in (sa, sb):
            for tt in (ta, tb):
                res = min(res, abs(x-ss)+abs(ss-tt))
        
        for tt in (ta, tb):
            for ss in (sa, sb):
                res = min(res, abs(x-tt)+abs(tt-ss))


        print(res)


resolve()

Measured memory_bytes: 94680
#include <iostream>

using namespace std;

int main(){
  string S;
  cin >> S;
  int N = S.length();

  int last_1[N];
  int last_2[N];
  for (int i =0;i<N; i++){
    if(i%2 == 0){
      last_1[i] = '0';
      last_2[i] = '1';
    }
    else{
      last_1[i] = '1';
      last_2[i] = '0';
    }
  }
  int ham_1 = 0;
  int ham_2 = 0;
  for(int i=0; i<N;i++){
    if (S[i] != last_1[i]){
      ham_1++;
    }
    if (S[i] != last_2[i]){
      ham_2++;
    }
  }
  if(ham_1<ham_2){
    std::cout << ham_1 << std::endl;
  }
  else{
    std::cout << ham_2 << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

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 int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

//組み合わせの数nCrを計算
ll calc_num_of_combination(ll n, ll r){
  ll num = 1;
  for(ll i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

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

  int n; cin >> n;
  vector<ll> a(n);
  map<int, int> mp;
  rep(i, n) cin >> a[i];
  rep(i, n) {
    mp[a[i]]++;
  }

  ll sum = 0;
  for (auto& p : mp) {
    if (p.second >= 0) sum += calc_num_of_combination(p.second, 2);
  }

  for (auto& v : a) {
    ll tmp = sum;
    if (mp[v] >= 2) {
      tmp -= calc_num_of_combination(mp[v], 2);
      if (mp[v] > 2) tmp += calc_num_of_combination(mp[v] - 1, 2);
    }
    cout << tmp << endl;
  }

  return 0;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
LL inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =1000000000000000000;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define F first
#define S second
class StonesOnATree
{

    public:
int minStones(vector <int> p, vector <int> w)
{

}

};

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

        int A[2005]={};
        int maxr=b;
        for(int i=0;i<a;i++){
            cin>>A[i];
        }
        
        int ans=0;

            if(a==1){
                cout<<abs(A[0]-c)<<endl;
                con;
            }
            
            else{
                ans=max( abs(A[a-1]-A[a-2]),abs(A[a-1]-c) );
                cout<<ans<<endl;
            }











    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

using namespace std;
#include <stdio.h>

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0){
    if(y%2) res=(x%hell*res%hell)%hell;
    x=(x%hell*x%hell)%hell;
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/

void solve(){
  int test;
  //cin>>test;
  test=1;
  
  while(test--){
      int n,h;
      cin>>h>>n;
      
      ll a[n],s=0;
      forn(i,0,n)
      {
          cin>>a[i];
          s+=a[i];
      }
      if(s>=h)
      cout<<"Yes";
      else
      cout<<"No";
  }    
}    

    




///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}


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

ll gcd(ll x, ll y) {return y ? gcd(y, x%y) : x;}

int main(){
	ll A,B;
	cin >> A >> B;
	ll g = gcd(A,B);
	if(g == 1){
		cout << 1 << endl;
		return 0;
	}
	ll cnt(1);
	for(ll i(2);i*i<=g;++i){
		if(g%i) continue;
		if(g%i == 0){
			cnt++;
			while(g%i == 0){
				g/=i;
			}
		}
	}
	if(g != 1)cnt++;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = [A1, A2, A3]
n = int(input())
b = []
for _ in range(n):
    b.append(int(input()))

AA = [[False, False, False],
[False, False, False],
[False, False, False]]

for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            AA[i][j] = True

if AA[0][0] and AA[0][1] and AA[0][2]:
    print('Yes')
elif AA[1][0] and AA[1][1] and AA[1][2]:
    print('Yes')
elif AA[2][0] and AA[2][1] and AA[2][2]:
    print('Yes')
elif AA[0][0] and AA[1][0] and AA[2][0]:
    print('Yes')
elif AA[0][1] and AA[1][1] and AA[2][1]:
    print('Yes')
elif AA[0][2] and AA[1][2] and AA[2][2]:
    print('Yes')
elif AA[0][0] and AA[1][1] and AA[2][2]:
    print('Yes')
elif AA[0][2] and AA[1][1] and AA[2][0]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
#include <stdio.h>

int data[100];

main(){
  int t, n, d, u, i, temp, j;

  scanf("%d", &t);

  for(i=0;i<t;i++){
    scanf("%d", &n);
    for(j=0;j<n;j++){
      scanf("%d", &data[j]);
    }

    u=-1001;
    d=1001;
    
    for(j=0;j<n-1;j++){
      temp=data[j+1]-data[j];
      if(temp>=0 && u<temp) u=temp;
      else if(temp<0 && d>temp) d=temp;
    }
    if(u==-1001) u=0;
    if(d==1001) d=0;
    printf("%d %d\n", u, -d);
  }
  return 0;
}


   

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

typedef long long int ll;
string s;

int main() {
    cin >> s;
    for(ll i = 0; i < s.length(); ++i) {
        if(s[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

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

const int mod = 1e9+7;
const int maxn = 1e6+5;
void tlfclwx(){ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
struct node
{
    int x, y;
}k[maxn];
int dp[maxn];
int main()
{
    int h, n;
    cin >> h >> n;
    for(int i = 1; i <= n; i++) cin >> k[i].x >> k[i].y;
    for(int i = 1; i <= 50000; i++) dp[i] = 0x3f3f3f3f;
    for(int i = 1; i <= n; i++) {
        for(int j = k[i].x; j <= 10000; j++) {
            dp[j] = min(dp[j], dp[j-k[i].x] + k[i].y);;
        }
    }
    int ans = dp[h];
		int k = h;
		for(int i = h+1; i <= 10000; i++){
			if(ans >= dp[i]){
				ans = dp[i];
				k = i;
			}
		}
    cout << ans << endl;
}


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

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

  cout << (K/2)*(K/2 + K%2) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Xor Sum 4
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            long[] A = new long[N];
            for (int i = 0; i < N; i++) {
                A[i] = sc.nextLong();
            }

            int[] c = new int[60];
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < 60; j++) {
                    c[j] += ((A[i] >> j) & 1);
                }
            }

            long ans = 0;

            for (int j = 0; j < 60; j++) {
                long a = (1L << j) % 1000000007;
                a = (a * (N - c[j])) % 1000000007;
                a = (a * c[j]) % 1000000007;
                ans = (ans + a) % 1000000007;
            }

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 97516
#include<iostream>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
typedef long long ll;
using namespace std;

int main(){
  ll n,a;
  ll zero,one,two;
  zero=one=two=0;
  cin>>n;
  rep(i,n){
    cin>>a;
    if(a%3==0)zero++;
    else if(a%3==1)one++;
    else two++;
  }
  ll ze=zero,on=one,tw=two;
  ll now=0,ans=0;
  while(1){
    if(ans==0){
      if(one){
	now++;
	ans++;
	one--;
      }else if(two){
	now+=2;
	ans++;
	two--;
      }else{
	if(zero>0)ans++;
	break;
      }
    }else{
      if(now==0)break;
      else{
	while(zero>0){
	  ans++;
	  zero--;
	}
	if(now==1){
	  if(one==0){
	    if(two>0)ans++;
	    break;
	  }else{
	    one--;
	    ans++;
	    now=2;
	  }
	}else{
	  if(two==0){
	    if(one>0)ans++;
	    break;
	  }else{
	    two--;
	    ans++;
	    now=1;
	  }
	}
      }
    }
  }
  zero=ze;
  one=on;
  two=tw;
  ll alt=ans;
  ans=0;
  now=0;
  while(1){
    if(ans==0){
      if(two){
	now=2;
	ans++;
	two--;
      }else if(one){
	now=1;
	ans++;
	one--;
      }else{
	if(zero>0)ans++;
	break;
      }
    }else{
      if(now==0)break;
      else{
	while(zero>0){
	  ans++;
	  zero--;
	}
	if(now==1){
	  if(one==0){
	    if(two>0)ans++;
	    break;
	  }else{
	    one--;
	    ans++;
	    now=2;
	  }
	}else{
	  if(two==0){
	    if(one>0)ans++;
	    break;
	  }else{
	    two--;
	    ans++;
	    now=1;
	  }
	}
      }
    }
  }
  cout<<max(ans,alt)<<endl;
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<stack>
#include<vector>
#include<cstring>
#include<algorithm>
#define FOR(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int N,M;
vector<int> edge[100010];
vector<int> redge[100010];
int indeg[100010];
stack<int> st;
int ans[100010];
int main(){
  memset(indeg,0,sizeof(indeg));
  cin >> N >> M; 
  FOR(i,0,N-1+M){
    int a,b;
    cin >> a >> b;
    edge[a].push_back(b);
    redge[b].push_back(a);
    indeg[b]++;
  }
  FOR(i,1,N+1) if(indeg[i]==0) st.push(i);
  int j=0;
  while(!st.empty()){
    int v=st.top();st.pop();
    ans[v]=j;j++;
    FOR(i,0,edge[v].size()){
      int e=edge[v][i];
      indeg[e]--;
      if(indeg[e]==0) st.push(e);
    }
  }
  FOR(i,1,N+1){
    int p=0,res=0;
    FOR(k,0,redge[i].size()){
      int r=redge[i][k];
      if(p<=ans[r]){
	res=r;
	p=ans[r];
      }
    }
    cout << res << "\n";
  }

  
  return 0;
}


Measured memory_bytes: 12544
#include <bits/stdc++.h>
using namespace std;
int n,a[3009];
vector <int> cnt[3009];
bool c[3009];
void find(int x,int uab){
	c[x]=false;a[x]--;
	for(int i=0;i<cnt[x].size();i++){
		if(a[cnt[x][i]]>a[x]||cnt[x][i]==uab)	continue;
		find(cnt[x][i],x);
		if(!c[cnt[x][i]]){c[x]=true;break;}
	}
	a[x]++;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)	scanf("%d",&a[i]);
	for(int i=1;i<n;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		cnt[a].push_back(b);
		cnt[b].push_back(a);
	}
	for(int i=1;i<=n;i++){
		find(i,0);
		if(c[i])	printf("%d ",i);
	}
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){
  int N,A[100];
  int i,j,minj,tmp,sum=0;

  scanf("%d",&N);
  for(i=0;i<N;i++)
    scanf("%d",&A[i]);

  for(i=0;i<=N-1;i++){
    minj=i;
    for(j=i;j<=N-1;j++){
      if(A[j]<A[minj])
	minj=j;
    }
      tmp=A[i];
      A[i]=A[minj];
      A[minj]=tmp;
      if(i!=minj)sum++;
  }

 for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i!=N-1)printf(" ");
  }

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

  return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define emp empty()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
    ll n ;
    cin >> n ;
    ll dp[2][n] ;
    ms(dp);
    ll arr[2][n] ;
    forn(i ,0 , n-1){
       cin >> arr[0][i] ;
    }
    forn(i , 0 , n-1){
       cin >> arr[1][i];
    }
    dp[0][0] = arr[0][0] ;
    dp[1][0] = arr[0][0] + arr[1][0] ;
    forn(i , 1 , n - 1){
       dp[0][i] = dp[0][i-1] + arr[0][i] ;
       dp[1][i] = max(dp[0][i] + arr[1][i] , dp[1][i-1] + arr[1][i]) ;
    }
    cout << dp[1][n-1] << el ;
    ro ;
}































Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }



void solve(long long N, long long D){
	ll res = (N+D*2) / (D*2+1);
	cout << res << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    solve(N, D);
    return 0;
}


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

int main()
{
	int N = 0, K = 0, count = 0;
	cin >> N >> K;

	if (N < K)
	{
		cout << "NO" << endl;
		return 0;
	}

	for (int i = 1; i <= N; i = i + 2)
	{
		++count;
		if (count >= K) {
			cout << "YES" << endl;
			return 0;
		}
	}

	if (count >= K)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;

int main(){

    int n; cin >> n;

    int ans = 0;

    for(int i=105; i<=n; i+=2){
        int temp  = 0;
        for(int j=1; j<=n; j++){
            if(i%j == 0){
                temp++;
                // cout << j << endl;
            }
        }
        if(temp == 8){
            ans++;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.array, std.conv, std.array, std.algorithm, std.numeric;

void main(){
  while (true){
    auto a = readln.strip.split.map!(to!long).array;
    if (a.length == 0) break;
    auto g = gcd(a[0], a[1]);
    writeln(g, " ", a[0] / g * a[1]);
  }
}

Measured memory_bytes: 2416
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
using namespace std;
#define ll long long
#define vel vector<ll>
#define vvel vector<vel>
#define vvvel vector<vvel>
#define veb vector<bool>
#define pin pair<int,int>
#define mkp make_pair
#define mot pair<D,D>//time,dist
#define root pair<int,mot>
#define path pair<ll,int>//cost,to
#define int long long
using namespace std;
vvel ta_min(0);
vvel ta_max(0);
int leth = 1024 * 512;
int siz = leth * 2;
int p = 1000000007;
void mmax(ll &a, ll b) { a = max(a, b); }
void mmin(ll &a, ll b) { a = min(a, b); }
vel dij(int s, vector<vector<path>> &way) {
	int n = way.size();
	int x = 1000 * 1000 * 1000;
	int INF = n * x + 1;
	vel tim(n, INF); tim[s] = 0;
	priority_queue<path> q;
	q.push(mkp(-0,s));
	veb seen(n,false);
	while (!q.empty()) {
		path tp = q.top(); q.pop();
		tp.first *= -1;
		int num = tp.second;
		if (!seen[num]) {
			tim[num] = tp.first;
			seen[num] = true;
			for (int i = 0; i < way[num].size(); i++) {
				path nex = way[num][i];
				path add = mkp(nex.first + tp.first, nex.second);
				add.first *= -1;
				q.push(add);
			}
		}
	}
	return tim;
}
void ref(int &x) { x = x % p; x = (x + p) % p; }
signed main() {
	int n, m; cin >> n >> m;
	int s, t; cin >> s >> t; s--; t--;
	vector<vector<path>> way(n);
	for (int i = 0; i < m; i++) {
		int u, v, d; cin >> u >> v >> d;
		u--; v--;
		way[u].push_back(mkp(d, v));
		way[v].push_back(mkp(d, u));
	}
	vel ti_s = dij(s, way);
	vel ti_t = dij(t, way);
	int dist = ti_s[t];
	vvel can_move_s(n);
	vvel can_move_t = can_move_s;
	vel goal_s(0);
	vel goal_t(0);
	for (int i = 0; i < n; i++){
		for (int j = 0; j < way[i].size(); j++) {
			path x = way[i][j];
			int to = x.second;
			int cos = x.first;
			if (ti_s[i] + cos + ti_t[to] == dist) { can_move_s[i].push_back(to); }
			if (ti_t[i] + cos + ti_s[to] == dist) { can_move_t[i].push_back(to); }
		}
	}
	vel com_s(n, 0); com_s[s] = 1;
	vel com_t(n, 0); com_t[t] = 1;
	vector<path> li_s(n);
	vector<path> li_t(n);
	for (int i = 0; i < n; i++) {
		li_s[i] = mkp(ti_s[i], i);
		li_t[i] = mkp(ti_t[i], i);
	}
	sort(li_s.begin(), li_s.end());
	sort(li_t.begin(), li_t.end());
	for (int i = 0; i < n; i++) {
		path x = li_s[i];
		int num = x.second;
		for (int j = 0; j < can_move_s[num].size(); j++) {
			int to = can_move_s[num][j];
			com_s[to] += com_s[num];
			ref(com_s[to]);
		}
	}
	for (int i = 0; i < n; i++) {
		path x = li_t[i];
		int num = x.second;
		for (int j = 0; j < can_move_t[num].size(); j++) {
			int to = can_move_t[num][j];
			com_t[to] += com_t[num];
			ref(com_t[to]);
		}
	}
	int ans = com_s[t] * com_t[s];
	ref(ans);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < can_move_s[i].size(); j++) {
			int to = can_move_s[i][j];
			if (ti_s[i] * 2 < dist and ti_t[to] * 2 < dist) {
				int x= (com_s[i] * com_t[to])%p;
				ans -= x * x;
				ref(ans);
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (ti_s[i] * 2 == dist and ti_t[i] * 2 == dist) {
			int x=(com_s[i] * com_t[i])%p;
			ans -= x * x;
			ref(ans);
		}
	}
	cout << ans << endl;
	return 0;
}

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

int n,a[15010],b[15010],an,bn,ans,Ans;
char s[5010],t[5010];

int getabs(int x) {return x<0?-x:x;}

int main()
{
	scanf("%d%s%s",&n,s+1,t+1),an=bn=5000,Ans=1000000000;
	for (int i=2; i<=n; i++) if (s[i]==s[i-1]) a[++an]=i-1;
	for (int i=2; i<=n; i++) if (t[i]==t[i-1]) b[++bn]=i-1;
	for (int i=0; i<=5000; i++) a[i]=b[i]=0;
	for (int i=an+1; i<=15000; i++) a[i]=n;
	for (int i=bn+1; i<=15000; i++) b[i]=n;
	for (int i=-n; i<=n; i++)
	{
		ans=0;
		if ((s[1]==t[1])^(i&1)^1) continue;
		for (int j=max(-i,0); j<=15000&&j<=15000-i; j++) ans+=getabs(b[i+j]-a[j]);
		for (int j=max(i,0); j<=15000&&j<=15000+i; j++) ans+=getabs(b[j]-a[j-i]);
		Ans=min(Ans,ans>>1);
	}
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <vector>
#define nmax 1001

using namespace std;
ifstream fin("p.in");
ofstream fout("p.out");

struct obiect
{
    int val,g;
}vec[nmax];
int n,g_max;

int main()
{
    int n,G;
    cin>>n>>G;
    long long sum_val=0;
    for(int i=1; i<=n; i++)
        {
            cin>>vec[i].g>>vec[i].val;
            sum_val+=vec[i].val;
        }

    vector<int>g_min(sum_val+1,1e9);
    g_min[0]=0;
    for(int i=1; i<=n; i++)
        for(long long j=sum_val; j>=vec[i].val; j--)
            g_min[j]=min(g_min[j],g_min[j-vec[i].val]+vec[i].g);

    for(long long i=sum_val; i>=0; i--)
         {
             //fout<<g_min[i]<<" ";
            if(g_min[i]<=G)
                {
                    cout<<i;
                    return 0;
                }
         }
    cout<<0;
    return 0;
}


Measured memory_bytes: 640
using System;

class Program
{
  static void Main(string[] args)
  {
    string str = Console.ReadLine();
    
    bool exist_7 = false;
    if((str[0] == '7') || (str[1] == '7') || (str[2] == '7'))
    {
      exist_7 = true;
    }
    
    if(exist_7){
      Console.WriteLine("Yes");
    }else{
      Console.WriteLine("No");
    }
  }
}


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


int c(int x, int n, vector<int> p) {
  set<int> ban;
  for(auto i: p) {
    ban.insert(i);
  }

  for(int i=0;i<x;i++) {
    int minus = x-i;
    if(ban.find(minus) == ban.end()) {
      return minus;
    }
    int plus = x + i;
    if(ban.find(plus) == ban.end()) {
      return plus;
    }
  }
  return 0;
}

int main() {
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  for(int i= 0;i<n;i++) {
    cin >> p[i];
  }
  cout << c(x, n, p);
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
	int N,T,A;
	cin>>N>>T>>A;
	double Min=INF;
	int ans=-1;
	rep(i,0,N)
	{
		int H=read();
		double nT=T-H*0.006;
		if(abs(A-nT)<Min)
		{
			Min=abs(A-nT);
			ans=i+1;
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
Row=int(input())
List=[]

for i in range(Row):
    a,n=input().split()
    List.append((a,int(n)*(-1),i+1)) #タプルで渡す
    #i番目に+1を忘れずに

List.sort() #デフォルトでは要素を順に比較してくれる

for l in List:
    print(l[2])

Measured memory_bytes: 3060
N = int(input())
A = []
for i in range(N):
    a = int(input())
    A.append(a)
    
A_MAX = max(A)
B = len([k for k in A if k == A_MAX])


if len(A) != B:
    C = -B-1
    D = sorted(A)
    A_MAX2 = D[C]

for j in A:
    if j == A_MAX:
        if B > 1:
            print(A_MAX)
        else:
            print(A_MAX2)
    else:
        print(A_MAX)

    

Measured memory_bytes: 14080
import java.util.PriorityQueue
import kotlin.comparisons.compareByDescending
fun main(args: Array<String>) {
    var (N, M) = listOfInt()
    val A = listOfLong()
    val Q = PriorityQueue<Long>(N, compareByDescending { it })
    for (n in 0 until N) {
        Q.add(A[n])
    }
    while (M > 0) {
        val e = Q.poll()!! / 2
        Q.add(e)
        M--
    }
    var ans = 0L
    while (Q.size > 0) {
        ans += Q.poll()!!
    }
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
fun listOfLong(delta: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + delta }

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

int main() {
  
  vector<int> a(3);
  REP(i,3) { 
    cin >> a[i];
  }
  
  sort(a.begin(), a.end());
  cout << ((a[0]+a[1] == a[2]) ? "Yes" : "No") << endl;

}

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

int main(){
	int year[3001];
	for(int i=0;i<3001;i++){
		if(i%4==0){
			year[i]=1;
		}else year[i]=0;
		if(i%100==0){
			year[i]=0;
		}
		if(i%400==0){
			year[i]=1;
		}
	}
	int a,b;
	cin>>a>>b;
	int cnt=0;
	if(a==0 && b==0)goto LABEL;
	for(int j=a;j<=b;j++){
		if(year[j]==1){
			cout<<j<<endl;
			cnt++;
		}
	}
	if(cnt==0)cout<<"NA"<<endl;
	while(1){
		cnt=0;
		cin>>a>>b;
		if(a==0 && b==0){
			break;
		}else{cout<<endl;}
		for(int j=a;j<=b;j++){
			if(year[j]==1){
				cout<<j<<endl;
				cnt++;
			}
		}
		if(cnt==0)cout<<"NA"<<endl;
	}
	LABEL:
	return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n, x;
    cin >> n >> x;
    int a[n + 1];
    a[0] = 0;
    REP(i, n)
    {
        cin >> a[i + 1];
    }

    long long ans = 0;
    for (int i = 1; i <= n; i++)
    {
        int sum = a[i - 1] + a[i];
        if (sum > x)
        {
            ans += sum - x;
            a[i] = max(0, a[i] - sum + x);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int X,N; cin>>X>>N;
    set<int> P;
    rep(n,0,N){
        int p; cin>>p;
        P.insert(p);
    }

    int ans=INT_MAX,ansIdx;
    rep(i,0,102){
        if(!P.count(i)){
            if(ans>abs(i-X)){
                ans=abs(i-X);
                ansIdx=i;
            }
        }
    }

    cout<<ansIdx<<endl;
}

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

using namespace std;

int main() {

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

    bool can = false;
    for (int i = 0; i <= M; i++) {
        for (int j = 0; j <= N; j++) {
        int p = i * N + M * j  - i * j * 2;
         if (K == p or K == (N * M - p) )
             can = true;
        }
    }

    if (can)
        cout << "Yes\n";
    else
        cout << "No\n";

}


Measured memory_bytes: 256
# include <cstdio>
# include <algorithm>

main()
{
    int arr[5];
    for (int i=0; i<5; i++) {
        scanf("%d", &arr[i]);
    }
    int k;
    scanf("%d", &k);
    std::sort(arr, arr+5);
    printf("%s\n", (arr[4] - arr[0] > k) ? ":(" : "Yay!");
}

Measured memory_bytes: 256