Harryxun/stf_run huggingface dataset:
n = int(input())
listB = list(map(int, input().split()))
i = 1
if i == 1:
    listA = []
    index2 = len(listB)-1
    befI = len(listB)
    while index2 > -1:
        if listB[index2]!=1:
            pass
        else:
            if index2 != befI:
                newL = listB[index2:befI]
                newL.sort()
                listA.extend(newL)
                befI = index2
            else:
                listA.append(1)
        index2-=1
    listC = []
    index3=0
    while index3 < len(listA):
        if index3 == 0:
            if listA[index3] == 1:
                listC.append(listA[index3])
            else:
                listC.append(0)
        elif listA[index3] > index3+1:
            listC.append(0)
        else:
            if listA[index3]-1 <=  len(listC):
                listC.insert(listA[index3]-1, listA[index3])
            else:
                listC.append(0)
        index3+=1
    if index3 == len(listA):
        if listC == listB:
            for ans in listA:
                print(ans)
        else:
            print(a)

### FIXED CODE ###

n = int(input())
listB = list(map(int, input().split()))
listA = []

flag=1
while flag:
    index=len(listB)-1
    while index > -1:
        if listB[index] == index+1:
            listA.append(listB[index])
            del listB[index]
            break
        index-=1
    if index == -1:
        print(-1)
        flag=0
        break
    if listB == []:
        break
listA.reverse()
if flag:
    for ans in listA:
        print(ans)
N=int(input())
A=list(map(int,input().split()))

while len(A)!=1:
#for i in range(2):
    A.sort()
    if A.count(0):A.remove(0)
    for i in range(len(A)-1):            
        A[i+1]=A[i+1]%A[0]

print(max(A))

### FIXED CODE ###

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

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

A.sort()
y=A[0]
for i in range(1,N):
    y=gcd(y,A[i])
print(y)
a = int(input())
b = int(input())
z = a * b
if (z % 2) == 0:
    print("Even")
else:
    print("Odd")

### FIXED CODE ###

a, b = map(int, input().split())
print("Even" if a*b % 2 == 0 else "Odd")
n, m = map(int, input().split())
a = []
for i in range(n):
  x, y = map(int, input().split())
  a.append(x)
  a.append(y)
for i in range(m):
  print(a.count(i+1))

### FIXED CODE ###

n, m = map(int, input().split())
a = []
for i in range(m):
  x, y = map(int, input().split())
  a.append(x)
  a.append(y)
for i in range(n):
  print(a.count(i+1))
import math
r = input()
print(2 * r * math.pi)

### FIXED CODE ###

import math
pi = math.pi
r = int(input())
print(2 * r * pi)
N, M = map(int, input().split())

A = list(map(int, input().split()))
def soujyuu(left, right, num):
    if right - left <= 1:
        A.insert(right, num)
    else:
        if num >= A[left + right // 2]:
            left = left + right // 2
        else:
            right = left + right // 2
        soujyuu(left, right, num)


A.sort()
for i in range(M):
    maxA = A.pop(N-1)
    maxA = maxA // 2
    soujyuu(0,N-2, maxA)
    #print(A)

print(sum(A))


### FIXED CODE ###

S = input()

if S == "Sunny":
    print("Cloudy")
elif S == "Cloudy":
    print("Rainy")
else:
    print("Sunny")
a = int(input())
print("ABC"+a)

### FIXED CODE ###

a = input()
print("ABC"+a)
#get inputs
N = int(input())
K = int(input())
X = map(int, input().split())
Total_dist = 0

#iterate through number of bals
for i in range(N):
	for Rtype in ['A','B']:
		dist = []
		if Rtype == 'A':
			dist.append(abs(X[i] - 0))
		if Rtype == 'B':
			dist.append(abs(X[i] - K))
	Total_dist += min(dist)

print(Total_dist)

### FIXED CODE ###

N = int(input())
K = int(input())
X = list(map(int, input().split()))
Total_dist = 0

#iterate through number of bals
for i in range(N):
	dist = []
	for Rtype in ['A','B']:
		if Rtype == 'A':
			dist.append(abs(X[i] - 0)*2)
		if Rtype == 'B':
			dist.append(abs(X[i] - K)*2)
	Total_dist += min(dist)

print(Total_dist)
n,k = map(int,input().split())
h = list(map(int,input().split()))

dp = [float("inf")]*n

def rec(i):#全探索+メモ化
    if dp[i] != float("inf"):
        return dp[i]
    if i <= 0:
        return 0
    else:
        for l in range(1,k+1):
            if i-l < 0:continue
            dp[i] = min(dp[i],rec(i-l) + abs(h[i]-h[i-l]))
    return dp[i]

print(rec(n-1))
            

### FIXED CODE ###

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

dp = [float("inf")]*n

#初期条件
dp[0] = 0

#漸化式
for i in range(1,n):
    for l in range(1,k+1):
        if i-l < 0:continue
        dp[i] = min(dp[i],dp[i-l] + abs(h[i-l]-h[i]))

print(dp[n-1])
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)

