There is a sale in a supermarket, there will be a discount every n customer.
There are some products in the supermarket where the id of the i-th product is products[i] and the price per unit of this product is prices[i].
The system will count the number of customers and when the n-th customer arrive he/she will have a discount on the bill. (i.e if the cost is x the new cost is x - (discount * x) / 100). Then the system will start counting customers again.
The customer orders a certain amount of each product where product[i] is the id of the i-th product the customer ordered and amount[i] is the number of units the customer ordered of that product.
Implement the Cashier class:

Cashier(int n, int discount, int[] products, int[] prices) Initializes the object with n, the discount, the products and their prices.
double getBill(int[] product, int[] amount) returns the value of the bill and apply the discount if needed. Answers within 10^-5 of the actual value will be accepted as correct.

 
Example 1:
Input
["Cashier","getBill","getBill","getBill","getBill","getBill","getBill","getBill"]
[[3,50,[1,2,3,4,5,6,7],[100,200,300,400,300,200,100]],[[1,2],[1,2]],[[3,7],[10,10]],[[1,2,3,4,5,6,7],[1,1,1,1,1,1,1]],[[4],[10]],[[7,3],[10,10]],[[7,5,3,1,6,4,2],[10,10,10,9,9,9,7]],[[2,3,5],[5,3,2]]]
Output
[null,500.0,4000.0,800.0,4000.0,4000.0,7350.0,2500.0]
Explanation
Cashier cashier = new Cashier(3,50,[1,2,3,4,5,6,7],[100,200,300,400,300,200,100]);
cashier.getBill([1,2],[1,2]);                        // return 500.0, bill = 1 * 100 + 2 * 200 = 500.
cashier.getBill([3,7],[10,10]);                      // return 4000.0
cashier.getBill([1,2,3,4,5,6,7],[1,1,1,1,1,1,1]);    // return 800.0, The bill was 1600.0 but as this is the third customer, he has a discount of 50% which means his bill is only 1600 - 1600 * (50 / 100) = 800.
cashier.getBill([4],[10]);                           // return 4000.0
cashier.getBill([7,3],[10,10]);                      // return 4000.0
cashier.getBill([7,5,3,1,6,4,2],[10,10,10,9,9,9,7]); // return 7350.0, Bill was 14700.0 but as the system counted three more customers, he will have a 50% discount and the bill becomes 7350.0
cashier.getBill([2,3,5],[5,3,2]);                    // return 2500.0

 
Constraints:

1 <= n <= 10^4
0 <= discount <= 100
1 <= products.length <= 200
1 <= products[i] <= 200
There are not repeated elements in the array products.
prices.length == products.length
1 <= prices[i] <= 1000
1 <= product.length <= products.length
product[i] exists in products.
amount.length == product.length
1 <= amount[i] <= 1000
At most 1000 calls will be made to getBill.
Answers within 10^-5 of the actual value will be accepted as correct.

Source: leetcode | Difficulty: MEDIUM
Tags: Data structures

Starter code: class Cashier:
    def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
    def getBill(self, product: List[int], amount: List[int]) -> float:
# Your Cashier object will be instantiated and called as such:
# obj = Cashier(n, discount, products, prices)
# param_1 = obj.getBill(product,amount)

