akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
N,M,L=map(int,input().split())

def war(d):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j]=min(d[i][j],d[i][k]+d[k][j])
    return d
INF=(L+1)*N
d=[[INF]*N for _ in range(N)]
d2=[[INF]*N for _ in range(N)]

for _ in range(M):
    A,B,C=map(int,input().split())
    if C>L:
        continue
    d[A-1][B-1]=C
    d[B-1][A-1]=C

for i in range(N):
    d[i][i]=0

d=war(d)

for i in range(N):
    for j in range(N):
        if d[i][j]<=L:
            d2[i][j]=1
for i in range(N):
    d2[i][i]=0
d2=war(d2)
#print(d)
#print(d2)
Q=int(input())
for i in range(Q):
    s,t=map(int,input().split())
    print(d2[s-1][t-1] %INF -1)


Measured memory_bytes: 54748
#include "bits/stdc++.h"

using namespace std;

const int maxn = 2e5 + 5;

vector < vector <int> > graph;
int arr[maxn];
int Tree[maxn * 4];

#define lchild       node * 2
#define rchild       node * 2 + 1
#define mid          (a + b) / 2

void build(int node, int a, int b) {
      if (a == b) {
            Tree[node] = arr[a];
            return;
      }
      build(lchild, a, mid);
      build(rchild, mid + 1, b);
      Tree[node] = max(Tree[lchild], Tree[rchild]);
}

void update(int node, int a, int b, int pos, int val) {
      if (a > pos or b < pos) {
            return;
      }
      if (a >= pos and b <= pos) {
            Tree[node] = val;
            return;
      }
      update(lchild, a, mid, pos, val);
      update(rchild, mid + 1, b, pos, val);
      Tree[node] = max(Tree[lchild], Tree[rchild]);
}

int query(int node, int a, int b, int i, int j) {
      if (a > j or b < i) {
            return 0;
      }
      if (a >= i and b <= j) {
            return Tree[node];
      }
      int p = query(lchild, a, mid, i, j);
      int q = query(rchild, mid + 1, b, i, j);
      int relavent = max(p, q);
      return relavent;
}

#undef lchild
#undef rchild
#undef mid

int n;
int bad[maxn];
int dp[maxn];
vector <int> vec;

void dfs(int u = 1, int p = 0) {
      int val = arr[u];
      int maxi = query(1, 1, n, 1, val - 1);
      int val_lis = maxi + 1;
      bad[u] = query(1, 1, n, val, val);
      update(1, 1, n, val, val_lis);
      dp[u] = query(1, 1, n, 1, n);
      for (int v : graph[u]) {
            if (v == p) {
                  continue;
            }
            dfs(v, u);
      }
      update(1, 1, n, val, bad[u]);
}

signed main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(nullptr); cout.tie(nullptr);
      cout.precision(12);

      bool FILEIO = 0;
      if (FILEIO and fopen("in.txt", "r")) {
            freopen("in.txt", "r", stdin);
      }

      cin >> n;
      map <int, int> mp;
      for (int i = 1; i <= n; i++) {
            cin >> arr[i];
            mp[ arr[i] ];
      }
      int ptr = 0;
      for (auto &it : mp) {
            it.second = ++ptr;
      }
      for (int i = 1; i <= n; i++) {
            arr[i] = mp[ arr[i] ];
      }
      graph.resize(n + 1);
      for (int e = 1; e < n; e++) {
            int u, v;
            cin >> u >> v;
            graph[u].push_back(v);
            graph[v].push_back(u);
      }
      dfs();
      for (int i = 1; i <= n; i++) {
            cout << dp[i] << endl;
      }
}


Measured memory_bytes: 35556
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;
void QuickSort(int* pnData, int nNumOf);

int main(){

    int n,ans = 0;
    int l[200];

    cin >> n;

    FOR(i,0,2*n){
        cin >> l[i];
    }

    QuickSort(l,2*n);

    for(int i = 0; i < 2*n; i+=2){
        ans += l[i];
    }

    cout << ans;

    return 0;
}



static void Sub_QuickSort(int* pnData, int nFirst, int nLast);

// クイックソート
void QuickSort(int* pnData, int nNumOf)
{
    Sub_QuickSort(pnData, 0, nNumOf - 1);
}

// 再帰関数
// nFirst : ブロックの最初のインデックス
// nLast  : ブロックの最後のインデックス
static void Sub_QuickSort(int* pnData, int nFirst, int nLast)
{
    int iLess    = nFirst;  // 前半のインデックス
    int iGreater = nLast;   // 後半のインデックス
    int x;                  // 「ある値」

    // 「ある値」は両端の要素の平均値にする
    x = (pnData[nFirst] + pnData[nLast]) / 2;

    // 交換ループ
    // 位置が逆になると終了
    while(iLess < iGreater)
    {
        // x より小さい要素は無視
        while(pnData[iLess] < x)
            iLess++;
        // x より大きい要素は無視
        while(pnData[iGreater] > x)
            iGreater--;

        // 位置がちゃんとしているときは交換し、
        // iLess と iGreater を１つずつ進める
        if(iLess < iGreater)
            swap(pnData[iLess++], pnData[iGreater--]);
    }
    // iLess == iGreater で終わった時は、
    // iGreater < iLess になるようにする
    if(iLess == iGreater)
    {
        if(pnData[iLess] < x)
            iLess++;
        else if(pnData[iLess] > x)
            iGreater--;
    }

    // 次のブロックのサイズが２以上の時は再帰
    if(iLess >= nFirst + 2)
        Sub_QuickSort(pnData, nFirst, iLess - 1);
    if(iGreater <= nLast - 2)
        Sub_QuickSort(pnData, iGreater + 1, nLast);
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {

  int n;
  char S[51][51];
  int A[51][26] = {0};
  int B[26] = {0};
  int i, j;
  int min;

  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%s", &S[i]);
  }
  
  for(i = 0; i < n; i++) {
    for(j = 0; S[i][j] != '\0'; j++) {
      A[i][S[i][j]-97]++;
    }
  }
  
  for(j = 0; j < 26; j++) {
    min = 51;
    for(i = 0; i < n; i++) {
      if(A[i][j] < min) {
	min = A[i][j];
      }
    }
    B[j] = min;
  }

  /*
  for(i = 0; i < 26; i++) {
    printf("%d", B[i]);
  }
  printf("\n");
  */
  
  for(i = 0; i < 26; i++) {
    for(j = 0; j < B[i]; j++) {
      printf("%c", 97+i);
    }
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

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

     int n = sc.nextInt();
     int m = sc.nextInt();

     int[][] A = new int[n][m];
     int[] b = new int[m];
     int[] c = new int[n];

     for(int i = 0; i < n; i++){
         for(int j = 0; j < m; j++)
             A[i][j] = sc.nextInt();
     }
     for(int i = 0; i < m; i++)
         b[i] = sc.nextInt();

     for(int i = 0; i < n; i++)
         c[i] = 0;

     for(int i = 0; i < n; i++) {
         for (int j = 0; j < m; j++)
             c[i] += A[i][j] * b[j];
     }

     for(int i = 0; i < n; i++)
         System.out.println(c[i]);

     sc.close();
    }
}