li = []
x.sort()
for i in range(N):
  li.append(x[i+1]-x[i])
  
li.sort()
while len(li) > 1:
  l = []
  div = li[0]
  for n in li:
    mod = n % div
    if mod != 0:
      mod.append(l)
  l.append(div)
  l.sort()
  li = l
print(*li)

### FIXED CODE ###

N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)

li = []
x.sort()
for i in range(N):
  li.append(x[i+1]-x[i])
  
li.sort()
while len(li) > 1:
  l = []
  div = li[0]
  for n in li:
    mod = n % div
    if mod != 0:
      l.append(mod)
  l.append(div)
  l.sort()
  li = l
print(*li)
r=int(intput())
print(r*r)

### FIXED CODE ###

r= int(input())
print(r*r)
x,y = input().split()
a,b = ord(x), ord(y)
 
if a < b:
    print('<')
elif a > b:
    print('>')
else if a=b:
    print('=')

### FIXED CODE ###

a,b=input().split()
x,y=ord(a),ord(b)

if x > y:
    print(">")
elif x==y:
  print("=")
else:
  print("<")
if (a==5 and b==5 and c==7) or (a==5 and b==7 and c==5) or (a==7 and b==5 and c==5):
   print(Yes)
else:print(No)

### FIXED CODE ###

a = list(map(int,input().split()))
a.sort()
if a[0] == a[1] == 5 and a[2] == 7:
    print("YES")
