akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<bool>v(n);
    vector<bool>vend(n);
    for(int i=0;i<m;i++)
    {
        int f,s;
        cin>>f>>s;
        f--,s--;
        if(f==0){
            v[s]=true;
        }
        else
        if(s==n-1){
            vend[f]=true;
        }
    }
    bool no=true;
    for(int i=0;i<n;i++){
        if(v[i]==true&&vend[i]==true){
            no=false;
            break;
        }
    }
    if(no){
        cout<<"IMPOSSIBLE"<<endl;
    }
    else{
        cout<<"POSSIBLE"<<endl;
    }

}


Measured memory_bytes: 3692
S = input()

N = len(S)
cnt = 0

for i in range(1 << (N - 1)):
    tmp = S[0]
    for j in range(N - 1):
        if (1 << j) & i:
            tmp += '+'
        tmp += S[j + 1]
    cnt += eval(tmp)

print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <utility>
#include <algorithm>
#include <math.h>
#include <cmath>

using namespace std;
typedef long long ll;

ll dp[100005];
ll arr[100005];
int n=0;
ll dpfun(int i)
{
	if(dp[i]!= -1)
		return dp[i];
	if(i==n-1)
		return dp[i]=0;
	if(i==n-2)
		return dp[i]=abs(arr[i]-arr[i+1]);
	else
		return dp[i]=min(abs(arr[i]-arr[i+1]) + dpfun(i+1), abs(arr[i]-arr[i+2]) + dpfun(i+2));
}

int main()
{
	ios_base::sync_with_stdio(false); 
	cin>>n;
	memset(dp,-1, sizeof dp);
	int i;
	for(i=0;i<n;i++)
		cin>>arr[i];

	cout<<dpfun(0)<<endl;
	return 0;
}

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

