Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys 

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



if N == 1:
    print(A[0])
    sys.exit()

mae = []
usiro = []

#0の時に前 1の時に後ろ
Flag = 0

for i in reversed(range(0,N,1)):
    
    if Flag == 0: # 前の時
        mae.append(str(A[i]))
        Flag = 1
    else:
        usiro.insert(0,str(A[i]))
        Flag = 0

moziretu = (mae + usiro)

string = ""
for i in range(len(moziretu)):
  if (i == 0) or (i == len(moziretu)):
    string = string + moziretu[i]
  else:
    string = string + " " +moziretu[i]
  
print(string)

### FIXED CODE ###

import sys 
from collections import deque
N = int(input())
A = list(map(int, input().split()))


if N == 1:
    print(A[0])
    sys.exit()

mae = deque()
usiro = deque()

#0の時に前 1の時に後ろ
Flag = 0

for i in reversed(range(0,N,1)):
    
    if Flag == 0: # 前の時
        mae.append(str(A[i]))
        mae.append(" ")
        Flag = 1
    else:
        usiro.insert(0,str(A[i]))
        usiro.appendleft(" ")
        Flag = 0

moziretu = (mae + usiro)
del moziretu[((len(moziretu))//2)]
moziretu = ''.join(moziretu)
print(moziretu)
### BUGGY CODE ###

a,b,k=map(int,input().split())
ab=[]
for i in range(a,b+1):
    ab.append(i)
cd=ab
ab_min=ab[:k]
ab_max=cd[b+1-a-k:]

anslist=list(set(ab_min)|set(ab_max))
anslist.sort()

for k in range(len(anslist)):
    print(anslist[k])


### FIXED CODE ###

a,b,k=map(int,input().split())
ab_min=[]
ab_max=[]
for i in range(a,min(b+1,a+k)):
    ab_min.append(i)
for j in range(max(a,b+1-k),b+1):
    ab_max.append(j)

ans=list(set(ab_min)|set(ab_max))
ans.sort()

for k in range(len(ans)):
    print(ans[k])
### BUGGY CODE ###

n,k=map(int, input().split())
p=list(map(int, input().split()))

def kitai(pk):
    return sum(pk)/2 + k*0.5

ans = 0.0
for i in range(len(p)-k+1):
    karians = kitai(p[i:i+k])
    if ans < karians:
        ans = karians
print(ans)


### FIXED CODE ###

n,k=map(int, input().split())
p=list(map(int, input().split()))
ksum = sum(p[0:k])
ans = kans = ksum/2 + k*0.5
for i in range(n-k):
    ksum = ksum -p[i] +p[i+k]
    kans = ksum/2 + k*0.5
    if ans < kans:
        ans = kans
print(ans)
### BUGGY CODE ###

# E
 
N = int(input())
a_list = [0]*(N+1)
for i in range(N+1):
    a_list[N-i] = int(input())

#import random
#N = 10**4
#a_list = [0]*(N+1)
#for i in range(N+1):
#    a_list[N-i] = random.choice(range(10**9))
#a_list[0] = 2*3*5*7*11*13*17*19*23*998244353

 
# a0を割り切る素数を全部求める
p_list = []
## 10^5までの素数を計算
primes = list(range(10**5))
primes[0] = 0
primes[1] = 0
for p in range(2, 10**5):
    if primes[p]:
        for i in range(2*p, 10**5, p):
            primes[i] = 0
primes = [p for p in primes if p>0]
 
## 素因数分解
A = a_list[0]
for p in primes:
    if A % p == 0:
        p_list.append(p)
    while A % p == 0:
        A = A // p
if A > 1:
    p_list.append(A)
# print(p_list)
# 個別に条件確認
res_list = []

check_list = [0]*(N+1)

for p in p_list:
    r = 0
    #check_list = [0]*(N+1)
    for i in range(min(p, N+1)):
        check_list[i] = a_list[i] % p
    for i in range(p, N+1):
        check_list[(i-1) % (p-1) + 1] += a_list[i] % p
    for i in range(min(p, N+1)):
        r += check_list[i] % p
    if r == 0:
        res_list.append(p)
        
for p in res_list:
    print(p)

### FIXED CODE ###

# E

# 入力
# input
N = int(input())
a_list = [0]*(N+1)
for i in range(N+1):
    a_list[N-i] = int(input())


# 10^5までの素数を計算
# list primes <= 10^5 
primes = list(range(10**5))
primes[0] = 0
primes[1] = 0
for p in range(2, 10**5):
    if primes[p]:
        for i in range(2*p, 10**5, p):
            primes[i] = 0
primes = [p for p in primes if p>0]
# primes <= N
p_list_small = [p for p in primes if p <= N]


# A_Nを素因数分解、Nより大きい素因数をp_list_largeに追加
# A_N, ..., A_0の最大公約数の素因数でやっても同じ
# list prime factors of A_N, if greater then N, add to p_list_large
# you can use prime factors of gcd(A_N, ..., A_0) instead 

p_list_large = []
A = abs(a_list[-1])
for p in primes:
    if A % p == 0:
        if p > N:
            p_list_large.append(p)
        while A % p == 0:
            A = A // p
if A != 1:
    p_list_large.append(A)

# 個別に条件確認
# check all p in p_list_small
# x^p ~ x (mod p)
res_list = []
for p in p_list_small:
    r = 0
    check_list = [0]*(N+1)
    for i in range(p):
        check_list[i] = a_list[i]
    for i in range(p, N+1):
        check_list[(i-1) % (p-1) + 1] += a_list[i]
    for i in range(p):
        if check_list[i] % p != 0:
            r = 1
    if r == 0:
        res_list.append(p)
        
# 個別に条件確認
# check all p in p_list_large
# a_i % p == 0
for p in p_list_large:
    r = 0
    for i in range(N+1):
        if a_list[i] % p != 0:
            r = 1
    if r == 0:
        res_list.append(p)
        
for p in res_list:
    print(p)
### BUGGY CODE ###

n = int(input())
list_A = list(map(int, input().split()))
list_A.sort()
max_value = max(list_A)
cnt = 0
hight = 1
hight_num = max_value
low = 1
low_num = 1
cnt = 0
ans = 0
b = 0
for i in range(max_value):
    hight *= hight_num - i
    low *= low_num + i
    if list_A[cnt] == low_num + i:
        ans = max(ans, hight//low)
        cnt += 1
        if ans == hight//low:
            b = low_num + i

print(max_value, b)

### FIXED CODE ###

n = int(input())
list_A = list(map(int, input().split()))
list_A.sort()
max_value = max(list_A)
a = max_value/2
b = pow(10, 10)
c = 0
for num in list_A:
    if abs(a-num) < b:
        b = abs(a-num)
        c = num

print(max_value, c)
### BUGGY CODE ###

import sys
from collections import deque
from bisect import bisect_left

def main():
    input = sys.stdin.readline
    N = int(input())
    q = deque()
    min_ = 10**9 + 1
    max_ = 0
    cnt = 0
    for _ in range(N):
        n = int(input())
        if n <= min_:
            q.appendleft(n)
            min_ = n
            cnt += 1
            continue

        if n > max_:
            _ = q.pop()
            q.append(n)
            max_ = n
            continue

        pos = bisect_left(q, n)
        q[pos-1] = n
        min_ = min(q)

    return cnt


if __name__ == '__main__':
    print(main())


### FIXED CODE ###

import sys
from collections import deque
from bisect import bisect_left

def main():
    input = sys.stdin.readline
    N = int(input())
    a = int(input())
    q = deque()
    q.append(a)
    ans = 1
    for _ in range(N-1):
        n = int(input())
        if n <= q[0]:
            q.appendleft(n)
            ans += 1
            continue

        if n > q[-1]:
            q[-1] = n
            continue

        pos = bisect_left(q, n)
        q[pos-1] = n
        min_ = q[0]

    return ans


if __name__ == '__main__':
    print(main())
### BUGGY CODE ###

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

cand = set(a)

exist = set()
dup = set()
for item in a:
    if item in exist:
        dup.add(item)
    else:
        exist.add(item)

dame_set = set()

a.sort()
ret = 0

for val in a:
    if val in dup:
        i = 1
        cnt = 10 ** 6 // val
        while i <= cnt:
            tmp = i * val
            if tmp in cand:
                dame_set.add(tmp)
            i += 1
    else:
        if val in dame_set:
            continue
        else:
            ret += 1
            i = 1
            cnt = 10 ** 6 // val
            while i <= cnt:
                tmp = i * val
                if tmp in cand:
                    dame_set.add(tmp)
                i += 1

print(ret)


### FIXED CODE ###

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

cand = set(a)

exist = set()
dup = set()
for item in a:
    if item in exist:
        dup.add(item)
    else:
        exist.add(item)

dame_set = set()

a.sort()
ret = 0

for val in a:
    if val in dup:
        if val in dame_set:
            continue
        else:
            i = 1
            cnt = 10 ** 6 // val
            while i <= cnt:
                tmp = i * val
                if tmp in cand:
                    dame_set.add(tmp)
                i += 1
    else:
        if val in dame_set:
            continue
        else:
            ret += 1
            i = 1
            cnt = 10 ** 6 // val
            while i <= cnt:
                tmp = i * val
                if tmp in cand:
                    dame_set.add(tmp)
                i += 1

print(ret)
### BUGGY CODE ###

from collections import deque
import itertools, math
d,g = list(map(int,input().split()))
pc = [list(map(int,input().split())) for _ in range(d)]
g /= 100

pat = list(itertools.permutations(range(d)))
ans = sum([pc[x][0] for x in range(d)])

def dfs(k, point, cnt, pat):
  global ans
  i = pat[k]
  
  cnt += min(pc[i][0], math.ceil((g-point)/(i+1)))
  point += min(pc[i][0], math.ceil((g-point)/(i+1))) * (i+1)
  point += pc[i][1]//100
  #print(k,i,point,cnt)
  if point >= g:  
    ans  = min(ans, cnt)
    return
  else:
    if k < d-1:
      dfs(k+1, point, cnt, pat)
      

for p in pat:
  dfs(0, 0, 0, list(p))

print(ans)

### FIXED CODE ###

from collections import deque
import itertools, math
d,g = list(map(int,input().split()))
pc = [list(map(int,input().split())) for _ in range(d)]
g /= 100

#ans = sum([pc[x][0] for x in range(d)])
ans = float('inf')
for bit in range(1<<d):
  cnt = 0
  point = 0
  pat = set(range(1,d+1))
  
  for i in range(d):
    if bit & (1<<i):
      point += pc[i][0]*(i+1) + pc[i][1]//100
      cnt += pc[i][0]
      pat.discard(i+1)
  
  if point < g:
      next = max(pat)
      n = min(pc[next-1][0], math.ceil((g - point)/(next)))
      cnt += n
      point += n*(next)
    
  if point >= g:
      #print(ans,cnt)
      ans = min(ans,cnt)


print(ans)
### BUGGY CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]

paper = []
for i in range(N):
    if not A[i] in paper:
        paper.append(A[i])
    else:
        paper.remove(A[i])

print(len(paper))


### FIXED CODE ###

import collections

N = int(input())
A = [int(input()) for _ in range(N)]

ans= 0
Acount = collections.Counter(A)

for i in Acount:
    if Acount[i] % 2 == 1:
        ans += 1

print(ans)
### BUGGY CODE ###

from collections import defaultdict, deque

n, m = [int(i) for i in input().split()]

children = defaultdict(list)
parents = defaultdict(list)

for _ in range(m):
    u, v = [int(i) for i in input().split()]
    children[u-1].append(v-1)
    parents[v-1].append(u-1)

def longest_path(children, parents, n):
    f = [None] * n
    targets = [x for y in children.values() for x in y]
    starts = [v for v in range(n) if v not in targets]

    # print f
    for i in range(n):
        get_f(children, parents, f, i)

    # print f
    return max(f)

def get_f(children, parents, f, i):
    if f[i] != None:
        return f[i]

    f[i] = 0
    for v in parents[i]:
        f[i] = max(f[i], get_f(children, parents, f, v) + 1)

    return f[i]

# def longest_path(children, parents, n):
#     targets = [x for y in children.values() for x in y]
#     starts = [v for v in range(n) if v not in targets]
#     f = [None] * n
    
#     Q = deque([])
#     for v in starts:
#         f[v] = 0
#         Q.append((v, 0))

#     output = 0
#     while len(Q) > 0:
#         node, length = Q.pop()
#         output = max(output, length)
#         for v in children[node]:
#             Q.append((v, length+1))

#     return output

print(longest_path(children, parents, n))


### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(1000000)

n, m = [int(i) for i in raw_input().split()]
parents = defaultdict(list)

i = 0
while i < m:
    u, v = [int(x) for x in raw_input().split()]
    parents[v-1].append(u-1)
    i += 1

def calc_f(parents, f, i):
    if i < 0 or i >= len(f):
        return 0

    if f[i] != -1:
        return f[i]

    f[i] = 0
    for v in parents[i]:
        f[i] = max(f[i], calc_f(parents, f, v)+1)

    return f[i]

f = [-1] * n
j = 0
while j < n:
    calc_f(parents, f, j)
    j += 1

if len(f) == 0:
    print 0
else:
    print max(f)
### BUGGY CODE ###

n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]
dp = [[0 for _ in range(w + 1)] for _ in range(n + 1)]

for i in range(n):
    for sum_w in range(w + 1):
        if sum_w - wv[i][0] >= 0:
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i]
                                 [sum_w - wv[i][0]] + wv[i][1])
        dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])