else:
    print("NO")
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    a = na()
    a.sort(reverse=True)
    upper = 10 ** 9 + 1
    under = 0

    while upper - under > 0.01:
        middle = (upper + under) // 2

        tk = k
        flg = True
        for ai in a:
            if ai <= middle:
                break

            ta = ai
            tk -= int((ta - middle) / middle)
            if tk < 0:
                flg = False
            break

        if flg:
            upper = middle
        else:
            under = middle

    print(math.ceil(under))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    a = na()
    a.sort(reverse=True)
    upper = 10**9 + 1
    under = 0

    while upper - under > 1:
        middle = (upper + under) // 2

        tk = k
        flg = True
        for ai in a:
            if ai <= middle:
                break

            ta = ai
            tk -= int(ta // middle)
            if tk < 0:
                flg = False
                break

        if flg:
            upper = middle
        else:
            under = middle

    if k == 0:
        print(max(a))
    else:
        print(math.ceil((upper + under) / 2))

if __name__ == '__main__':
    main()
1 ini = lambda : int(input())
  2 inm = lambda : map(int,input().split())
  3 inl = lambda : list(map(int,input().split()))
  4 gcd = lambda x,y : gcd(y,x%y) if x%y else y
  5 a = input()
  6 if ord(a) < ord('a'):
  7         print('A')
  8 else: 
  9         print('a')


### FIXED CODE ###

import sys

x = input()
if ord(x) < 91:
    print('A')
else:
    print('a')
#from pprint import pprint
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from copy import deepcopy
#from itertools
#import sys 
#sys.setrecursionlimit(N) #N回まで再起を許可する。

# = map(int,input().split())

# = list(map(int,input().split()))

# = [list(map(int,input().split())) for _ in range(XXXX)]


h,n = map(int,input().split())

ab= [list(map(int,input().split())) for _ in range(n)]

dp = [[float("inf") for _ in range(h+1)] for _ in range(n+1)]
#dp[i][j]はi番目のものを選んだ時かつダメージ送料がjだったときの最小MP、


for i in range(1,n+1):
    dp[i][0] = 0
    for j in range(h+1):
        a = ab[i-1][0]
        b = ab[i-1][1]
        elif j+a <= h:
            dp[i][j+a] = min(dp[i][j] + b, dp[i-1][j+a], dp[i][j+a])
        elif j+a > h:
            dp[i][h] = min(dp[i][j] + b, dp[i-1][h], dp[i][h])
            continue

print(dp[-1][-1])

### FIXED CODE ###

#from pprint import pprint
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from copy import deepcopy
#from itertools
#import sys 
#sys.setrecursionlimit(N) #N回まで再起を許可する。
 
# = map(int,input().split())
 
# = list(map(int,input().split()))
 
# = [list(map(int,input().split())) for _ in range(XXXX)]
from sys import stdin


def main():
    input = stdin.readline
    
    h,n = map(int,input().split())
    
    ab= [list(map(int,input().split())) for _ in range(n)]
    
    dp = [[float("inf") for _ in range(h+1)] for _ in range(n+1)]
    #dp[i][j]はi番目のものを選んだ時かつダメージ送料がjだったときの最小MP、
    
    
    for i in range(1,n+1):
        dp[i][0] = 0
        for j in range(h+1):
            a = ab[i-1][0]
            b = ab[i-1][1]
            dp[i][j] = min(dp[i][j],dp[i-1][j])
            if j+a <= h:
                dp[i][j+a] = min(dp[i][j] + b, dp[i-1][j+a], dp[i][j+a])
            elif j+a > h:
                dp[i][h] = min(dp[i][j] + b, dp[i-1][h], dp[i][h])

    
    print(dp[-1][-1])

if __name__ == "__main__":
    main()
import math

N, M = [int(i) for i in input().split(" ")]
S = input()
T = input()

def solve():
    gcd = math.gcd(N, M)
    for i in range(1, gcd + 1):
        if S[-int(N / gcd) * i] != T[-int(M / gcd) * i]:
            return -1
    return N * M / gcd

print(solve())

### FIXED CODE ###

import fractions
 
N, M = [int(i) for i in raw_input().split(" ")]
S = raw_input()
T = raw_input()
 
def solve():
    gcd = fractions.gcd(N, M)
    for i in range(1, gcd + 1):
        if S[-int(N / gcd) * i] != T[-int(M / gcd) * i]:
            return -1
    return int(N * M / gcd)
 
print(solve())
N = int(input('N: '))
K = int(input('K: '))
S = input('S: ')
S1 = ''
for i in range (N):
    if i + 1 == K:
        if S[i] == 'A':
            S1 += 'a'
        elif S[i] == 'B':
            S1 += 'b'
        elif S[i] == 'C':
            S1 += 'c'
    else:
        S1 += S[i]

print(S1)


### FIXED CODE ###

n, k = map(int, input().split())
s = list(input())
s[k-1] = chr(ord(s[k-1])+ord('a')-ord('A'))
print(''.join(s))
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

"""
・「必要」とは～～が存在
・x を含まない、[K-x,K) 内の総和が存在
・集合を指定すると、ある値段より上側
・全体としても単調性がある
"""

N,K,*A = map(int,read().split())

A.sort()
A = [x if x <= K else K + 1 for x in A]

mask = (1 << K) - 1

def test(x):
    # x 番目を抜いて
    dp = 1
    for a in itertools.chain(A[:x], A[x+1:]):
        dp |= (dp << a)
        dp &= mask
    dp >>= (K - x)
    return (dp > 0)

left = -1 # 必要
right = N # 不要
while left + 1 < right:
    x = (left + right) // 2
    if test(x):
        right = x
    else:
        left = x

answer = right
print(answer)

### FIXED CODE ###

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

import itertools

"""
・「必要」とは～～が存在
・x を含まない、[K-x,K) 内の総和が存在
・集合を指定すると、ある値段より上側
・全体としても単調性がある
"""

N,K,*A = map(int,read().split())

A = [x if x <= K else K + 1 for x in A]
A.sort()

mask = (1 << K) - 1

def test(x):
    # x番目は必要
    if A[x] > K:
        return True
    dp = 1
    for a in itertools.chain(A[:x], A[x+1:]):
        dp |= (dp << a)
        dp &= mask
    dp >>= (K - A[x])
    return (dp > 0)

left = -1 # 必要
right = N # 不要
while left + 1 < right:
    x = (left + right) // 2
    if test(x):
        right = x
    else:
        left = x

answer = left + 1
print(answer)
s = input()
t = input()
cnt = 0
for i in len(s):
  if s[i] != t[i]:
    cnt += 1
    
print(cnt)

### FIXED CODE ###

s = input()
t = input()
cnt = 0
for i in range(len(s)):
  if s[i] != t[i]:
    cnt += 1
    
print(cnt)
S = list(input())
s = sorted(list(set(S)))
l = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
     'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

ans = 'None'

for i in range(26):
    if s[i] != l[i]:
        ans = l[i]
        break

print(ans)

### FIXED CODE ###

S = list(input())
s = sorted(list(set(S)))
l = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
     'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

if s == l:
    ans = 'None'
else:
    for i in range(26):
        if (len(s) - 1) < i:
            ans = l[i]
            break
        elif s[i] != l[i]:
            ans = l[i]
            break

print(ans)
def koch(n, a, b):
  if n == 0:
    return
  s.x = (2*a.x* + b.x)/3
  s.y = (2*a.y* + b.y)/3
  t.x = (a.x* + 2*b.x)/3
  t.y = (a.y* + 2*b.y)/3
  u.x = (t.x - s.x)*cos(pi/3) - (t.y - s.y)*sin(pi/3) + s.x
  u.y = (t.x - s.x)*sin(pi/3) + (t.y - s.y)*cos(pi/3) + s.y

  koch(n-1, a, s)
  print  "%f %f" %(s.x, s.y)
  koch(n-1, s, u)
  print  "%f %f" %(u.x, u.y)
  koch(n-1, u, t)
  print  "%f %f" %(t.x, t.y)
  koch(n-1, t, b)

n = input()

p1.x = 0
p1.y = 0
p2.x = 100
p2.y = 0

print "%f %f" %(p1.x, p2.y)
koch(n, p1, p2)
print "%f %f" %(p1.x, p2.y)

### FIXED CODE ###

import math

rad = math.radians(60)

class coordinates:
  def __init__(self, x, y):
    self.x = x
    self.y = y
 
def koch(n, a, b):
  if n == 0:
    return
  s = coordinates((2.0*a.x + b.x)/3.0, (2.0*a.y + b.y)/3.0)
  t = coordinates((a.x + 2.0*b.x)/3.0, (a.y + 2.0*b.y)/3.0)
  ux = (t.x - s.x)*math.cos(rad) - (t.y - s.y)*math.sin(rad) + s.x
  uy = (t.x - s.x)*math.sin(rad) + (t.y - s.y)*math.cos(rad) + s.y
  u = coordinates(ux, uy)
  
  koch(n-1, a, s)
  print  s.x, s.y
  koch(n-1, s, u)
  print  u.x, u.y
  koch(n-1, u, t)
  print  t.x, t.y
  koch(n-1, t, b)
  
n = input()
  
p1 = coordinates(0.0, 0.0)
p2 = coordinates(100.0, 0.0)
  
print p1.x, p1.y
koch(n, p1, p2)
print p2.x, p2.y
s = list(input())
t = list(input())

dp = [ [ "" for i in range(3010)] for j in range(3010) ]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1)
        else:
            dp[i+1][j+1] = max(dp[i+1][j+1],dp[i+1][j])
            dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j+1])