Measured memory_bytes: 40924
"""
int(input())
map(int,input().split())
list(map(int,input().split()))

"""

n=int(input())
A=list(map(int,input().split()))
A.sort()
cur=(A[0]+A[1])/2

for i in range(2,n):
    cur=(cur+A[i])/2
print(cur)


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

int main() {
  int N;
  long long K;
  std::cin >> N >> K;

  std::vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
    A[i] -= 1;
  }

  int x = 0; // 交差する点までの長さ
  int y = 0; // ループの長さ
  int cross = -1;

  {
    std::vector<int> c(N, 0);

    int k = 0;
    c[k] += 1;
    while (c[k] <= 1) {
      k = A[k];
      c[k] += 1;
    }
    // <= ここで k は交差する点
    cross = k;

    int l = 0;
    while (l != k) {
      l = A[l];
      x += 1;
    }
    // <= ここで l == k
    l = A[l];
    y += 1;
    while (l != k) {
      l = A[l];
      y += 1;
    }
  }
  // std::cout << "x: " << x << std::endl;
  // std::cout << "y: " << y << std::endl;

  if (K <= x) {
    // ループには入らない
    int k = 0;
    for (int i = 0; i < K; ++i)
      k = A[k];
    std::cout << k + 1 << std::endl;
  } else {
    // ループに入る
    K -= x;
    K %= y;

    int k = cross;
    for (int i = 0; i < K; ++i)
      k = A[k];
    std::cout << k + 1 << std::endl;
  }
}


Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
#define inf INT_MAX
int n;
int a[3005];
long long dp[3005][3005][2];
int turn = 0;

long long recur(int i, int j, int turn){
    if(i == j){
        return (turn == 0 ? a[i] : -a[i]);
    }
    long long &r = dp[i][j][turn];
    if(r != inf) return dp[i][j][turn];
    if(turn == 0){
        return r = max(a[i] + recur(i+1,j,1-turn),a[j] + recur(i,j-1,1-turn));
    } else return r = min(-a[i]+recur(i+1,j,1-turn),-a[j] + recur(i,j-1,1-turn));
}

int main(){
    cin>>n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            for(int k = 0; k < 2; k++){
                dp[i][j][k] = inf;
            }
        }
    }
    for(int i = 0; i < n; i++){
        cin>>a[i];
    }
    cout<<recur(0,n-1,turn);
}


Measured memory_bytes: 141312
mod = 10 ** 9 + 7

K = map(int, list(input()))
D = int(input())

s = 0
dp = [0] * D
for k in K:
    T = [0] * D
    for i, dpi in enumerate(dp):
        for x in range(10):
            T[(i + x) % D] = (T[(i + x) % D] + dpi) % mod
    for x in range(k):
        T[(s + x) % D] += 1

    s = (s + k) % D
    dp = T

print((dp[0] + (-1 if s != 0 else 0)) % mod)

Measured memory_bytes: 44508
#include<cstring>
#include <cstdio> 
#include <iostream>
#include <cmath>
#include<algorithm>
using namespace std;
#define pi 3.1415926 
//int num[200005][200005]={};
int main()
{
	int n,d,x,y,ans=0;
	scanf("%d %d",&n,&d);
	while(n--)
	{
		scanf("%d %d",&x,&y);
		if(d-sqrt(pow(x,2)+pow(y,2))>=0)
		{
			ans++;	
		}
	}
    printf("%d",ans);
}

Measured memory_bytes: 3796
from itertools import product
n,k=map(int,input().split())
a=list(map(int,input().split()))
ls=[0,1,2,3,4,5,6,7,8,9]
nm=[]
for i in ls:
  if i not in a:
    nm.append(i)
b=[]
for i in product(nm,repeat=5):
  b.append(10000*i[0]+1000*i[1]+100*i[2]+10*i[3]+i[4])
  b.append(1000*i[0]+100*i[1]+10*i[2]+i[3])
  b.append(100*i[0]+10*i[1]+i[2])
  b.append(10*i[0]+i[1])
  b.append(i[0])
b.sort()
for i in b:
  if i>=n:
    print(i)
    break
  


Measured memory_bytes: 11580
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>

using namespace std;

/*
//Boost C++ Libraries
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/vector.hpp>

namespace ublas = boost::numeric::ublas;
*/