print(dp[n][w])


### FIXED CODE ###

n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]
dp = [[0 for _ in range(w + 1)] for _ in range(n + 1)]

for i in range(n):
    for sum_w in range(w + 1):
        if sum_w - wv[i][0] >= 0:
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i]
                                 [sum_w - wv[i][0]] + wv[i][1])
        dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])
print(dp[n][w])
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
if not 1 in a:
    print(-1)
else:
    for i in range(n):
        if i==0:
            for j in range(0,n):
                if i+1==a[j]:
                    break
                else:
                    a[j]=0
        else:
            if i in a:
                for j in range(a.index(i)+1,n):
                    if i+1==a[j]:
                        break
                    else:
                        a[j]=0
            else:
                break
    print(a.count(0))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
now=1
rtn=0
for i in range(n):
    if a[i]==now:
        rtn+=1
        now+=1
if rtn:
    print(n-rtn)
else:
    print(-1)
### BUGGY CODE ###

N = int(input())
x = list([int(i) for i in input().split()])
cnt = 0
while True:
    flag = False
    for i in x:
        if i & 1:
            flag = True
            break
        else:
            i <<= 1
    else:
        cnt += 1
    if flag:
        break
print(cnt)

### FIXED CODE ###

N = int(input())
x = list(map(int, input().split()))
mn_lst = []
for i in x:
    cnt = 0
    while i % 2 == 0:
        cnt += 1
        i >>= 1
    mn_lst.append(cnt)
    
