akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(){
  int n,i,j,top,tcos,bcos,bcal,tcal[100];
  // double calmax,acal,acos;
  int calmax,acal,acos;

  scanf("%d",&top);
  scanf("%d %d",&bcos,&tcos);
  scanf("%d",&bcal);
  for(i=0;i<top;i++){
    scanf("%d",&tcal[i]);
  }

  //sort
  for(i=0;i<top;i++){
    for(j=0;j<top;j++){
      if(j==top-1)break;
      if(tcal[j]<tcal[j+1]){
	n=tcal[j];
	tcal[j]=tcal[j+1];
	tcal[j+1]=n;
      }
    }
  }

  //syori
  calmax=(double)bcal/bcos;
  acal=bcal;
  acos=bcos;
  for(i=0;i<top;i++){
    acal+=tcal[i];
    acos+=tcos;
    if(calmax<acal/acos)calmax=acal/acos;
  }

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

  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, char *argv[])
{
  vector<int> N(4);
  for(int i = 0; i < 4; i++) {
    cin >> N.at(i);
  }
  auto result1 = find(N.begin(), N.end(), 1);
  auto result9 = find(N.begin(), N.end(), 9);
  auto result7 = find(N.begin(), N.end(), 7);
  auto result4 = find(N.begin(), N.end(), 4);
  if (result1 == N.end() || result9 == N.end() || result7 == N.end() || result4 == N.end() ) {
    std::cout << "NO" << std::endl;
  } else {
    std::cout << "YES" << std::endl;
  }
  return 0;
}


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

int main() {
  long long a,b;
  cin >> a >> b;
  long long x;
  cin >> x;
  
  if(x == 1){
    cout << b-a+1 << endl;
    return 0;
  }
  
  else{
    long long s=0;
    long long ra = a%x;
    long long rb = b%x;
    long long ka = (a-ra)/x;
    long long kb = (b-rb)/x;
    
    s = kb-ka;
    
    if(ra == 0){
      s++;
    }
    
    cout << s << endl;
    return 0;
  }
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    #define ll long long int
    #define MOD 1000000007
    using namespace std;
    ll dp [3001][3001];
    int main()
    {
        ll n,m;
        cin>>n>>m;
        char a[n+1][m+1];
        ll dp[n+1][m+1];
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                dp[i][j]=0;
            }
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                cin>>a[i][j];
            }
        }
        for(int i=0;i<n;i++){
            if(a[i][0]=='#'){
                break;
            }
            dp[i][0]=1;
        }
        for(int i=0;i<m;i++){
            if(a[0][i]=='#'){
                break;
            }
            dp[0][i]=1;
        }
        for(int i=1;i<n;i++){
            for(int j=1;j<m;j++){
                if(a[i][j]=='#'){
                    continue;
                }
                else{
                    dp[i][j]=(dp[i][j-1]+dp[i-1][j])%MOD;
                }

            }

        }
        cout<<dp[n-1][m-1]%MOD;
    }




Measured memory_bytes: 9088
/*
	f(i, w):- max f(i-1, w - b[i].w) + b[i].c, f(i-1, w)
*/
#include <bits/stdc++.h>

using namespace std;


const int INF = int(1e9);
struct info{
	int v;
	int w;
}e[100];

int N, W, b[101][10001];


int f( int i, int W ){

	if( W < 0 )
		return -INF;

	if( W == 0 )
		return 0;
	if(i == 0 )
		return 0;

	if(b[i][W] != 0)
		return b[i][W];

	b[i][W] =  max( f( i - 1, W - e[i].w ) + e[i].v, f( i - 1, W ) );
	return b[i][W];
}


int main( void ){

	//freopen("input.in", "r", stdin);
	scanf("%d%d", &N, &W);

	for( int i = 1; i <= N; ++i )
		scanf("%d%d", &e[i].v, &e[i].w);

	printf("%d\n", f(N, W));		

	return 0;
}

Measured memory_bytes: 4916
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    string s,t;cin>>s>>t;
    ll a=in(),b=in();
    --(in<string>()==s?a:b);
    cout<<a<<' '<<b<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using Edge = struct { int to, cost; };
bool operator<(const Edge &e1, const Edge &e2) {
  return (e1.cost != e2.cost) ? e1.cost > e2.cost : e1.to < e2.to;
}
template<class E>
using Graph = vector<vector<E>>;

const int INF = 1e9;

