Problem:
Problem A
Decimal Sequences
Hanako learned the conjecture that all the non-negative integers appear in the infinite digit sequence of the decimal representation of $\pi$ = 3.14159265..., the ratio of a circle's circumference to its diameter. After that, whenever she watches a sequence of digits, she tries to count up non-negative integers whose decimal representations appear as its subsequences.
For example, given a sequence "
3 0 1
", she finds representations of five non-negative integers 3, 0, 1, 30 and 301 that appear as its subsequences.
Your job is to write a program that, given a finite sequence of digits, outputs the smallest non-negative integer not appearing in the sequence. In the above example, 0 and 1 appear, but 2 does not. So, 2 should be the answer.
Input
The input consists of a single test case.
$n$
$d_1$ $d_2$ ... $d_n$
$n$ is a positive integer that indicates the number of digits. Each of $d_k$'s $(k = 1, ... ,  n)$ is a digit. There is a space or a newline between $d_k$ and $d_{k+1}$ $(k = 1, ..., n - 1)$.
You can assume that $1 \leq n \leq 1000$.
Output
Print the smallest non-negative integer not appearing in the sequence.
Sample Input 1
3
3 0 1
Sample Output 1
2
Sample Input 2
11
9 8 7 6 5 4 3 2 1 1 0
Sample Output 2
12
Sample Input 3
10
9 0 8 7 6 5 4 3 2 1
Sample Output 3
10
Sample Input 4
100
3 6 7 5 3 5 6 2 9 1 2 7 0 9 3 6 0 6 2
6 1 8 7 9 2 0 2 3 7 5 9 2 2 8 9 7 3 6
1 2 9 3 1 9 4 7 8 4 5 0 3 6 1 0 6 3 2
0 6 1 5 5 4 7 6 5 6 9 3 7 4 5 2 5 4 7
4 4 3 0 7 8 6 8 8 4 3 1 4 9 2 0 6 8 9
2 6 6 4 9
Sample Output 4
11
Sample Input 5
100
7 2 7 5 4 7 4 4 5 8 1 5 7 7 0 5 6 2 0
4 3 4 1 1 0 6 1 6 6 2 1 7 9 2 4 6 9 3
6 2 8 0 5 9 7 6 3 1 4 9 1 9 1 2 6 4 2
9 7 8 3 9 5 5 2 3 3 8 4 0 6 8 2 5 5 0
6 7 1 8 5 1 4 8 1 3 7 3 3 5 3 0 6 0 6
5 3 2 2 2
Sample Output 5
86
Sample Input 6
1
3
Sample Output 6
0

Submitted solutions:

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using a2 = array<ll, 2>;
using a3 = array<ll, 3>;

bool chmin(auto& a, const auto& b) { return a > b ? a = b, 1 : 0; }
bool chmax(auto& a, const auto& b) { return a < b ? a = b, 1 : 0; }

ll mod = 998244353;

ifstream in;
ofstream out;

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

    if(argc > 2) {
        in.open(argv[1]);
        cin.rdbuf(in.rdbuf());
        out.open(argv[2]);
        cout.rdbuf(out.rdbuf());
    }

    ll n;
    cin >> n;
    vector<ll> v(n);
    for(auto& x : v) cin >> x;

    set<ll> sh;
    for(int i = 0; i < 2 * n * n; i++) sh.insert(i);

    for(int i = 0; i < n; i++) {
        string s;
        for(int j = i; j < i + 10 && j < n; j++) {
            s.push_back('0' + v[j]);
            sh.erase(stoll(s));
        }
    }
    cout << *sh.begin() << endl;

    return 0;
}
accuracy: 1
time_ms: 540
memory_kb: 97216
final_rank: 7

code_snippet: #include<bits/stdc++.h>

using namespace std;

inline int get_int() {
    int res, c, t = 1;
    while(!isdigit(c = getchar())) if(c == '-') t = -1;
    for(res = c - '0'; isdigit(c = getchar()); )
        res = res * 10 + c - '0';
    return res * t;
}

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

typedef long long LL;
typedef pair<int, int> pii;
typedef long double ld;
typedef unsigned int uint;

const int INF = 0x3f3f3f3f;
const double EPS = 1e-7;
const double PI = acos(-1);

const int MAXN = 1000;

int n, A[MAXN + 10];
set<string> S;