i = len(s)-1
j = len(t)-1
while (i>0 and j>0):

### FIXED CODE ###

s = list(input())
t = list(input())

dp = [ [ 0 for i in range(3010)] for j in range(3010) ]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1)
        else:
            dp[i+1][j+1] = max(dp[i+1][j+1],dp[i+1][j])
            dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j+1])

i = len(s)-1
j = len(t)-1
ans = ""

while (i>=0 and j>=0):
    if dp[i+1][j+1] == dp[i+1][j]:
        j -= 1
    elif dp[i+1][j+1] == dp[i][j+1]:
        i -= 1
    else:
        ans = s[i] + ans
        i -= 1
        j -= 1

print(ans)
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, N = MAP()
A, B = ZIP(N)
max_A = max(A)

L = H+max_A+1
dp = np.zeros(L, dtype=np.int64)
dp[1:] = 10**18
n = 1
for w, v in zip(B, A):
	dp[v:v+n] = np.minimum(dp[v:v+n], dp[:n]+w)
	n += v

print(dp[H:].min())


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
import heapq

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, N = MAP()
A = [0]*N
B = [0]*N

for i in range(N):
    A[i], B[i] = MAP()

dp = [[INF]*(H+max(A)+1) for _ in range(N+1)]
dp[0][0] = 0