struct Dijkstra {
  vector<int> d;
  template<class E>
    Dijkstra(const Graph<E> &G, int s) {
      int N = G.size();
      priority_queue<Edge> pq;
      d.assign(N, INF); d[s] = 0;
      pq.push({s, 0});
      while (!pq.empty()) {
        Edge e = pq.top(); pq.pop();
        int u = e.to;
        if (d[u] < e.cost) continue;
        for (auto&& v : G[u]) {
          if (d[v.to] > d[u] + v.cost) {
            d[v.to] = d[u] + v.cost;
            pq.push({v.to, d[v.to]});
          }
        }
      }
    }
};

int main() {
  int N, M; cin >> N >> M;
  Graph<P> Gc(N);
  vector<unordered_set<int>> com(N);
  for (int i = 0; i < M; ++i) {
    int p, q, c; cin >> p >> q >> c;
    --p; --q;
    Gc[p].push_back({q, c});
    Gc[q].push_back({p, c});
    com[p].insert(c);
    com[q].insert(c);
  }
  int id = 0;
  map<P, int> mp;
  for (int i = 0; i < N; ++i) {
    com[i].insert(0);
    for (auto&& c : com[i]) mp[{i, c}] = id++;
  }
  Graph<Edge> Gd(id);
  for (int i = 0; i < N; ++i) {
    for (auto&& p : Gc[i]) {
      int j, c; tie(j, c) = p;
      int uid = mp[{i, c}];
      int vid = mp[{j, c}];
      Gd[uid].push_back({vid, 0});
    }
    for (auto&& c : com[i]) {
      if (!c) continue;
      int uid = mp[{i, c}];
      int vid = mp[{i, 0}];
      Gd[uid].push_back({vid, 1});
      Gd[vid].push_back({uid, 1});
    }
  }
  int sid = mp[{0, 0}];
  int tid = mp[{N - 1, 0}];
  int ans = Dijkstra(Gd, sid).d[tid];
  cout << ( (ans == INF) ? -1 : ans / 2 ) << endl;
  return 0;
}


Measured memory_bytes: 102908
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define ll  long long
#define ld  long double
#define pb push_back
#define mod 1000000007
#define M_PI 3.141592653589
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
ll binpow(ll a,ll b,ll m=mod) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
main()
{
     IO
     string s,t;
     cin>>s>>t;
     ll a=0;
     for(int x=0;x<s.length();x++)
     {
         if(s[x]!=t[x])
            ++a;
     }
     cout<<a;
}


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


int main(){
    int r, g, b, K;
    cin >> r >> g >> b >> K;
    int i = 0;
    while(r >= g){
        i++;
        g *= 2;
    }
    K -= i;
    i = 0;
    while(g >= b){
        i++;
        b *= 2;
    }
    K -= i;

    if(K >= 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3588
def isprime(n):
    check = 1
    if n == 2:
        pass
    elif n == 1 or n % 2 == 0:
        check = 0
    else:
        i = 3
        while i * i <= n:
            if n % i == 0:
                check = 0
                break
            else:
                i += 2
    return check
        

n = int(input())
ans = 0
for k in range(n):
    a = int(input())
    ans += isprime(a)
    
print(ans)


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

using namespace std;

int main()
{
    int S;
    
    scanf("%d", &S);
    
    while (S--){
        int A[9];
        for (int i = 0; i < 9; i++){
            scanf("%x", A + i);
        }
        
        int r = 0;
        int c = 0;
        for (int i = 0; i < 32; i++){
            int s = 0;
            for (int j = 0; j < 8; j++){
                s += ((A[j] >> i) & 1);
            }
            //printf("%d %d\n", ((s + c) & 1), ((A[8] >> i) & 1));
            if (((s + c) & 1) != ((A[8] >> i) & 1)){
                r |= (1 << i);
                c = (8 - s + c) / 2;
            }
            else {
                c = (s + c) / 2;
            }
        }
        
        printf("%x\n", r);
    }
    
    return (0);
}

Measured memory_bytes: 1196
N,M=map(int,input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
k=N//M + N%M
def macthing(y,x):
  flag=0
  for p in range(M):
    if A[y+p][x:x+M]!=B[p]:
      flag=1
      break
  if flag==0:
    return True
  else:
    return False
    
for i in range(k):
  for j in range(k):
    if macthing(i,j):
      print('Yes')
      exit()
print('No')

Measured memory_bytes: 9140
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n; cin >> n;
  int ma = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    int t; cin >> t;
    if (t >= ma) ans++;
    ma = max(ma, t);
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
const int  N = 2e5 + 314;
void foo(){
    string s;
    cin>>s;
    for(int i = 0; i < s.size(); i++)cout<<'x';   
}
int main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)foo();
}

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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int a;
    cin >> a;
    string b;
    cin >> b;
    int hundred_b = (b[0]-'0')*100 + (b[2]-'0')*10 + b[3]-'0';
    cout << a * hundred_b / 100 << endl;

    return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>

int main(void)
{
  int x,n;
  scanf("%d %d", &x, &n);

  if(n>0){
    int p[n];
    for(int i=0;i<n;i++){
      scanf("%d", &p[i]);
    }
    int tmp;
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
        if(p[i] > p[j]){
	  tmp = p[i];
	  p[i] = p[j];
	  p[j] = tmp;
        }
      }
    }

    int j=0;
    int ans;
    int dist=100;
    for(int i=-1;i<=101;i++){
      if(i==p[j]) j++;
      else{
        if(i<x) tmp = x - i;
        else tmp = i - x;

        if(dist>tmp){
	  dist = tmp;
	  ans = i;
        }
      }
    }
  
    printf("%d\n", ans);
  }
  else{
    printf("%d\n", x);
  }

  return 0;
}