int main() {

    n = get_int();
    for(int i = 1; i <= n; i++) A[i] = get_int();

    for(int i = 1; i <= n; i++) {
        string str;
        for(int j = i; j <= n; j++) {
            str.push_back('0'+A[j]);
            S.insert(str);
        }
    }
    for(int i = 0; ; i++) {
        static char buf[100];
        sprintf(buf, "%d", i);
        if(S.find(string(buf)) == S.end()) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}
accuracy: 1
time_ms: 180
memory_kb: 213452
final_rank: 6

code_snippet: #include <cstdio>
#include <cstring>
#include <cmath>

#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <set>
#include <map>

using namespace::std;

#define ls t<<1
#define rs (t<<1)|1
#define sqr(x) ((x)*(x))


const int inf = 0x3f3f3f3f;
const double eps = 1e-6;
const int maxn = 1e3 + 10;
const int maxm = 1e4 + 10;
const int mod = 1e9 + 7;
int n, a[maxn];
map<int, int> vis;

int main()
{
	while (~scanf("%d", &n))
	{
		vis.clear();
		memset(a, 0, sizeof(a));
		for (int i = 0; i < n; i++)
		{
			scanf("%d", &a[i]);
			for (int k = 1; k <= i + 1; k++)
			{
				int ans = 0;
				for (int j = i - k + 1; j <= i; j++)
				{
					ans *= 10; ans += a[j];
				}
				vis[ans] = 1;
			}
		}
		for (int i = 0; i <= 10000; i++)
			if (!vis[i])
			{
				printf("%d\n", i); break;
			}
	}
}
accuracy: 0.92
time_ms: 80
memory_kb: 4784
final_rank: 20

code_snippet: #include <bits/stdc++.h>

int main() {
    int n; std::cin >> n;
    std::vector<int> a(n);
    for (auto& x : a) std::cin >> x;
    std::unordered_set<std::string> set;
    for (int i{} ; i < n ; i++) {
        std::string s;
        for (int j{i} ; j < n ; j++) {
            s += a[j] + '0';
            set.insert(s);
        }
    }
    int ans{};
    while (set.count(std::to_string(ans))) ans++;
    std::cout << ans << '\n';
}
accuracy: 1
time_ms: 280
memory_kb: 212316
final_rank: 8

code_snippet: #include <bits/stdc++.h>

using namespace std;

using ll = long long;
#define rep(i,s,f) for (ll i = (s);i < (ll)(f);i++)
set<string>st;
bool finish=false;
void solve(int num,string s){
    if(num==0){
        if (s=="")s="0";
        if(st.find(s)==st.end()){
            cout<<s<<endl;
            finish=true;
        }
        return;
    }
    for(int i=0;i<10;i++){
        if(s==""&&i==0){
            solve(num-1,"");
        }else{
            string tmp_s=s;
            tmp_s+=(char)(i+'0');
            solve(num-1,tmp_s);
        }
        if(finish)return;
    }
    return;
}
int main(){
    int N;
    cin >>N;
    vector<char>vec(N);
    for(int i=0;i<N;i++){
        cin>>vec[i];
    }

    
    for(int i=0;i<N;i++){
        string tmp ="";
        for(int j=i;j<N;j++){
            if(tmp==""&&vec[j]=='0'){
                st.insert("0");
            }else{
                tmp +=vec[j];
                st.insert(tmp);
            }

        }
    }
    solve(N,"");
    return 0;
}
accuracy: 1
time_ms: 180
memory_kb: 198288
final_rank: 5

code_snippet: #include<bits/stdc++.h>

using namespace std;

using ll=long long;

int main(){
    int n;cin>>n;
    vector<int>d(n);
    for(auto &i:d){
        cin>>i;
    }
    map<ll,ll>mp;
    for(int l=0;l<n;l++){
        ll now=0;
        for(int r=l;r<n;r++){
            now*=10;
            now+=d[r];
//            cout<<"l: "<<l<<" r: "<<r<<" now: "<<now<<endl;
            mp[now]=1;
        }
    }
    ll ans=0;
    while(mp[ans])ans++;
    cout<<ans<<endl;
}
accuracy: 0.9466666666666667
time_ms: 40
memory_kb: 6828
final_rank: 15

code_snippet: #include<bits/stdc++.h>
using namespace std;
map<long long,long long>mp;
long long  a[100001];
long long sum[100001]={0};
int main()
{
    long long n,m;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        mp[a[i]]++;
        for(int j=1;j<=i;j++)
        {
            sum[j]=sum[j]*10+a[i];
            mp[sum[j]]++;
        }
    }
    for(long long i=0;i<=1000000000;i++)
    {
        if(mp[i]==0)
        {
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}
accuracy: 0.9466666666666667
time_ms: 10
memory_kb: 6508
final_rank: 10

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define rep3(i, a, b) for (ll i = (a); i > (b); --i)
#define rep(i, n) for (ll i = 0; i < n; ++i)

const int INF = 1e9;
#define INF64 102030405060708090
const long long MOD = 1000000007;
const long long MOD2 = 998244353;

using P = pair<long long, int>;

class UnionFind
{
    int n;
    vector<int> par;
    vector<int> ranks;
    vector<int> sizes;

public:
    UnionFind(int m)
    {
        n = m;
        for (int i = 0; i < n; i++)
        {
            par.emplace_back(i);
            ranks.emplace_back(0);
            sizes.emplace_back(1);
        }
    }

    int find(int x)
    {
        if (par[x] == x)
            return x;
        else
            return par[x] = find(par[x]);
    }

    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (ranks[x] < ranks[y])
        {
            par[x] = y;
            sizes[y] += sizes[x];
        }
        else
        {
            par[y] = x;
            sizes[x] += sizes[y];
            if (ranks[x] == ranks[y])
                ranks[x]++;
        }
    }

    int sizing(int x)
    {
        return sizes[find(x)];
    }

    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
};


int main()
{
    int n;
    cin>>n;
    vector<int> d(n);
    rep(i,n)cin>>d[i];

    set<int> x;
    rep(i,100000) x.insert(i);

    rep(i,n){
        rep(j,5){
            if (i+j<n){
                int num = 0;
                rep(x,j+1){
                    num = num*10+d[i+x];
                }
                x.erase(num);
            }
        }
    }
    cout<<*x.begin()<<endl;
}
accuracy: 1
time_ms: 10
memory_kb: 8132
final_rank: 1

code_snippet: #include<cstdio>
#include<set>
using namespace std;

int n, d[1000];

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &d[i]);
  set<int> st;
  for (int i = 0; i < n; i++) {
    int now = 0;
    for (int j = i; j < min(j+9, n); j++) {
      now = now * 10 + d[j];
      st.insert(now);
    }
  }
  for (int i = 0;; i++) if (st.count(i) == 0) {
    printf("%d\n", i);
    break;
  }
}
accuracy: 0.92
time_ms: 30
memory_kb: 4016
final_rank: 18