for i in range(N):
    for j in range(H+max(A)):
        if j < A[i]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j-A[i]]+B[i])

print(min(dp[N][H:]))
n = int(input())

count = 0
for i in range(n-1):
    for j in range(n):
        for k in range(n+1):
            if i + j + k == x: count+= 1

print(count)

### FIXED CODE ###

while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0: break
    count = 0
    for i in range(1,n - 1):
        for j in range(i + 1 ,n):
            if i + j + j + 1 > x: break
            for k in range(j + 1 ,n + 1):
                if i + j + k == x:
                    count += 1
                    break
    print(count)
import math
num=int(input())
a,b=num.split()

if a%2!=0 and b%2!=0:
    print("Yes")
else
    print("No")

### FIXED CODE ###

import math
num=input().split()
a=int(num[0])
b=int(num[1])

if a!=2 and b!=2:
    print("Yes")
else:
    print("No")
import numpy as np

n,k = map(int, input().split())
p_list = np.fromstring(input(), int, sep=' ')

Cumulative_sum = np.zeros(n+1)
Cumulative_sum[1:] = p_list.cumsum()

length_k_sum_list = Cumulative_sum[k:] - Cumulative_sum[0:-k]

print((length_k_sum_list.max()+k)/2)


### FIXED CODE ###

import sys
import numpy as np

val = np.fromstring(sys.stdin.buffer.read(), np.int64, sep=' ')
n,k = val[:2]
p_list = val[2:]

S = np.zeros(n+1, np.int64)
S[1:] = p_list.cumsum()

KS = S[k:] - S[0:-k]
print((KS.max()+k)/2)
a, b = map(float, input().split())

print(int(a * B))

### FIXED CODE ###

from math import floor
import decimal
a, b = input().split()
a = int(a)
b = decimal.Decimal(b)
#print(a, b)
#print(type(a), type(b))
print(floor(a * b))
A op B=map(int,raw_input.split())
print A op B 

### FIXED CODE ###

a,op,b=raw_input().split()
if op=="+":
  print int(a)+int(b)
else:
  print int(a)-int(b)
