Harryxun/stf_run huggingface dataset:
H, W = map(int, input().split())
S = ""
for i in range(H):
    S += input()

light = [0] * (H*W)
for h in range(H):
    cnt = 0
    pre = "@"
    info = []
    for i in range(h*W, (h+1)*W):
        if S[i] == pre:
            cnt += 1
            if i == (h+1)*W-1:
                if S[i] == ".":
                    info.append(cnt)
                else:
                    info.append(-cnt)
        else:
            if pre == ".":
                info.append(cnt)
                cnt = 1
            elif pre == "#":
                info.append(-cnt)
                cnt = 1
    cnt = h*W
    while len(info) > 0:
        LD = info.pop(0)
        if LD > 0: 
            for i in range(LD):
                light[cnt + i] += LD
            cnt += LD
        else:
            for i in range(-LD):
                light[cnt + i] = 0
            cnt += -LD

for w in range(W):
    cnt = 0
    pre = "@"
    info = []
    for i in range(H):
        if S[w + i * H] == pre:
            cnt += 1
            if i == H-1:
                if S[w + i * H] == ".":
                    info.append(cnt)
                else:
                    info.append(-cnt)
        else:
            if pre == ".":
                info.append(cnt)
                cnt = 1
            elif pre == "#":
                info.append(-cnt)
                cnt = 1
    cnt = w
    while len(info) > 0:
        LD = info.pop(0)
        if LD > 0: 
            for i in range(LD):
                light[w + i * H] += LD
            cnt += LD * H
        else:
            for i in range(-LD):
                light[i] = 0
            cnt += -LD * H
print(max(light)-1)

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline

    H, W = map(int, input().split())
    grid = []
    for _ in range(H):
        grid.append(input().rstrip('\n'))

    L = [[0] * W for _ in range(H)]
    R = [[0] * W for _ in range(H)]
    U = [[0] * W for _ in range(H)]
    D = [[0] * W for _ in range(H)]
    for h in range(H):
        for w in range(1, W):
            if grid[h][w-1] == '.' and grid[h][w] == '.':
                L[h][w] = L[h][w-1] + 1
    for h in range(H):
        for w in range(W-2, -1, -1):
            if grid[h][w] == '.' and grid[h][w+1] == '.':
                R[h][w] = R[h][w+1] + 1
    for w in range(W):
        for h in range(1, H):
            if grid[h][w] == '.' and grid[h-1][w] == '.':
                U[h][w] = U[h-1][w] + 1
    for w in range(W):
        for h in range(H-2, -1, -1):
            if grid[h][w] == '.' and grid[h+1][w] == '.':
                D[h][w] = D[h+1][w] + 1

    ans = 1
    for h in range(H):
        for w in range(W):
            ans = max(ans, L[h][w] + R[h][w] + U[h][w] + D[h][w] + 1)
    print(ans)


if __name__ == '__main__':
    main()
K, S = map(int, input().split())
ans = 0
for x in range(K+1):
  for y in range(K+1):
    z = k - x - y
    if 0 <= z <= K:
      ans += 1
print(ans)

### FIXED CODE ###

K, S = map(int, input().split())
ans = 0
for x in range(K+1):
  for y in range(K+1):
    z = S - x - y
    if 0 <= z <= K:
      ans += 1
print(ans)
import sys
a,b=map(int,input().split())
if b=1:
  print("0")
  sus.exit()
p=1
ans=0
for i in range(0,20):
  p+=a-1
  ans+=1
  if p>=b:
    print(ans)
    sys.exit()

### FIXED CODE ###

import sys
a,b=map(int,input().split())
if b==1:
  print("0")
  sys.exit()
p=1
ans=0
for i in range(0,20):
  p+=a-1
  ans+=1
  if p>=b:
    print(ans)
    sys.exit()
def lcm(a,b):
    c=2
    return a/c*b

n=int(input())
t=[0]*n

for lop2 in range(n):
    t[lop2]=int(input())

ans=t[0]

for lop in range(1,n):
    ans=lcm(ans,t[lop])
print(int(ans))

### FIXED CODE ###

'''
def gcd(a,b):
    if a<b:
     c=a
     a=b
     b=c

    c=a%b

    if c==0:
     return b
    else:
     return gcd(b,c)
'''

