https://www.acmicpc.net/problem/2798
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
card = list(map(int, input().split()))
min_gap = m
result = 0
for i in card:
for j in card:
if i != j:
for k in card:
if j != k and i != k:
if (i + j + k) <= m and m - (i + j + k) < min_gap:
min_gap = m - (i + j + k)
result = i + j + k
print(result)
https://www.acmicpc.net/problem/2231
n = int(input())
for i in range(1, n+1):
n_list = list(map(int, str(i)))
s_num = i + sum(n_list)
if s_num == n:
print(i)
break
if i == n:
print(0)