2021-11-03 16:12:21 +00:00
|
|
|
import doctest
|
2021-11-03 16:23:19 +00:00
|
|
|
from collections import Counter
|
2021-11-03 16:12:21 +00:00
|
|
|
|
|
|
|
|
2021-11-03 16:38:05 +00:00
|
|
|
def sockMerchant(n: int, ar: list[int]) -> int:
|
2021-11-03 16:12:21 +00:00
|
|
|
"""
|
|
|
|
>>> sockMerchant(9, [10, 20, 20, 10, 10, 30, 50, 10, 20])
|
|
|
|
3
|
|
|
|
>>> sockMerchant(4, [1, 1, 3, 3])
|
|
|
|
2
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
i = 0
|
|
|
|
occur = Counter(ar)
|
|
|
|
|
|
|
|
for x in occur.values():
|
|
|
|
i += x // 2
|
|
|
|
return i
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
2021-11-03 16:23:19 +00:00
|
|
|
n = int(input().strip())
|
2021-11-03 16:12:21 +00:00
|
|
|
|
2021-11-03 16:23:19 +00:00
|
|
|
ar = list(map(int, input().rstrip().split()))
|
2021-11-03 16:12:21 +00:00
|
|
|
|
|
|
|
result = sockMerchant(n, ar)
|
|
|
|
print(result)
|
|
|
|
doctest.testmod()
|