https://www.acmicpc.net/problem/2751
import sys
test_case = int(input())
numbers = []
for _ in range(test_case):
num = int(sys.stdin.readline())
numbers.append(num)
def merge(list1, list2):
return sorted(list1+list2)
def merge_sort(items):
if len(items) ==1:
return items
mid = len(items)//2
left = merge_sort(items[:mid])
right = merge_sort(items[mid:])
return merge(left, right)
rlt = merge_sort(numbers)
print(rlt)
# print('\n'.join(map(str, rlt)))
import sys
test_case = int(input())
numbers = []
for _ in range(test_case):
num = int(sys.stdin.readline())
numbers.append(num)
numbers.sort()
for num in numbers:
print(num)
import sys
# sys.setrecursionlimit(10**7)
count = int(input())
numbers = []
for _ in range(count):
num = int(sys.stdin.readline())
numbers.append(num)
def q(numbers, v):
if(len(numbers)==0):
return
p = v / 2
#numbers[0]
l = list(filter(lambda x : x < p, numbers))
if(len(l)==len(numbers)):
for x in sorted(l):
print(x)
else:
q(l, int(v * 0.25))
l = list(filter(lambda x : x >= p, numbers))
if(len(l)==len(numbers)):
for x in sorted(l):
print(x)
else:
q(l, int(v * 0.75))
pass
q(numbers, 1000000)
import sys
def merge_sort(array):
if len(array) <= 1:
return array
mid = len(array) // 2
left = merge_sort(array[:mid])
right = merge_sort(array[mid:])
i, j, k = 0, 0, 0
while i < len(left) and j < len(right):
if left[i] < right[j]:
array[k] = left[i]
i += 1
else:
array[k] = right[j]
j += 1
k += 1
if i == len(left):
while j < len(right):
array[k] = right[j]
j += 1
k += 1
elif j == len(right):
while i < len(left):
array[k] = left[i]
i += 1
k += 1
return array
n = int(input())
array = []
for _ in range(n):
array.append(int(sys.stdin.readline()))
array = merge_sort(array)
print('\n'.join(map(str, array)))
import sys
n = int(input())
array = []
for _ in range(n):
array.append(int(sys.stdin.readline()))
array = sorted(array)
print('\n'.join(map(str, array)))