Problem:
 Score : 400 points    Problem Statement  You are given a permutation p of the set { 1, 2, ..., N }. Please construct two sequences of positive integers a_1 , a_2 , ..., a_N and b_1 , b_2 , ..., b_N satisfying the following conditions:   1 \leq a_i, b_i \leq 10^9 for all i  a_1 < a_2 < ... < a_N  b_1 > b_2 > ... > b_N  a_{p_1}+b_{p_1} < a_{p_2}+b_{p_2} < ... < a_{p_N}+b_{p_N}       Constraints  2 \leq N \leq 20,000  p is a permutation of the set { 1, 2, ..., N }         Input The input is given from Standard Input in the following format:  N  p_1  p_2  ...  p_N       Output The output consists of two lines. The first line contains a_1 , a_2 , ..., a_N seperated by a space. The second line contains b_1 , b_2 , ..., b_N seperated by a space.  It can be shown that there always exists a solution for any input satisfying the constraints.        Sample Input 1 2
1 2      Sample Output 1 1 4
5 4  a_1 + b_1 = 6 and a_2 + b_2 = 8 . So this output satisfies all conditions.       Sample Input 2 3
3 2 1      Sample Output 2 1 2 3
5 3 1       Sample Input 3 3
2 3 1      Sample Output 3 5 10 100
100 10 1

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    h,w = LI()
    a = SR(h)
    d = [(1,0),(0,1)]
    bfs = [[1]*w for i in range(h)]
    for y in range(h):
        for x in range(w):
            if a[y][x] == "
                bfs[y][x] = 0
                q = deque([(y,x)])
                while q:
                    i,j = q.popleft()
                    k = 0
                    for dy,dx in d:
                        ni = i+dy
                        nj = j+dx
                        if 0 <= ni < h and 0 <= nj < w:
                            if a[ni][nj] == "
                                if k:
                                    print("Impossible")
                                    return
                                k = 1
                                bfs[ni][nj] = 0
                                q.append((ni,nj))
                for i in range(h):
                    for j in range(w):
                        if a[i][j] == "
                            print("Impossible")
                            return
                print("Possible")
                return
    return


def B():
    n = I()
    p = LI()
    a = [0]*n
    b = [0]*n
    for i in range(n):
        a[p[i]-1] += i
        b[p[i]-1] += i
    for i in range(n-1):
        a[i+1] += a[i]
    for i in range(n-1)[::-1]:
        b[i] += b[i+1]
    for i in range(n):
        a[i] += i+1
        b[i] += n-i
    print(*a)
    print(*b)
    return


def C():

    return


def D():

    return


def E():

    return


def F():

    return


if __name__ == "__main__":
    B()

Solution (Python):



import sys
import math
import bisect
import time
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
p = LI()
a = [i*n for i in range(1,n+1)]
b = a[::-1]
for i in range(n):
    a[p[i]-1] += i
print(*a)
print(*b)

Solution (Python):
N = int(input())
P = list(map(int,input().split()))

A = [i*(10**4*2+1)+1 for i in range(N)]
B = list(reversed(A))
for i in range(N):
    B[P[i]-1] += i

for i in A:
    print(i,end = " ")
print()
for i in B:
    print(i,end = " ")

Solution (Python):
N = int(input())
P = [int(x) for x in input().split()]
R = [1]*N
for ind,p in enumerate(P):
    R[p-1]+=ind
A = [30000*i for i in range(1,N+1)]
B = [30000*(N-i-1) + R[i] for i in range(N)]
print(*A)
print(*B)

Solution (Python):
n = int(input())
p = list(map(int, input().split()))

a = [20001*i + 1  for i in range(n)]
b = [20001*i + 1  for i in range(n)][::-1]

for i in range(n):
    a[p[i] - 1] += i
print(*a)
print(*b)

Solution (Python):
n=int(input())
p=list(map(int,input().split()))
print(*[30000*i for i in range(1,n+1)])
b=[30000*(n-i)for i in range(n)]
for i in range(n):
    b[p[i]-1]+=i
