akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//const int INF = 1e9;//INT_MAX=1<<31-1=2147483647
const ll INF = (ll)1e18;//1<<63-1=9223372036854775807
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

const ll N_MAX = 100000;
const ll M_MAX = 100000;
const ll C_I_MAX = 1000000000;

ll N, M;

map<ll, ll> m;
ll ans=0;
void input() {
	scanf("%lld%lld", &N, &M);

	rep(i, N) {
		ll a;
		cin >>a;
		m[-a]++;
	}

	rep(i,M){
		ll a,b;
		cin >>a>>b;
		m[-b]+=a;
	}

}

void solve(){
	ll k=0;
	ll ans=0;
	for(auto a:m){
		ll num=-a.first;
		ll count=a.second;
		if(k+count<N){
			ans+=num*count;
			k+=count;
		}else{
			ans+=num*(N-k);
			break;
		}
	}

	printf("%lld\n", ans);
	return;
}

signed main() {
	input();
	solve();
	return 0;
}


Measured memory_bytes: 12800
#include <iostream>
using namespace std;
typedef long long ll;
#define MAX_N 100010
const ll R = 1e9 + 7;
 
int n, m;
ll dp[MAX_N] = {};

int main() {
    cin >> n >> m;
    int a[m + 1];
    for (int i = 0; i < m; i++) cin >> a[i];
    
    int j = 0;
    dp[1] = 1, dp[2] = 2;
    for (int i = 1; i <= n; i++) {
        if (i <= 2) dp[i] = dp[i - 1] + 1;
        else dp[i] = (dp[i - 1] + dp[i - 2]) % R;
        if (i == a[j]) {
            dp[i] = 0; 
            if (j < m) j++;
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1408
#include<set>
#include<cmath>
#include<stack>
#include<cstdio>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int n;
set<int>s;
int main(){
	scanf("%d",&n);
	while(n--){
		int x;
		scanf("%d",&x);
		if(s.find(x)!=s.end())s.erase(x);
		else s.insert(x);
	}
	printf("%d\n",s.size());
	return 0;
}

Measured memory_bytes: 4864
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
res = 0
for i in range(n):
  c = 0
  for j in range(n):
    if j < i:
      c += a[j]
    elif j == i:
      c += a[j]
      c += b[j]
    else:
      c += b[j]
  res = max(res,c)
print(res)

Measured memory_bytes: 9112
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
using namespace std;


using ll = long long int;

/// <summary>
/// GCDを計算します
/// </summary>
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
	if (a < b) {
		NumType tmp = a;
		a = b;
		b = tmp;
	}

	NumType r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

/// <summary>
/// 約数を数えます
/// </summary>
template <typename NumType>
NumType cntDivisor(const NumType& num) {
	NumType cnt = 0;
	for (NumType i = 1; i * i <= num; ++i) {
		if (num % i == 0) {
			cnt++;
			if (i * i != num) cnt++;
		}
	}

	return cnt;
}

/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define FOR_RANGE(index, beg, end)     for (ll index = beg; index < end; ++index)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"


///////////////////////////////////////////////////////////////////////////


int main() {
	// 入出力を早くするための魔法の言葉
	cin.tie(0);ios::sync_with_stdio(false);

	ll N, X;
	cin >> N >> X;

	vector<ll> tmp(N + 1);

	vector<ll> L(N);
	for (ll i = 0; i < N; i++) {
		cin >> L[i];
	}
	ll a = 0;
	for (ll i = 1; i < N + 1; i++) {
		a += L[i - 1];
		tmp[i] = a;
	}

	int ans = 0;
	for (int i = 0; i < N + 1; i++) {
		if (tmp[i] <= X) {
			++ans;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#coding:utf-8
inf = 1000000
n = int(input())
mtrx = []
for i in range(n):
    nums = list(map(int,input().split()))
    col = []
    for j in range(n):
        if nums[j] == -1:
            col.append(inf)
        else:
            col.append(nums[j])
    mtrx.append(col)

        
d = [inf for i in range(n)]
p = [-1 for i in range(n)]
color = ["white" for i in range(n)]
d[0] = 0
while True:
    mincost = inf
    for i in range(n):
        if color[i] != "black" and d[i] < mincost:
            mincost = d[i]
            u = i
    if mincost == inf:
        break

    color[u] = "black"
    for v in range(n):
        if color[v] != "black" and mtrx[u][v] < inf:
            if mtrx[u][v] < d[v]:
                d[v] = mtrx[u][v]
                p[v] = u
                color[v] = "gray"
print(sum(d))
      


Measured memory_bytes: 5868
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
  int a, b, c, x, y;

  cin >> a >> b >> c >> x >> y;

  if ((a + b) > (c * 2)) {
    if (x > y) {
      cout << (y * c * 2) + (x - y) * min(a, c * 2) << endl;
    } else if (x < y) {
      cout << (x * c * 2) + (y - x) * min(b, c * 2) << endl;
    } else {
      cout << (c * 2) * x << endl;
    }
  } else {
    cout << a * x + b * y << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define orep(i, n) for (int i = 1; i < (int)(n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

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

  bool flag = false;

  for (int i = 1; i < b + 1; i++) {
    if ((a + i * a) % b == c) flag = true;
  }

  string ans = flag ? "YES" : "NO";

  cout << ans << endl;

  return 0;
}

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

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

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

    ll n,h,w;
    cin>>n>>h>>w;
    ll res=0;
    FOR(i,0,n){
      ll in1,in2;
      cin>>in1>>in2;
      if(h<=in1 && w<=in2){
        res++;
      }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {

	int m = 0, f = 0, r = 0;
	char a[50];
	int j = 0;
	while (m != -1 || f != -1 || r != -1) {
		cin >> m >> f >> r;

		if (m == -1 || f == -1) {
			a[j] = 'F';
		}
		else if (m + f >= 80) {
			a[j] = 'A';
		}
		else if (m + f < 80 && m + f >= 65) {
			a[j] = 'B';
		}
		else if (m + f < 65 && m + f >= 50) {
			a[j] = 'C';
		}
		else if (m + f< 50 && m + f >= 30) {
			if (r >= 50) {
				a[j] = 'C';
			}else{
				a[j] = 'D';
			}
			
		}
		else {
			a[j] = 'F';
		}
		j++;
	}

	for (int i = 0; i < j-1; i++) {
		cout << a[i] << endl;
	}

	return 0;

}


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

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

  vector<int> a(n);
  rep(i, n) cin >> a[i];

  deque<int> deq;
  rep(i, n) {
    int index = lower_bound(deq.begin(), deq.end(), a[i]) - deq.begin();
    if (index == 0) {
      deq.push_front(a[i]);
    } else {
      deq[index - 1] = a[i];
    }
  }

  cout << deq.size() << endl;
  return 0;
}

Measured memory_bytes: 1024
#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
#define NDEBUG
#endif
#include<bits/stdc++.h>
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
const int N=8005,M=205,P=998244353;
int n,m,f[N][M],fac[N],ifac[N],inv[N];
int fpow(int k1,int k2){
	int k3=1;
	for(;k2;k2>>=1,k1=1LL*k1*k1%P)if(k2&1)k3=1LL*k3*k1%P;
	return k3;
}
void addx(int&k1,int k2){
	(k1+=k2)>=P&&(k1-=P);
}
int add(int k1,int k2){
	addx(k1,k2);
	return k1;
}
void subx(int&k1,int k2){
	(k1-=k2)<0&&(k1+=P);
}
int sub(int k1,int k2){
	subx(k1,k2);
	return k1;
}
void ntt(vector<int>&a,int g,int lim){
	a.resize(lim);
	for(int i=0,j=0;i<lim;++i){
		if(i<j)swap(a[i],a[j]);
		for(int k=(lim>>1);(j^=k)<k;k>>=1);
	}
	vector<int>w(lim>>1);
	w[0]=1;
	for(int i=1;i<lim;i<<=1){
		for(int j=1,wn=fpow(g,(P-1)/(i<<1));j<i;++j)w[j]=1LL*w[j-1]*wn%P;
		for(int j=0;j<lim;j+=i<<1)for(int k=0;k<i;++k){
			int x=a[j+k],y=1LL*a[i+j+k]*w[k]%P;
			a[j+k]=add(x,y),a[i+j+k]=sub(x,y);
		}
	}
	if(g!=3){
		int I=fpow(lim,P-2);
		for(int i=0;i<lim;++i){
			a[i]=1LL*a[i]*I%P;
		}
	}
}
int getlim(int k1){
	int k2=1;
	while(k2<=k1)k2<<=1;
	return k2;
}
vector<int>pmul(vector<int>a,vector<int>b){
	int need=SZ(a)+SZ(b)-1;
	int lim=getlim(need);
	ntt(a,3,lim),ntt(b,3,lim);
	rep(i,0,lim-1)a[i]=1LL*a[i]*b[i]%P;
	ntt(a,332748118,lim);
	return a.resize(need),a;
}
void pt(vector<int>a){
	for(int i=0;i<SZ(a);++i)D(" %d"+(i==0),a[i]);
	D("\n");
}
int C(int k1,int k2){
	if(k1<0||k2<0||k1-k2<0)return 0;
	return 1LL*fac[k1]*ifac[k2]%P*ifac[k1-k2]%P;
}
int main(){
	fac[0]=fac[1]=ifac[0]=ifac[1]=inv[0]=inv[1]=1;
	rep(i,2,N-1)fac[i]=1LL*fac[i-1]*i%P,inv[i]=1LL*(P-P/i)*inv[P%i]%P,ifac[i]=1LL*ifac[i-1]*inv[i]%P;
	scanf("%d%d",&n,&m);
	f[0][0]=1;
	rep(j,1,m){
		vector<int>F(n+1);
		rep(i,0,n){
			F[i]=1LL*f[i][j-1]*ifac[i]%P;
		}
		vector<int>G(ifac,ifac+3+n);
		G[0]=G[1]=G[2]=0;
		F=pmul(F,G);
		//D("F[%d]=",j);
		//pt(F);
		rep(i,0,n){
			f[i][j]=1LL*fac[i+2]*F[i+2]%P;
		}
		rep(i,0,n){
			addx(f[i][j],1LL*f[i][j-1]*(1LL*i*(i+1)/2%P+1)%P);
		}
	}
	int ans=0;
	for(int i=0;i<=n;++i){
		addx(ans,1LL*C(n,i)*f[i][m]%P);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 10364
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST         ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll           long long
#define ld           long double
#define pb           push_back
#define mp           make_pair
#define pii          pair<int,int>
#define mii          map<int,int>
#define vi           vector<int>
#define vll          vector<long long>
#define all(a)       (a).begin(),(a).end()
#define clz(a)       __builtin_clz(a) // count leading zeroes
#define ctz(a)       __builtin_ctz(a) // count trailing zeroes
#define popc(a)      __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul          1000000007
#define rep(i,a,b)   for(int i=a;i<b;i++)
#define rfor(i,a,b)  for(int i=a; i>=b; i--)
#define SIZE         1000005
#define F            first
#define S            second
#define mod          998244353
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::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, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define endl         '\n'
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void solve()
{
    int n; cin>>n;
    vi a(n+1),b(n+1),c(n+1);
    int ans=0, prev=-1;
    rep(i,1,n+1) cin>>a[i];
    rep(i,1,n+1) cin>>b[i];
    rep(i,1,n+1) cin>>c[i];
    rep(i,1,n+1)
    {
        ans+=b[a[i]];
        if(prev+1 == a[i]) ans+=c[prev];
        prev = a[i];
    }
    cout<<ans;
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1; //cin>>t;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#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=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  int a[100005], b;
  REP(i,N){
    cin >> a[i];
    if(a[i] == 1) b = i;
  }
  int ans = INF;
  REP(i,N){
    if(i <= b && b < i + K){
      ans = min(ans,
                (i + K - 2) / (K - 1) + (N - (i + K) + K - 2) / (K - 1));
      //      cout << "N, K, i, ans " << N << ' ' << K << ' ' << i << ' ' << (i + K - 2) / (K - 1) << ' ' << (N - (i + K) + K - 2) / (K - 1) << endl;;
    }
  }
  cout << ans + 1 << endl;
  return 0;
}


Measured memory_bytes: 640
n = gets.chomp.to_i
divisor = []
i = 1
while i * i <= n
    if n % i == 0 then
        divisor << i
        tmp = n / i
        divisor << tmp if tmp != i
    end
    i += 1
end
divisor.sort!
divisor_num = divisor.size

if divisor_num & 1 == 1 then
    puts (divisor[divisor_num/2] - 1) * 2
else
    puts divisor[divisor_num/2] + divisor[divisor_num/2-1] - 2
end

Measured memory_bytes: 1912
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
const int M = 2e5 + 10;
struct TnT {
    int pos;
    ll val;
}nn[M];
struct node {
    int l , r;
    ll sum;
}T[M << 2];
bool cmp(TnT a , TnT b) {
    if(a.val == b.val) return a.pos < b.pos;
    return a.val < b.val;
}
void push_up(int i) {
    T[i].sum = T[i << 1].sum + T[(i << 1) | 1].sum;
}
void build(int i , int l , int r) {
    int mid = (l + r) >> 1;
    T[i].l = l , T[i].r = r , T[i].sum = 0;
    if(l == r) return ;
    build(i << 1 , l , mid);
    build((i << 1) | 1 , mid + 1 , r);
    push_up(i);
}
void update(int i , int pos) {
    int mid = (T[i].l + T[i].r) >> 1;
    if(T[i].l == pos && T[i].r == pos) {
        T[i].sum++;
        return ;
    }
    if(mid < pos) update((i << 1) | 1 , pos);
    else update(i << 1 , pos);
    push_up(i);
}
ll query(int i , int l , int r) {
    int mid = (T[i].l + T[i].r) >> 1;
    if(T[i].l == l && T[i].r == r) {
        return T[i].sum;
    }
    push_up(i);
    if(mid < l) return query((i << 1) | 1 , l , r);
    else if(mid >= r) return query(i << 1 , l , r);
    else {
        return query(i << 1 , l , mid) + query((i << 1) | 1 , mid + 1 , r);
    }
}
int main() {
    ll n , k , a;
    scanf("%lld%lld" ,  &n , &k);
    for(int i = 1 ; i <= n ; i++) {
        scanf("%lld" , &a);
        a -= k;
        nn[i].pos = i;
        nn[i].val = nn[i - 1].val + a;
    }
    sort(nn + 1 , nn + 1 + n , cmp);
    ll ans = 0;
    build(1 , 1 , (int)n);
    for(int i = 1 ; i <= n ; i++) {
        update(1 , nn[i].pos);
        if(nn[i].val >= 0) ans++;
        if(nn[i].pos - 1 == 0) continue;
        ans += query(1 , 1 , nn[i].pos - 1);
    }
    printf("%lld\n" , ans);
    return 0;
}

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

int main(){
  long int h,w;
  cin>>h>>w;
  long long int s = (h*w);
  if(s%2==0)
    s=s/2;
  else
    s=s/2 +1;
  if(h==1 || w==1){
      s=1;
  }  
  cout<<s<<endl;    
  return 0;
}

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

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        int W = Integer.parseInt(st.nextToken());
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());

        int ans=0;
        if (a<b){
            ans=Math.max(b-(a+W),ans);
        }
        else{
            ans=Math.max(ans, a-(b+W));
        }
        System.out.println(ans);


    }


}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
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; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int MOD = 1e9+7;
const long long INF = 1LL << 60;
typedef long long ll;
int main(){
    ll n; cin >> n;
    vector<ll> d(n);
    rep(i,n)cin>>d[i];
    /* int cnt = 0;
    for(ll i = 0; i < 100010; i++){
        ll arc = 0, abc = 0;
        for(ll j = 0; j < n; j++){
            if(d[j]<i)abc++;
            else arc++;
        }
        if(arc==abc)cnt++;
    }
    cout << cnt << endl; */
    int cnt = 0;
    sort(d.begin(), d.end());
    for(int i = d[n/2-1]+1; i <= d[n/2]; i++){
        cnt++;
    }
    cout<<cnt<<endl;
}

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

int main(){
  int n,cnt=0,cnt1=0;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]%4==0) cnt++;
    else if(a[i]%2==0) cnt1++;
  }
  if((2*cnt+n%2)+cnt1>=n) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int isPrime(int n){
  for(int i=2;i*i<=n;i++) if(n%i==0) return false;
  return true;
}
int main(){
  bool d[70000];
  for(int i=0;i<70000;i++) d[i]=isPrime(i);
  int n;
  while(cin >> n){
    int k=1;
    while(!d[n-k]) k++;
    cout << n-k << " ";
    k=1;
    while(!d[n+k]) k++;
    cout << n+k << endl;
  }
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    ll n,x,t;
    cin >> n >> x >> t;
    cout << ((n+x-1)/x) * t << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<map>
#include<queue>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iostream>
#include<algorithm>
#define MAXN 100000

using namespace std;
map<int,int>m;
int a[MAXN+80],n,q;
int chk()
{
	int i,ans=0,appear0=0;
	for(i=1;i<=n;i++)
	{
		if(a[i]==0)
			appear0++;
		if(a[i]%q==0)
			ans+=i-appear0;
	}
	return ans;
}
int check()
{
	m.clear();
	m[0]=1;
	int houS=0,i,ans=0,pow10=1;
	for(i=n;i;i--)
	{
		houS=(houS+a[i]*pow10)%q;
		if(a[i])
			ans+=m[houS];
		m[houS]++;
		pow10=pow10*10%q;
	}
	return ans;
}
int main()
{
	int s,w,g,i;
	while(scanf("%d%d%d%d",&n,&s,&w,&q)==4&&(n||s||w||q))
	{
		g=s;
		for(i=1;i<=n;i++)
		{
			a[i]=(g/7)%10;
			if(g&1)
				g=(g>>1)^w;
			else
				g>>=1;
		}
		if(q==2||q==5)
			printf("%d",chk());
		else
			printf("%d",check());
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifdef DEBUG
#include <boost/core/demangle.hpp>
#define dump(x) cerr << "L" << __LINE__ << ": in " << __PRETTY_FUNCTION__ << " \e[32;1m" << boost::core::demangle(typeid(x).name()) << "\e[37m" << " " << (#x) << " = " << (x) << "\e[m" << endl;
#else
#define dump(x)
#endif
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T> ostream& operator<<(ostream &os, vector<T> &v){os << "{";ITR(i,v){if(i!=v.begin())os << ","; os << *i;}os << "}"; return os;}
template <typename T, typename U> ostream& operator<<(ostream& os, pair<T,U> &p){os << "(" << p.first << "," << p.second << ")"; return os;}

template <typename T> T& chmin(T &a, const T &b){return a = min(a,b);}
template <typename T> T& chmax(T &a, const T &b){return a = max(a,b);}

const LLI mod = 1e9+7;

LLI dp[11000][110][2];

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

  string K; cin >> K;
  int D; cin >> D;

  dp[0][0][0] = 1;

  REP(i,K.size()){
    REP(j,D){
      FORE(p,0,9) (dp[i+1][(j+p)%D][true] += dp[i][j][true]) %= mod;
      FOR(p,0,K[i]-'0') (dp[i+1][(j+p)%D][true] += dp[i][j][false]) %= mod;
      (dp[i+1][(j+K[i]-'0')%D][false] += dp[i][j][false]) %= mod;
    }
  }

  LLI ans = 0;
  REP(i,2) (ans += dp[K.size()][0][i]) %= mod;
  ((ans -= 1) += mod) %= mod;
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 18688
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ans = 0;
  
  for (int i = 0;i < n - 1;i++){
    for(int j = i + 1; j < n; j++){
      chmax(ans, abs(a[i] - a[j]));
    }
  }
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $K);

if($K <= 10){
    echo $K;
    exit;
}
$array = [0,1];
for($i=10;$i<$K;$i++){
    if($array[0] <= $array[1] && $array[0] != 9){
            $array[0]++;
    }else{
        $j = 0;
        while(($array[$j] > $array[$j+1] || $array[$j] == 9)) {
            $j++;
            if(!isset($array[$j+1])){
                if($array[$j] == 9){
                    $array[$j+1] = 0;
                    $j++;
                    break;
                }else{
                    break;
                }
            }
        }
        $array[$j]++;
        for($k = $j-1; $k>=0;$k--) {
            $array[$k] = max($array[$k + 1] - 1, 0);
        }
    }
}

echo (int)implode(array_reverse($array));


Measured memory_bytes: 4728
#include<stdio.h>
int main()
{
	int N;
  int hasil;
	scanf("%d", &N);

	if(N%2!=0){
    hasil=N/2;
		printf("%d", hasil+1);
	}
  else{
    hasil=N/2;
    printf("%d", hasil);
  }
	return 0;
}

Measured memory_bytes: 1732
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define N 500005
#define inf 1000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define int ll
using namespace std;
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,k,dis[N],ans,a[N],fa[N];
int nedge,Next[N*2],head[N],to[N*2];
#define V to[i]
void add(int a,int b){
	Next[++nedge]=head[a];head[a]=nedge;to[nedge]=b;
}
void dfs(int x){
	dis[x]=1;
	go(i,x){
		fa[V]=x;dfs(V);dis[x]=max(dis[x],dis[V]+1);
	}
	if (dis[x]==k&&fa[x]!=1&&x!=1) ans++,dis[x]=0;
}
signed main(){
	n=read();k=read();
	F(i,1,n) a[i]=read();
	if (a[1]!=1) ans++;
	F(i,2,n) add(a[i],i);
	dfs(1);
	wrn(ans);
	return 0;
}

Measured memory_bytes: 18432
#include <bits/stdc++.h>
#define  rep(i,n) for(li i = 0; i < (n); ++i)
#define  red(i,n) for(li i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;


int main()
{
    int a,b;
    cin>>a>>b;
    cout<<(a+b)/2+(a+b)%2<<endl;

    return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    var arr = readLine()!!.split(" ").map{it.toInt()}
    var ans = 0
    var cont = 0
    for(i in 1 until n){
        if(arr[i] <= arr[i - 1]){
            cont++
        }else{
            cont = 0
        }
        if(cont > ans){
            ans = cont
        }
    }
    println(ans)
}


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

int main() {
	int N, K, X;
  	cin >> N >> K;
    for (int i = 0; i < N; i++) {
      int a;
      cin >> a;
      if (K-a < a) {
        X += (K-a)*2 ;
      }
      else {
        X += a*2 ;
      }
    }
    cout << X << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void)

{
    double N, a, res, sum = 0.0;
    cin>>N;
    while(N--){
        cin>>a;
        res = (1.0/a);
        sum += res;
    }
    cout<<(1.0/sum)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

template <class It> string join(It i1, It i2)
{
    ostringstream ss;
    for (auto it = i1; it != i2; ++it)
        ss << ((it == i1) ? "" : ", ") << (*it);
    return ss.str();
}

#ifdef DEBUG
#define Dump(x) cerr << #x << " = " << x << endl;
#define Dumps(x) cerr << #x << " : { " << join(x.begin(), x.end()) << " }" << endl;
#else
#define Dump(x)
#define Dumps(x)
#endif


struct q_t
{
    q_t() : a(0), b(0) {}
    int a, b;
};
ostream& operator<<(ostream &os, const q_t &q)
{
    os << "(" << q.a << ", " << q.b << ")";
    return os;
}


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

    vector<q_t> Q(M);
    for (auto &q : Q)
        cin >> q.a >> q.b;

    sort(Q.begin(), Q.end(),
         [](const q_t &x, const q_t &y) { return (x.a != y.a) ? (x.a < y.a) : (x.b < y.b); });
    Dumps(Q);

    q_t t = Q[0];
    Dump(t);
    
    vector<int> C;
    for (int i = 1; i < M; ++i)
    {
        q_t q = Q[i];
        if (q.a >= t.b)
        {
            C.push_back(t.b - 1);
            t = q;
            Dump(t);
        }
        else if (q.b < t.b)
            t = q;
    }
    C.push_back(t.b - 1);

    Dumps(C);
    cout << C.size() << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string>) {}
template<typename T1,typename T2> ostream& operator<<(ostream& os, pair<T1,T2> buf) {
  return os << "(" << buf.first << ": " << buf.second << ")"; }
#define DefOut(Con) template<typename T>ostream&operator<<(ostream&os,Con<T>&A){ bool f = false; os << "{"; \
  for (const auto e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
#define DefOut2(Con) template<typename K,typename V>ostream&operator<<(ostream&os,Con<K,V>&A) \
{ bool f = false; os << "{"; for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
template<typename T>ostream &operator << (ostream &os,vector<vector<T>>& A) {
  for (auto &B: A) os << '\n' << B; return os; }
DefOut(vector) DefOut(set) DefOut(multiset) DefOut2(map) 
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << a << endl; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1000000007;
long long const INF = 1e18;
#define PI 3.14159265358979323846
/***********************************************************************/

int32_t main() {

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vector<vector<int>> g(n);
  vector<int> deg(n);
  int root = 0;
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    --u; --v;
    g[u].push_back(v);
    g[v].push_back(u);
    deg[u]++;
    deg[v]++;
    if (deg[u] > deg[root]) root = u;
    if (deg[v] > deg[root]) root = v;
  }
  vector<int> c(n);
  for (int &z: c) cin >> z;
  sort(ALL(c));
  reverse(ALL(c));
  
  vector<int> ans(n);
  int ptr = 0;
  i64 tot = 0;
  ans[root] = c[ptr++];
  queue<int> q;
  vector<bool> vis(n, false);
  vis[root] = true;
  q.push(root);
  while (!q.empty()) {
    int u = q.front(); q.pop();
    for (int v: g[u]) if (!vis[v]) {
      vis[v] = true;
      q.push(v);
      ans[v] = c[ptr++];
      tot += ans[v];
    }
  }
  
  assert (ptr == n);
  cout << tot << '\n';
  for (int z: ans) cout << z << ' ';
  cout << endl;

  return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
      
      	String astr = "";
      	String bstr = "";
      
      	for (int i=0 ; i<b ; i++) {
          astr = astr + Integer.toString(a);
        }
      
        for (int i=0 ; i<a ; i++) {
          bstr = bstr + Integer.toString(b);
        }
      
      	String[] temp = {astr,bstr};
        Arrays.sort(temp);
 
      	if (temp[0] != "") {
        	System.out.print(temp[0]);
        } else {
           System.out.print(temp[1]);
        }
   
	}
}


Measured memory_bytes: 21712
using System;

namespace atcorder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string s=Console.ReadLine();
            int N = int.Parse(s.Split(' ')[0]);
            int X = int.Parse(s.Split(' ')[1]);
            int[] m = new int[N];
            int min = X;
            for (int i = 0; i < N;i++){
                m[i] = int.Parse(Console.ReadLine());
                X -= m[i];
                if (min > m[i]) min = m[i];
            }
            Console.WriteLine(N + X / min);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;

int main() {
    ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int K;
    cin >> K;
    for(int i=0;i<N;i++){
        if(S[i]!=S[K-1])S[i]='*';
    }
    cout << S;
    


}

/*



 */



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long n,x,y,d;
    int cnt=0;
    cin>>n>>d;
    d*=d;
    while(n--)
    {
        cin>>x>>y;
        if(x*x+y*y<=d)
            cnt++;
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,ans=0;
	cin>>a>>b;
	if(a>b) ans+=a,a--;
	else ans+=b,b--;
	if(a>b) ans+=a,a--;
	else ans+=b,b--;
	cout<<ans;
}

Measured memory_bytes: 256
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.array(lr())
MOD = 10 ** 9 + 7
length = int(A.max()).bit_length()
answer = 0
for i in range(length):
    B = (A >> i) & 1
    x = np.count_nonzero(B)
    y = N - x
    x *= y
    x *= 2 ** i % MOD
    answer += x % MOD

print(answer % MOD)
# 18

Measured memory_bytes: 48832
import collections

N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

tento = 0
for i in range(N):
    a = A[i]
    for j in range(i+1, N):
        if A[i] > A[j]:
            tento += 1
tento *= K

vs = dict(collections.Counter(sorted(A)))
acc = 0

c = N
for i, (k, v) in enumerate(vs.items()):
    c -= v
    acc += v * c
tento += acc * (K * (K - 1) // 2)

print(tento % (10**9 + 7))


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	long long int h, w;
	cin >> h >> w;

	long long int odd = h / 2 + h % 2;
	long long int even = h / 2;

	if(h == 1 || w == 1) cout << 1;
	else cout << (w / 2 + w % 2) * odd + (w / 2) * even;

	return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std ;
typedef  long long int ll ;
#define inf ll(1e18)
#define mod 1000000007
#define mod1 998244353
#define mod2 999983
ll power(ll a,ll n,ll m) ;
ll power(ll a,ll n,ll m)
{  if(n==0)
   return 1 ;
   ll x=power(a,n/2,m) ;
   if(n%2!=0)
    return (((a*x)%m)*(x)%m)%m ;
    else return (x*x)%m ;
}
double PI=3.14159265357 ;
int32_t main()
{ ll n,i,j,x,y,m,k,t,sum,count,cnt,b,c,d,j1,z,a,temp;
  ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
   cin>>n ;
 cout<<(1000-(n%1000))%1000 ;
 return 0; }


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

constexpr lint mod0 = 1919191991;
constexpr lint mod1 = 1919191993;

bool is_prime(lint n) {
    for (int p = 2; p * p <= n; ++p) if (n % p == 0) {
        return false;
    }
    return true;
}

lint tmod(lint a, lint p) { return (a %= p) < 0 ? a + p : a; }
lint mod_inv(lint a, lint p) {
    a = tmod(a, p);
    lint b = p, x = 1, u = 0;
    while (b) {
        lint q = a / b;
        swap(a -= q * b, b);
        swap(x -= q * u, u);
    }
    return a == 1 ? tmod(x, p) : -1;
}

struct WeightedUnionFind {
    using T = pair<lint, lint>;
    static T op(T x, T y) { return {x.first * y.first % mod0, x.second * y.second % mod1}; }
    static constexpr T e() { return {1, 1}; }
    static T inv(T x) { return {mod_inv(x.first, mod0), mod_inv(x.second, mod1)}; }
    static T sub(T x, T y) { return op(x, inv(y)); }

    const int n;
    V<> t;
    V<T> pot;
    WeightedUnionFind(int n) : n(n), t(n, -1), pot(n, e()) {}
    int find(int v) {
        if (t[v] < 0) return v;
        int r = find(t[v]);
        pot[v] = op(pot[v], pot[t[v]]);
        return t[v] = r;
    }
    void unite(int u, int v, T d) {
        bool _same = same(u, v);
        assert(!_same);
        d = sub(d, sub(pot[v], pot[u]));
        if (t[u] >= 0) u = t[u];
        if (t[v] >= 0) v = t[v];
        if (-t[u] < -t[v]) {
            t[v] += t[u];
            t[u] = v;
            pot[u] = inv(d);
        } else {
            t[u] += t[v];
            t[v] = u;
            pot[v] = d;
        }
    }
    T diff(int u, int v) {
        bool _same = same(u, v);
        assert(_same);
        return sub(pot[v], pot[u]);
    }
    bool same(int u, int v) { return find(u) == find(v); }
    int size(int v) { return -t[find(v)]; }
};

int main() {
    // int t = 3;
    // for (lint p = 1919191919; ; ++p) if (is_prime(p)) {
    //     cerr << p << endl;
    //     if (t == 0)break;
    //     --t;
    // }
    // return 0;

    int n, m; cin >> n >> m;
    WeightedUnionFind uf(n);
    while (m--) {
        int a, b, v;
        cin >> a >> b >> v, --a, --b;
        pair<lint, lint> x = {v, v};
        if (uf.same(a, b)) {
            if (uf.diff(a, b) != x) {
                return cout << "No\n", 0;
            }
        } else {
            uf.unite(a, b, x);
        }
    }
    cout << "Yes\n";
}



Measured memory_bytes: 4704
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N,K;
bool bad[10];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> K;
    F0R(i,K) {
        int x; cin >> x;
        bad[x] = 1;
    }
    while (1) {
        bool z = 0;
        for (char c: to_string(N)) if (bad[c-'0']) {
            z = 1;
            break;
        }
        if (!z) {
            cout << N;
            exit(0);
        }
        N++;
    }
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#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)

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    int ans = 0;
    vector<int> h(n);
    rep(i, n) {
      cin >> h[i];
    }
    rep(left, n) {
      while(h[left] > 0) {
        int right, water;
        for (right = left + 1; right < n; ++right) {
          if (h[right] == 0)  break;
        }
        for (water = left; water <right; ++water) {
          h[water]--;
        }
        ans++;
      }
    }
    cout << ans << '\n';

    return 0;
}


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


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

    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    rep(i, n){
        string s;
        cin >> s;
        if(s == "AC"){
            ac++;
        }
        else if(s == "WA"){
            wa++;
        }
        else if(s == "TLE"){
            tle++;
        }
        else{
            re++;
        }
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

ll digits(ll m){
    return to_string(m).length();
}
int main() {
    ll n; cin >> n;

    ll ans = INFINITY;

    for (ll i = 1; i <= sqrt(n); ++i) {
        if (n % i == 0) {
            ll _ans = max(digits(i), digits(n / i));
            if (ans > _ans)ans = _ans;
        }
    }
    print(ans);
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

inline ll input() {
    ll n;
    cin >> n;
    return n;
}

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

set_random;

const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , k;
string s;

int main() {
    fast_io;

    cin >> n >> k >> s;
    for(ll i = 0 ; i < n ; i++)
    {
        if(i == k - 1)  s[i] |= 32;
    }
    cout << s << endl;

    return 0;
}
/*
todo :
    1- set constants
    2- check TimeLimit and MemoryLimit
    3- check special test cases
    4- don't forget BS can help you that is good idea(use for loop for floats)
    5- don't forget printf and scanf can help you in your code speed
*/


Measured memory_bytes: 384
<?php
fscanf(STDIN, "%d", $n);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
$b = array_fill(0, $n, 0); $p = []; $m = 0;
for ($i=$n - 1; $i >= 0; $i--) {
    $b[$i] = (count_multiple($i + 1, $i + 1) % 2) === $a[$i] ? 0 : 1;
    if ($b[$i] === 1) {
        $p[] = $i + 1;
        $m++;
    }
}
echo $m !== 0 ? $m."\n".implode(' ', $p) : $m;
function count_multiple($i, $s) {
    global $b, $n;
    $r = 0;
    for ($i=$i; $i <= $n; $i += $s) {
        $r += $b[$i - 1];
    }
    return $r;
}
?>

Measured memory_bytes: 33900
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define db long double
# define IOS ios_base :: sync_with_stdio(0)
# define halt(...) {fo << (__VA_ARGS__) << '\n';exit(0);}
# define pp(n) cerr << #n << " = " << n << '\n'
# define ppp(v) for (auto it : v) cerr << it << ' ';cerr << '\n'
const int mod = 1e9 + 7;
int dp[1 << 18][45];
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,x,y,z;
    fi>>n>>x>>y>>z;
    int ans = 0;
    int Mask = (1 << (x - 1)) | (1 << (x + y - 1)) | (1 << (x + y + z - 1));
    dp[0][0] = 1;
    const int M = (1 << (x + y + z)) - 1;
    for (int i = 1;i <= n;++i)
    {
        ans = (1ll * ans * 10) % mod;
        for (int m = 0;m <= M;++m)
            if ((m&Mask) != Mask && dp[m][i-1])
            {
                for (int j = 1;j <= 10;++j)
                {
                    int New_mask = M & ((m << j) | (1 << (j - 1)));
                    dp[New_mask][i] = (dp[New_mask][i] + dp[m][i-1]) % mod;
                }
            }
        for (int m = 0;m <= M;++m)
            if ((m&Mask) == Mask)
            ans = (ans + dp[m][i]) % mod;
    }
    fo << ans << '\n';
    return 0;
}

Measured memory_bytes: 23424
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
typedef long long int ll;
#define REP(i,n) for(int i=0;i<signed(n);i++)
const ll MOD = 1000000007;
const ll INF = 9e9;
ll N, M, ans = INF;
ll A[300010], S[301000];

using namespace std;
int main() {
	fill(begin(A), end(A), 0);
	fill(begin(S), end(S), 0);
	N = M = 0;
	std::ios_base::sync_with_stdio(false);
	cin >> N;
	REP(i, N) {
		cin >> A[i];
		S[i] += A[i];
		S[i + 1] = S[i];
	}
	//a:右半分の区切り i:真ん中 b:左半分
	//s:右の和 t:左の和
	ll a = 0, b = 2, s, t;
	REP(i, N - 1) {
		if (i == b)b++;
		s = (S[i] - S[a]) - S[a];
		t = (S[N - 1] - S[b]) - (S[b] - S[i]);
		bool f = true;
		if (i == 0)continue;
		while (f) {
			f = false;
			if (a + 1 == i)continue;
			if (abs(s)>abs(s - A[a + 1] * 2)) {
				s -= A[a + 1] * 2;
				a++; f = true;
			}
		}
		f = true;
		while (f) {
			f = false;
			if (b + 1 == N - 1 || b == N - 1)continue;
			if (abs(t)>abs(t - A[b + 1] * 2)) {
				t -= A[b + 1] * 2;
				b++; f = true;
			}
		}
		ans = min(ans, (max({ S[a],S[i] - S[a],S[b] - S[i],S[N - 1] - S[b] })
			- min({ S[a],S[i] - S[a],S[b] - S[i],S[N - 1] - S[b] })));
	}
	cout << ans << endl;
	cin >> a;
	return 0;
}


Measured memory_bytes: 4992