Measured memory_bytes: 1680
#include <iostream>

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    if (x / d > k) cout << x - d * k << endl;
    else if ((k - (x / d)) % 2) cout << abs(x % d - d) << endl;
    else cout << x % d << endl;
    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>

int main(void){
    char S[100001];
    scanf("%s", S);

    int cnt0 = 0;
    int cnt1 = 0;
    int i;
    char *ps = S;
    while(*ps != '\0'){
        if(*ps == '0'){cnt0++;}
        else{cnt1++;}
      	ps++;
    }
    if(cnt0 > cnt1){printf("%d", 2 * cnt1);}
    else{printf("%d", 2 * cnt0);}

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

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


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

bool check(int n){
  int cnt=0,tmp=n;
  while(tmp)cnt++,tmp/=10;
  int size=a.size();
  for(int i=0;i<size;i++){
    int sum=a[i];
    for(int j=1;j<cnt&&(i+j)<size;j++)sum=sum*10+a[i+j];
    if(sum==n) return 0;
  }
  return 1;
}

int main(){
  int n;
  cin>>n;
  a.resize(n);
  for(int i=0;i<n;i++) cin>>a[i];
  int i=0;
  while(1){
    if(check(i))break;
    i++;
  }
  cout <<i<<endl;
  return 0;
}

Measured memory_bytes: 1200
def main():    
    N = int(input())
    D = [int(i) for i in input().split()]
    M = int(input())
    D.sort()
    T = [int(i) for i in input().split()]
    T.sort()

    point = 0
    for t in T:
        for p in range(point, N):
            if D[p] < t:
                continue
            elif D[p] == t:
                point = p+1
                #print(D[p])
                break

            elif D[p] > t:
                print('NO')
                return 
    print('YES')
    return

if __name__ == '__main__':
    main()


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

int main()
{
    int a,b,c; cin >> a >> b >> c;
    int maxn, minn;
    maxn = max(a, max(b, c));
    minn = min(a, min(b, c));
    cout << minn << " " << maxn << endl;
}


Measured memory_bytes: 3120
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner (System.in);
	int n = Integer.parseInt(scan.nextLine());
	int[][] graph = new int[n][n];
	int u, k, v;
	String[] input;
	for (int i = 0; i < n; i++) {
	    input = scan.nextLine().split(" ");
	    u = Integer.parseInt(input[0]);
	    k = Integer.parseInt(input[1]);
	    for (int j = 0; j < k; j++) {
		v = Integer.parseInt(input[2+j]);
		graph[u-1][v-1] = 1;
	    }
	}
	StringBuilder sb = new StringBuilder();
	for (int i = 0; i < n; i++) {
	    for (int j = 0; j < n-1; j++) {
		sb.append(graph[i][j] + " ");
	    }
	    sb.append(graph[i][n-1] + "\n");
	}
	System.out.print(sb);
    }
}

Measured memory_bytes: 28896
n,m = gets.chomp.split.map(&:to_i)
cities = []
m.times do |i|
  cities << gets.chomp.split.map(&:to_i) + [i]
end
cities.sort_by!{|i| i[1] }
ps = Array.new(n+1,0)
ans = Array.new(m)
cities.each do |p,y,i|
  ps[p] += 1
  s = ps[p].to_s.size
  x = "0"*(6-s) + ps[p].to_s
  p = "0"*(6-p.to_s.size) + p.to_s
  ans[i] = p + x
