akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 A, B, N;
  cin >> A >> B >> N;
  i64 ans = 0, x;

  if(N<=1000000 or B<=1000000){
    rep(i,min(N+1,B+1)){
      chmax(ans, i64(A * i / B) - A * i64(i / B));
    }
    cout << ans << "\n";
    return;
  }

  if(N>=B-1){
    x = B - 1;
    ans = i64(A * x / B) - A * i64(x / B);
    cout << ans << "\n";
    return;
  }

  x = N;
  ans = i64(A * x / B) - A * i64(x / B);
  cout << ans << "\n";




}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

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

using namespace std;

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

    int tmp[N+1];
    int black = 0;
    int white = 0;
    int cnt = 0;

    tmp[0] = 0;
    for(int i = 0; i < N; i++){
        if( S[i] == '.' ) ++cnt;
        tmp[i+1] = cnt;
    }

    int ans = 2000000;
    for(int i = 0; i < N+1; i++){
        black = tmp[N] - tmp[i];
        white = i - tmp[i];

        ans = min( ans, black+white);
    }

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

Measured memory_bytes: 1412
n,m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
f = 0
for i in range(n - m + 1):
    for j in range(n - m + 1):
        t = [k[j:j + m] for k in a[i:i + m]]
        if t == b: f = 1
print ("Yes" if f else "No")


Measured memory_bytes: 3060
#include <iostream>
#include<string>
#include <typeinfo>
using namespace std;

int kaibun(string SA){
    int a=0;
 
    for(int i=0;i<(SA.size()+1)/2;i++){
        if(SA[i]!=SA[SA.size()-1-i]){a++;}
    }
    return a;
}

int main() {
string s;
cin>>s;
string t(s,0,(s.size()-1)/2);
if(kaibun(s)==0 and kaibun(t)==0){cout<<"Yes"<<endl;}
else{cout<<"No"<<endl;}
	return 0;
}

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

l, r = 0, 0
sum_a = 0
ans = 0
while r < n:
    # 右端を進める
    if sum_a & a[r] == 0:
        sum_a += a[r]
        r += 1
        ans += r - l
    # 右端と左端を進める
    elif l == r:
        l += 1
        r += 1
    # 左端を進める
    else:
        sum_a -= a[l]
        l += 1
    # print('l={}, r={}, size={}, ans={}, {}'.format(l, r, r - l, ans, a[l:r]))
print(ans)

Measured memory_bytes: 24840
#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;
const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = false, flag = false;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
struct edge { ll to, cost; };

int main() {
	ll a, b;
	cin >> a >> b;
	if (a <= 0 && b >= 0)cout << "Zero" << endl;
	else if (a > 0)cout << "Positive" << endl;
	else if (a < 0 && b < 0) {
		if (abs(b - a) % 2 == 0)cout << "Negative" << endl;
		else cout << "Positive" << endl;
	}
}

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

const int MOD = (int)1e9+7;

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


	int count=0;
	for(int i=S.size()-1;i>=0;i--){
		if(S.at(i)==')')	count++;
		else if(S.at(i)=='(')	count=max(0,count-1);
	}
	for(int i=count;i>0;i--){
		S="("+S;
	}
	count=0;
	for(int i=0;i<S.size();i++){
		if(S.at(i)=='(')	count++;
		else if(S.at(i)==')')	count=max(0,count-1);
	}
	for(int i=count;i>0;i--){
		S=S+")";
	}
	cout << S << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  string S;
  cin>>S;

  int ans=0;
  if(S=="SUN") ans=7;
  else if(S=="MON") ans=6;
  else if(S=="TUE") ans=5;
  else if(S=="WED") ans=4;
  else if(S=="THU") ans=3;
  else if(S=="FRI") ans=2;
  else if(S=="SAT") ans=1;

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  int r_avg; //切り上げの平均

  cin >> a >> b ;

  //単純に条件分岐してみる場合
  r_avg = ( a + b ) / 2 ;
  if ( ( r_avg * 2 ) != (a + b )){
    r_avg = r_avg + 1;
  } 
  cout << r_avg << endl;
}

Measured memory_bytes: 3560
from itertools import combinations_with_replacement
import numpy as np

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

G = [list(map(int, input().split())) for _ in range(Q)]

ans = 0

# 可能な数列Aの全探索、そのままやとめちゃ多いからなんか工夫する？
# そもそもAの全探索方がいまいちわからん...

