- 처음에는 조합을 사용할까 했는데 조합(combination)은 뽑아내는 수 r개를 범위로 받아올 수 없기 때문에 투 포인터를 이용해서 양쪽 끝에서부터 시작하여 조건문으로 경우를 나누어 각각의 실행문이 시작되도록 코드를 작성했다.
N = int(input())
M = int(input())
ingredient = list(map(int, input().split()))
ingredient.sort()
cnt = 0
start = 0
end = len(ingredient) - 1
while True:
if start >= end:
break
if ingredient[start] + ingredient[end] == M:
cnt += 1
end -= 1
elif ingredient[start] + ingredient[end] > M:
end -= 1
else:
start += 1
print(cnt)