print(min(mn_lst))
### BUGGY CODE ###

N, K = map(int, input().split())
H = list(map(int, input().split()))

dp = [0 for _ in range(N)]
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    r = max(0, i - K)
    dp[i] = min(d + abs(H[i] - h) for d, h in zip(dp[r:i], H[r:i]))
print(dp[N-1])

### FIXED CODE ###

N, K = map(int, input().split())
H = list(map(int, input().split()))

dp = [0 for _ in range(N)]
for i, hi in enumerate(H):
    if i == 0:
        continue
    r = max(0, i - K)
    dp[i] = min(d + abs(hi - h) for d, h in zip(dp[r:i], H[r:i]))
print(dp[N-1])
### BUGGY CODE ###

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

for _ in range(0, M, 1):
	A.sort(reverse = True)
	A[0] >>= 1

print(sum(A))

### FIXED CODE ###

import heapq

N, M = map(int, input().split())
A = list(map(lambda o: -int(o), input().split()))
heapq.heapify(A)

for i in range(0, M, 1):
	heapq.heappush(A, -(-heapq.heappop(A) >> 1))

print(-sum(A))
### BUGGY CODE ###

[n,m]=[int(x) for x in input().split()]
LR=[[int(x)-1 for x in input().split()] for _ in range(m)]