print(*b)

Solution (Python):
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def sol():
    N = int(input())
    P = list(map(int, input().split()))

    index = [-1] * (N + 1)
    for i, p in enumerate(P):
        index[p] = i + 1

    offset = 30000
    A = [0] * N
    B = [0] * N
    for i, p in enumerate(P):
        A[i] = index[i + 1] + offset * (i + 1)
        B[i] = offset * N - offset * i

    print(*A)
    print(*B)


sol()

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *

N = int(input())
P = list(map(int, input().split()))
a = [i*N for i in range(1, N+1)]
b = a[::-1]
for i, p in enumerate(P):
    a[p-1] += i
print(*a)
print(*b)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
P = [int(x) for x in input().split()]

L = 2*N+100

A = [None] + [L*i for i in range(1,N+1)]
B = [None] + [L*(N+1-i) for i in range(1,N+1)]

for i,p in enumerate(P,1):
    A[p] += i

print(' '.join(map(str,A[1:])))
print(' '.join(map(str,B[1:])))

Solution (Python):
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
P = list(map(int, sys.stdin.readline().split()))

A = np.zeros(N, dtype=int)
B = np.zeros(N, dtype=int)

for i, p in enumerate(P):
    A[p - 1] = i

for i in range(1, N):
    diff = max(A[i - 1] - A[i] + 1, B[i] - B[i - 1] + 1, 0)
    A[i] += diff
    B[i] -= diff

A -= A.min() - 1
B -= B.min() - 1

print(*A)
print(*B)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
b=[None for _ in range(n)]
for i,j in enumerate(a):b[j-1]=i
print(*[20001*i+b[i]+1 for i in range(n)])
print(*[20001*(n-i) for i in range(n)])

Solution (Python):
N = int(input())
p = list(map(int, input().split()))

A = [(N * i) + 1  for i in range(N)]
B = [(N * (N -i - 1) + 1) for i in range(N)]

for i in range(N):
    A[p[i] - 1] += i

print (*A)
print (*B)

Solution (Python):
N = int(input())
*P, = map(int,input().split())

d = 21000
A = [i*d for i in range(N)]
B = A[::-1]
for i,p in enumerate(P,1):
    A[p-1]+=i
    B[p-1]+=i
print(*A)
print(*B)

Solution (Python):
N=int(input())
p=list(map(int,input().split()))
M,S=10**9,30000
a=list(range(1,S*N,S))
b=list(reversed(a))
for i in range(N-1):
    b[p[i+1]-1]+=i+1
print(*a)
print(*b)

Solution (Python):
N = int(input())
P = list(map(lambda x: int(x)-1, input().split()))

A = [i*N for i in range(1,N+1)]
B = A[::-1]

for i,p in enumerate(P) :
    A[p] += i
    B[p] += i

print(*A)
print(*B)

Solution (Python):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
p = list(li_())

a = [i*n for i in range(1, n+1)]
b = [i*n for i in range(1, n+1)][::-1]

for i, pi in enumerate(p):
    a[pi] += i
    b[pi] += i

print(*a)
print(*b)

Solution (Python):
N = int(input())
*P, = map(int, input().split())
M = 30000
A = [M*i + 1 for i in range(N)]
B = [M*(N-i) for i in range(N)]
for i, p in enumerate(P):
    A[p-1] += i
print(*A)
print(*B)

Solution (Python):
n=int(input())
arr=list(map(int,input().split()))
ans1=[40000*i for i in range(1,n+1)]
ans2=[40000*i for i in range(n,0,-1)]
for i in range(n):
  ans1[arr[i]-1]+=i
print(*ans1)
print(*ans2)

Solution (Python):
n = int(input())
p = list(map(int, input().split()))

a = [n*(i+1) for i in range(n)]
b = [0 for i in range(n)]

for i in range(n):
    j = p[i]-1
    b[j]= n*(n+1)-a[j]+i