A,B = map(int, input().split())
if A+B %2 == 1:
    print('IMPOSSIBLE)
else:
    print((A+B)/2)

### FIXED CODE ###

A,B = map(int, input().split())
C=(A+B)/2
D=A+B
if D %2 > 0:
    print('IMPOSSIBLE')
elif D %2 == 0:
    print((A+B)//2)
N = int(input())
D = [input() for _ in range(N)]
print('Four' if len(set(D))==4 else 'Three')

### FIXED CODE ###

input()
print("Four" if "Y" in input() else "Three")
# -*- coding: utf-8 -*-
H, W = map(int, input().split())
if H > 1 and W > 1:
    print((H * W) // 2 + (H * W) % 2)
else
    print(1)

### FIXED CODE ###

# -*- coding: utf-8 -*-
H, W = map(int, input().split())
if H > 1 and W > 1:
    print((H * W) // 2 + (H * W) % 2)
else:
    print(1)
S = input()
ans = 0
# for i in range(len(S)-3):
#     for j in range(i+4, len(S)+1):
#         if int(S[i:j]) % 2019 == 0:
#             ans += 1
# #             break
# print(ans)
i = 0
while i < len(S)-3:
    for j in range(i+4, len(S)+1):
        if int(S[i:j]) % 2019 == 0:
            ans += 1
            i += j-5
    i += 1
print(ans)

### FIXED CODE ###

s = input()[::-1]
length = len(s)
a = [0] * length
d = [0] * length
ans = [0] * 2019
x = 10

a[0] = int(s[0])
d[0] = a[0]
ans[d[0]] += 1

for i in range(1, length):
    a[i] = int(s[i]) * x % 2019
    d[i] = (d[i-1] + a[i]) % 2019
    ans[d[i]] += 1
    x = x * 10 % 2019

ans_c = [i for i in ans if i != 0]

print(int(sum([ans_c[i] * (ans_c[i]-1) for i in range(len(ans_c))]) / 2) + ans[0])
def search(x, num):
    nodes.remove(x)
    search_list = []
    for y in list(edge[x]):
        edge[y].discard(x)
        if y in nodes:
            num = search(y, num)
    return num + 1


(n,m),*d  = [list(map(int, s.split())) for s in open(0)]

edge = [set() for _ in range(n+1)]
for x in d:
    edge[x[0]].add(x[1])
    edge[x[1]].add(x[0])

nodes = set(range(1,n+1))
ans = 1
for x in list(nodes):
    if x not in nodes:
        continue
    tmp = search(x, 0)
    ans = max(tmp, ans)
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(int(1e6))

def search(x, num):
    nodes.remove(x)
#     for y in edge[x]:
#         edge[y].discard(x)
#     for y in list(edge[x]):
    for y in edge[x]:
        if y in nodes:
            num = search(y, num)
    return num + 1

(n,m),*d  = [list(map(int, s.split())) for s in open(0)]

edge = [set() for _ in range(n+1)]
for x in d:
    edge[x[0]].add(x[1])
    edge[x[1]].add(x[0])

nodes = set(range(1,n+1))
ans = 1
for x in list(nodes):
    if x in nodes:
        ans = max(ans, search(x, 0))
print(ans)
[n, m] = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()
for i in range(m):
    a[-1] = int(a[-1] / 2)
    a.sort()
print(sum(a))

### FIXED CODE ###

[n, k] = [int(i) for i in input().split()]
total = 0
for i in range(1, n+1):
    point = i
    prob = 1/n
    while(point < k):
        point *= 2
        prob /= 2
    total += prob
print(total)
def testA():
    max_num = 0
    for i in range(10 ** 8):
        if max_num < i:
            max_num = i
    return max_num
monster, hisatu = map(int, input().split())
m_life = list(map(int, input().split()))
count = 0
if hisatu >= len(m_life):
    print(0)
else:
    while hisatu > 0:
        m_life.remove(testA(m_life))
        hisatu -= 1
    for i in m_life:
        count += i
    print(count)


### FIXED CODE ###

monster, hisatu = map(int, input().split())
m_life = list(map(int, input().split()))
m_life.sort()
count = 0
for i in range(len(m_life)-hisatu):
    count += m_life[i]
print(count)
N=int(input())
b=[int(i) for i in input().split()]
import numpy as np
import math
def ordering(N,b):
    a=[]
    comb=math.factorial(N)
    x=[[]]*comb
    y=[[]]*comb
    for i in range(1,N):
        a=a+[i]
        for n,m in enumerate(a):
            x[n].insert(m-1,m)
            y[n].append(m)
    resnum=[x.index(i) for i in x if i==b]
    try:
        for i in y[resnum[0]]:
            print(i)
    except:
        return(-1)
print(ordering(N,b))


### FIXED CODE ###

N=int(input())
b=[int(i) for i in input().split()]
a=[]
try:
    while len(b)>0:
        a2=max([j for i,j in enumerate(b) if b[i]==i+1])
        a.insert(0,a2)
        x=b.pop(a2-1)
    for n in a:
        print(n)
except:
    print(-1)