akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;


ll n, m, x[1024], y[1024], z[1024];
int main(){
  cin >> n >> m;
  for(int i=0;i<n;i++) cin >> x[i] >> y[i] >> z[i];
  ll ans = 0;
  for(int sx=-1;sx<3;sx+=2){
    for(int sy=-1;sy<3;sy+=2){
  	  for(int sz=-1;sz<3;sz+=2){
        vector<ll> v;
        for(int i=0;i<n;i++) v.push_back(sx*x[i]+sy*y[i]+sz*z[i]);
        sort(v.begin(), v.end(), greater<ll>());
        ll sum = 0;
        for(int i=0;i<m;i++) sum += v[i];
        ans = max(ans, sum);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

int A[SIZE], B[SIZE], C[SIZE];
map<int, int> mm[SIZE];

ll ans[SIZE], in[SIZE];

int main(){
  int N, M, T;
  set<int> ss;

  cin >> N >> M >> T;

  for(int i=0; i<M; i++) {
    cin >> A[i] >> B[i] >> C[i];
    B[i]--;
  }

  for(int i=0; i<M; i++) {
    if (C[i] == 0) {
      auto it = ss.find(B[i]);
      ss.erase(it);

      for(int p : ss) {
        int a = p, b = B[i];
        int add = A[i] - max(in[a], in[b]);
        if (a > b) swap(a, b);
        mm[a][b] += add;
      }

      in[B[i]] = 0;

    } else {

      ss.insert(B[i]);
      in[B[i]] = A[i];
    }
  }

  for(int p : ss) {
    for(int q : ss) {
      if (p < q) {
        int add = T - max(in[p], in[q]);
        mm[p][q] += add;
      }
    }
  }

  const ll e8 = 100000000LL;

  for(int i=0; i<N; i++) {
    ans[i] = 0 * e8 + N - (i == 0);
  }

  for(int i=0; i<N; i++) {
    for(auto p : mm[i]) {
      int a = i;
      int b = p.first;
      int v = p.second;

      ans[a] = max(ans[a], v * e8 + N - b);
      ans[b] = max(ans[b], v * e8 + N - a);
    }
  }

  for(int i=0; i<N; i++) {
    int p = N - ans[i] % e8 + 1;

    printf("%d\n", p);
  }


  return 0;
}



Measured memory_bytes: 187580
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)); //整数型のまま切り上げ演算する
#define PI 3.14159265359
#define MOD 1000000007
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl; }

const LL INF = 1LL << 60;

int main(void) {
	LL N, K;
	cin >> N >> K;

	vector<LL> X(N);
	rep(i, N) cin >> X[i];

	//K個連続してる数字が最適(折り返したりは時間の無駄)
	LL ans = INF;
	for (LL l = 0; l < N - K + 1; l++) {
		LL r = l + K - 1;
		LL ans_candidate = min(abs(X[l]) + abs(X[l] - X[r]), abs(X[r]) + abs(X[l] - X[r]));
		chmin(ans, ans_candidate);
	}
	cout << ans << endl;
	return 0;
}



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

int main() {
  int N;
  cin>>N;
  
  long long ttttt=0;
  vector<long long> A(200000);
  for(int a=0;a<N;a++){
    cin>>A.at(a);
    ttttt+=A.at(a);
  }
 // long long hozon=ttttt;
  //sort(A.begin(),A.end());
  //long long amari=0;
  long long amari=0;
 
  for(int p=0;p<N-1;p++){
    long long hozon=0;
    bool judge=0;
    ttttt-=A.at(p);
    if(ttttt>=1000000007){
      hozon=ttttt;
      ttttt=ttttt%1000000007;
      judge=1;
    }
    amari+=A.at(p)*ttttt;
    if(amari>=1000000007){
      //cout<<total<<"totalllll"<<endl;
      //amari+=total%1000000007;
      amari=amari%1000000007;
       // cout<<amari<<"amari"<<endl;
    }
    if(judge){
      ttttt=hozon;
    }
      //cout<<total<<"total"<<endl;
  }
  //  if(total>=1000000007){
 //     amari=amari%1000000007;
      
 //   }

  cout<<amari;
}




Measured memory_bytes: 4836
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
// 型シノニム
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
// 定数
constexpr ll INF   = 1e16;
constexpr ll INM   = 114514;
constexpr ll MOD   = 1e9 + 7;
constexpr ld EPS   = 1e-12;
constexpr ll dx[4] = {1, 0, -1, 0};
constexpr ll dy[4] = {0, 1, 0, -1};
// 便利関数
void IOS() { ios::sync_with_stdio(false), cin.tie(0); }
template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <class T>
bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T>
bool chmin(T &a, const T &b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll mod) {
	if (a > 0) return a % mod;
	if (a % mod == 0) return 0;
	ll x = -a / mod + 1;
	a += x * mod;
	return a % mod;
}
ll powm(ll a, ll b, ll m) {
	if (b == 0) {
		return 1;
	} else if (b % 2 == 0) {
		ll d = powm(a, b / 2, m);
		return (d * d) % m;
	} else {
		return (powm(a, b - 1, m) * a) % m;
	}
}

// 本体

ll dp[2002][2002];

int main() {
	IOS();
	int n;
	cin >> n;
	vector<P> a(n);
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;
		a[i] = make_pair(x, i + 1);
	}
	sort(a.begin(), a.end(), greater<P>());
	Fill(dp, -INF);
	ll ans = -INF;
	for (int l = 0; l <= n; l++) {
		for (int r = 0; l + r <= n; r++) {
			if (l == 0 && r == 0) {
				dp[0][0] = 0;
				continue;
			}
			ll x = a[l + r - 1].first;
			ll i = a[l + r - 1].second;
			if (l > 0) chmax(dp[l][r], dp[l - 1][r] + x * (i - l));
			if (r > 0) chmax(dp[l][r], dp[l][r - 1] + x * (n - r + 1 - i));
			chmax(ans, dp[l][r]);
		}
	}
	dump(ans);
}