print(' '.join(map(str,a)))
print(' '.join(map(str,b)))

Solution (Python):
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N = int(input())
p = list(map(int,input().split()))
d = defaultdict(int)
for i in range(N):
    d[p[i]] = i
a,b = [],[]
for i in range(1,N+1):
    a.append(N*i+d[i])
    b.append((N-i+1)*N+d[i])
print(*a,sep=" ")
print(*b,sep=" ")

Solution (Python):
n = int(input())
p = [int(item) for item in input().split()]

a = []
for i in range(n):
    a.append(20001 * (i+1))
b = list(reversed(a))

for i, item in enumerate(p):
    a[item-1] -= n - i
    b[item-1] -= n - i
print(" ".join([str(item) for item in a]))
print(" ".join([str(item) for item in b]))

Solution (Python):
N = int(input())
p = list(map(int,input().split()))
a = [N*(k+1) for k in range(N)]
b = [N*(N-k) for k in range(N)]
for k in range(N):
    b[p[k]-1] += k
print(*a, sep = " ")
print(*b, sep = " ")

Solution (Python):
N = int(input())
p = list(map(int, input().split()))

a = [(i + 1) * N for i in range(N)]
b = [(N - i) * N for i in range(N)]

for i, pi in enumerate(p):
    a[pi - 1] += i

print(' '.join(map(str, a)))
print(' '.join(map(str, b)))

Solution (Python):

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

for i in range(N):
    p_arr[i] -= 1

a_arr = [N*i + 1 for i in range(N)]
b_arr = [0]*N
for i in range(N):
    b_arr[p_arr[i]] = N*(N - p_arr[i]) + i + 1

a_output = ""
b_output = ""
for i in range(N):
    a_output += str(a_arr[i])
    b_output += str(b_arr[i])
    if i == N-1:
        continue
    else:
        a_output += " "
        b_output += " "

print(a_output)
print(b_output)

Solution (Python):
import numpy as np

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

p_arr = np.array(p_lst) - 1

a_arr = [N*i + 1 for i in range(N)]
b_arr = [0]*N
for i in range(N):
    b_arr[p_arr[i]] = N*(N - p_arr[i]) + i + 1

a_output = ""
b_output = ""
for i in range(N):
    a_output += str(a_arr[i])
    b_output += str(b_arr[i])
    if i == N-1:
        continue
    else:
        a_output += " "
        b_output += " "

print(a_output)
print(b_output)

Solution (Python):
N = int(input())
P = list(map(int, input().split()))
geta = 30000

A = [i*geta + 1 for i in range(N)]
B = [(N-1-i)*geta + 1 for i in range(N)]

for i, p in enumerate(P):
    A[p-1] += i
print(*A)
print(*B)

Solution (Python):
n = int(input())
plist = list(map(int, input().split()))
pd = {}
for i, p in enumerate(plist):
  pd[p] = i + 1

al = [30000 * i for i in range(1, n+1)]
print(*al)
bl = [30000 * (n - i) + pd[i] for i in range(1, n+1)]
print(*bl)

Solution (Python):
n = int(input())
p = list(map(int, input().split()))

a = [1+i*n for i in range(n)]
b = [0]*n
for i, pi in enumerate(p):
    b[pi-1] = i - a[pi-1]
min_b = abs(min(b))+1
for i in range(n):
    b[i] += min_b
print(*a)
print(*b)

Solution (Python):
n = int(input())
p = list(map(int, input().split()))
a = [(i+1) * 2*10**4 for i in range(n)]
b = [(n-i) * 2*10**4 for i in range(n)]
for i in range(n):
    a[p[i]-1] += i
print(" ".join(list(map(str, a))))
print(" ".join(list(map(str, b))))

Solution (Python):
N = int(input())
p = list(map(int, input().split()))
q = [0] * N
for i in range(N):
    q[p[i] - 1] = i
for i in range(N):
    print(30000 * i + 1, end = "")
    if i == N - 1:
        print()
    else:
        print(end = " ")