end

ans.each do |a|
  puts a
end 


Measured memory_bytes: 18120
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if((a + b) % 2 == 0) {
			System.out.println((a + b) / 2);
		}else {
			System.out.println((a + b ) / 2 + 1);
		}
		sc.close();
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define LLI long long int
#define MOD 1000000007
#define de(x) if( x && x == MODE)
#define MODE 0
using namespace std;

char K[100007] = {};
int D;
LLI dp[100007][107] = {};

int main() {
    int i,j;

    scanf("%s", K+1);
    scanf("%d", &D);
    int N = strlen(K+1);
    K[0] = '0';
    int pre = 0;
    for (i=0; i < N; i++) {
        pre += K[i]-'0';
        pre %= D;
        for (j=0; j < (K[i+1]-'0'); j++) {
            dp[i+1][ (pre+j) % D]++;
            dp[i+1][ (pre+j) % D] %= MOD;
        }
        for (j=0; j<D; j++) {
            for (int k=0; k <= 9; k++) {
                dp[i+1][ ( (j + k) % D + D ) % D] += dp[i][j];
                dp[i+1][ ( (j + k) % D + D ) % D] %= MOD;
            }
        }
    }
    pre += K[N]-'0';
    pre %= D;
    dp[N][pre] = ( dp[N][pre] + 1 ) % MOD;
    dp[N][0] = ( dp[N][0] - 1 + MOD) % MOD;

    de(1) {
        for (i=0; i<=N; i++) {
            printf("%d >>> ", i);
            for (j=0; j<D; j++) {
                printf("%lld ", dp[i][j]);
            }
            printf("\n");
        }
    }

    printf("%lld\n", dp[N][0]);

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N - 1);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        --A[i];
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> B[i];
        ans += B[i];
    }
    for (int i = 0; i < N - 1; i++)
    {
        cin >> C[i];
    }
    
    for (int i = 0; i < N - 1; i++)
    {
        if (A[i + 1] - A[i] == 1)
        {
            ans += C[A[i]];
        }
        
    }
    cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
// A - 台形

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const int MOD = 1e9 + 7;

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

	int ans = (a + b) * h / 2;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
int main()
{
    ll n,ans=0;
    cin>>n;
    ans=n+n*n+n*n*n;
    cout<<ans<<endl;

}


Measured memory_bytes: 3632
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n = inp()
    a = []
    b = []
    for _ in range(n):
        aa,bb = inpm()
        a.append(aa)
        b.append(bb)
    cnt = 0
    for i in range(n-1,-1,-1):
        if (a[i]+cnt)%b[i]!=0:
            cnt += b[i]-(a[i]+cnt)%b[i]
    print(cnt)
    
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 12144
//check check check
#include<iostream>
#include<vector>
#include<algorithm>
#include<fstream>
#include<queue>
#include<cstring>
#include<map>
#include<iomanip>

#define ll long long
#define pb(x) push_back(x)

using namespace std;

typedef pair<int,int> ii;

const int NMAX = 0;

string s1,s2;

int main()
{
    int a,b;

    cin>>a>>b;
    int start = 1;
    int cnt = 0;

    while(start < b)
    {
        start += (a-1);
        cnt++;
    }

    cout<<cnt;

}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        long[] a = in.nl(n);
        long[] b = new long[n];
        b[n-1] = a[n-1];
        for (int i = n-2; i >= 1; i--) {
            b[i] = b[i+1] + a[i];
            b[i] %= mod;
        }
        long ans = 0;
        for (int i = 0; i < n-1; i++) {
            ans += a[i]*b[i+1];
            ans %= mod;
        }
        out.println(ans);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 56740
/*************************************************************************
Author: ziki
Created Time: 2012-10-5 13:25:44
File Name: a.cpp
Description: 
************************************************************************/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <string.h>


using namespace std;

typedef long long int64;
typedef unsigned long long uint64;
#define two(X) (1<<(X))
#define twoL(X) (((int64)(1))<<(X))
#define contain(S,X) (((S)&two(X))!=0)
#define containL(S,X) (((S)&twoL(X))!=0)
const double pi=acos(-1.0);
const double eps=1e-11;
const int inf=0x7FFFFFFF;
template<class T> inline void checkmin(T &a,T b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,T b){if(b>a) a=b;}
template<class T> inline T sqr(T x){return x*x;}
typedef pair<int,int> ipair;
#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define zero(a) memset(a, 0, sizeof(a))
#define out(x) (cout<<#x<<": "<<x<<endl)
template<class T>void show(T a, int n){for(int i=0; i<n; ++i) cout<<a[i]<<' '; cout<<endl;}
template<class T>void show(T a, int r, int l){for(int i=0; i<r; ++i)show(a[i],l);cout<<endl;}

