message stringlengths 2 30.5k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 237 109k | cluster float64 10 10 | __index_level_0__ int64 474 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Vasya went to the supermarket to get some groceries. He walked about the supermarket for a long time and got a basket full of products. Now he needs to choose the cashier to pay for the products.
There are n cashiers at the exit from the supermarket. At the moment the queue for the i-th cashier already has ki people. The j-th person standing in the queue to the i-th cashier has mi, j items in the basket. Vasya knows that:
* the cashier needs 5 seconds to scan one item;
* after the cashier scans each item of some customer, he needs 15 seconds to take the customer's money and give him the change.
Of course, Vasya wants to select a queue so that he can leave the supermarket as soon as possible. Help him write a program that displays the minimum number of seconds after which Vasya can get to one of the cashiers.
Input
The first line contains integer n (1 ≤ n ≤ 100) — the number of cashes in the shop. The second line contains n space-separated integers: k1, k2, ..., kn (1 ≤ ki ≤ 100), where ki is the number of people in the queue to the i-th cashier.
The i-th of the next n lines contains ki space-separated integers: mi, 1, mi, 2, ..., mi, ki (1 ≤ mi, j ≤ 100) — the number of products the j-th person in the queue for the i-th cash has.
Output
Print a single integer — the minimum number of seconds Vasya needs to get to the cashier.
Examples
Input
1
1
1
Output
20
Input
4
1 4 3 2
100
1 2 2 3
1 9 1
7 8
Output
100
Note
In the second test sample, if Vasya goes to the first queue, he gets to the cashier in 100·5 + 15 = 515 seconds. But if he chooses the second queue, he will need 1·5 + 2·5 + 2·5 + 3·5 + 4·15 = 100 seconds. He will need 1·5 + 9·5 + 1·5 + 3·15 = 100 seconds for the third one and 7·5 + 8·5 + 2·15 = 105 seconds for the fourth one. Thus, Vasya gets to the cashier quicker if he chooses the second or the third queue. | instruction | 0 | 30,433 | 10 | 60,866 |
Tags: implementation
Correct Solution:
```
def line_to_cashier(arr,b):
min=10000000000
for i in range(len(arr)):
tp=arr[i]*15
sum_array=sum(b[i])*5
total=tp+sum_array
#print(total)
if total<min:
final_ans=total
min=total
#print('______')
print(final_ans)
n=int(input(''))
arr=list(map(int,input('').split()))
b=[]
for i in range(n):
a=list(map(int,input('').split()))
b.append(a)
line_to_cashier(arr,b)
``` | output | 1 | 30,433 | 10 | 60,867 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Vasya went to the supermarket to get some groceries. He walked about the supermarket for a long time and got a basket full of products. Now he needs to choose the cashier to pay for the products.
There are n cashiers at the exit from the supermarket. At the moment the queue for the i-th cashier already has ki people. The j-th person standing in the queue to the i-th cashier has mi, j items in the basket. Vasya knows that:
* the cashier needs 5 seconds to scan one item;
* after the cashier scans each item of some customer, he needs 15 seconds to take the customer's money and give him the change.
Of course, Vasya wants to select a queue so that he can leave the supermarket as soon as possible. Help him write a program that displays the minimum number of seconds after which Vasya can get to one of the cashiers.
Input
The first line contains integer n (1 ≤ n ≤ 100) — the number of cashes in the shop. The second line contains n space-separated integers: k1, k2, ..., kn (1 ≤ ki ≤ 100), where ki is the number of people in the queue to the i-th cashier.
The i-th of the next n lines contains ki space-separated integers: mi, 1, mi, 2, ..., mi, ki (1 ≤ mi, j ≤ 100) — the number of products the j-th person in the queue for the i-th cash has.
Output
Print a single integer — the minimum number of seconds Vasya needs to get to the cashier.
Examples
Input
1
1
1
Output
20
Input
4
1 4 3 2
100
1 2 2 3
1 9 1
7 8
Output
100
Note
In the second test sample, if Vasya goes to the first queue, he gets to the cashier in 100·5 + 15 = 515 seconds. But if he chooses the second queue, he will need 1·5 + 2·5 + 2·5 + 3·5 + 4·15 = 100 seconds. He will need 1·5 + 9·5 + 1·5 + 3·15 = 100 seconds for the third one and 7·5 + 8·5 + 2·15 = 105 seconds for the fourth one. Thus, Vasya gets to the cashier quicker if he chooses the second or the third queue. | instruction | 0 | 30,434 | 10 | 60,868 |
Tags: implementation
Correct Solution:
```
god = 10**18
x = int(input())
items = list(map(int, input().split(' ')))
for i in range(x):
a = list(map(int, input().split(' ')))
god = min(god, sum(a)*5+15*items[i])
print(god)
``` | output | 1 | 30,434 | 10 | 60,869 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Vasya went to the supermarket to get some groceries. He walked about the supermarket for a long time and got a basket full of products. Now he needs to choose the cashier to pay for the products.
There are n cashiers at the exit from the supermarket. At the moment the queue for the i-th cashier already has ki people. The j-th person standing in the queue to the i-th cashier has mi, j items in the basket. Vasya knows that:
* the cashier needs 5 seconds to scan one item;
* after the cashier scans each item of some customer, he needs 15 seconds to take the customer's money and give him the change.
Of course, Vasya wants to select a queue so that he can leave the supermarket as soon as possible. Help him write a program that displays the minimum number of seconds after which Vasya can get to one of the cashiers.
Input
The first line contains integer n (1 ≤ n ≤ 100) — the number of cashes in the shop. The second line contains n space-separated integers: k1, k2, ..., kn (1 ≤ ki ≤ 100), where ki is the number of people in the queue to the i-th cashier.
The i-th of the next n lines contains ki space-separated integers: mi, 1, mi, 2, ..., mi, ki (1 ≤ mi, j ≤ 100) — the number of products the j-th person in the queue for the i-th cash has.
Output
Print a single integer — the minimum number of seconds Vasya needs to get to the cashier.
Examples
Input
1
1
1
Output
20
Input
4
1 4 3 2
100
1 2 2 3
1 9 1
7 8
Output
100
Note
In the second test sample, if Vasya goes to the first queue, he gets to the cashier in 100·5 + 15 = 515 seconds. But if he chooses the second queue, he will need 1·5 + 2·5 + 2·5 + 3·5 + 4·15 = 100 seconds. He will need 1·5 + 9·5 + 1·5 + 3·15 = 100 seconds for the third one and 7·5 + 8·5 + 2·15 = 105 seconds for the fourth one. Thus, Vasya gets to the cashier quicker if he chooses the second or the third queue. | instruction | 0 | 30,435 | 10 | 60,870 |
Tags: implementation
Correct Solution:
```
n=int(input())
ans=1000005
l=list(map(int,input().split()))
for i in range(n):
ans=min(ans,sum(map(int,input().split()))*5+l[i]*15)
print(ans)
``` | output | 1 | 30,435 | 10 | 60,871 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Vasya went to the supermarket to get some groceries. He walked about the supermarket for a long time and got a basket full of products. Now he needs to choose the cashier to pay for the products.
There are n cashiers at the exit from the supermarket. At the moment the queue for the i-th cashier already has ki people. The j-th person standing in the queue to the i-th cashier has mi, j items in the basket. Vasya knows that:
* the cashier needs 5 seconds to scan one item;
* after the cashier scans each item of some customer, he needs 15 seconds to take the customer's money and give him the change.
Of course, Vasya wants to select a queue so that he can leave the supermarket as soon as possible. Help him write a program that displays the minimum number of seconds after which Vasya can get to one of the cashiers.
Input
The first line contains integer n (1 ≤ n ≤ 100) — the number of cashes in the shop. The second line contains n space-separated integers: k1, k2, ..., kn (1 ≤ ki ≤ 100), where ki is the number of people in the queue to the i-th cashier.
The i-th of the next n lines contains ki space-separated integers: mi, 1, mi, 2, ..., mi, ki (1 ≤ mi, j ≤ 100) — the number of products the j-th person in the queue for the i-th cash has.
Output
Print a single integer — the minimum number of seconds Vasya needs to get to the cashier.
Examples
Input
1
1
1
Output
20
Input
4
1 4 3 2
100
1 2 2 3
1 9 1
7 8
Output
100
Note
In the second test sample, if Vasya goes to the first queue, he gets to the cashier in 100·5 + 15 = 515 seconds. But if he chooses the second queue, he will need 1·5 + 2·5 + 2·5 + 3·5 + 4·15 = 100 seconds. He will need 1·5 + 9·5 + 1·5 + 3·15 = 100 seconds for the third one and 7·5 + 8·5 + 2·15 = 105 seconds for the fourth one. Thus, Vasya gets to the cashier quicker if he chooses the second or the third queue. | instruction | 0 | 30,436 | 10 | 60,872 |
Tags: implementation
Correct Solution:
```
R = lambda:map(int,input().split())
n, = R()
print(min(15*k+5*sum(R())for k in R()))
``` | output | 1 | 30,436 | 10 | 60,873 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Vasya went to the supermarket to get some groceries. He walked about the supermarket for a long time and got a basket full of products. Now he needs to choose the cashier to pay for the products.
There are n cashiers at the exit from the supermarket. At the moment the queue for the i-th cashier already has ki people. The j-th person standing in the queue to the i-th cashier has mi, j items in the basket. Vasya knows that:
* the cashier needs 5 seconds to scan one item;
* after the cashier scans each item of some customer, he needs 15 seconds to take the customer's money and give him the change.
Of course, Vasya wants to select a queue so that he can leave the supermarket as soon as possible. Help him write a program that displays the minimum number of seconds after which Vasya can get to one of the cashiers.
Input
The first line contains integer n (1 ≤ n ≤ 100) — the number of cashes in the shop. The second line contains n space-separated integers: k1, k2, ..., kn (1 ≤ ki ≤ 100), where ki is the number of people in the queue to the i-th cashier.
The i-th of the next n lines contains ki space-separated integers: mi, 1, mi, 2, ..., mi, ki (1 ≤ mi, j ≤ 100) — the number of products the j-th person in the queue for the i-th cash has.
Output
Print a single integer — the minimum number of seconds Vasya needs to get to the cashier.
Examples
Input
1
1
1
Output
20
Input
4
1 4 3 2
100
1 2 2 3
1 9 1
7 8
Output
100
Note
In the second test sample, if Vasya goes to the first queue, he gets to the cashier in 100·5 + 15 = 515 seconds. But if he chooses the second queue, he will need 1·5 + 2·5 + 2·5 + 3·5 + 4·15 = 100 seconds. He will need 1·5 + 9·5 + 1·5 + 3·15 = 100 seconds for the third one and 7·5 + 8·5 + 2·15 = 105 seconds for the fourth one. Thus, Vasya gets to the cashier quicker if he chooses the second or the third queue. | instruction | 0 | 30,437 | 10 | 60,874 |
Tags: implementation
Correct Solution:
```
n=int(input())
k=list(map(int,input().split()))
m=[]
for i in range(n):
m.append(list(map(int,input().split())))
k=0
f=[]
for i in m:
for j in range(len(i)):
k=k+(i[j]*5)+15
f.append(k)
k=0
a=min(f)
print(a)
``` | output | 1 | 30,437 | 10 | 60,875 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Vasya went to the supermarket to get some groceries. He walked about the supermarket for a long time and got a basket full of products. Now he needs to choose the cashier to pay for the products.
There are n cashiers at the exit from the supermarket. At the moment the queue for the i-th cashier already has ki people. The j-th person standing in the queue to the i-th cashier has mi, j items in the basket. Vasya knows that:
* the cashier needs 5 seconds to scan one item;
* after the cashier scans each item of some customer, he needs 15 seconds to take the customer's money and give him the change.
Of course, Vasya wants to select a queue so that he can leave the supermarket as soon as possible. Help him write a program that displays the minimum number of seconds after which Vasya can get to one of the cashiers.
Input
The first line contains integer n (1 ≤ n ≤ 100) — the number of cashes in the shop. The second line contains n space-separated integers: k1, k2, ..., kn (1 ≤ ki ≤ 100), where ki is the number of people in the queue to the i-th cashier.
The i-th of the next n lines contains ki space-separated integers: mi, 1, mi, 2, ..., mi, ki (1 ≤ mi, j ≤ 100) — the number of products the j-th person in the queue for the i-th cash has.
Output
Print a single integer — the minimum number of seconds Vasya needs to get to the cashier.
Examples
Input
1
1
1
Output
20
Input
4
1 4 3 2
100
1 2 2 3
1 9 1
7 8
Output
100
Note
In the second test sample, if Vasya goes to the first queue, he gets to the cashier in 100·5 + 15 = 515 seconds. But if he chooses the second queue, he will need 1·5 + 2·5 + 2·5 + 3·5 + 4·15 = 100 seconds. He will need 1·5 + 9·5 + 1·5 + 3·15 = 100 seconds for the third one and 7·5 + 8·5 + 2·15 = 105 seconds for the fourth one. Thus, Vasya gets to the cashier quicker if he chooses the second or the third queue.
Submitted Solution:
```
n = int(input())
ks = [int(i) for i in input().split()]
mi = 10**9
for k in range(n):
mi = min(mi, sum([5*int(i)+15 for i in input().split()]))
print(mi)
``` | instruction | 0 | 30,438 | 10 | 60,876 |
Yes | output | 1 | 30,438 | 10 | 60,877 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Vasya went to the supermarket to get some groceries. He walked about the supermarket for a long time and got a basket full of products. Now he needs to choose the cashier to pay for the products.
There are n cashiers at the exit from the supermarket. At the moment the queue for the i-th cashier already has ki people. The j-th person standing in the queue to the i-th cashier has mi, j items in the basket. Vasya knows that:
* the cashier needs 5 seconds to scan one item;
* after the cashier scans each item of some customer, he needs 15 seconds to take the customer's money and give him the change.
Of course, Vasya wants to select a queue so that he can leave the supermarket as soon as possible. Help him write a program that displays the minimum number of seconds after which Vasya can get to one of the cashiers.
Input
The first line contains integer n (1 ≤ n ≤ 100) — the number of cashes in the shop. The second line contains n space-separated integers: k1, k2, ..., kn (1 ≤ ki ≤ 100), where ki is the number of people in the queue to the i-th cashier.
The i-th of the next n lines contains ki space-separated integers: mi, 1, mi, 2, ..., mi, ki (1 ≤ mi, j ≤ 100) — the number of products the j-th person in the queue for the i-th cash has.
Output
Print a single integer — the minimum number of seconds Vasya needs to get to the cashier.
Examples
Input
1
1
1
Output
20
Input
4
1 4 3 2
100
1 2 2 3
1 9 1
7 8
Output
100
Note
In the second test sample, if Vasya goes to the first queue, he gets to the cashier in 100·5 + 15 = 515 seconds. But if he chooses the second queue, he will need 1·5 + 2·5 + 2·5 + 3·5 + 4·15 = 100 seconds. He will need 1·5 + 9·5 + 1·5 + 3·15 = 100 seconds for the third one and 7·5 + 8·5 + 2·15 = 105 seconds for the fourth one. Thus, Vasya gets to the cashier quicker if he chooses the second or the third queue.
Submitted Solution:
```
n = int(input());m = list(map(int, input().split()));i = 0;a = []
while i < n:
b = list(map(int, input().split()))
j = len(b) * 15
for p in b:
j += p * 5
a.append(j)
i+=1
a.sort();print(a[0])
``` | instruction | 0 | 30,439 | 10 | 60,878 |
Yes | output | 1 | 30,439 | 10 | 60,879 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Vasya went to the supermarket to get some groceries. He walked about the supermarket for a long time and got a basket full of products. Now he needs to choose the cashier to pay for the products.
There are n cashiers at the exit from the supermarket. At the moment the queue for the i-th cashier already has ki people. The j-th person standing in the queue to the i-th cashier has mi, j items in the basket. Vasya knows that:
* the cashier needs 5 seconds to scan one item;
* after the cashier scans each item of some customer, he needs 15 seconds to take the customer's money and give him the change.
Of course, Vasya wants to select a queue so that he can leave the supermarket as soon as possible. Help him write a program that displays the minimum number of seconds after which Vasya can get to one of the cashiers.
Input
The first line contains integer n (1 ≤ n ≤ 100) — the number of cashes in the shop. The second line contains n space-separated integers: k1, k2, ..., kn (1 ≤ ki ≤ 100), where ki is the number of people in the queue to the i-th cashier.
The i-th of the next n lines contains ki space-separated integers: mi, 1, mi, 2, ..., mi, ki (1 ≤ mi, j ≤ 100) — the number of products the j-th person in the queue for the i-th cash has.
Output
Print a single integer — the minimum number of seconds Vasya needs to get to the cashier.
Examples
Input
1
1
1
Output
20
Input
4
1 4 3 2
100
1 2 2 3
1 9 1
7 8
Output
100
Note
In the second test sample, if Vasya goes to the first queue, he gets to the cashier in 100·5 + 15 = 515 seconds. But if he chooses the second queue, he will need 1·5 + 2·5 + 2·5 + 3·5 + 4·15 = 100 seconds. He will need 1·5 + 9·5 + 1·5 + 3·15 = 100 seconds for the third one and 7·5 + 8·5 + 2·15 = 105 seconds for the fourth one. Thus, Vasya gets to the cashier quicker if he chooses the second or the third queue.
Submitted Solution:
```
N = int(input())
cashiers = []
K_unused = input().split()
for i in range(N):
qu_sum = 0
tmp = list(map(int, input().split()))
queue = len(tmp)
for e in tmp:
qu_sum += (e*5) + 15
cashiers.append(qu_sum)
print(min(cashiers))
``` | instruction | 0 | 30,440 | 10 | 60,880 |
Yes | output | 1 | 30,440 | 10 | 60,881 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Vasya went to the supermarket to get some groceries. He walked about the supermarket for a long time and got a basket full of products. Now he needs to choose the cashier to pay for the products.
There are n cashiers at the exit from the supermarket. At the moment the queue for the i-th cashier already has ki people. The j-th person standing in the queue to the i-th cashier has mi, j items in the basket. Vasya knows that:
* the cashier needs 5 seconds to scan one item;
* after the cashier scans each item of some customer, he needs 15 seconds to take the customer's money and give him the change.
Of course, Vasya wants to select a queue so that he can leave the supermarket as soon as possible. Help him write a program that displays the minimum number of seconds after which Vasya can get to one of the cashiers.
Input
The first line contains integer n (1 ≤ n ≤ 100) — the number of cashes in the shop. The second line contains n space-separated integers: k1, k2, ..., kn (1 ≤ ki ≤ 100), where ki is the number of people in the queue to the i-th cashier.
The i-th of the next n lines contains ki space-separated integers: mi, 1, mi, 2, ..., mi, ki (1 ≤ mi, j ≤ 100) — the number of products the j-th person in the queue for the i-th cash has.
Output
Print a single integer — the minimum number of seconds Vasya needs to get to the cashier.
Examples
Input
1
1
1
Output
20
Input
4
1 4 3 2
100
1 2 2 3
1 9 1
7 8
Output
100
Note
In the second test sample, if Vasya goes to the first queue, he gets to the cashier in 100·5 + 15 = 515 seconds. But if he chooses the second queue, he will need 1·5 + 2·5 + 2·5 + 3·5 + 4·15 = 100 seconds. He will need 1·5 + 9·5 + 1·5 + 3·15 = 100 seconds for the third one and 7·5 + 8·5 + 2·15 = 105 seconds for the fourth one. Thus, Vasya gets to the cashier quicker if he chooses the second or the third queue.
Submitted Solution:
```
def main():
input()
mi = int(1e8)
for _ in list(map(int, input().split(' '))):
m = list(map(int, input().split(' ')))
mi = min(mi, len(m) * 15 + sum(list(map(lambda i: i*5, m))))
return mi
print(main())
``` | instruction | 0 | 30,441 | 10 | 60,882 |
Yes | output | 1 | 30,441 | 10 | 60,883 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Vasya went to the supermarket to get some groceries. He walked about the supermarket for a long time and got a basket full of products. Now he needs to choose the cashier to pay for the products.
There are n cashiers at the exit from the supermarket. At the moment the queue for the i-th cashier already has ki people. The j-th person standing in the queue to the i-th cashier has mi, j items in the basket. Vasya knows that:
* the cashier needs 5 seconds to scan one item;
* after the cashier scans each item of some customer, he needs 15 seconds to take the customer's money and give him the change.
Of course, Vasya wants to select a queue so that he can leave the supermarket as soon as possible. Help him write a program that displays the minimum number of seconds after which Vasya can get to one of the cashiers.
Input
The first line contains integer n (1 ≤ n ≤ 100) — the number of cashes in the shop. The second line contains n space-separated integers: k1, k2, ..., kn (1 ≤ ki ≤ 100), where ki is the number of people in the queue to the i-th cashier.
The i-th of the next n lines contains ki space-separated integers: mi, 1, mi, 2, ..., mi, ki (1 ≤ mi, j ≤ 100) — the number of products the j-th person in the queue for the i-th cash has.
Output
Print a single integer — the minimum number of seconds Vasya needs to get to the cashier.
Examples
Input
1
1
1
Output
20
Input
4
1 4 3 2
100
1 2 2 3
1 9 1
7 8
Output
100
Note
In the second test sample, if Vasya goes to the first queue, he gets to the cashier in 100·5 + 15 = 515 seconds. But if he chooses the second queue, he will need 1·5 + 2·5 + 2·5 + 3·5 + 4·15 = 100 seconds. He will need 1·5 + 9·5 + 1·5 + 3·15 = 100 seconds for the third one and 7·5 + 8·5 + 2·15 = 105 seconds for the fourth one. Thus, Vasya gets to the cashier quicker if he chooses the second or the third queue.
Submitted Solution:
```
from collections import Counter
def solve():
n=int(input())
queue=[int(i) for i in input().split()]
Min,sum=0x3ff,0
for i in range(n):
arr=[int(i) for i in input().split()]
sum=15*queue[i]
for i in arr:
sum+=i*5
Min=min(sum,Min)
return Min
print(solve())
``` | instruction | 0 | 30,442 | 10 | 60,884 |
No | output | 1 | 30,442 | 10 | 60,885 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Vasya went to the supermarket to get some groceries. He walked about the supermarket for a long time and got a basket full of products. Now he needs to choose the cashier to pay for the products.
There are n cashiers at the exit from the supermarket. At the moment the queue for the i-th cashier already has ki people. The j-th person standing in the queue to the i-th cashier has mi, j items in the basket. Vasya knows that:
* the cashier needs 5 seconds to scan one item;
* after the cashier scans each item of some customer, he needs 15 seconds to take the customer's money and give him the change.
Of course, Vasya wants to select a queue so that he can leave the supermarket as soon as possible. Help him write a program that displays the minimum number of seconds after which Vasya can get to one of the cashiers.
Input
The first line contains integer n (1 ≤ n ≤ 100) — the number of cashes in the shop. The second line contains n space-separated integers: k1, k2, ..., kn (1 ≤ ki ≤ 100), where ki is the number of people in the queue to the i-th cashier.
The i-th of the next n lines contains ki space-separated integers: mi, 1, mi, 2, ..., mi, ki (1 ≤ mi, j ≤ 100) — the number of products the j-th person in the queue for the i-th cash has.
Output
Print a single integer — the minimum number of seconds Vasya needs to get to the cashier.
Examples
Input
1
1
1
Output
20
Input
4
1 4 3 2
100
1 2 2 3
1 9 1
7 8
Output
100
Note
In the second test sample, if Vasya goes to the first queue, he gets to the cashier in 100·5 + 15 = 515 seconds. But if he chooses the second queue, he will need 1·5 + 2·5 + 2·5 + 3·5 + 4·15 = 100 seconds. He will need 1·5 + 9·5 + 1·5 + 3·15 = 100 seconds for the third one and 7·5 + 8·5 + 2·15 = 105 seconds for the fourth one. Thus, Vasya gets to the cashier quicker if he chooses the second or the third queue.
Submitted Solution:
```
n=int(input())
ans=1000000000000
for i in range(n):
l1=list(map(int,input().split()))
ans=min(sum(l1)*5+15*len(l1),ans)
print(ans)
``` | instruction | 0 | 30,443 | 10 | 60,886 |
No | output | 1 | 30,443 | 10 | 60,887 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Vasya went to the supermarket to get some groceries. He walked about the supermarket for a long time and got a basket full of products. Now he needs to choose the cashier to pay for the products.
There are n cashiers at the exit from the supermarket. At the moment the queue for the i-th cashier already has ki people. The j-th person standing in the queue to the i-th cashier has mi, j items in the basket. Vasya knows that:
* the cashier needs 5 seconds to scan one item;
* after the cashier scans each item of some customer, he needs 15 seconds to take the customer's money and give him the change.
Of course, Vasya wants to select a queue so that he can leave the supermarket as soon as possible. Help him write a program that displays the minimum number of seconds after which Vasya can get to one of the cashiers.
Input
The first line contains integer n (1 ≤ n ≤ 100) — the number of cashes in the shop. The second line contains n space-separated integers: k1, k2, ..., kn (1 ≤ ki ≤ 100), where ki is the number of people in the queue to the i-th cashier.
The i-th of the next n lines contains ki space-separated integers: mi, 1, mi, 2, ..., mi, ki (1 ≤ mi, j ≤ 100) — the number of products the j-th person in the queue for the i-th cash has.
Output
Print a single integer — the minimum number of seconds Vasya needs to get to the cashier.
Examples
Input
1
1
1
Output
20
Input
4
1 4 3 2
100
1 2 2 3
1 9 1
7 8
Output
100
Note
In the second test sample, if Vasya goes to the first queue, he gets to the cashier in 100·5 + 15 = 515 seconds. But if he chooses the second queue, he will need 1·5 + 2·5 + 2·5 + 3·5 + 4·15 = 100 seconds. He will need 1·5 + 9·5 + 1·5 + 3·15 = 100 seconds for the third one and 7·5 + 8·5 + 2·15 = 105 seconds for the fourth one. Thus, Vasya gets to the cashier quicker if he chooses the second or the third queue.
Submitted Solution:
```
from collections import Counter
def solve():
n=int(input())
queue=[int(i) for i in input().split()]
Min,sum=0x3fff,0
for i in range(n):
arr=[int(i) for i in input().split()]
sum=15*queue[i]
for i in arr:
sum+=i*5
Min=min(sum,Min)
return Min
print(solve())
``` | instruction | 0 | 30,444 | 10 | 60,888 |
No | output | 1 | 30,444 | 10 | 60,889 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Vasya went to the supermarket to get some groceries. He walked about the supermarket for a long time and got a basket full of products. Now he needs to choose the cashier to pay for the products.
There are n cashiers at the exit from the supermarket. At the moment the queue for the i-th cashier already has ki people. The j-th person standing in the queue to the i-th cashier has mi, j items in the basket. Vasya knows that:
* the cashier needs 5 seconds to scan one item;
* after the cashier scans each item of some customer, he needs 15 seconds to take the customer's money and give him the change.
Of course, Vasya wants to select a queue so that he can leave the supermarket as soon as possible. Help him write a program that displays the minimum number of seconds after which Vasya can get to one of the cashiers.
Input
The first line contains integer n (1 ≤ n ≤ 100) — the number of cashes in the shop. The second line contains n space-separated integers: k1, k2, ..., kn (1 ≤ ki ≤ 100), where ki is the number of people in the queue to the i-th cashier.
The i-th of the next n lines contains ki space-separated integers: mi, 1, mi, 2, ..., mi, ki (1 ≤ mi, j ≤ 100) — the number of products the j-th person in the queue for the i-th cash has.
Output
Print a single integer — the minimum number of seconds Vasya needs to get to the cashier.
Examples
Input
1
1
1
Output
20
Input
4
1 4 3 2
100
1 2 2 3
1 9 1
7 8
Output
100
Note
In the second test sample, if Vasya goes to the first queue, he gets to the cashier in 100·5 + 15 = 515 seconds. But if he chooses the second queue, he will need 1·5 + 2·5 + 2·5 + 3·5 + 4·15 = 100 seconds. He will need 1·5 + 9·5 + 1·5 + 3·15 = 100 seconds for the third one and 7·5 + 8·5 + 2·15 = 105 seconds for the fourth one. Thus, Vasya gets to the cashier quicker if he chooses the second or the third queue.
Submitted Solution:
```
n = int(input())
people_in_queue = list(map(int, input().split()))
number_of_products = []
for i in range(n):
products_for_ith_person = list(map(int, input().split()))
number_of_products.append(products_for_ith_person)
num_sec1= 0
num_sec2 = 0
if n == 1:
print(20)
else:
for i in range(n-1):
num_sec1 = sum(number_of_products[i])*5 + (people_in_queue[i]*15)
num_sec2 = sum(number_of_products[i+1])*5 + (people_in_queue[i+1]*15)
if num_sec2 <= num_sec1:
num_sec1 = num_sec2
temp = num_sec1
num_sec2 = 0
print(min(temp,num_sec1, num_sec2))
``` | instruction | 0 | 30,445 | 10 | 60,890 |
No | output | 1 | 30,445 | 10 | 60,891 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales and told you the results. Find out how the deminations of the coins differ or if Vasya has a mistake in the weighting results. No two coins are equal.
Input
The input data contains the results of all the weighting, one result on each line. It is guaranteed that every coin pair was weighted exactly once. Vasya labelled the coins with letters «A», «B» and «C». Each result is a line that appears as (letter)(> or < sign)(letter). For example, if coin "A" proved lighter than coin "B", the result of the weighting is A<B.
Output
It the results are contradictory, print Impossible. Otherwise, print without spaces the rearrangement of letters «A», «B» and «C» which represent the coins in the increasing order of their weights.
Examples
Input
A>B
C<B
A>C
Output
CBA
Input
A<B
B>C
C>A
Output
ACB | instruction | 0 | 30,462 | 10 | 60,924 |
Tags: implementation
Correct Solution:
```
if __name__ == '__main__':
m = {}
m['A'],m['B'],m['C'] = 0,0,0
for i in range(3):
st = str(input())
f,s = st[0],st[2]
if st[1] == '>':
m[f] += 1
else:
m[s] += 1
if(m['A'] == m['B'] == m['C'] == 1):
print('Impossible')
else:
lst = [k for k,v in sorted(m.items(),key=lambda x:x[1])]
print(*lst,sep="")
``` | output | 1 | 30,462 | 10 | 60,925 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales and told you the results. Find out how the deminations of the coins differ or if Vasya has a mistake in the weighting results. No two coins are equal.
Input
The input data contains the results of all the weighting, one result on each line. It is guaranteed that every coin pair was weighted exactly once. Vasya labelled the coins with letters «A», «B» and «C». Each result is a line that appears as (letter)(> or < sign)(letter). For example, if coin "A" proved lighter than coin "B", the result of the weighting is A<B.
Output
It the results are contradictory, print Impossible. Otherwise, print without spaces the rearrangement of letters «A», «B» and «C» which represent the coins in the increasing order of their weights.
Examples
Input
A>B
C<B
A>C
Output
CBA
Input
A<B
B>C
C>A
Output
ACB | instruction | 0 | 30,463 | 10 | 60,926 |
Tags: implementation
Correct Solution:
```
n1 = input()
n2 = input()
n3 = input()
if n1[1] == ">":
n1 = n1[2] + "<" + n1[0]
if n2[1] == ">":
n2 = n2[2] + "<" + n2[0]
if n3[1] == ">":
n3 = n3[2] + "<" + n3[0]
if n1[0] != n2[0] and n1[0] != n3[0] and n3[0] != n2[0]:
print("Impossible")
elif n1[0] == n2[0]:
print(n1[0], n3[0], n3[2], sep ="")
elif n1[0] == n3[0]:
print(n1[0], n2[0], n2[2], sep ="")
elif n3[0] == n2[0]:
print(n3[0], n1[0], n1[2], sep ="")
``` | output | 1 | 30,463 | 10 | 60,927 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales and told you the results. Find out how the deminations of the coins differ or if Vasya has a mistake in the weighting results. No two coins are equal.
Input
The input data contains the results of all the weighting, one result on each line. It is guaranteed that every coin pair was weighted exactly once. Vasya labelled the coins with letters «A», «B» and «C». Each result is a line that appears as (letter)(> or < sign)(letter). For example, if coin "A" proved lighter than coin "B", the result of the weighting is A<B.
Output
It the results are contradictory, print Impossible. Otherwise, print without spaces the rearrangement of letters «A», «B» and «C» which represent the coins in the increasing order of their weights.
Examples
Input
A>B
C<B
A>C
Output
CBA
Input
A<B
B>C
C>A
Output
ACB | instruction | 0 | 30,464 | 10 | 60,928 |
Tags: implementation
Correct Solution:
```
vals = []
for _ in range(3):
vals.append(input())
valid = True
indexes = {"A":0, "B":0, "C":0}
a, b, c = 0, 0, 0
for i in range(3):
current = vals[i]
if current[1] == "<":
indexes[current[2]] += 1
else:
indexes[current[0]] += 1
string = [False, False, False]
for i in indexes:
if not string[indexes[i]]:
string[indexes[i]] = i
else:
valid = False
break
if valid:
print("".join(string))
else:
print("Impossible")
``` | output | 1 | 30,464 | 10 | 60,929 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales and told you the results. Find out how the deminations of the coins differ or if Vasya has a mistake in the weighting results. No two coins are equal.
Input
The input data contains the results of all the weighting, one result on each line. It is guaranteed that every coin pair was weighted exactly once. Vasya labelled the coins with letters «A», «B» and «C». Each result is a line that appears as (letter)(> or < sign)(letter). For example, if coin "A" proved lighter than coin "B", the result of the weighting is A<B.
Output
It the results are contradictory, print Impossible. Otherwise, print without spaces the rearrangement of letters «A», «B» and «C» which represent the coins in the increasing order of their weights.
Examples
Input
A>B
C<B
A>C
Output
CBA
Input
A<B
B>C
C>A
Output
ACB | instruction | 0 | 30,465 | 10 | 60,930 |
Tags: implementation
Correct Solution:
```
coins = ['ABC', 'ACB', 'BAC', 'BCA', 'CAB', 'CBA']
results = []
for i in range(0, 3):
results.append(input())
ans = 'Impossible'
for i in range(0, 6):
place = [0, 0, 0]
for j in range(0, 3):
place[ord(coins[i][j])-65] = j
flag = True
for j in range(0, 3):
if results[j][1] == '>':
if place[ord(results[j][0])-65] < place[ord(results[j][2])-65]:
flag = False
break
else:
if place[ord(results[j][0])-65] > place[ord(results[j][2])-65]:
flag = False
break
if flag:
ans = coins[i]
break
print(ans)
``` | output | 1 | 30,465 | 10 | 60,931 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales and told you the results. Find out how the deminations of the coins differ or if Vasya has a mistake in the weighting results. No two coins are equal.
Input
The input data contains the results of all the weighting, one result on each line. It is guaranteed that every coin pair was weighted exactly once. Vasya labelled the coins with letters «A», «B» and «C». Each result is a line that appears as (letter)(> or < sign)(letter). For example, if coin "A" proved lighter than coin "B", the result of the weighting is A<B.
Output
It the results are contradictory, print Impossible. Otherwise, print without spaces the rearrangement of letters «A», «B» and «C» which represent the coins in the increasing order of their weights.
Examples
Input
A>B
C<B
A>C
Output
CBA
Input
A<B
B>C
C>A
Output
ACB | instruction | 0 | 30,466 | 10 | 60,932 |
Tags: implementation
Correct Solution:
```
import operator
import sys
dec = {'A': 0, 'B': 0, 'C': 0}
x = [input(), input(), input()]
for i in range(3):
if x[i][1] == '>':
dec[x[i][0]] += 1
else:
dec[x[i][2]] += 1
if dec['A'] == dec['B'] or dec['A'] == dec['C'] or dec['C'] == dec['B']:
print("Impossible")
sys.exit()
dec.items()
sor = sorted(dec.items(), key=operator.itemgetter(1))
for i in range(3):
print(sor[i][0], end='')
``` | output | 1 | 30,466 | 10 | 60,933 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales and told you the results. Find out how the deminations of the coins differ or if Vasya has a mistake in the weighting results. No two coins are equal.
Input
The input data contains the results of all the weighting, one result on each line. It is guaranteed that every coin pair was weighted exactly once. Vasya labelled the coins with letters «A», «B» and «C». Each result is a line that appears as (letter)(> or < sign)(letter). For example, if coin "A" proved lighter than coin "B", the result of the weighting is A<B.
Output
It the results are contradictory, print Impossible. Otherwise, print without spaces the rearrangement of letters «A», «B» and «C» which represent the coins in the increasing order of their weights.
Examples
Input
A>B
C<B
A>C
Output
CBA
Input
A<B
B>C
C>A
Output
ACB | instruction | 0 | 30,467 | 10 | 60,934 |
Tags: implementation
Correct Solution:
```
#
# Author: eloyhz
# Date: Sep/11/2020
#
#
#
#
def read_weight():
w = list(input())
if w[1] == '>':
w[1] = '<'
w[0], w[2] = w[2], w[0]
return ''.join(w)
if __name__ == '__main__':
coins = [['ABC', 'A<B', 'A<C', 'B<C'],
['ACB', 'A<C', 'A<B', 'C<B'],
['BAC', 'B<A', 'B<C', 'A<C'],
['BCA', 'B<C', 'B<A', 'C<A'],
['CAB', 'C<A', 'C<B', 'A<B'],
['CBA', 'C<B', 'C<A', 'B<A']]
w1 = read_weight()
w2 = read_weight()
w3 = read_weight()
ans = None
for c in coins:
if w1 in c and w2 in c and w3 in c:
ans = c[0]
break
print(ans if ans else 'Impossible')
``` | output | 1 | 30,467 | 10 | 60,935 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales and told you the results. Find out how the deminations of the coins differ or if Vasya has a mistake in the weighting results. No two coins are equal.
Input
The input data contains the results of all the weighting, one result on each line. It is guaranteed that every coin pair was weighted exactly once. Vasya labelled the coins with letters «A», «B» and «C». Each result is a line that appears as (letter)(> or < sign)(letter). For example, if coin "A" proved lighter than coin "B", the result of the weighting is A<B.
Output
It the results are contradictory, print Impossible. Otherwise, print without spaces the rearrangement of letters «A», «B» and «C» which represent the coins in the increasing order of their weights.
Examples
Input
A>B
C<B
A>C
Output
CBA
Input
A<B
B>C
C>A
Output
ACB | instruction | 0 | 30,468 | 10 | 60,936 |
Tags: implementation
Correct Solution:
```
def top_sort(graph, visited, node, result):
if node in visited: return
visited.add(node)
for sub_node in graph[node]: top_sort(graph, visited, sub_node, result)
result.append(node)
def solve():
graph, visited, result = {'A':[], 'B':[], 'C':[]}, set([]), []
for _ in range(3):
exp = input()
if exp[1] == '<': graph[exp[2]].append(exp[0])
else: graph[exp[0]].append(exp[2])
if len([1 for i in graph.values() if len(i) > 0]) == 3: return 'Impossible'
for node in graph: top_sort(graph, visited, node, result)
return ''.join(result)
print(solve())
``` | output | 1 | 30,468 | 10 | 60,937 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales and told you the results. Find out how the deminations of the coins differ or if Vasya has a mistake in the weighting results. No two coins are equal.
Input
The input data contains the results of all the weighting, one result on each line. It is guaranteed that every coin pair was weighted exactly once. Vasya labelled the coins with letters «A», «B» and «C». Each result is a line that appears as (letter)(> or < sign)(letter). For example, if coin "A" proved lighter than coin "B", the result of the weighting is A<B.
Output
It the results are contradictory, print Impossible. Otherwise, print without spaces the rearrangement of letters «A», «B» and «C» which represent the coins in the increasing order of their weights.
Examples
Input
A>B
C<B
A>C
Output
CBA
Input
A<B
B>C
C>A
Output
ACB | instruction | 0 | 30,469 | 10 | 60,938 |
Tags: implementation
Correct Solution:
```
from operator import itemgetter
list_ = [{'A': 0, 'B': 1, 'C': 2}, {'A': 0, 'B': 2, 'C': 1}, {'A': 1, 'B': 0, 'C': 2}, {'A': 1, 'B': 2, 'C': 0},
{'A': 2, 'B': 0, 'C': 1}, {'A': 2, 'B': 1, 'C': 0}]
expression = [input() for _ in range(3)]
def is_true(a, index) -> True:
return list_[index][a[0]] > list_[index][a[2]] if a[1] == '>' else list_[index][a[0]] < list_[index][a[2]]
for i in range(list_.__len__()):
if is_true(expression[0], i) and is_true(expression[1], i) and is_true(expression[2], i):
ans = sorted(list_[i].items(), key=itemgetter(1))
for j in ans:
print(j[0], end='')
exit()
print('Impossible ')
``` | output | 1 | 30,469 | 10 | 60,939 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales and told you the results. Find out how the deminations of the coins differ or if Vasya has a mistake in the weighting results. No two coins are equal.
Input
The input data contains the results of all the weighting, one result on each line. It is guaranteed that every coin pair was weighted exactly once. Vasya labelled the coins with letters «A», «B» and «C». Each result is a line that appears as (letter)(> or < sign)(letter). For example, if coin "A" proved lighter than coin "B", the result of the weighting is A<B.
Output
It the results are contradictory, print Impossible. Otherwise, print without spaces the rearrangement of letters «A», «B» and «C» which represent the coins in the increasing order of their weights.
Examples
Input
A>B
C<B
A>C
Output
CBA
Input
A<B
B>C
C>A
Output
ACB
Submitted Solution:
```
A = ["A", 0]
B = ["B", 0]
C = ["C", 0]
for i in range(3):
eq = input()
if eq[0] == "A":
if eq[1] == ">" and eq[2] == "B":
A[1] += 1
elif eq[1] == ">" and eq[2] == "C":
A[1] += 1
elif eq[2] == "B":
B[1] += 1
elif eq[2] == "C":
C[1] += 1
elif eq[0] == "B":
if eq[1] == ">" and eq[2] == "A":
B[1] += 1
elif eq[1] == ">" and eq[2] == "C":
B[1] += 1
elif eq[2] == "A":
A[1] += 1
elif eq[2] == "C":
C[1] += 1
elif eq[0] == "C":
if eq[1] == ">" and eq[2] == "A":
C[1] += 1
elif eq[1] == ">" and eq[2] == "B":
C[1] += 1
elif eq[2] == "A":
A[1] += 1
elif eq[2] == "B":
B[1] += 1
if A[1] == B[1] == C[1]:
print("Impossible")
else:
for l in sorted([A, B, C], key=lambda x: x[1]):
print(l[0], end="")
``` | instruction | 0 | 30,470 | 10 | 60,940 |
Yes | output | 1 | 30,470 | 10 | 60,941 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales and told you the results. Find out how the deminations of the coins differ or if Vasya has a mistake in the weighting results. No two coins are equal.
Input
The input data contains the results of all the weighting, one result on each line. It is guaranteed that every coin pair was weighted exactly once. Vasya labelled the coins with letters «A», «B» and «C». Each result is a line that appears as (letter)(> or < sign)(letter). For example, if coin "A" proved lighter than coin "B", the result of the weighting is A<B.
Output
It the results are contradictory, print Impossible. Otherwise, print without spaces the rearrangement of letters «A», «B» and «C» which represent the coins in the increasing order of their weights.
Examples
Input
A>B
C<B
A>C
Output
CBA
Input
A<B
B>C
C>A
Output
ACB
Submitted Solution:
```
from itertools import permutations
def proB(arr):
for per in list(permutations('ABC')):
dic={}
pos=0
for k in per:
dic[k]=pos
pos+=1
flg=True
for p in arr:
i,j=p[0],p[2]
if(p[1]=='<'):
if(dic.get(i)<dic.get(j)):
continue
flg=False
break
else:
if(dic.get(i)>dic.get(j)):
continue
flg=False
break
if(flg):
return ''.join(dic.keys())
return 'Impossible'
arr=[]
for i in range(3):
inp=input()
arr.append(inp)
print(proB(arr))
``` | instruction | 0 | 30,471 | 10 | 60,942 |
Yes | output | 1 | 30,471 | 10 | 60,943 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales and told you the results. Find out how the deminations of the coins differ or if Vasya has a mistake in the weighting results. No two coins are equal.
Input
The input data contains the results of all the weighting, one result on each line. It is guaranteed that every coin pair was weighted exactly once. Vasya labelled the coins with letters «A», «B» and «C». Each result is a line that appears as (letter)(> or < sign)(letter). For example, if coin "A" proved lighter than coin "B", the result of the weighting is A<B.
Output
It the results are contradictory, print Impossible. Otherwise, print without spaces the rearrangement of letters «A», «B» and «C» which represent the coins in the increasing order of their weights.
Examples
Input
A>B
C<B
A>C
Output
CBA
Input
A<B
B>C
C>A
Output
ACB
Submitted Solution:
```
mp = {'A': 0, 'B': 1, 'C': 2}
def main():
l1 = input()
l2 = input()
l3 = input()
ls = [l1, l2, l3]
num = [0, 0, 0]
for l in ls:
if l[1] == '<':
num[mp[l[2]]] += 1
else:
num[mp[l[0]]] += 1
if min(num) != 0:
print('Impossible')
return
res = sorted(zip(num, ['A', 'B', 'C']), key=lambda x: x[0])
res = [x[1] for x in res]
print(''.join(res))
return
if __name__ == '__main__':
main()
``` | instruction | 0 | 30,472 | 10 | 60,944 |
Yes | output | 1 | 30,472 | 10 | 60,945 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales and told you the results. Find out how the deminations of the coins differ or if Vasya has a mistake in the weighting results. No two coins are equal.
Input
The input data contains the results of all the weighting, one result on each line. It is guaranteed that every coin pair was weighted exactly once. Vasya labelled the coins with letters «A», «B» and «C». Each result is a line that appears as (letter)(> or < sign)(letter). For example, if coin "A" proved lighter than coin "B", the result of the weighting is A<B.
Output
It the results are contradictory, print Impossible. Otherwise, print without spaces the rearrangement of letters «A», «B» and «C» which represent the coins in the increasing order of their weights.
Examples
Input
A>B
C<B
A>C
Output
CBA
Input
A<B
B>C
C>A
Output
ACB
Submitted Solution:
```
dict_list={'A':0,'B':0,'C':0}
for i in range(3):
string = input()
if string[1]=='>':
dict_list[string[0]] += 1
dict_list[string[2]] -= 1
else:
dict_list[string[2]] += 1
dict_list[string[0]] -= 1
string_1=['',' ','']
for key,value in dict_list.items():
if value == 2:
string_1[2]=key
elif value == 0:
string_1[1]=key
elif value == -2:
string_1[0]=key
for i in range(3):
if string_1[i] not in ('A','B','C') :
print("Impossible")
exit()
print(("").join(string_1))
``` | instruction | 0 | 30,473 | 10 | 60,946 |
Yes | output | 1 | 30,473 | 10 | 60,947 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales and told you the results. Find out how the deminations of the coins differ or if Vasya has a mistake in the weighting results. No two coins are equal.
Input
The input data contains the results of all the weighting, one result on each line. It is guaranteed that every coin pair was weighted exactly once. Vasya labelled the coins with letters «A», «B» and «C». Each result is a line that appears as (letter)(> or < sign)(letter). For example, if coin "A" proved lighter than coin "B", the result of the weighting is A<B.
Output
It the results are contradictory, print Impossible. Otherwise, print without spaces the rearrangement of letters «A», «B» and «C» which represent the coins in the increasing order of their weights.
Examples
Input
A>B
C<B
A>C
Output
CBA
Input
A<B
B>C
C>A
Output
ACB
Submitted Solution:
```
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 18 02:03:24 2018
@author: Arsanuos
"""
def main():
arr = [ [-1 for t in range(3)] for x in range(3)]
for i in range(3):
tmp = input()
tmp = tmp if tmp[1] == '<' else tmp[::-1]
arr[ord(tmp[0]) - 65][ord(tmp[2]) - 65] = ord(tmp[2]) - 65
s = 0
cnt = 0
out = [] * 3
for i in range(len(arr)):
row = arr[i]
for item in row:
if item != -1:
s +=1
if s > 0:
cnt += 1
out.append((s, i))
s = 0
if cnt == 3:
print("NO")
else:
print(out)
out.sort(reverse=True)
for su, char in out:
print(chr(char + 65), end="")
print()
if __name__ == "__main__":
main()
``` | instruction | 0 | 30,474 | 10 | 60,948 |
No | output | 1 | 30,474 | 10 | 60,949 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales and told you the results. Find out how the deminations of the coins differ or if Vasya has a mistake in the weighting results. No two coins are equal.
Input
The input data contains the results of all the weighting, one result on each line. It is guaranteed that every coin pair was weighted exactly once. Vasya labelled the coins with letters «A», «B» and «C». Each result is a line that appears as (letter)(> or < sign)(letter). For example, if coin "A" proved lighter than coin "B", the result of the weighting is A<B.
Output
It the results are contradictory, print Impossible. Otherwise, print without spaces the rearrangement of letters «A», «B» and «C» which represent the coins in the increasing order of their weights.
Examples
Input
A>B
C<B
A>C
Output
CBA
Input
A<B
B>C
C>A
Output
ACB
Submitted Solution:
```
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 8 10:55:25 2020
@author: Nada Adel
"""
import sys
mylist=['A','B','C']
mydic={'A':0,'B':0,'C':0}
check=[]
out=[0,0,0]
for x in range(3):
line = input()
digits=[d for d in str(line)]
inx1=mylist.index(digits[0])
inx2=mylist.index(digits[2])
if digits[1]=='>':
check.append(digits[0])
mydic[digits[0]]+=1
if inx1>inx2:
mylist[inx1]=digits[2]
mylist[inx2]=digits[0]
else :
check.append(digits[2])
mydic[digits[2]]+=1
if inx2>inx1:
mylist[inx1]=digits[2]
mylist[inx2]=digits[0]
if len(set(check))==3:
print("Impossible")
else:
if mydic['A']==2:
out[2]='A'
if mydic['B']==1:
out[1]='B'
out[0]='C'
else :
out[1]='C'
out[0]='B'
elif mydic['B']==2:
out[2]='B'
if mydic['A']==1:
out[1]='A'
out[0]='C'
else :
out[1]='C'
out[0]=='A'
elif mydic['C']==2:
out[2]='C'
if mydic['A']==1:
out[1]='A'
out[0]='C'
else :
out[1]='C'
out[0]='A'
for x in range(3):
print(out[2-x],end ="")
``` | instruction | 0 | 30,475 | 10 | 60,950 |
No | output | 1 | 30,475 | 10 | 60,951 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales and told you the results. Find out how the deminations of the coins differ or if Vasya has a mistake in the weighting results. No two coins are equal.
Input
The input data contains the results of all the weighting, one result on each line. It is guaranteed that every coin pair was weighted exactly once. Vasya labelled the coins with letters «A», «B» and «C». Each result is a line that appears as (letter)(> or < sign)(letter). For example, if coin "A" proved lighter than coin "B", the result of the weighting is A<B.
Output
It the results are contradictory, print Impossible. Otherwise, print without spaces the rearrangement of letters «A», «B» and «C» which represent the coins in the increasing order of their weights.
Examples
Input
A>B
C<B
A>C
Output
CBA
Input
A<B
B>C
C>A
Output
ACB
Submitted Solution:
```
#%%
ins = []
val = {}
def makeStr(x):
s = list(x)
if s[1] == ">": return s[0]+s[2]
else: return s[2]+s[0]
first = makeStr(input())
val.update(
{
first[0] : 3,
first[1] : 2
}
)
second = makeStr(input())
if second[0] in val.keys(): val.update(
{
second[1]: val[second[0]] - 1
}
)
else:
val.update(
{
second[0]: val[second[1]] + 1
}
)
last = makeStr(input())
val.update(
{
last[1]: val[last[1]] - 1
}
)
for item in sorted(val.items(), key = lambda item: item[1]):
print(item[0], end="")
``` | instruction | 0 | 30,476 | 10 | 60,952 |
No | output | 1 | 30,476 | 10 | 60,953 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales and told you the results. Find out how the deminations of the coins differ or if Vasya has a mistake in the weighting results. No two coins are equal.
Input
The input data contains the results of all the weighting, one result on each line. It is guaranteed that every coin pair was weighted exactly once. Vasya labelled the coins with letters «A», «B» and «C». Each result is a line that appears as (letter)(> or < sign)(letter). For example, if coin "A" proved lighter than coin "B", the result of the weighting is A<B.
Output
It the results are contradictory, print Impossible. Otherwise, print without spaces the rearrangement of letters «A», «B» and «C» which represent the coins in the increasing order of their weights.
Examples
Input
A>B
C<B
A>C
Output
CBA
Input
A<B
B>C
C>A
Output
ACB
Submitted Solution:
```
# Hey, there Stalker!!!
# This Code was written by:
# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
# ▒▒╔╗╔═══╦═══╗▒▒▒╔╗▒▒▒
# ▒╔╝║║╔═╗║╔═╗╠╗▒▒║║▒▒▒
# ▒╚╗║║║║║║║║║╠╬══╣║╔╗▒
# ▒▒║║║║║║║║║║╠╣║═╣╚╝╝▒
# ▒╔╝╚╣╚═╝║╚═╝║║║═╣╔╗╗▒
# ▒╚══╩═══╩═══╣╠══╩╝╚╝▒
# ▒▒▒▒▒▒▒▒▒▒▒╔╝║▒▒▒▒▒▒▒
# ▒▒▒▒▒▒▒▒▒▒▒╚═╝▒▒▒▒▒▒▒
# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
#from functools import reduce
from __future__ import division, print_function
#mod=int(1e9+7)
#import resource
#resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])
#import threading
#threading.stack_size(2**26)
"""fact=[1]
#for i in range(1,100001):
# fact.append((fact[-1]*i)%mod)
#ifact=[0]*100001
#ifact[100000]=pow(fact[100000],mod-2,mod)
#for i in range(100000,0,-1):
# ifact[i-1]=(i*ifact[i])%mod"""
#from collections import deque, defaultdict, Counter, OrderedDict
#from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
#from heapq import heappush, heappop, heapify, nlargest, nsmallest
# sys.setrecursionlimit(10**6)
from sys import stdin, stdout
import bisect #c++ upperbound
from bisect import bisect_left as bl #c++ lowerbound bl(array,element)
from bisect import bisect_right as br #c++ upperbound
import itertools
from collections import Counter
import collections
import math
import heapq
import re
def modinv(n,p):
return pow(n,p-2,p)
def cin():
return map(int,sin().split())
def ain(): #takes array as input
return list(map(int,sin().split()))
def sin():
return input()
def inin():
return int(input())
def Divisors(n) :
l = []
for i in range(1, int(math.sqrt(n) + 1)) :
if (n % i == 0) :
if (n // i == i) :
l.append(i)
else :
l.append(i)
l.append(n//i)
return l
def most_frequent(list):
return max(set(list), key = list.count)
def GCD(x,y):
while(y):
x, y = y, x % y
return x
def ncr(n,r,p): #To use this, Uncomment 19-25
t=((fact[n])*((ifact[r]*ifact[n-r])%p))%p
return t
def Convert(string):
li = list(string.split(""))
return li
def SieveOfEratosthenes(n):
global prime
prime = [True for i in range(n+1)]
p = 2
while (p * p <= n):
if (prime[p] == True):
for i in range(p * p, n+1, p):
prime[i] = False
p += 1
f=[]
for p in range(2, n):
if prime[p]:
f.append(p)
return f
prime=[]
q=[]
def dfs(n,d,v,c):
global q
v[n]=1
x=d[n]
q.append(n)
j=c
for i in x:
if i not in v:
f=dfs(i,d,v,c+1)
j=max(j,f)
# print(f)
return j
#Implement heapq
#grades = [110, 25, 38, 49, 20, 95, 33, 87, 80, 90]
#print(heapq.nlargest(3, grades)) #top 3 largest
#print(heapq.nsmallest(4, grades))
#Always make a variable of predefined function for ex- fn=len
#n,k=map(int,input().split())
"""*******************************************************"""
def get_key(val):
for key, value in my_dict.items():
if val == value:
return key
def main():
x=sin()
y=sin()
z=sin()
s={'A':0,'B':0,'C':0}
if x[1]=='>':
s[x[0]]+=1
else:
s[x[0]]-=1
if y[1]=='>':
s[y[0]]+=1
else:
s[y[0]]-=1
if z[1]=='>':
if s[z[0]]<=s[z[2]]:
print('Impossible')
quit()
else:
if s[z[0]]>=s[z[2]]:
print('Impossible')
quit()
s=sorted(s.items(),key=lambda x:x[1])
for i in s:
print(i[0],end='')
print('')
"""*******************************************************"""
######## Python 2 and 3 footer by Pajenegod and c1729
py2 = round(0.5)
if py2:
from future_builtins import ascii, filter, hex, map, oct, zip
range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192
class FastIO(BytesIO):
newlines = 0
def __init__(self, file):
self._file = file
self._fd = file.fileno()
self.writable = "x" in file.mode or "w" in file.mode
self.write = super(FastIO, self).write if self.writable else None
def _fill(self):
s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
return s
def read(self):
while self._fill(): pass
return super(FastIO,self).read()
def readline(self):
while self.newlines == 0:
s = self._fill(); self.newlines = s.count(b"\n") + (not s)
self.newlines -= 1
return super(FastIO, self).readline()
def flush(self):
if self.writable:
os.write(self._fd, self.getvalue())
self.truncate(0), self.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
if py2:
self.write = self.buffer.write
self.read = self.buffer.read
self.readline = self.buffer.readline
else:
self.write = lambda s:self.buffer.write(s.encode('ascii'))
self.read = lambda:self.buffer.read().decode('ascii')
self.readline = lambda:self.buffer.readline().decode('ascii')
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')
if __name__== "__main__":
main()
#threading.Thread(target=main).start()
``` | instruction | 0 | 30,477 | 10 | 60,954 |
No | output | 1 | 30,477 | 10 | 60,955 |
Provide a correct Python 3 solution for this coding contest problem.
In some other world, today is the day before Christmas Eve.
Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan).
He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
Constraints
* 2 \leq N \leq 10
* 100 \leq p_i \leq 10000
* p_i is an even number.
Input
Input is given from Standard Input in the following format:
N
p_1
p_2
:
p_N
Output
Print the total amount Mr. Takaha will pay.
Examples
Input
3
4980
7980
6980
Output
15950
Input
4
4320
4320
4320
4320
Output
15120 | instruction | 0 | 30,767 | 10 | 61,534 |
"Correct Solution:
```
N = int(input())
P = [int(input()) for n in range(N)]
print(sum(P) - max(P) // 2)
``` | output | 1 | 30,767 | 10 | 61,535 |
Provide a correct Python 3 solution for this coding contest problem.
In some other world, today is the day before Christmas Eve.
Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan).
He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
Constraints
* 2 \leq N \leq 10
* 100 \leq p_i \leq 10000
* p_i is an even number.
Input
Input is given from Standard Input in the following format:
N
p_1
p_2
:
p_N
Output
Print the total amount Mr. Takaha will pay.
Examples
Input
3
4980
7980
6980
Output
15950
Input
4
4320
4320
4320
4320
Output
15120 | instruction | 0 | 30,768 | 10 | 61,536 |
"Correct Solution:
```
n=int(input())
l=[int(input()) for _ in range(n)]
print(sum(l)-max(l)//2)
``` | output | 1 | 30,768 | 10 | 61,537 |
Provide a correct Python 3 solution for this coding contest problem.
In some other world, today is the day before Christmas Eve.
Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan).
He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
Constraints
* 2 \leq N \leq 10
* 100 \leq p_i \leq 10000
* p_i is an even number.
Input
Input is given from Standard Input in the following format:
N
p_1
p_2
:
p_N
Output
Print the total amount Mr. Takaha will pay.
Examples
Input
3
4980
7980
6980
Output
15950
Input
4
4320
4320
4320
4320
Output
15120 | instruction | 0 | 30,769 | 10 | 61,538 |
"Correct Solution:
```
n,*p=list(map(int,open(0).read().split()))
p.sort()
print(sum(p[:-1])+p[-1]//2)
``` | output | 1 | 30,769 | 10 | 61,539 |
Provide a correct Python 3 solution for this coding contest problem.
In some other world, today is the day before Christmas Eve.
Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan).
He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
Constraints
* 2 \leq N \leq 10
* 100 \leq p_i \leq 10000
* p_i is an even number.
Input
Input is given from Standard Input in the following format:
N
p_1
p_2
:
p_N
Output
Print the total amount Mr. Takaha will pay.
Examples
Input
3
4980
7980
6980
Output
15950
Input
4
4320
4320
4320
4320
Output
15120 | instruction | 0 | 30,770 | 10 | 61,540 |
"Correct Solution:
```
n = int(input())
l = [int(input()) for _ in [0]*n]
print(sum(l)-max(l)//2)
``` | output | 1 | 30,770 | 10 | 61,541 |
Provide a correct Python 3 solution for this coding contest problem.
In some other world, today is the day before Christmas Eve.
Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan).
He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
Constraints
* 2 \leq N \leq 10
* 100 \leq p_i \leq 10000
* p_i is an even number.
Input
Input is given from Standard Input in the following format:
N
p_1
p_2
:
p_N
Output
Print the total amount Mr. Takaha will pay.
Examples
Input
3
4980
7980
6980
Output
15950
Input
4
4320
4320
4320
4320
Output
15120 | instruction | 0 | 30,771 | 10 | 61,542 |
"Correct Solution:
```
pn=[int(input()) for _ in range(int(input()))]
print(sum(pn)-max(pn)//2)
``` | output | 1 | 30,771 | 10 | 61,543 |
Provide a correct Python 3 solution for this coding contest problem.
In some other world, today is the day before Christmas Eve.
Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan).
He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
Constraints
* 2 \leq N \leq 10
* 100 \leq p_i \leq 10000
* p_i is an even number.
Input
Input is given from Standard Input in the following format:
N
p_1
p_2
:
p_N
Output
Print the total amount Mr. Takaha will pay.
Examples
Input
3
4980
7980
6980
Output
15950
Input
4
4320
4320
4320
4320
Output
15120 | instruction | 0 | 30,772 | 10 | 61,544 |
"Correct Solution:
```
P = [int(input()) for _ in range(int(input()))]
p = max(P)
print(sum(P)-int(p//2))
``` | output | 1 | 30,772 | 10 | 61,545 |
Provide a correct Python 3 solution for this coding contest problem.
In some other world, today is the day before Christmas Eve.
Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan).
He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
Constraints
* 2 \leq N \leq 10
* 100 \leq p_i \leq 10000
* p_i is an even number.
Input
Input is given from Standard Input in the following format:
N
p_1
p_2
:
p_N
Output
Print the total amount Mr. Takaha will pay.
Examples
Input
3
4980
7980
6980
Output
15950
Input
4
4320
4320
4320
4320
Output
15120 | instruction | 0 | 30,773 | 10 | 61,546 |
"Correct Solution:
```
n=int(input());p=[int(input())for i in range(n)];print(sum(p)-round(max(p)/2))
``` | output | 1 | 30,773 | 10 | 61,547 |
Provide a correct Python 3 solution for this coding contest problem.
In some other world, today is the day before Christmas Eve.
Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan).
He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
Constraints
* 2 \leq N \leq 10
* 100 \leq p_i \leq 10000
* p_i is an even number.
Input
Input is given from Standard Input in the following format:
N
p_1
p_2
:
p_N
Output
Print the total amount Mr. Takaha will pay.
Examples
Input
3
4980
7980
6980
Output
15950
Input
4
4320
4320
4320
4320
Output
15120 | instruction | 0 | 30,774 | 10 | 61,548 |
"Correct Solution:
```
n=int(input())
a=[int(input()) for i in range(n)]
print(sum(a)-max(a)//2)
``` | output | 1 | 30,774 | 10 | 61,549 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In some other world, today is the day before Christmas Eve.
Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan).
He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
Constraints
* 2 \leq N \leq 10
* 100 \leq p_i \leq 10000
* p_i is an even number.
Input
Input is given from Standard Input in the following format:
N
p_1
p_2
:
p_N
Output
Print the total amount Mr. Takaha will pay.
Examples
Input
3
4980
7980
6980
Output
15950
Input
4
4320
4320
4320
4320
Output
15120
Submitted Solution:
```
n=int(input())
s=[int(input()) for _ in range(n)]
print(int(sum(s) - max(s)/2))
``` | instruction | 0 | 30,775 | 10 | 61,550 |
Yes | output | 1 | 30,775 | 10 | 61,551 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In some other world, today is the day before Christmas Eve.
Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan).
He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
Constraints
* 2 \leq N \leq 10
* 100 \leq p_i \leq 10000
* p_i is an even number.
Input
Input is given from Standard Input in the following format:
N
p_1
p_2
:
p_N
Output
Print the total amount Mr. Takaha will pay.
Examples
Input
3
4980
7980
6980
Output
15950
Input
4
4320
4320
4320
4320
Output
15120
Submitted Solution:
```
N=int(input())
List=[int(input()) for i in range(N)]
print(sum(List)-(max(List)//2))
``` | instruction | 0 | 30,776 | 10 | 61,552 |
Yes | output | 1 | 30,776 | 10 | 61,553 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In some other world, today is the day before Christmas Eve.
Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan).
He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
Constraints
* 2 \leq N \leq 10
* 100 \leq p_i \leq 10000
* p_i is an even number.
Input
Input is given from Standard Input in the following format:
N
p_1
p_2
:
p_N
Output
Print the total amount Mr. Takaha will pay.
Examples
Input
3
4980
7980
6980
Output
15950
Input
4
4320
4320
4320
4320
Output
15120
Submitted Solution:
```
n=int(input())
l=[int(input()) for i in range(n)]
print(sum(l)-int(max(l)/2))
``` | instruction | 0 | 30,777 | 10 | 61,554 |
Yes | output | 1 | 30,777 | 10 | 61,555 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In some other world, today is the day before Christmas Eve.
Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan).
He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
Constraints
* 2 \leq N \leq 10
* 100 \leq p_i \leq 10000
* p_i is an even number.
Input
Input is given from Standard Input in the following format:
N
p_1
p_2
:
p_N
Output
Print the total amount Mr. Takaha will pay.
Examples
Input
3
4980
7980
6980
Output
15950
Input
4
4320
4320
4320
4320
Output
15120
Submitted Solution:
```
n=int(input())
a=[int(input()) for i in range(n)]
b=sum(a)-max(a)/2
print(int(b))
``` | instruction | 0 | 30,778 | 10 | 61,556 |
Yes | output | 1 | 30,778 | 10 | 61,557 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In some other world, today is the day before Christmas Eve.
Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan).
He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
Constraints
* 2 \leq N \leq 10
* 100 \leq p_i \leq 10000
* p_i is an even number.
Input
Input is given from Standard Input in the following format:
N
p_1
p_2
:
p_N
Output
Print the total amount Mr. Takaha will pay.
Examples
Input
3
4980
7980
6980
Output
15950
Input
4
4320
4320
4320
4320
Output
15120
Submitted Solution:
```
N = int(input())
price_list = []
append = pricelist.append
for i in range(N):
p = int(input)
append(p)
pricelist.sort(reverse=True)
pricelist[0] = pricelist[0] / 2
print(sum(pricelist))
``` | instruction | 0 | 30,779 | 10 | 61,558 |
No | output | 1 | 30,779 | 10 | 61,559 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In some other world, today is the day before Christmas Eve.
Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan).
He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
Constraints
* 2 \leq N \leq 10
* 100 \leq p_i \leq 10000
* p_i is an even number.
Input
Input is given from Standard Input in the following format:
N
p_1
p_2
:
p_N
Output
Print the total amount Mr. Takaha will pay.
Examples
Input
3
4980
7980
6980
Output
15950
Input
4
4320
4320
4320
4320
Output
15120
Submitted Solution:
```
N = int(input())
prices = [int(input()) for i in range(N)]
print(sum(prices)-max(prices))
``` | instruction | 0 | 30,780 | 10 | 61,560 |
No | output | 1 | 30,780 | 10 | 61,561 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In some other world, today is the day before Christmas Eve.
Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan).
He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
Constraints
* 2 \leq N \leq 10
* 100 \leq p_i \leq 10000
* p_i is an even number.
Input
Input is given from Standard Input in the following format:
N
p_1
p_2
:
p_N
Output
Print the total amount Mr. Takaha will pay.
Examples
Input
3
4980
7980
6980
Output
15950
Input
4
4320
4320
4320
4320
Output
15120
Submitted Solution:
```
N = int(input())
list=[]
for i in range(N):
list.append(i)
print(sum(list)-max(list)//2)
``` | instruction | 0 | 30,781 | 10 | 61,562 |
No | output | 1 | 30,781 | 10 | 61,563 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In some other world, today is the day before Christmas Eve.
Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan).
He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
Constraints
* 2 \leq N \leq 10
* 100 \leq p_i \leq 10000
* p_i is an even number.
Input
Input is given from Standard Input in the following format:
N
p_1
p_2
:
p_N
Output
Print the total amount Mr. Takaha will pay.
Examples
Input
3
4980
7980
6980
Output
15950
Input
4
4320
4320
4320
4320
Output
15120
Submitted Solution:
```
n = int(input())
a = [input() for _ in range(n)]
a.sort(reverse=True)
ans = 0
ans += int(a[0]) // 2
a.pop(0)
a = list(map(int, a))
print(ans + sum(a))
``` | instruction | 0 | 30,782 | 10 | 61,564 |
No | output | 1 | 30,782 | 10 | 61,565 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are m people living in a city. There are n dishes sold in the city. Each dish i has a price p_i, a standard s_i and a beauty b_i. Each person j has an income of inc_j and a preferred beauty pref_j.
A person would never buy a dish whose standard is less than the person's income. Also, a person can't afford a dish with a price greater than the income of the person. In other words, a person j can buy a dish i only if p_i ≤ inc_j ≤ s_i.
Also, a person j can buy a dish i, only if |b_i-pref_j| ≤ (inc_j-p_i). In other words, if the price of the dish is less than the person's income by k, the person will only allow the absolute difference of at most k between the beauty of the dish and his/her preferred beauty.
Print the number of dishes that can be bought by each person in the city.
Input
The first line contains two integers n and m (1 ≤ n ≤ 10^5, 1 ≤ m ≤ 10^5), the number of dishes available in the city and the number of people living in the city.
The second line contains n integers p_i (1 ≤ p_i ≤ 10^9), the price of each dish.
The third line contains n integers s_i (1 ≤ s_i ≤ 10^9), the standard of each dish.
The fourth line contains n integers b_i (1 ≤ b_i ≤ 10^9), the beauty of each dish.
The fifth line contains m integers inc_j (1 ≤ inc_j ≤ 10^9), the income of every person.
The sixth line contains m integers pref_j (1 ≤ pref_j ≤ 10^9), the preferred beauty of every person.
It is guaranteed that for all integers i from 1 to n, the following condition holds: p_i ≤ s_i.
Output
Print m integers, the number of dishes that can be bought by every person living in the city.
Examples
Input
3 3
2 1 3
2 4 4
2 1 1
2 2 3
1 2 4
Output
1 2 0
Input
4 3
1 2 1 1
3 3 1 3
2 1 3 2
1 1 3
1 2 1
Output
0 2 3
Note
In the first example, the first person can buy dish 2, the second person can buy dishes 1 and 2 and the third person can buy no dishes.
In the second example, the first person can buy no dishes, the second person can buy dishes 1 and 4, and the third person can buy dishes 1, 2 and 4.
Submitted Solution:
```
vsego_korobok2=8
vsego_korobok=7
podrugi=2
podrugi2=3
konfeti3=[1,2,2,3,2,4,5]
konfeti2=[1,2,2,3,2,4,6,10]
konfeti=[1,2,2,3,2,4,10]
korobki=0
korobki2=0
korobki3=0
chet=list()
chet2=list()
nechet=list()
nechet2=list()
chet3=list()
nechet3=list()
#a=vk,b=konf,c=pod,d=ch,f=nec,jkor
for i in range(vsego_korobok):
if(konfeti[i]%podrugi==0):
chet.append(konfeti[i])
for i in range(vsego_korobok):
if(konfeti[i]%podrugi!=0):
nechet.append(konfeti[i])
u=len(nechet)
for i in range(u-1):
m=nechet[i]+nechet[+1]
if(m%podrugi==0):
korobki+=2
p=len(chet)
for i in range(p-1):
m=chet[i]+chet[i+1]
if(m%podrugi==0):
chet[i+1]+=1
korobki+=2
print(korobki)
for i in range(vsego_korobok2):
if(konfeti2[i]%podrugi==0):
chet2.append(konfeti2[i])
for i in range(vsego_korobok2):
if(konfeti2[i]%podrugi!=0):
nechet2.append(konfeti2[i])
u=len(nechet2)
for i in range(u-1):
m=nechet2[i]+nechet2[+1]
if(m%podrugi==0):
korobki2+=2
p=len(chet2)
for i in range(p-1):
m=chet2[i]+chet2[i+1]
if(m%podrugi==0):
chet2[i+1]+=1
korobki2+=2
print(korobki2)
for i in range(vsego_korobok):
if(konfeti3[i]%podrugi2==0):
chet3.append(konfeti3[i])
for i in range(vsego_korobok):
if(konfeti3[i]%podrugi2!=0):
nechet3.append(konfeti3[i])
u=len(nechet3)
for i in range(u-1):
m=nechet3[i]+nechet3[+1]
if(m%podrugi2==0):
korobki3+=2
p=len(chet3)
for i in range(p-1):
m=chet3[i]+chet3[i+1]
if(m%podrugi2==0):
chet3[i+1]+=1
korobki3+=2
print(korobki3)
``` | instruction | 0 | 31,025 | 10 | 62,050 |
No | output | 1 | 31,025 | 10 | 62,051 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are m people living in a city. There are n dishes sold in the city. Each dish i has a price p_i, a standard s_i and a beauty b_i. Each person j has an income of inc_j and a preferred beauty pref_j.
A person would never buy a dish whose standard is less than the person's income. Also, a person can't afford a dish with a price greater than the income of the person. In other words, a person j can buy a dish i only if p_i ≤ inc_j ≤ s_i.
Also, a person j can buy a dish i, only if |b_i-pref_j| ≤ (inc_j-p_i). In other words, if the price of the dish is less than the person's income by k, the person will only allow the absolute difference of at most k between the beauty of the dish and his/her preferred beauty.
Print the number of dishes that can be bought by each person in the city.
Input
The first line contains two integers n and m (1 ≤ n ≤ 10^5, 1 ≤ m ≤ 10^5), the number of dishes available in the city and the number of people living in the city.
The second line contains n integers p_i (1 ≤ p_i ≤ 10^9), the price of each dish.
The third line contains n integers s_i (1 ≤ s_i ≤ 10^9), the standard of each dish.
The fourth line contains n integers b_i (1 ≤ b_i ≤ 10^9), the beauty of each dish.
The fifth line contains m integers inc_j (1 ≤ inc_j ≤ 10^9), the income of every person.
The sixth line contains m integers pref_j (1 ≤ pref_j ≤ 10^9), the preferred beauty of every person.
It is guaranteed that for all integers i from 1 to n, the following condition holds: p_i ≤ s_i.
Output
Print m integers, the number of dishes that can be bought by every person living in the city.
Examples
Input
3 3
2 1 3
2 4 4
2 1 1
2 2 3
1 2 4
Output
1 2 0
Input
4 3
1 2 1 1
3 3 1 3
2 1 3 2
1 1 3
1 2 1
Output
0 2 3
Note
In the first example, the first person can buy dish 2, the second person can buy dishes 1 and 2 and the third person can buy no dishes.
In the second example, the first person can buy no dishes, the second person can buy dishes 1 and 4, and the third person can buy dishes 1, 2 and 4.
Submitted Solution:
```
n,m=map(int,input().split())
price=list(map(int,input().split()))
standard=list(map(int,input().split()))
beauty=list(map(int,input().split()))
income=list(map(int,input().split()))
preference=list(map(int,input().split()))
buy=[]
for i in range(m):
c=0
for j in range(n):
if standard[j]>=income[i] and price[j]<=income[i]:
x=beauty[j]-preference[i]
y=income[i]-price[j]
if x>0 and x<=y:
c+=1
buy.append(c)
print(*buy)
``` | instruction | 0 | 31,026 | 10 | 62,052 |
No | output | 1 | 31,026 | 10 | 62,053 |
Provide tags and a correct Python 3 solution for this coding contest problem.
<image>
To monitor cryptocurrency exchange rates trader William invented a wonderful device consisting of n lights arranged in a row. The device functions in the following way:
Initially, all lights on William's device are turned off. At the beginning of a new iteration the device randomly, with a uniform distribution, picks a light that is turned off and turns it on, telling William which cryptocurrency he should invest in. After this iteration if any k consecutive lights contain more than one turned on light, then the device finishes working.
William doesn't like uncertainty, so he wants you to calculate the expected value of the number of lights that are turned on in the device after it finishes working.
Input
Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10). Description of the test cases follows.
The only line for each test case contains two integers n and k (2 ≤ k ≤ n ≤ 10^5), which are the total number of lights and the length of subsegment of lights that are being checked, respectively.
Output
For each test case print the answer, modulo 10^9+7.
Formally, let M = 10^9+7. It can be shown that the answer can be expressed as an irreducible fraction p/q, where p and q are integers and q not ≡ 0 \pmod{M}. Output the integer equal to p ⋅ q^{-1} mod M. In other words, output such an integer x that 0 ≤ x < M and x ⋅ q ≡ p \pmod{M}.
Example
Input
3
3 2
15 2
40 15
Output
333333338
141946947
329622137
Note
Explanation of the first sample test case:
Let's write out all possible sequences of light toggles, which will make the device complete its operation:
1. (1, 2) — 2 lights are turned on
2. (1, 3, 2) — 3 lights are turned on
3. (2, 1) — 2 lights are turned on
4. (2, 3) — 2 lights are turned on
5. (3, 2) — 2 lights are turned on
6. (3, 1, 2) — 3 lights are turned on
Then the final expected value will be equal to 2/6 + 3/6 + 2/6 + 2/6 + 2/6 + 3/6 = 14/6 = 7/3.
Then the required output will be 333333338, since 333333338 ⋅ 3 ≡ 7 \pmod{10^9+7}. | instruction | 0 | 31,233 | 10 | 62,466 |
Tags: combinatorics, dp, math, probabilities
Correct Solution:
```
from bisect import bisect,bisect_left
from collections import *
from heapq import *
from math import gcd,ceil,sqrt,floor,inf
from itertools import *
from operator import add,mul,sub,xor,truediv,floordiv
from functools import *
#----------------------------------------------------------------------
import os
import sys
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
#------------------------------------------------------------------------
def RL(): return map(int, sys.stdin.readline().split())
def RLL(): return list(map(int, sys.stdin.readline().split()))
def N(): return int(input())
def A(n):return [0]*n
def AI(n,x): return [x]*n
def A2(n,m): return [[0]*m for i in range(n)]
def G(n): return [[] for i in range(n)]
def GP(it): return [[ch,len(list(g))] for ch,g in groupby(it)]
#------------------------------------------------------------------------
from types import GeneratorType
def bootstrap(f, stack=[]):
def wrappedfunc(*args, **kwargs):
if stack:
return f(*args, **kwargs)
else:
to = f(*args, **kwargs)
while True:
if type(to) is GeneratorType:
stack.append(to)
to = next(to)
else:
stack.pop()
if not stack:
break
to = stack[-1].send(to)
return to
return wrappedfunc
mod=10**9+7
farr=[1]
ifa=[]
def fact(x,mod=0):
if mod:
while x>=len(farr):
farr.append(farr[-1]*len(farr)%mod)
else:
while x>=len(farr):
farr.append(farr[-1]*len(farr))
return farr[x]
def ifact(x,mod):
global ifa
fact(x,mod)
ifa.append(pow(farr[-1],mod-2,mod))
for i in range(x,0,-1):
ifa.append(ifa[-1]*i%mod)
ifa.reverse()
def per(i,j,mod=0):
if i<j: return 0
if not mod:
return fact(i)//fact(i-j)
return farr[i]*ifa[i-j]%mod
def com(i,j,mod=0):
if i<j: return 0
if not mod:
return per(i,j)//fact(j)
return per(i,j,mod)*ifa[j]%mod
def catalan(n):
return com(2*n,n)//(n+1)
def isprime(n):
for i in range(2,int(n**0.5)+1):
if n%i==0:
return False
return True
def floorsum(a,b,c,n):#sum((a*i+b)//c for i in range(n+1))
if a==0:return b//c*(n+1)
if a>=c or b>=c: return floorsum(a%c,b%c,c,n)+b//c*(n+1)+a//c*n*(n+1)//2
m=(a*n+b)//c
return n*m-floorsum(c,c-b-1,a,m-1)
def inverse(a,m):
a%=m
if a<=1: return a
return ((1-inverse(m,a)*m)//a)%m
def lowbit(n):
return n&-n
class BIT:
def __init__(self,arr):
self.arr=arr
self.n=len(arr)-1
def update(self,x,v):
while x<=self.n:
self.arr[x]+=v
x+=x&-x
def query(self,x):
ans=0
while x:
ans+=self.arr[x]
x&=x-1
return ans
class ST:
def __init__(self,arr):#n!=0
n=len(arr)
mx=n.bit_length()#取不到
self.st=[[0]*mx for i in range(n)]
for i in range(n):
self.st[i][0]=arr[i]
for j in range(1,mx):
for i in range(n-(1<<j)+1):
self.st[i][j]=max(self.st[i][j-1],self.st[i+(1<<j-1)][j-1])
def query(self,l,r):
if l>r:return -inf
s=(r+1-l).bit_length()-1
return max(self.st[l][s],self.st[r-(1<<s)+1][s])
class DSU:#容量+路径压缩
def __init__(self,n):
self.c=[-1]*n
def same(self,x,y):
return self.find(x)==self.find(y)
def find(self,x):
if self.c[x]<0:
return x
self.c[x]=self.find(self.c[x])
return self.c[x]
def union(self,u,v):
u,v=self.find(u),self.find(v)
if u==v:
return False
if self.c[u]>self.c[v]:
u,v=v,u
self.c[u]+=self.c[v]
self.c[v]=u
return True
def size(self,x): return -self.c[self.find(x)]
class UFS:#秩+路径
def __init__(self,n):
self.parent=[i for i in range(n)]
self.ranks=[0]*n
def find(self,x):
if x!=self.parent[x]:
self.parent[x]=self.find(self.parent[x])
return self.parent[x]
def union(self,u,v):
pu,pv=self.find(u),self.find(v)
if pu==pv:
return False
if self.ranks[pu]>=self.ranks[pv]:
self.parent[pv]=pu
if self.ranks[pv]==self.ranks[pu]:
self.ranks[pu]+=1
else:
self.parent[pu]=pv
class UF:#秩+路径+容量,边数
def __init__(self,n):
self.parent=[i for i in range(n)]
self.ranks=[0]*n
self.size=AI(n,1)
self.edge=A(n)
def find(self,x):
if x!=self.parent[x]:
self.parent[x]=self.find(self.parent[x])
return self.parent[x]
def union(self,u,v):
pu,pv=self.find(u),self.find(v)
if pu==pv:
self.edge[pu]+=1
return False
if self.ranks[pu]>=self.ranks[pv]:
self.parent[pv]=pu
self.edge[pu]+=self.edge[pv]+1
self.size[pu]+=self.size[pv]
if self.ranks[pv]==self.ranks[pu]:
self.ranks[pu]+=1
else:
self.parent[pu]=pv
self.edge[pv]+=self.edge[pu]+1
self.size[pv]+=self.size[pu]
def Prime(n):
c=0
prime=[]
flag=[0]*(n+1)
for i in range(2,n+1):
if not flag[i]:
prime.append(i)
c+=1
for j in range(c):
if i*prime[j]>n: break
flag[i*prime[j]]=prime[j]
if i%prime[j]==0: break
return flag
def dij(s,graph):
d=AI(n,inf)
d[s]=0
heap=[(0,s)]
vis=A(n)
while heap:
dis,u=heappop(heap)
if vis[u]:
continue
vis[u]=1
for v,w in graph[u]:
if d[v]>d[u]+w:
d[v]=d[u]+w
heappush(heap,(d[v],v))
return d
def bell(s,g):#bellman-Ford
dis=AI(n,inf)
dis[s]=0
for i in range(n-1):
for u,v,w in edge:
if dis[v]>dis[u]+w:
dis[v]=dis[u]+w
change=A(n)
for i in range(n):
for u,v,w in edge:
if dis[v]>dis[u]+w:
dis[v]=dis[u]+w
change[v]=1
return dis
def lcm(a,b): return a*b//gcd(a,b)
def lis(nums):
res=[]
for k in nums:
i=bisect.bisect_left(res,k)
if i==len(res):
res.append(k)
else:
res[i]=k
return len(res)
def RP(nums):#逆序对
n = len(nums)
s=set(nums)
d={}
for i,k in enumerate(sorted(s),1):
d[k]=i
bi=BIT([0]*(len(s)+1))
ans=0
for i in range(n-1,-1,-1):
ans+=bi.query(d[nums[i]]-1)
bi.update(d[nums[i]],1)
return ans
def michange(a,b):
d=defaultdict(deque)
for i,x in enumerate(b):
d[x].append(i)
order=A(len(a))
for i,x in enumerate(a):
if not d:
return -1
order[i]=d[x].popleft()
return RP(order)
class DLN:
def __init__(self,val):
self.val=val
self.pre=None
self.next=None
def nb(i,j,n,m):
for ni,nj in [[i+1,j],[i-1,j],[i,j-1],[i,j+1]]:
if 0<=ni<n and 0<=nj<m:
yield ni,nj
def topo(n):
q=deque()
res=[]
for i in range(1,n+1):
if ind[i]==0:
q.append(i)
res.append(i)
while q:
u=q.popleft()
for v in g[u]:
ind[v]-=1
if ind[v]==0:
q.append(v)
res.append(v)
return res
@bootstrap
def gdfs(r,p):
for ch in g[r]:
if ch!=p:
yield gdfs(ch,r)
yield None
'''
from random import randint
def ra(n,a,b):
return [randint(a,b) for i in range(n)]
'''
t=N()
ifact(10**5,mod)
for i in range(t):
n,k=RL()
pre=A(n+1)
ans=0
for i in range(2,n+1):
pre[i]=1-com(n-(k-1)*(i-1),i,mod)*ifa[n]%mod*farr[i]%mod*farr[n-i]%mod
ans+=(pre[i]-pre[i-1])*i
ans%=mod
print(ans)
'''
sys.setrecursionlimit(200000)
import threading
threading.sta1ck_size(10**8)
t=threading.Thr
ead(target=main)
t.start()
t.join()
'''
``` | output | 1 | 31,233 | 10 | 62,467 |
Provide tags and a correct Python 3 solution for this coding contest problem.
<image>
To monitor cryptocurrency exchange rates trader William invented a wonderful device consisting of n lights arranged in a row. The device functions in the following way:
Initially, all lights on William's device are turned off. At the beginning of a new iteration the device randomly, with a uniform distribution, picks a light that is turned off and turns it on, telling William which cryptocurrency he should invest in. After this iteration if any k consecutive lights contain more than one turned on light, then the device finishes working.
William doesn't like uncertainty, so he wants you to calculate the expected value of the number of lights that are turned on in the device after it finishes working.
Input
Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10). Description of the test cases follows.
The only line for each test case contains two integers n and k (2 ≤ k ≤ n ≤ 10^5), which are the total number of lights and the length of subsegment of lights that are being checked, respectively.
Output
For each test case print the answer, modulo 10^9+7.
Formally, let M = 10^9+7. It can be shown that the answer can be expressed as an irreducible fraction p/q, where p and q are integers and q not ≡ 0 \pmod{M}. Output the integer equal to p ⋅ q^{-1} mod M. In other words, output such an integer x that 0 ≤ x < M and x ⋅ q ≡ p \pmod{M}.
Example
Input
3
3 2
15 2
40 15
Output
333333338
141946947
329622137
Note
Explanation of the first sample test case:
Let's write out all possible sequences of light toggles, which will make the device complete its operation:
1. (1, 2) — 2 lights are turned on
2. (1, 3, 2) — 3 lights are turned on
3. (2, 1) — 2 lights are turned on
4. (2, 3) — 2 lights are turned on
5. (3, 2) — 2 lights are turned on
6. (3, 1, 2) — 3 lights are turned on
Then the final expected value will be equal to 2/6 + 3/6 + 2/6 + 2/6 + 2/6 + 3/6 = 14/6 = 7/3.
Then the required output will be 333333338, since 333333338 ⋅ 3 ≡ 7 \pmod{10^9+7}. | instruction | 0 | 31,234 | 10 | 62,468 |
Tags: combinatorics, dp, math, probabilities
Correct Solution:
```
import sys
input=sys.stdin.readline
max_n=2*10**5
fact, inv_fact = [0] * (max_n+1), [0] * (max_n+1)
fact[0] = 1
mod=10**9+7
def make_nCr_mod():
global fact
global inv_fact
for i in range(max_n):
fact[i + 1] = fact[i] * (i + 1) % mod
inv_fact[-1] = pow(fact[-1], mod - 2, mod)
for i in reversed(range(max_n)):
inv_fact[i] = inv_fact[i + 1] * (i + 1) % mod
make_nCr_mod()
def nCr_mod(n, r):
if(n<=0):
return(0)
global fact
global inv_fact
res = 1
while n or r:
a, b = n % mod, r % mod
if(a < b):
return 0
res = res * fact[a] % mod * inv_fact[b] % mod * inv_fact[a - b] % mod
n //= mod
r //= mod
return res
mod=10**9+7
t=int(input())
preffix=1
for _ in range(t):
n,k=map(int,input().split())
ans=1
for i in range(1,n+1):
ans=(ans+nCr_mod(n-(i-1)*(k-1),i)*pow(nCr_mod(n,i),mod-2,mod))%mod
print(ans)
``` | output | 1 | 31,234 | 10 | 62,469 |
Provide tags and a correct Python 3 solution for this coding contest problem.
<image>
To monitor cryptocurrency exchange rates trader William invented a wonderful device consisting of n lights arranged in a row. The device functions in the following way:
Initially, all lights on William's device are turned off. At the beginning of a new iteration the device randomly, with a uniform distribution, picks a light that is turned off and turns it on, telling William which cryptocurrency he should invest in. After this iteration if any k consecutive lights contain more than one turned on light, then the device finishes working.
William doesn't like uncertainty, so he wants you to calculate the expected value of the number of lights that are turned on in the device after it finishes working.
Input
Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10). Description of the test cases follows.
The only line for each test case contains two integers n and k (2 ≤ k ≤ n ≤ 10^5), which are the total number of lights and the length of subsegment of lights that are being checked, respectively.
Output
For each test case print the answer, modulo 10^9+7.
Formally, let M = 10^9+7. It can be shown that the answer can be expressed as an irreducible fraction p/q, where p and q are integers and q not ≡ 0 \pmod{M}. Output the integer equal to p ⋅ q^{-1} mod M. In other words, output such an integer x that 0 ≤ x < M and x ⋅ q ≡ p \pmod{M}.
Example
Input
3
3 2
15 2
40 15
Output
333333338
141946947
329622137
Note
Explanation of the first sample test case:
Let's write out all possible sequences of light toggles, which will make the device complete its operation:
1. (1, 2) — 2 lights are turned on
2. (1, 3, 2) — 3 lights are turned on
3. (2, 1) — 2 lights are turned on
4. (2, 3) — 2 lights are turned on
5. (3, 2) — 2 lights are turned on
6. (3, 1, 2) — 3 lights are turned on
Then the final expected value will be equal to 2/6 + 3/6 + 2/6 + 2/6 + 2/6 + 3/6 = 14/6 = 7/3.
Then the required output will be 333333338, since 333333338 ⋅ 3 ≡ 7 \pmod{10^9+7}. | instruction | 0 | 31,235 | 10 | 62,470 |
Tags: combinatorics, dp, math, probabilities
Correct Solution:
```
from __future__ import division, print_function
import sys, collections, math, itertools, random, bisect
# sys.stdout = open('C:/Users/welcome/Desktop/sublime/output.txt', 'w')
# sys.stdin = open('C:/Users/welcome/Desktop/sublime/input.txt', 'r')
INF = sys.maxsize
def get_ints(): return map(int, input().strip().split())
def get_array(): return list(map(int, input().strip().split()))
mod = 1000000007
MOD = 998244353
#-----------------------------------------------------------------------------------------------------------------------------------
def solve():
mod = 10 ** 9 + 7
N = 10 ** 5
F, iF = [0] * (N + 1), [0] * (N + 1)
F[0] = 1
for i in range(1, N + 1):
F[i] = F[i - 1] * i % mod
iF[-1] = pow(F[-1], mod - 2, mod)
for i in range(N - 1, -1, -1):
iF[i] = iF[i + 1] * (i + 1) % mod
def cal(n, k):
if k < 0 or k > n: return 0
return F[n] * iF[k] * iF[n - k] % mod
for _ in range(int(input())):
n, k = map(int, input().split())
ans = 1
x = 1
while n - (k - 1) * (x - 1) >= x:
ans = (ans + cal(n - (k - 1) * (x - 1), x) * pow(cal(n, x), mod - 2, mod)) % mod
x += 1
print(ans)
#-----------------------------------------------------------------------------------------------------------------------------------
def main():
solve()
# Region of fastio, don't change
py2 = round(0.5)
if py2:
from future_builtins import ascii, filter, hex, map, oct, zip
range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192
class FastIO(BytesIO):
newlines = 0
def __init__(self, file):
self._file = file
self._fd = file.fileno()
self.writable = "x" in file.mode or "w" in file.mode
self.write = super(FastIO, self).write if self.writable else None
def _fill(self):
s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
return s
def read(self):
while self._fill(): pass
return super(FastIO, self).read()
def readline(self):
while self.newlines == 0:
s = self._fill();
self.newlines = s.count(b"\n") + (not s)
self.newlines -= 1
return super(FastIO, self).readline()
def flush(self):
if self.writable:
os.write(self._fd, self.getvalue())
self.truncate(0), self.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
if py2:
self.write = self.buffer.write
self.read = self.buffer.read
self.readline = self.buffer.readline
else:
self.write = lambda s: self.buffer.write(s.encode('ascii'))
self.read = lambda: self.buffer.read().decode('ascii')
self.readline = lambda: self.buffer.readline().decode('ascii')
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')
if __name__ == '__main__':
main()
``` | output | 1 | 31,235 | 10 | 62,471 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.