akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main()
{
    int n,sum=0;
    cin>>n;
    int ara[n];
    for(int y=0;y<n;y++){
        cin>>ara[y];
    }

    for(int j=0;j<n;j++){

       for(int y=j+1;y<n;y++){
        sum=sum+ara[j]*ara[y];
    }
    }
    cout<<sum<<endl;
    return 0;

}


Measured memory_bytes: 256
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre(){ fac[0]=1; fac[1]=1; for(int i=2;i<2000005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE

signed main()
{   



      
      senky_bansal
      IIIT_ALLAHABAD
      
      pre();
      ll t;
      // cin>>t;
      t=1;
      while(t--)
      { 
         ll r1,c1,r2,c2;
         cin>>r1>>c1>>r2>>c2;
         ll ans =0;
         for(int i=c1;i<=c2;i++)
         {
             ll p1 = (ncr(r2+i+1,i+1)-ncr(r1+i,i+1)+mod)%mod;
             p1+=mod;
             p1%=mod;
             ans+=p1;
             ans%=mod;
         }
         cout<<ans%mod;
         

      }
      






}



























Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
int dp[3000][3000];
int main() {
  string a, b;
  cin >> a >> b;
  for (int i = 0; i < a.size(); i++) {
    for (int j = 0; j < b.size(); j++) {
      if (!i && !j)
        dp[i][j] = (a[0] == b[0]);
      else if (!i)
        if (a[i] == b[j])
          dp[i][j] = 1;
        else
          dp[i][j] = dp[i][j - 1];
      else if (!j)
        if (a[i] == b[j])
          dp[i][j] = 1;
        else
          dp[i][j] = dp[i - 1][j];
      else if (a[i] == b[j])
        dp[i][j] = dp[i - 1][j - 1] + 1;
      else
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
    }
  }
  int i = a.size() - 1, j = b.size() - 1;
  string res = "";
  while (i != -1 && j != -1) {
    if (a[i] == b[j]) {
      res += a[i];
      i--; j--;
    }
    else if (i && dp[i - 1][j] == dp[i][j])
      i--;
    else
      j--;
  }
  reverse(res.begin(), res.end());
  cout << res;
  return 0;
}

Measured memory_bytes: 38772
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
    ll N, Y;
    cin >> N >> Y;
    for (ll i = 0; (i <= N); ++i) {
        if (i*1000 > Y) break;
        for (ll j = 0; (j <= N); ++j) {
            if (i*1000+j*5000 > Y) break;
            if (i*1000 + j*5000 + (N-i-j)*10000 == Y) {
                cout << (N-i-j) << " " << j << " " << i << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair < int, int > pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 100005;

int n, sg[MAXN];
vector < int > adj[MAXN];

inline void Dfs(int x, int f)
{
	for (auto y : adj[x])
		if (y ^ f)
			Dfs(y, x), sg[x] ^= sg[y] + 1;
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read();
	for (int i = 1, x, y; i < n; i ++)
		x = Read(), y = Read(), adj[x].pb(y), adj[y].pb(x);

	Dfs(1, 0);

	if (sg[1])
		puts("Alice");
	else
		puts("Bob");
}


Measured memory_bytes: 9216
#include<iostream>
#include<cctype>
#include<string>
using namespace std;


int main(){
    string word,str;
    cin >> word;

    for(int i=0; i<word.size(); i++){
        word[i] = tolower(word[i]);
    }

    int n = 0;

    while(1){
        cin >> str;
        if( str == "END_OF_TEXT" ) break;
        for(int j=0; j<str.size();j++){
            str[j] = tolower(str[j]);
        }
        if( word == str ) n++;
    }

    cout << n << endl;
   
    return 0;
}


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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ii bin_search(ll m, ll N, const vector<ll>& xs, const vector<ll>& ps)
{
    ll count = 0, sum = 0;

    for (int i = 0; i < N; ++i)
    {
        auto j = lower_bound(xs.begin(), xs.end(), m - xs[i]) - xs.begin();

        if (j < N)
        {
            auto n = (N - j);
            count += n;
            sum += ps[N - 1] - (j ? ps[j - 1] : 0) + n*xs[i];
#ifdef DEBUG
    cout << "+++ i = " << i << ", xs[" << i << "] = " << xs[i] << ", j = " << j << ", xs[" << j << "] = " << xs[j] << ", sum = " << xs[i] + xs[j] << endl;
    cout << "=== new count = " << count << ", new  sum = " << sum << endl;
#endif
        }
    }

    return { count, sum };
}

ll solve(ll N, ll M, vector<ll>& xs)
{
    sort(xs.begin(), xs.end());

    vector<ll> ps(N, 0);
    ps[0] = xs[0];

    for (int i = 1; i < N; ++i)
        ps[i] = ps[i - 1] + xs[i];

    ll ans = 0, a = xs.front() + xs.front(), b = xs.back() + xs.back(), m = 0, count = 0,
        bestm = 0;
#ifdef DEBUG
    cout << "xs = ";
    for (auto x : xs)
        cout << x << ' ';
    cout << endl;
    cout << "ps = ";
    for (auto x : ps)
        cout << x << ' ';
    cout << endl;
    cout << "a = " << a << ", b = " << b << endl;
#endif

    while (a <= b)
    {
        m = a + (b - a)/2;
        //m = 69969;
        auto p = bin_search(m, N, xs, ps);
#ifdef DEBUG
cout << "=== m = " << m << ", a = " << a << ", b = " << b << ", : (" << p.first << ", " << p.second << ")" << endl;
#endif 
        if (p.first >= M)
        {
            ans = p.second;
            count = p.first;
            bestm = m;
            a = m + 1;
        } else
            b = m - 1;
   //     break;
    }
 
    while (count > M)
    {
        ans -= bestm;
        --count;
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    ll N, M;
    cin >> N >> M;

    vector<ll> xs(N, 0);

    for (int i = 0; i < N; ++i)
        cin >> xs[i];

    auto ans = solve(N, M, xs);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n=0;
  int max=0;
  int count=1;
  cin >> n;
  
  vector<string> vec(n);
  for (int i = 0; i < n; i++) {
      cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  
  for (int i = 0; i < n-1; i++) {
    //  cout << vec.at(i) <<endl;
     if(vec.at(i)==vec.at(i+1)){
         count++;
     }
     else{
         count=1;
     }
     if(max<count){
         max=count;
     }
    //  cout<<max<<endl;
          }
          
          count=1;
          
          if(max==1){
              for (int i = 0; i < n; i++) {
                  cout<< vec.at(i) << endl;
              }
          }
          else{
          for (int i = 0; i < n-1; i++) {
     if(vec.at(i)==vec.at(i+1)){
         count++;
         if(count==max){
             cout<< vec.at(i) << endl;
         }
     }
     else{
         count=1;
     }
          }
          }
  
  
  
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
#define benfero freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define mm ' '
#define nl '\n'
#define MOD 1000007
typedef unsigned long long int ull;
typedef long long int ll;
int main()
{
    //benfero
    ll n;
    cin>>n;
    cout<<n*n<<endl;

    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  static int mod = 1000000007;
  public static long frac(int n){//n!(mod)の導出

    long ans = 1;
    for(int i=2;i <=n; i++){
      ans *= i;
      ans %= mod;
        }

    return ans;
  }

  public static long modpow(long a,long n, long mod){
    //a^n modの計算
    long res = 1;
    while(n>0){
      if(n%2==1){res = res * a % mod;}
      a = a * a % mod;
      n>>=1;//右に１ビット論理シフト
    }
    return res;
  }

  static long modinv(long a,long mod){
    //a^(-1)modの計算（逆元の計算）
    return modpow(a,mod-2,mod);
  }

  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    int x = sc.nextInt();
    int y = sc.nextInt();

    double a = (2*(double)x-(double)y)/3;
    double b = (2*(double)y-(double)x)/3;

    if(((2*x-y)%3==0&&(2*y-x)%3==0)&&(2*x-y>=0&&2*y-x>=0)){
      int aa = (int)a;
      int bb = (int)b;
      int cc = aa + bb;

      //(aa+bb)Caaの組み合わせ解のmodの導出
      long ans1 = frac(aa+bb); //(aa+bb)!のmod
      long ans2 = modinv(frac(aa),mod);
      long ans3 = modinv(frac(bb),mod);
      long ans4 = ((ans1*ans2)%mod*ans3)%mod;
      System.out.println(ans4);




    }else{
      System.out.println("0");
    }

  }
}


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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long

static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const ll INF = 1e18;

int main() {

    int A, B;
    cin >> A >> B;
    cout << A*B << endl;

}

/*
みんな、くるくるぱーにな〜れ
　∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/



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

long long pre[100005],A[100005];

int main()
{
	int N;
	scanf("%d",&N);
	
	int i;
	
	for (i=1;i<=N;i++)
	{
		cin>>A[i];
	}
	
	sort(A+1,A+N+1);
	
	for (i=1;i<=N;i++)
	pre[i]=pre[i-1]+A[i];
	
	int p=0;
	for(i=N-1;i>0;i--)
	{
		if(pre[i]*2<A[i+1])
		{
			p=i;
			break;
		}
	}
	
	cout<<N-p;
	
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	string s;
	cin >> n;
	set<string> w;	
	string p;
	bool valid = 1;
	rep(i,0,n){
		cin >> s;	
		if(i != 0 && s.front() != p.back()){
			valid = false;
			break;
		}
		if(w.find(s) != w.end()){
			valid = false;
			break;
		}
		else{
			w.insert(s);
			p = s;
		}
	}
	cout << (valid?"Yes":"No") << '\n';
}


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

int main() {
    int r, n;
    while (cin >> r >> n, r | n) {
        map<int, int> mp;
        for (int i = 0; i < n; i++) {
            int l, r, h;
            cin >> l >> r >> h;
            for (int i = l; i < r; i++) mp[i] = max(mp[i], h);
        }
        double ans = 100.0;
        for (int i = - r; i < r; i++) {
            double p = (i < 0 ? i + 1 : i);
            ans = min(ans, mp[i] + r - sqrt(r * r - p * p));
        }
        cout << fixed << setprecision(10) << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3236
#include <cstdio>
#include <iostream>
 
typedef unsigned long long ull;
int x[201000];
int k, n;
ull b[201000];

int main()
{
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; i++) scanf("%d", &x[i]), b[i] = b[i - 1] + x[i];
	ull ans = 18446744073709551615ull; //ULLONG_MAX
	for(int i = 1; i <= n; i++)
	{
		ull res = 0; ull s = 1;
		for(int j = n; j >= 1; j -= i, s++)
		{
			if(s == 1) res += (b[j] - b[std::max(0, j - i)]) * 5;
			else res += (b[j] - b[std::max(0, j - i)]) * ((s + 1) * (s + 1) - s * s);
		}
		res += 1ull * i * k;
		ans = std::min(ans, res);
	}
	printf("%llu\n", ans + 1ull * n * k);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  while(B <= A) {
    B *= 2;
    K--;
  }
  while(C <= B) {
    C *= 2;
    K--;
  }
  yes(K >= 0);
}

Measured memory_bytes: 3644
import java.util.*;

public class Main {
	public static void main(String args[]) {
		
		Scanner ob = new Scanner(System.in);
		int N = ob.nextInt();
		int X = ob.nextInt();
		int T = ob.nextInt();
		int result = 0;
		
		while(N > 0) {
			N -= X;
			result += T;
		}
		System.out.println(result);
		ob.close();
	}
}


Measured memory_bytes: 35804
#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()
using ll = long long;
using P = pair<int,int>;
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};
//const int INF = (1 << 29);


int main(){

  int n;
  cin >> n;
  vector<pair<string,int>> v;
  map<pair<string,int>,int> mp;
  rep(i,n){
    string s;int k;cin >> s >> k;
    v.push_back({s,k});
    mp[{s,k}] = i+1;
  }
  sort(all(v));
  rep(i,n)for(int j = i+1;j < n;j++)if(v[i].first == v[j].first && v[i].second < v[j].second)swap(v[i],v[j]);
  rep(i,n)cout << mp[v[i]] << endl;


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;

int calc(int a)
{
    int sum=0,i;
    for (i=1;i<=a;i++)
    {
        if (a%i==0) sum++;
    }
    return sum;
}

int main()
{
    int n,i,ans=0;
    scanf("%d",&n);
    if (n%2==0) n--;
    for (i=1;i<=n;i+=2)
    {
        int tmp=calc(i);
        if (tmp==8) ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define NFOR(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); --i)
#define rep(i, a) for (ll i = 0; i < a; i++)
#define endl "\n"
#define fi first
#define se second
#define MOD 1000000007
#define inf 1e12
#define pb push_back
#define Case cout<<"Case #"<<++cas<<": ";
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) v.begin(),v.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;

#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}

void solve() {
	ll n, W;
	cin >> n >> W;
	vl w(n), v(n);
	rep(i, n) cin >> w[i] >> v[i];

	ll dp[n+1][W+1];
	rep(i, n+1) dp[i][0] = 0;
	rep(i, W+1) dp[0][i] = 0;
	FOR(i, 1, n)
		FOR(j, 1, W) 
			dp[i][j] = max(dp[i-1][j], (j >= w[i-1]) ? (dp[i-1][j-w[i-1]] + v[i-1]) : 0LL);

	cout << dp[n][W] << endl;
}

int main()
{
    fastio;
    ll t  = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 79232
#include <iostream>

int S(int n) {
	if(n <= 9) {
		return n;
	}
	return (n % 10) + S(n / 10);
}

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

	std::cout << ((N % S(N) == 0) ? "Yes" : "No") << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<stack>
#include<string>
#include<cstdlib>
using namespace std;
int main(){
    string t;
    stack<int>a;
    int t1;
    
    while(cin>>t){
        if(t=="+"){
            t1=a.top();a.pop();
            t1+=a.top();a.pop();
            a.push(t1);
    }else if(t=="*"){
            t1=a.top();a.pop();
            t1*=a.top();a.pop();
            a.push(t1);
    }else if(t=="-"){
        t1=-a.top();a.pop();
        t1+=a.top();a.pop();
        a.push(t1);
    }else a.push(atoi(t.c_str()));
    }
    cout<<a.top()<<endl;
    return 0;
}



Measured memory_bytes: 3192
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;

int N;
const int MAX_N = 100010;

ll a[MAX_N];

int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+N+1);
	for(int i=1;i<=N;i++){
		a[i]+=a[i-1];
	}

	int i=N;
	while(a[i]<=3*a[i-1]){
		i--;
	}
	printf("%d\n",N+1-i);
	return 0;	
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll a,b;
    cin>>a>>b;
    cout<<a*b-a-b+1<<"\n";
}


Measured memory_bytes: 256
n = int(input())
a = [int(input()) for _ in range(n)]
left = [0]*n
right = [0]*n
for i in range(1, n):
    left[i] = max(left[i-1], a[i-1])
    right[n-i-1] = max(right[n-i], a[n-i])
for i in range(n):
    print(max(left[i], right[i]))


Measured memory_bytes: 15636
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f;








void sol()
{   
    cin>>x>>n;
    in(a,n);
    c=0;
    for(auto p:a)c+=p;
    
    
    
    cout<< ((c>=x)?"Yes":"No") <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
#define N 100010
int n,num,cnt,root,h[N],g[N],fa[N],in[N],out[N],vis[N],a[N];
struct node{int to,next;}mp[N],eg[N<<1]; 
inline void ins(int x,int y){
	mp[++num].to=y;mp[num].next=h[x];h[x]=num;
}
inline void add(int x,int y){
//	printf("%d %d\n",x,y);
	eg[++cnt].to=y;eg[cnt].next=g[x];g[x]=cnt;
	eg[++cnt].to=x;eg[cnt].next=g[y];g[y]=cnt;
}
int dfs(int x){
	int sz=0,now=0;
	for(int i=h[x];i;i=mp[i].next){
		int y=mp[i].to;if(y==fa[x]) continue;
		int z=dfs(y);
		++sz;
		if(sz==1) now=z;
		else{
			add(now,z);
			sz=0;now=0;
		}
	}
	if(!in[x]) return x;
	return now;
}
void DFS(int x){
	vis[x]=1;
	for(int i=g[x];i;i=eg[i].next){
		int y=eg[i].to;if(vis[y]) continue;
		a[y]=-a[x];DFS(y);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&fa[i]);
		if(fa[i]!=-1) ins(fa[i],i),in[fa[i]]^=1;
		else root=i;
	}
	int x1=dfs(root);
	num=0;memset(h,0,sizeof(h));
	for(int i=1;i<=n;++i){
		scanf("%d",&fa[i]);
		if(fa[i]!=-1) ins(fa[i],i),out[fa[i]]^=1;
		else root=i;
	}
	for(int i=1;i<=n;++i) if(in[i]!=out[i]){
		printf("IMPOSSIBLE");
		return 0;
	}
	puts("POSSIBLE");
	int x2=dfs(root);
	for(int i=1;i<=n;++i){
		if(!in[i] && !vis[i]){
			a[i]=1;
			DFS(i);
		}
	}
	for(int i=1;i<=n;++i) printf("%d ",a[i]);
	return 0;
}

Measured memory_bytes: 7936
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
//using namespace boost::multiprecision;  
//using namespace boost::math;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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

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

    int n;
    cin >> n;

    vector<int> cnt(1e7+1);

    for(int i = 1; i <= 1e7; ++i){
        for(int j = i; j <= 1e7; j += i){
            cnt[j]++;
        }
    }

    int res = 0;

    reps(i, n){
        res += i * cnt[i];
    }

    cout << res << '\n';

    return 0;
}




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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

int main() {

	IOS

	int x, n;
	cin >> x >> n;

	unordered_set<int> s;
	int ip;

	for (int i = 0; i < n; i++) {
		cin >> ip;
		s.insert(ip);
	}

	for (int i = 0; ; i++) {

		if (s.find(x-i) == s.end()) {
			cout << x-i;
			break;
		}

		if (s.find(x+i) == s.end()) {
			cout << x+i;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <array>
#include <iostream>

constexpr uint8_t SIZE = 3;

int main() {
    std::array<uint16_t, SIZE> a{};
    for (auto& b : a) {
        std::cin >> b;
    }
    std::sort(a.begin(), a.end());
    for (uint8_t i = 0; i < SIZE; ++i) {
        std::cout << a.at(i);
        if (i == SIZE - 1) {
            std::cout << std::endl;
        } else {
            std::cout << ' ';
        }
    }
}


Measured memory_bytes: 3168
N, M = gets.split.map(&:to_i)
x = Array.new(M) { gets.split.map(&:to_i) }
y = Array.new(N + 1, 1)
z = Array.new(N + 1, 0)
z[0] = 0
z[1] = 1
x.each do |u, v|
  if z[u] == 1
    z[v] = 1
  end
  y[u] -= 1
  y[v] += 1
  if y[u] == 0
    z[u] = 0
  end
end
puts z.sum

Measured memory_bytes: 22208
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

  vector<int> a(N), b(N);
  rep(i, N) { cin >> a[i] >> b[i]; }

  int64_t result = 0;
  rrep(i, N) {
    int64_t c = a[i] + result;
    if (c % b[i] == 0) {
    } else {
      result += b[i] - c % b[i];
    }
  }
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 1024
import collections
from pprint import pprint as pp

ri = lambda: int(input())
ria = lambda: list(map(int, input().split()))

def func(N, M):
    num = 0
    cols = N*M
    if cols == 0:
        return 0
    if cols == 1:
        return 1
    if N == 1:
        return cols - 2
    if N == 2:
        return 0
    return (N-2) * (M-2)
    

l = ria()
N,M = min(l), max(l)
print(func(N,M))


Measured memory_bytes: 3820
s = input()
ans = 0
tmp = 0
for i in range(len(s)):
    if s[i] == "A" or s[i] == "T" or s[i] == "G" or s[i] == "C" :
        tmp += 1
    else :
        if tmp > ans :
            ans = tmp
        tmp = 0
if tmp > ans :
    ans = tmp

print(ans)

Measured memory_bytes: 3060
# https://atcoder.jp/contests/agc029/tasks/agc029_a
# Wをなるべく右に詰めようとしたときに移動する距離の総和が答え
ans = 0
cnt = 0  # Wの移動先
for i, s in enumerate(input()):
    if s == 'W':
        ans += i - cnt
        cnt += 1
print(ans)


Measured memory_bytes: 73440
n,p=map(int,input().split())
s=input()
if p==2:
  ans=0
  for i in range(n):
    if int(s[i])%2==0:
      ans=ans+i+1
  print(ans)
elif p==5:
  ans=0
  for i in range(n):
    if int(s[i])%5==0:
      ans=ans+i+1
  print(ans)
else:
  R=[0]*p
  x=0
  y=1
  for i in range(n-1,-1,-1):
    a=int(s[i])
    b=(a*y+x)%p
    R[b]=R[b]+1
    y=y*10%p
    x=b
  ans=R[0]*(R[0]+1)//2
  for i in range(1,p):
    ans=ans+(R[i]*(R[i]-1))//2
  print(ans)

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

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
//	cout << a << b << c << d << endl;
	
/*	if((a-b<=d)||(b-a<=d)){
		if((b-c<=d)||(c-b<=d))
			cout << "Yes";
		else	cout << "No";
	}
	if((a-c<=d)||(c-a<=d))
		cout << "Yes";
	else	cout << "No";*/
	
	int ab = a-b, bc = b-c, ac = a-c;
	
	if(ab<0)	ab = -ab;
	if(bc<0)	bc = -bc;
	if(ac<0)	ac = -ac;
	
	if(((ab<=d)&&(bc<=d)) || (ac<=d)){
	
	//if( (((a-b<d)||(b-a<d)) && ((b-c<d)||(c-b<d))) || ((a-c<d)||(c-a<d)) ){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	return 0;
}



Measured memory_bytes: 256
arr = gets.chomp.split
stack = []

arr.each{|c|
	case c
	when "+"
		stack.push(stack.pop + stack.pop)
	when "-"
		stack.push(- stack.pop + stack.pop)
	when "*"
		stack.push(stack.pop * stack.pop)
	else
		stack.push(c.to_i)
	end
}
puts stack[0]

Measured memory_bytes: 8612
# include "cmath"
# include "queue"
# include "cstdio"
# include "cstring"
# include "iostream"
# include "algorithm"
# define Maxn 10000
# define fi first
# define se second
# define P pair<int,int>
# define rep(i,x,y) for(int i=x;i<=y;i++)
# define rep_d(i,x,y) for(int i=x;i>=y;i--)
# define rep_t(u) for(int i=head[u];i;i=f[i].next)
using namespace std;
typedef long long ll;
inline ll read()
{
	ll ok=1,k=0;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')
		ok=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		k=k*10+c-'0';
		c=getchar();
	}
	return ok*k;
}
ll f[Maxn];
int main()
{
	ll n=read(),ans=0;
	rep(i,1,n)
	f[i]=read();
	rep(i,1,n)
	{
		rep(j,i+1,n)
		ans+=f[i]*f[j];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,m=0,i;
    scanf("%d",&N);
    i=N;
    while(i!=0)
    {
        m+=i%10;
        i/=10;
    }
    if(N%m==0) printf("Yes\n");
    else printf("No\n");
        return 0;
}


Measured memory_bytes: 256
#入力
n=int(input())
A=list(map(int,input().split()))
#答え
ans=0

#空のリスト作成
b=[0]*(10**5+1)

#与えられた数列Aに含まれる数aiの順番にあるリストｂiを+１して、aiの個数のリストにする。
for i in A:
    b[i]+=1

#0から最大の10＊＊5まで調べる。ある数の前後プラス・マイナス１に含まれる数の個数が
#最大になるものを探す。それをXとすれば、答えが最大となる。
for i in range(10**5+1):
    if ans < sum(b[i:i+3]):
        ans=sum(b[i:i+3])

print(ans)


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int k, x;
    cin >> k >> x;
    int sum = k * 500;
    if(sum >= x){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl; 
    }
}

Measured memory_bytes: 256
my $s = <STDIN>;
my ($N,$M) = split(/ /,$s);
$s = <STDIN>;
chomp $s;
my @H = split(/ /,$s);
my @flag;
for(my $i=0;$i<$M;$i++){
    $s = <STDIN>;
    my @dat = split(/ /,$s);
    if( $H[$dat[0]-1] > $H[$dat[1]-1]  ){
        $flag[$dat[1]-1] = 1;
    }elsif( $H[$dat[0]-1] == $H[$dat[1]-1]  ){
        $flag[$dat[1]-1] = 1;
        $flag[$dat[0]-1] = 1;
    }else{
        $flag[$dat[0]-1] = 1;
    }
}
my $count =$N;
for(my $i=0;$i<$N;$i++){
    if($flag[$i] == 1){
        $count--;
    }
}
print "$count";

Measured memory_bytes: 17708
#include<stdio.h>
i;int main(){
	float m[100],ma=-1,mi=100000;
	for(i=0;scanf("%f",&m[i])!=EOF;i++){
		if(ma<m[i])ma=m[i];
		if(mi>m[i])mi=m[i];
	}
	printf("%.2f\n",ma-mi);
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
using namespace std;

int main() {
  int r;
  cin >> r;
  cout << r * 2 * 3.14;
}

Measured memory_bytes: 3712
def powmod(x, n,mod):
  if n == 0:
   return 1
  K = 1
  while n > 1:
   if n % 2 != 0:
    K = K * x%mod
    x = x ** 2%mod
    n = (n - 1) // 2
   else:
    x = x ** 2%mod
    n = n // 2%mod

  return K * x # 指数を割り続け n が 1 に至ったら終了
L=input()
S=len(L)-1
if S==0:
 print(3)
else:
 ans=1
 ct=0
 for i in range(S+1):
  if int(L[i])==1:
   ans+=((powmod(3, S-i,10**9+7)+1)*powmod(2, ct,10**9+7))%(10**9+7)
   ans%=(10**9+7)
   ct+=1
 print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin>>S;
  int N=S.size();
  vector<int> answer(N);
  
  for(int i=0;i<N;i++){  
  	if(S.at(i)=='A'||S.at(i)=='T'||S.at(i)=='G'||S.at(i)=='C'){
   	  for(int j=i;j<N;j++){
        
       if(S.at(j)=='A'||S.at(j)=='T'||S.at(j)=='G'||S.at(j)=='C'){ 
    	answer.at(i) ++;
  		}
        
       else{
         break;
       	}
        
      }
  	}
  }
   
  sort(answer.begin(), answer.end());
  cout << answer.at(N-1) << endl;
}

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

using namespace std;

const int N = 1e5;
const int MOD = 1e9 + 7;

bool flag[N + 5];
int dp[N + 5];
int n;
int solve(int idx){
	if(idx == n) return 1;
	if(idx > n || flag[idx]) return 0;
	int& ret = dp[idx];
	if(ret != -1) return ret;
	ret = solve(idx+1);
	ret = (ret + solve(idx+2)) % MOD;
	return ret;
}


int main(){
	int m; scanf("%d %d",&n,&m);
	for(int i=0; i<m; i++){
		int x; scanf("%d",&x);
		flag[x] = true;
	}
	memset(dp,-1,sizeof dp);
	printf("%d\n",solve(0));
	return 0;
}

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

using namespace std;

int main()
{
	// 入力
	int N;
	cin >> N;
	vector<int> A(N);
	// ソート用の長さNの配列
	vector<int> ASort(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		ASort[i] = A[i];
	}
	
	// 昇順ソート
	sort(ASort.begin(), ASort.end());
	// 最大値
	int AMax = ASort[N - 1];
	// 最大値より次に小さい値
	int ASecond = ASort[N -2];
	
	// 出力
	for (int i = 0; i < N; i++)
	{
		// Aiが最大値の場合
		if (A[i] == AMax) {
			cout << ASecond << endl;
		}
		else {
			cout << AMax << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define int long long int
#define frwd(i,a,b,j) for(int i=a;i<b;i+=j)
#define rev(i,a,b,j) for(int i=a;i>=b;i-=j)
#define all(x) x.begin(),x.end()
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ub upper_bound
#define lb lower_bound
#define inf 1e18+7
#define rem 1000000007
using namespace std;
void solve()
{
	string s,t;
	cin>>s>>t;
	if(t.find(s)==0) cout<<"Yes";
	else cout<<"No";
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	int t;
	//cin>>t;
	t=1;
	while(t--)
	{
		solve();
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <list>
using namespace std;

#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))

struct hen{
  int num;
  int color;
};

int main(){
  int n;
  cin >> n;
  vector<list<int>> e = vector<list<int>>(n,list<int>());
  int a,b;
  for(int i=0;i<n-1;i++){
    cin >> a >> b;
    a--;
    b--;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  queue<struct hen> bfs;
  vector<int> flag(n,0);
  struct hen now;

  bfs.push({0,1});
  bfs.push({n-1,2});
  flag[0]=1;
  flag[n-1]=2;
  while(!bfs.empty()){
    now=bfs.front();
    bfs.pop();
    for(list<int>::iterator itr=e[now.num].begin();itr!=e[now.num].end();itr++){
      if(!flag[(*itr)]){
        bfs.push({(*itr),now.color});
        flag[(*itr)]=now.color;
      }
    }
  }
  int f=0,s=0;
  for(int i=0;i<n;i++){
    if(flag[i]==1){
      f++;
    }else {
      s++;
    }
  }
  cout << (f>s?"Fennec":"Snuke") << endl;
  return 0;
}


Measured memory_bytes: 8448
# heapqでは最小値の取得しかできない。
# heapqで最大値を取得したい場合は，全要素を-1倍してから最小値を取得し，再度-1倍する。
import heapq

N, M = map(int, input().split())

# 最大値を取り出すため、リストの要素を全てマイナスにする
A = list(map(lambda x: -int(x), input().split()))

heapq.heapify(A)

# 割引券の枚数分だけforを回す
for _ in range(M):
    # リストの最大値を取り出す、2で割って挿入
    # マイナスになっているので一旦正負逆転させてから２で割る、挿入するときにもう一度反転
    heapq.heappush(A, ((heapq.heappop(A) * (-1)) // 2) * (-1))

print(abs(sum(A)))


Measured memory_bytes: 20948
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define PQS priority_queue <int, vector<int>, greater<int> > 
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

int  n;
int A[85];
// map <pair <int, pii>, int > dp, vis;

// int go(int ind, int money, int stocks) {
//   if(ind > n) return money;
  
//   int &x = dp[{ind, {money, stocks}}];
//   if(vis[{ind,{money, stocks}}]) return x;

//   int kuchni = go(ind+1, money, stocks);
//   int nm = money + stocks*A[ind];
//   int sell = go(ind+1, nm, 0);
//   nm = money%A[ind]; int ns = money/A[ind];
//   int buy = go(ind+1, nm, ns);
  
//   vis[{ind,{money, stocks}}] = 1;
//   return (x = max(kuchni, max(buy, sell)));
// }

void solve() {
  cin >> n;
  for(int i = 1; i <= n; i++) cin >> A[i];
  int money = 1000, stocks = 0;
  A[n+1] = -INF;
  for(int i = 1; i <= n; i++) {
    if(A[i] < A[i+1]) {
      stocks += (money/A[i]);
      money %= A[i];
    } else {
      money += (stocks * A[i]);
      stocks = 0;
    }
  }
  cout << money << '\n';
}

signed main() {   
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
  #endif
   int t = 1;  //cin >> t;
   for(int i = 1; i <= t; i++) {
   //  cout << "Case #" << i << ": ";
     solve();
  }
}    

/*

*/

Measured memory_bytes: 3652
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n, minMed, maxMed;
    cin >> n;
    
    vector<pii> lim(n);
    for (auto &[a, b] : lim) cin >> a >> b;
    
    sort(ALL(lim), [](auto a, auto b) {return a.X < b.X;});
    if (n & 1) minMed = lim[n / 2].X;
    else       minMed = lim[n / 2].X + lim[n / 2 - 1].X;
    
    sort(ALL(lim), [](auto a, auto b) {return a.Y < b.Y;});
    if (n & 1) maxMed = lim[n / 2].Y;
    else       maxMed = lim[n / 2].Y + lim[n / 2 - 1].Y;
    
    cout << maxMed - minMed + 1 << "\n";
    
    return 0;
}

Measured memory_bytes: 6356
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

map<ll, bool> mp;
int n;
bool flag = flag;

int main()
{
    cin>>n;
    REP(i,n) {
        ll a;
        cin>>a;
        flag |= mp[a];
        mp[a] = true;
    }
    YES(!flag);

    return 0;
}


Measured memory_bytes: 12800
<?php
  $rest=trim(fgets(STDIN));
  for($i=0;$i<$rest;$i++){
    $line=fgets(STDIN);
    $num[]=trim($line);
  }
  foreach($num as $ele2){
    $trinum=explode(" ",$ele2);
    $maxnum=max($trinum);
    $key=array_search($maxnum,$trinum);
    unset($trinum[$key]);
    $sum=0;
    if(!count($trinum)==2){
      echo "NO\n";

      break;
    }
    foreach($trinum as $ele){
      $sum+=pow($ele,2);
    }
    /* echo "max:".(int)$maxnum; */
    if($sum==pow((int)$maxnum,2))
      echo "YES\n";
    else
      echo "NO\n";
  }

Measured memory_bytes: 15296
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<(n);++i)
#define int long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define out(i) cout<<i<<endl;
#define m_p make_pair
#define m_t make_tuple
#define Vec vector
typedef long long ll;
typedef string str;
typedef vector<int> V;
typedef vector<pair<int,int>> VP;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
int min(int a,int b){if(a>b)return b;return a;}
int max(int a,int b){if(a>b)return a;return b;}
int gcd(int a,int b){if(b==0)return a; return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
const ll INF=1ll<<60;
const ll MOD=1e9+7;

signed main(){
  int a,b,c,d,n;
  cin>>a>>b>>c>>d>>n;
  if(a*8<b*4&&a*8<2*c&&a*8<d)cout<<(n*4*a)<<endl;
  else if(b*4<a*8&&b*4<c*2&&b*4<d)cout<<(n*2*b)<<endl;
  else if(c*2<a*8&&c*2<b*4&&c*2<d)cout<<(n*c)<<endl;
  else if(n%2==0)cout<<(n/2*d)<<endl;
  else {
    int res=0;
    res+=(n/2*d);
    if(a*4<b*2&&a*4<c)res+=(a*4);
    else if(b*2<a*4&&b*2<c)res+=(b*2);
    else res+=c;
    cout<<res<<endl;
  }
  
  
  return 0;
}



Measured memory_bytes: 256
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = inl()
mx = max(a)
mn = min(a)
if mx>mn+1:
    print('No')
elif mx==mn:
    if mx==n-1 or n>=2*mn:
        print('Yes')
    else:
        print('No')
else:
    k = len([x for x in a if x==mn])
    if k<mx and n-k>=2*(mx-k):
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 55876
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define fr(va, beg, end) for (lli va = beg; va < end; va++)
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
    lli n, m, sum = 0, a;
    cin >> n >> m;
    vector<lli> v;
    for (lli i = 0; i < n; i++) {
        cin >> a;
        v.pb(a);
        sum += a;
    }
    lli cnt = 0, val = sum / (4 * m);

    if (sum % (4 * m) != 0) {
        val++;
    }

    for (lli i = 0; i < n; i++) {
        if (v[i] >= val) {
            cnt++;
        }
    }
    if (cnt >= m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

Measured memory_bytes: 256
#include <iostream>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

//??????n?????????a?????????x???????????°true?????????????????°false?????????
bool binary_search(int a[], int n, int x) {
    int l = 0, r = n;
    while (r - l > 0) {
        int mid = (l + r) / 2;
        if (a[mid] < x)
            l = mid + 1;
        else if (a[mid] == x)
            return true;
        else
            r = mid;
    }
    return false;
}

int n;
int S[100005];
int q;
int main() {
    int ans = 0;
    cin >> n;
    rep(i, n) cin >> S[i];
    cin >> q;
    rep(i, q) {
        int t;
        cin >> t;
        if (binary_search(S, n, t)) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

ma = max(a)
mi = min(a)
if ma-mi >= 2:
    print('No')
elif ma == mi:
    if a[0] <= N//2 or a[0] == N-1:
        print('Yes')
    else:
        print('No')
else:
    maxnum = a.count(ma)
    minnum = a.count(mi)
    #if max(a) == minnum:
    #    print('No')
    if minnum + 1 <= ma <= minnum + maxnum//2:
        print('Yes')
    else:
        print('No')


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

int main() {
  int H, W; cin >> H >> W;
  int cnt = 0;
  for (int i = 0; i < H; i++) {
    string S; cin >> S;
    for (int j = 0; j < S.size(); j++) {
      if (S.at(j) == '#') cnt++;
    }
  }
  if (cnt == H+W-1) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str;
  int l,sa,n = 0;
  cin >> str;
  
  l = str.size();
 
  int count = 0;
  for (int i = 0; i < l/2; i++) {
    if (str.at(i) == str.at(l-i-1)) {
      count++;
    }
  }
  
  sa = l - count * 2;
  
  if(sa != 0 && sa % 2 == 0){
    n = sa/2;
  } else if(sa % 2 == 1){
    n = (sa - 1)/2;
  } else {
    n = 0;
  }
 
  //cout << count << endl;
  //cout << sa << endl;
  cout << n << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		double x1, y1, x2, y2;
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] coor = in.readLine().split(" ");
		x1 = Double.parseDouble(coor[0]);
		y1 = Double.parseDouble(coor[1]);
		x2 = Double.parseDouble(coor[2]);
		y2 = Double.parseDouble(coor[3]);
		System.out.println(Math.sqrt(Math.pow(x2 - x1, 2)
				+ Math.pow(y2 - y1, 2)));
	}
}

Measured memory_bytes: 16924
N = int(input())
import math, sys
x = math.floor(N/1.08)
c = [x-1, x, x+1]
C = [i*1.08 for i in c]
for i, j in zip(c, C):
    if math.floor(j) == N:
        print(int(i))
        sys.exit()
print(":(")

Measured memory_bytes: 3064