def max_artwork_value_two_pointers(N, artworks):
artworks.sort()
left = 0
current_value = 0
max_result = float('-inf')
for right in range(N):
current_value += artworks[right][1] я
while artworks[right][0] - artworks[left][0] > 0:
max_result = max(max_result, current_value - (artworks[right][0] - artworks[left][0]))
current_value -= artworks[left][1]
left += 1
max_result = max(max_result, current_value - (artworks[right][0] - artworks[left][0]))
return max_result
N = int(input().strip())
artworks = []
for _ in range(N):
Ai, Bi = map(int, input().split())
artworks.append((Ai, Bi))
print(max_artwork_value_two_pointers(N, artworks))
Compilation message
File "art.py", line 9
current_value += artworks[right][1] я
^
SyntaxError: invalid syntax