ok=list(range(n))
for c in LR:
  ok=[item for item in ok if c[0]<=item and item<=c[1]]
  #print(ok)
print(len(ok))


### FIXED CODE ###

import numpy as np
[n,m]=[int(x) for x in input().split()]
LR_T=np.array([[int(x)-1 for x in input().split()] for _ in range(m)]).T

print(max(np.min(LR_T[1])-np.max(LR_T[0])+1,0))
### BUGGY CODE ###

N, K = map(int, input().split())
*P, = map(int, input().split())
# expec = tuple((P[i] * (P[i] + 1) / 2) / P[i] for i in range(N))
expec = tuple((P[i] + 1) / 2 for i in range(N))
ans = 0
for i in range(N-K+1):
    a = expec[i:i+K]
    s = sum(a)
    ans = max(ans, s)
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
*P, = map(int, input().split())
cum = [0] * (N + 1)
for i in range(N):
    cum[i+1] = cum[i] + (P[i] * (P[i] + 1) / 2) / P[i]
ans = 0
for i in range(N-K+1):
    ans = max(ans, cum[i+K] - cum[i])
print(ans)
### BUGGY CODE ###

N = int(input())
li = list(map(int, input().split()))
for i in range(N):
  print(li.index(i+1) + 1, end = " ")