for i in range(N):
    print(30000 * (N - i) + q[i] + 1, end = "")
    if i == N - 1:
        print()
    else:
        print(end = " ")

Solution (Python):
N = int(input())
p = list(map(int, input().split()))
q = [0] * N
for i in range(N):
    q[p[i] - 1] = i
for i in range(N):
    print(30000 * i + 1, end = "")
    if i == N - 1:
        print()
    else:
        print(end = " ")
for i in range(N):
    print(30000 * (N - i) + q[i] + 1, end = "")
    if i == N - 1:
        print()
    else:
        print(end = " ")

Solution (Python):
n = int(input())
x = list(map(int, input().split()))

a = [20001*i for i in range(1,n+1)]
b = [20001*(n+1-i) for i in range(1,n+1)]

for i in range(n):
    b[x[i]-1] += i
    
for x in a:print(x, end=' ')
print()
for x in b:print(x, end=' ')

Solution (Python):
a = int(input())
x = list(map(int,input().split()))
t = range(1,a+1)
A = []
B = []
for i in range(1,a+1):
    A.append(30000*i)
    B.append(30000*(a-i+1))
for i ,d in enumerate(x):
    A[d-1] -= a-i
print(*A)
print(*B)

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
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 II(): return int(sys.stdin.readline())
def SI(): return input()

from itertools import accumulate

def main():
    N = II()
    P = LI()
    T = [1] * N
    for i, p in enumerate(P):
        T[p - 1] += i
    A = list(accumulate(T))
    B = list(accumulate(T[::-1]))[::-1]
    print(*A)
    print(*B)

    return 0

main()

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
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 II(): return int(sys.stdin.readline())
def SI(): return input()

from itertools import accumulate

def main():
    N = II()
    P = LI()
    T = [1] * N
    for i, p in enumerate(P):
        T[p - 1] += i
    A = list(accumulate(T))
    B = list(accumulate(T[::-1]))[::-1]
    print(*A)
    print(*B)

    return 0

main()

Solution (Python):
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    P = [int(input_raw[i]) for i in range(N)]
    P_inv = {}

    A = {}
    B = {}
    A[P[0]] = P[0] * N + 1
    B[P[0]] = P[0] * N + 1
    min_B = B[P[0]]
    min_A = A[P[0]]
    for i in range(1, N):

        if P[i] > P[i - 1]:
            A[P[i]] = A[P[i - 1]]  + N*(P[i] - P[i - 1])
            B[P[i]] = B[P[i - 1]] - N *(P[i] - P[i - 1])
        else:
            A[P[i]] = A[P[i - 1]]  - N *(P[i - 1] - P[i])
            B[P[i]] = B[P[i - 1]] + N *(P[i - 1] - P[i])
        min_A = min(min_A, A[P[i]])
        min_B = min(min_B, B[P[i]])

    for i in range(1, N + 1):
        A[P[i - 1]] += -min_A + 1
        B[P[i - 1]] += -min_B + 1
    for i in range(1, N + 1):
        A[P[i - 1]] += i
    for i in range(1, N + 1):
        print A[i],
    print
    for i in range(1, N + 1):
        print B[i],





if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())

p = list(map(int,input().split()))
q = [0 for i in range(N)]
for i in range(N):
    q[p[i]-1]=i
    
A = 0
B = 10**9+1
ans_a = []
ans_b = []
for i in range(N):
    A+=q[i]
    if i!=0:
        B-=q[i-1]
    A+=1
    B-=1
    ans_a.append(A)
    ans_b.append(B)
    
print(*ans_a)
print(*ans_b)

Solution (Python):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
n=int(input())
P=list(map(int,input().split()))
A,B=[],[]
for i in range(1,n+1):
    A.append(25000*i)
    B.append(25000*(n-i+1))
for i,p in enumerate(P):
    A[p-1]+=i
print(*A)
print(*B)

Solution (Python):
N = int(input())
p_list = list(map(int, input().split()))

r = {}
for i in range(N):
    r[p_list[i]] = i + 1