code_snippet: #include<cstdio>
#include<set>
using namespace std;

int n, d[1000];

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &d[i]);
  set<int> st;
  for (int i = 0; i < n; i++) {
    int now = 0;
    for (int j = i; j < min(j+7, n); j++) {
      now = now * 10 + d[j];
      st.insert(now);
    }
  }
  for (int i = 0;; i++) if (st.count(i) == 0) {
    printf("%d\n", i);
    break;
  }
}
accuracy: 0.92
time_ms: 30
memory_kb: 3972
final_rank: 16

code_snippet: #include<cstdio>
#include<set>
using namespace std;

int n, d[1000];

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &d[i]);
  set<int> st;
  for (int i = 0; i < n; i++) {
    int now = 0;
    for (int j = i; j < min(j+4, n); j++) {
      now = now * 10 + d[j];
      st.insert(now);
    }
  }
  for (int i = 0;; i++) if (st.count(i) == 0) {
    printf("%d\n", i);
    break;
  }
}
accuracy: 0.92
time_ms: 30
memory_kb: 3980
final_rank: 17

code_snippet: #include<bits/stdc++.h> 
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int i = 0; i < N; i++)

int main(){
    int N;
    cin >> N;
    set<string> itg;
    string sub = "";

    for(int i = 0;i < N; i++){
        char d; cin >> d;
        sub  += d;
    }

    for(int i = 0; i < N; i++){
        for(int k = 1; k+i <= N; k++){
            string I = sub.substr(i, k);
            if(I[0] == '0' && I.size() > 1) continue;
            itg.emplace(I);
        }
    }

    string ans = "";
    for(int i = 0; (i <= itg.size()+1 && ans == ""); i++){
        string I = to_string(i);
        if(itg.count(I) == 0) ans = I;
    }

    cout << ans << endl;
}
accuracy: 1
time_ms: 180
memory_kb: 198276
final_rank: 4

code_snippet: #include<bits/stdc++.h>
using namespace std;
#define N (1000000000+7)
//#define N (998244353)
#define INF 1e16
typedef long long ll;

ll gcd(ll a, ll b) {
    if(a==0){
        return b;
    }
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}