Measured memory_bytes: 34992
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

typedef pair <int,int> pii;
typedef vector <pii> vpii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef long long int lli;
typedef vector <lli> vlli;
typedef vector <vlli> vvlli;
typedef vector <string> vs;
typedef vector <bool> vb;

#define rep(i, n) for( i = 0; i < (n); ++i)
#define repA(i, a, n) for( i = a; i <= (n); ++i)
#define repD(i, a, n) for( i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sortr(x) sort(x.begin(),x.end(),greater <int> ())
#define mod 1000000007
#define ff first
#define ss second
#define fill(a,c)  memset(a, c, sizeof (a))
#define formap(i,v) for(auto &i: v)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; formap(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it<<endl;} cerr<<endl
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; formap(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it.first<<" , "<<it.second<<endl;} cerr<<endl
#define PI  3.14159265358979323846
#define pb push_back




int main() {
     cin.sync_with_stdio(0);cin.tie(0);
     cin.exceptions(cin.failbit);
    
    
    int a,b,x,y,ans;
     cin>>a>>b>>x>>y;
     if (a!=x)ans=1;
     else ans=0;
     cout<<ans<<endl;
     
     
     
     
     
     
     
     
     
     
   
   
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() { cerr << "--------------" << endl; }
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   string s;
   cin >> s;
   int n = s.size();
   rep(i, 0, n) { cout << 'x'; }
   cout << endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define ll long long int
using namespace std; 
  
const int MAX = 1000001; 
  
// structure to store queries 
struct Query 
{ 
    int l, r, idx; 
}; 
  
// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  
// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    // initialising bit array 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
  
    // holds the rightmost index of any number 
    // as numbers of a[i] are less than or equal to 10^6 
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  
    // answer for each query 
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        // If last visit is not -1 update -1 at the 
        // idx equal to last_visit[arr[i]] 
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
  
        // Setting last_visit[arr[i]] as i and updating 
        // the bit array accordingly 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
        // If i is equal to r of any query  store answer 
        // for that query in ans[] 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
  
    // print answer for each query 
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 
  
// driver code 
int main() 
{ 
	int n, q;
	cin >> n >> q;
	Query queries[q];
	int a[n]; 
	for(int i = 0; i < n; ++i)
		cin >> a[i];
	for(int i = 0; i < q; ++i){
		int b, c; 
		cin >> b >> c;
		--b;
		--c;
		queries[i].idx = i;
		queries[i].l  = b;
		queries[i].r = c;
	}
    sort(queries, queries+q, cmp); 
    answeringQueries(a, n, queries, q); 
    return 0; 
} 

Measured memory_bytes: 19324
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define itrep(it, a) for(it = (a).begin(); it != (a).end(); it++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 30)
using namespace std;

int main(){
    int n;
    cin >> n;
    cout << (n + 1) * n / 2 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i;
  char rank[][4]={"AAA","AA","A","B","C","D","E"};
  double t1,t2;
  double m5[]={35.5,37.5,40.0,43.0,50.0,55.0,70.0};
  double m10[]={71.0,77.0,83.0,89.0,105.0,116.0,148.0};
	       
  while(scanf("%lf %lf",&t1,&t2)!=EOF){
    for(i=0;i<7;i++){
      if(t1<m5[i]&&t2<m10[i]){
	printf("%s\n",rank[i]);
	break;
      }
    }
    if(i==7) printf("NA\n");
  }
  return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int gcd(int a,int b)
{
	if(!b)return a;
	return gcd(b,a%b);
}
int n,m,q,mod,b[50050][3],g,f[300030],z;
int find(int x)
{
	if(x!=f[x])return f[x]=find(f[x]);
	return x;
}
inline int id(int v,int p,int q){return (v-1)*6+p*3+q;}
void merge(int x,int y){if(find(x)!=find(y))f[find(x)]=find(y);}
bool check[2][1000010];
int main()
{
	scanf("%d %d %d %d",&n,&m,&q,&mod);
	int x,y,w;
	for(int i=1;i<=m;++i)
	{
		scanf("%d %d %d",&x,&y,&w);
		b[i][0]=x,b[i][1]=y,b[i][2]=w;
		g=gcd(abs(w-b[1][2]),g);
	}
	if(!g)g=mod;mod=gcd(mod,3*g);
	z=b[1][2]%g;
	for(int i=1;i<=6*n;++i)f[i]=i;
	for(int i=1;i<=m;++i)
	{
		w=(b[i][2]-z)/g;
		for(int j=0;j<=2;++j)
		{
			merge(id(b[i][0],0,j),id(b[i][1],1,(2*j+w)%3));
			merge(id(b[i][0],1,j),id(b[i][1],0,(2*j+w)%3));
			merge(id(b[i][1],0,j),id(b[i][0],1,(2*j+w)%3));
			merge(id(b[i][1],1,j),id(b[i][0],0,(2*j+w)%3));			
		}
	}
	for(int i=0,j=z;i<mod*2;++i,(j<<=1)%=mod)check[i&1][j]=1;
	while(q--)
	{
		bool flag=0;
		scanf("%d %d %d",&x,&y,&w);
		for(int p=0;p<=1;++p)
			for(int q=0;q<=2;++q)
				if(find(id(y,0,0))==find(id(x,p,q)))
					flag|=check[p][(w+z+(3-q)*g)%mod];
		flag?puts("YES"):puts("NO");
	}
	return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll N, K, Q;
    cin >> N >> K >> Q;
    VL A(Q), ans(N);
    for (ll i = 0; i < Q; i++) cin >> A[i];
    fill(ALL(ans), 0);

    for (ll i = 0; i < Q; i++){
        ans[A[i] - 1]++;
    }

    for (ll i = 0; i < N; i++){
        if(K - (Q - ans[i]) > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 2176
N = int(input())

l = [ 1 , 9 , 30 , 76 , 141 , 267 , 400 , 624 , 885 , 1249 , 1590 , 2208 , 2689 , 3411 , 4248 , 5248 , 6081 , 7485 , 8530 , 10248 , 11889 , 13687 , 15228 , 17988 , 20053 , 22569 , 25242 , 28588 , 31053 , 35463 , 38284 , 42540 , 46581 , 50893 , 55362 , 61824 , 65857 , 71247 , 76884 , 84388 , 89349 , 97881 , 103342 , 111528 , 120141 , 128047 , 134580 , 146316 , 154177 , 164817 , 174438 , 185836 , 194157 , 207927 , 218812 , 233268 , 245277 , 257857 , 268182 , 288216 , 299257 , 313635 , 330204 , 347836 , 362973 , 383709 , 397042 , 416448 , 434025 , 456967 , 471948 , 499740 , 515581 , 536073 , 559758 , 583960 , 604833 , 633651 , 652216 , 683712 , 709065 , 734233 , 754734 , 793188 , 818917 , 846603 , 874512 , 909496 , 933081 , 977145 , 1006126 , 1041504 , 1073385 , 1106467 , 1138536 , 1187112 , 1215145 , 1255101 , 1295142 , 1342852 , 1373253 , 1422195 , 1453816 , 1502376 , 1553361 , 1595437 , 1629570 , 1691292 , 1726717 , 1782111 , 1827492 , 1887772 , 1925853 , 1986837 , 2033674 , 2089776 , 2145333 , 2197483 , 2246640 , 2332104 , 2379085 , 2434833 , 2490534 , 2554600 , 2609625 , 2693919 , 2742052 , 2813988 , 2875245 , 2952085 , 3003306 , 3096024 , 3157249 , 3224511 , 3306240 , 3388576 , 3444609 , 3533637 , 3591322 , 3693924 , 3767085 , 3842623 , 3912324 , 4027884 , 4102093 , 4181949 , 4270422 , 4361548 , 4427853 , 4548003 , 4616104 , 4718640 , 4812789 , 4918561 , 5003286 , 5131848 , 5205481 , 5299011 , 5392008 , 5521384 , 5610705 , 5739009 , 5818390 , 5930196 , 6052893 , 6156139 , 6239472 , 6402720 , 6493681 , 6623853 , 6741078 , 6864016 , 6953457 , 7094451 , 7215016 , 7359936 , 7475145 , 7593865 , 7689630 , 7886244 , 7984165 , 8130747 , 8253888 , 8403448 , 8523897 , 8684853 , 8802826 , 8949612 , 9105537 , 9267595 , 9376656 , 9574704 , 9686065 , 9827097 , 9997134 , 10174780 , 10290813 , 10493367 , 10611772 , 10813692  ]
print(l[N-1])


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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

long long n;
long long a;
long long b;
long long pw(long long a, long long n){
    long long res = 1;
    while(n > 0){
        if(n & 1){
            res = res * 1ll * a % mod;
        }
        a = a * 1ll * a % mod;
        n >>= 1;
    }
    return res;
}
long long inv(long long x){
    return pw(x, mod - 2);
}
long long calc(long long a, long long n){
    long long p = 1;
    for(long long i = 0; i < a; i ++){
        p = p * 1ll * (n - i) % mod;
    }
    long long q = 1;
    for(long long i = 1; i <= a; i ++){
        q = q * 1ll * i % mod;
    }
    return (p * 1ll * inv(q) % mod);
}
int main()
{
    #ifdef FILEs
        freopen("input.txt", "r", stdin);
        /// freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);

    cin >> n >> a >> b;
    long long res = pw(2, n) - 1;
    res -= calc(a, n);
    res -= calc(b, n);
    res %= mod;
    if(res < 0){
        res += mod;
    }
    cout << res << "\n";
}



Measured memory_bytes: 256
S = input()
T = input()
L = []

for i in range(len(S)-len(T)+1):
    ok = True
    for j, t in enumerate(T):
        if S[i+j]!=t and S[i+j]!='?':
            ok = False
            break
    if ok: L.append(i)

S = S.replace('?', 'a')
X = []
for i in L:
    X.append(S[:i] + T + S[i+len(T):])

print(min(X) if len(X)!=0 else 'UNRESTORABLE')

Measured memory_bytes: 3064
//A - On the Way
#include <bits/stdc++.h>
using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B) {
        cout << "No" << endl;
    }

    else if (A < B) {
        if (A < C && C < B) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }

    else {
        if (B < C && C < A) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
h = [0] + gets.split.map(&:to_i)

x = Array.new(n+1, true)
m.times do
    a, b = gets.split.map(&:to_i)
    if h[a] < h[b]
        x[a] = false
    elsif h[b] < h[a]
        x[b] = false
    else
        x[a] = x[b] = false
    end
end

puts x.count {|e| e} - 1


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int x, n; cin >> x >> n;
  map<int, bool> mp;
  REP(i, n) {
    int a; cin >> a;
    mp[a] = true;
  }

  int mi = INF;
  int argmi = n;
  REP(i, 110) {
    if(mp[i]) continue;
    if(mi > abs(i - x)) {
      mi = abs(i - x);
      argmi = i;
    }
  }

  cout << argmi << endl;

}
























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

typedef long long ll;

ll func(ll x){
  if(x/10==0) return x;
  return x%10 + func(x/10);
}

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

  if(stoll(N)<10){
    cout << stoll(N) << endl;
    return 0;
  }


  vector<string> S(10);
  for(char i='9'; i>'0'; i--){
    S[i-'0'].push_back(i);
    for(int j=0; j<n-1; j++){
      S[i-'0'].push_back('9');
    }
  }

  for(int i=0; i<n-1; i++) S[0].push_back('9');

  ll Ma=0;
  for(int i=0; i<S.size(); i++){
    if(stoll(S[i])<=stoll(N)) Ma = max(Ma, func(stoll(S[i])));
  }

  cout << Ma << endl;
}

Measured memory_bytes: 256
n, h = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]

max_a = 0
for i in ab:
    max_a = max(i[0], max_a)

b = sorted([i[1] for i in ab if i[1] > max_a], reverse=True)

count = 0
for i in b:
    h -= i
    count += 1

    if h <= 0:
        print(count)
        exit()

print(count + (h - 1) // max_a + 1)

Measured memory_bytes: 29340
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    ll n;
    cin >>n;
    mes(n*n*n);
        
    
    
    
    
    

}


Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdio.h>
#include <set>
#include <vector>
using namespace std;


int main(){
    int a, b;
    string s;
    cin>>a>>b>>s;
    int i=1;
    int ans = 0;
    for(auto v:s){
        if(i<=a || (a+2<=i && i<=a+b+1)){
            i++;
            if(v<'0' || v>'9'){
                ans++;
            }
        }
        else if(i==a+1){
            i++;
            if(v!='-'){
                ans++;
            }
        }
        else{
            ans++;
            break;
        }
    }
    if(ans>0){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  rough
//
//  Created by abhishek kumar on 22/04/20.
//  Copyright © 2020 abhishek kumar. All rights reserved.
//

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


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll items,weight,value,target;
    cin>>items>>target;
    vector<pair<ll,ll>> arr;
    arr.push_back(make_pair(0, 0));
    for(auto i=1;i<=items;i++)
    {
        cin>>weight>>value;
        arr.push_back(make_pair(weight,value));
    }
    
    vector<vector<ll>> knapsack(items+1,vector<ll>(target+1,0));
    
    for(auto i=1;i<=items;i++)
    {
        for(auto j=1;j<=target;j++)
        {
            if(arr[i].first > j)
                knapsack[i][j]=knapsack[i-1][j];
            else
            {
                knapsack[i][j]=max(knapsack[i-1][j],arr[i].second + knapsack[i-1][j-arr[i].first]);
            }
                
        }
    }
    
    cout<<knapsack[items][target];
    
    return 0;
}

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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

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

    LL d = n/(a + b);

    LL cnt = d * a;
    n %= (a + b);

    cnt = cnt + min(a,n);

    cout << cnt << "\n";
}


Measured memory_bytes: 256
/*Saurav Paul*/
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long int
#define loop(i,a,b)           for(ll i=a;i<=b;++i)
#define boost		          ios_base::sync_with_stdio(0);
#define eb                    emplace_back
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1e9+7
#define itoc(c)               ((char)(((int)'0')+c))
#define ctoi(c)               ((int)(((int)c)-'0'))
#define all(p)                p.begin(),p.end()
#define iscn(num)             scanf("%d",&num);
#define scn(num)              scanf("%lld",&num);
#define scn2(num,num2)        scanf("%lld%lld",&num,&num2);
using namespace std;
///////////////////////

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef PAUL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define dbg(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
////////////////////////

template<typename T>T set_bit(T N,T pos){return N=N | (1<<pos);}
template<typename T>T reset_bit(T N,T pos){return N= N & ~(1<<pos);}
template<typename T> bool check_bit(T N,T pos){return (bool)(N & (1<<pos));}
template<typename T>void bin_print(T N){bitset<25>bit(N);cerr<<bit.to_string()<<"\n";}
template<typename T> void max_self(T &a, T b){
	a=max(a,b);
}
template <typename T > void min_self(T &a, T b){
	a=min(a,b);
}
template <typename T > void add_self(T &a, T b){
	a+=b;
}
////////////////////////

template<typename T> void ara_read(T &v,ll n){
	ll temp;
	for(ll i=0; i< n; i++){
		scanf("%lld",&temp);
		v.emplace_back(temp);
	}
}
template<typename T> void ara_print(T &v){
	for(ll x : v)
		printf("%lld ",x);
	puts("");
}
////////////////////////
const int INF = 1e9 + 99;
typedef pair<int,int> Pair;
typedef vector<int> vec;;
const int nax = 1e5 + 90;
const int mod = 1e9 + 7;
bool breaked[nax];

int main()
{
	int n ,m; 
	scanf("%d%d",&n,&m);
	for(int i = 0,temp ; i < m ; i++)
		scanf("%d",&temp),breaked[temp] = 1;
	
	vector < int > dp(n+1);
	dp[0] = 1;
	for(int i = 0 ;  i < n ; i ++){
		if(breaked[i]==0)
		for(int x : {1,2}){
			if(x+i <= n && breaked[x+i]==0){
				ll temp = (dp[i] + dp[x+i]) % mod;
				dp[x+i] = (int)temp ;
			}
		}
	}
	//~ debug() << dbg(dp);
	printf("%d\n",dp[n]);
    return 0;
}


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

using namespace std;

int c[15][15];
int p[1 << 15];
int dp[1 << 15][15];

int main() {
    int n, m, ans = 1e9, sum = 0, i, j, k;
    
    scanf("%d %d", &n, &m);
    
    for (i = 0; i < m; i++) {
        int x, y, z;
        
        scanf("%d %d %d", &x, &y, &z);
        
        x--;
        y--;
        
        sum += z;
        
        c[x][y] = c[y][x] = z;
    }
    
    for (i = 0; i < (1 << n); i++) {
        for (j = 0; j < n; j++) {
            if (((i >> j) & 1) == 0) continue;
            
            for (k = j + 1; k < n; k++) {
                if (((i >> k) & 1) == 0) continue;
                
                p[i] += c[j][k];
            }
        }
    }
    
    for (i = 0; i < (1 << n); i++) {
        for (j = 0; j < n; j++) {
            dp[i][j] = -1;
        }
    }
    
    dp[1][0] = 0;
    
    for (i = 0; i < (1 << n); i++) {
        for (j = 0; j < n; j++) {
            int x = ((1 << n) - 1) ^ i ^ (1 << j);
            if (dp[i][j] < 0) continue;
            
            for (int y = x; y >= 0; y--) {
                y &= x;
                dp[i | y][j] = max(dp[i | y][j], dp[i][j] + p[y]);
            }
            
            for (k = 0; k < n; k++) {
                if ((i >> k) & 1) continue;
                if (c[j][k] == 0) continue;
                
                dp[i | (1 << k)][k] = max(dp[i | (1 << k)][k], dp[i][j] + c[j][k]);
            }
        }
    }
    
    for (i = 0; i < (1 << n); i++) ans = min(ans, sum - dp[i][n - 1]);
    
    printf("%d\n", ans);
    
    return 0;
}


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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second

#define intRACE

#ifdef intRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
int pref[1000006];
int main(){
	string s;
	int n;
	cin.tie(0);
	cin >> n >> s;
	int ans  = 1e9;
	for(int i = 1; i <= n; i++) pref[i] = pref[i - 1] + (s[i - 1] == '#');
	for(int i = 0; i <= n; i++) ans = min(ans, pref[i] + n - i - (pref[n] - pref[i]));
	cout << ans;
}

Measured memory_bytes: 1412
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

    int N;
    cin >> N;
    ll A[N];
    rep(i, 0, N) cin >> A[i];
    sort(A, A + N);
    ll ruiseki[N];
    memset(ruiseki, 0, sizeof(ruiseki));
    ruiseki[0] = A[0];
    rep(i, 1, N) ruiseki[i] = ruiseki[i - 1] + A[i];


    int rsl = 1;
    for(int i = N - 2; i >= 0; i--) {
        if(2 * ruiseki[i] >= A[i + 1]) rsl++;
        else break;
    }
    cout << rsl << endl;
}


Measured memory_bytes: 1792
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

typedef pair<int, int> P;

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

    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    REP(i, M) cin >> B[i];

    int ans = 0;
    REP(i, N) {
        int score = C;
        REP(j, M) {
            int a;
            cin >> a;
            score += a * B[j];
        }
        if (score > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N, A;
  cin >> N >> A;
  vector<int> x(N);
  rep(i, N)
  {
    cin >> x[i];
  }
  map<pair<int, int>, long long> count;
  count[make_pair(0, 0)]++;
  rep(i, N)
  {
    int card = x[i];
    queue<pair<pair<int, int>, long long>> nums;
    for (auto itr = count.begin(); itr != count.end(); ++itr)
    {
      int num = itr->first.first;
      int card_count = itr->first.second;
      num += card;
      nums.push(make_pair(make_pair(num, card_count + 1), itr->second));
    }
    while (nums.size())
    {
      count[nums.front().first] += nums.front().second;
      nums.pop();
    }
  }

  long long ans = 0;
  for (auto itr = count.begin(); itr != count.end(); ++itr)
  {
    int num = itr->first.first;
    int card_count = itr->first.second;
    if (num == A * card_count)
      ans += itr->second;
  }
  cout << ans - 1 << endl;
  return 0;
}

Measured memory_bytes: 1920
//#pragma region ALL(include define etc)
#include <iostream>   // swap(a, b)
#include <string>
#include <cmath>      // abs(絶対値) sin cos tan(角度 / 180.0 * 3.141592)
#include <vector>     // vec.push_back(a) vec.pop_back()
#include <algorithm>  // max(a, b) min(a, b) reverse() sort()
#include <functional> // sort(a, a + N, greater<型>());
#include <math.h>
#include <iomanip>
#define int long long
#define ll long long
#define double long double
using namespace std;
//#pragma endregion

signed main()
{
	// 10^18 = 1000000000000000000

	//int h1, h2, m1, m2, k;
	//int box, box1,box2;

	//int N;
	int n;
	int a, b;
	int v, w, t;
	//int m;
	//int k;
	//string s;
	//string t;
	//int m1, m2;
	//int a, b, c, k;

	//int box[1000000000000000000];
	int box;
	int box2;

	//long double aaa;

	//int k, d;
	int all = 0;
	//double all;
	//double a, b;
	//double h, m;
	//int a[30000] = { 0 };
	//double c, d, e;

	//double mbox, hbox;
	//double box, box2;

	//int b = 0;

	//int box[10000] = { 0 };

	//bool flag = true;
	bool flag = false;

	//string str;

	//cin >> h1 >> m1 >> h2 >> m2 >> k;
	cin >> a >> v;
	cin >> b >> w;
	cin >> t;
	//cin >> a >> b;

	/*a = a + (v * t);
	b = b + (w * t);

	if(a>b)*/
	if (a < b)
	{
		for (int i = 1; i <= t; i++)
		{
			box = a + (v * i);
			box2 = b + (w * i);

			if (box >= box2)
			{
				flag = true;
				break;
			}
		}
	}
	else
	{
		for (int i = 1; i <= t; i++)
		{
			box = a - (v * i);
			box2 = b - (w * i);

			if (box <= box2)
			{
				flag = true;
				break;
			}
		}
	}


	/*if (a < b)
	{
		box = b - a;
		if (v > w)
		{
			box2 = v - w;
			box /= t;
			if (box >= box2)
			{
				flag = false;
			}
		}
		else
		{
			flag = false;
		}
	}
	else
	{
		if (w > v)
		{
			box = a - b;
			box2 = w - v;
			box /= t;
			if (box >= box2)
			{
				flag = false;
			}
		}
		else
		{
			flag = false;
		}
	}*/
	

	//for (int i = 0; i < n; i++)
	//{
	//	cin >> box;
	//	if (box == 0)
	//	{
	//		all = 0;
	//		flag = false;
	//		break;
	//	}
	//	all *= box;
	//}

	//all = a * b;

	//n = t.length();

	//cout << b << "\n";
	/*for (int i = 0; i < n; i++)
	{
		if (t[i] == '?')
		{
			t[i] = 'D';
		}
	}*/

	/*if (flag == true)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}*/
	//if (all == 0 && flag == true)
	//{
	//	cout << "-1\n";
	//}
	//else if (all > 1000000000000000000)//1000000000000000000
	//{
	//	cout << "-1\n";
	//}
	//else
	//{
	//	cout << all << "\n";
	//}
	if (flag == true)
	{
		cout << "YES\n";
	}
	else
	{
		cout << "NO\n";
	}

	//cout << fixed << setprecision(111) << all;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数


int main()
{
  string s ;
  cin >> s ;
  int n = SZ(s) ;
  vector<int> vec(4,0) ;
  REP(i,n){
    if(s.at(i)=='N'){
      vec.at(0)++ ;
    }
    else if(s.at(i)=='S'){
      vec.at(1)++ ;
    }
    else if(s.at(i)=='W'){
      vec.at(2)++ ;
    }
    else if(s.at(i)=='E'){
      vec.at(3)++ ;
    }
  }
  if(vec.at(0)==0 && vec.at(1)!=0){
    cout << "No"<<endl ;
    return 0 ;
  }
  if(vec.at(1)==0 && vec.at(0)!=0){
    cout << "No"<<endl ;
    return 0 ;
  }
  if(vec.at(2)==0 && vec.at(3)!=0){
    cout << "No"<<endl ;
    return 0 ;
  }
  if(vec.at(3)==0 && vec.at(2)!=0){
    cout << "No"<<endl ;
    return 0 ;
  }
  cout <<"Yes"<<endl ;
    


  return 0 ;
}




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



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

    int ketasuu = to_string(N).length();
    int sum = 0;

    for(int i=1;i<ketasuu;i++){
        if(i%2==1){
            sum += (pow(10, i) -1 ) - (pow(10, i-1) -1 );
        }

    }
	if(ketasuu%2==1){
        sum += N - pow(10, ketasuu-1) +1;
    }
      
    


    cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

int abs(int x){
  return x > 0 ? x : -x;
}

int length(char c[]){
  int cnt=0;
  for(cnt=0;c[cnt]!='\0';cnt++){
  }
  return cnt;
}
int x,t;

int main(){
  scanf("%d %d",&x,&t);
  printf("%d\n", max(0,x-t));
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h, w, count = 0;
    cin>>h>>w;
    char s [h+100][w+100];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin>>s[i][j];
        }
    }

    for( int i = 0; i < h; i++){
        for( int j = 0; j < w; j++){
            if(s[i][j] == '#'){
                cout<<"#";
            }else {
                if(s[i-1][j] == '#'){
                    count +=1;
                }
                if(s[i-1][j+1] == '#'){
                    count+=1;
                }
                if(s[i-1][j-1] == '#'){
                    count+=1;
                }
                if(s[i+1][j] == '#'){
                    count+=1;
                }
                if(s[i+1][j-1] == '#'){
                    count+=1;
                }
                if(s[i+1][j+1] == '#'){
                    count+=1;
                }
                if(s[i][j-1] == '#'){
                    count+=1;
                }
                if(s[i][j+1] == '#'){
                    count+=1;
                }

                cout<<count;
            }
            count = 0;
        }
        cout<<endl;
       
    }
return 0;
}

Measured memory_bytes: 256
use proconio::input;


fn main() {
    input! {
        n: usize
    }

    let mut vec = (0..=n).collect::<Vec<usize>>();

    let mut tbl = vec![true; n+1];
    tbl[0] = false;
    tbl[1] = false;
    for i in 2..=n {
        if tbl[i] {
            vec[i] *= 2;
            let mut j = i + i;
            while j <= n {
                tbl[j] = false;
                let mut count = 1;
                let mut k = j / i;
                while k % i == 0 {
                    count += 1;
                    k /= i;
                }
                vec[j] *= count+1;
                j += i;
            }
        }
    }

    let ans = {
        let mut ans = 1;
        for i in 2..=n {
            ans += vec[i];
        }
        ans
    };

    println!("{}",ans)

}



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

int main(){
	int n, a[100], c = 0;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++) {
		int minj = i;
		for (int j = i; j < n; j++) {
			if (a[minj] > a[j]) {
				minj = j;
			}
		}
		if (a[minj] != a[i])c++;
		int tmp = a[minj];
		a[minj] = a[i];
		a[i] = tmp;
	}
	for (int i = 0; i < n - 1; i++)cout << a[i] << " ";
	cout << a[n - 1] << endl << c << endl;

	return 0;
}

Measured memory_bytes: 3096
<?php
    $input_character = trim(fgets(STDIN));
    $character = preg_split("//u", $input_character, -1, PREG_SPLIT_NO_EMPTY);
    foreach ($character as $value) {
        if (ctype_upper($value)) {
            echo strtolower($value);
        } elseif (ctype_lower($value)) {
            echo strtoupper($value);
        } else {
            echo $value;
        }
    }
    echo PHP_EOL;


Measured memory_bytes: 9380
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string s;cin>>s;
	for(int i = 0; i < s.size(); i++) {
		cout << 'x';
	}
	cout << endl;
	return 0;
}

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

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

