27 lines
551 B
Python
27 lines
551 B
Python
from collections import defaultdict
|
|
#qweqweqwe
|
|
# I
|
|
N, M = map(int, input().split())
|
|
cup = defaultdict(int)
|
|
|
|
for _ in range(N):
|
|
x, s = map(int, input().split())
|
|
cup[x] += s
|
|
|
|
# summa dalās ar M
|
|
pairs = 0
|
|
|
|
for x in cup:
|
|
if x >= M - x and cup[x] > 0:
|
|
if x == M - x:
|
|
pairs += cup[x] // 2
|
|
cup[x] %= 2
|
|
else:
|
|
if M - x in cup:
|
|
pairs += min(cup[x], cup[M - x])
|
|
cup[x] -= min(cup[x], cup[M - x])
|
|
cup[M - x] -= min(cup[x], cup[M - x])
|
|
|
|
|
|
print(pairs)
|