A = np.array(list(combinations_with_replacement(range(1, M + 1), N)))
scores = np.zeros(len(A), dtype=np.int32)
for g in G:
    a, b, c, d = g
    cond = A[:, b - 1] - A[:, a - 1] == c
    scores += d * cond

print(scores.max())

Measured memory_bytes: 46484
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL H, W, M;
	cin >> H >> W >> M;
	map<LL, int> HM, WM;
	map<pair<LL, LL>, int> MM;
	for(int i=0; i<M; i++){
		LL h, w;
		cin >> h >> w;
		//h--; w--;
		if(HM.count(h) == 0){
			HM[h] = 1;
		}
		else{
			HM[h]++;
		}
		if(WM.count(w) == 0){
			WM[w] = 1;
		}
		else{
			WM[w]++;
		}
		MM[make_pair(h, w)] = 1;
	}
	
	int hmax = 0;
	for(auto itr = HM.begin(); itr != HM.end(); itr++){
		LL k = itr->first;
		int v = itr->second;
		if(hmax < v){
			hmax = v;
		}
	}
	map<LL, int> M1;
	for(auto itr = HM.begin(); itr != HM.end(); itr++){
		LL k = itr->first;
		int v = itr->second;
		if(v == hmax){
			M1[k] = v;
		}
	}

	int wmax = 0;
	for(auto itr = WM.begin(); itr != WM.end(); itr++){
		LL k = itr->first;
		int v = itr->second;
		if(wmax < v){
			wmax = v;
		}
	}
	map<LL, int> M2;
	for(auto itr = WM.begin(); itr != WM.end(); itr++){
		LL k = itr->first;
		int v = itr->second;
		if(v == wmax){
			M2[k] = v;
		}
	}
	if(M1.size() * M2.size() > M){
		printf("%d\n", hmax + wmax);
		return 0;
	}

	int exist = 0;
	for(auto itr1 = M1.begin(); itr1 != M1.end(); itr1++){
		for(auto itr2 = M2.begin(); itr2 != M2.end(); itr2++){
			LL a = itr1->first;
			LL b = itr2->first;
			if(MM.count(make_pair(a, b)) == 0){
				exist = 1;
				break;
			}
		}
		if(exist == 1){
			break;
		}
	}
	if(exist == 1){
		printf("%d\n", hmax + wmax );
	}
	else{
		printf("%d\n", hmax + wmax - 1);
	}
	return 0;
}



Measured memory_bytes: 97368
#include <stdio.h>
 
int main(){
  long N,count=0,i;
  double a[N];
  double sum=0,M;
  scanf("%ld %lf",&N,&M);
  for(i=0;i<N;i++){
    scanf("%lf",&a[i]);
    sum+=a[i];
  }
  for(i=0;i<N;i++){
    double b=a[i]/sum;
    double c=1/(4*M);
    if(b>=c){
      count++;
    }
  }
  if(count>=M){
    printf("Yes");
  }else{
    printf("No");
  }
}


Measured memory_bytes: 128
#!/usr/bin/env python
import math

n = int(input())
A = list(map(int, input().split()))

is_prime = [True for _ in range(1100000)]
is_prime[0] = is_prime[1] = False

for i in range(2, 1100000):
    if not is_prime[i]: continue
    for j in range(i*i, 1100000, i): 
        is_prime[j] = False 

g = 0 
for a in A:
    g = math.gcd(g, a)

if g != 1:
    print('not coprime')
    exit()

used = [False for _ in range(1100000)]
primes = [a for a in A if is_prime[a]]
not_primes = [a for a in A if not is_prime[a]]

for p in primes:
    used[p] = True

small_prime = [p for p in range(1100) if is_prime[p]]
for a in not_primes:
    for p in small_prime:
        if a == 1: break
        if a%p != 0: continue
        if used[p]:
            print('setwise coprime')
            exit()
        used[p] = True
        while a%p == 0:
            a //= p
    if a > 1:
        if used[a]:
            print('setwise coprime')
            exit()
        used[a] = True

print('pairwise coprime')