### FIXED CODE ###

N = int(input())
li = list(map(int, input().split()))
ans = [0]*N
for i in range(N):
  ans[li[i]-1] = i+1
print(*ans)
### BUGGY CODE ###

# encoding: utf-8
N, M = list(map(int, input().split()))

# TLE
# Amod = [A for A in map(lambda x: int(x) % M , input().split())]
# ans = 0
# for l in range(len(Amod)):
#     acm = 0
#     for r in range(l, len(Amod)):
#         acm = (acm + Amod[r]) % M
#         if acm == 0: ans += 1
import array

Asym = array.array('I', [0 for i in range(N)])
sym = 0
for i, A in enumerate(map(int, input().split())):
    sym = (sym + A) % M
    Asym[i] = sym
    
ans = Asym.count(0)
for sym in set(Asym):
    cnt = Asym.count(sym)
    ans +=  int(cnt * (cnt -  1) / 2)
    
print(ans)

# print(int(Asym.count(0) + sum([Asym.count(sym) * (Asym.count(sym) - 1) for sym in set(Asym)]) / 2))

# Acnt = [0 for i in range(M)]
# sym = 0
# for A in map(int, input().split()):
#     sym = (sym + A) % M
#     Acnt[sym] += 1

# print(int(Acnt[0] + sum([cnt * (cnt - 1) for cnt in Acnt]) / 2))

### FIXED CODE ###

# encoding: utf-8
N, M = list(map(int, input().split()))

d_sym = {}
sym = 0

# refresh

ans = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    #
    if sym == 0: ans += 1
    # 
    if str(sym) in d_sym.keys(): d_sym[str(sym)] += 1
    else: d_sym[str(sym)] = 1

print(int(ans + sum([val * (val - 1) / 2 for val in d_sym.values()])))
### BUGGY CODE ###

from collections import deque
import numpy as np