int id(int h) {
	if(h>=11 && h<=14) return 0;
	if(h>=18 && h<21) return 1;
	if(h>=21 && h<=24 || h>=0 && h<=1) return 2;
	return -1;
}
int main()
{
	int n;
	string str[3] = {"lunch","dinner","midnight"};
	while( cin>>n&& n) {
		int h,m,mm;
		int ok[3] = {0}, s[3] = {0};
		for (int i=0; i<n; i++) {
			scanf("%d%*c%d%d",&h,&m,&mm);
			int t = id(h), co;
			if(t>=0) {
			co = mm - m;
			if(co<0) co += 60;
			if(co<=8) ok[t]++;
			s[t]++;
			}
		}
		for (int i=0; i<3; i++) {
			cout<<str[i]<<' ';
			if(s[i]) 
				printf("%d\n",ok[i]*100/s[i]);
			else
				printf("no guest\n");
		}
		
	}
	return 0;
}

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

r = ''
for i in range(1, n+1):
    x = i
    if x % 3 == 0:
        r += ' '+str(x)
        continue
    while x > 0 and x % 10 != 3:
        x = x // 10
    if x % 10 == 3:
        r += ' '+str(i)
print(r)

Measured memory_bytes: 7628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var p = Input().ToInt();
		int k = 0;
		for(int i = 1; i < n-1; i++)
		{
			var max = Math.Max(p[i+1], Math.Max(p[i], p[i-1]));
			var min = Math.Min(p[i+1], Math.Min(p[i], p[i-1]));
			
			if(p[i] != max && p[i] != min)
			{
				k++;
			}
		}
		Console.WriteLine(k);
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 13140
Tiles=input()

N_len=len(Tiles)
type1 = sum( 1 if Tiles[i] == str(i%2) else 0 for i in range(N_len))
type2 = sum( 0 if Tiles[i] == str(i%2) else 1 for i in range(N_len))
print(min(type1,type2))