Measured memory_bytes: 134500
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, int>;
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i < (int)n; i++)
const ll mod = 1e9 + 7;
const ll inf = 1e12;
const double pi = 3.141592;
const int di[4] = {1, 0, -1, 0};
const int dj[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> x(n);
    rep(i, n) cin >> x[i];
    ll ans = 0;
    rep(i,n-1){
        ans += min(a * (x[i + 1] - x[i]), b);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
using namespace std;
 
int n, k, a[200010], cnt, ans, total;
 
int main(void) {
    scanf("%d%d", &n, &k);
    for(int i=0; i<n; i++) {
        int t;
        scanf("%d", &t);
        total+=t;
        if(a[t]) a[t]++;
        else {
            a[t]=1;
            cnt++;
        }
    }
 
    if(cnt<=k) {
        printf("0");
        return 0;
    }
    
    sort(a+1, a+n+1);
    
    int i=1;
    while (cnt>k) {
        if(a[i]) {
            total-=a[i];
            cnt--;
            ans+=a[i];
        }
        i++;
    }
    
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 896
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
ll n;
cin>>n;
V<ll> t(n),a(n);
for(int i=0;i<n;i++)cin>>t[i]>>a[i];
ll ans=0;
ll x=1,y=1;
for(int i=0;i<n;i++){
       ll d=max((x+t[i]-1)/t[i],(y+a[i]-1)/a[i]);
       x=t[i]*d;
       y=a[i]*d;
}
cout<<x+y<<endl;
}


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

int main() {

	int *nx, *my;
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	
	nx = new int[n + 1];
	my = new int[m + 1];


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

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

	nx[n] = x;
	my[m] = y;

	for (int i = 0; i < n+1; i++) {
		for (int j = 0; j < n; j++) {
			if (nx[j] > nx[j + 1]) {
				int fake = nx[j];
				nx[j] = nx[j + 1];
				nx[j + 1] = fake;
			}
		}
	}

	for (int i = 0; i < m+1; i++) {
		for (int j = 0; j < m; j++) {
			if (my[j] > my[j + 1]) {
				int fake = my[j];
				my[j] = my[j + 1];
				my[j + 1] = fake;
			}
		}
	}

	//for (int i = 0; i <= n; i++)cout << nx[i] << "\t";
	//cout << "\n";
	//for (int i = 0; i <= m; i++)cout << my[i] << "\t";
	

	if (nx[n] < my[0]) {
		cout << "No War" << endl;
	}
	else {
		cout << "War" << endl;
	}

	delete nx;
	delete my;

	return 0;
}
//*/

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
#define MAX 1000000007

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    ssort(a);
    cout << abs(a[0]-a[n-1]) << endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<string>
#define mod 1000000007
using namespace std;
typedef long long ll;
inline int mul(int a,int b){ return (a*1ll*b)%mod; }
inline int add(int a,int b){ a+=b;if(a>=mod) a-=mod; return a;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1) rt=rt*a;a=mul(a,a);b>>=1;} return rt;}
//for(int i=0;i<n;i++)

void solve(){
    ll x,k,d;
    cin>>x>>k>>d;
    if(x==0){
       if(k&1) cout<<abs(d);
       else cout<<x;
       return;
    }
    if(x>0){
       ll y=x/d;
       if(y>=k)
          cout<<abs(x-(k*d));
       else{
          ll now=x-(y*d);
          ll rem=k-y;
          if(rem&1)
            cout<<abs(now-d);
          else
            cout<<now;
       }
       return;
    }
    ll y=x/d;
    y=abs(y);
    if(y>=k)
        cout<<abs(x+(k*d));
    else{
         ll now=x+(y*d);
          ll rem=k-y;
          if(rem&1)
            cout<<abs(now+d);
          else
            cout<<abs(now);
         }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int t=1;//cin>>t;
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
long long  i,n,d;
  cin >> n >> d;
  long long steve=0;
  for(i=0;i<n;i++){
    long long x,y;
    cin >> x >> y;
    if(x*x+y*y<=d*d){
      steve++;
    }
  }
  cout << steve << endl;
}
    

Measured memory_bytes: 3524
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define rn return
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;