H, W = list(map(int, input().split()))
field = [input() for _ in range(H)]
dist = [[5000] * W for _ in range(H)]

def bfs():
  q = deque()
  for y in range(H):
    for x in range(W):
      if field[y][x] == '#':
        q.append((y, x))
        dist[y][x] = 0
  while len(q) > 0:
    y, x = q.popleft()
    for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
      ny, nx = y + dy, x + dx
      if ny < 0 or ny >= H or nx < 0 or nx >= W:
        continue
      if field[ny][nx] == '#':
        continue
      if dist[ny][nx] <= dist[y][x] + 1:
        continue
      dist[ny][nx] = dist[y][x] + 1
      q.append((ny, nx))
      
bfs()
print(np.max(np.asarray(dist).flatten()))

### FIXED CODE ###

from collections import deque
import copy

def main():
  H, W = map(int, input().split())
  maps = [[j=="#" for j in input()] for i in range(H)]
  q = deque([(i, j) for i in range(H) for j in range(W) if maps[i][j]])
  count = 0
  while True:
    nq = deque()
    while q:
      x, y = q.popleft()
      if x > 0 and not maps[x-1][y]:
        maps[x-1][y] = True
        nq.append((x-1,y))
      if y > 0 and not maps[x][y-1]:
        maps[x][y-1] = True
        nq.append((x,y-1))
      if x < H-1 and not maps[x+1][y]:
        maps[x+1][y] = True
        nq.append((x+1,y))
      if y < W-1 and not maps[x][y+1]:
        maps[x][y+1] = True
        nq.append((x,y+1))
    if nq:
      q = copy.copy(nq)
    else:
        break
    count += 1
  print(count)

if __name__ == "__main__":
  main()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000000)

ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())

N, M, P = mis()

to = [[] for _ in range(N)]
ot = [[] for _ in range(N)]
edges = []

for i in range(M):
    a,b,c = mis()
    a -= 1
    b -= 1
    c = -(c-P)
    #
    to[a].append(b)
    ot[b].append(a)
    edges.append((a,b,c))

reachableFrom0 = [False] * N
reachableToN = [False] * N

def dfs(n):
    if reachableFrom0[n]:
        return
    reachableFrom0[n] = True
    for i in to[n]:
        dfs(i)

def rdfs(n):
    if reachableToN[n]:
        return
    reachableToN[n] = True
    for i in ot[n]:
        rdfs(i)

dfs(0)
rdfs(N-1)

ok = [a and b for a, b in zip(reachableFrom0, reachableToN)]

edges = [(a, b, c) for a, b, c in edges if ok[a] and ok[b]]

V = [float('inf')] * N
V[0] = 0

def bf_step():
    for a, b, c in edges:
        V[b] = min(V[b], V[a] + c)

def bf():
    for _ in range(N):
        bf_step()

bf()

Vb = tuple(V)
bf_step()

if tuple(V) == Vb:
    print(max(-V[-1], 0))
else:
    print(-1)




### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())

def main():
    N, M, P = mis()
    
    to = [[] for _ in range(N)]
    ot = [[] for _ in range(N)]
    edges = []

    for i in range(M):
        a,b,c = mis()
        a -= 1
        b -= 1
        c = -(c-P)
        #
        to[a].append(b)
        ot[b].append(a)
        edges.append((a,b,c))

    reachableFrom0 = set()
    reachableToN = set()

    # dfs
    reachableFrom0.add(0)
    nodes = [0]
    while nodes:
        node = nodes.pop()
        for i in to[node]:
            if i not in reachableFrom0:
                nodes.append(i)
                reachableFrom0.add(i)

    #rdfs
    reachableToN.add(N-1)
    nodes = [N-1]
    while nodes:
        node = nodes.pop()
        for i in ot[node]:
            if i not in reachableToN:
                nodes.append(i)
                reachableToN.add(i)


    ok = reachableFrom0 & reachableToN

    edges = tuple((a, b, c) for a, b, c in edges if a in ok and b in ok)

    V = [float('inf')] * N
    V[0] = 0

    def bf(n):
        for _ in range(n):
            upd = False
            for a, b, c in edges:
                if V[b] > V[a] + c:
                    V[b] = V[a] + c
                    upd = True
            if not upd:
                return False
        return True

    bf(N)

    if not bf(1):
        print(max(-V[-1], 0))
    else:
        print(-1)

