If I have figured correctly, what you are after:
; WITH cte AS
( SELECT pid, uid, event, timeStamp,
maxts = MAX(timeStamp) OVER (PARTITION BY pid, uid)
FROM tableX
)
SELECT pid, cnt = COUNT(*)
FROM cte
WHERE maxts = timeStamp
AND event = 200
GROUP BY pid ;
If there is a chance that you have 2 rows with identical pid, uid and timestamp, you'll need to replace COUNT(*)
with COUNT(DISTINCT uid)
.