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

Solution (Python):
n = int(input())
length = int(n / 19) + 1
if n > 19 and n % 19 == 0:
    length -= 1
d = []
for i in range(length):
    d += list(map(int, input().split()))
start, end = 1, 10
l = []
flag = False
for j in range(1, len(d)+1):
    for i in range(0, len(d)):
        tmp = ''.join(map(str, d[i:i+j]))
        if len(tmp) > 1 and tmp[0] == '0':
            pass
        elif len(tmp) == j:
            l.append(int(tmp))
    l = sorted(set(l))
    if start == 1:
        for k in range(0, 10):
            if k not in l:
                print(k)
                flag = True
                break
    else:
        for k in range(start, end):
            if k not in l:
                print(k)
                flag = True
                break
    if flag:
        break
    start, end = start*10, end*10
    l = []

Solution (Python):
n=int(input())
d=''.join([''.join(input().split())for i in range(n//19+(n%19!=0))])
i=0
while True:
 if d.find(str(i))==-1:
  print(i)
  exit() 
 i+=1

Solution (Python):
n=int(input())
d=''.join(''.join(input().split())for i in[0]*(n//19+(n%19!=0)))
i=0
while 1:
 if d.find(str(i))==-1:
  print(i)
  exit() 
 i+=1

Solution (Python):
j=''.join
n=int(input())
d=j(j(input().split())for i in[0]*(n//19+(n%19!=0)))
i=0
while 1:
 if d.find(str(i))==-1:
  print(i)
  exit() 
 i+=1

Solution (Python):
j=''.join
n=int(input())
d=j(j(input().split())for i in[0]*(n//19+(n%19!=0)))
i=0
while 1:
 if d.find(str(i))<0:
  print(i)
  exit() 
 i+=1

Solution (Python):
j=''.join
u=input
n=int(u())
d=j(j(u().split())for i in[0]*(n//19+(n%19!=0)))
i=0
while 1:
 if d.find(str(i))<0:
  print(i)
  exit() 
 i+=1

Solution (Python):
j=''.join
u=input
n=int(u())
d=j(j(u().split())for i in[0]*(n//19+(n%19>0)))
i=0
while 1:
 if d.find(str(i))<0:
  print(i)
  exit() 
 i+=1

Solution (Python):
N = int(input())
src = ''
while len(src) < N:
    src += ''.join(input().split())
n = 0
while True:
    if str(n) not in src:
        print(n)
        break
    n += 1

Solution (Python):
n = int(input())
d = list()
while len(d) < n:
    d.extend(list(map(int, input().split())))

appear = set()
for i in range(n):
    for j in range(0, min(3, n - i)):
        appear.add(int("".join(map(str, d[i:i + j + 1]))))

for i in range(1000):
    if not i in appear:
        print(i)
        break

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n = I()
        a = []
        while len(a) < n:
            a += LS()
        s = set()
        for i in range(n):
            s.add(int(a[i]))
            for j in range(i+1,min(i+2,n)):
                s.add(int(a[i]+a[j]))
                for k in range(j+1,min(j+2,n)):
                    s.add(int(a[i]+a[j]+a[k]))
        r = -1
        for i in range(1000):
            if not i in s:
                r = i
                break
        rr.append(r)
        break

    return '\n'.join(map(str, rr))


print(main())

Solution (Python):
n,*d=open(0).read().split()
n=int(n)
s=set()
for i in range(n):
    for j in range(i+1,n+1):
        s|={int(''.join(d[i:j]))}
for i,j in enumerate(sorted(s)):
    if i!=j:
        print(i)
        break

Solution (Python):
n, *d = map(int, open(0).read().split())
d = ''.join(map(str, d))
se = set()
for i in range(n):
    for j in range(i + 1, n + 1):
        se.add(int(d[i:j]))
ans = 0
while ans in se:
    ans += 1
print(ans)

Solution (Python):
import sys
def main():
    n = int(input())
    d = ""
    while len(d) != n:
        d += "".join(input().split())
    digits = set()
    for i in range(n):
        for j in range(i+1,n+1):
            
            seq = d[i:j]
            if not seq:
                continue
            digits.add(int(seq))
    digits = sorted(list(digits))
    for i in range(digits[-1]+1):
        if i != digits[i]:
            print(i)
            return
            

if __name__ == '__main__':
    main()

Solution (Python):
import sys
input()
a = []
for line in sys.stdin:
    a.extend([x for x in line.split()])
a = "".join(a)
for i in range(int(a)):
    if str(i) not in a:
        print(i)
        break

Solution (Python):
n = int(input())
d = []
while len(d) < n: d += input().split()
d = ''.join(d)

for i in range(1000000):
    if str(i) not in d:
        print(i)
        break

Solution (Python):
def toNum(lis):
  ret = 0
  for i in range(len(lis)):
    ret += lis[-i - 1] * 10**i
  
  return ret
  

def solve(list,n):
  c = 0
  i = 0
  digit = 1
  while i + digit <= n:
    if toNum(a[i:i+digit]) == c:
      c += 1
      digit = len(str(c))
      i = 0
      continue
    else:i += 1
  return c


n = int(input())
a = []
while len(a) < n:
  a += [int(i) for i in input().split()]

print(solve(a,n))