Develop a REST API that makes transactions.
Implement the transaction-processing core for this API. Given account balances and transfer requests, process requests in order, reject invalid or unsuccessful transfers without changing balances, and make repeated idempotency keys return the original result without applying the transfer again.
Function contract: process_transactions(accounts, transactions) receives a dictionary of account IDs to nonnegative integer balances and a list of transaction dictionaries with idempotency_key, from_account, to_account, and positive integer amount. Return {"balances": final_balances, "results": transaction_results}. Each result must contain the idempotency key and status: "completed", "rejected", or "duplicate".
def process_transactions(accounts, transactions):