a_list = []
b_list = []
for i in range(1, N + 1):
    a_list.append(30000 * i)
    b_list.append(30000 * (N - i) + r[i])

print(*a_list)
print(*b_list)

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

A = [N*i+1 for i in range(1, N+1)]
B = list(reversed(A))

for i, p in enumerate(P):
    A[p-1] -= N-i
print(*A)
print(*B)

Solution (Python):


import sys


INF = float('inf')
MOD = 10 ** 9 + 7

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 LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    P = LI()

    
    A = [n * i + 1 for i in range(1, n + 1)]
    B = A[::-1]

    
    
    
    
    for i, p in enumerate(P):
        A[p - 1] -= n - i

    print(*A)
    print(*B)
    


main()

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]

a = [20000*i+1 for i in range(N)]
b = [20000*(N-i) for i in range(N)]

for i in range(N):
  a[A[i]-1] += i

a = [str(i) for i in a]
b = [str(i) for i in b]

print(" ".join(a))
print(" ".join(b))

Solution (Python):
n = int(input())
p = list(map(int, input().split()))

a = [0] * (n+1)
b = [0] * (n+1)

for i in range(n):
    if i == 0:
        continue
    a[p[i]-1] += i
    a[n] -= i
    b[0] += i
    b[p[i]] -= i

for i in range(n):
    a[i+1] += a[i]
    b[i+1] += b[i]

for i in range(n):
    ai = i+1
    bi = n-i
    a[i] += ai
    b[i] += bi

print(*a[:n])
print(*b[:n])

Solution (Python):
from random import shuffle
from collections import Counter
def inpl(): return list(map(int, input().split()))





N = int(input())
P = inpl()

A = [0]*N
B = [0]*N
S = [10**9 - N] * (N)
for i, p in enumerate(P):
    S[p-1] += i

A[0] = 1
B[0] = S[0] - 1

for i in range(1, N):
    A[i] = max(A[i-1] + 1, S[i] - B[i-1] + 1)
    B[i] = S[i] - A[i]

for i in range(N-1):
    assert A[i] < A[i+1]
    assert B[i] > B[i+1]

assert B[-1] > 0
print(*A)
print(*B)

Solution (Python):
n=int(input())
x=list(map(int, input().split()))
a=list(range(1,n*30000+1,30000))
b=list(range(n*30000,0,-30000))
for i,j in enumerate(x):
    b[j-1]+=i
print(*a)
print(*b)

Solution (Python):
N = int(input())
p = list(map(lambda x: int(x) - 1, input().split()))
r = {}
for i in range(N):
    r[p[i]] = i + 1

A = [30000 * i for i in range(1, N + 1)]
B = [30000 * (N - i) + r[i - 1] for i in range(1, N + 1)]
print(*A)
print(*B)

Solution (Python):
n = int(input())
p = [int(m) for m in input().split()]

a = [i * n + (i - 1) for i in range(1, n + 1)]
b = [i * n + (i - 1) for i in range(n, 0, -1)]

for i in range(n):
    a[p[i] - 1] += i + 1

for i in range(n):
    print(a[i],"", end="")
print()
for i in range(n):
    print(b[i],"", end="")

Solution (Python):
N = int(input())
P = [int(_) - 1 for _ in input().split()]
Q = sorted([(P[i], i) for i in range(N)])

A = [1]
B = [10**9]

for i in range(1, N):
    d = Q[i][1] - Q[i - 1][1]
    if d > 0:
        A += [A[-1] + d + 1]
        B += [B[-1] - 1]
    else:
        A += [A[-1] + 1]
        B += [B[-1] + d - 1]
print(*A, sep=" ")
print(*B, sep=" ")

Solution (Python):
N=int(input())
P=[int(i) for i in input().split()]
Q=[0]*N
for i in range(N):
    Q[P[i]-1]=i
L=30000
A=[L*(i) for i in range(1,N+1)]
B=[L*(N+1-i) + Q[i-1] for i in range(1,N+1)]
print(' '.join(map(str,A)))
print(' '.join(map(str,B)))

