Problem:


問題 3

　入力ファイルの１行目に正整数 n （n≧3）が書いてあり，
つづく n 行に異なる正整数 a1, ..., an が
１つずつ書いてある．
a1, ..., an から異なる２個を選んで作られる
順列を（数として見て）小さい順に並べたとき，
３番目に来るものを出力せよ．

　ただし，
例えば，a1 = 1，a4 = 11 のような場合も，
a1a4 と a4a1 は異なる順列とみなす．
また，
1≦ai≦10000 (i=1, ..., n) かつ 3≦n≦104 である．

出力ファイルにおいては，
出力の最後にも改行コードを入れること．

入出力例

入力例１

3
2
7
5

出力例１

52

入力例２

4
17
888
1
71

出力例２

171

問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。



Sample input:
3
2
7
5


Sample output:
52

Submission status: Wrong Answer

Solution code:
n = int(input())

min1 = min2 = min3 = 10001

for i in range(n) :
    num = int(input())
    if num < min1 :
        min2, min3 = min1, min2
        min1 = num
    elif num < min2 :
        min3 = min2
        min2 = num
    elif num < min3 :
        min3 = num
    # print("DBG : ", min1, min2, min3, num < min1, num < min2, num < min3)

list_str = [str(min1) + str(min2), str(min1) + str(min3), str(min2) + str(min3), str(min2) + str(min1), str(min3) + str(min1)]
list_int = sorted(list(map(int, list_str)))