def gcd(a,b):
    return a if b == 0 else gcd(b,a%b)

def lcm(e,f):
    c=gcd(e,f)
    g=e*f
    return g//c



n=int(input())
t=[0]*n

for lop2 in range(n):
    t[lop2]=int(input())

ans=t[0]

for lop in range(1,n):
    ans=lcm(ans,t[lop])
print(int(ans))
import math
from functools import reduce

def gcd(numbers):
    return reduce(math.gcd, numbers)

N = int(input())
A = list(map(int, input().split()))

max_gcd = 1
for i in range(N):
    i_gcd =  gcd(A[:(i-1)] + A[i:])
    if max_gcd < i_gcd:
        max_gcd = i_gcd

print(max_gcd)

### FIXED CODE ###

def gcd(a, b):
    if b > a:
        a, b = b, a
    while b:
        a, b = b, a%b
    return a

def cul(n, x):
    l = len(x)
    b = x
    b.pop(n)
    tmp = b[0]
    for i in range(1, l-1):
        tmp = gcd(tmp, b[i])
    return tmp

import sys
p = 50
N = int(input())
if p>N: p=N
a = list(map(int, input().split()))

ans = 0
for i in range(p):
    s = cul(i, a[:p])
    if s>ans: ans=s

print(ans)
import math
r = int(inpu())
print(r ** 2 * math.pi, r * 2 * math.pi)


### FIXED CODE ###

import math

r = float(input())
print(float(r ** 2 * math.pi), float(r * 2 * math.pi))
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0]*n
    
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    
    def union(self, x, y):
        x = self.find[x]
        y = self.find[y]
        
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
        
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
    
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


N, M = map(int, input().split())
p = [0] + [int(_) for _ in input().split()]
pair = [[int(_) for _ in input().split()] for _ in range(M)]
uf = UnionFind(N+1)
ans = 0

for i in pair:
    uf.union(i[0], i[1])

for i in range(1, N+1):
    if uf.find(i) == uf.find(p[i]):
        ans += 1

print(ans)

### FIXED CODE ###

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0]*n
    
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
        
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
    
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


N, M = map(int, input().split())
p = [0] + [int(_) for _ in input().split()]
pair = [[int(_) for _ in input().split()] for _ in range(M)]
uf = UnionFind(N+1)
ans = 0

for i in pair:
    uf.union(i[0], i[1])

for i in range(1, N+1):
    if uf.find(i) == uf.find(p[i]):
        ans += 1

print(ans)
n = input()
for i in range(n):
  A = map(int, raw_input().split())
  j = 2000
  while 0 < j:  
    if(j + A < 2000 && f[j + 1] == 1):
      f[j + A + 1] == 1
    j- = 1

Q = input()
for i in range(Q)
  m = map(int, raw_input().split())
  if(f[m] == 1):
    print "yes"
  else:
    print "no"

### FIXED CODE ###

n = int(raw_input())
A = map(int,raw_input().split())
Q = int(raw_input())
m = map(int,raw_input().split())

def s(i, m):
  if m == 0:
    return True
  if i >= n or m > sum(A):
    return False
  r = s(i + 1, m) or s(i + 1, m - A[i])
  return r

