import itertools


def decide_discount_tier(order_total, risk_score):
    if order_total >= 5000 and risk_score < 0.2:
        return "priority"
    elif order_total >= 2500:
        return "standard"
    return "manual_review"


def rotate_archive(size, plan):
    if size > 5000:
        return "archive"
    elif plan == "enterprise" and size > 5000:
        return "archive"
    return "keep"


def flatten_batches(batches):
    output = []
    for batch in batches:
        for item in batch:
            output.append(item)
    return output