Solution (Python):
N = int(input())
P = list(map(int,input().split()))
A = [45678 * i for i in range(1, N + 1)]
B = A[::-1]
for i, p in enumerate(P):
    A[p - 1] += i
    B[p - 1] += i
print(*A)
print(*B)

Solution (Python):
N=int(input())
p=list(map(int,input().split()))
P=[]
for j in range(len(p)):
    P.append([p[j],j])
P.sort()
a=[]
b=[]

for i in range(1,len(p)+1):
    a.append(str(i*20001+P[i-1][1]))
    b.append(str((len(p)+1-i)*20001+P[i-1][1]))
    
print(" ".join(a))
print(" ".join(b))

Solution (Python):
n = int(input())
p = list(map(int,input().split()))

a = [0] * n
b = [0] * n
c = []

for i in range(n):
    a[i] = 30000*(i+1)+5
    b[i] = 30000*(n-i-1)+5

for i in range(n):
    k = p[i]
    b[k-1] += i

res = ''
ans = ''
for i in range(n):
    if i == n-1:
        res += str(a[i])
        ans += str(b[i])
    else:
        res += str(a[i]) + ' '
        ans += str(b[i]) + ' '

print(res)
print(ans)

Solution (Python):
n = int(input())
p = list(map(int,input().split()))
a = []
b = []
x = [0]*n
for i in range(n):
  x[p[i]-1] = 800000000+i
a.append(1)
b.append(x[0]-1)
for i in range(1,n):
  y = a[-1]+1
  z = b[-1]-1
  if y+z>x[i]:
    z = x[i]-y
  if y+z <x[i]:
    y = x[i]-z
  a.append(y)
  b.append(z)
print(*a)
print(*b)

Solution (Python):
N=int(input())
p=[(int(a),i+1) for i,a in enumerate(input().split())]
p.sort()
a=[0]*N
b=[0]*N
a[0]=p[0][1]
b[0]=10**9
for i in range(1,N):
  if p[i][1]>p[i-1][1]:
    a[i]=a[i-1]+p[i][1]-p[i-1][1]+1
    b[i]=b[i-1]-1
  if p[i][1]<p[i-1][1]:
    a[i]=a[i-1]+1
    b[i]=b[i-1]+p[i][1]-p[i-1][1]-1
    
print(" ".join(list(map(str,a))))
print(" ".join(list(map(str,b))))

Solution (Python):
N = int(input())
p = list(map(int,input().split()))

q = [0 for i in range(N)]

for i in range(N):
    q[p[i]-1]=i+1

a = [str((i+1)*N)  for i in range(N)]
b = [str((N-i-1)*N + q[i]) for i in range(N)]
print(" ".join(a))
print(" ".join(b))

Solution (Python):
N = int(input())
P = [int(p) for p in input().split()]

A = [30000 * i for i in range(1, N+1)]
R = [0 for i in range(N)]
for i in range(N):
    R[P[i]-1] = i+1
B = [30000 * (N-i) + R[i-1] for i in range(1, N+1)]

print(" ".join(map(str, A)))
print(" ".join(map(str, B)))

Solution (Python):
def inpl(): return [int(i) for i in input().split()]
import numpy as np
N = int(input())
p = inpl()

a = np.array(range(1,N+1))
b = np.array(range(1,N+1))
c = np.zeros((N,1), dtype = int)
d = np.zeros((N,1), dtype = int)
for i in range(N):
    c[p[i]-1] += i+1
    d[N-p[i]] += i+1
print(*(a+np.cumsum(c)))
print(*(b+np.cumsum(d))[::-1])

Solution (Python):
N = int(input())
P = [int(i) for i in input().split()]
asum = [1] * (N + 1)
bsum = [-1] * (N + 1)
bsum[0] = N
for i in range(N):
    p = P[i] - 1
    asum[p + 1] += 20000 - i
    bsum[0] += 20000 - i
    bsum[p] -= 20000 - i
