```python
def line_cost(price: int, quantity: int) -> int:
    """Calculate the cost for a single line item."""
    if quantity < 0:
        raise ValueError("Quantity cannot be negative")
    if price < 0:
        raise ValueError("Price cannot be negative")
    return price * quantity


def basket_cost(lines: list, discount: int) -> int:
    """Calculate the total cost of the basket after applying a discount."""
    if discount < 0:
        raise ValueError("Discount cannot be negative")
    if discount > 100:
        raise ValueError("Discount cannot exceed 100 percent")
    
    total = sum(line_cost(price, quantity) for price, quantity in lines)
    
    discount_amount = (total * discount) // 100
    return total - discount_amount
```