Solutions:
class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.count = 0
		self.discount = discount
		self.products = {}
		for i in range(0, len(products)):
			self.products[products[i]] = prices[i]

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.count += 1
		subtotal = 0
		for i in range(0, len(product)):
			subtotal += self.products[product[i]] * amount[i]
		if self.count == self.n:
			subtotal = subtotal - self.discount * subtotal / 100
			self.count = 0
		return subtotal


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.count = 0
		self.discount = discount
		self.prices = {prod: price for (prod, price) in zip(products, prices)}

	def getBill(self, product: List[int], amount: List[int]) -> float:
		bill = 0
		for (p, a) in zip(product, amount):
			bill += self.prices[p] * a
		self.count += 1
		if self.count % self.n == 0:
			bill *= 1 - self.discount / 100.0
		return bill


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.discount = discount / 100
		self.n = n
		self.memo = dict()
		for (a, b) in zip(products, prices):
			self.memo[a] = b
		self.idx = 0

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.idx += 1
		res = 0
		for (a, b) in zip(product, amount):
			res += self.memo[a] * b
		if self.idx % self.n == 0:
			res *= 1 - self.discount
		return res


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.discount = discount
		self.prices = {product: price for (product, price) in zip(products, prices)}
		self.customer_number = 1

	def getBill(self, product: List[int], amount: List[int]) -> float:
		total = sum((self.prices[product[i]] * amount[i] for i in range(len(product))))
		if self.customer_number % self.n == 0:
			total *= 1 - self.discount / 100
		self.customer_number += 1
		return total


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.c = 0
		self.n = n
		self.discount = discount
		self.prod_price = {prod: price for (prod, price) in zip(products, prices)}

	def getBill(self, product: List[int], amount: List[int]) -> float:
		cost = 0
		for (p, a) in zip(product, amount):
			cost += self.prod_price[p] * a
		self.c += 1
		if self.c == self.n:
			cost -= cost * self.discount / 100
			self.c = 0
		return cost


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.N = n
		self.count = 0
		self.discount = discount
		self.products = products
		self.prices = prices
		self.reverse_dict = {i: j for (j, i) in enumerate(products)}

	def getBill(self, product: List[int], amount: List[int]) -> float:
		price_total = 0
		for (i, am) in zip(product, amount):
			price_total += am * self.prices[self.reverse_dict[i]]
		self.count += 1
		if self.count >= self.N:
			price_total *= 1 - self.discount / 100.0
			self.count = 0
		return price_total


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.counter = 0
		(self.n, self.discount, self.products) = (n, discount, products)
		self.prices = {}
		for (product_id, price) in zip(products, prices):
			self.prices[product_id] = price

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.counter += 1
		self.counter %= self.n
		cost_per_item = [self.prices[p] for p in product]
		total_bill = sum([x[0] * x[1] for x in zip(cost_per_item, amount)])
		if not self.counter:
			total_bill = total_bill * (100 - self.discount) / 100
		return total_bill


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.discount = discount
		self.products = {}
		for (idx, item) in enumerate(products):
			self.products[item] = prices[idx]
		self.count = 0

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.count += 1
		bill = 0
		for (idx, item) in enumerate(product):
			bill += self.products[item] * amount[idx]
		if self.count % self.n == 0:
			return (100 - self.discount) / 100 * bill
		else:
			return bill


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self._n = n
		self._discount = discount
		self._id_to_price = {products[i]: prices[i] for i in range(len(products))}
		self._customer_no = 0

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self._customer_no += 1
		num_purchases = len(product)
		bill = 0
		for i in range(num_purchases):
			product_id = product[i]
			quantity_of_product = amount[i]
			bill += self._id_to_price[product_id] * quantity_of_product
		if self._customer_no == self._n:
			self._customer_no = 0
			return bill - self._discount * bill / 100
		else:
			return bill


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.discount_limit = n
		self.discount_count = n
		self.discount = discount
		self.prices = prices
		self.products = {}
		i = 0
		for p in products:
			self.products[str(p)] = i
			i += 1

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.discount_count -= 1
		bill = 0.0
		for item in range(len(product)):
			bill += self.prices[self.products[str(product[item])]] * amount[item]
		if self.discount_count < 1:
			bill = bill - self.discount * bill / 100
			self.discount_count = self.discount_limit
		return bill


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.discount = discount
		self.products = {p: i for (i, p) in enumerate(products)}
		self.prices = prices
		self.counter = 0

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.counter += 1
		cost = sum([self.prices[self.products[p]] * amount[i] for (i, p) in enumerate(product)])
		if self.counter % self.n == 0:
			return cost - self.discount * cost / 100
		else:
			return cost


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.count = 0
		self.n = n
		self.discount = discount
		self.products = {}
		for i in range(len(products)):
			self.products[products[i]] = prices[i]

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.count += 1
		cost = 0
		for (pr, am) in zip(product, amount):
			cost += self.products[pr] * am
		if self.count % self.n == 0:
			self.count = 0
			return cost * (1 - self.discount / 100)
		return cost


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.discount = discount
		prod_price = {}
		for i in range(len(products)):
			prod_id = products[i]
			price = prices[i]
			prod_price[prod_id] = price
		self.prod_price = prod_price
		self.count = 0

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.count += 1
		if self.count % self.n == 0:
			d = self.discount
		else:
			d = 0
		bill = 0
		for i in range(len(product)):
			p_id = product[i]
			a = amount[i]
			price = self.prod_price[p_id]
			bill += a * price
		return bill - bill * d / 100


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.prices = dict(list(zip(products, prices)))
		self.discount = discount
		self.cnt = 0
		self.n = n

	def getBill(self, product: List[int], amount: List[int]) -> float:
		total = 0
		self.cnt += 1
		for (i, p) in enumerate(product):
			total += self.prices[p] * amount[i]
		if self.cnt % self.n == 0:
			return total * (1 - self.discount / 100)
		else:
			return total


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.discount = discount
		self.products = products
		self.prices = prices
		self.mapping = {}
		for i in range(len(prices)):
			self.mapping[products[i]] = prices[i]
		self.customer = 0

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.customer += 1
		total = 0.0
		for i in range(len(product)):
			total += self.mapping[product[i]] * amount[i]
		if self.customer % self.n == 0:
			total = total - self.discount / 100 * total
		return total


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.discount = discount
		self.n = n
		self.prices = {key: prices[idx] for (idx, key) in enumerate(products)}
		self.count = 0

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.count += 1
		res = sum([amount[i] * self.prices[k] for (i, k) in enumerate(product)])
		if self.count == self.n:
			res *= 1 - self.discount / 100
			self.count = 0
		return res


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.count = 0
		self.discount_factor = 1 - discount / 100
		self.prices_dict = {}
		for (product, price) in zip(products, prices):
			self.prices_dict[product] = price

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.count += 1
		discount_factor = 1
		if self.count == self.n:
			discount_factor = self.discount_factor
			self.count = 0
		price_sum = 0.0
		for (p, a) in zip(product, amount):
			price_sum += a * self.prices_dict[p]
		return discount_factor * price_sum


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.discount = discount
		self.id_price_map = {}
		for (i, product_id) in enumerate(products):
			self.id_price_map[product_id] = prices[i]
		self.customer_count = 0

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.customer_count += 1
		total_price = 0
		for (i, product_id) in enumerate(product):
			total_price += self.id_price_map[product_id] * amount[i]
		if self.customer_count % self.n == 0:
			total_price -= self.discount * total_price / 100
		return total_price


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self._counter = 0
		self._n = n
		self._discount = discount
		self._products: Dict[int, int] = {products[i]: prices[i] for i in range(len(products))}

	def getBill(self, product: List[int], amount: List[int]) -> float:
		bill = sum([self._products[pid] * amt for (pid, amt) in zip(product, amount)])
		self._counter += 1
		if self._counter % self._n == 0:
			bill -= self._discount * bill / 100
			self._counter = 0
		return bill


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.count = 0
		self.propri = {}
		self.discount = discount
		for i in range(len(products)):
			self.propri[products[i]] = prices[i]

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.count += 1
		discount_flag = False
		if self.count % self.n == 0:
			discount_flag = True
		result = 0
		for i in range(len(product)):
			result += self.propri[product[i]] * amount[i]
		if discount_flag:
			result *= (100 - self.discount) / 100
		return result


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.discount = discount
		self.count = 0
		self.price_dict = {}
		for (i, item) in enumerate(products):
			self.price_dict[item] = prices[i]

	def getBill(self, product: List[int], amount: List[int]) -> float:
		total = 0.0
		self.count += 1
		for (i, idx) in enumerate(product):
			total += amount[i] * self.price_dict[idx]
		if self.count % self.n == 0 and self.count > 0:
			total -= total * self.discount / 100.0
		return total


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		(self.n, self.i, self.d) = (n, 0, discount)
		self.price = {product: price for (product, price) in zip(products, prices)}

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.i += 1
		s = sum((self.price[p] * a for (p, a) in zip(product, amount)))
		return s if self.i % self.n else s * (1 - self.d / 100)


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.counter = 0
		self.d = {}
		self.discount = discount
		self.n = n
		for (i, x) in enumerate(products):
			self.d[x] = prices[i]

	def getBill(self, product: List[int], amount: List[int]) -> float:
		total = 0
		for (i, productId) in enumerate(product):
			total += self.d[productId] * amount[i]
		self.counter += 1
		if self.counter % self.n == 0:
			total = total - self.discount * total / 100
		return total


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.discount = discount
		self.productToId = {product: productId for (productId, product) in enumerate(products)}
		self.productIdToPrice = {productId: price for (productId, price) in enumerate(prices)}
		self.customerNumber = 0

	def calculateCost(self, productsBought: List[int], amounts: List[int]) -> float:
		cost = 0
		for i in range(len(productsBought)):
			(product, productAmount) = (productsBought[i], amounts[i])
			price = self.getProductPrice(product)
			cost += price * productAmount
		return cost

	def calculateDiscountedCost(self, cost: float) -> float:
		return cost - self.discount * cost / 100

	def getProductPrice(self, product: int) -> int:
		return self.productIdToPrice[self.productToId[product]]

	def getBill(self, productsBought: List[int], amounts: List[int]) -> float:
		self.customerNumber += 1
		cost = self.calculateCost(productsBought, amounts)
		if self.customerNumber == self.n:
			cost = self.calculateDiscountedCost(cost)
			self.customerNumber = 0
		return cost


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.product_to_price = dict(list(zip(products, prices)))
		self.discount = discount / 100
		self.n = n
		self.cur_customer = 0

	def getBill(self, product: List[int], amount: List[int]) -> float:
		prices = [self.product_to_price[prod] * amt for (prod, amt) in zip(product, amount)]
		self.cur_customer += 1
		disc = self.discount if self.cur_customer % self.n == 0 else 0
		return sum(prices) * (1 - disc)


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.prod = {}
		for i in range(0, len(products)):
			self.prod[products[i]] = prices[i]
		self.idx = n
		self.dis = 1 - discount / 100
		self.cur_idx = 0

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.cur_idx += 1
		s = 0
		for i in range(0, len(product)):
			s += self.prod[product[i]] * amount[i]
		if self.cur_idx % self.idx == 0:
			s *= self.dis
		return s


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = self.m = n
		self.discount = discount
		self.prices = {pro: pri for (pro, pri) in zip(products, prices)}

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.n -= 1
		res = sum((self.prices[pr] * am for (pr, am) in zip(product, amount)))
		if not self.n:
			self.n = self.m
			return res - res * (self.discount / 100)
		return res


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.discount = discount
		self.index = 0
		self.prices = collections.defaultdict(int)
		for i in range(len(products)):
			self.prices[products[i]] = prices[i]

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.index += 1
		total = sum([self.prices[product[i]] * amount[i] for i in range(len(product))])
		if self.index % self.n == 0:
			total = (1 - self.discount / 100) * total
		return float(total)


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.counter_ = 0
		self.discount_ = discount
		self.max_ = n
		self.dicts_ = {}
		for i in range(len(products)):
			self.dicts_[products[i]] = prices[i]

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.counter_ += 1
		bill = 0
		for i in range(len(product)):
			bill += self.dicts_[product[i]] * amount[i]
		if self.counter_ == self.max_:
			bill *= 1 - self.discount_ / 100
			self.counter_ = 0
		return bill


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.discount = discount
		self.products = products
		self.prices = prices
		self.crCustomer = 0
		self.dic_prices = dict(list(zip(products, prices)))

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.crCustomer += 1
		if self.crCustomer % self.n == 0:
			discount = self.discount
		else:
			discount = 0
		return sum([(1 - discount / 100) * self.dic_prices[p] * a for (p, a) in zip(product, amount)])


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.counter = 0
		self.period = n
		self.discount = 1 - discount / 100
		self.prices = {}
		for (index, productId) in enumerate(products):
			self.prices[productId] = prices[index]

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.counter += 1
		totalAmount = 0
		for (index, productId) in enumerate(product):
			totalAmount += self.prices[productId] * amount[index]
		if self.counter % self.period == 0:
			totalAmount = self.discount * totalAmount
		return totalAmount


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.p = dict()
		for (p1, p2) in zip(products, prices):
			self.p[p1] = p2
		self.d = discount
		self.n = n
		self.count = 0

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.count += 1
		bill = 0
		for (p, a) in zip(product, amount):
			bill += self.p[p] * a
		if self.count == self.n:
			bill -= bill * self.d / 100
			self.count = 0
		return bill


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.discount = discount
		self.product_prices = dict(list(zip(products, prices)))
		self.current = 0

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.current += 1
		bill = 0
		for i in range(len(amount)):
			bill += amount[i] * self.product_prices[product[i]]
		if self.current == self.n:
			self.current = 0
			return bill - bill * (self.discount / 100)
		return bill


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.temp = n
		self.discount = 1 - discount / 100
		self.prices = {product: price for (product, price) in zip(products, prices)}

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.n -= 1
		total = sum((self.prices[product_id] * quantity for (product_id, quantity) in zip(product, amount)))
		if self.n == 0:
			total *= self.discount
			self.n = self.temp
		return total


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.product_map = {products[i]: prices[i] for i in range(len(products))}
		self.prices = prices
		self.customer_count = 0
		self.discount = discount / 100
		self.discount_customer = n

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.customer_count += 1
		bill = 0
		discount = 0
		for i in range(len(product)):
			bill += amount[i] * self.product_map[product[i]]
		if self.customer_count == self.discount_customer:
			discount = self.discount * bill
			self.customer_count = 0
			bill = bill - discount
		return bill


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.discount = discount
		self.n = n
		self.products = {product: price for (product, price) in zip(products, prices)}
		self.customers = 0

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.customers += 1
		bill = sum([self.products[prod] * amnt for (prod, amnt) in zip(product, amount)])
		if self.customers % self.n == 0:
			self.customers = 0
			bill -= bill * self.discount / 100
		return bill


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.discount = discount
		self.products = products
		self.prices = prices
		self.counter = 1

	def getBill(self, product: List[int], amounts: List[int]) -> float:
		bill = 0
		for (i, product_id) in enumerate(product):
			bill += amounts[i] * self.prices[self.products.index(product_id)]
		if self.counter == self.n:
			bill -= bill * (self.discount / 100)
			self.counter = 1
		else:
			self.counter += 1
		return bill


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.discount = discount
		self.di = dict()
		for (i, j) in zip(products, prices):
			self.di[i] = j
		self.present = 0

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.present += 1
		if self.present == self.n:
			tot = 0
			for (pro, amt) in zip(product, amount):
				tot += self.di[pro] * amt
			tot -= self.discount * tot / 100
			self.present = 0
			return tot
		else:
			tot = 0
			for (pro, amt) in zip(product, amount):
				tot += self.di[pro] * amt
			return tot