int main(){
    int N; cin >> N;
    rep(i,N/7 + 1){
        if ((N-i*7)%4 == 0) {
            cout << "Yes"; rn 0;
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
int main(void)
{
    char s[51];
    int k, i=0, n;
    scanf("%d%d", &n, &k);
    scanf("%s", s);

    while(s[i]!='\0'){
        if(i==k-1)  s[i]=tolower(s[i]);
        i++;
    }

    printf("%s\n", s);
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	vector<ll> a(n);
	ll sum = 0;
	rep(i,n){
		cin >> a[i];
		sum += a[i];
	}
	int ans = 0;
	rep(i,n){
		if(4*m*a[i] >= sum) ++ans;
	}
	if(ans >= m) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll x, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % m;
		x = x * x % m; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 19;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

void solve() {
	int n, k; cin >> n >> k;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	Rep(i, k, n) {
		if (a[i] > a[i - k]) {
			cout << "Yes\n";
		}
		else {
			cout << "No\n";
		}
	}
}




signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init_f();
	//cout << grandy(2, 3, false, false) << "\n";
	//init();
	//int t; cin >> t; rep(i, t)
	solve();
	return 0;
}


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

using namespace std;

int main()
{


  int n;
  cin >> n ;
  vector<int > ar(n);

  // int count =0;
  for (int i = 1; i < n; ++i)
  {
  	int temp;
  	cin >> temp;
  	ar[temp-1] = ar[temp-1] + 1;
  }

  for (int i = 0; i < n; ++i)
  {
    cout << ar[i] << endl;
  }




}


Measured memory_bytes: 3960
#include<iostream>
#include<set>
using namespace std;
int main(){
    int N;
    cin >> N;

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

    set<int> SetOfValues;
    for(int i=0; i<N; i++) SetOfValues.insert(d[i]);

    cout << SetOfValues.size() << endl;
}

Measured memory_bytes: 256
def binarySearch(arr, l, r, key):
    if r>=1:
        m = (l+r)//2
        if arr[m] == key:
            return m
        elif arr[m] > key:
            return binarySearch(arr, l, m, key)
        else:
            return binarySearch(arr, m+1, r, key)
    else:
        return -1

n = 1000
positive_arr = [elm**5 for elm in range(n)]
negative_arr = [-elm for elm in positive_arr]
arr = negative_arr
arr.extend(positive_arr)
# print(arr)
x = int(input())
negative_a, negative_b, printed = False, False, False
for a in arr:
    for b in arr:
        if a - b == x:
            if a<0:
                a *= -1
                negative_a = True
            if b<0:
                b *= -1
                negative_b = True
            a = int(a**(1/5))
            b = int(b**(1/5))
            if negative_a:
                a *= -1
            if negative_b:
                b *= -1
            print(a,b)
            printed = True
            break
    if printed:
        break



Measured memory_bytes: 9524
# define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <complex>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) begin(x),end(x)
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }

int main()
{
	while (true)
	{
		int _w, _d;
		cin >> _w >> _d;
		if (!_w&&!_d)break;
		vi w, d;
		vb W, D;
		FOR(i, _w)
		{
			INT(h);
			w.push_back(h);
			W.push_back(false);
		}
		FOR(i, _d)
		{
			INT(h);
			d.push_back(h);
			D.push_back(false);
		}
		int ans = 0;
		sort(ALL(w));
		sort(ALL(d));
		FOR(i, w.size())
		{
			bool ok = false;
			FOR(j, d.size())
			{
				if (w[i] == d[j] && !D[j])
				{
					W[i] = D[j] = ok = true;
					ans += w[i];
					break;
				}
			}
			if (ok)continue;
			FOR(j, d.size())
			{
				if (w[i] <= d[j])
				{
					W[i] = true;
					ans += w[i];
					break;
				}
			}
		}
		FOR(i,d.size())
		{
			if (!D[i])ans += d[i];
		}
		cout << ans << endl;



	}
}

Measured memory_bytes: 3140
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 06/27/20 20:37:13
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int a; cin>>a;
  int ans = a+a*a+a*a*a;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int k, s;
int main(){ 
    int count = 0;
    cin >> k >> s;
    for (int i=0;i<=k;++i){
        for (int j=0;j<=k;++j){
            int z = s - i - j;
            if (z>=0&&z<=k) ++count;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	float xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;

	while (scanf("%f %f %f %f %f %f %f %f", &xa1, &ya1, &xa2, &ya2, &xb1, &yb1, &xb2, &yb2)!=EOF) {
		 if (xa2 >= xb2) {
			if (xa1 <= xb2 && ((yb1 <= ya2 && ya1 <= yb2)||(yb2 >= ya1 && ya2 >= yb1)))
				printf("YES\n");
			else
				printf("NO\n");
		}
		else {
			if (xa2 >= xb1 && ((ya2 >= yb1 && ya1 <= yb2) || (ya1 <= yb2 && ya2 >= yb1)))
				printf("YES\n");
			else
				printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	string S, T;
	cin >> S >> T;
	if(S.size() < T.size()) {
		cout << "UNRESTORABLE\n";
		return 0;
	}
	vector<int> candidate;
	for(int i = 0; i <= S.size() - T.size(); i++) {
		if(S[i] == T[0] || S[i] == '?') {
			bool ok = true;
			for(int j = 1; j < T.size(); j++)
				if(S[i + j] != T[j] && S[i + j] != '?') {
					ok = false;
					break;
				}
			if(ok) candidate.push_back(i);
		}
	}
	if(candidate.size() == 0) {
		cout << "UNRESTORABLE\n";
		return 0;
	}
	vector<string> answers;
	for(int i = 0; i < candidate.size(); i++) {
		string tmp = S;
		for(int j = 0; j < S.size(); j++) {
			if(S[j] == '?') {
				if(candidate[i] <= j && j < candidate[i] + T.size())
					tmp[j] = T[j - candidate[i]];
				else
					tmp[j] = 'a';
			}
		}
		answers.push_back(tmp);
	}
	sort(answers.begin(), answers.end());
	cout << answers[0] << "\n";
	return 0;
}


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

using namespace std;

int main()
{
	long long n, m;
	cin >> n >> m;

    long long ans;
    if(n > m/2) ans = m / 2;
    else ans = n;
    ans += (m - 2*ans) / 4;

    cout << ans << endl;

    return 0;
}


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

int cmp( const void *p, const void *q ) {
    return *(int*)q - *(int*)p;
}

int main(void){
    long int n,k;
    scanf("%ld %ld",&n,&k);
    long int h[n];
    int i,j;
    for(i=0;i<n;i++){
        scanf("%ld",&h[i]);
    }
    
    qsort(h,n,sizeof(long int),cmp);

    if(n<=k){
        printf("0");
    }
    else{
        long int sum=0;
        for(i=0;i<n-k;i++){
            sum = sum + h[i+k];
        }
        printf("%ld",sum);
    }
    return 0;
}

Measured memory_bytes: 3324
n = int(input())
a = [int(_) for _ in input().split()]
b = (int(_) for _ in input().split())
c = [int(_) for _ in input().split()]

ans = sum(b)
for i in range(n-1):
	if (a[i] +1) == a[i+1]:
		ans += c[a[i]-1]

print(ans)


Measured memory_bytes: 3316
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <functional>
#include <queue>
using namespace std;
const int INT_INF = 500000000;
const long long LONG_LONG_INF = (long long)pow(10, 18);
const int MOD = pow(10, 9) + 7;
/* contest template */
long long N, M, A, R, C, H, ans;

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        string s;
        cin >> s;
        if (s[0] == 'M')
        {
            M++;
        }
        else if (s[0] == 'A')
        {
            A++;
        }
        else if (s[0] == 'R')
        {
            R++;
        }
        else if (s[0] == 'C')
        {
            C++;
        }
        else if (s[0] == 'H')
        {
            H++;
        }
    }
    ans += M * A * R;
    ans += M * A * C;
    ans += M * A * H;
    ans += M * R * C;
    ans += M * R * H;
    ans += M * C * H;
    ans += A * R * C;
    ans += A * R * H;
    ans += A * C * H;
    ans += R * C * H;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
	char a;
	cin>>a;
	if(a >= 'a' && a <= 'z') cout<<'a'<<endl;
	else cout<<'A'<<endl;
	return 0;
}

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

#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ll long long
#define pb push_back
#define zoom                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define pl pair<ll, ll>
#define MOD 1000000007
#define endl "\n"
#define ff first
#define ss second
#define trace1(x) cerr << #x << ": " << x << endl
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define trace3(x, y, z) cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl
#define trace4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl
#define trace5(a, b, c, d, e) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl
#define trace(v)                                   \
    for (auto it = v.begin(); it != v.end(); it++) \
        cerr << *it << " ";                        \
    cerr << endl;
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<vi> vvi;

void solve()
{
    long double a,b;
    cin>>a>>b;

    ll mult=a*b;

    cout<<mult<<endl;
}

int main()
{
    zoom;
    ll t=1;
    //cin >> t;

    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3812
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	cout<<n*800-(n/15)*200;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, A, B, C, D, E;
    cin >> N >> A >>  B >> C >> D >> E;
    ll minNum = min(A, min(B, min(C, min(D, E))));
    ll ans = (N - 1) / minNum + 5;

    cout << ans << endl;
}


Measured memory_bytes: 256
//author : Yogi79

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

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   int a[n],b[n],c[n-1];
   for(int i=1;i<=n;i++)
    cin>>a[i];

   for(int i=1;i<=n;i++)
    cin>>b[i];

   for(int i=1;i<n;i++)
    cin>>c[i];

int sum =0;
int temp1=-1,temp2;
//cout<<b[1]<<endl;

   for(int i=1;i<n+1;i++)
    {
        temp2 = a[i];
       sum += b[a[i]];
       //cout<<b[a[i]]<<endl;
       if(temp2-temp1 == 1 && i != 1)
        sum +=  c[temp1];
    temp1 = a[i];
    }
    cout<<sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;


int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int one = a*x + b*y;
    int two = 2*c*max(x,y);
    int three=INF,four=INF;
    if(y>x) three = 2*c*x + b*(y-x);
    else if(x>y) four = 2*c*y + a*(x-y);
    cout << min({one,two,three,four}) << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
namespace _0002
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> b = new List<int>();
            string input;
            while(true)
            {
                input = Console.ReadLine();
                if (input == null)
                {
                    break;
                }
                int[] x = input.Split().Select(int.Parse).ToArray();
                b.Add((x[0] + x[1]).ToString().Length);
            }
            foreach (var i in b)
            {
                Console.WriteLine(i);
            }
        }
    }
}

Measured memory_bytes: 9420
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main()
{
    ll n,i,j,k,p,s=0,r;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            p=__gcd(i,j);
            for(k=1;k<=n;k++)
            {
                r=__gcd(p,k);
                s+=r;
            }
        }
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3536
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(void){
    double r;
    cin >> r;
    cout << 3*r*r << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1e9+7;

signed main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(auto& x : a)
        cin >> x;
    vector<vector<ll>> dp(n, vector<ll>(n, 1e18));
    vector<ll> r(n + 1, 0);
    for(ll i = 0; i < n; ++i)
        r[i + 1] = r[i] + a[i];
    for(ll i = 0; i < n; ++i)
        dp[i][i] = 0;
    for(ll k = 1; k < n; ++k){
        for(ll i = 0, j = k; j < n; ++i, ++j){
            for(ll l = i; l < j; ++l){
                dp[i][j] = min(dp[i][j], dp[i][l] + dp[l + 1][j] + r[j + 1] - r[i]);
            }
        }
    }
    cout << dp[0][n - 1] << endl;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	int n, u, v, m;
	cin >> n >> u >> v >> m;
	vector<vector<pii>> cat(1111111), rab(1111111);

	REP(i, n)REP(j, n)
	{
		int t; cin >> t;
		cat[t].push_back(pii(i, j));
	}
	REP(i, n)REP(j, n)
	{
		int t; cin >> t;
		rab[t].push_back(pii(i, j));
	}
	vi in(m);
	REP(i, m) cin >> in[i];
	if (n == 1)
	{
		int c = INF, r = INF;
		REP(i, m)
		{
			if (cat[in[i]].size() >= 1 && c == INF) c = i;
			if (rab[in[i]].size() >= 1 && r == INF) r = i;
		}
		if (c < r&&u == 1) puts("USAGI");
		else if (r < c&&v == 1) puts("NEKO");
		else if (c == r&&u == 1 && v == 1) puts("DRAW");
		else if (u >= 2 && v >= 2) puts("DRAW");
		else if (c >= r&&u == 1 && c != INF) puts("USAGI");
		else if (r >= c&&v == 1 && v != INF) puts("NEKO");
		else puts("DRAW");
		return 0;
	}
	vi catx(n), caty(n), cato(2), rabx(n), raby(n), rabo(2);
	int cntc = 0, cntr = 0;
	int ans = -1;
	REP(i, m)
	{
		int t = in[i];
		REP(j, cat[t].size())
		{
			int x = cat[t][j].first, y = cat[t][j].second;
			catx[x]++;
			caty[y]++;
			if (x == y) cato[0]++;
			if (x + y == n - 1) cato[1]++;
			if (catx[x] == n) cntc++;
			if (caty[y] == n) cntc++;
			if (cato[0] == n)
			{
				cato[0] = 0;
				cntc++;
			}
			if (cato[1] == n)
			{
				cato[1] = 0;
				cntc++;
			}
		}
		REP(j, rab[t].size())
		{
			int x = rab[t][j].first, y = rab[t][j].second;
			rabx[x]++;
			raby[y]++;
			if (x == y) rabo[0]++;
			if (x + y == n - 1) rabo[1]++;
			if (rabx[x] == n) cntr++;
			if (raby[y] == n) cntr++;
			if (rabo[0] == n)
			{
				rabo[0] = 0;
				cntr++;
			}
			if (rabo[1] == n)
			{
				rabo[1] = 0;
				cntr++;
			}
		}
		if (cntc >= u&&cntr >= v) break;
		else if (cntc >= u)
		{
			ans = 0;
			break;
		}
		else if (cntr >= v)
		{
			ans = 1;
			break;
		}
	}
	if (ans == -1) puts("DRAW");
	else if (ans == 0) puts("USAGI");
	else puts("NEKO");

	return 0;
}

Measured memory_bytes: 63984
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;

int main(){
    int x;
    cin>>x;
    if(x>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3628
import numpy as np
from itertools import combinations
N,M,X=map(int,input().split())
x=[]
for i in range(N):
    y=list(map(int,input().split()))
    x.append(y)
def can(i,X):
    z=np.sum(i, axis=0)
    if X<=min(z[1:]):
        return z[0]
    else:
        return -1
y=[]
for i in range(1,len(x)+1):
    y.extend(list(combinations(x, i)))
A=[]
for i in y:
    z=can(i,X)
    if z==-1:
        continue
    A.append(z)
if len(A)==0:
    print(-1)
else:
    print(min(A))

Measured memory_bytes: 27692
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int M = sc.nextInt();
        int D = sc.nextInt();
        int count=0;
        for(int m=1;m<=M;m++){
            for(int d=1;d<=D;d++){
                int d1 = d%10;
                int d10 = (d-d1)/10;
                if(d1<2 || d10<2)continue;
                if(d1*d10==m)count++;
            }
        }
        System.out.println(count);
    }
}

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

using namespace std;

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end());

    int ans = 0;
    for (int i = 0; i < n - 1; ++i) {
        if (a[i] <= x) {
            x -= a[i];
            ++ans;
        }
    }
    if (ans < n - 1)
        cout << ans << endl;
    else if (x == a[n - 1])
        cout << n << endl;
    else
        cout << n - 1 << endl;
}