using namespace std;

vector<string> split_string(string);

int main() {
  int n,b;
  cin >> n;
  int sum = 0;
  vector<int> a(n);
  vector<int> c(n);
  for (int i = 0; i < n; i++) {
	cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
	cin >> b;
    sum += b;
  }
  for (int i = 0; i < n-1; i++) {
	cin >> c[i];
  }
  for (int i = 0; i < n; i++) {
	a[i]--;
  }
  
  for (int j = 0; j < n-1; j++) {
    if (a[j + 1] == a[j] + 1) {
      sum += c[a[j]];
    }
  }
    cout << sum << endl;
}
  

Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")



#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include <ext/rope>
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define Find order_of_key
// #define at find_by_order
#define x first
#define y second
#define ll long long
#define lll __int128
#define ull unsigned long long
#define ulll unsigned __int128
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define gu getchar_unlocked()
#define pu putchar_unlocked()
#define all(x) x.begin(),x.end()
#define endl '\n'

int n=300000;
struct segtree {
	static const int maxn = 300010;
	int tree[maxn << 2]={0};
	void build(int node = 1, int l = 0, int r = n) {
		if (l == r) {tree[node] = 0; return; }
		int mid = l + r >> 1;
		build(node << 1, l, mid);
		build(node << 1 | 1, mid + 1, r);
		tree[node] = max(tree[node << 1] , tree[node << 1 | 1]);
	}
	void update(int pos, ll v, int node = 1, int l = 0, int r = n) {
		if (r < pos || l > pos) return;
		if (pos == l && pos == r) {
			tree[node] = v;
			return;
		} int mid = l + r >> 1;
		update(pos, v, node << 1, l, mid);
		update(pos, v, node << 1 | 1, mid + 1, r);
		tree[node] = max(tree[node << 1] , tree[node << 1 | 1]);
	}
	ll query(int i, int j, int node = 1, int l = 0, int r = n) {
		if (r < i || l > j) return -1;
		if (i <= l && r <= j) {
			return tree[node];
		} int mid = l + r >> 1;
		return max(query(i, j, node << 1, l, mid) ,
		           query(i, j, node << 1 | 1, mid + 1, r));
	}
}sg;

int main()
{
	sg.build();
	int nn,k;
	cin>>nn>>k;
	for(int i=1;i<=nn;i++){
		int a;
		cin>>a;
		int l=max(a-k,0);
		int r=min(a+k,300000);
		int g=sg.query(l,r);
		sg.update(a,g+1);
	}cout<<sg.query(0,n)<<endl;
	return 0;
}

Measured memory_bytes: 7748