int main(void){
    //
    int n, l;
    cin >> n >> l;
    vector<string> inputarr(n);
    for(int i=0;i<n;i++){
        cin >> inputarr[i];
    }
    sort(inputarr.begin(), inputarr.end());
    for(int i=0;i<n-1;i++){
        cout << inputarr[i];
    }
    cout << inputarr[n-1] << endl;

    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	int d = 0, sum = 0;
	for (int i = 0; i < 5; i++) {
		int n;
		cin >> n;
		sum += n / 10 * 10;
		if (n % 10) {
			sum += 10;
			d = max(d, 10 - n % 10);
		}
	}

	cout << sum - d << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
const ll mod=1e9+7;
bool sortbysec(const pair<int,int>&a,const pair<int,int>&b)
{
    return (a.second<b.second);
}
int main()
{
    string s;
    cin>>s;
    if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])
        cout<<"Bad"<<endl;
    else
        cout<<"Good"<<endl;







}



















































Measured memory_bytes: 3616
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
l = Array.new(n+1,0)
r = Array.new(n+1,0)
n.times do |i|
 l[i+1] = l[i].gcd(a[i])
 r[-2-i] = r[-1-i].gcd(a[-1-i])
end
max = 1
n.times do |i|
  max = [l[i].gcd(r[i+1]),max].max
end
puts max