print(list_int[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
num = [int(input()) for i in range(n)]
num.sort()
print(num)
if n >= 4:
    print(str(num[0]) + str(num[3]))
else:
    print(str(num[1]) + str(num[0]))

Submission status: Wrong Answer

Solution code:
n=int(raw_input())
a=[int(raw_input()) for _ in xrange(n)]
a.sort()
if n==3:
    print(str(a[1])+str(a[0]))
else:
    print(str(a[0])+str(a[3]))

Submission status: Wrong Answer

Solution code:
import itertools
a=sorted([int(input()) for _ in [0]*int(input())])[:3]
b=[]
for c,d in itertools.permutations(a,2):
    b+=[c*10**len(str(d))+d]
print(sorted(b)[2])

Submission status: Wrong Answer

Solution code:
from itertools import permutations as P
n = int(input())
print(sorted([a+b for a, b in list(P([input() for _ in range(n)], 2))])[2])

Submission status: Wrong Answer

Solution code:
from itertools import permutations as P
n = int(input())
print(sorted([a+b for a, b in list(P([input() for _ in range(n)], 2))])[2]+"\n")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""


"""
import sys

def main(args):
    n = int(input())
    numbers = [int(input()) for _ in range(n)]
    numbers.sort()

    combi = []
    combi.append(int(str(numbers[0]) + str(numbers[1])))
    combi.append(int(str(numbers[0]) + str(numbers[2])))
    combi.append(int(str(numbers[1]) + str(numbers[0])))
    combi.append(int(str(numbers[2]) + str(numbers[0])))
    combi.append(int(str(numbers[2]) + str(numbers[1])))
    if n > 3:
        combi.append(int(str(numbers[0]) + str(numbers[3])))

    combi.sort()
    print(combi[2])


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Wrong Answer

Solution code:
n=int(raw_input())
A=[]
for i in range(n):
    A.append(raw_input().strip())

t=min(4,n)
A=sorted(A)[:t]
B=[]
for i in range(t):
    for j in range(i+1,t):
        B.append(int(A[i]+A[j]))
        B.append(int(A[j]+A[i]))
B.sort()
print B[2]

Submission status: Wrong Answer

Solution code:
order = 0
nums = []
g_len = int(input())

for i in range(g_len):
    nums.append(input())
    
str_list = []
for i in range((g_len)):
    for j in range((g_len)):
        if i != j:
            this = int(nums[i]+nums[j])
            str_list.append(this)
        
x = []
c =0 
for t in str_list:
    c += 1
    if c > 3:
        if t < max(x):
            x.append(t)
    x.append(t)
    
x = sorted(x)

print(x[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [[] for i in range(5)]
for i in range(n):
    c = input()
    a[len(c) -1].append(c)
for i in range(5):
    a[i].sort()
b, c, d = 0, 0, 0
for i in range(5):
    if len(a[i]) != 0:
        if b == 0:
            b = len(a[i])
            if b >= 3:
                print(a[i][2] + a[i][0])
                break
            j = i
        elif c == 0:
            c = len(a[i])
            if b + c >= 3:
                if b == 1:
                    if c == 2:
                        e = [int(a[j][0] + a[i][0]), int(a[j][0] + a[i][1]), int(a[i][0] + a[j][0]), int(a[i][1] + a[j][0])]
                        e.sort()
                        print(e[2])
                    else:
                        e = [int(a[j][0] + a[i][0]), int(a[j][0] + a[i][1]), int(a[j][0] + a[i][2]), int(a[i][0] + a[j][0]), int(a[i][1] + a[j][0]), int(a[i][2] + a[j][0])]
                        e.sort()
                        print(e[2])
                else:
                    print(min(int(a[j][0] + a[i][0]), int(a[i][0] + a[j][0])))
                break
        else:
            print(min(int(a[j][0] + a[i][0]), int(a[i][0] + a[j][0])))
            break

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [[] for i in range(5)]
for i in range(n):
    c = input()
    a[len(c) -1].append(c)
for i in range(5):
    a[i].sort()
b, c, d = 0, 0, 0
for i in range(5):
    if len(a[i]) != 0:
        if b == 0:
            b = len(a[i])
            if b >= 3:
                print(a[i][1] + a[i][0])
                break
            j = i
        elif c == 0:
            c = len(a[i])
            if b + c >= 3:
                if b == 1:
                    if c == 2:
                        e = [int(a[j][0] + a[i][0]), int(a[j][0] + a[i][1]), int(a[i][0] + a[j][0]), int(a[i][1] + a[j][0])]
                        e.sort()
                        print(e[2])
                    else:
                        e = [int(a[j][0] + a[i][0]), int(a[j][0] + a[i][1]), int(a[j][0] + a[i][2]), int(a[i][0] + a[j][0]), int(a[i][1] + a[j][0]), int(a[i][2] + a[j][0])]
                        e.sort()
                        print(e[2])
                else:
                    print(min(int(a[j][0] + a[i][0]), int(a[i][0] + a[j][0])))
                break
        else:
            print(min(int(a[j][0] + a[i][0]), int(a[i][0] + a[j][0])))
            break

Submission status: Wrong Answer

Solution code:
import sys
input()
e=sorted(list(map(int,[e for e in sys.stdin])))
if len(e)>3:print(e[0],e[2],sep='')
else:print(e[1],e[0],sep='')

Submission status: Wrong Answer

Solution code:
a=sorted([int(input())for _ in[0]*int(input())])[:4]
p=[]
for i in range(3):
 for d in a[i:4]:
  c=a[i]
  p+=[c*10**len(str(d))+d,d*10**len(str(c))+c]
print(sorted(p)[2])

Submission status: Wrong Answer

Solution code:
a=sorted([int(input())for _ in[0]*int(input())])
p=[]
for i in range(2):
 for d in a[i+1:3]:
  c=a[i]
  p+=[c*10**len(str(d))+d,d*10**len(str(c))+c]
print(sorted(p)[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]
a = sorted(a)

rst = str(a[1]) + str(a[0])
print(rst)

Submission status: Wrong Answer

Solution code:
n = int(input())

a = [input() for i in range(n)]
b = []
for a_i in a:
    for a_j in a:
        b.append(int(a_i+a_j))
b.sort()

print(b[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a = sorted(a)
cnt = 0
for i, e in enumerate(a):
    for j in range(3):
        if i == j: continue
        cnt += 1
        if cnt == 3:
            print(str(e) + str(a[j]))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a = sorted(a)
cnt = 0
for i, e in enumerate(a):
    for j in range(n):
        if i == j: continue
        cnt += 1
        if cnt == 3:
            print(str(e) + str(a[j]))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    n = int(input())
    lists = []
    for i in range(n):
        lists.append(int(input()))
    lists.sort()

    if n == 3:
        print(str(lists[1]) + str(lists[0]))
    else:
        print(str(lists[0]) + str(lists[3]))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    n = int(input())
    ls = []
    for i in range(n):
        ls.append(int(input()))
    ls.sort()

    a =  int(str(ls[1]) + str(ls[2]))
    b =  int(str(ls[2]) + str(ls[1]))
    if a < b:
        c = int(str(ls[1]) + str(ls[3]))
        if b < c:
            print(b)
        else:
            print(c)
    elif a > b:
        c = int(str(ls[3]) + str(ls[1]))
        if a < c:
            print(a)
        else:
            print(c)
    else:
        print(a)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    n = int(input())
    ls = []
    for i in range(n):
        ls.append(int(input()))
    ls.sort()
    #print(ls)

    a =  int(str(ls[1]) + str(ls[2]))
    b =  int(str(ls[2]) + str(ls[1]))
    if a < b:
        c = int(str(ls[3]) + str(ls[0]))
        if b < c:
            print(b)
        else:
            print(c)
    elif a > b:
        c = int(str(ls[0]) + str(ls[3]))
        if a < c:
            print(a)
        else:
            print(c)
    else:
        print(a)

Submission status: Wrong Answer

Solution code:
import itertools
L=[input() for i in range(input())]
L.sort()
print "".join(map(str,list(itertools.permutations(L[:3],2))[2]))

Submission status: Wrong Answer

Solution code:
n = input()
a = sorted(raw_input() for i in range(n))
if n > 3:
	print min(a[0]+a[1],a[0]+a[2],a[1]+a[2],a[0]+a[3],a[1]+a[3])
else:
	print min(a[0]+a[1],a[0]+a[2],a[1]+a[2])

Submission status: Wrong Answer

Solution code:
n = input()
a = sorted(raw_input() for i in range(n))
if n > 3:
	print min(a[0]+a[1],a[0]+a[2],a[1]+a[2],a[0]+a[3],a[1]+a[3],a[2]+a[3])
else:
	print min(a[0]+a[1],a[0]+a[2],a[1]+a[2])

Submission status: Wrong Answer

Solution code:
n = input()
a = sorted(raw_input() for i in range(n))
if n > 3:
	print sorted([a[0]+a[1],a[0]+a[2],a[1]+a[2],a[0]+a[3],a[1]+a[3],a[2]+a[3]])[2]
else:
	print sorted([a[0]+a[1],a[0]+a[2],a[1]+a[2]])[2]

Submission status: Wrong Answer

Solution code:
n = input()
a = sorted(raw_input() for i in range(n))
print sorted(a[i]+a[j] for i in range(min(n,20)) for j in range(i+1,min(n,20)))[2]

Submission status: Wrong Answer

Solution code:
n = input()
a = sorted(raw_input() for i in range(n))
print sorted(a[i]+a[j] for i in range(min(n,50)) for j in range(i+1,min(n,50)))[2]

Submission status: Wrong Answer

Solution code:
n = input()
a = sorted(raw_input() for i in range(n))
print sorted(a[i]+a[j] for i in range(min(n,100)) for j in range(i+1,min(n,100)))[2]

Submission status: Wrong Answer

Solution code:
n = input()
a = sorted(raw_input() for i in range(n))[:4]
ans = []
for i in range(3):
	for j in range(i+1,4):
		ans.append(a[i]+a[j])
		ans.append(a[j]+a[i])
print sorted(ans)[2]

Submission status: Wrong Answer

Solution code:
n = input()
a = sorted(raw_input() for i in range(n))[:4]
ans = []
for i in range(3):
	for j in range(i+1,4):
		ans.append(int(a[i]+a[j]))
		ans.append(int(a[j]+a[i]))
print sorted(ans)[2]

Submission status: Wrong Answer

Solution code:
a = map(str,sorted(input() for i in range(input()))[:4])
ans = []
for i in range(3):
	for j in range(i+1,4):
		ans.append(a[i]+a[j])
		ans.append(a[j]+a[i])
print sorted(ans)[2]

Submission status: Memory Limit Exceeded

Solution code:
from itertools import permutations as P
n = int(input())
a = [int(input()) for _ in range(n)]
p = [int(''.join(map(str, v))) for v in list(P(a, 2))]
print(sorted(p)[2])

Submission status: Memory Limit Exceeded

Solution code:
def main():
    n = int(input())
    a = []
    for _ in range(n):
        a.append(input())

    b = [] #joining number(str)
    for x in range(n):
        for y in range(n):
            if x == y:
                pass
            else:
                hoge = a[x] + a[y]
                b.append(hoge)

    for x in range(len(b)): #number(str) -> number(int)
        b[x] = int(b[x])

    b.sort()

    print(b[2])

if __name__ == "__main__":
    main()

Submission status: Memory Limit Exceeded

Solution code:
import sys

inputs = sys.stdin.readlines()
datum = []

for i, x in enumerate(inputs[1:]):
    for y in inputs[i+2:]:
        if y!='\n':
            datum.append(int('{}{}'.format(x.strip(), y.strip())))
            datum.append(int('{}{}'.format(y.strip(), x.strip())))
print(sorted(datum)[2])

Submission status: Memory Limit Exceeded

Solution code:
order = 0
nums = []
g_len = int(input())

for i in range(g_len):
    nums.append(input())
    
str_list = []
for i in range((g_len)):
    for j in range((g_len)):
        if i != j:
            str_list.append(nums[i]+nums[j])
        
x = []

for t in str_list:
    x.append(int(t))
    
x = sorted(x)

print(x[2])

Submission status: Memory Limit Exceeded

Solution code:
n=int(input())
l=[]
i=0
while i<n:
    l.append(int(input()))
    i+=1

A=[]
for p in l:
    for k in l:
        if k==p:
            pass
        else:
            A.append(int(str(p)+str(k)))

a=min(A)
A.remove(a)
b=min(A)
A.remove(b)
c=min(A)
print(c)

Submission status: Memory Limit Exceeded

Solution code:
import itertools

n = int(input())
a = [int(input()) for i in range(n)]

b = []
for x, y in list(itertools.permutations(a, 2)):
    b.append(int(str(x)+str(y)))
b = sorted(b)
print(b[2])

Submission status: Memory Limit Exceeded

Solution code:
n = int(input())

a = [input() for i in range(n)]
b = []
for i, a_i in enumerate(a):
    for j, a_j in enumerate(a):
        if i == j:
            continue
        b.append(int(a_i+a_j))
b.sort()

print(b[2])

Submission status: Memory Limit Exceeded

Solution code:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
b = []
for i in range(n):
    for j in range(n):
        if i == j: continue
        b.append(int(str(a[i]) + str(a[j])))
b = sorted(b)
print(b[2])

Submission status: Memory Limit Exceeded

Solution code:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a = sorted(a)

b = []
for i in range(n):
    for j in range(i+1, n):
        if i == j: continue
        b.append(int(str(a[i]) + str(a[j])))
        b.append(int(str(a[j]) + str(a[i])))
b = sorted(b)
print(b[2])

Submission status: Memory Limit Exceeded

Solution code:
if __name__ == '__main__':
    n = int(input())
    lists = []
    for i in range(n):
        lists.append(input())

    a = sorted([int(i + j) for i in lists for j in lists if i != j])
    print(a[2])

Submission status: Memory Limit Exceeded

Solution code:
import itertools
L=[input() for i in range(input())]
S=[]
for i in itertools.permutations(L,2):
    S.append(int("".join(map(str,i))))
print sorted(S)[2]

Submission status: Accepted

Solution code:
import itertools

n = int(input())
A = sorted([int(input()) for i in range(n)])[:4]

B = []
for a, b in itertools.permutations(A, 2):
    B.append(a * pow(10, len(str(b))) + b)

print(sorted(B)[2])

Submission status: Accepted

Solution code:
n=int(raw_input())
a=[int(raw_input()) for _ in xrange(n)]
a.sort()
ans=[]
for i in xrange(3):
    for j in xrange(i+1,n):
        ans.append(int(str(a[i])+str(a[j])))
        ans.append(int(str(a[j])+str(a[i])))
    ans.sort()
print(ans[2])

Submission status: Accepted

Solution code:
n=int(raw_input())
a=[int(raw_input()) for _ in xrange(n)]
a.sort()
ans=[]
for i in xrange(3):
    for j in xrange(i+1,n):
        ans.append(int(str(a[i])+str(a[j])))
        ans.append(int(str(a[j])+str(a[i])))
ans.sort()
print(ans[2])

Submission status: Accepted

Solution code:
import itertools
a=sorted([int(input()) for _ in [0]*int(input())])[:4]
b=[]
for c,d in itertools.permutations(a,2):
    b+=[c*10**len(str(d))+d]
print(sorted(b)[2])

Submission status: Accepted

Solution code:
from itertools import permutations as P
n = int(input())
a = sorted([int(input()) for _ in range(n)])[:4]
p = [int(''.join(map(str, v))) for v in list(P(a, 2))]
print(sorted(p)[2])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""


"""
import sys

def main(args):
    n = int(input())
    numbers = [int(input()) for _ in range(n)]
    numbers.sort()

    combi = []
    combi.append(int(str(numbers[0]) + str(numbers[1])))
    combi.append(int(str(numbers[0]) + str(numbers[2])))
    combi.append(int(str(numbers[1]) + str(numbers[0])))
    combi.append(int(str(numbers[2]) + str(numbers[0])))
    combi.append(int(str(numbers[2]) + str(numbers[1])))
    if n > 3:
        combi.append(int(str(numbers[0]) + str(numbers[3])))
        combi.append(int(str(numbers[3]) + str(numbers[0])))

    combi.sort()
    print(combi[2])


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
n=int(raw_input())
A=[]
for i in range(n):
    A.append(int(raw_input()))

t=min(4,n)
A=[str(x) for x in sorted(A)[:t]]
B=[]
for i in range(t):
    for j in range(i+1,t):
        B.append(int(A[i]+A[j]))
        B.append(int(A[j]+A[i]))
B.sort()
print B[2]

Submission status: Accepted

Solution code:
from itertools import permutations

n = int(input())
a = list(sorted(int(input()) for _ in range(n)))
print(list(sorted(int(str(c) + str(d)) for c, d in permutations(a[:4], 2)))[2])

Submission status: Accepted

Solution code:
def get_n():
    return int(input())
def get_ns():
    return [int(a) for a in input().split()]
import math
def main():
    n = get_n()
    ns = sorted(set([get_n() for _ in range(n)]))[:100]
    top3 = [9999999999,9999999999,9999999999]
    for i,a in enumerate(ns):
        for j,b in enumerate(ns):
            if i==j:
                continue
            keta = int(math.log10(b))+1
            c = a*pow(10,keta)+b
            if c <top3[2]:
                top3 = sorted(top3+[c])[:-1]
    print(top3[2])





if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import itertools

n = int(input())
a = sorted([int(input()) for i in range(n)])[:4]
b = []
for c,d in itertools.permutations(a,2):
    b += [c * 10**len(str(d)) + d]
print(sorted(b)[2])

Submission status: Accepted

Solution code:
n = int(input())
a = [[] for i in range(5)]
for i in range(n):
    c = input()
    a[len(c) -1].append(c)
for i in range(5):
    a[i].sort()
b, c, d = 0, 0, 0
for i in range(5):
    if len(a[i]) != 0:
        if b == 0:
            b = len(a[i])
            if b >= 3:
                if b == 3:
                    print(a[i][1] + a[i][0])
                else:
                    print(a[i][0] + a[i][3])
                break
            j = i
        elif c == 0:
            c = len(a[i])
            if b + c >= 3:
                if b == 1:
                    if c == 2:
                        e = [int(a[j][0] + a[i][0]), int(a[j][0] + a[i][1]), int(a[i][0] + a[j][0]), int(a[i][1] + a[j][0])]
                        e.sort()
                        print(e[2])
                    else:
                        e = [int(a[j][0] + a[i][0]), int(a[j][0] + a[i][1]), int(a[j][0] + a[i][2]), int(a[i][0] + a[j][0]), int(a[i][1] + a[j][0]), int(a[i][2] + a[j][0])]
                        e.sort()
                        print(e[2])
                else:
                    print(min(int(a[j][0] + a[i][0]), int(a[i][0] + a[j][0])))
                break
        else:
            print(min(int(a[j][0] + a[i][0]), int(a[i][0] + a[j][0])))
            break

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
a.sort()
a = a[:4]
b = []
for i in [0,1,2,3]:
  for j in [0,1,2,3]:
    if i != j:
      b.append(int(str(a[i]) + str(a[j])))
b.sort()
print(b[2])

Submission status: Accepted

Solution code:
a=sorted([int(input())for _ in[0]*int(input())])[:4]
p=[]
for i in range(3):
 for d in a[i+1:4]:
  c=a[i]
  p+=[c*10**len(str(d))+d,d*10**len(str(c))+c]
print(sorted(p)[2])

Submission status: Accepted

Solution code:
a=sorted([int(input())for _ in[0]*int(input())])
p=[]
for i in range(3):
 for d in a[i+1:4]:
  c=a[i]
  p+=[c*10**len(str(d))+d,d*10**len(str(c))+c]
print(sorted(p)[2])

Submission status: Accepted

Solution code:
a=sorted([int(input())for _ in[0]*int(input())])
p=[]
for i in range(3):
 for d in a[i+1:4]:
  c=a[i]
  p+=[int(f'{c}{d}'),int(f'{d}{c}')]
print(sorted(p)[2])

Submission status: Accepted

Solution code:
a=sorted([int(input())for _ in[0]*int(input())])
p=[]
for i in range(3):
 for d in a[i+1:4]:
  c=a[i]
  p+=[f'{c}{d}',f'{d}{c}']
print(sorted(list(map(int,p)))[2])

Submission status: Accepted

Solution code:
n=int(input())
a=[int(input())for _ in[0]*n]
for i in range(4):
 for j in range(n-1,i,-1):
  if a[i]>a[j]:a[i],a[j]=a[j],a[i]
p=[]
for i in range(3):
 for d in a[i+1:4]:
  c=a[i]
  p+=[int(f'{c}{d}'),int(f'{d}{c}')]
print(sorted(p)[2])

Submission status: Accepted

Solution code:
n=int(input())
a=[int(input())for _ in[0]*n]
for i in range(4):
 for j in range(n-1,i,-1):
  if a[i]>a[j]:a[i],a[j]=a[j],a[i]
p=[]
for i in range(3):
 for d in a[i+1:4]:
  c=a[i]
  p+=[int(f'{c}{d}'),int(f'{d}{c}')]
for i in range(3):
 for j in range(11,i,-1):
  if p[i]>p[j]:p[i],p[j]=p[j],p[i]
print(sorted(p)[2])

Submission status: Accepted

Solution code:
import itertools
print(sorted([int(f'{c}{d}')for c,d in itertools.permutations(sorted([int(input())for _ in[0]*int(input())])[:4],2)])[2])

Submission status: Accepted

Solution code:
from itertools import permutations as p
print(sorted([int(f'{c}{d}')for c,d in p(sorted([int(input())for _ in[0]*int(input())])[:4],2)])[2])

Submission status: Accepted

Solution code:
import itertools
print(sorted(int(f'{c}{d}')for c,d in itertools.permutations(sorted([int(input())for _ in[0]*int(input())])[:4],2))[2])

Submission status: Accepted

Solution code:
import itertools
print(sorted(int(f'{a}{b}')for a,b in itertools.permutations(sorted(int(input())for _ in[0]*int(input()))[:4],2))[2])

Submission status: Accepted

Solution code:
def con(m,n):
  ln = len(str(n))
  return m * 10 ** ln + n
n = int(input())
lst = [int(input()) for i in range(n)]
lst.sort()
lst = lst[0:4]
save = []
for i in lst:
  for j in lst:
    if i != j:
      save.append(con(i, j))
save.sort()
print(save[2])

Submission status: Accepted

Solution code:
def main():
  def con(m,n):
    ln = len(str(n))
    return m * 10 ** ln + n
  n = int(input())
  lst = [int(input()) for i in range(n)]
  lst.sort()
  lst = lst[0:4]
  save = []
  for i in lst:
    for j in lst:
      if i != j:
        save.append(con(i, j))
  save.sort()
  print(save[2])
  
main()

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a = sorted(a)

b = []
cnt = 0
for i in range(n):
    for j in range(i+1, n):
        if cnt == 3:
            break
        if i == j: continue
        b.append(int(str(a[i]) + str(a[j])))
        b.append(int(str(a[j]) + str(a[i])))
        cnt += 1
b = sorted(b)
print(b[2])

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n = int(input())
    ls = []
    for i in range(n):
        ls.append(int(input()))
    ls.sort()

    ans = [int(str(i) + str(j)) for i in ls[:3 + 1] for j in ls[:3 + 1] if i != j] if n > 3 else [int(str(i) + str(j)) for i in ls for j in ls if i != j]
    print(sorted(ans)[2])

Submission status: Accepted

Solution code:
from heapq import heappush, heappop
n = input()
h = [-10000]*4
for i in range(n):
    a = input()
    heappush(h, -a)
    heappop(h)
h = [str(-a) for a in h]
ans = []
for i in range(3):
    for j in range(i+1, 4):
        ans.append(int(h[i]+h[j]))
        ans.append(int(h[j]+h[i]))
ans.sort()
print ans[2]

Submission status: Accepted

Solution code:
n = input()
h = sorted(input() for i in range(n))[:4]
h = map(str, h)
ans = []
for i in range(3):
    for j in range(i+1, 4):
        ans.append(int(h[i]+h[j]))
        ans.append(int(h[j]+h[i]))
print sorted(ans)[2]

Submission status: Accepted

Solution code:
a = map(str,sorted(input() for i in range(input()))[:4])
ans = []
for i in range(3):
	for j in range(i+1,4):
		ans.append(int(a[i]+a[j]))
		ans.append(int(a[j]+a[i]))
print sorted(ans)[2]

Submission status: Accepted

Solution code:
a = map(str,sorted(int(raw_input()) for i in range(input()))[:4])
ans = []
for i in range(3):
	for j in range(i+1,4):
		ans.append(int(a[i]+a[j]))
		ans.append(int(a[j]+a[i]))
print sorted(ans)[2]

Submission status: Accepted

Solution code:
n = int(input())
l = sorted([int(input()) for i in range(n)])

L = []
for i in range(4):
    for j in range(4):
        if not i == j:
            L.append(int(str(l[i])+str(l[j])))

L = sorted(L)

print(L[2])

Submission status: Accepted

Solution code:
n = int(input())
a = []
b = []
c = []
for i in range(0, n):
	a.append(int(input()))

# print(n)
# print(a)

a.sort()
#print(a)
for j in range(0, 4):
	for k in range(0, 4):
		if (j != k):
			b.append(str(a[j]) + str(a[k]))

for k in b:
	c.append(int(k))

c.sort()
print(c[2])

Submission status: Accepted

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]
a.sort()
s = a[0:4]
p = []
for i in range(len(s)):
    for j in range(len(s)):
        if i != j:
            p.append(int(str(s[i]) + str(s[j])))
p.sort()
print(p[2])

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a.sort()
b = sorted([int(str(a[0])+str(a[1])), int(str(a[1])+str(a[0])), int(str(a[0])+str(a[2])), int(str(a[2])+str(a[0])), int(str(a[3])+str(a[0])), int(str(a[0])+str(a[3]))])
print(b[2])

Submission status: Accepted

Solution code:
n=int(input())
a=[0 for i in range(n)]

for i in range(n):
    a[i]=int(input())

min1=min(a)
id1=a.index(min1)
temp1=a[id1]
a[id1]=99999

min2=min(a)
id2=a.index(min2)
temp2=a[id2]
a[id2]=99999

min3=min(a)
id3=a.index(min3)
temp3=a[id3]
a[id3]=99999

min4=min(a)
id4=a.index(min4)

b1=str(temp1)
b2=str(temp2)
b3=str(temp3)
b4=str(a[id4])

j12=b1+b2
j21=b2+b1
j13=b1+b3
j31=b3+b1
j14=b1+b4
j41=b4+b1

k12=int(j12)
k21=int(j21)
k13=int(j13)
k31=int(j31)
k14=int(j14)
k41=int(j41)

A=[k12,k21,k13,k31,k14,k41]
for i in range(6):
    v=A[i]
    j=i-1
    while j>=0 and A[j]>v:
        A[j+1]=A[j]
        j=j-1
    A[j+1]=v
print(A[2])

Submission status: Accepted

Solution code:
n=int(input())
m=[]
for i in range(n):
    m.append(int(input()))
m.sort()
m=m[:4]
ans=[]
for i in m:
    for j in m:
        if i==j:continue
        ans.append(int(str(i)+str(j)))
ans.sort()
print(ans[2])

Submission status: Accepted

Solution code:

n = int(input())
v=[]; ans=[]
for i in range(n):
    c=input()
    v.append(int(c))

v= sorted(v)[:min(len(v), 5)]
for i,d in enumerate(v):
    for i2,d2 in enumerate(v):
        if i==i2: continue;
        w=int(str(d) + str(d2))
        ans.append(w)
ans.sort()
print(ans[2])

Submission status: Accepted

Solution code:
import sys
n = int(input())
a = [sys.maxsize]*4
for i in range(n):
	t = int(input())
	if t < a[0]:
		a[3]=a[2]
		a[2]=a[1]
		a[1]=a[0]
		a[0]=t
	elif t < a[1]:
		a[3]=a[2]
		a[2]=a[1]
		a[1]=t
	elif t < a[2]:
		a[3]=a[2]
		a[2]=t
	elif t < a[3]:
		a[3]=t

m = min(4,len(a))
ans = [sys.maxsize]*3
for i in range(m):
	for j in range(m):
		if i!=j:
			t=int(str(a[i])+str(a[j]))
			if t < ans[0]:
				ans[2]=ans[1]
				ans[1]=ans[0]
				ans[0]=t
			elif t < ans[1]:
				ans[2]=ans[1]
				ans[1]=t
			elif t < ans[2]:
				ans[2]=t
print(ans[2])

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

a.sort()

b = []
cnt = 0
for i in range(n):
    for j in range(i+1,n):
        b.append(int(str(a[i])+str(a[j])))
        b.append(int(str(a[j])+str(a[i])))
        cnt += 1
        if cnt > n:
            break

b.sort()

print(b[2])

Submission status: Accepted

Solution code:
N = int(input())
l1 = []
for i in range(N):
    l1.append(int(input()))
l1.sort()
if N == 3 :
    l2 = l1
else :
    l2 = l1[:4]
l3 = []
for i in range(len(l2)):
    for j in range(len(l2)):
        if i == j:
            continue
        l3.append(int(str(l2[i])+str(l2[j])))
l3.sort()
print(l3[2])

Submission status: Accepted

Solution code:
n = int(input())
x = 2

listA = []
listB = []
listC = []

for i in range(n):
    a = int(input())
    listA.append(a)
    listB.append(a)

listA.sort()
listB.sort()
    
for i in range(x+2):
    listB.remove(listA[i])
    
    for j in range(x+1):
        listC.append(int(str(listA[i]) + str(listB[j])))
         
    listB.append(listA[i])
    listB.sort()

listC.sort()
print(listC[x])

Submission status: Accepted

Solution code:
nums=[]
for i in range(int(input())):
    nums.append(input())
nums=sorted(nums,key=int)[:4]
pers=[]
for i in nums:
    for j in nums:
        if i!=j:
            pers.append(int(i+j))
print(sorted(pers)[2])

Submission status: Runtime Error

Solution code:
import sys

inputs = sys.stdin.readlines()
datum = []
for i, x in enumerate(inputs[1:]):
    for y in inputs[i+2:]:
        datum.append(int('{}{}'.format(x, y)))
        datum.append(int('{}{}'.format(y, x)))
print sorted(datum)[2]

Submission status: Runtime Error

Solution code:
order = 0
nums = []
g_len = int(input())

for i in range(g_len):
    nums.append(input())
    
str_list = []
for i in range((g_len)):
    for j in range((g_len)):
        if i != j:
            this = int(nums[i]+nums[j])
            str_list.append(this)
        
x = []
c =0 
for t in str_list:
    c += 1
    if c > 3:
        if t < max(x):
            x.append(t)
    else: x.append(t)
    
x = sorted(x)

print(x[2])

Submission status: Runtime Error

Solution code:
def get_n():
    return int(input())
def get_ns():
    return [int(a) for a in input().split()]
import math
def main():
    n = get_n()
    ns = sorted(set([get_n() for _ in range(n)]))
    top3 = [9999999999,9999999999,9999999999]
    for i,a in enumerate(ns):
        for j,b in enumerate(ns):
            if i==j:
                continue
            keta = int(math.log10(b))+1
            c = a*pow(10,keta)+b
            if c <top3[2]:
                top3 = sorted(top3+[c])[:-1]
    print(top3[2])





if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import itertools

n = int(input())
a = sorted([int(input()) for i in range(n)])[:4]
b = []
for c,d in intertools.permutations(a,2):
    b += [c * 10**len(str(d)) + d]
print(sorted(b)[2])

Submission status: Runtime Error

Solution code:
n = input()
a = []
for i in range(n):
  a.append(input())
a = a.sort()[:3]
b = []
for i in [0,1,2]:
  for j in [0,1,2]:
    if i != j:
      b.append(int(str(a[i] + a[j])))
b.sort()
return(b[2])

Submission status: Runtime Error

Solution code:
n = input()
a = []
for i in range(n):
  a.append(input())
a = a.sort()[:3]
b = []
for i in [0,1,2]:
  for j in [0,1,2]:
    if i != j:
      b.append(int(str(a[i] + a[j])))
b.sort()
print(b[2])

Submission status: Runtime Error

Solution code:
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
a = a.sort()[:3]
b = []
for i in [0,1,2]:
  for j in [0,1,2]:
    if i != j:
      b.append(int(str(a[i] + a[j])))
b.sort()
print(b[2])

Submission status: Runtime Error

Solution code:
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
a = a.sort()
a = a[:3]
b = []
for i in [0,1,2]:
  for j in [0,1,2]:
    if i != j:
      b.append(int(str(a[i] + a[j])))
b.sort()
print(b[2])

Submission status: Runtime Error

Solution code:
a=sorted([int(input())for _ in[0]*int(input())])[:4]
b=[]
for i in range(3):
 for d in a[i:4]:
  c=a[i]
  b+=[c*10**len(d)+d,d*10**len(c)+c]
print(sorted(b)[2])

Submission status: Runtime Error

Solution code:
def permutations(iterable, r=None):
    pool = tuple(iterable)
    n = len(pool)
    r = n if r is None else r
    if r > n:
        return
    indices = range(n)
    cycles = range(n, n-r, -1)
    yield tuple(pool[i] for i in indices[:r])
    while n:
        for i in reversed(range(r)):
            cycles[i] -= 1
            if cycles[i] == 0:
                indices[i:] = indices[i+1:] + indices[i:i+1]
                cycles[i] = n - i
            else:
                j = cycles[i]
                indices[i], indices[-j] = indices[-j], indices[i]
                yield tuple(pool[i] for i in indices[:r])
                break
        else:
            return


L=[input() for i in range(input())]
S=[]
for i in permutations(L,2):
    S.append(int("".join(map(str,i))))
print sorted(S)[2]