Measured memory_bytes: 3188
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a[100010],b[100010],c[100010],ans=0;
    cin>>n;
    rep(i,n){
        cin>>a[i]>>b[i];
        ans-=b[i];
        c[i]=a[i]+b[i];
    }
    sort(c,c+n);
    reverse(c,c+n);
    ll cnt=n/2+n%2,i=0;
    while(cnt>0){
        ans+=c[i];
        i+=2;
        cnt--;
    }
    cout<<ans<<endl;
    return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int main() {
   string s;
   cin >> s;
   reverse(all(s));

   string dreamer = "dreamer";
   string dream = "dream";
   string erase = "erase";
   string eraser = "eraser";
   reverse(all(dreamer));
   reverse(all(dream));
   reverse(all(erase));
   reverse(all(eraser));

   int n = s.size();
   for (int i = 0; i < n; ) {
      string str5 = s.substr(i, 5);
      string str6 = s.substr(i, 6);
      string str7 = s.substr(i, 7);
      if (str5 == dream || str5 == erase) {
         i += 5;
      } else if (str6 == eraser) {
         i += 6;
      } else if (str7 == dreamer) {
         i += 7;
      } else {
         puts("NO");
         return 0;
      }
   }

   puts("YES");

   return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	vector<int> h(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	int ans = 0;
	int tmp = 0;

	for (int i = 1; i < n; i++) {
		if (h[i-1] >= h[i]) {
			tmp++;
			ans = max(ans, tmp);
		} else {
			tmp = 0;
		}
	}

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


Measured memory_bytes: 640
// AOJ 2040 Sort the Panels
// 2018.3.13 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define QMAX 300000
typedef struct { int s; char p; char t; } QUE;
QUE que[QMAX]; int qsize, qmax;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t, char p)
{
	int i, min;
	QUE qt;

	i = qsize++;	//if (qsize > qmax) qmax = qsize;
	que[i].s = s, que[i].t = t, que[i].p = p;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define ABS(a)  ((a)>=0?(a):-(a))
char dist[1<<16][16];

int dijkstra(int n, int nb, int start, int goal)
{
	int i, j, k, m, s, t, p, ns, nt, nw;
	int pi, ij;

	memset(dist, 75, sizeof(dist));
	qsize = 0;
	t = -1, nw = n - nb;
	for (p = 0; p < n; p++) dist[start][p] = 0, enq(start, 0, p);
	while (qsize) {
		s = que[0].s, t = que[0].t, p = que[0].p, deq();
		if (s == goal) break;

		if (dist[s][p] < t) continue;

		for (k = i = 0; k < nb; i++) if (s & (1<<i)) { k++, pi = ABS(p-i);
			for (m = j = 0; m < nw; j++) if (!(s & (1<<j))) { m++;
				ij = ABS(j-i);
				ns = s ^ (1<<i) ^ (1<<j);
				nt = t + pi+ij;
				if (dist[ns][j] > nt) dist[ns][j] = nt, enq(ns, nt, j);
				nt = t + ABS(p-j)+ij;
				if (dist[ns][i] > nt) dist[ns][i] = nt, enq(ns, nt, i);
			}
		}
	}
	return t;
}

int calc(char *s) { int res=0; while (*s > ' ') res = (res<<1)|(*s++ == 'B'); return res; }

int main()
{
	int n, nb, start, goal;
	char buf[20], *p;

	while (fgets(buf, 10, stdin) && *buf != '0') {
		n = atoi(buf);
		fgets(p=buf, 20, stdin); nb = 0; while (*p > ' ') if (*p++ == 'B') nb++;
		start = calc(buf);
		fgets(buf, 20, stdin), goal = calc(buf);
		if (nb > n-nb) {
			nb = n-nb;
			start = ~start & ((1<<n)-1), goal = ~goal & ((1<<n)-1);
		}
		printf("%d\n", dijkstra(n, nb, goal, start));
	}
	return 0;
}


Measured memory_bytes: 4384
#include<cstdio>

int main()
{
    char c[5][5];
    scanf("%s %s", &c[0], &c[1]);

    if (c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0])
        printf("YES");
    else
        printf("NO");
}

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

int main(){
  string s, t; cin >> s >> t;
  int a, b; cin >> a >> b;
  string u; cin >> u;
  if(s == u) a--;
  else b--;

  cout << a << " " << b << endl;

  return 0;
}

// EOF


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

int main(void){
	int a, b, c, k;
	int max;
	scanf("%d %d %d %d",&a,&b,&c,&k);
	max = a;
	if(max < b)max = b;
	if(max < c)max = c;
	
	printf("%d\n",(max*(int)(pow(2,(double)k)))+a+b+c-max);

	return 0;
}

Measured memory_bytes: 128
import fractions
A,B,C,D = map(int, input().split())
BC = B//C
if A%C == 0:
    AC = A//C-1
else:    
    AC = A//C
BD = B//D
if A%D == 0:
    AD = A//D - 1
else:
    AD = A//D
GCD = C*D//fractions.gcd(C,D)
BB = B//GCD
if A%GCD == 0:
    AA = A//GCD - 1
else:
    AA = A//GCD
print((B-A+1)-(BC-AC)-(BD-AD)+(BB-AA))

Measured memory_bytes: 5304
fun main(args: Array<String>) {
    val S = readLine()!!
    val Q = readLine()!!.toInt()
    // var isReversed = false
    val queries = (1..Q).map {
        val line = readLine()!!.split(" ")
        if(line.size > 1) {
            Pair(line[0].toInt(), Pair(line[1].toInt(), line[2]))
        } else {
            Pair(line[0].toInt(), null)
        }
    }
    val when_fliped_pairs = mutableListOf<Pair<Int, Pair<Int, String>>>()
    var flip_counter = 0
    for(query in queries) {
        flip_counter += if(query.first == 1) {1} else {0}
        query.second?.run {
             when_fliped_pairs.add(Pair(flip_counter, this)) 
        }
    }
    val prefix_appendees = mutableListOf<String>()
    val suffix_appendees = mutableListOf<String>()
    for(query in when_fliped_pairs) {
        when(Pair((flip_counter - query.first) % 2 == 0, query.second.first == 1)) {
                   Pair(false, false), Pair(true, true) -> {
                    prefix_appendees.add(query.second.second)
                }
                else -> {
                    suffix_appendees.add(query.second.second)
                }
        }
    }
   (prefix_appendees.reversed().joinToString("") + if(flip_counter % 2 == 1) { S.reversed() } else { S } + suffix_appendees.joinToString("")).run(::println)
}

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

bool is_prime[1000000];
int number[1000000] = {0};
void init_prime() {
    memset(is_prime, true, 1000000);
    for (int i = 2; i <= 999999; i++) {
        if (is_prime[i]) {
            number[i] = number[i-1]+1;
            for (int j = 2*i; j <= 999999; j+=i)
                is_prime[j] = false;
        } else
            number[i] = number[i-1];
    }
}

int main() {
    init_prime();

    int n;
    while (cin >> n) {
        cout << number[n] << endl;
    }
    return 0;
}

Measured memory_bytes: 7964
#include <stdio.h>

int main(){
  
	char arr[10];
	
	scanf("%s",arr);
	
	arr[0] = '2';
	arr[1] = '0';
	arr[2] = '1';
	arr[3] = '8';
	
	for(int i=0;i<10;i++){
		printf("%c",arr[i]);
	}
  
    return 0;
}

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

int main() {
    string s,t;
    cin >> s >> t;
    int ans = 1005;
    rep(i, s.size() - t.size() + 1){
        int a = 0;
        rep(j,t.size()){
            if(s.at(i+j) != t.at(j)){
                a++;
            }
        }
        ans = min(ans, a);
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3620
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int H, W;
  cin>>H>>W;
  int sx, sy, gx, gy;
  cin>>sx>>sy>>gx>>gy;
  sx--;
  sy--;
  gx--;
  gy--;
  vector<string> S(H);
  for(int i=0;i<H;++i) cin>>S[i];
  priority_queue<tuple<int, int, int>, vector<tuple<int, int, int> >, greater<tuple<int, int, int> > > que;
  tuple<int, int, int> state;
  int x, y, cost;
  que.push(make_tuple(0, sx, sy));
  int ans[H][W];
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      ans[i][j] = -1;
    }
  }
  int xx, yy;
  while(!que.empty()) {
    state = que.top();que.pop();
    x = get<1>(state);
    y = get<2>(state);
    cost = get<0>(state);
    if(ans[x][y]>-1) continue;
    ans[x][y] = cost;
    for(int i=-2;i<=2;++i) {
      for(int j=-2;j<=2;++j) {
        xx = x+i;
        yy = y+j;
        if(xx<0 || H<=xx || yy<0 || W<=yy) continue;
        if(S[xx][yy]=='#') continue;
        if(ans[xx][yy]>-1) continue;
        if(abs(x-xx)+abs(y-yy)==1) que.push(make_tuple(cost, xx, yy));
        else que.push(make_tuple(cost+1, xx, yy));
      }
    }
  }
  cout<<ans[gx][gy]<<endl;
}



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