for j in range(Q):
  if s(0, m[j]):
    print "yes"
  else:
    print "no"
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    A=list(mi()) + [0]

    dp = [[0] * (2*10**3+10) for _ in range(N+1)]
    x = 1000//A[0]
    dp[0][x] = 1000 - x * A[0]


    for i in range(x):
        dp[0][i] = 1000 - i * A[0]

    mx = x
    for i in range(N):
        _mx = mx
        for m in range(mx+1):
            for n in range(m+1):
                dp[i+1][m-n] = max(dp[i+1][m-n],dp[i][m] + A[i+1] * n)
                assert dp[i+1][m-n] >= 0
            
            if A[i+1] != 0:
                for j in range((dp[i][m] // A[i+1])+1):
                    dp[i+1][m+j] = max(dp[i+1][m+j],dp[i][m] - A[i+1] * j)
                    _mx = max(_mx,m+j)
                    
                    assert dp[i+1][m+j] >= 0

        mx = _mx

    ans = 0
    for i in range(len(dp[N-1])):
        if dp[N-1][i] == 0: continue
        ans = max(ans, dp[N-1][i] + A[N-1] * i)

    # print(dp[3][10])
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    _A=list(mi())
    A = []

    for a in _A:
        if len(A) > 0 and A[-1] == a: continue
        A.append(a)
    
    N = len(A)
    bottoms = []
    
    if N < 2:
        print(1000)
        exit()

    if A[0] < A[1]:
        bottoms.append(0)

    for i in range(N-1):
        if not i+2 < len(A): continue
        # print(A[i], A[i+1], A[i+2])
        if A[i] > A[i+1] and A[i+1] < A[i+2]:
            bottoms.append(i+1)
    
    money = 1000
    kabu = 0
    # print(bottoms)
    for bi in bottoms:
        bottom = A[bi]
        i = bi
        while i < N-1 and A[i] < A[i+1]:
            i += 1
        
        top = A[i]

        # print(bi,i)
        # print(bottom,top)
        kabu += money//bottom
        money -= money//bottom * bottom
        
        money += kabu * top
        kabu = 0
        # print("money",money)
    
    print(money)

    

if __name__ == "__main__":
    main()
x,y = map(int,input().split())
a = [4,6,9,11]
b = [1,3,5,7,8,10,12]

if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
elif x == y == 2:
    print("Yes"
else:
    print("No")



### FIXED CODE ###

x,y = map(int,input().split())

a = [4,6,9,11]
b = [1,3,5,7,8,10,12]

if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
elif x == y == 2:
    print("Yes")
else:
    print("No")
def solve(string):
    ins = string.split("\n")
    h, w = map(int, ins[0].split(" "))
    a = [list(map(int, _i.split(" "))) for _i in ins[1:]]
    move = []
    for i, _a in enumerate(a):
        for j, __a in enumerate(_a):
            if __a % 2 == 0:
                continue
            a[i][j] -= 1
            if j < w - 1:
                a[i][j + 1] += 1
                move.append("{} {} {} {}".format(i + 1, j + 1, i + 1, j + 2))
            elif i < h - 1:
                a[i + 1][j] += 1
                move.append("{} {} {} {}".format(i + 1, j + 1, i + 2, j + 1))
    return "{}\n{}".format(len(move), "\n".join(move))


if __name__ == '__main__':
    line = input()
    tmp = [line]
    for _ in range(int(line[0])):
        tmp.append(input())
    print(solve('\n'.join(tmp)))


### FIXED CODE ###

h,w = map(int,input().split())
a = []
for i in range(h):
    tmp = list(map(lambda x:int(x)%2,input().split()))
    a.append(tmp)
result = []
 
for i in range(h):
    for j in range(w-1):
        if a[i][j] == 1:
            #a[i][j] == 0
            a[i][j+1] = 1 ^ a[i][j+1]
            result.append((i+1,j+1,i+1,j+2)) 
for i in range(h-1):
    if a[i][w-1] == 1:
        a[i+1][w-1] = 1 ^ a[i+1][w-1]
        result.append((i+1,w,i+2,w))
print(len(result))
for row in result:
    print("{} {} {} {}".format(row[0],row[1],row[2],row[3]))
a, b, c = list(map(int, input().splist()))
print('{} {}'.format(min([a,b,c], max([a,b,c]))))



### FIXED CODE ###

a, b, c = list(map(int, input().split()))
print('{} {}'.format(min([a,b,c]), max([a,b,c])))
a, b, k = map(int, input().split())

for i in range(k):
    if a > 0:
        a = a - 1
    elif b > 0:
        b = b - 1

print(a, b)

### FIXED CODE ###

s, t = input().split()
print(t+s)
import math as mat
a, b, c = int(input().split())
if mat.sqrt(a) + mat.sqrt(b) < mat.sqrt(c):
  print('Yes')
else:
  print('No')

### FIXED CODE ###

import math
a,b,c = map(int,input().split())
l = 4*a*b
r = (c-a-b)**2
if (a+b >= c):
    print("No")
else:
    if(l < r):
        print("Yes")
    else:
        print("No")
X=int(input())
N=0
n=0
N=X//500
n=(X-N*500)//5
input(N*1000+5*n)

### FIXED CODE ###

X=int(input())
N=0
n=0
if X==0:
    print(0)
else:
    N=X//500
    n=(X-N*500)//5
    print(N*1000+5*n)
def main():
    N = int(input())
    P = [int(i) for i in input().split()]
    ans = 0
    for i in range(N):
        if i+1 == P[i]:
            P[i], P[i+1] = P[i+1], P[i]
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    pre = False
    for i, a in enumerate(A):
        if pre:
            pre = False
        elif i+1 == a:
            ans += 1
            pre = True
    print(ans)


if __name__ == '__main__':
    main()
for i in range(0,len(input()))
 print("x",end="")
print()

### FIXED CODE ###

for i in range(0,len(input())):
 print("x",end="")
print()
N, M = map(int, input().split())
G = [[] for i in range(N + 1)]
for i in range(M):
    l, r, d = map(int, input().split())
    G[l].append((r, d))
    G[r].append((l, -d))
used = [False] * (N + 1)
dist = [0] * (N + 1)
flag = False


def dfs(v, d0):
    global flag
    if used[v]:
        if dist[v] != d0:
            flag = True
        return
    else:
        used[v] = True
        dist[v] = d0

    for w, d1 in G[v]:
        dfs(w, d0 + d1)


for i in range(1, N + 1):
    if not used[i]:
        dfs(i, 0)

if flag:
    print("No")
else:
    print("Yes")



### FIXED CODE ###

import sys
sys.setrecursionlimit(200002)
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    l, r, q = map(int, input().split())
    G[l - 1].append((r - 1, q))
    G[r - 1].append((l - 1, -q))
X = [None] * N


def dfs(u):
    global X, G
    for w, d in G[u]:
        if X[w] is None:
            X[w] = X[u] + d
            if not dfs(w):
                return False
        else:
            if X[w] != X[u] + d:
                return False

    return True


flag = True
for i in range(N):
    if X[i] is None:
        X[i] = 0
        flag &= dfs(i)

if flag:
    print("Yes")
else:
    print("No")
abc=list(map(int,input().split()))
abc.sort()
if A ==[5, 5, 7]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

abc=list(map(int,input().split()))
abc.sort()
if abc ==[5, 5, 7]:
  print("YES")
else:
  print("NO")
#include<bits/stdc++.h>

template<uint32_t N = 10'000'000>
struct Sieve_of_Eratosthenes{
  using u32 = uint32_t;
  std::vector<u32> factor;
  Sieve_of_Eratosthenes(){
    factor.resize(N+1);
    for(u32 p=2;p<=N;++p){
      if(factor[p])continue;
      factor[p] = p;
      for(u32 x=p+p;x<=N;x+=p){
        if(factor[x])continue;
        factor[x] = p;
      }
    }
  }
  std::vector<u32> prime_factor(u32 x){
    std::vector<u32> pf;
    while(factor[x]){
      pf.push_back(factor[x]);
      while(factor[x]==pf.back())x/=factor[x];
    }
    return pf;
  }
};

signed main(){
  using namespace std;
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin>>n;
  vector<int> a(n);
  for(auto& ai:a)cin>>ai;

  constexpr int a_max = 1e6;
  Sieve_of_Eratosthenes ushi;

  map<int,int> mp;
  bool pairwise_coprime = true;
  bool setwise_coprime = accumulate(begin(a),end(a),0,[](auto a,auto b){return gcd(a,b);}) == 1;

  for(auto const& ai:a){
    for(auto const& p:ushi.prime_factor(ai)){
      if(mp.count(p)){
        pairwise_coprime = false;
        goto loopend;
      }
      mp[p]++;
    }
  }
loopend:

  if(pairwise_coprime){
    cout<<"pairwise coprime"<<endl;
  }
  else if(setwise_coprime){
    cout<<"setwise coprime"<<endl;
  }
  else{
    cout<<"not coprime"<<endl;
  }


}

### FIXED CODE ###

from math import gcd
max_a = int(2e6)
factor = [0]*max_a
for p in range(2,max_a):
  if factor[p]:
    continue
  factor[p] = p
  for x in range(p+p,max_a,p):
    if factor[x]:
      continue
    factor[x] = p

def prime_fac(ai):
  while factor[ai]:
    yield factor[ai]
    x = factor[ai]
    while x == factor[ai]:
      ai = int(ai/factor[ai])

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

cnt = [0]*max_a
loop_end = False
g = 0
pairwise_coprime = True
setwise_coprime = True

for ai in a:
  for p in prime_fac(ai):
    if cnt[p]:
      pairwise_coprime = False
      loop_end = True
    cnt[p] = 1
    if loop_end:
      break
  if loop_end:
    break

for ai in a:
  g = gcd(g,ai)
setwise_coprime = g==1

if pairwise_coprime:
  print('pairwise coprime')
elif setwise_coprime:
  print('setwise coprime')
else:
  print('not coprime')
A, B, C = sorted([int(x) for x in input().split()])
ret = 0
while True:
    if A < B and B < C:
        A += 1
        B += 1
    elif A < B and B == C:
        A += 2
    elif A > B and B == C:
        B += 1
        C += 1
    else:
        # 想定外
        exit(1)

    ret += 1
    if A == B and B == C:
        print(ret)
        exit()


### FIXED CODE ###

A, B, C = map(int, input().split())

ret = 0
while True:
    if A == B and B == C:
        print(ret)
        exit()

    ret += 1
    A, B, C = sorted([A, B, C])
    if B < C:
        A += 1
        B += 1
    elif B == C:
        A += 2
a = input()
b = input()

if a < b:
    print("str(a) + '<' + str(b)")
elif a > b:
    print("str(a) + '>' + str(b)")
else:
    print("str(a) + '==' + str(b)")

### FIXED CODE ###

[a, b] = [int(_) for _ in input().split()]

if a < b:
    print('a < b')
elif a > b:
    print('a > b')
else:
    print('a == b')
N = int(input())
L = np.array(input().split(),np.int16)

L.sort(reverse=True)
counter = 0

for index1,c in enumerate(L):
    index2 = index1+1
    if index2>N-1:
      break
    b = L[index2]
    while b>=c/2:
        
        index3 = index2+1
        if index3>N-1:
            break
        a = L[index3]
        
        while a+b>c:
            counter += 1
            index3+=1
            if index3>N-1:
                break
            a = L[index3]

        index2+=1
        if index2>N-1:
            break
        b = L[index2]


print(counter)

### FIXED CODE ###

N = int(input())
L = list(map(int,input().split()))

L.sort(reverse=True)
counter = 0
import bisect

for index1,c in enumerate(L):
    for index2,b in enumerate(L[index1+1:],start=index1+1):
        left = 0 ; right = N
        oppai = c-b
        while left+1<right:
            mid = (left+right)//2
            if L[mid]>oppai:
                left = mid
            else :
                right=mid
        
        index3 = left
        
        if index3>index2:

            counter += index3-index2
print(counter)
import sys
sys.setrecursionlimit(100000)
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
ns = []
ans = 0
for i in range(len(s)):
    if ns.count(s[i]) == 0:
        aas = s.count(s[i])
        if aas > 0:
            ns.append(s[i])
        abs = cmb(aas,2)
        ans += int(abs)
print(ans)

### FIXED CODE ###

from collections import Counter

N = int(input())
s = Counter()
for i in range(N):
    s[''.join(sorted(input()))] += 1
ans = 0
for kw, count in s.most_common():
    for i in range(1, int(count)):
        ans += i
    if int(count) < 2:
        break
print(ans)
def append_factor(f, p):
    if p not in f:
        f[p] = 0
    f[p] += 1

def factors(n):
    l = int(math.sqrt(n)) + 1
    ret = {}
    while n % 2 == 0:
        append_factor(ret, 2)
        n //= 2
    while n % 3 == 0:
        append_factor(ret, 3)
        n //= 3
    i = 6
    while i*i <= n:
        while n % (i - 1) == 0:
            append_factor(ret, i - 1)
            n //= (i - 1)
        while n % (i + 1) == 0:
            append_factor(ret, i + 1)
            n //= (i + 1)
        i += 6
    if n != 1:
        append_factor(ret, n)

    return ret

def minimum_sum(x):
    # find the minimum integer n where n(n+1)/2 <= x
    # n^2 < n(n+1) <= 2x < (n+1)(n+2) < (n+2)^2

    n = int(math.sqrt(x))
    while (n + 1)*(n + 2) <= 2*x:
        n += 1

    return n

def main():
    N = int(input())
    fs = factors(N)
    # print(fs)
    ans = 0
    for f in fs:
        ans += minimum_sum(fs[f])
    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import math

def append_factor(f, p):
    if p not in f:
        f[p] = 0
    f[p] += 1

def factors(n):
    l = int(math.sqrt(n)) + 1
    ret = {}
    while n % 2 == 0:
        append_factor(ret, 2)
        n //= 2
    while n % 3 == 0:
        append_factor(ret, 3)
        n //= 3
    for i in range(6, l, 6):
        while n % (i - 1) == 0:
            append_factor(ret, i - 1)
            n //= (i - 1)
        while n % (i + 1) == 0:
            append_factor(ret, i + 1)
            n //= (i + 1)
    if n != 1:
        append_factor(ret, n)

    return ret

def minimum_sum(x):
    # find the minimum integer n where n(n+1)/2 <= x
    # n^2 < n(n+1) <= 2x < (n+1)(n+2) < (n+2)^2

    n = int(math.sqrt(x))
    while (n + 1)*(n + 2) <= 2*x:
        n += 1

    return n

def main():
    N = int(input())
    fs = factors(N)
    # print(fs)
    ans = 0
    for f in fs:
        ans += minimum_sum(fs[f])
    print(ans)

if __name__ == '__main__':
    main()
N = int(input())
b = [int(_) for _ in input().split()]


def delitable(numbers):
    return [v for i, v in enumerate(numbers) if v == i + 1]


b_searched = set()
b_unsearched = []


b_searched.add(tuple(b))
delit = delitable(b)

if delit == []:
    print("-1")
for delit_num in delit:
    b_unsearched.append([b[:delit_num - 1] + b[delit_num:], [delit_num]])


while b_unsearched:
    b, log = b_unsearched.pop()

    if not b and max(b) > N - len(log):
        continue

    b_tuple = tuple(b)
    b_searched.add(b_tuple)
    delit = delitable(b)


    if not delit:
        if not b:
            log.reverse()
            print("\n".join(map(str, log)))
            break
        else:
            continue
    for delit_num in delit:
        b_temp = b[:delit_num - 1] + b[delit_num:]
        if not tuple(b_temp) in b_searched:
            b_unsearched.append([b_temp, log + [delit_num]])
else:
    print("-1")

### FIXED CODE ###

N = int(input())
b = [int(_) for _ in input().split()]


def delitable(numbers):
    return [v for i, v in enumerate(numbers) if v == i + 1]


log = []
while b:
    delit = delitable(b)
    if not delit:
        print(-1)
        break
    del b[delit[-1] - 1]
    log.append(delit[-1])
else:
    log.reverse()
    print("\n".join(map(str, log)))
target = input()
sum = 0
for each in all:
  sum += int(each)
if sum % 9 == 0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

target = input()
sum = 0
for each in target:
  sum += int(each)
if sum % 9 == 0:
  print("Yes")
else:
  print("No")
from math import sqrt
n = int(input())
s = int(input())

if n < s:
  print(-1)
  import sys
  sys.exit()
if n == s:
  print(n+1)
  import sys
  sys.exit()

def f(b, n):
  if n < b:
    return n
  return f(b, n//b) + (n % b)

res = -1

for p in range(1, int(sqrt(n))+1):
  b = (n-s)//p + 1
  if f(b, n) == s:
    res = b
    break

for b in range(2, int(sqrt(n))+1):
  if f(b, n) == s:
    res = b
    break

print(res)

### FIXED CODE ###

from math import sqrt
n = int(input())
s = int(input())

if n < s:
  print(-1)
  import sys
  sys.exit()
if n == s:
  print(n+1)
  import sys
  sys.exit()

def f(b, n):
  if n < b:
    return n
  return f(b, n//b) + (n % b)

res = -1

for p in range(int(sqrt(n)), 0, -1):
  b = (n-s)//p + 1
  if b == 1:
    continue
  if f(b, n) == s:
    res = b
    break

for b in range(2, int(sqrt(n))+2):
  if f(b, n) == s:
    res = b
    break

print(res)