a = [0] * N
b = [0] * N
a[0] = asum[0]
b[0] = bsum[0]
for i in range(1, N):
    a[i] = a[i - 1] + asum[i]
    b[i] = b[i - 1] + bsum[i]
for i in range(N):
    print(a[i], end=' ')
print()
for i in range(N):
    print(b[i], end=' ')

Solution (Python):
n = int(input())
p = list(map(int, input().split()))

a = [i * 20000 for i in range(n)]
b = [(n - i - 1) * 20000 for i in range(n)]

for i, c in enumerate(p):
    a[c - 1] += i + 1
    b[c - 1] += i + 1

print(" ".join(map(str, a)))
print(" ".join(map(str, b)))

Solution (Python):
n = int(input())

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

a = [(i+1)*n for i in range(n)]
b = [(n-i)*n for i in range(n)]

for i in range(n):
    a[p[i]-1] -= n-i-1
    
sa = ""
sb = ""
for i in range(n):
    sa = sa + str(a[i])
    sb = sb + str(b[i])
    if i != n-1:
        sa = sa + ' '
        sb = sb + ' '
        
print(sa)
print(sb)

Solution (Python):
from itertools import accumulate

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

ds = [0] * N
for i, p in enumerate(ps):
    ds[p - 1] = N - i

As = accumulate([1] + ds[:-1])
Bs = reversed(list(accumulate([1] + ds[1:][::-1])))
print(' '.join(map(str, As)))
print(' '.join(map(str, Bs)))

Solution (Python):
n=int(input())
c=list(map(int, input().split()))
a=list(range(n,n**2+1,n))
b=a[::-1]
for i in range(n):
    b[c[i]-1]+=i
print(*a)
print(*b)

Solution (Python):
n=int(input())
c=list(map(int, input().split()))
a=list(range(n,n**2+1,n))
b=list(range(n**2,0,-n))
for i in range(n):
    b[c[i]-1]+=i
    
for i in a:
    print(i,end=' ')
print()
for i in b:
    print(i,end=' ')
print()

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
lis = [40000 * i + 1 for i in range(n)]
li = [str(40000 * (n-i) + 1) for i in range(n)]
for i in range(n):
  lis[a[i]-1] += i
  lis[a[i]-1] = str(lis[a[i]-1])
print(" ".join(lis))
print(" ".join(li))

Solution (Python):
a=range(1,8**5*int(input())+1,8**5);*b,=a[::-1];print(*a)
for t,i in enumerate(input().split()):b[int(i)-1]+=t
print(*b)

Solution (Python):
p=20000;a=range(p,p*int(input())+1,p);*b,=a[::-1];print(*a)
for t,i in enumerate(input().split()):b[int(i)-1]+=t
print(*b)

Solution (Python):
n=int(input());p=20000;a=range(p,p*n+1,p);*b,=a[::-1];print(*a)
for t,i in enumerate(input().split()):b[int(i)-1]+=t
print(*b)

Solution (Python):
n=int(input());p=20000;a=range(p,p*n+1,p);*b,=a[::-1];print(*a)
for t,i in zip(range(n),input().split()):b[int(i)-1]+=t
print(*b)

Solution (Python):
N = int(input())
p = list(map(int, input().split()))
a = [N * i for i in range(1, N + 1)]
b = [N * i for i in range(N, 0, -1)]
for i, v in enumerate(p):
    a[v - 1] += i
print(*a)
print(*b)

Solution (Python):
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())


n = ni()
p = li_()

a = [i*n + 1 for i in range(n)]
b = a[::-1]

ad = 0
for pi in p:
    a[pi] += ad
    b[pi] += ad
    ad += 1
    
print(*a)
print(*b)

Solution (Python):
f = lambda: map(int, input().split())
n = int(input())
p = list(f())
m = 3*10**4
k = 10**9
a = [i*m for i in range(1, n+1)]
b = [k-a[i] for i in range(n)]
for i in range(n):
    b[p[i]-1] += i