int main(void){
    int n;
    cin>>n;
    vector<char>d(n);
    for(int i=0;i<n;i++)cin>>d[i];
    set<string>s;
    vector<string>t;
    for(int i=0;i<n;i++){
        string u;
        if(d[i]=='0'){
            s.insert("0");
            continue;
        }
        for(int j=i;j<n;j++){
            u.push_back(d[j]);
            s.insert(u);
        }
    }
    for(int i=0;i<=1000;i++){
        string u;
        int x = i;
        while(x>=10){
            int r = x%10;
            u.push_back(r+'0');
            x = x/10;
        }
        u.push_back(x+'0');
        //cout<<u<<endl;
        reverse(u.begin(),u.end());
        t.push_back(u);
    }
    for(auto x:t){
        if(s.count(x)==0){
            cout<<x<<endl;
            return 0;
        }
    }
}
accuracy: 1
time_ms: 170
memory_kb: 198160
final_rank: 3

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

#define int long long

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif

#define MAX_N (1000006)
#define INF (1LL << 60)
const int MOD = (int)1e9 + 7;


signed main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i=0; i<n; i++) cin >> d[i];
    for(int i=0; i<1001; i++){
        int m = to_string(i).length();
        bool f=true;
        for(int j=0; j<n-m+1; j++){
            string t;
            for(int k=0; k<m; k++){
                t.push_back(d[j+k]+'0');
            }
            int v = atoi(t.c_str());
            debug(i,j,v);
            if(v==i) f=false;
        }
        if(f){
            cout << i << endl;
            return 0;
        }
    }
}

/*

*/
accuracy: 1
time_ms: 50
memory_kb: 3300
final_rank: 2

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

#define int long long

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif

#define MAX_N (1000006)
#define INF (1LL << 60)
const int MOD = (int)1e9 + 7;


signed main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i=0; i<n; i++) cin >> d[i];
    set<int> st;
    for(int i=0; i<n; i++){
        int v = 0;
        for(int j=i; j<n; j++){
            v += d[j];
            debug(i,j,d[j],v);
            st.insert(v);
            v *= 10;
        }
    }
    for(int i=0; i<=1000000; i++){
        if(st.find(i) == st.end()){
            cout << i << endl;
            return 0;
        }
    }
}

/*

*/
accuracy: 0.9466666666666667
time_ms: 40
memory_kb: 5656
final_rank: 11

code_snippet: #include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<ll> d(N);
    rep(i,N){
        cin >> d[i];
    }
    set<ll> se;
    for(int i=0; i<N; i++){
        ll sum = 0;
        for(int j=i; j<min(N,j+13); j++){
            sum *= 10;
            sum += d[j];
            se.insert(sum);
        }
    }
    for(ll i=0; i<=100'000'000; i++){
        if(!se.count(i)){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}
accuracy: 0.9466666666666667
time_ms: 40
memory_kb: 5736
final_rank: 13

code_snippet: #include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<ll> d(N);
    rep(i,N){
        cin >> d[i];
    }
    set<ll> se;
    for(int i=0; i<N; i++){
        ll sum = 0;
        for(int j=i; j<min(N,j+9); j++){
            sum *= 10;
            sum += d[j];
            se.insert(sum);
        }
    }
    for(ll i=0; i<=10'000'000; i++){
        if(!se.count(i)){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}
accuracy: 0.9466666666666667
time_ms: 40
memory_kb: 5784
final_rank: 14

code_snippet: #include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i,N){
        cin >> d[i];
    }
    set<ll> se;
    for(int i=0; i<N; i++){
        ll sum = 0;
        for(int j=i; j<min(N,j+8); j++){
            sum *= 10;
            sum += d[j];
            se.insert(sum);
        }
    }
    for(ll i=0; i<=1'000'000; i++){
        if(!se.count(i)){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}
accuracy: 0.9466666666666667
time_ms: 40
memory_kb: 5716
final_rank: 12

code_snippet: #include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i,N){
        cin >> d[i];
    }
    set<int> se;
    for(int i=0; i<N; i++){
        ll sum = 0;
        for(int j=i; j<min(N,j+8); j++){
            sum *= 10;
            sum += d[j];
            se.insert(sum);
        }
    }
    for(int i=0; i<=1'000'000; i++){
        if(!se.count(i)){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}
accuracy: 0.92
time_ms: 30
memory_kb: 4400
final_rank: 19

code_snippet: #include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int main() {
  int n;
  cin >> n;
  string d(n, '\0');
  REP(i, n) cin >> d[i];
  map<string, bool> mp;
  REP(i, n) {
    FOR(j, i + 1, n + 1) {
      auto s = d.substr(i, j - i);
      mp[s] = true;
    }
  }
  REP(i, 1e7) {
    if (mp[to_string(i)]) continue;
    cout << i << endl;
    return 0;
  }
}
accuracy: 1
time_ms: 280
memory_kb: 217384
final_rank: 9