Measured memory_bytes: 23360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

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

    int n,k,ans = 0;
    cin>>n>>k;
    vector<int>p(n);
    rep(i,n)cin>>p[i];

    sort(all(p));
    rep(i,k){
        ans += p[i];
    }
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s = "MARCH";
    int c[5] = {};

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        string t;
        cin >> t;
        for (int j = 0; j < 5; j++) {
            if (t[0] == s[j]) {
                c[j]++;
            }
        }
    }

    /*for (int i = 0; i < 5; i++) {
        cout << c[i] << " ";
    }
    cout << "\n";*/

    long long ans = 0LL;
    for (int i = 0; i < 5; i++) {
        for (int j = i + 1; j < 5; j++) {
            for (int k = j + 1; k < 5; k++) {
                ans += 1LL * c[i] * c[j] * c[k];
                //cout << c[i] << " * " << c[j] << " * " << c[k] << endl;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef pair<int, int> p;

struct range {
    int start;
    int end;
};

int main() {
    while (true) {
        int card_count, shuffle_count, l, r, x;
        cin >> card_count;
        if (card_count == 0)break;
        
        cin >> shuffle_count >> l >> r >> x;
        vector<range> shuffle(shuffle_count);
        for (int i = 0; i < shuffle_count; i++) {
            cin >> shuffle[i].start >> shuffle[i].end;
        }
        reverse(shuffle.begin(), shuffle.end());

        vector<range> card_group{{l, r}};
        for (int i = 0; i < shuffle_count; i++) {
            range current_shuffle = shuffle[i];
            int left_cut = card_count - shuffle[i].end;
            int right_cut = card_count - shuffle[i].start;

            vector<range> after;
            for (auto group:card_group) {
                if (group.start <= left_cut && left_cut < group.end) {
                    after.push_back({group.start, left_cut});
                    group.start = left_cut + 1;
                }
                if (group.start <= right_cut && right_cut < group.end) {
                    after.push_back({group.start, right_cut});
                    group.start = right_cut + 1;
                }
                after.push_back({group.start, group.end});
            }

            for (auto &group:after) {
                if (group.end <= left_cut) {
                    group.start += current_shuffle.end;
                    group.end += current_shuffle.end;
                } else if (group.end <= right_cut) {
                    group.start += current_shuffle.start + current_shuffle.end - card_count;
                    group.end += current_shuffle.start + current_shuffle.end - card_count;
                } else {
                    group.start += current_shuffle.start - card_count;
                    group.end += current_shuffle.start - card_count;
                }
            }

            card_group = after;
        }

        int ret = 0;
        for (auto group:card_group) {
            if (group.start <= x)
                ret += min(x, group.end) - group.start + 1;
        }

        cout << ret << endl;
    }
    return 0;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
const int N=(1<<19),p=998244353,q=(p+1)/2;
int n,l,w[N],f[N];
inline int read(){
	int num=0; char g=getchar(); while(g<48||57<g) g=getchar();
	while(47<g&&g<58) num=(num<<1)+(num<<3)+g-48,g=getchar(); return num;
}
inline long long pows(long long u,int v){
	long long ans=1; while(v>0) {if(v&1) ans=ans*u%p; u=u*u%p,v=v>>1;} return ans;
}
inline void fwt(int *s){
	for(int d=1;d<l;d=d<<1)
		for(int i=0,r=d<<1;i<l;i=i+r)
			for(int j=0;j<d;j++){
				int a=s[i+j],b=s[i+j+d];
				s[i+j]=(a+b)%p,s[i+j+d]=(a-b+p)%p;
			}
}
int main(){
	n=read(),l=(1<<n); int cnt=0;
	for(int i=0;i<l;i++) w[i]=read(),cnt+=w[i];
	for(int i=0;i<l;i++) w[i]=w[i]*pows(cnt,p-2)%p; fwt(w),w[0]=0;
	for(int i=1;i<l;i++) w[i]=pows(w[i]-1,p-2); fwt(w);
	for(int i=0;i<l;i++) printf("%d\n",(w[i]-w[0]+p)%p);
	return 0;
}

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

int main() {
    int a, b, ans = -1;
    cin >> a >> b;
    for (int i = 1; i <= 1009; i++) {
        if (floor(i * 0.08) == a && floor(i * 0.1) == b) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll m;cin>>m;
  ll result = 0;
  ll digits_counter=-1;
  ll sum=0;
  rep(i, m){
    ll d,c;cin>>d>>c;
    digits_counter+=c;
    sum+= d*c;
  }

  if(sum%9==0)cout << sum/9+digits_counter-1 << endl;
  else cout << sum/9+digits_counter << endl;

//  cout << (sum-1)/9+digits_counter << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i<b; i++)
#define dep(i,a,b) for(int i = a; i>b; i--)
#define makeUnique(vec) sort(all(vec)); vec.resize(unique(all(vec)) - vec.begin())
#define LOG_vec(vec, sep) for (int fl = 0; fl < vec.size(); fl++) { std::cout << vec[fl]<< sep; } std::cout << "\n"
#define LOG_ints(vec, sep) for (int fl = 0; fl < MAXSIZE; fl++) { std::cout << vec[fl]<< sep; } std::cout << "\n"
#define all(x) (x).begin(), (x).end()
#define ll long long
#define LSB(i) ((i) & -(i))
#define MAXSIZE 30

using namespace std;

int main() {
	int q;
	cin >> q;
	int summ = 0;

	summ += (q / 500) * 1000;
	q %= 500;
	summ += (q / 5) * 5;

	cout << summ;
}

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

signed main() {
	int n;
	cin >> n;
	vector<int> a(3 * n);
	for (int i = 0; i < 3 * n; ++i)cin >> a[i];
	sort(a.rbegin(), a.rend());
	int ans = 0;
	for (int i = 1; i < 2 * n; i += 2)ans += a[i];
	cout << ans << endl;
}

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

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

  if (x < 112) {
    cout << 111 << endl;
  }
if (111 < x &&x < 223) {
    cout << 222 << endl;
  }
if (222 <x &&x < 334 ) {
    cout << 333<< endl;
  }
if (333 < x &&x< 445) {
    cout << 444 << endl;
  }
if (444 < x&& x< 556) {
    cout << 555<< endl;
  }
if (555 < x&& x< 667) {
    cout << 666 << endl;
  }
if (666 < x && x< 778) {
    cout << 777 << endl;
  }
if (777 < x&&x < 889) {
    cout << 888<< endl;
  }
if (888 < x&&x < 1000) {
    cout << 999 << endl;
  }
}


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


signed main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> a(N); //学生x座標
  vector<int> b(N); //学生y座標
  vector<int> c(M); //CPx座標
  vector<int> d(M); //CPy座標
  
  for( int i = 0; i < N; i++ ){
    cin >> a.at(i) >> b.at(i);
  }
  for( int i = 0; i < M; i++ ){
    cin >> c.at(i) >> d.at(i);
  }
  
  const int dekai = 5000000000;
  int kyori;
  int ans;
  for( int i = 0; i < N; i++ ){
    kyori = dekai;
    for( int j = 0; j < M; j++ ){
      if( abs( a.at(i) - c.at(j) ) + abs( b.at(i) - d.at(j) ) < kyori ){
        kyori = abs( a.at(i) - c.at(j) ) + abs( b.at(i) - d.at(j) );
        ans = j+1;
      }
    }
    cout << ans << endl;
  }
  
}



Measured memory_bytes: 256
#include<cstdio>
using ll = long long;
const static int MOD = 1000000007;

int main(){
	int N;
	scanf("%d\n", &N);
	int appeared_alphabet[26];
	for (int i = 0; i < 26; ++i) appeared_alphabet[i] = 1;
	for (int i = 0; i < N; ++i){
		char tmp;
		scanf("%c", &tmp);
		appeared_alphabet[tmp - 'a']++;
	}
	ll answer = 1;
	for (int i = 0; i < 26; ++i) (answer *= appeared_alphabet[i]) %= MOD;
	printf("%lld\n", answer - 1);
	return 0;
}

Measured memory_bytes: 128
from math import ceil
N = int(input())
P = tuple(map(int, input().split()))
T = tuple(map(int, input().split()))
ans = 10**10
for i in range(1+ceil(N/T[0])):
    for j in range(1+ceil(N/T[1])):
        for k in range(1+ceil(N/T[2])):
            l = max(0, ceil((N-i*T[0]-j*T[1]-k*T[2])/T[3]))
            ans = min(ans, P[0]*i + P[1]*j + P[2]*k + P[3]*l)
print(ans)



Measured memory_bytes: 5664
import java.util.*;

public class Main
{
    public static void main( String[] args )
    {
        Scanner sc = new Scanner(System.in);
        int A[][] = new int[3][3];
        for(int i = 0;i<3;i++){
            for(int j = 0;j < 3;j++){
                A[i][j] = sc.nextInt();
            }
        }
        int N = sc.nextInt();
        for(int k = 0; k < N; k++){
            int b = sc.nextInt();
            for(int i = 0;i<3;i++){
                for(int j = 0;j < 3;j++){
                    if(b == A[i][j]){
                        A[i][j] = 0;
                    }
                }
            }
        }
        // for(int i = 0;i<3;i++){
        //         System.out.print(A[i][0] + " ");
        //         System.out.print(A[i][1] + " " );
        //         System.out.println(A[i][2]);
        // }
        boolean out = true;
        boolean bingo = false;
        for(int i = 0;i<3;i++){
            out = true;
            for(int j = 0;j < 3;j++){
                if(A[i][j] != 0){
                    out = false;
                    break;
                }
            }
            if(out == true){
                bingo = true;
                break;
            }
        }
        for(int j = 0;j<3;j++){
            out = true;
            for(int i = 0;i < 3;i++){
                if(A[i][j] != 0){
                    out = false;
                    break;
                }
            }
            if(out == true){
                bingo = true;
                break;
            }
        }
        if(A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0 ||
            A[0][2] == 0 && A[1][1] == 0 && A[2][0] == 0)bingo = true;

        if(bingo){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 22868
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define ll long long

ll ans;
int n, m;
char s[666][666];
bool vis[666][666];

int head, tail;
int q[666666][2];
int w, b;

void work(int x, int y, char a){
	if(!vis[x][y] && s[x][y] != a)
		q[++tail][0] = x, q[tail][1] = y, vis[x][y] = 1;
}

void bfs(int a, int c){
	w = b = head = tail = 0;
	q[++tail][0] = a; q[tail][1] = c;
	vis[a][c] = true;
	while(head < tail){
		int x = q[++head][0], y;
		y = q[head][1];
		if(s[x][y] == '#') b++; else w++;
		work(x + 1, y, s[x][y]), work(x - 1, y, s[x][y]), work(x, y + 1, s[x][y]), work(x, y - 1, s[x][y]);
	}
	ans += 1ll * w * b;
}

int main(){
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; i++) vis[i][0] = vis[i][m + 1] = 1;
	for(int i = 1; i <= m; i++) vis[0][i] = vis[n + 1][i] = 1;
	for(int i = 1; i <= n; i++)
		scanf("%s", s[i] + 1);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(!vis[i][j]) bfs(i, j);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    int n;
    cin >> n;
    int a;
    vector<int> v;
    cin >> a;
    v.push_back(a);
    rep(i,n-1) {
        cin >> a;
        if (*(v.end()-1) >= a) v.push_back(a);
        else *(lower_bound(v.rbegin(), v.rend(), a) - 1) = a;
    }
    cout << v.size() << endl;
    return 0;
}

Measured memory_bytes: 892
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	long solve(Supplier<String> sc) {
		long X = Long.parseLong(sc.get());
		long rem = X % 11;
		return -Math.floorDiv(-X, 11) * 2 - (rem <= 6 && 0 < rem ? 1 : 0);
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		System.out.println(Solver.INSTANCE.solve(new Supplier<String>() {
			private StringTokenizer tokenizer;

			public String get() {
				try {
					return (tokenizer = tokenizer != null && tokenizer.hasMoreTokens() ? tokenizer : new StringTokenizer(reader.readLine())).nextToken();
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
		}));
	}
}

Measured memory_bytes: 23380
N = int(input())
A = list(map(int, input().split()))
B = [0] * N
c = sum([A[i-1] for i in range(2,N,2)])
B[0] = sum(A) - 2 * c
for i in range(1,N):
    B[i] = 2*A[i-1] - B[i-1]
print(*B)

Measured memory_bytes: 14028
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = 1000000007;

int main() {
    int N,K; cin >> N >> K;
    vector<ll> A,B,C;
    int zerocnt=0;
    rep(i,N) {
        int a; cin >> a;
        if(a >= 0) A.emplace_back(a);
        else if(a < 0) B.emplace_back(a);
        if(a == 0) zerocnt++;
        C.emplace_back(a);
    }

    ll ans = 1;
    if(N == K){
        rep(i,K){
            ans *= (C[i]+MOD)%MOD;
            ans %= MOD;
        }
    }else{
        if(K%2==1 && ((int)A.size() == 0)){
            sort(B.begin(), B.end(), greater<int>());
            rep(i,K){
                ans *= (B[i]+MOD)%MOD;
                ans %= MOD;
            }
        }else{
            int Aind = 0, Bind = 0;
            sort(A.begin(), A.end(), greater<int>());
            sort(B.begin(), B.end());

            while(K >= 2){
                if(Aind < (int)A.size()-1 && Bind < (int)B.size()-1){
                    if(A[Aind]*A[Aind+1] > B[Bind]*B[Bind+1]){
                        ans *= A[Aind];
                        ans %= MOD;
                        Aind++;
                        K--;
                    }else{
                        ans *= ((B[Bind]*B[Bind+1])%MOD);
                        ans %= MOD;
                        Bind += 2;
                        K-=2;
                    }
                }else if(Aind >= (int)A.size()-1){
                    ans *= ((B[Bind]*B[Bind+1])%MOD);
                    ans %= MOD;
                    Bind += 2;
                    K-=2;
                }else{
                    ans *= ((A[Aind])%MOD);
                    ans %= MOD;
                    Aind ++;
                    K--;
                }
            }
            if(K>0){
                ans *= A[Aind];
                ans %= MOD;
                Aind++;
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7460
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  string s;
  cin >> s;

  string ans;
  int a = s[0] - '0';
  int b = s[1] - '0';
  int c = s[2] - '0';
  int d = s[3] - '0';
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        int t = a;
        t = (i ? t + b : t - b);
        t = (j ? t + c : t - c);
        t = (k ? t + d : t - d);

        if (t == 7) {
          ans = to_string(a) + (i ? "+" : "-") + to_string(b) + (j ? "+" : "-") + to_string(c) + (k ? "+" : "-") + to_string(d) + "=7";
        }
      }
    }
  }

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
    int h = 0;
    int[] arr;
 
    void run() {
        Scanner sc = new Scanner(System.in);
        arr = new int[2000100];
        while (true) {
            String command = sc.next();
            int i;
            if (command.equals("end")){
                break;
            } else if (command.equals("insert")) {
                i = sc.nextInt();
                insert(i);
            } else {
                System.out.println(heapExtractMax(arr));
            }
        }
    }
 
    int parent(int i) { return i / 2; }
    int left(int i) { return 2 * i; }
    int right(int i) { return 2 * i + 1; }
 
    void insert(int key) {
        h++;
        arr[h] = Integer.MIN_VALUE;
        heapIncreaseKey(arr, h, key);
    }
 
    void heapIncreaseKey(int[] arr, int i, int key) {
        if (key < arr[i]) {
            throw new RuntimeException("新しいキーは現在のキーより小さい");
        }
        arr[i] = key;
        while (i > 1 && arr[parent(i)] < arr[i]) {
            int tmp = arr[i];
            arr[i] = arr[parent(i)];
            arr[parent(i)] = tmp;
            i = parent(i);
        }
    }
 
    int heapExtractMax(int[] arr) {
        if (h < 1) {
            throw new RuntimeException("ヒープアンダーフロー");
        }
        int max = arr[1];
        arr[1] = arr[h];
        h--;
        maxHeapify(arr, 1);
        return max;
    }
 
    void maxHeapify(int[] arr, int i) {
        int largest;
        int l = left(i);
        int r = right(i);
        if (l <= h && arr[l] > arr[i]) {
            largest = l;
        } else {
            largest = i;
        }
 
        if (r <= h && arr[r] > arr[largest]) {
            largest = r;
        }
 
        if (largest != i) {
            int tmp = arr[i];
            arr[i] = arr[largest];
            arr[largest] = tmp;
            maxHeapify(arr, largest);
        }
    }
 
    void buildMaxHeap(int[] arr) {
        for (int i = h / 2; i > 0; i--) {
            maxHeapify(arr, i);
        }
    }
 
    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
}


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

int main(){

    int a, b, c, d;

    cin >> a >> b >> c >> d;

    if(a*b >= c*d){
        cout << a*b << endl;
    }
    else{
        cout << c*d << endl;
    }


    return 0;

}


Measured memory_bytes: 3520
from bisect import bisect_right

N, D, A = map(int, input().split())
M = []
for i in range(N):
  x, h = map(int, input().split())
  M.append((x, -(-h//A)))
M.sort(key=lambda x: x[0])
X = list(map(lambda x: x[0], M))
H = list(map(lambda x: x[1], M))

dmg = [0] * (N+1)
ans = 0

for i in range(N):
  x, h = M[i]
  h = max(0, h - dmg[i])
  dmg[bisect_right(X, x + 2*D)] -= h
  dmg[i+1] += dmg[i] + h
  ans += h
print(ans)

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

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

#define endl '\n'
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=2e5+5,mod=998244353,bit=61;

ll n,a[N],b[N];

signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        cin>>n;
        vector<ll> sm,bg;
        f(i,1,n)
        {
            cin>>a[i]>>b[i];
            sm.pb(a[i]);
            bg.pb(b[i]);
        }
        sort(all(sm));
        sort(all(bg));
        if(n&1)
        {
            ll l=sm[n/2];
            ll r=bg[n/2];
            cout<<r-l+1<<endl;
        }
        else
        {
            ld l=(sm[n/2]+sm[(n/2)-1])/2.0;
            ld r=(bg[n/2]+bg[(n/2)-1])/2.0;
            ld dif=r-l;
            ll ans=(dif)/(0.5) + 1;
            cout<<ans<<endl;
        }
    }
    return 0;
}


















Measured memory_bytes: 9804
#include<bits/stdc++.h>
using namespace std;
int n;
double p[3000];
double dp[3000][3000];
int main() {
	cin>>n;
	for(int i=1;i<=n;++i) cin>>p[i];
	dp[0][0]=1;
	for(int i=1;i<=n;++i) {
		for(int j=0;j<=n;++j) {
			dp[i][j]=dp[i-1][j]*(1-p[i])+(j>0?dp[i-1][j-1]*p[i]:0);
		}
	}
	
	double res=0;
	for(int i=n/2+1;i<=n;++i) {
		res+=dp[n][i];
	}
	cout<<fixed<<setprecision(10);
	cout<<res<<"\n";
}


Measured memory_bytes: 70528
N,K,S=map(int, input().split())
ans=[0]*N
if K==0:
    if S==10**9:
        for i in range(N):
            ans[i]=S-1
    else:
        for i in range(N):
            ans[i]=S+1
else:
    for i in range(K):
        ans[i]=S
    if S==10**9:
        for i in range(K,N):
            ans[i]=S-1
    else:
        for i in range(K,N):
            ans[i]=S+1
print(*ans)

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


int main()
{
	int n; cin >> n;
	int ans = 0;
	for (int a = 1; a < n; ++a)
		for (int b = n/a; b > 0; --b)
			if (n - a*b > 0)
				ans++;
	cout << ans << endl;
}


Measured memory_bytes: 3620
h,w = map(int, input().split())
S=list()
for i in range(h):
    S.append(str(input()))

for H in range(h):
    for W in range(w):
        stat=0
        #print(H,W,S[H][W])
        if S[H][W]=='.':
            continue
        if H!=0:
            if S[H][W]==S[H-1][W]:
                stat=1
        if W!=w-1:
            if S[H][W]==S[H][W+1]:
                stat=1
        if H!=h-1:
            if S[H][W]==S[H+1][W]:
                stat=1
        if W!=0:
            if S[H][W]==S[H][W-1]:
                stat=1
        if stat==0:
            print('No')
            exit()

print('Yes')

Measured memory_bytes: 9072
#include <stdio.h>
 
int main(){
	int n,k,i,j,t,m,a[201],b[201];
	scanf("%d",&n);
	for(i=1;i<=2*n;i++){
		a[i]=i;
	}
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%d",&k);
		if(k==0){
			t=1;
			j=1;
			while(1){
				b[j]=a[t];
				b[j+1]=a[n+t];
				t++;
				j+=2;
				if(j>=2*n+1)break;
			}
			for(j=1;j<=2*n;j++){
				a[j]=b[j];
			}
		}
		else if(1<=k && k<=2*n-1){
			t=1;
			for(j=k+1;j<=2*n;j++){
				b[t]=a[j];
				t++;
			}
			for(j=1;j<=k;j++){
				b[t]=a[j];
				t++;
			}
			for(j=1;j<=2*n;j++){
				a[j]=b[j];
			}
		}
	}
	for(i=1;i<=2*n;i++){
		printf("%d\n",a[i]);
	}
	return 0;
}

Measured memory_bytes: 2756
#include <stdio.h>

int main()
{
  int n;
  scanf("%d",&n);
  char s[10000 + 1];
  scanf("%s",&s);
  int i;
  i = 0;
  while (s[i])
  {
    s[i] += n;
    if (s[i] > 'Z')
    {
      s[i] = s[i] - 'Z' + 'A' - 1;
    }
    i++;
  }
  printf("%s",s);
}

Measured memory_bytes: 128
//varun
#include <stdio.h>
//sukhan
 int main(void){
 int a, b, c;

 scanf("%d%d%d", &a, &b, &c);

 int ispoor = 0;
 if (a == b && b != c) ispoor = 1;
 if (b == c && c != a) ispoor = 1;
 if (c == a && a != b) ispoor = 1;

 if (ispoor) {
 puts("Yes");
 } else {
 puts("No");
 }

 return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll a,b,c, k;
    cin >> a >> b >> c >> k;
    ll tmp = 0;
    while(b <= a){
        b *= 2;
        ++tmp;
    }
    while(c <= b){
        c *= 2;
        ++tmp;
    }
    if(tmp <= k) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<stdlib.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main()
{
  int n;
  int sum=0;
  double num=0;
  int p=0;
  double d_p;
  
  cin>>n;
  vector<int> x(n);
  
  for(int i=0;i<n;i++)
  {
    cin>>x[i];
    num=num+x[i];
  }
  
  p=num/n;
  d_p=num/n;
  
  if(d_p>=p+0.5)
  {
    p=p+1;
  }
  
  for(int j=0;j<n;j++)
  {
    sum=sum+(x[j]-p)*(x[j]-p);
  }
  
  cout<<sum<<endl;

  return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int A, B; cin >> A >> B;
  string s;
  if(A == B) s = "Draw";
  else if(A < B) {
    if(A == 1) s = "Alice";
    else s = "Bob";
  } else {
    if(B == 1) s = "Bob";
    else s = "Alice";
  }
  cout << s << endl;
}

Measured memory_bytes: 256
if __name__=='__main__':
    N = int(input())
    hi = list(map(int,input().split()))
    dp = [0]*N
    dp[1] = abs(hi[0]-hi[1])
    
    for i in range(2,N):
        dp_1 = dp[i-1] + abs(hi[i]-hi[i-1])
        dp_2 = dp[i-2] + abs(hi[i]-hi[i-2])
        dp[i] = dp_1 if dp_1 < dp_2 else dp_2
            
    print(dp[-1])

Measured memory_bytes: 13928
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
ll per(ll n,ll x){
    ll ans = 1;
    rep(i,x)ans *= n-i;
    rep(i,x)ans /= i+1;
    ans %= 1000000000+7;
    return ans;
}
int main(){
    int n,k;
    cin >> n >> k;
    ll ans = 0;
    vector<ll>sum(n+1);
    sum[0] = 0;
    rep(i,n)sum[i+1] = sum[i] + i+1;
    for(int i = k;i <= n+1;i++){
        ll big = 0,sma = 0;
        if(n-i < 0)big = sum[n];
        else big = sum[n] - sum[n-i];

        sma = sum[i-1];
        //cout << i << ' ' << big << ' ' << sma << endl;
        ans += big - sma+1;
        ans %= 1000000000+7;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MAX=1e18;
ll mod=1e9+7;
#define pb push_back
#define se second
#define fi first
#define maxe max_element
#define mine min_element
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define boost  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
vector<int> graph[205];
int color[205];
int nCk[100][100];
bool bipartite_jugding(int v, int c){
    color[v] = c;
    for(int i = 0; i < graph[v].size(); ++i){
        if(color[graph[v][i]] == c) return false;
        if(color[graph[v][i]] == 0 && !bipartite_jugding(graph[v][i], -c)){
            return false;
        }
    }
    return true;
}

 void combi() {
	for (int i = 0; i <= 99; ++i) nCk[i][0] = 1;
	for (int i = 1; i <= 99; ++i) for (int j = 1; j <= i; ++j) {
		nCk[i][j] = (nCk[i-1][j] + nCk[i-1][j-1]) % mod;
	}
}

long long expo(ll x,ll n,ll M)
{

    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*expo((x*x)%M,(n-1)/2,M))%M;

}
ll h,n;
void solve()
{
    int t=1;
    //cin>>t;
    while(t--)
    {

   cin>>h>>n;
   vector<ll> a(n);ll sum=0;
   for(int i=0;i<n;i++){cin>>a[i];sum+=a[i];}
   if(sum>=h)
    cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;

   }
}

int main()
{
    boost;
  solve();
}


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

#define ll long long 
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define REP(i,n) for (int i=0; i<(n); i++)
#define RREP(i,n) for (int i=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define SQ(x) (x)*(x)
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define bug(x) cerr<<#x<<" is "<<x<<endl

using namespace std;

#define int ll

const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"First\n"; exit(0);}

ll mpow(ll a, ll n, ll mo = mod){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mo;
        a = a*a %mo;
        n>>=1;
    }
    return re;
}

ll inv (ll b, ll mo = mod){
    if (b==1) return b;
    return (mo-mo/b) * inv(mo%b) % mo;
}

const int maxn = 1e5+5;

int deg[maxn];
int col[maxn];
int nf[maxn];

main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n; cin>>n;
    vector<vector<int> > g(n);
    REP(i,n-1){
        int a, b; cin>>a>>b; g[a-1].pb(b-1); g[b-1].pb(a-1);
        deg[a-1]++; deg[b-1]++;
    }
    queue<int> cd;
    REP(i,n){
        for (int v : g[i]) {
            if (deg[v]==1) nf[i]++;
        }
        if (nf[i]==1) cd.push(i);
        if (nf[i]>1) GG();
    }
    while (!cd.empty()){
        int t = cd.front(); cd.pop();
        col[t] = 1; 
        // cout<<"Painted "<<t+1<<endl;
        for (int v : g[t]) {
            deg[v]--;
            if (deg[v]==0) col[v] = 2;
            else if (deg[v]==1){
                for (int u : g[v]){
                    if (col[u]) continue;
                    nf[u]++; if (nf[u]>1) GG();
                    cd.push(u);
                }
            }
        }
    }
    REP(i,n){
        if (col[i] == 1){ int mo = 1;
            for (int v : g[i]){
                if (col[v]==2) {
                    mo = 0; break;
                }
            } if (mo) GG();
        }
    }
    cout<<"Second"<<endl;
} 

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

num = min(a + b, c * 2)
a = min(a, c * 2)
b = min(b, c * 2)
s = min(x, y)

if x > y:
    print(num * s + a * (x - s))
else:
    print(num * s + b * (y - s))


Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {

	double v;
	
	while( scanf("%lf", &v) != EOF ) {
		int n;
		double t = v/9.8;
		double y = 4.9*t*t;
		
		for(n=0; 5*n-5<y; n++);
		
		printf("%d\n", n);
		
	}
	
	return 0;
}

Measured memory_bytes: 628
#define _overload(_1, _2, _3, _4, name, ...) name
#define _rep1(Itr, N) _rep3(Itr, 0, N, 1)
#define _rep2(Itr, a, b) _rep3(Itr, a, b, 1)
#define _rep3(Itr, a, b, step) for (llong (Itr) = a; (Itr) < b; (Itr) += step)
#define repeat(...) _overload(__VA_ARGS__, _rep3, _rep2, _rep1)(__VA_ARGS__)

#include <iostream>
using namespace std;
using llong = long long;

int main() {
    llong d, t, s;
    cin >> d >> t >> s;

    if (s * t < d) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
};


Measured memory_bytes: 3632
list=[];

for i in range(3):
    A, B = map(int, input().split())
    list.append(A);
    list.append(B);

townNum=[3,3,3,3];
result=0;

for i in list:
    townNum[i-1]-=1;
    if(townNum[i-1]==0):
        result=1;
        break;

if(result==1):
    print("NO");
else:
    print("YES");


Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	int n,x,N;
	scanf("%d",&N);
	x=sqrt(N);
	n=x*x;
	printf("%d\n",n);
	return 0;
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<long int> L(87);

	L.at(0) = 2;
	L.at(1) = 1;

	for (int i = 2; i < N + 1; i++) {
		L.at(i) = L.at(i - 1) + L.at(i - 2);
	}

	cout << L.at(N) << endl;
}

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

using namespace std;
const int N=1e4+55;
int dp[N][155][2];
int m=1e9+7;
string k;
int d;
int n;

int bt(int i , int s , bool q)
{
    if(i==-1)
        return (s==0);
    if(dp[i][s][q]!=-1)
        return dp[i][s][q];
    int ret=0;
    for(int j=0;j<=9;j++)
    {
        if(q&&(j==(k[i]-'0')))
        {
            ret+=bt(i-1,(s+j)%d,1);
            break ;
        }
        ret+=bt(i-1,(s+j)%d,0);
        ret%=m;
    }
    ret%=m;
    dp[i][s][q]=ret;
    return ret;
}

int main()
{
    memset(dp,-1,sizeof dp);
    ios::sync_with_stdio(false);
    cin>>k;
    n=k.size();
    reverse(k.begin(),k.end());
    cin>>d;
    cout<<(m+bt(n-1,0,1)-1)%m<<endl;
    return 0;
}


Measured memory_bytes: 13184
use std::str::FromStr;

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

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let n : i32 = get_one();
    let v : Vec<i32> = get_vec();

    let mut ans = Vec::new();
    let mut i = n-1;
    while i >= 0 {
        ans.push(v[i as usize]);
        i -= 2;
    }
    i = if n % 2 == 0 {0} else {1};
    while i < n {
        ans.push(v[i as usize]);
        i += 2;
    }
    let xs : Vec<String> = ans.iter().map(|e| e.to_string()).collect();
    let ans_str : String = xs.connect(" ");
    println!("{}", ans_str);
}


Measured memory_bytes: 17652
#include <bits/stdc++.h>
	using namespace std;
	#define mod 1000000007
	#define fi first
	#define se second
	#define mp make_pair
	#define pb push_back
	#define ps push
	#define pll pair<long,long>
	typedef long long ll;
	#define PI 3.14159265
	
	
	const ll INF=(ll)1e16;
	
	
	int main()
	{
		ios::sync_with_stdio(0); 
		cin.tie(0); 
		cout.tie(0);
		
		ll p,n;
		cin>>p>>n;
		vector<ll> v(n);
		for(ll i=0;i<n;i++)
		{
			cin>>v[i];
		}
		set<ll> s;
		for(ll i=1;i<n;i++)
		{
			s.insert({v[i]-v[i-1]});
		}
		s.insert({p-v[n-1]+v[0]});
		ll ans=INT_MAX;
		
		for(auto i:s)
		{
			
			ans=min(ans,p-i);
		}
		cout<<ans;
	}		


Measured memory_bytes: 1792
while (n1 = gets.to_i) != 0
  hash = Hash.new
  n1.times do
    c1, c2 = gets.split(" ")
    hash[c1] = c2
  end 
  n2 = gets.to_i
  n2.times do
    char = gets.chomp!
    char = hash[char] if hash[char]
    print char
  end 
  print "\n"
end

Measured memory_bytes: 2700