Cross-Margin Liquidation Engine 
Simulate a cross-margin derivatives engine: process trades, track account equity, and liquidate undercollateralized accounts as fast as possible.
Accounts are funded with a USD deposit and trade instruments whose prices change over time. When a price update causes an account’s equity to fall below 1% of its total position notional, the account must be liquidated.
Definitions
- Account equity =
balance + Σ(size_i * price_i) - Σ(total_paid_i) - Total position notional =
Σ(|size_i| * price_i) - Total paid for instrument
i= signed sum oftrade_size * price_at_trade_timeacross all trades - Margin rule: liquidate if
equity < total_notional / 100after any price update
Input
One command per line on STDIN:
a <balance>– create account with USD balance (IDs start at0, incrementing)p <instrument_idx> <price>– set/update instrument price (0-indexed)t <account_idx> <instrument_idx> <size>– tradesize(signed) at current price- Final line:
<account_idx>– query this account and terminate
Output
On each price update, liquidate all accounts violating the margin rule. For each liquidation, print:
liquidate <account_id> <equity> <position_notional>
Liquidation order: largest total position notional first, then account ID descending as tie-breaker. Liquidated accounts have their balance and positions cleared.
For the final query, print <equity> <notional> for the requested account.
Constraints
- Accounts: <= 100,000
- Instruments: <= 1,000
- Price range: 100 to 1,000,000
- Trade size range: 1 to 10,000
Example
a 100
p 0 100
t 0 0 10
p 0 90
0
Output:
liquidate 0 0 900
0 0
| Date | Author | Language | Status | Score | |
|---|---|---|---|---|---|
| May 6, 2026 15:26 | CPPg++10.5.0 | Error | |||
| May 6, 2026 15:25 | CPPg++10.5.0 | Error | |||
| May 6, 2026 15:23 | CPPg++10.5.0 | Success | 16,625 | ||
| May 6, 2026 12:34 | GOgo1.26.2 | Success | 6,650 | ||
| May 6, 2026 11:23 | ZIG0.14.0 | Success | 6,030 | ||
| May 6, 2026 10:06 | RUSTrust-1.94.0 | Success | 5,022 | ||
| May 6, 2026 09:04 | GOgo1.26.2 | Error | |||
| May 6, 2026 08:43 | CSHARP10.0.7 | Success | 5,394 | ||
| May 6, 2026 08:38 | CSHARP9.0.15 | Success | 5,590 | ||
| May 6, 2026 05:01 | CSHARP10.0.7 | Success | 5,488 | ||
| May 6, 2026 02:45 | RUSTrust-1.94.0 | Success | 7,433 | ||
| May 6, 2026 00:35 | RUSTrust-1.94.0 | Success | 5,247 | ||
| May 5, 2026 20:51 | RUSTrust-1.94.0 | Success | 5,394 | ||
| May 5, 2026 18:49 | CSHARP10.0.7 | Success | 5,550 | ||
| May 5, 2026 18:37 | CSHARP10.0.7 | Success | 5,540 | ||
| May 5, 2026 18:30 | CSHARP9.0.15 | Success | 5,926 | ||
| May 5, 2026 18:25 | CSHARP9.0.15 | Error | |||
| May 5, 2026 18:15 | CPPclang++18.1.3 | Success | 5,309 | ||
| May 5, 2026 17:55 | CPPg++10.5.0 | Success | 5,180 | ||
| May 5, 2026 17:43 | GOgo1.26.2 | Success | 6,069 | ||
| May 5, 2026 17:35 | GOgo1.26.2 | Error | |||
| May 5, 2026 15:46 | GOgo1.26.2 | Error | |||
| May 5, 2026 15:41 | GOgo1.26.2 | Error | |||
| May 5, 2026 15:11 | CSHARP9.0.15 | Success | 5,609 | ||
| May 5, 2026 13:40 | ZIG0.16.0 | Success | 1,731 | ||
| May 5, 2026 13:22 | CSHARP10.0.7 | Success | 1,831 | ||
| May 5, 2026 13:06 | ZIG0.16.0 | Success | 1,674+216.66 RP | ||
| May 5, 2026 12:47 | CSHARP10.0.7 | Success | 1,915 | ||
| May 5, 2026 12:41 | ZIG0.16.0 | Success | 1,737+145.38 RP | ||
| May 5, 2026 09:50 | CPPg++14.2.0 | Error | |||
| May 5, 2026 09:39 | CPPclang++18.1.3 | Success | 1,609+84.40 RP | ||
| May 5, 2026 09:25 | CPPclang++18.1.3 | Success | 1,785 | ||
| May 5, 2026 09:16 | CPPclang++18.1.3 | Success | 1,719 | ||
| May 5, 2026 09:12 | CPPclang++18.1.3 | Success | 1,711 | ||
| May 5, 2026 09:09 | RUSTrust-1.95.0 | Success | 1,749+479.21 RP | ||
| May 5, 2026 09:07 | CPPclang++18.1.3 | Success | 1,802 | ||
| May 5, 2026 09:00 | RUSTrust-1.95.0 | Success | 1,909+43.54 RP | ||
| May 5, 2026 08:50 | ZIG0.16.0 | Success | 1,782+2'083.09 RP | ||
| May 5, 2026 08:41 | RUSTrust-1.95.0 | Error | |||
| May 5, 2026 08:35 | GOgo1.26.2 | Success | 1,779+544.99 RP | ||
| May 5, 2026 08:27 | CSHARP10.0.7 | Success | 1,817+2'298.45 RP | ||
| May 5, 2026 08:21 | ZIG0.16.0 | Error | |||
| May 5, 2026 08:17 | RUSTrust-1.95.0 | Error | |||
| May 5, 2026 08:14 | CPPclang++18.1.3 | Success | 5,195 | ||
| May 5, 2026 08:14 | ZIG0.16.0 | Error | |||
| May 5, 2026 05:32 | RUSTrust-1.94.0 | Success | 5,081 | ||
| May 5, 2026 04:28 | GOgo1.26.2 | Success | 6,166 | ||
| May 5, 2026 02:20 | GOgo1.26.2 | Success | 5,969 | ||
| May 5, 2026 02:09 | GOgo1.26.2 | Success | 6,386 | ||
| May 5, 2026 01:59 | ZIG0.14.0 | Success | 5,427 | ||
| May 5, 2026 01:51 | ZIG0.14.0 | Success | 5,485 | ||
| May 5, 2026 01:45 | CPPclang++18.1.3 | Success | 5,151 | ||
| May 4, 2026 22:00 | CPPclang++18.1.3 | Success | 5,236 | ||
| May 4, 2026 13:01 | CPPg++14.2.0 | Success | 124,281 | ||
| May 4, 2026 12:16 | CPPg++14.2.0 | Error | |||
| May 4, 2026 11:57 | CPPclang++18.1.3 | Success | 1,620+2'561.61 RP | ||
| May 4, 2026 11:51 | CPPg++14.2.0 | Success | 389,178 | ||
| May 4, 2026 11:45 | CPPclang++18.1.3 | Error | |||
| May 4, 2026 11:21 | CPPclang++18.1.3 | Error | |||
| May 4, 2026 11:14 | CPPclang++18.1.3 | Error | |||
| May 1, 2026 09:35 | CPPg++14.2.0 | Success | 16,943 | ||
| May 1, 2026 09:34 | CPPclang++20.1.2 | Success | 13,849 | ||
| May 1, 2026 09:32 | CPPg++10.5.0 | Success | 17,429 | ||
| May 1, 2026 05:16 | GOgo1.26.2 | Success | 5,956 | ||
| May 1, 2026 04:45 | CPPg++10.5.0 | Success | 5,564 | ||
| May 1, 2026 00:13 | CPPg++10.5.0 | Success | 5,786 | ||
| Apr 30, 2026 15:12 | RUSTrust-1.95.0 | Success | 1,925+940.92 RP | ||
| Apr 30, 2026 15:05 | RUSTrust-1.95.0 | Error | |||
| Apr 30, 2026 14:48 | RUSTrust-1.95.0 | Error | |||
| Apr 30, 2026 14:06 | RUSTrust-1.95.0 | Error | |||
| Apr 30, 2026 13:59 | RUSTrust-1.95.0 | Error | |||
| Apr 30, 2026 13:52 | RUSTrust-1.95.0 | Error | |||
| Apr 30, 2026 13:38 | RUSTrust-1.95.0 | Error | |||
| Apr 30, 2026 13:11 | GOgo1.26.2 | Success | 1,970+3'973.99 RP | ||
| Apr 30, 2026 12:14 | CPPg++13.3.0 | Success | 35,220+16.08 RP | ||
| Apr 30, 2026 11:57 | CSHARP10.0.7 | Success | 3,120+1'786.49 RP | ||
| Apr 30, 2026 11:40 | ZIG0.16.0 | Success | 2,834+1'998.01 RP | ||
| Apr 30, 2026 11:27 | CPPg++14.2.0 | Success | 3,054+3'032.96 RP | ||
| Apr 30, 2026 10:45 | CPPg++14.2.0 | Success | 112,054 | ||
| Apr 30, 2026 10:30 | CPPg++14.2.0 | Success | 116,948 | ||
| Apr 30, 2026 10:23 | CPPg++14.2.0 | Success | 112,090 | ||
| Apr 30, 2026 10:00 | CPPg++14.2.0 | Success | 112,880 | ||
| Apr 30, 2026 09:39 | CPPg++14.2.0 | Success | 126,704 | ||
| Apr 29, 2026 23:20 | GOgo1.26.2 | Success | 6,148 | ||
| Apr 29, 2026 23:15 | CPPg++13.3.0 | Success | 37,335+98.35 RP | ||
| Apr 29, 2026 12:21 | CPPg++13.3.0 | Success | 5,284 | ||
| Apr 29, 2026 11:35 | CPPclang++18.1.3 | Success | 15,301 | ||
| Apr 29, 2026 07:20 | RUSTrust-1.95.0 | Success | 5,104 | ||
| Apr 29, 2026 07:01 | GOgo1.26.2 | Success | 5,989 | ||
| Apr 28, 2026 23:26 | CPPg++13.3.0 | Success | 61,101 | ||
| Apr 28, 2026 23:26 | CPPg++10.5.0 | Success | 5,661 | ||
| Apr 28, 2026 13:43 | CPPclang++18.1.3 | Success | 100,775 | ||
| Apr 28, 2026 12:46 | CPPclang++20.1.2 | Success | 63,778 | ||
| Apr 28, 2026 12:42 | CPPclang++18.1.3 | Success | 15,371 | ||
| Apr 28, 2026 12:41 | CPPclang++20.1.2 | Success | 14,379 | ||
| Apr 28, 2026 12:34 | CPPg++13.3.0 | Success | 19,329 | ||
| Apr 28, 2026 10:46 | CPPg++14.2.0 | Success | 129,856 | ||
| Apr 28, 2026 10:39 | CPPg++14.2.0 | Success | 128,201 | ||
| Apr 28, 2026 10:10 | CPPg++14.2.0 | Success | 118,942 | ||
| Apr 28, 2026 09:58 | CPPg++14.2.0 | Success | 120,357 |