Measured memory_bytes: 256
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

let main() =
    let [| h; a |] = reada int
    (h + a - 1) / a |> puts
    ()

main()
writer.Close()


Measured memory_bytes: 11348
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
int n,c;
int d[32][32];
int cr[505][505];
vector<int>vec[3];
int cost[31][3];
 main()

{
    fast
    cin>>n>>c;
    f(i,1,c)f(j,1,c)cin>>d[i][j];
    f(i,1,n)f(j,1,n)cin>>cr[i][j],vec[(i+j)%3].pb(cr[i][j]);
    f(i,1,c)
    {
        f(j,0,2)
        {
            int sum=0;
            for(auto x:vec[j])
            {
                if(x==i)continue;
                else sum+=d[x][i];
            }
            cost[i][j]=sum;
        }
    }
    int ses=inf;
    f(i,1,c)f(j,1,c)f(k,1,c)
    {
        if(i==j || i==k || j==k)continue;
        int tmp=cost[i][0]+cost[j][1]+cost[k][2];
        ses=min(ses,tmp);
    }
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 4388
# 2020/02/22
# AtCoder Beginner Contest 135 - C

# Input
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

# Calc
ans = 0
for i in range(n):
    remb = max(b[i] - a[i], 0)
    geta = min(b[i], a[i]) + min(a[i+1], remb)
    a[i+1] = max(a[i+1] - remb, 0)

    ans = ans + geta

# Output
print(ans)


Measured memory_bytes: 18624
h,w = gets.split(" ").map(&:to_i)
pic = Array.new(h) {gets.chomp.split("")}
ans = "Yes"

for i in 0 .. h-1 do
    for j in 0.. w-1 do
        if pic[i][j] == "#"
            ch = Array.new
            if i > 0 
                ch << pic[i-1][j]
            end
            if i < h-1
                ch << pic[i+1][j]
            end
            if j > 0 
                ch << pic[i][j-1]
            end
            if j < w-1
                ch << pic[i][j+1]
            end
            if ! ch.include?("#")
                ans = "No"
            end
        end
    end
end


puts ans

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<long long int, null_type,less<long long int>, rb_tree_tag,tree_order_statistics_node_update> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int n;
    cin>>n;
    map <long long int,long long int> m;
    long long int a[n];
    long long int sum=0;
    for (long long int i=0;i<n;i++){
        cin>>a[i];
        m[a[i]]++;
        sum+=a[i];
    }
    long long int q;
    cin>>q;
    while (q--){
        long long int b,c;
        cin>>b>>c;
        sum-=b*m[b];
        sum+=c*m[b];
        cout<<sum<<"\n";
        m[c]+=m[b];
        m[b]=0;
    }
}

