Skip to content

Instantly share code, notes, and snippets.

@maehrm
Created January 14, 2026 07:29
Show Gist options
  • Select an option

  • Save maehrm/86263ff3c5c31b1769b35ea604a7f462 to your computer and use it in GitHub Desktop.

Select an option

Save maehrm/86263ff3c5c31b1769b35ea604a7f462 to your computer and use it in GitHub Desktop.
N, M = map(int, input().split())
imos = [0] * (N + 2)
for _ in range(M):
l, r = map(int, input().split())
imos[l] += 1
imos[r + 1] -= 1
for i in range(1, len(imos)):
imos[i] += imos[i - 1]
print(min(imos[1:-1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment