Feature Flag Drift Between Environments
Before every release, the on-call engineer checks that the feature flags in staging haven't drifted
away from production. Each environment exports its flags as lines of key=value. Within one export
every key appears at most once, but the two exports may list different keys, in any order.
Write the drift report. It has three sections, in this order:
ONLY_STAGING: the flags that exist in staging but not in production.ONLY_PRODUCTION: the flags that exist in production but not in staging.CHANGED: the flags that exist in both environments with different values.
Flags present in both environments with the same value are not reported.
Keys and values are case-sensitive: Beta and beta are different keys, and on and ON are
different values.
Input
The first line contains n (0 ≤ n ≤ 10^5), the number of flags in staging. Each of the next n
lines contains one staging flag as key=value.
The next line contains m (0 ≤ m ≤ 10^5), the number of flags in production, followed by m lines
in the same format.
Every key and every value is a non-empty string of at most 50 characters, each being an English
letter (a–z, A–Z), a digit, _, . or -. So each line contains exactly one =, with no
spaces. The keys within one environment are pairwise distinct.
Output
For each section, print a heading line with the section name and the number of flags in it, then one line per flag:
- In
ONLY_STAGINGandONLY_PRODUCTION, print the flag askey=value, exactly as it appears in its environment. - In
CHANGED, printkey staging_value -> production_value.
Within every section, list the flags in increasing order of key, comparing keys character by
character by their ASCII codes (so digits come before uppercase letters, which come before
lowercase letters). A section with no flags is just its heading with the count 0.
Notes
In the first example, checkout_v2 is only in staging, legacy_banner is only in production,
max_upload_mb changed from 25 to 10, and dark_mode is identical in both, so it is not
reported.
In the second example, the keys Beta and beta are different flags. In ASCII order, uppercase
letters come before lowercase ones, so Beta is listed before beta. Staging is empty, so
ONLY_STAGING and CHANGED have no flags.