print(*a)
print(*b)

Solution (Python):
N=int(input())
P=[int(i)-1 for i in input().split()]
M=30000
R=[0 for i in range(N)]
for i in range(N):
    R[P[i]]=i+1
A=[str(M*i) for i in range(1,N+1)]
B=[str(M*(N+1-i)+R[i-1]) for i in range(1,N+1)]
print(" ".join(A))
print(" ".join(B))

Solution (Python):
n=int(input())
*l,=map(int,input().split())

*a,=range(1,30000*n+1,30000)
b=a[::-1]

for i,j in enumerate(l):
  b[j-1]+=i

print(*a)
print(*b)

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, P):
    M = 30000
    a = []
    b = []
    for i in range(1, N+1):
        a.append(i*M+1)
        b.append((N-i+1)*M + 1)
    for i, p in enumerate(P):
        a[p-1] += i

    return '\n'.join([' '.join(map(str, a)), ' '.join(map(str, b))])


def main():
    N = read_int()
    P = read_int_n()
    print(slv(N, P))


if __name__ == '__main__':
    main()

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, P):
    M = 30000
    a = []
    b = []
    for i in range(1, N+1):
        a.append(i*M+1)
        b.append((N-i+1)*M + 1)
    for i, p in enumerate(P):
        a[p-1] += i

    return '\n'.join([' '.join(map(str, a)), ' '.join(map(str, b))])


def main():
    N = read_int()
    P = read_int_n()
    print(slv(N, P))


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
p = list(map(int, input().split()))
p = [(x-1, i+1) for i, x in enumerate(p)]
p.sort()

a = [0]*n
b = [0]*n

for i, j in p:
    a[i] = (n+1)*i+1
    b[i] = (n+1)*(n-i)+j

f = lambda x: " ".join(list(map(lambda n: str(n), x)))
print(f(a))
print(f(b))

Solution (Python):
def main():
    n = int(input())
    p = list(map(int, input().split()))

    c = [0 for i in range(n)]
    for i in range(n):
        c[p[i]-1] = i + 1

    a, b = [None for i in range(n)], [None for i in range(n)]
    for i in range(n):
        a[i] = str(30000 * (i+1))
        b[i] = str(30000 * (n-i) + c[i])

    print(" ".join(a))
    print(" ".join(b))


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
p = list(map(int, input().split()))
p_index = sorted([[p[i], i] for i in range(n)], key=lambda x: x[0])
q = [p_index[i][1] for i in range(n)]

a = [n * (i + 1) for i in range(n)]
b = list(reversed(a))

a = [a[i] + q[i] - 1 for i in range(n)]

print(" ".join(list(map(str, a))))
print(" ".join(list(map(str, b))))

Solution (Python):
N = int(input())
P = [int(_) for _ in input().split()]

a = [1] * N
b = [N] + [-1] * (N - 1)

for i, x in enumerate(P):
    a[x - 1] += i
    b[0] += i
    if x < N:
        b[x] -= i

from itertools import accumulate

print(*accumulate(a))
print(*accumulate(b))

Solution (Python):
N = int(input())
P = list(map(int, input().split()))
A = list(range(30000, 30000*(N+1), 30000))
B = list(range(30000*N, 0, -30000))
for i, p in enumerate(P):
    A[p-1] += i
print(*A)
print(*B)

Solution (Python):
N=int(input())
P=[int(x) for x in input().split()]

A=[]
B=[]

for i in range(N):
  A.append((i+1)*N)
  B.append((N-i)*N)

for i in range(N):
  A[P[i]-1]+=i

print(*A)
print(*B)

Solution (Python):
N = int(input())
p = list(map(int, input().split()))

a = list(range(1, N**2+1, N+1))
b = list(range(N**2+1, 1, -(N+1)))

for i in range(N):
    a[p[i]-1] += i
    b[p[i]-1] += i

a = map(str, a)
b = map(str, b)

print(" ".join(a))
print(" ".join(b))