main()
### BUGGY CODE ###

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

while k<len(A):
    if A[k] == k+1:
            k += 1
    else:
            count += 1
            A.pop(k)
if count == N:
    print(-1)
else:
    print(count)

### FIXED CODE ###

import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
count = 0
k=0
t=0

while t<len(A):
    if A[t] == k+1:
            k += 1
            t += 1
    else:
            count += 1
            t += 1
if count == N:
    print(-1)
else:
    print(count)
### BUGGY CODE ###

N=int(input())
S=list(str(input()))
R=[]
G=[]
B=[]
for i in range(N):
	if S[i]=='R':
		R.append(i)
	elif S[i]=='G':
		G.append(i)
	else:
		B.append(i)
ans=0
for r in R:
	for g in G:
		ans+=len(B)
		M=max(r,g)
		m=min(r,g)
		if (2*M-m) in B:
			ans-=1
		if (2*m-M) in B:
			ans-=1
		if (M+m)%2==0:
			if (M+m)//2 in B:
				ans-=1
print(ans)



### FIXED CODE ###

N=int(input())
S=list(str(input()))
R=0
G=0
B=0
for i in range(N):
	if S[i]=='R':
		R+=1
	elif S[i]=='G':
		G+=1
	else:
		B+=1
ans=G*B*R
for a in range(N-1):
	for d in range(1,(N-a-1)//2+1):
		if S[a]!=S[a+d] and S[a+d]!=S[a+d*2] and S[a]!=S[a+d*2]:
			ans-=1
print(ans)
### BUGGY CODE ###

import sys
H,W,K = map(int, sys.stdin.readline().split())
MAP = sys.stdin.readlines()
ans = [None] * H
for i in range(H):
	ans[i] = list(map(str,MAP[i].rstrip()))


#H,W,K = map(int, input().split())
#ans = [list(map(str,input())) for _ in range(H)]

cnt = 1
for i in range(H):
	ichigo = 0
	cond = 0
	for j in range(W):
		if j == W-1 and ans[i][j] == ".":
			ans[i][j] = cnt
			cond = 1
			break
		if ans[i][j] == ".":
			ans[i][j] = cnt
		else:
			ans[i][j] = cnt
			cnt += 1
			ichigo += 1

	if ichigo == 0:
		ans[i] = []
		continue

	if cond:
		for k in range(W):
			if ans[i][-(k+1)] == cnt:
				ans[i][-(k+1)] -= 1
			else:
				break


cond = 1
while cond:
	cond = 0
	for i in range(H):
		if ans[i] == []:
			cond = 1
			if i == H-1:
				ans[i] = ans[i-1]
			else:
				ans[i] = ans[i+1]

for i in range(H):
	for j in range(W):
		if j == W-1:
			print(ans[i][j])
		else:
			print(ans[i][j], end = " ")

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

H,W,K = map(int, readline().split())
grid = np.frombuffer(read(), 'S1').reshape(H,-1)[:,:W]

X,Y = np.where(grid == b'#')

A = np.zeros((H,W), np.int32)
A[X,Y] = np.arange(1,K+1)

np.maximum.accumulate(A, axis = 1, out = A)

for w in range(W-2, -1, -1):
	A[:,w] += A[:,w+1] * (A[:,w] == 0)

for h in range(1,H):
	if A[h,-1] == 0:
		A[h] += A[h-1]
for h in range(H-1,-1,-1):
	if A[h,-1] == 0:
		A[h] += A[h+1]

print('\n'.join(' '.join(row) for row in A.astype(str)))