class Cashier:

	def __init__(self, n: int, discount: int, products, prices):
		self.prices_dict = dict()
		for (p, m) in zip(products, prices):
			self.prices_dict[p] = m
		self.discount = discount
		self.counts = 0
		self.n = n

	def getBill(self, product, amount) -> float:
		self.counts += 1
		money = sum((self.prices_dict[p] * a for (p, a) in zip(product, amount)))
		if self.counts % self.n == 0:
			money = money * (1 - self.discount / 100)
		return money


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.discount = discount
		dicta = {}
		self.products = products
		self.prices = prices
		self.nown = n

	def getBill(self, product: List[int], amount: List[int]) -> float:
		applied = False
		if self.nown == 1:
			applied = True
			self.nown = self.n
		else:
			self.nown -= 1
		summoney = 0
		for i in range(len(product)):
			summoney += self.prices[self.products.index(product[i])] * amount[i]
		if applied:
			return summoney - summoney * self.discount / 100
		else:
			return summoney


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.count = 0
		self.discount = discount
		self.products = products.copy()
		self.prices = prices.copy()

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.count += 1
		bill = 0
		for (quantity, pid) in zip(amount, product):
			index = self.products.index(pid)
			bill += self.prices[index] * quantity
		if self.count == self.n:
			bill = bill - self.discount * bill / 100
			self.count = 0
		return bill


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.discountNumber = n
		self.discount = discount
		self.productsList = products
		self.pricesList = prices
		self.currentCustNum = 1

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.cost = 0
		for i in range(0, len(product)):
			self.priceIndex = self.productsList.index(product[i])
			self.cost += self.pricesList[self.priceIndex] * amount[i]
		if self.currentCustNum == self.discountNumber:
			self.cost = self.cost - self.discount * self.cost / 100
			self.currentCustNum = 1
		else:
			self.currentCustNum += 1
		return self.cost


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		(self.n, self.c, self.discount, self.d) = (n, n, 1 - discount / 100, {})
		for i in range(len(products)):
			self.d[products[i]] = prices[i]

	def getBill(self, product: List[int], amount: List[int]) -> float:
		bill = 0
		for (i, v) in enumerate(product):
			bill += self.d[v] * amount[i]
		self.n -= 1
		if self.n == 0:
			bill *= self.discount
			self.n = self.c
		return bill


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.discount = discount
		self.products = products
		self.prices = prices
		self.client = 0

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.client += 1
		bill = 0
		for (p, a) in zip(product, amount):
			idx = self.products.index(p)
			bill += a * self.prices[idx]
		if self.client == self.n:
			self.client = 0
			bill = bill - self.discount * bill / 100
		return bill


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.d = discount
		self.count = 0
		self.p = {}
		for i in range(len(products)):
			if products[i] not in self.p:
				self.p[products[i]] = prices[i]
			else:
				self.p[products[i]] += prices[i]

	def getBill(self, product: List[int], amount: List[int]) -> float:
		bill = 0
		self.count += 1
		for i in range(len(product)):
			bill += self.p[product[i]] * amount[i]
		if self.count != 0 and self.count % self.n == 0:
			bill = bill - self.d * bill / 100
		return bill


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.discount = discount
		self.products = products
		self.prices = prices
		self.customer = 1

	def getBill(self, product: List[int], amount: List[int]) -> float:
		bill = 0
		for i in range(len(product)):
			ids = self.products.index(product[i])
			bill += self.prices[ids] * amount[i]
		if self.customer % self.n == 0:
			bill = bill - self.discount * bill / 100
		self.customer += 1
		return bill


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.n_customer = 0
		self.discount = discount
		self.products = products
		self.prices = prices

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.n_customer += 1
		bill = 0
		for i in range(len(product)):
			p = product[i]
			product_index = self.products.index(p)
			bill += amount[i] * self.prices[product_index]
		if self.n_customer % self.n == 0:
			return bill - bill * self.discount / 100
		return bill


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.num_disc = n
		self.disc = discount
		self.prod = products
		self.pric = prices
		self.count = 0

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.count += 1
		total = 0
		for i in range(len(product)):
			ind = self.prod.index(product[i])
			total += self.pric[ind] * amount[i]
		if self.count != 0 and self.count % self.num_disc == 0:
			total = total - self.disc * total / 100
			self.count = 0
		return total


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.dic = {}
		for (x, y) in zip(products, prices):
			self.dic[x] = y
		self.dis = discount
		self.k = 0

	def getBill(self, product: List[int], amount: List[int]) -> float:
		total = 0
		for (x, y) in zip(product, amount):
			total += self.dic[x] * y
		self.k += 1
		if self.k == self.n:
			self.k = 0
			return total - total * (self.dis / 100.0)
		else:
			return total


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.cur = 0
		self.discount = discount
		self.products = products
		self.prices = prices

	def getBill(self, product: List[int], amount: List[int]) -> float:
		temp = []
		for i in range(len(product)):
			temp.append([product[i], amount[i]])
		self.cur += 1
		result = 0
		for (id, number) in temp:
			real_id = self.products.index(id)
			price = self.prices[real_id]
			result += price * number
		if self.cur % self.n == 0:
			result = result * (1 - self.discount / 100)
		return result


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.discount = discount
		self.prices = dict(list(zip(products, prices)))
		self.pos = 0

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.pos += 1
		sz = len(product)
		cost = sum([self.prices[product[i]] * amount[i] for i in range(sz)])
		if self.pos % self.n == 0:
			cost = cost - self.discount * cost / 100
		return cost


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.ctr = 0
		self.n = n
		self.discount = (100 - discount) / 100
		self.products = dict()
		for idx in range(len(products)):
			self.products[products[idx]] = prices[idx]

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.ctr += 1
		cost = 0
		for idx in range(len(product)):
			itemId = product[idx]
			cost += self.products[itemId] * amount[idx]
		if self.ctr % self.n == 0:
			self.ctr = 0
			cost = self.discount * cost
		return cost


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.N = n
		self.count = n
		self.disc = discount
		self.p_dict = {}
		for (pd, pr) in zip(products, prices):
			self.p_dict[pd] = pr

	def getBill(self, product: List[int], amount: List[int]) -> float:
		total_p = 0
		for (pd, num) in zip(product, amount):
			total_p += self.p_dict[pd] * num
		if self.count == 1:
			total_p = total_p * (1 - self.disc / 100)
			self.count = self.N
		else:
			self.count -= 1
		return total_p


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.discount = discount
		self.products = products
		self.prices = prices
		self.counter = 0

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.counter += 1
		ans = 0
		for i in range(len(product)):
			ans += self.prices[self.products.index(product[i])] * amount[i]
		if self.counter == self.n:
			self.counter = 0
			ans = ans - self.discount * ans / 100.0
		return ans


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.discount = discount
		self.products = products
		self.prices = prices
		self.top = 0

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.top += 1
		bill = 0
		for (i, p) in enumerate(product):
			index = self.products.index(p)
			cost = self.prices[index]
			total = cost * amount[i]
			bill += total
		if self.top == self.n:
			bill -= self.discount * bill / 100
			self.top = 0
		return bill


class Cashier:

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.customer_num = 1 % n
		self.n = n
		self.discount = discount
		self.prices_by_id = {product_id: prices[idx] for (idx, product_id) in enumerate(products)}

	def getBill(self, product: List[int], amount: List[int]) -> float:
		if self.customer_num == 0:
			multiplier = 1 - self.discount / 100
		else:
			multiplier = 1
		self.customer_num = (self.customer_num + 1) % self.n
		return sum([self.prices_by_id[product[i]] * amount[i] for i in range(len(product))]) * multiplier


class Cashier:
	from functools import lru_cache

	def __init__(self, n: int, discount: int, products: List[int], prices: List[int]):
		self.n = n
		self.d = discount
		self.p = products
		self.amt = prices
		self.c = 0

	@lru_cache(maxsize=128)
	def compute_amount(self, pdt, qty):
		bill = 0
		for (p, q) in zip(pdt, qty):
			i = self.p.index(p)
			bill += self.amt[i] * q
		return bill

	def getBill(self, product: List[int], amount: List[int]) -> float:
		self.c += 1
		amt = self.compute_amount(tuple(product), tuple(amount))
		if self.c % self.n == 0 and self.d:
			return amt - amt * self.d / 100
		else:
			return amt