Measured memory_bytes: 10204
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    long n, m, k;
    cin >> n >> m >> k;
    vector<long> as(n + 1), bs(m + 1);
    as[0] = 0;
    bs[0] = 0;
    for (long i = 1; i <= n; i++) {
        long a;
        cin >> a;
        as[i] = as[i - 1] + a;
    }
    for (long i = 1; i <= m; i++) {
        long b;
        cin >> b;
        bs[i] = bs[i - 1] + b;
    }
    long ans = 0;
    for (long i = 0; i <= n; i++) {
        if (as[i] > k) break;
        long ok = 0;
        long ng = m + 1;
        while (abs(ok - ng) > 1) {
            long mid = (ok + ng) / 2;
            if (as[i] + bs[mid] <= k) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        ans = max(ans, i + ok);
    }
    cout << ans << endl;
}


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

int n, m;
int s[10002], t[502];

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

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

  int c = 0;

  for(int i = 0; i < m; i++){
    for(int j = 0; j < n; j++){
      if(t[i] == s[j]){
        c++;
        break;
      }
    }
  }

  cout << c << endl;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)

signed main()
{
  int N;
  int A[100005], B[100005];
  cin >> N;
  Rep(i, N) {
    cin >> A[i] >> B[i];
  }
  int cnt = 0; 
  for(int i = N - 1; i >= 0; i--) {
    cnt += (B[i] - (A[i] + cnt) % B[i]) % B[i];
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long dp[105][100005];
long long solve(vector<pair<int, int>>& arr, int index, int curWeight, int maxWeight) {
	// cout<<"Solve "<<index<<" "<<prev<<endl;
	int n = arr.size();

	if (index == n) {
		return 0;
	}

	if (dp[index][curWeight] != -1) {
		return dp[index][curWeight] ;
	}

	long long ans = -100000000000;
	int wi = arr[index].first;
	int vi = arr[index].second;
	ans = solve(arr, index + 1, curWeight, maxWeight);
	if (wi + curWeight <= maxWeight) {
		ans = max(ans, vi + solve(arr, index + 1, curWeight + wi, maxWeight));
	}
	return dp[index][curWeight]  = ans;
}

int main() {
	int n, w, wi, vi;
	cin>>n>>w;
	vector<pair<int, int>> arr;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 100005; j++) {
			dp[i][j] = -1;
		}
		cin>>wi>>vi;
		arr.push_back({wi, vi});
	}
	cout<<solve(arr, 0, 0, w)<<endl;
}

Measured memory_bytes: 81672
#include <stdio.h>
#include <cassert>
#include <algorithm>

typedef long long int LL;

int main() {
  LL l, r;
  scanf("%lld", &l);
  scanf("%lld", &r);

  LL min = 2020;

  for(LL i = l; i<r; i++) {
    for(LL j = i+1; j<=r; j++) {
      LL res = (i*j)%2019;
      if(res < min){ 
        min = res;
        if (min == 0) break;
      }
    }
    if(min == 0) break;
  }

  printf("%lld\n",min);

  return 0;
}

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



int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    
    vector<int> p(a), q(b), r(c);
    rep(i,a) {
        cin >> p[i];
    }
    rep(i,b) {
        cin >> q[i];
    }
    rep(i,c) {
        cin >> r[i];
    }
    
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    
    vector<int> total;
    rep(i,x) {
        total.push_back(p[i]);
    }
    rep(i,y) {
        total.push_back(q[i]);
    }
    rep(i,c) {
        total.push_back(r[i]);
    }
    
    sort(total.rbegin(), total.rend());
    long int sum = 0;
    rep(i,x+y) {
        sum += total[i];
    }
    
    cout << sum << endl;
    
    return 0;
}




Measured memory_bytes: 6540