Subscription Status Manager
A subscription service manages user accounts with three possible states: active, inactive, and suspended. You must process events that update subscriptions and answer queries about user statuses.
A user is active if they have a valid subscription (end date ≥ current day) and are not suspended. A user is inactive if they have no subscription or it has expired. A user is suspended if marked so by an administrator, regardless of their subscription status. When a user transitions between states, their change counter increments.
Input
The first line contains n (1 ≤ n ≤ 10^5), the number of operations. Each of the next n lines is one of:
SUBSCRIBE user_id days: user subscribes fordaysdays from now (subscription ends at current_day + days)RENEW user_id days: user renews their subscription, extending it bydaysdays from their current end dateCANCEL user_id: user cancels their subscriptionSUSPEND user_id: administrator suspends a userUNSUSPEND user_id: administrator lifts a user's suspensionSTATUS user_id: output the current status of the user (ACTIVE,INACTIVE, orSUSPENDED)COUNT status: output how many users have the given status (ACTIVE,INACTIVE, orSUSPENDED)CHANGED user_id: output how many times the user's status has changed
User IDs are positive integers up to 10^6. Days are positive integers up to 10^9. All users start as inactive with 0 changes.
- The current day is always 0: time does not advance between operations.
- Which users exist: a user exists from the first operation that names their id, whatever that operation is (
STATUSandCHANGEDincluded).COUNTcounts only users that exist, not every possible id.
Output
For each STATUS, COUNT, or CHANGED query, print one line with the answer.
Notes
- Suspending an already suspended user does nothing and does not count as a change.
- Unsuspending a user who is not suspended does nothing and does not count as a change.
- Only
SUSPENDandUNSUSPENDchange whether a user is suspended.SUBSCRIBE,RENEWandCANCELupdate the subscription of a suspended user, who staysSUSPENDED. - When RENEW is used on a user with an expired subscription, it extends from the current day, not from the old end date.
- Changes are counted whenever a user's visible status (
ACTIVE,INACTIVE, orSUSPENDED) changes, not for internal subscription date changes alone.