int main(){
  int n, i;
  cin >> n;
  vector<int> a(n);
  for(i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<int>());
  int count = 0, befor = -1;
  for(i = 0; i < n; i++){
    if(a[i] != befor){count++;}
    befor = a[i];
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

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

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

LL D;

vector<int> Ddig;

LL mask(int x) {
    return 1LL << x;
}

bool contains(LL s, int x) {
    return s & mask(x);
}

LL solve(int n) {
    vector<LL> b(n);

    LL solutions = 0;

    for (int i = 0; i < mask(n-1); i++) {
        fill(b.begin(), b.end(), 0);

        bool valid = true;

        FORN(j, n) {
            bool prevcarry = (j > 0) && contains(i, j-1);
            bool carry = contains(i, j);

            b[j] = 10 * carry - (Ddig[j] + prevcarry);

            if (abs(b[j]) >= 10 || (n-1-j <= j && b[j] != -b[n-1-j])) {
                valid = false;
                break;
            }
        }

        if (valid) {
            LL curr = 1;

//            PR0(b, n);

            FORN(j, n) {
                if (n-1-j < j) break;
                curr *= (10 - abs(b[j])) - (j == 0 && b[j] >= 0);
            }

            solutions += curr;
        }
    }

    return solutions;
}

int main() {
    GLL(D);

    while (D) {
        Ddig.PB(D % 10);
        D /= 10;
    }

    int Dsz = Ddig.size();

    while (Ddig.size() < 2 * Dsz + 1) {
        Ddig.PB(0);
    }

    LL res = 0;
    for (int i = Dsz; i <= 2 * Dsz + 1; i++) res += solve(i);
    printf("%lld\n", res);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

int main() {
	int n;
	string s, t;
	string ans;
	cin >>n>> s>>t;
	rep(i, n) {
		ans += s[i];
		ans += t[i];
	}
	cout << ans;
}


Measured memory_bytes: 256
/* 
	بسم الله الرحمن الرحیم
	
	(; طلا یک جهانی
*/	

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

#define int long long

int32_t main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int r, d, x;
	cin >> r >> d >> x;
	for (int i = 0; i < 10; i++) {
		x = r * x - d;
		cout << x << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll a;
    cin >> a;
    vector<ll> sums(100001, 0);
    sums.push_back(0);
    for (int i = 0; i <= 100000; i++)
    {
        if (i <= 2 || i % 2 == 0)
        {
            sums[i + 1] = sums[i];
            continue;
        }
        int k = (i + 1) / 2;
        bool s = true, t = true;
        for (int j = 2; j <= sqrt(i); j++)
        {
            if (i % j == 0)
            {
                s = false;
                break;
            }
        }
        for (int j = 2; j <= sqrt(k); j++)
        {
            if (k % j == 0)
            {
                t = false;
                break;
            }
        }
        sums[i + 1] = sums[i];
        if (s && t)
            sums[i + 1]++;
    }
    for (int i = 0; i < a; i++)
    {
        ll k, l;
        cin >> k >> l;
        cout << sums[l + 1] - sums[k] << endl;
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

#define int long long int

void solve(long long K) {
  string s = "ACL";
  rep(i, K) cout << s;
  cout << endl;
}

signed main() {
  long long K;
  scanf("%lld", &K);
  solve(K);
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    priority_queue<double, std::vector<double>, std::greater<double> > que;
    int n;
    cin >> n;
    rep(i,n)
    {
        int tmp;
        cin >> tmp;
        que.push(tmp);
    }
    while(true)
    {
        double a,b,c;
        a = que.top();
        que.pop();
        b  = que.top();
        que.pop();
        c = (a+b)/2;
        if (que.empty())
        {
            cout << c << endl;
            break;
        }
        que.push(c);
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

class Edge{
public:
	int from, to;
    ll cost;
	Edge(int from = 0, int to = 0, ll cost = 0) :
			from(from), to(to), cost(cost){}

	bool operator < (const Edge &e) const{
		return cost < e.cost;
	}
	bool operator >(const Edge &e) const{
		return cost > e.cost;
	}

};

class Node{
public:
	vector<Edge> edges;
	ll dist;
	Node(){
		dist = -1;
	}
};

class Graph{
public:
	vector<Node> nodes;
	Graph(int n) {
		rep(i, n) { Node n;  nodes.push_back(n); }
	}
	Node& operator[](int i){
		return nodes[i];
	}
};


class Data{

public:
	ll dist;
	Edge *edge;
	Data(ll dist, Edge *edge) {
		this->dist = dist;
		this->edge = edge;
	}

	bool operator < (const Data &d) const{
		return dist < d.dist;
	}
	bool operator >(const Data &d) const{
		return dist > d.dist;
	}
};

int N, Q, K;
Graph G(0);
ll dist[100000];

void process(int K){
	queue<Data> q;
	Edge e0 =  Edge(-1, K, 0);
	q.push(Data(0, &e0));

	while(!q.empty()){
		Data d = q.front(); q.pop();
        Edge &e = *(d.edge);
        Node &n = G[e.to];
		if(n.dist != -1) continue;

		n.dist = d.dist;

		for(auto &ee: n.edges){
			q.push(Data(n.dist + ee.cost, &ee));
		}
	}

    rep(i, N){
        fprintf(stderr, "%d %lld\n", i, G[i].dist);
    }
}

ll query(int x, int y){
	return G[x].dist + G[y].dist;
}

int main() {
	cin >> N;
	G = Graph(N);

	rep(i, N-1){
		int a, b; ll c;
		cin >> a >> b >> c; a--; b--;
		G[a].edges.push_back(Edge(a, b, c));
		G[b].edges.push_back(Edge(b, a, c));
	}

	cin >> Q >> K;
    K--;
	process(K);

	rep(i, Q){
		int x, y;
		cin >> x >> y; x--; y--;
		cout << query(x, y) << endl;
	}

}

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

int main(){
  int n;
  cin >> n;
  
  vector<long int> L;
  L.push_back(2);
  L.push_back(1);
  
  for(int i=2; i<=n; i++){
    L.push_back(L.at(i-2) + L.at(i-1));
  }
  cout << L[n] << endl;
}

Measured memory_bytes: 256
n,k,*a=map(int, open(0).read().split())
b=[0]
for t in a:b+=(t-1+b[-1])%k,
d={k:0}
a=0
for l,r in zip([k]*min(k,n+1)+b,b):d[l]-=1;t=d.get(r,0);a+=t;d[r]=t+1
print(a)

Measured memory_bytes: 35744
function Main(input) {
	const splited = input.split("\n");
	const a = parseInt(splited[0], 10);
    let res = "No";
    let count = 0;
  	for (let i = 1; i <= a; i++) {
        const t = splited[i].split(" ");
        if (parseInt(t[0], 10) === parseInt(t[1], 10)) {
            count++;
            if (count >= 3) {
                  res = "Yes";
                  break;
            }
            continue;
        }
        count = 0;
    }
	//出力
	console.log(res);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29604
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    N, Q = iim()
    it = map(int, sys.stdin.read().split())

    M = N + 1if N & 1 else N
    NM = 1<<M.bit_length()
    ans = (N-2)**2
    A = [[N-2]*(NM+M) for i in range(2)]

    def set(a, i, j, x):
        i += NM; j += NM
        while i < j:
            a[i] = min(a[i], x)
            if i&1:
                i += 1
            a[j] = min(a[j], x)
            if j&1 == 0:
                j -= 1
            i >>= 1; j >>= 1
        a[i] = min(a[i], x)
    def get(a, i):
        i += NM
        ans = a[i]
        while i > 0:
            i >>= 1
            ans = min(ans, a[i])
        return ans

    for q, i in zip(it, it):
        q -= 1; i -= 2
        val = get(A[q], i)
        ans -= val
        set(A[q^1], 0, val, i)
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 110444
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll a,b,n;
    cin >> a >> b >> n;
    ll maxx = min(n,b-1);
    cout << (a*maxx)/b << endl;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
#define ff first
#define ss second
#define szof(_x) ((int) (_x).size())
#define TASK_NAME ""

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7;
const ll INFL = 1e18 + 123;
const double PI = atan2(0, -1);
mt19937 tw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(tw) % (y - x + 1) + x; }

const int MOD = 998244353;

void add(int& a, int b) {
	a += b;
	if (a >= MOD) {
		a -= MOD;
	}
}

int mult(int a, int b) {
	return (ll) a * b % MOD;
}

vector<int> factorial, rfactorial;

int cnk(int n, int k) {
	return mult(factorial[n], mult(rfactorial[n - k], rfactorial[k]));
}

int mpow(int a, int b) {
	int ret = 1;
	while (b) {
		if (b & 1) {
			ret = mult(ret, a);
		}
		a = mult(a, a);
		b >>= 1;
	}
	return ret;
}

int inv(int a) {
	return mpow(a, MOD - 2);
}

void solve() {
	int n, a, b;
	ll k;
	cin >> n >> a >> b >> k;

	factorial = {1};
	for (int i = 1; i < n + 5; ++i) {
		factorial.push_back(mult(factorial.back(), i));
	}
	rfactorial = {inv(factorial.back())};
	for (int i = n + 4; i > 0; --i) {
		rfactorial.push_back(mult(rfactorial.back(), i));
	}
	reverse(rfactorial.begin(), rfactorial.end());

	int ans = 0;
	for (int i = 0; i <= n; ++i) {
		if ((ll) i * a <= k && (k - (ll) i * a) % b == 0 && (k - (ll) i * a) / b <= n) {
			add(ans, mult(cnk(n, i), cnk(n, (k - (ll) i * a) / b)));
		}
	}

	cout << ans << "\n";
}


int main() {
	//freopen(TASK_NAME ".in", "r", stdin);
	//freopen(TASK_NAME ".out", "w", stdout);
	cerr << fixed << setprecision(15);
	cout << fixed << setprecision(15);
	ios::sync_with_stdio(false);

	int tests = 1;
	// cin >> tests;
	for (int it = 1; it <= tests; ++it) {
		solve();
	}
	
	#ifdef LOCAL
		cerr << "time: " << clock() << " ms\n";
	#endif
	return 0;
}

Measured memory_bytes: 4464
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n,m,x,v;
vector<vector<int>> books;

int main(){
    scanf("%d %d %d",&n,&m,&x);
    for(int i=0;i<n;i++) {
        vector<int> book;
        for(int j=0;j<=m;j++) {
            scanf("%d",&v);
            book.push_back(v);
        }
        books.push_back(book);
    }
    ll best = 1e9;
    for(int i=0;i<(1<<n);i++) {
        vector<ll> skills(m,0);
        ll cost = 0;
        for(int j=0;j<n;j++)
        if(i&(1<<j)) {
            cost += books[j][0];
            for(int k=0;k<m;k++) skills[k] += books[j][k+1];
        }
        bool valid = true;
        for(int k=0;k<m && valid;k++) if(skills[k] < x) valid = false;
        if(valid) {
            best = min(best, cost);
        }
    }
    cout << (best >= 1e9 ? -1 : best) << endl;
}


Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    string S;
    cin >> S;
    int l = 0, r = 0;
    ll ans = 0;
    for(int i = 0; i < S.size(); i++){
        if(r != 0 && S[i] == '<'){
            v.push_back(P(l, r));
            l = 1;
            r = 0;
        }else if(S[i] == '<'){
            l++;
        }else if(S[i] == '>'){
            r++;
        }
    }
    if(r != 0 || l != 0) v.push_back(P(l, r));
    for(int i = 0; i < v.size(); i++){
        ll l = v[i].first;
        ll r = v[i].second;
        if(r < l) swap(l, r);
        //cout << l << ' ' << r << endl;
        ans += (((r)*(r+1))/2 + (l*(l-1))/2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3352
#include <bits/stdc++.h>
using namespace std;
int main(){
 
  int a,b,c,d,e,k;
  cin >> a>>b>>c>>d>>e>>k;
  
  if(e-a<=k) cout << "Yay!" <<endl;
    else cout << ":(" << endl;
 
  
  
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int d[10][10];
int main()
{
	int mx, my;
	scanf("%d%d", &mx, &my);
	for (int i = 0; i < 10; i++)for (int j = 0; j < 10; j++)scanf("%d", &d[i][j]);
	for (int i = 0; i < 10; i++)for (int j = 0; j < 10; j++)for (int k = 0; k < 10; k++)d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
	int ans = 0;
	for (int i = 0; i < mx*my; i++)
	{
		int z;
		scanf("%d", &z);
		if (z != -1)ans += d[z][1];
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
#define DUMP1(A) do { for (auto &a : A) cout << a << ' '; cout << '\n'; } while (0)
#define DUMP2(A) do { for (auto &row : A) { DUMP1(row); } } while (0)
int main() {
    string T; cin >> T;
    for (int i = 0; i < T.size(); i++) {
        if (T[i] == '?') T[i] = 'D';
    }
    cout << T << endl;
    return 0;
}


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

using namespace std;

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

using ll = long long;

const ll INF = (1LL<<61);

ll abs(ll a, ll b) {
  ll c = a - b;
  return c > 0 ? c : -c;
}

int N;
int h[100010];
ll dp[100010];

int main() {
  int i;

  cin >> N;
  REP(i,N) scanf("%d", &h[i]);

  REP(i,N) {
    ll a = (i - 1 >= 0) ? dp[i-1] + abs(h[i] - h[i-1]) : INF;
    ll b = (i - 2 >= 0) ? dp[i-2] + abs(h[i] - h[i-2]) : INF;
    dp[i] = (a == INF && b == INF) ? 0 : min(a, b);
  }

  cout << dp[N-1] << endl;

  return 0;
}



Measured memory_bytes: 1408
N, K = map(int,input().split())
dl = list(input().split())
# 案１：使える数値を順に組み合わせていく
# 案２：Nから順に数字を＋１ずつ加算していき、使える文字のみになったら終了
temp = N - 1
flg = True
while flg:
    temp += 1
    flg = False
    st = str(temp)
    for i in range(len(st)):
        if st[i] in dl:
            flg = True
print(temp)


Measured memory_bytes: 2940
<?php
fscanf(STDIN, "%s", $s);
$ln = strlen($s);
$x = PHP_INT_MAX;
for ($i = 0; $i < $ln; $i++) {
	$c = $s[$i];
	if (isset($n[$c])) continue;
	$n[$c] = $i;
	$d = 0;
	for ($j = $i + 1; $j < $ln; $j++) {
		if ($s[$j] == $c) {
			if ($d > $n[$c]) $n[$c] = $d;
			$d = 0;
		} else {
			$d++;
		}
	}
	if ($d > $n[$c]) $n[$c] = $d;
	if ($x > $n[$c]) $x = $n[$c];
}
echo $x;

Measured memory_bytes: 4604
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

bool isPrime[100010];
void set_prime() {
	for (int i = 1; i <= 100000; i++) {
		isPrime[i] = true;
	}
	isPrime[0] = false; isPrime[1] = false;
	for (int i = 2; i * i <= 100000; i++) {
		int j = 2;
		while (i * j <= 100000) {
			isPrime[i * j] = false;
			j++;
		}
	}
}

int main()
{
	int N;
	cin >> N;
	set_prime();
	int j = 2;
	for (int i = 0; i < N; i++) {
		while (true) {
			if (isPrime[j] && j % 5 == 1) {
				cout << j++ << " ";
				break;
			}
			j++;
		}
	}
	cout << endl;
}


Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

ll N,K;
vector<int> g[100010];

ll ans;

void dfs(int now,int par,int ppar,int num){
    int co=0;
    if(par!=-1) co++;
    if(ppar!=-1) co++;
    ans=ans*(K-num-co)%MOD;

    co=0;
    for(auto nex:g[now]){
        if(nex==par) continue;
        dfs(nex,now,par,co);
        co++;
    }
}

int main(){
  cin>>N>>K;
  for(int i=0;i<N-1;i++){
    int a,b;
    cin>>a>>b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  ans=1;
  dfs(1,-1,-1,0);
  cout<<ans%MOD<<endl;



  return 0;
}


Measured memory_bytes: 9216
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long X = lread();
    if (X <= 6)
    {
        writeln(1);
        return;
    }
    long ans = X / (5 + 6) * 2;
    long x = X % (5 + 6);
    foreach (i; 0 .. 100)
    {
        if (x <= 0)
        {
            writeln(ans);
            return;
        }
        x -= (i & 1) ? 5 : 6;
        ans++;
    }
}


Measured memory_bytes: 3664
#F
H,W=map(int,input().split())
A=[[x for x in input()] for i in range(H)]
mod=10**9+7

dp=[[0 for i in range(W+1)] for j in range(H+1)]
dp[H-1][W-1]=1

for i in range(H-1,-1,-1):
    for j in range(W-1,-1,-1):
        if i==H-1 and j==W-1:
            continue
        
        if A[i][j]=="#":
            continue
        elif A[i][j]==".":
            dp[i][j]=(dp[i+1][j]+dp[i][j+1])%mod

print(dp[0][0])

Measured memory_bytes: 90716
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<long long> v(N);
    long long sum;
    long long mod = pow(10,9)+7;
    for(int i=0;i<N;i++){
        cin >> v[i];
        sum += v[i];
        sum %= mod;
    }
    long long ans=0;
    for(int i=0;i<N-1;i++){
        sum -= v[i];
      //cout << sum << endl;
        if(sum <= 0) sum += mod;
      //cout << sum << endl;
        ans += (v[i] * sum);
        ans %= mod;
      //cout << ans << endl;
    }

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

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

int solve(int a, int b, int c, int k) {
    int ans = 0;

    int x = min(k, a);
    k -= x;
    ans += x;

    if (k == 0) return ans;

    x = min(k, b);
    k -= x;

    if (k == 0) return ans;

    ans -= k;
    return ans;
}

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

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    cout << solve(a, b, c, k) << newl;
    
    return 0;
}

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

 
int main(){
    long long N,A,B;
    cin >> N >> A >> B;
    long long H[N];
    rep(i,N) cin >> H[i];
    int low = 0,high = 1e9;
    while(high-low > 1){
        long long mid = (high+low)/2;
        long long count = 0;
        rep(i,N){
            if(H[i] - mid * B > 0){
                count += ceil((H[i] - mid * B) / (double)(A-B));
            }
        }
        if(count <= mid){
            high = mid;
        }else{
            low = mid;
        }
    }
    cout << high << endl;

    return 0;
}

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

int main() {
	
	//vector<int> a(n);  sort(a.begin(),a.end());
	//cout << "test" << "\n";

	cin.tie(0);
	ios::sync_with_stdio(false);
	
	//string ans="YES";
	
	double ans=0;


	int n;
	cin >> n;
	
	vector<double> a(n);
	
	rep(i,n) cin >> a[i];
	sort(a.begin(),a.end());
	
	ans=a[0]+a[1];
	ans/=2;
	
	for(int i=2;i<n;i++){
		ans=(ans+a[i])/2;
	}

	cout << ans << "\n";
	
	
	return 0;

    }

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

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

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

	int r = 0;
	ll sum = 0, ans = 0;
	for (int l = 0; l < n; l++) {
		while (r < n && ((sum + a[r]) == (sum ^ a[r]))) {
			sum += a[r];
			r++;
		}
		ans += r - l;
		if (r == l) r++;
		else sum -= a[l];
	}

	out(ans);

	return 0;
}

Measured memory_bytes: 1792
N, M, L = map(int,input().split(' '))
Ms=[]
inf = 10**11
for i in range(N+1):
    #for j in range(N):
    Ms.append([inf]*(N+1) )
#print(d)
#print(d[1][1])
for i in range(M):
    a,b,c = map(int,input().split(' '))
    #print(a,b,c)
    Ms[a][b] = c
    Ms[b][a] = c
    #print(Ms)
Q = int(input())

def warshall_floyd(Ms):
    for k in range(1,len(Ms)):
        for i in range(1,len(Ms)):
            for j in range(1,len(Ms)):
                Ms[i][j]=min(Ms[i][j],Ms[i][k]+Ms[k][j])
    return Ms

Ms = warshall_floyd(Ms)
#print(Ms)
#print("Ms",Ms[3][2],Ms[2][3])
#Ls = Ms.copy()
Ls = Ms
for i in range(N+1):
    for j in range(N+1):
        if Ls[i][j] <= L:
            Ls[i][j] = 1
        else:
            Ls[i][j]=inf
#print("Ls",Ls[3][2])
Ls = warshall_floyd(Ls)
#print(Ls)
for i in range(Q):
    s,t = map(int,input().split(' '))
    if Ls[s][t] == inf:
        print(-1)
    else:
        print(Ls[s][t]-1)



Measured memory_bytes: 58200
#include <stdio.h>
int gcd(int a, int b)
{
  int r;
  if (a > b) {
    int t = b;
    b = a;
    a = t;
  }
  
  while ((r = b % a) != 0) {
    b = a;
    a = r;
  }
  
  return a;
}

int main(void)
{
  int k;
  int wa = 0;
  int l, m, n;
  
  scanf("%d",&k);
  
  for (l=1; l<=k; l++) {
    for (m=1; m<=k; m++) {
      for (n=1; n<=k; n++) {
        wa += gcd(gcd(l,m),n);
      }
    }
  }
  
  printf("%d",wa);
  
  return 0;
}

Measured memory_bytes: 1720
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1
#define sosuu 1000000007

int main(){
  int N;
  cin >> N;
  int ans=1;
  int a,b;
  int judge;
  rep(i,N){
  if(i==0){
  cin >> a;
    continue;
  }
    cin>>b;
    judge=max(a,judge);
    if(judge<=b)
      ans++;
    a=b;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define ll long long
using namespace std;
vector<int> adj[114514];
int deg[114514],grundy[114514];
signed main(){
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++){
		int x,y;
		cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);
		deg[x]++;
		deg[y]++;
	}
	queue<int> que;
	for(int i=2;i<=n;i++){
		if(deg[i]==1){
			que.push(i);
			grundy[i] = 0;
		}
	}
	while(!que.empty()){
		int id = que.front(); que.pop();
		for(int i=0;i<adj[id].size();i++){
			if(deg[adj[id][i]]>1 || adj[id][i]==1){
				int id2 = adj[id][i];
				grundy[id2] = grundy[id2]^(grundy[id]+1);
				deg[id2]--;
				if(deg[id2]==1 && id2!=1)que.push(id2);
			}
		}
	}
	if(grundy[1]==0){
		cout<<"Bob"<<endl;
	}
	else{
		cout<<"Alice"<<endl;
	}
	/* for(int i=1;i<=n;i++){
		cout<<i<<" "<<grundy[i]<<endl;
	}*/
	return 0;
}

Measured memory_bytes: 8704
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

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

    void run() {

        long n = sc.nextLong();
        long k = sc.nextLong();

        long tmp = n%k;
        long ans = Math.min(tmp, Math.abs(k-tmp));

        System.out.println(ans);
    }

}


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

int main() {
  int N; cin>>N;
  int ans=0;
  rep_eq(i,1,N) ans+=i;
  cout <<ans <<endl;
  return 0;
}


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

int main(){
long long n;cin>>n;
if(n%2){
    cout<<0;return 0;
}
long long sum=n/10;
n/=10;
while(n){
    sum+=n/5;
    n/=5;
}
cout<<sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
int uni[100010];
void init(int n) {
    rep(i, n) uni[i] = -1;
}
int root(int a) {
    if(uni[a] < 0) return a;
    return uni[a] = root(uni[a]);
}
bool connect(int a, int b) {
    a = root(a);
    b = root(b);
    if(a == b) return false;
    if(uni[a] > uni[b]) {
        swap(a, b);
    }
    uni[a] = uni[a] + uni[b];
    uni[b] = a;
    return true;
}
bool same(int x, int y) {
    return root(x) == root(y);
}
signed main(void) {
    int N, Q;
    cin >> N >> Q;
    init(N);
    rep(i, Q) {
        int a, b, c;
        cin >> a >> b >> c;
        if(a == 0)
            connect(b, c);
        else
            cout << same(b, c) << endl;
    }
}



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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()


void solve(long long N, long long M, std::vector<long long> x, std::vector<long long> y){
    vector<bool> flag(N, false);
    vector<i64> cnt(N, 1);
    flag[0] = true;
    rep(i, M){
        x[i]--; y[i]--;
        if(flag[x[i]]) flag[y[i]] = true;
        if(cnt[x[i]] == 1) flag[x[i]] = false;
        cnt[x[i]]--;
        cnt[y[i]]++;
    }
    i64 ans = 0;
    rep(i, N) if(flag[i]) ++ans;
    cout << ans << endl;
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> x(M);
    std::vector<long long> y(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    solve(N, M, std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 2688
#include<iostream>
#include<queue>
#include<limits>
// #include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<cmath>
#include<math.h>
#include<iomanip>  
#include<deque> 
#include<stack>
#include<string> 
#include<string.h>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#define ll long long
#define tc(t)  while(t--)
#define V vector
#define Vp vector< pair<int,int> >
#define pb push_back
#define UM unordered_map
#define IT iterator
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define PQ priority_queue
#define _FI ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

 char ar[140000];
vector<ll> SieveOfEratosthenes(ll n) 
{ 
  vector<ll> result;
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
    int count=1;
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        {  
            for (ll i=p*p; i<=n; i += p) 
                {
                  prime[i] = false; 
                }
            count++;
        } 
    } 
  
    for (ll p=2; p<=n; p++) 
       if (prime[p]) 
          {
            result.push_back(p);
          }
    return result;
}



vector<ll> Divisors (ll n)
{
  vector<ll> res;
  for(ll i=1;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
      if(n/i==i)
      {
        res.pb(i);
      }
      else
      {
        res.pb(i);
        res.pb(n/i);
      }
    }
  }

  return res;
}

ll Div(ll n)
{
  for(ll i=2;i<=sqrt(n);i++)
  {
    if(n%i==0)
      return i;
  }
  return n;
}

int a[4][2]={ {1,0}, {1,-1}, {1,1}, {2,0} } ;
bool validPoint(int x,int y, int N)
{
    return (x>=0 && x<N && y>=0 && y<N);
}

 
int main()
{
  _FI 

  ll n;
  cin>>n;
  ll k;
  cin>>k;
  V<ll> arr(n);
  forn(i,n)
      cin>>arr[i];
  
  V<double> v;
  for(int i=0;i<n;i++)
  {
    double x= (1.0+1.0*arr[i])/2;
    v.pb(x);
  }
  forn(i,n)
    cerr<<v[i]<<" ";
  double sum=0;
  double maxSum=0;
  for(int i=0;i<k;i++)
  {
    sum+=v[i];
  }
  maxSum=max(sum,maxSum);

  for(int i=k;i<n;i++)
  {
    sum=sum+v[i]-v[i-k];
    maxSum=max(sum,maxSum);
  }

  cout<<fixed<<setprecision(10)<<maxSum<<endl;

  return 0;
}















Measured memory_bytes: 6416
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int w, a, b; cin >> w >> a >> b;
    int s = a, t = a + w;
    if(b + w < s) cout << s - (b+w) << endl;
    else if(b > t) cout << b - t << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

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

q1=[]
q2=[]

for i in range(n):
  q1.append(i+a[i])
  q2.append(i-a[i])

c2=Counter(q2)

ans=0
for i in q1:
  ans+=c2[i]

print(ans)

Measured memory_bytes: 50592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+100;
typedef long long ll;

ll a[maxn];
ll f[maxn];

int main()
{
    int N;
    cin>>N;
    a[0]=0;
    for(int i=1;i<=N;i++){
        cin>>a[i];
        a[i]+=a[i-1];
    }
    ll ans=0;
    sort(a,a+N+1);
    ll u=1;
    for(int i=1;i<=N;i++){
        if(a[i]==a[i-1]) u++;
        else{
            ans+=(u*(u-1))/2;
            u=1;
        }
    }
    ans+=(u*(u-1))/2;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

x, n, *p = map(int, read().split())

min_d = 1000000

if n == 0:
    print(x)
    exit()

for i in range(110):
    if i in p:
        continue
    d = abs(x - i)
    if d < min_d:
        min_d = d
        ans = i

print(ans)


Measured memory_bytes: 9116
import java.util.*;
class Main {
	public static void main(String...args) {
		Scanner scan = new Scanner(System.in);
		int times = scan.nextInt();
	    int minValue = scan.nextInt();
		int nowValue = scan.nextInt();
		int dif = nowValue - minValue;
		minValue = Math.min(nowValue,minValue);
		
		for(int i =0; i < times -2; i ++) {
			nowValue = scan.nextInt();
			dif = Math.max(nowValue - minValue , dif);
			minValue = Math.min(nowValue,minValue);
		}
		System.out.println(dif);
	}
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {
    li n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    li aa = 0, bb = 0;
    rep(i, n) {
        if (s[i] == 'a') {
            if (a + b > aa + bb) {
                aa++;
                puts("Yes");
            } else {
                puts("No");
            }
        } else if (s[i] == 'b') {
            if (a + b > aa + bb && b > bb) {
                puts("Yes");
                bb++;
            } else {
                puts("No");
            }
        } else {
            puts("No");
        }
    }

    return 0;
}

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


#define int  long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define pf push_front
#define eb emplace_back //FASTER THAN PUSH BACK!
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define mi multiset<int>
#define mii multiset<pii>
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

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

int modp(int a,int n)
{
    if(n==0) return 1;
    if(n==1) return a%mod;
    int res=modp(a,n/2);
    if(n%2==0) return (res*res)%mod;
    else return (a*res*res)%mod;
}

// vi adj[100005];
// vector<bool> vis(100005,false);


// void dfs(int s)
// {
//     vis[s]=true;
    
//     for(int u:adj[s])
//     {
//         if(!vis[u])
//         {
//             vis[u]=true;
//             dfs(u);
//         }
//     }
// }

void solve()
{
    int t,n,m,i,k,l,r,u,v,w,j,s,sum=0,pos=-5,flag=0,count=0;
    string S,T,U;
    
    cin>>n>>m;
    vi a(m);
    rep(i,0,m)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(n-sum>=0)cout<<n-sum;
    else cout<<"-1";
}




signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3692
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-10;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

bool equal(double lhs, double rhs){
  return (lhs - EPS <= rhs && rhs - EPS <= lhs);
}

int main(){
  double R;
  while(~scanf("%lf",&R)){
    if(equal(R,0.0)) break;
    for(int denominator = 1; denominator <= 10000000; denominator++){
      int upper = 10000000;
      int lower = 0;
      for(int round = 0; round < 30; round++){
        int mid = lower + (upper - lower)/2;
        if((double)mid/(double)denominator >= M_PI - R){
          upper = mid;
        }
        else{
          lower = mid;
        }
      }

      for(int numerator = upper; numerator <= 10000000; numerator++){
        if((double)numerator/(double)denominator > M_PI + R) break;
        printf("%d/%d\n",numerator,denominator);
        goto found;
      }
    }
  found:;
  }
}

Measured memory_bytes: 1204
#include<iostream>
#include <stdio.h>
using namespace std;
int main(){
    int a,b,d,r;
    double f;
    
    cin >> a >> b;
    
    d = a / b;
    r = a % b;
    f = 1.0000*a / b;
    
    printf("%d %d %f", d, r, f);
    
    return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const ll Mod = 1e9 + 7;
const ll N = 3030;

char Cmp[N];
ll Dp[N][N];

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

    scanf("%s",Cmp+2);

    Dp[1][1] = 1;

    for(ll i = 2; i <= n; i++)
    {
        for(ll b = 1; b <= n; b++)
        {
            ll L , R;

            if( Cmp[i] == '<' ) L = 1 , R = b-1;
            else                L = b, R = i-1;

            if( L <= R )    Dp[i][b] = ( Dp[i][b] + Dp[i-1][R] - Dp[i-1][L-1] + Mod )%Mod;
        }

        for(ll b=1;b<=i;b++)
            Dp[i][b] = ( Dp[i][b] + Dp[i][b-1] )%Mod;
    }

    cout<<Dp[n][n];
}


Measured memory_bytes: 71936
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;

#define MAX 1000000

int main(){
  int t;
  cin>>t;
  for(int w=0; w<t; w++){
    int n,k;
    cin>>n>>k;
    int houses[MAX];
    
    for(int i=0; i<=n; i++) houses[i]=0;
    int hajime=0,owari=0,kyori;
    int hen[n+1];
    for(int i=0; i<=n; i++) hen[i]=0;
    for(int i=0; i<n; i++){
      int where;
      cin>>where;
      houses[i]=where;
      if(i) hen[i-1]=houses[i]-houses[i-1];
      if(!i) hajime=where;
      if(i==n-1) owari=where;
    }
    if(n<=k){
      cout<<0<<en
      continue;
    }
    
    kyori=owari-hajime;
    sort(hen, hen+n-1,greater<int>());
    for(int i=0; i<k-1; i++){
      kyori-=hen[i];
    }
    cout<<kyori<<en
  }
  RE
}


Measured memory_bytes: 3896
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, A; cin >> N >> A;
  ll x = N % 500;
  if (x <= A) {
    cout << "Yes\n";
  }else {
    cout << "No\n";
  }

  return 0;
}



Measured memory_bytes: 256