int main() {
	long double W, H;
	long double V;
	int x, y;

	std::cin >> W >> H >> x >> y;

	V = W * H / 2;
	std::cout << V << "\n";

	if (W / 2 == x && H / 2 == y) std::cout << "1\n";
	else std::cout << "0\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	string s; cin >> s;
	int n = s.size();
	ll ans = 0;
	rep(bit, (1 << (n - 1))) {
		ll a = s[0] - '0';
		rep(i, n - 1) {
			if (bit & (1 << i)) {
				ans += a;
				a = 0;
			}
			a = a * 10 + s[i + 1] - '0';
		}
		ans += a;
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
// 152

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

int main() {
    int n;
    cin >> n;
    vector <int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    int ans = 1;
    int data = p[0];
    for (int i = 1; i < n; i++) {
        if (data > p[i]) {
            data = p[i];
            ans = ans + 1;
        }
    }
        cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>

int main() {
  std::string s, t;
  std::cin >> s >> t;
  std::sort(s.begin(), s.end());
  std::sort(t.rbegin(), t.rend());
  if (t>s) {
    std::cout << "Yes" << std::endl;
  }
  else {
    std::cout << "No" << std::endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define input freopen("1.txt","r",stdin);
#define output freopen("output.txt","w",stdout);
#define ll long long int
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
#define pii pair<int, int>
#define pll pair<ll,ll>
#define mp make_pair
#define vpi vector<pii>
#define vpl vector<pll> 
using namespace std;
 
const int p=1e9+7;
const int maxn=1e5+2;

void solve() {
    int N; cin>>N;
    int h[N]; 
    for(int i=0; i<N; i++) cin>>h[i];
    int DP[N] = {0};
    for(int i = 1; i < N; i++) {
        DP[i] = (i > 1) ? min(DP[i-1] + abs(h[i] - h[i-1]), DP[i-2] + abs(h[i] - h[i-2])) : abs(h[1] - h[0]);
    }
    cout << DP[N-1] << "\n";
}

int main() {
    fast 
    // input output
    int t=1; 
    // cin>>t; 
    while(t--) solve();
    return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define INF (ll)1e18

ll A;
double B;
ll B2;

ll i, j, k;

int main(){
    scanf("%lld%lf", &A,&B);
    B2 = (ll)(B * 100 + 1e-9);
    printf("%lld\n", A * B2 / 100);
    return 0;
}

Measured memory_bytes: 3828
#python3
from collections import deque

INF = int(1e20)
di = [1, 0, -1, 0]
dj = [0, 1, 0, -1]

def main():
    h, w = map(int, input().split())
    maze = [input() for i in range(h)]
    ans = 0

    for si in range(h):
        for sj in range(w):
            if maze[si][sj] == '#':
                continue
            dist = [[INF for i in range(w)] for j in range(h)]
            q = deque()

            def update(i, j, x):
                if dist[i][j] != INF:
                    return None
                dist[i][j] = x
                q.append((i,j))
            
            update(si, sj, 0)
            while len(q) != 0:
                i, j = q.popleft()

                for dir in range(4):
                    ni = i+di[dir]
                    nj = j+dj[dir]
                    if (ni<0)|(ni>=h)|(nj<0)|(nj>=w):
                        continue
                    if maze[ni][nj] == '#':
                        continue
                    update(ni, nj, dist[i][j]+1)
        
            for i in range(h):
                for j in range(w):
                    if dist[i][j] == INF:
                        continue
                    ans = max(ans, dist[i][j])
    print(ans)

main()

Measured memory_bytes: 3316
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In,' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var H = cin.ReadInt;
            var N = cin.ReadInt;

            var sum = 0;
            for(var i = 0 ;i<N;i++){
                sum += cin.ReadInt;
            }

            WriteLine(H <= sum ? "Yes" : "No");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream,char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0;i < tmp.Length;i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }

}

Measured memory_bytes: 18400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  vector<int> l(n);
  REP(i, n) cin >> l[i];
  SORT(l);
  int ans = 0;
  REP(i, n - 2) {
    int a = l[i];
    FOR(j, i + 1, n - 2) {
      int b = l[j];
      FOR(k, j + 1, n - 1) {
        int c = l[k];
        if (a == b || b == c || c == a) continue;
        if (a + b <= c) continue;
        ans++;
      }
    }
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


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

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

ll N;
ll A[200005];
ll used[30];
ll cnt;

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

	cin >> N;

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

	ll l = 0;
	ll r = 0;
	ll ans = 0;

	while(true){
		while(cnt == 0 && r < N){
			for (int i = 0;i < 25;i++){
				if(A[r]&(1<<i)){
					used[i]++;
					if(used[i] >= 2) cnt++;
				}
			}
			r++;
			if(cnt == 0) ans += r-l;
		}
		if(r >= N && cnt == 0) break;
		for (int i = 0;i < 25;i++){
			if(A[l]&(1<<i)){
				used[i]--;
				if(used[i] > 0) cnt--;
			}
		}
		l++;
		if(cnt == 0) ans += r-l;
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 1792
import java.util.*;

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int x=sc.nextInt();

		int cnt = 1;
		int sum=0;

		for(int i=0; i<n; i++) {
			int l=sc.nextInt();
			sum += l;
			if(sum<=x) {
				cnt++;
			}
		}
		System.out.println(cnt);
		sc.close();
	}
}


Measured memory_bytes: 36156
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true){
            final int times = Integer.parseInt(br.readLine());
            if (times == 0) { break; }
            
            Map<String, Long> data = new LinkedHashMap<>();
            for (int i=1; i <= times; i++) {
                String[] e = br.readLine().split(" ");
                data.merge(e[0], Long.parseLong(e[1]) * Long.parseLong(e[2]), Long::sum);
            }
            
            long count = data.entrySet().stream()
                .filter(e -> e.getValue() >= 1_000_000L)
                .peek(e -> System.out.println(e.getKey()))
                .count();
            if (count == 0L) { System.out.println("NA"); }
        }
    }
}

Measured memory_bytes: 32052
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n,a,b;
    cin>>n>>a>>b;
    if(b<a){
        cout<<0<<endl;
        return 0;
    }
    if(n==1){
        if(a!=b){
            cout<<0<<endl;
        }else{
            cout<<1<<endl;
        }
        return 0;
    }
    cout<<(b-a)*(n-2)+1<<endl;
    
}


Measured memory_bytes: 3652