text stringlengths 1.02k 43.5k | conversation_id int64 853 107k | embedding list | cluster int64 24 24 |
|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Two pirates Polycarpus and Vasily play a very interesting game. They have n chests with coins, the chests are numbered with integers from 1 to n. Chest number i has ai coins.
Polycarpus and Vasily move in turns. Polycarpus moves first. During a move a player is allowed to choose a positive integer x (2Β·x + 1 β€ n) and take a coin from each chest with numbers x, 2Β·x, 2Β·x + 1. It may turn out that some chest has no coins, in this case the player doesn't take a coin from this chest. The game finishes when all chests get emptied.
Polycarpus isn't a greedy scrooge. Polycarpys is a lazy slob. So he wonders in what minimum number of moves the game can finish. Help Polycarpus, determine the minimum number of moves in which the game can finish. Note that Polycarpus counts not only his moves, he also counts Vasily's moves.
Input
The first line contains a single integer n (1 β€ n β€ 100) β the number of chests with coins. The second line contains a sequence of space-separated integers: a1, a2, ..., an (1 β€ ai β€ 1000), where ai is the number of coins in the chest number i at the beginning of the game.
Output
Print a single integer β the minimum number of moves needed to finish the game. If no sequence of turns leads to finishing the game, print -1.
Examples
Input
1
1
Output
-1
Input
3
1 2 3
Output
3
Note
In the first test case there isn't a single move that can be made. That's why the players won't be able to empty the chests.
In the second sample there is only one possible move x = 1. This move should be repeated at least 3 times to empty the third chest.
Submitted Solution:
```
n=int(input())
if n==1:
print(-1)
exit(0)
a=list(map(int,input().split(' ')))
a=[0]+a
# print(a)
ans=0
for i in range(1,n+1):
if 2*i+1>n:
continue
if a[i]==0 or a[2*i]==0 or a[2*i+1]==0 :
continue
mina=min([a[i],a[2*i],a[2*i+1]])
a[i],a[2*i],a[2*i+1]=a[i]-mina,a[2*i]-mina,a[2*i+1]-mina
ans+=mina
# print(a)
for i in range(1,n+1):
if 2*i+1>n:
continue
if a[i]>0 and a[2*i]>0:
mina=min([a[i],a[2*i]])
ans+=mina
a[i],a[2*i]=a[i]-mina,a[2*i]-mina
elif a[2*i+1]>0 and a[2*i]>0:
mina=min([a[2*i+1],a[2*i]])
ans+=mina
a[2*i+1],a[2*i]=a[2*i+1]-mina,a[2*i]-mina
elif a[2*i+1]>0 and a[i]>0:
mina=min([a[2*i+1],a[i]])
ans+=mina
a[2*i+1],a[i]=a[2*i+1]-mina,a[i]-mina
for i in range(1,n+1):
if 2*i+1>n:
continue
if a[i]>0:
ans+=a[i]
a[i]=0
elif a[2*i]>0:
ans+=a[2*i]
a[2*i]=0
elif a[2*i+1]>0:
ans+=a[2*i+1]
a[2*i+1]=0
for i in range(1,n+1):
if a[i]>0:
print(-1)
exit(0)
print(ans)
```
No
| 92,957 | [
0.55859375,
0.494384765625,
0.19775390625,
0.17333984375,
-0.438720703125,
-0.4150390625,
-0.60595703125,
0.0234222412109375,
-0.0221099853515625,
0.39599609375,
0.80615234375,
0.08343505859375,
-0.09112548828125,
-0.68994140625,
-0.39013671875,
-0.160888671875,
-0.6591796875,
-0.7... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Two pirates Polycarpus and Vasily play a very interesting game. They have n chests with coins, the chests are numbered with integers from 1 to n. Chest number i has ai coins.
Polycarpus and Vasily move in turns. Polycarpus moves first. During a move a player is allowed to choose a positive integer x (2Β·x + 1 β€ n) and take a coin from each chest with numbers x, 2Β·x, 2Β·x + 1. It may turn out that some chest has no coins, in this case the player doesn't take a coin from this chest. The game finishes when all chests get emptied.
Polycarpus isn't a greedy scrooge. Polycarpys is a lazy slob. So he wonders in what minimum number of moves the game can finish. Help Polycarpus, determine the minimum number of moves in which the game can finish. Note that Polycarpus counts not only his moves, he also counts Vasily's moves.
Input
The first line contains a single integer n (1 β€ n β€ 100) β the number of chests with coins. The second line contains a sequence of space-separated integers: a1, a2, ..., an (1 β€ ai β€ 1000), where ai is the number of coins in the chest number i at the beginning of the game.
Output
Print a single integer β the minimum number of moves needed to finish the game. If no sequence of turns leads to finishing the game, print -1.
Examples
Input
1
1
Output
-1
Input
3
1 2 3
Output
3
Note
In the first test case there isn't a single move that can be made. That's why the players won't be able to empty the chests.
In the second sample there is only one possible move x = 1. This move should be repeated at least 3 times to empty the third chest.
Submitted Solution:
```
import math
a = []
a_sum = 0
n = int(input())
a = [0]+[int(i) for i in input().split()]
def rex(k):
global a_sum
for i in range(k,2*k-1):
if i%2 == 0:
if a[i] >= a[i+1]:
a_sum += a[i]
a[i//2] = a[i//2] - a[i]
else:
a_sum += a[i+1]
a[i//2] = a[i//2] - a[i+1]
a[i] = 0
a[i+1] = 0
i +=1
# if __name__ == '__main__':
if n%2 ==0 or n==1:
print(-1)
exit()
else:
rec = int(math.log(n) / math.log(2)) +1
x = (n-1)//2
for i in range(rec):
rex(x+1)
if x>2:
if x%2 ==1:
x = (x-1)//2
else:
max = a[1]
if a[2] > a[1]:
max = a[2]
if a[3] > max:
max = a[3]
a_sum = a_sum+max
print(a_sum)
exit()
```
No
| 92,958 | [
0.53955078125,
0.50341796875,
0.211669921875,
0.1728515625,
-0.42822265625,
-0.40966796875,
-0.58056640625,
0.0000553131103515625,
-0.036102294921875,
0.414794921875,
0.84130859375,
0.07928466796875,
-0.10919189453125,
-0.69482421875,
-0.391357421875,
-0.1282958984375,
-0.65087890625... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp plays "Game 23". Initially he has a number n and his goal is to transform it to m. In one move, he can multiply n by 2 or multiply n by 3. He can perform any number of moves.
Print the number of moves needed to transform n to m. Print -1 if it is impossible to do so.
It is easy to prove that any way to transform n to m contains the same number of moves (i.e. number of moves doesn't depend on the way of transformation).
Input
The only line of the input contains two integers n and m (1 β€ n β€ m β€ 5β
10^8).
Output
Print the number of moves to transform n to m, or -1 if there is no solution.
Examples
Input
120 51840
Output
7
Input
42 42
Output
0
Input
48 72
Output
-1
Note
In the first example, the possible sequence of moves is: 120 β 240 β 720 β 1440 β 4320 β 12960 β 25920 β 51840. The are 7 steps in total.
In the second example, no moves are needed. Thus, the answer is 0.
In the third example, it is impossible to transform 48 to 72.
Tags: implementation, math
Correct Solution:
```
n, m = map(int, input().split())
if m % n != 0:
print(-1)
else:
x = m / n
two = 0
three = 0
while (x % 2 == 0):
two += 1
x = x // 2
while (x % 3 == 0):
three += 1
x = x // 3
if x != 1:
print(-1)
else:
print(two + three)
```
| 93,580 | [
0.556640625,
0.26806640625,
-0.11004638671875,
0.1258544921875,
-0.446044921875,
-0.44091796875,
-0.2235107421875,
0.0867919921875,
0.1553955078125,
0.9873046875,
0.9765625,
0.10662841796875,
0.309814453125,
-0.70458984375,
-0.32275390625,
0.223876953125,
-0.3681640625,
-0.73828125... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp plays "Game 23". Initially he has a number n and his goal is to transform it to m. In one move, he can multiply n by 2 or multiply n by 3. He can perform any number of moves.
Print the number of moves needed to transform n to m. Print -1 if it is impossible to do so.
It is easy to prove that any way to transform n to m contains the same number of moves (i.e. number of moves doesn't depend on the way of transformation).
Input
The only line of the input contains two integers n and m (1 β€ n β€ m β€ 5β
10^8).
Output
Print the number of moves to transform n to m, or -1 if there is no solution.
Examples
Input
120 51840
Output
7
Input
42 42
Output
0
Input
48 72
Output
-1
Note
In the first example, the possible sequence of moves is: 120 β 240 β 720 β 1440 β 4320 β 12960 β 25920 β 51840. The are 7 steps in total.
In the second example, no moves are needed. Thus, the answer is 0.
In the third example, it is impossible to transform 48 to 72.
Tags: implementation, math
Correct Solution:
```
import math
x, y = map(int, input().split())
v, c = y / x, 0
while v % 3 == 0:
v /= 3
c += 1
while v % 2 == 0:
v /= 2
c += 1
if v > 1:
print(-1)
else:
print(c)
```
| 93,581 | [
0.56396484375,
0.273681640625,
-0.1473388671875,
0.1688232421875,
-0.465576171875,
-0.421630859375,
-0.2012939453125,
0.07470703125,
0.1431884765625,
0.9921875,
0.96826171875,
0.059112548828125,
0.28857421875,
-0.6923828125,
-0.310546875,
0.208251953125,
-0.369384765625,
-0.7250976... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp plays "Game 23". Initially he has a number n and his goal is to transform it to m. In one move, he can multiply n by 2 or multiply n by 3. He can perform any number of moves.
Print the number of moves needed to transform n to m. Print -1 if it is impossible to do so.
It is easy to prove that any way to transform n to m contains the same number of moves (i.e. number of moves doesn't depend on the way of transformation).
Input
The only line of the input contains two integers n and m (1 β€ n β€ m β€ 5β
10^8).
Output
Print the number of moves to transform n to m, or -1 if there is no solution.
Examples
Input
120 51840
Output
7
Input
42 42
Output
0
Input
48 72
Output
-1
Note
In the first example, the possible sequence of moves is: 120 β 240 β 720 β 1440 β 4320 β 12960 β 25920 β 51840. The are 7 steps in total.
In the second example, no moves are needed. Thus, the answer is 0.
In the third example, it is impossible to transform 48 to 72.
Tags: implementation, math
Correct Solution:
```
n,m=map(int,input().split())
if(m%n):
print(-1)
exit()
ans=0
m=m//n
while(m>1):
if(m%3==0):
ans+=1
m=m//3
if(m%2==0):
ans+=1
m=m//2
if(m>1 and m%2 and m%3):
print(-1)
exit()
print(ans)
```
| 93,582 | [
0.52734375,
0.25439453125,
-0.1619873046875,
0.1414794921875,
-0.41943359375,
-0.50439453125,
-0.1822509765625,
0.1063232421875,
0.172119140625,
1.0458984375,
0.998046875,
0.09979248046875,
0.295654296875,
-0.7158203125,
-0.37158203125,
0.2100830078125,
-0.389404296875,
-0.74755859... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp plays "Game 23". Initially he has a number n and his goal is to transform it to m. In one move, he can multiply n by 2 or multiply n by 3. He can perform any number of moves.
Print the number of moves needed to transform n to m. Print -1 if it is impossible to do so.
It is easy to prove that any way to transform n to m contains the same number of moves (i.e. number of moves doesn't depend on the way of transformation).
Input
The only line of the input contains two integers n and m (1 β€ n β€ m β€ 5β
10^8).
Output
Print the number of moves to transform n to m, or -1 if there is no solution.
Examples
Input
120 51840
Output
7
Input
42 42
Output
0
Input
48 72
Output
-1
Note
In the first example, the possible sequence of moves is: 120 β 240 β 720 β 1440 β 4320 β 12960 β 25920 β 51840. The are 7 steps in total.
In the second example, no moves are needed. Thus, the answer is 0.
In the third example, it is impossible to transform 48 to 72.
Tags: implementation, math
Correct Solution:
```
n, m = map(int, input().split())
if m % n:
print(-1)
exit(0)
m //= n
a = 0
while m % 2 == 0:
m//=2
a+=1
while m % 3 == 0:
m//=3
a+=1
if m==1:
print(a)
else:
print(-1)
```
| 93,583 | [
0.52783203125,
0.26123046875,
-0.15087890625,
0.1463623046875,
-0.45263671875,
-0.45458984375,
-0.2161865234375,
0.0928955078125,
0.11737060546875,
0.98779296875,
0.99462890625,
0.078369140625,
0.28955078125,
-0.72216796875,
-0.326416015625,
0.2137451171875,
-0.369384765625,
-0.710... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp plays "Game 23". Initially he has a number n and his goal is to transform it to m. In one move, he can multiply n by 2 or multiply n by 3. He can perform any number of moves.
Print the number of moves needed to transform n to m. Print -1 if it is impossible to do so.
It is easy to prove that any way to transform n to m contains the same number of moves (i.e. number of moves doesn't depend on the way of transformation).
Input
The only line of the input contains two integers n and m (1 β€ n β€ m β€ 5β
10^8).
Output
Print the number of moves to transform n to m, or -1 if there is no solution.
Examples
Input
120 51840
Output
7
Input
42 42
Output
0
Input
48 72
Output
-1
Note
In the first example, the possible sequence of moves is: 120 β 240 β 720 β 1440 β 4320 β 12960 β 25920 β 51840. The are 7 steps in total.
In the second example, no moves are needed. Thus, the answer is 0.
In the third example, it is impossible to transform 48 to 72.
Tags: implementation, math
Correct Solution:
```
n,m = list(map(int,input().split()))
if m%n == 0:
d = m//n
if d > 1:
count = 0
while d%2 == 0:
count += 1
d = d//2
while d%3 == 0:
count += 1
d = d//3
if d == 1:
print(count)
else:
print(-1)
else:
print(0)
else:
print(-1)
```
| 93,584 | [
0.52783203125,
0.26025390625,
-0.12493896484375,
0.1373291015625,
-0.46484375,
-0.450439453125,
-0.19091796875,
0.1009521484375,
0.1556396484375,
1.001953125,
0.955078125,
0.07958984375,
0.306884765625,
-0.6845703125,
-0.349853515625,
0.2255859375,
-0.3818359375,
-0.72607421875,
... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp plays "Game 23". Initially he has a number n and his goal is to transform it to m. In one move, he can multiply n by 2 or multiply n by 3. He can perform any number of moves.
Print the number of moves needed to transform n to m. Print -1 if it is impossible to do so.
It is easy to prove that any way to transform n to m contains the same number of moves (i.e. number of moves doesn't depend on the way of transformation).
Input
The only line of the input contains two integers n and m (1 β€ n β€ m β€ 5β
10^8).
Output
Print the number of moves to transform n to m, or -1 if there is no solution.
Examples
Input
120 51840
Output
7
Input
42 42
Output
0
Input
48 72
Output
-1
Note
In the first example, the possible sequence of moves is: 120 β 240 β 720 β 1440 β 4320 β 12960 β 25920 β 51840. The are 7 steps in total.
In the second example, no moves are needed. Thus, the answer is 0.
In the third example, it is impossible to transform 48 to 72.
Tags: implementation, math
Correct Solution:
```
a,b=map(int,input().split())
i=0
if b%a==0:
b=b//a
while b!=1:
if b%2==0:
b=b//2
i=i+1
elif b%3==0:
b=b//3
i=i+1
elif b%2!=0 and b%3!=0 and b>1:
b=1
i=-1
elif b<1:
b=1
i=-1
print(i)
else:
print(-1)
```
| 93,585 | [
0.5693359375,
0.242919921875,
-0.165771484375,
0.1590576171875,
-0.480224609375,
-0.480224609375,
-0.1688232421875,
0.10882568359375,
0.156494140625,
1.013671875,
0.93310546875,
0.08880615234375,
0.292236328125,
-0.669921875,
-0.35400390625,
0.1868896484375,
-0.42041015625,
-0.7299... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp plays "Game 23". Initially he has a number n and his goal is to transform it to m. In one move, he can multiply n by 2 or multiply n by 3. He can perform any number of moves.
Print the number of moves needed to transform n to m. Print -1 if it is impossible to do so.
It is easy to prove that any way to transform n to m contains the same number of moves (i.e. number of moves doesn't depend on the way of transformation).
Input
The only line of the input contains two integers n and m (1 β€ n β€ m β€ 5β
10^8).
Output
Print the number of moves to transform n to m, or -1 if there is no solution.
Examples
Input
120 51840
Output
7
Input
42 42
Output
0
Input
48 72
Output
-1
Note
In the first example, the possible sequence of moves is: 120 β 240 β 720 β 1440 β 4320 β 12960 β 25920 β 51840. The are 7 steps in total.
In the second example, no moves are needed. Thus, the answer is 0.
In the third example, it is impossible to transform 48 to 72.
Tags: implementation, math
Correct Solution:
```
n, m = map(int, input().split())
if m % n:
print(-1)
else:
m //= n
k = 0
for d in (2,3):
while m % d == 0:
m //= d
k += 1
print(k if m < 2 else -1)
```
| 93,586 | [
0.52294921875,
0.267578125,
-0.1392822265625,
0.14697265625,
-0.470703125,
-0.45166015625,
-0.21826171875,
0.08551025390625,
0.111328125,
0.99755859375,
0.994140625,
0.0780029296875,
0.291259765625,
-0.7158203125,
-0.328369140625,
0.2293701171875,
-0.389892578125,
-0.71875,
-0.48... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp plays "Game 23". Initially he has a number n and his goal is to transform it to m. In one move, he can multiply n by 2 or multiply n by 3. He can perform any number of moves.
Print the number of moves needed to transform n to m. Print -1 if it is impossible to do so.
It is easy to prove that any way to transform n to m contains the same number of moves (i.e. number of moves doesn't depend on the way of transformation).
Input
The only line of the input contains two integers n and m (1 β€ n β€ m β€ 5β
10^8).
Output
Print the number of moves to transform n to m, or -1 if there is no solution.
Examples
Input
120 51840
Output
7
Input
42 42
Output
0
Input
48 72
Output
-1
Note
In the first example, the possible sequence of moves is: 120 β 240 β 720 β 1440 β 4320 β 12960 β 25920 β 51840. The are 7 steps in total.
In the second example, no moves are needed. Thus, the answer is 0.
In the third example, it is impossible to transform 48 to 72.
Tags: implementation, math
Correct Solution:
```
x,y=map(int,input().split())
s=0
if y/x==1:
print(0)
elif int(y/x)!=y/x:
print(-1)
else:
d=y/x
while d!=1:
if int(d/2)!=d/2 and int(d/3)!=d/3:
print(-1)
exit()
for i in [2,3]:
if int(d/i)!=d/i:
d=d
else:
d=d/i
s=s+1
print(s)
```
| 93,587 | [
0.51513671875,
0.280029296875,
-0.1522216796875,
0.1507568359375,
-0.47021484375,
-0.449951171875,
-0.170654296875,
0.0914306640625,
0.173095703125,
1.052734375,
0.951171875,
0.100341796875,
0.297119140625,
-0.67333984375,
-0.33837890625,
0.165771484375,
-0.419189453125,
-0.7299804... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp plays "Game 23". Initially he has a number n and his goal is to transform it to m. In one move, he can multiply n by 2 or multiply n by 3. He can perform any number of moves.
Print the number of moves needed to transform n to m. Print -1 if it is impossible to do so.
It is easy to prove that any way to transform n to m contains the same number of moves (i.e. number of moves doesn't depend on the way of transformation).
Input
The only line of the input contains two integers n and m (1 β€ n β€ m β€ 5β
10^8).
Output
Print the number of moves to transform n to m, or -1 if there is no solution.
Examples
Input
120 51840
Output
7
Input
42 42
Output
0
Input
48 72
Output
-1
Note
In the first example, the possible sequence of moves is: 120 β 240 β 720 β 1440 β 4320 β 12960 β 25920 β 51840. The are 7 steps in total.
In the second example, no moves are needed. Thus, the answer is 0.
In the third example, it is impossible to transform 48 to 72.
Submitted Solution:
```
# print("Input n and m")
n,m = [int(x) for x in input().split()]
if m%n != 0:
print(-1)
else:
answer = 0
qu = m//n
while qu%2==0:
qu = qu // 2
answer += 1
while qu%3==0:
qu = qu // 3
answer += 1
if qu == 1:
print(str(answer))
else:
print(-1)
```
Yes
| 93,588 | [
0.51953125,
0.287841796875,
-0.1805419921875,
0.1839599609375,
-0.62646484375,
-0.283935546875,
-0.286865234375,
0.256591796875,
0.1324462890625,
0.99365234375,
0.90283203125,
0.1441650390625,
0.123046875,
-0.72998046875,
-0.37353515625,
0.1339111328125,
-0.382080078125,
-0.7045898... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp plays "Game 23". Initially he has a number n and his goal is to transform it to m. In one move, he can multiply n by 2 or multiply n by 3. He can perform any number of moves.
Print the number of moves needed to transform n to m. Print -1 if it is impossible to do so.
It is easy to prove that any way to transform n to m contains the same number of moves (i.e. number of moves doesn't depend on the way of transformation).
Input
The only line of the input contains two integers n and m (1 β€ n β€ m β€ 5β
10^8).
Output
Print the number of moves to transform n to m, or -1 if there is no solution.
Examples
Input
120 51840
Output
7
Input
42 42
Output
0
Input
48 72
Output
-1
Note
In the first example, the possible sequence of moves is: 120 β 240 β 720 β 1440 β 4320 β 12960 β 25920 β 51840. The are 7 steps in total.
In the second example, no moves are needed. Thus, the answer is 0.
In the third example, it is impossible to transform 48 to 72.
Submitted Solution:
```
x,y=map(int,input().split())
k=-1
if y%x==0:
k=0
p=y/x
while p%2==0:
p/=2
k+=1
while p%3==0:
p/=3
k+=1
if p!=1:k=-1
print(k)
```
Yes
| 93,589 | [
0.6064453125,
0.300048828125,
-0.1552734375,
0.1689453125,
-0.6279296875,
-0.310546875,
-0.3125,
0.2318115234375,
0.0889892578125,
0.99609375,
0.90869140625,
0.07965087890625,
0.169677734375,
-0.7021484375,
-0.350341796875,
0.150146484375,
-0.345703125,
-0.67138671875,
-0.4311523... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp plays "Game 23". Initially he has a number n and his goal is to transform it to m. In one move, he can multiply n by 2 or multiply n by 3. He can perform any number of moves.
Print the number of moves needed to transform n to m. Print -1 if it is impossible to do so.
It is easy to prove that any way to transform n to m contains the same number of moves (i.e. number of moves doesn't depend on the way of transformation).
Input
The only line of the input contains two integers n and m (1 β€ n β€ m β€ 5β
10^8).
Output
Print the number of moves to transform n to m, or -1 if there is no solution.
Examples
Input
120 51840
Output
7
Input
42 42
Output
0
Input
48 72
Output
-1
Note
In the first example, the possible sequence of moves is: 120 β 240 β 720 β 1440 β 4320 β 12960 β 25920 β 51840. The are 7 steps in total.
In the second example, no moves are needed. Thus, the answer is 0.
In the third example, it is impossible to transform 48 to 72.
Submitted Solution:
```
n,m=map(int,input().split())
r=-1
if m%n==0:
m//=n;r=0
for d in 2,3:
while m%d==0:m//=d;r+=1
if m>1:r=-1
print(r)
```
Yes
| 93,590 | [
0.5927734375,
0.300537109375,
-0.157958984375,
0.148193359375,
-0.61376953125,
-0.302001953125,
-0.314453125,
0.2357177734375,
0.07305908203125,
0.99658203125,
0.93212890625,
0.0894775390625,
0.168212890625,
-0.71875,
-0.348876953125,
0.116455078125,
-0.334228515625,
-0.63232421875... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp plays "Game 23". Initially he has a number n and his goal is to transform it to m. In one move, he can multiply n by 2 or multiply n by 3. He can perform any number of moves.
Print the number of moves needed to transform n to m. Print -1 if it is impossible to do so.
It is easy to prove that any way to transform n to m contains the same number of moves (i.e. number of moves doesn't depend on the way of transformation).
Input
The only line of the input contains two integers n and m (1 β€ n β€ m β€ 5β
10^8).
Output
Print the number of moves to transform n to m, or -1 if there is no solution.
Examples
Input
120 51840
Output
7
Input
42 42
Output
0
Input
48 72
Output
-1
Note
In the first example, the possible sequence of moves is: 120 β 240 β 720 β 1440 β 4320 β 12960 β 25920 β 51840. The are 7 steps in total.
In the second example, no moves are needed. Thus, the answer is 0.
In the third example, it is impossible to transform 48 to 72.
Submitted Solution:
```
n, m = map(int, input().split())
if m % n:
print(-1)
else:
d = m // n
c = 0
while d % 2 == 0:
d //= 2
c += 1
while d % 3 == 0:
d //= 3
c += 1
if d == 1:
print(c)
else:
print(-1)
```
Yes
| 93,591 | [
0.580078125,
0.307861328125,
-0.173095703125,
0.145751953125,
-0.61181640625,
-0.31103515625,
-0.286865234375,
0.244384765625,
0.092041015625,
0.9873046875,
0.9140625,
0.09197998046875,
0.1748046875,
-0.72314453125,
-0.330078125,
0.11505126953125,
-0.354248046875,
-0.6630859375,
... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp plays "Game 23". Initially he has a number n and his goal is to transform it to m. In one move, he can multiply n by 2 or multiply n by 3. He can perform any number of moves.
Print the number of moves needed to transform n to m. Print -1 if it is impossible to do so.
It is easy to prove that any way to transform n to m contains the same number of moves (i.e. number of moves doesn't depend on the way of transformation).
Input
The only line of the input contains two integers n and m (1 β€ n β€ m β€ 5β
10^8).
Output
Print the number of moves to transform n to m, or -1 if there is no solution.
Examples
Input
120 51840
Output
7
Input
42 42
Output
0
Input
48 72
Output
-1
Note
In the first example, the possible sequence of moves is: 120 β 240 β 720 β 1440 β 4320 β 12960 β 25920 β 51840. The are 7 steps in total.
In the second example, no moves are needed. Thus, the answer is 0.
In the third example, it is impossible to transform 48 to 72.
Submitted Solution:
```
n,m=map(int,input().split())
p=m/n
sum1=0
if m%n!=0: print(-1)
else:
while(p%2==0):
p/=2
sum1+=1
while(p%3==0):
p/=3
sum1+=1
print(sum1)
```
No
| 93,592 | [
0.5986328125,
0.3203125,
-0.163818359375,
0.1488037109375,
-0.58447265625,
-0.33544921875,
-0.295654296875,
0.2529296875,
0.0780029296875,
0.97119140625,
0.9384765625,
0.0869140625,
0.1932373046875,
-0.6884765625,
-0.380126953125,
0.1580810546875,
-0.32861328125,
-0.64453125,
-0.... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp plays "Game 23". Initially he has a number n and his goal is to transform it to m. In one move, he can multiply n by 2 or multiply n by 3. He can perform any number of moves.
Print the number of moves needed to transform n to m. Print -1 if it is impossible to do so.
It is easy to prove that any way to transform n to m contains the same number of moves (i.e. number of moves doesn't depend on the way of transformation).
Input
The only line of the input contains two integers n and m (1 β€ n β€ m β€ 5β
10^8).
Output
Print the number of moves to transform n to m, or -1 if there is no solution.
Examples
Input
120 51840
Output
7
Input
42 42
Output
0
Input
48 72
Output
-1
Note
In the first example, the possible sequence of moves is: 120 β 240 β 720 β 1440 β 4320 β 12960 β 25920 β 51840. The are 7 steps in total.
In the second example, no moves are needed. Thus, the answer is 0.
In the third example, it is impossible to transform 48 to 72.
Submitted Solution:
```
n,m=map(int,input().split())
count =0
if not((m//n)%2 == 0 or (m//n)%3==0 or m==n):
print(-1)
else:
if (m//n)%2 == 0 or (m//n)%3==0 or m==n:
while m>n :
if (m//n)%2 == 0 or (m//n)%3==0 or m==n:
if m%2 == 0 and m!=n:
m/=2
count +=1
if m%3 == 0 and m!=n:
m/=3
count +=1
print(int(count))
```
No
| 93,593 | [
0.5595703125,
0.295654296875,
-0.2296142578125,
0.1181640625,
-0.552734375,
-0.374755859375,
-0.2568359375,
0.232421875,
0.08966064453125,
1.037109375,
0.9560546875,
0.158935546875,
0.218017578125,
-0.759765625,
-0.3603515625,
0.1688232421875,
-0.36572265625,
-0.6767578125,
-0.40... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp plays "Game 23". Initially he has a number n and his goal is to transform it to m. In one move, he can multiply n by 2 or multiply n by 3. He can perform any number of moves.
Print the number of moves needed to transform n to m. Print -1 if it is impossible to do so.
It is easy to prove that any way to transform n to m contains the same number of moves (i.e. number of moves doesn't depend on the way of transformation).
Input
The only line of the input contains two integers n and m (1 β€ n β€ m β€ 5β
10^8).
Output
Print the number of moves to transform n to m, or -1 if there is no solution.
Examples
Input
120 51840
Output
7
Input
42 42
Output
0
Input
48 72
Output
-1
Note
In the first example, the possible sequence of moves is: 120 β 240 β 720 β 1440 β 4320 β 12960 β 25920 β 51840. The are 7 steps in total.
In the second example, no moves are needed. Thus, the answer is 0.
In the third example, it is impossible to transform 48 to 72.
Submitted Solution:
```
import math
def primeFactors(n):
c=[]
# Print the number of two's that divide n
while n % 2 == 0:
c.append(2)
n = n // 2
# n must be odd at this point
# so a skip of 2 ( i = i + 2) can be used
for i in range(3,int(math.sqrt(n))+1,2):
# while i divides n , print i ad divide n
while n % i== 0:
c.append(i)
n = n // i
# Condition if n is a prime
# number greater than 2
if n > 2:
c.append(n)
return c
n,m = map(int,input().split())
k = m//n
l = m%n
if(l!=0 or (k%3!=0 and k%2!=0)):
if(n==m):
print(0)
else:
print(-1)
else:
print(len(primeFactors(k)))
```
No
| 93,594 | [
0.52197265625,
0.1298828125,
-0.2265625,
0.12347412109375,
-0.5234375,
-0.20068359375,
-0.24462890625,
0.2607421875,
0.1632080078125,
0.869140625,
0.966796875,
-0.09722900390625,
0.3447265625,
-0.720703125,
-0.2012939453125,
0.286865234375,
-0.369384765625,
-0.72998046875,
-0.489... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp plays "Game 23". Initially he has a number n and his goal is to transform it to m. In one move, he can multiply n by 2 or multiply n by 3. He can perform any number of moves.
Print the number of moves needed to transform n to m. Print -1 if it is impossible to do so.
It is easy to prove that any way to transform n to m contains the same number of moves (i.e. number of moves doesn't depend on the way of transformation).
Input
The only line of the input contains two integers n and m (1 β€ n β€ m β€ 5β
10^8).
Output
Print the number of moves to transform n to m, or -1 if there is no solution.
Examples
Input
120 51840
Output
7
Input
42 42
Output
0
Input
48 72
Output
-1
Note
In the first example, the possible sequence of moves is: 120 β 240 β 720 β 1440 β 4320 β 12960 β 25920 β 51840. The are 7 steps in total.
In the second example, no moves are needed. Thus, the answer is 0.
In the third example, it is impossible to transform 48 to 72.
Submitted Solution:
```
a=input()
b=[int(x)for x in a.split()]
def func3(number, rezdel):
for i in range(number):
if ((2**i)*(3**(number-i)))==rezdel:
return False
return True
def func (razdel):
for i in range(razdel):
if(3**i==razdel):
return i
def func2(razdel):
for i in range(razdel):
if(2**i==razdel):
return i
count=1
if b[1]%b[0]==0:
if(b[1]==b[0]):
print(0)
if(b[1]/b[0])%6==0:
while(func3(count,(int(b[1]/b[0])))):
count+=1
print(count)
elif(b[1]/b[0])%3==0:
print(func(int(b[1]/b[0])))
elif (b[1]/b[0])%2==0:
print(str(func2(int(b[1]/b[0]))))
else:
print(-1)
```
No
| 93,595 | [
0.56396484375,
0.2369384765625,
-0.1683349609375,
0.30224609375,
-0.487548828125,
-0.322998046875,
-0.269287109375,
0.1514892578125,
-0.021942138671875,
1.072265625,
0.98828125,
-0.0295257568359375,
0.2117919921875,
-0.72216796875,
-0.223876953125,
0.244140625,
-0.55224609375,
-0.6... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 β€ si β€ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum number of cars will the children need if all members of each group should ride in the same taxi (but one taxi can take more than one group)?
Input
The first line contains integer n (1 β€ n β€ 105) β the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 β€ si β€ 4). The integers are separated by a space, si is the number of children in the i-th group.
Output
Print the single number β the minimum number of taxis necessary to drive all children to Polycarpus.
Examples
Input
5
1 2 4 3 3
Output
4
Input
8
2 3 4 4 2 1 3 1
Output
5
Note
In the first test we can sort the children into four cars like this:
* the third group (consisting of four children),
* the fourth group (consisting of three children),
* the fifth group (consisting of three children),
* the first and the second group (consisting of one and two children, correspondingly).
There are other ways to sort the groups into four cars.
Tags: *special, greedy, implementation
Correct Solution:
```
num = int(input())
i=0
total=0
k=0
k1=0
k2=0
k3=0
k4=0
arr=[]
arr = input().split()
for i in range(len(arr)):
arr[i]= int(arr[i])
for nmb in arr:
nmb= int(nmb)
if nmb==4:
k4+=1
elif nmb==3:
k3+=1
elif nmb==2:
k2+=1
elif nmb==1:
k1+=1
if k2==0 and k1==0:
total=int(k4+k3)
elif k1!=0 and k2==0:
if k3>=k1:
total=k3+k4
else:
if k1%4==0:
total=k4+k3+((k1-k3)/4)
else:
total=k4+k3+((k1-k3)/4)+1
elif k1!=0 and k2!=0:
if k3>k1:
t2=(k2*2)
if t2%4==0:
total=int(t2/4)+k4+k1+(k3-k1)
else:
total=int(t2/4)+1+k4+k1+(k3-k1)
else:
t2=k4*4+k3*3+k2*2+k1
if t2%4==0:
total=int(t2/4)
else:
total=int(t2/4)+1
elif k1==0:
if (k2*2)%4==0:
total=int(k4+k3+(k2*2/4))
else:
total=k4+k3+(int(k2*2/4)+1)
print(int(total))
```
| 93,763 | [
0.496826171875,
0.277587890625,
0.06353759765625,
0.142578125,
-0.37060546875,
-0.42529296875,
-0.158447265625,
0.223388671875,
0.251220703125,
0.6015625,
0.7724609375,
-0.188720703125,
0.2120361328125,
-0.58740234375,
-0.53515625,
0.381591796875,
-0.4697265625,
-0.3955078125,
-0... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 β€ si β€ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum number of cars will the children need if all members of each group should ride in the same taxi (but one taxi can take more than one group)?
Input
The first line contains integer n (1 β€ n β€ 105) β the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 β€ si β€ 4). The integers are separated by a space, si is the number of children in the i-th group.
Output
Print the single number β the minimum number of taxis necessary to drive all children to Polycarpus.
Examples
Input
5
1 2 4 3 3
Output
4
Input
8
2 3 4 4 2 1 3 1
Output
5
Note
In the first test we can sort the children into four cars like this:
* the third group (consisting of four children),
* the fourth group (consisting of three children),
* the fifth group (consisting of three children),
* the first and the second group (consisting of one and two children, correspondingly).
There are other ways to sort the groups into four cars.
Tags: *special, greedy, implementation
Correct Solution:
```
n = int(input())
s = list(map(int, input().split()))
cabs = 0
one = s.count(1)
two = s.count(2)
three = s.count(3)
four = s.count(4)
cabs += two // 2 + three + four
one -= three
if two % 2 == 1:
cabs += 1
one -= 2
if one > 0:
cabs += (one + 3) // 4
print(cabs)
```
| 93,764 | [
0.499267578125,
0.35400390625,
0.109130859375,
0.21240234375,
-0.345947265625,
-0.390869140625,
-0.23779296875,
0.238525390625,
0.330810546875,
0.54345703125,
0.78466796875,
-0.1285400390625,
0.306640625,
-0.6181640625,
-0.55810546875,
0.260009765625,
-0.436767578125,
-0.3657226562... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 β€ si β€ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum number of cars will the children need if all members of each group should ride in the same taxi (but one taxi can take more than one group)?
Input
The first line contains integer n (1 β€ n β€ 105) β the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 β€ si β€ 4). The integers are separated by a space, si is the number of children in the i-th group.
Output
Print the single number β the minimum number of taxis necessary to drive all children to Polycarpus.
Examples
Input
5
1 2 4 3 3
Output
4
Input
8
2 3 4 4 2 1 3 1
Output
5
Note
In the first test we can sort the children into four cars like this:
* the third group (consisting of four children),
* the fourth group (consisting of three children),
* the fifth group (consisting of three children),
* the first and the second group (consisting of one and two children, correspondingly).
There are other ways to sort the groups into four cars.
Tags: *special, greedy, implementation
Correct Solution:
```
n=int(input())
taxi=n1=n2=n3=n4=0
x=[]
for i in range(0,n):
x.append('0')
x=input().split()
for i in range(0,n):
if(x[i]=='1'):
n1+=1
elif(x[i]=='2'):
n2+=1
elif(x[i]=='3'):
n3+=1
else:
n4+=1
taxi+=n4
if(n3>n1 or n3==n1):
taxi+=n3
n1=0
else:
taxi+=n3
n1=n1-n3
taxi+=n2//2
n2=n2%2
if(n2==1):
taxi+=1
if(n1>2):
n1-=2
else:
n1=0
taxi+=(n1//4)
if(n1%4!=0 and n1!=0):
taxi+=1
print(taxi)
```
| 93,765 | [
0.50341796875,
0.319091796875,
0.13916015625,
0.2020263671875,
-0.363525390625,
-0.424072265625,
-0.1837158203125,
0.19287109375,
0.3154296875,
0.56103515625,
0.7900390625,
-0.1571044921875,
0.26416015625,
-0.57470703125,
-0.51904296875,
0.25537109375,
-0.45068359375,
-0.3698730468... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 β€ si β€ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum number of cars will the children need if all members of each group should ride in the same taxi (but one taxi can take more than one group)?
Input
The first line contains integer n (1 β€ n β€ 105) β the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 β€ si β€ 4). The integers are separated by a space, si is the number of children in the i-th group.
Output
Print the single number β the minimum number of taxis necessary to drive all children to Polycarpus.
Examples
Input
5
1 2 4 3 3
Output
4
Input
8
2 3 4 4 2 1 3 1
Output
5
Note
In the first test we can sort the children into four cars like this:
* the third group (consisting of four children),
* the fourth group (consisting of three children),
* the fifth group (consisting of three children),
* the first and the second group (consisting of one and two children, correspondingly).
There are other ways to sort the groups into four cars.
Tags: *special, greedy, implementation
Correct Solution:
```
n = int(input())
l = list(map(int, input().split()))
f = 0
th = 0
tw = 0
o = 0
for i in range(len(l)):
#print (l[i])
if l[i] == 1:
o += 1
elif l[i] == 2:
tw += 1
elif l[i] == 3:
th += 1
elif l[i] == 4:
f += 1
#print (f, th, tw, o)
ans = f
#print(ans)
ans += th
#print(ans)
o = max(0, o - th)
ans += tw // 2
#print(ans)
if (tw % 2):
ans += 1
if (tw % 2) and o:
o = max(0, o - 2)
ans += o // 4
#print(ans)
if o % 4:
ans += 1
print(ans)
```
| 93,766 | [
0.46435546875,
0.30712890625,
0.11724853515625,
0.1788330078125,
-0.40283203125,
-0.37451171875,
-0.20849609375,
0.221923828125,
0.33740234375,
0.5166015625,
0.681640625,
-0.1380615234375,
0.3017578125,
-0.54638671875,
-0.56005859375,
0.2318115234375,
-0.452880859375,
-0.3842773437... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 β€ si β€ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum number of cars will the children need if all members of each group should ride in the same taxi (but one taxi can take more than one group)?
Input
The first line contains integer n (1 β€ n β€ 105) β the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 β€ si β€ 4). The integers are separated by a space, si is the number of children in the i-th group.
Output
Print the single number β the minimum number of taxis necessary to drive all children to Polycarpus.
Examples
Input
5
1 2 4 3 3
Output
4
Input
8
2 3 4 4 2 1 3 1
Output
5
Note
In the first test we can sort the children into four cars like this:
* the third group (consisting of four children),
* the fourth group (consisting of three children),
* the fifth group (consisting of three children),
* the first and the second group (consisting of one and two children, correspondingly).
There are other ways to sort the groups into four cars.
Tags: *special, greedy, implementation
Correct Solution:
```
n = input()
t = list(map(int,input().split()))
a,b,c,d = [t.count(x+1) for x in range(4)]
print(d+c--b//2--max(0,a-c-b%2*2)//4)
```
| 93,767 | [
0.478271484375,
0.3486328125,
0.10211181640625,
0.227783203125,
-0.37890625,
-0.37939453125,
-0.23583984375,
0.2408447265625,
0.3271484375,
0.52734375,
0.712890625,
-0.124267578125,
0.274169921875,
-0.560546875,
-0.53662109375,
0.2418212890625,
-0.44873046875,
-0.393310546875,
-0... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 β€ si β€ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum number of cars will the children need if all members of each group should ride in the same taxi (but one taxi can take more than one group)?
Input
The first line contains integer n (1 β€ n β€ 105) β the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 β€ si β€ 4). The integers are separated by a space, si is the number of children in the i-th group.
Output
Print the single number β the minimum number of taxis necessary to drive all children to Polycarpus.
Examples
Input
5
1 2 4 3 3
Output
4
Input
8
2 3 4 4 2 1 3 1
Output
5
Note
In the first test we can sort the children into four cars like this:
* the third group (consisting of four children),
* the fourth group (consisting of three children),
* the fifth group (consisting of three children),
* the first and the second group (consisting of one and two children, correspondingly).
There are other ways to sort the groups into four cars.
Tags: *special, greedy, implementation
Correct Solution:
```
import math
cars = 0
n = int(input())
s = [int(i) for i in input().split()]
groups = [0,0,0,0]
for i in s:
groups[i-1] += 1
cars += groups[3]
if groups[2] >= groups[0]:
cars += groups[0]
groups[2] -= groups[0]
groups[0] = 0
else:
cars += groups[2]
groups[0] -= groups[2]
groups[2] = 0
cars += groups[1]//2
groups[1] -= groups[1]//2*2
cars += groups[2]
if groups[1] == 1:
cars += 1
if groups[0] >= 2:
groups[0] -= 2
else:
groups[0] = 0
cars += int(math.ceil(groups[0]/4))
print(cars)
```
| 93,768 | [
0.43896484375,
0.374267578125,
0.11956787109375,
0.193603515625,
-0.3173828125,
-0.388427734375,
-0.1898193359375,
0.205322265625,
0.321044921875,
0.5380859375,
0.78271484375,
-0.154541015625,
0.237548828125,
-0.6201171875,
-0.5478515625,
0.2369384765625,
-0.4345703125,
-0.36499023... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 β€ si β€ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum number of cars will the children need if all members of each group should ride in the same taxi (but one taxi can take more than one group)?
Input
The first line contains integer n (1 β€ n β€ 105) β the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 β€ si β€ 4). The integers are separated by a space, si is the number of children in the i-th group.
Output
Print the single number β the minimum number of taxis necessary to drive all children to Polycarpus.
Examples
Input
5
1 2 4 3 3
Output
4
Input
8
2 3 4 4 2 1 3 1
Output
5
Note
In the first test we can sort the children into four cars like this:
* the third group (consisting of four children),
* the fourth group (consisting of three children),
* the fifth group (consisting of three children),
* the first and the second group (consisting of one and two children, correspondingly).
There are other ways to sort the groups into four cars.
Tags: *special, greedy, implementation
Correct Solution:
```
# Solution found online
input()
arr = [0, 0, 0, 0, 0]
for i in input().split():
arr[int(i)] += 1
total = arr[4] + arr[3] + arr[2] // 2
arr[1] -= arr[3]
if arr[2] % 2 == 1:
total += 1
arr[1] -= 2
if arr[1] > 0:
total += (arr[1] + 3) // 4
print(total)
# MY ORIGINAL SOLUTION BELOW
# Interestingly enough both solutions are the same runtime
# obv the above solution is hella cleaner though
# input()
# arr = [int(i) for i in input().split()]
# k = [0, 0, 0, 0, 0]
# for i in arr:
# k[i] += 1
# t = 0
# t += k[4]
# k[4] = 0
# ot = min(k[1], k[3])
# t += ot
# k[1] -= ot
# k[3] -= ot
# twos = k[2] // 2
# t += twos
# k[2] -= twos * 2
# k[2] %= 2
# if k[2] == 1:
# if k[1] > 0:
# t += 1
# k[2] = 0
# k[1] -= min(k[1], 2)
# else:
# t += 1
# k[2] = 0
# for i in range(4, 0, -1):
# num = k[1] // i
# t += num
# k[1] -= num * i
# t += k[3]
# print(t)
```
| 93,769 | [
0.509765625,
0.3984375,
0.0816650390625,
0.18359375,
-0.346923828125,
-0.455810546875,
-0.2061767578125,
0.265380859375,
0.326416015625,
0.54345703125,
0.8076171875,
-0.17919921875,
0.26416015625,
-0.63134765625,
-0.6171875,
0.2215576171875,
-0.43701171875,
-0.2470703125,
-0.4790... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 β€ si β€ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum number of cars will the children need if all members of each group should ride in the same taxi (but one taxi can take more than one group)?
Input
The first line contains integer n (1 β€ n β€ 105) β the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 β€ si β€ 4). The integers are separated by a space, si is the number of children in the i-th group.
Output
Print the single number β the minimum number of taxis necessary to drive all children to Polycarpus.
Examples
Input
5
1 2 4 3 3
Output
4
Input
8
2 3 4 4 2 1 3 1
Output
5
Note
In the first test we can sort the children into four cars like this:
* the third group (consisting of four children),
* the fourth group (consisting of three children),
* the fifth group (consisting of three children),
* the first and the second group (consisting of one and two children, correspondingly).
There are other ways to sort the groups into four cars.
Tags: *special, greedy, implementation
Correct Solution:
```
# fails only in 3 3 2 it give 2 but answer is 3
# import math
# n=int(input())
# pas=list(map(int,input().split()[:n]))
# sums = 0
# for i in range(0,len(pas)):
# sums=sums+pas[i]
# if(n == 3):
# if(pas[0] == 3 and pas[1] == 3 and pas[2]==2):
# print('3')
# else:
# print(math.ceil(sums/4))
# else:
# print(math.ceil(sums/4))
# special Implementation
input()
a,b,c,d=map(input().count,('1','2','3','4'))
print(d+c+(b*2+max(0,a-c)+3)//4)
```
| 93,770 | [
0.48046875,
0.325927734375,
0.10540771484375,
0.1878662109375,
-0.364013671875,
-0.338623046875,
-0.2158203125,
0.254638671875,
0.3046875,
0.56640625,
0.732421875,
-0.165771484375,
0.304931640625,
-0.5859375,
-0.56787109375,
0.262939453125,
-0.423583984375,
-0.357421875,
-0.54687... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 β€ si β€ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum number of cars will the children need if all members of each group should ride in the same taxi (but one taxi can take more than one group)?
Input
The first line contains integer n (1 β€ n β€ 105) β the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 β€ si β€ 4). The integers are separated by a space, si is the number of children in the i-th group.
Output
Print the single number β the minimum number of taxis necessary to drive all children to Polycarpus.
Examples
Input
5
1 2 4 3 3
Output
4
Input
8
2 3 4 4 2 1 3 1
Output
5
Note
In the first test we can sort the children into four cars like this:
* the third group (consisting of four children),
* the fourth group (consisting of three children),
* the fifth group (consisting of three children),
* the first and the second group (consisting of one and two children, correspondingly).
There are other ways to sort the groups into four cars.
Submitted Solution:
```
import collections
n = int(input())
a = list(map(int,input().split()))
k = collections.Counter(a)
r = 0
r+= k[4]
temp = k[2] // 2
r+= temp
k[2] -= temp*2
k[4] = 0
if k[3]<k[1]:
r += k[3]
k[1] -= k[3]
k[3]-=k[3]
else:
r += k[1]
k[3] -= k[1]
k[1] -= k[1]
r += k[3]
k[3] = 0
if k[1]>=1 and k[2] == 1:
r+= 1
k[1] -= 2
k[2] -= 1
if k[2] == 1:
r += 1
k[2] = 0
while k[1]>0:
r+=1
k[1]-=4
print(r)
```
Yes
| 93,771 | [
0.423828125,
0.429443359375,
0.04669189453125,
0.21044921875,
-0.53564453125,
-0.3310546875,
-0.27490234375,
0.395751953125,
0.265869140625,
0.63232421875,
0.7216796875,
-0.0965576171875,
0.1964111328125,
-0.5615234375,
-0.5419921875,
0.226318359375,
-0.505859375,
-0.39404296875,
... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 β€ si β€ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum number of cars will the children need if all members of each group should ride in the same taxi (but one taxi can take more than one group)?
Input
The first line contains integer n (1 β€ n β€ 105) β the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 β€ si β€ 4). The integers are separated by a space, si is the number of children in the i-th group.
Output
Print the single number β the minimum number of taxis necessary to drive all children to Polycarpus.
Examples
Input
5
1 2 4 3 3
Output
4
Input
8
2 3 4 4 2 1 3 1
Output
5
Note
In the first test we can sort the children into four cars like this:
* the third group (consisting of four children),
* the fourth group (consisting of three children),
* the fifth group (consisting of three children),
* the first and the second group (consisting of one and two children, correspondingly).
There are other ways to sort the groups into four cars.
Submitted Solution:
```
n=int(input())
a=list(map(int,input().split(" ")))
c1=0
c2=0
c3=0
c4=0
for i in range(0,n):
if a[i]==1: c1+=1
elif a[i]==2: c2+=1
elif a[i]==3: c3+=1
elif a[i]==4: c4+=1
count=c4+c3
c1=c1-c3
count=count+(c2//2)
if(c2%2>0) :
count=count+1
c1=c1-2
if(c1>0) :
count=count+(c1//4)
if(c1%4>0) : count=count+1
print(count)
```
Yes
| 93,772 | [
0.42578125,
0.36083984375,
0.07012939453125,
0.203857421875,
-0.5234375,
-0.32470703125,
-0.2357177734375,
0.373291015625,
0.24462890625,
0.67041015625,
0.74072265625,
-0.07403564453125,
0.1929931640625,
-0.58203125,
-0.5439453125,
0.25,
-0.473388671875,
-0.388427734375,
-0.47509... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 β€ si β€ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum number of cars will the children need if all members of each group should ride in the same taxi (but one taxi can take more than one group)?
Input
The first line contains integer n (1 β€ n β€ 105) β the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 β€ si β€ 4). The integers are separated by a space, si is the number of children in the i-th group.
Output
Print the single number β the minimum number of taxis necessary to drive all children to Polycarpus.
Examples
Input
5
1 2 4 3 3
Output
4
Input
8
2 3 4 4 2 1 3 1
Output
5
Note
In the first test we can sort the children into four cars like this:
* the third group (consisting of four children),
* the fourth group (consisting of three children),
* the fifth group (consisting of three children),
* the first and the second group (consisting of one and two children, correspondingly).
There are other ways to sort the groups into four cars.
Submitted Solution:
```
arr=[]
for i in range(0,5):
arr.append(0)
n=int(input())
a=list(map(int,input().split()))
for i in range(0,n):
arr[a[i]]+=1
con=0
con+=arr[4]
con+=arr[3]
if arr[1]>arr[3]:
if arr[2]!=0:
if arr[2]%2==0:
con+=arr[2]//2
arr[1]=arr[1]-arr[3]
if arr[1]%4==0:
con+=arr[1]//4
else:
con+=(arr[1]//4)+1
else:
arr[1] = arr[1]-arr[3]
con+=(arr[2]//2)+1
if arr[1]>2:
arr[1]-=2
if arr[1]%4==0:
con+=arr[1]//4
else:
con += (arr[1]//4)+1
else:
arr[1] = arr[1] - arr[3]
if arr[1] % 4 == 0:
con += arr[1] // 4
else:
con += (arr[1] //4) + 1
elif arr[1]<=arr[3]:
if arr[2]!=0:
if arr[2]%2==0:
con+=arr[2]//2
else:
con+=(arr[2]//2)+1
print(con)
```
Yes
| 93,773 | [
0.4306640625,
0.433349609375,
0.0626220703125,
0.177734375,
-0.491455078125,
-0.337646484375,
-0.2578125,
0.348876953125,
0.28125,
0.65380859375,
0.84326171875,
-0.12066650390625,
0.201171875,
-0.62255859375,
-0.58837890625,
0.2108154296875,
-0.468017578125,
-0.292236328125,
-0.4... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 β€ si β€ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum number of cars will the children need if all members of each group should ride in the same taxi (but one taxi can take more than one group)?
Input
The first line contains integer n (1 β€ n β€ 105) β the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 β€ si β€ 4). The integers are separated by a space, si is the number of children in the i-th group.
Output
Print the single number β the minimum number of taxis necessary to drive all children to Polycarpus.
Examples
Input
5
1 2 4 3 3
Output
4
Input
8
2 3 4 4 2 1 3 1
Output
5
Note
In the first test we can sort the children into four cars like this:
* the third group (consisting of four children),
* the fourth group (consisting of three children),
* the fifth group (consisting of three children),
* the first and the second group (consisting of one and two children, correspondingly).
There are other ways to sort the groups into four cars.
Submitted Solution:
```
n=int(input())
s=input()
o=0
tw=0
t=0
f=0
for i in s:
if i=="4":
f+=1
elif i=="3":
t+=1
elif i=="2":
tw+=1
elif i=="1":
o+=1
if o-t<=0:
l=f+t+tw//2+tw%2
elif o-t<=2 and tw%2!=0:
l=f+t+tw//2+tw%2
elif o-t<=4 and tw%2==0:
l=f+t+tw//2+1
elif (o-t-(tw%2)*2)%4==0:
l=f+t+tw//2+(o-t-(tw%2)*2)//4+tw%2
else:
l=f+t+tw//2+(o-t-(tw%2)*2)//4+tw%2+1
print(l)
```
Yes
| 93,774 | [
0.435302734375,
0.388671875,
0.0716552734375,
0.231201171875,
-0.583984375,
-0.3037109375,
-0.2476806640625,
0.402587890625,
0.250244140625,
0.63330078125,
0.68701171875,
-0.06903076171875,
0.1612548828125,
-0.57568359375,
-0.56787109375,
0.232666015625,
-0.462646484375,
-0.3723144... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 β€ si β€ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum number of cars will the children need if all members of each group should ride in the same taxi (but one taxi can take more than one group)?
Input
The first line contains integer n (1 β€ n β€ 105) β the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 β€ si β€ 4). The integers are separated by a space, si is the number of children in the i-th group.
Output
Print the single number β the minimum number of taxis necessary to drive all children to Polycarpus.
Examples
Input
5
1 2 4 3 3
Output
4
Input
8
2 3 4 4 2 1 3 1
Output
5
Note
In the first test we can sort the children into four cars like this:
* the third group (consisting of four children),
* the fourth group (consisting of three children),
* the fifth group (consisting of three children),
* the first and the second group (consisting of one and two children, correspondingly).
There are other ways to sort the groups into four cars.
Submitted Solution:
```
n =int(input())
x = list(map(int, input().split()))
i = 1
r = 0
while i < n+1:
r += x[i-1]
i += 1
k = (r + 3) // 4
if (n<4)and(k!=n)and(r<=4*k): k = n
print(k)
```
No
| 93,775 | [
0.429443359375,
0.397705078125,
0.04010009765625,
0.220947265625,
-0.509765625,
-0.313720703125,
-0.287841796875,
0.401611328125,
0.26025390625,
0.642578125,
0.7294921875,
-0.061248779296875,
0.1802978515625,
-0.564453125,
-0.54150390625,
0.18994140625,
-0.4736328125,
-0.4162597656... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 β€ si β€ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum number of cars will the children need if all members of each group should ride in the same taxi (but one taxi can take more than one group)?
Input
The first line contains integer n (1 β€ n β€ 105) β the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 β€ si β€ 4). The integers are separated by a space, si is the number of children in the i-th group.
Output
Print the single number β the minimum number of taxis necessary to drive all children to Polycarpus.
Examples
Input
5
1 2 4 3 3
Output
4
Input
8
2 3 4 4 2 1 3 1
Output
5
Note
In the first test we can sort the children into four cars like this:
* the third group (consisting of four children),
* the fourth group (consisting of three children),
* the fifth group (consisting of three children),
* the first and the second group (consisting of one and two children, correspondingly).
There are other ways to sort the groups into four cars.
Submitted Solution:
```
n = int(input())
s = input()
l = s.split(" ")
l.sort(reverse=True)
for i in range(0, len(l)):
l[i] = int(l[i])
c = 0
for x in range(n):
if l[x] == 4:
c += 1
l[x] = 0
elif l[x] != 0:
for y in range(x + 1, n):
if l[x] + l[y] == 4 and l[y] != 0:
c += 1
l[x] = 0
l[y] = 0
for x in l:
if x != 0:
c += 1
print(c)
```
No
| 93,776 | [
0.4443359375,
0.37158203125,
0.06561279296875,
0.206787109375,
-0.517578125,
-0.257080078125,
-0.263671875,
0.40380859375,
0.24658203125,
0.61328125,
0.71240234375,
-0.0721435546875,
0.1787109375,
-0.55810546875,
-0.54296875,
0.202392578125,
-0.4609375,
-0.3603515625,
-0.49023437... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 β€ si β€ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum number of cars will the children need if all members of each group should ride in the same taxi (but one taxi can take more than one group)?
Input
The first line contains integer n (1 β€ n β€ 105) β the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 β€ si β€ 4). The integers are separated by a space, si is the number of children in the i-th group.
Output
Print the single number β the minimum number of taxis necessary to drive all children to Polycarpus.
Examples
Input
5
1 2 4 3 3
Output
4
Input
8
2 3 4 4 2 1 3 1
Output
5
Note
In the first test we can sort the children into four cars like this:
* the third group (consisting of four children),
* the fourth group (consisting of three children),
* the fifth group (consisting of three children),
* the first and the second group (consisting of one and two children, correspondingly).
There are other ways to sort the groups into four cars.
Submitted Solution:
```
n = int(input())
arr = list(map(int, input().split()))
if sum(arr) >= 4:
s = sum(arr) // 4
l = sum(arr) % 4
if l == 0:
print(l + s)
else:
print(s + 1)
else:
print(1)
```
No
| 93,777 | [
0.444580078125,
0.41943359375,
-0.0010805130004882812,
0.212158203125,
-0.5224609375,
-0.30712890625,
-0.251220703125,
0.415771484375,
0.26513671875,
0.595703125,
0.75,
-0.07708740234375,
0.19287109375,
-0.56298828125,
-0.5908203125,
0.16796875,
-0.466796875,
-0.40966796875,
-0.4... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 β€ si β€ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum number of cars will the children need if all members of each group should ride in the same taxi (but one taxi can take more than one group)?
Input
The first line contains integer n (1 β€ n β€ 105) β the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 β€ si β€ 4). The integers are separated by a space, si is the number of children in the i-th group.
Output
Print the single number β the minimum number of taxis necessary to drive all children to Polycarpus.
Examples
Input
5
1 2 4 3 3
Output
4
Input
8
2 3 4 4 2 1 3 1
Output
5
Note
In the first test we can sort the children into four cars like this:
* the third group (consisting of four children),
* the fourth group (consisting of three children),
* the fifth group (consisting of three children),
* the first and the second group (consisting of one and two children, correspondingly).
There are other ways to sort the groups into four cars.
Submitted Solution:
```
t = int(input())
a = list(map(int,input().split()))
c1 = 0
c2 = 0
c3 = 0
c4 = 0
for i in range(t) :
if a[i] == 4 :
c4 += 1
if a[i] == 3 :
c3 += 1
if a[i] == 2 :
c2 += 1
if a[i] == 1 :
c1 += 1
ans = c4 + c3
if c2%2 == 0:
ans += c2//2
if c2%2 == 1 and c3>=c1:
co2 = (c2-1)//2
ans = ans + co2 + 1
elif c3 < c1 :
co1 = c1-c3
if co1%4==0:
ans += (co1//4)
else :
ans += (co1//4) + 1
## if co1%4==0:
## ans += (co1//4)
## elif co1%4==1 :
## ans += (co1+1)//4
## elif co1%4==2 :
## ans += (co1+2)//4
## else :
## ans += (co1+3)//4
print(ans)
```
No
| 93,778 | [
0.41845703125,
0.387451171875,
0.10675048828125,
0.20947265625,
-0.51806640625,
-0.32177734375,
-0.23876953125,
0.36865234375,
0.2457275390625,
0.66845703125,
0.75732421875,
-0.0828857421875,
0.179443359375,
-0.58349609375,
-0.53271484375,
0.238037109375,
-0.46044921875,
-0.3798828... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Only T milliseconds left before the start of well-known online programming contest Codehorses Round 2017.
Polycarp needs to download B++ compiler to take part in the contest. The size of the file is f bytes.
Polycarp's internet tariff allows to download data at the rate of one byte per t0 milliseconds. This tariff is already prepaid, and its use does not incur any expense for Polycarp. In addition, the Internet service provider offers two additional packages:
* download a1 bytes at the rate of one byte per t1 milliseconds, paying p1 burles for the package;
* download a2 bytes at the rate of one byte per t2 milliseconds, paying p2 burles for the package.
Polycarp can buy any package many times. When buying a package, its price (p1 or p2) is prepaid before usage. Once a package is bought it replaces the regular tariff until package data limit is completely used. After a package is consumed Polycarp can immediately buy a new package or switch to the regular tariff without loosing any time. While a package is in use Polycarp can't buy another package or switch back to the regular internet tariff.
Find the minimum amount of money Polycarp has to spend to download an f bytes file no more than in T milliseconds.
Note that because of technical reasons Polycarp can download only integer number of bytes using regular tariff and both packages. I.e. in each of three downloading modes the number of downloaded bytes will be integer. It means that Polycarp can't download a byte partially using the regular tariff or/and both packages.
Input
The first line contains three integer numbers f, T and t0 (1 β€ f, T, t0 β€ 107) β size of the file to download (in bytes), maximal time to download the file (in milliseconds) and number of milliseconds to download one byte using the regular internet tariff.
The second line contains a description of the first additional package. The line contains three integer numbers a1, t1 and p1 (1 β€ a1, t1, p1 β€ 107), where a1 is maximal sizes of downloaded data (in bytes), t1 is time to download one byte (in milliseconds), p1 is price of the package (in burles).
The third line contains a description of the second additional package. The line contains three integer numbers a2, t2 and p2 (1 β€ a2, t2, p2 β€ 107), where a2 is maximal sizes of downloaded data (in bytes), t2 is time to download one byte (in milliseconds), p2 is price of the package (in burles).
Polycarp can buy any package many times. Once package is bought it replaces the regular tariff until package data limit is completely used. While a package is in use Polycarp can't buy another package or switch back to the regular internet tariff.
Output
Print the minimum amount of money that Polycarp needs to pay to download B++ compiler no more than in T milliseconds. If there is no solution, print the only integer -1.
Examples
Input
120 964 20
26 8 8
13 10 4
Output
40
Input
10 200 20
1 1 1
2 2 3
Output
0
Input
8 81 11
4 10 16
3 10 12
Output
28
Input
8 79 11
4 10 16
3 10 12
Output
-1
Note
In the first example Polycarp has to buy the first additional package 5 times and do not buy the second additional package. He downloads 120 bytes (of total 26Β·5 = 130 bytes) in 120Β·8 = 960 milliseconds (960 β€ 964). He spends 8Β·5 = 40 burles on it.
In the second example Polycarp has enough time to download 10 bytes. It takes 10Β·20 = 200 milliseconds which equals to upper constraint on download time.
In the third example Polycarp has to buy one first additional package and one second additional package.
In the fourth example Polycarp has no way to download the file on time.
Submitted Solution:
```
f = 0
T = 0
t0 = 0
a1 = 0
t1 = 0
p1 = 0
a2 = 0
t2 = 0
p2 = 0
R = 0
def func(leftt, leftb, mid):
global f, T, t0, a1, t1, p1, a2, t2, p2, R
ft = 0
if (mid == R):
ft += (mid - 1) * a2;
keks = (leftt - (mid - 1) * a2 * t2) // t2
ft += keks;
else:
ft += (leftt - mid * a2 * t2) // t0
ft += mid * a2
return ft >= leftb
def keks(cnt):
global f, T, t0, a1, t1, p1, a2, t2, p2, R
ks = cnt * a1
if (ks * t1 >= T):
g = (cnt - 1) * a1 + (T - (cnt - 1) * t1 * a1) // t1
if (g >= f):
return cnt * p1
return 1e18
if (ks >= f):
return cnt * p1
leftt = T - ks * t1
leftb = f - ks
if (t2 < t0):
r = (leftt) // (a2 * t2) + 1
R = r
diff = leftb * t0 - leftt
sf = t0 - t2
keks = (diff * t2 + sf - 1) // sf
if (keks % a2 != 0):
keks+= a2 - keks % a2
keks //= a2
keks //= t2
ans = 1e18
for i in range(keks - 1, keks + 1):
l = i
if (l >= 0 and l <= r):
if (func(leftt, leftb, l)):
ans = min(ans, cnt * p1 + l * p2)
return ans;
else:
if (func(leftt, leftb, 0)):
return cnt * p
return 1e18;
def main():
global f, T, t0, a1, t1, p1, a2, t2, p2, R
f, T, t0 = map(int, input().split())
a1, t1, p1 = map(int, input().split())
a2, t2, p2 = map(int, input().split())
ans = 1e18;
if (t0 * f <= T):
ans = 0;
print(ans)
return
ll = 0;
rr = T // (t1 * a1) + 1
for g in range(ll, rr + 1):
ans = min(ans, keks(g))
if (ans > 9e17):
print(-1)
return
print(ans)
main()
```
No
| 94,098 | [
0.402587890625,
0.0452880859375,
0.2103271484375,
0.30126953125,
-0.42333984375,
-0.067626953125,
-0.084228515625,
-0.035736083984375,
-0.21484375,
0.40478515625,
0.919921875,
-0.1380615234375,
0.4287109375,
-0.74609375,
-0.57763671875,
0.447021484375,
-0.328125,
-0.587890625,
-0... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Only T milliseconds left before the start of well-known online programming contest Codehorses Round 2017.
Polycarp needs to download B++ compiler to take part in the contest. The size of the file is f bytes.
Polycarp's internet tariff allows to download data at the rate of one byte per t0 milliseconds. This tariff is already prepaid, and its use does not incur any expense for Polycarp. In addition, the Internet service provider offers two additional packages:
* download a1 bytes at the rate of one byte per t1 milliseconds, paying p1 burles for the package;
* download a2 bytes at the rate of one byte per t2 milliseconds, paying p2 burles for the package.
Polycarp can buy any package many times. When buying a package, its price (p1 or p2) is prepaid before usage. Once a package is bought it replaces the regular tariff until package data limit is completely used. After a package is consumed Polycarp can immediately buy a new package or switch to the regular tariff without loosing any time. While a package is in use Polycarp can't buy another package or switch back to the regular internet tariff.
Find the minimum amount of money Polycarp has to spend to download an f bytes file no more than in T milliseconds.
Note that because of technical reasons Polycarp can download only integer number of bytes using regular tariff and both packages. I.e. in each of three downloading modes the number of downloaded bytes will be integer. It means that Polycarp can't download a byte partially using the regular tariff or/and both packages.
Input
The first line contains three integer numbers f, T and t0 (1 β€ f, T, t0 β€ 107) β size of the file to download (in bytes), maximal time to download the file (in milliseconds) and number of milliseconds to download one byte using the regular internet tariff.
The second line contains a description of the first additional package. The line contains three integer numbers a1, t1 and p1 (1 β€ a1, t1, p1 β€ 107), where a1 is maximal sizes of downloaded data (in bytes), t1 is time to download one byte (in milliseconds), p1 is price of the package (in burles).
The third line contains a description of the second additional package. The line contains three integer numbers a2, t2 and p2 (1 β€ a2, t2, p2 β€ 107), where a2 is maximal sizes of downloaded data (in bytes), t2 is time to download one byte (in milliseconds), p2 is price of the package (in burles).
Polycarp can buy any package many times. Once package is bought it replaces the regular tariff until package data limit is completely used. While a package is in use Polycarp can't buy another package or switch back to the regular internet tariff.
Output
Print the minimum amount of money that Polycarp needs to pay to download B++ compiler no more than in T milliseconds. If there is no solution, print the only integer -1.
Examples
Input
120 964 20
26 8 8
13 10 4
Output
40
Input
10 200 20
1 1 1
2 2 3
Output
0
Input
8 81 11
4 10 16
3 10 12
Output
28
Input
8 79 11
4 10 16
3 10 12
Output
-1
Note
In the first example Polycarp has to buy the first additional package 5 times and do not buy the second additional package. He downloads 120 bytes (of total 26Β·5 = 130 bytes) in 120Β·8 = 960 milliseconds (960 β€ 964). He spends 8Β·5 = 40 burles on it.
In the second example Polycarp has enough time to download 10 bytes. It takes 10Β·20 = 200 milliseconds which equals to upper constraint on download time.
In the third example Polycarp has to buy one first additional package and one second additional package.
In the fourth example Polycarp has no way to download the file on time.
Submitted Solution:
```
print("0")
```
No
| 94,099 | [
0.402587890625,
0.0452880859375,
0.2103271484375,
0.30126953125,
-0.42333984375,
-0.067626953125,
-0.084228515625,
-0.035736083984375,
-0.21484375,
0.40478515625,
0.919921875,
-0.1380615234375,
0.4287109375,
-0.74609375,
-0.57763671875,
0.447021484375,
-0.328125,
-0.587890625,
-0... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Only T milliseconds left before the start of well-known online programming contest Codehorses Round 2017.
Polycarp needs to download B++ compiler to take part in the contest. The size of the file is f bytes.
Polycarp's internet tariff allows to download data at the rate of one byte per t0 milliseconds. This tariff is already prepaid, and its use does not incur any expense for Polycarp. In addition, the Internet service provider offers two additional packages:
* download a1 bytes at the rate of one byte per t1 milliseconds, paying p1 burles for the package;
* download a2 bytes at the rate of one byte per t2 milliseconds, paying p2 burles for the package.
Polycarp can buy any package many times. When buying a package, its price (p1 or p2) is prepaid before usage. Once a package is bought it replaces the regular tariff until package data limit is completely used. After a package is consumed Polycarp can immediately buy a new package or switch to the regular tariff without loosing any time. While a package is in use Polycarp can't buy another package or switch back to the regular internet tariff.
Find the minimum amount of money Polycarp has to spend to download an f bytes file no more than in T milliseconds.
Note that because of technical reasons Polycarp can download only integer number of bytes using regular tariff and both packages. I.e. in each of three downloading modes the number of downloaded bytes will be integer. It means that Polycarp can't download a byte partially using the regular tariff or/and both packages.
Input
The first line contains three integer numbers f, T and t0 (1 β€ f, T, t0 β€ 107) β size of the file to download (in bytes), maximal time to download the file (in milliseconds) and number of milliseconds to download one byte using the regular internet tariff.
The second line contains a description of the first additional package. The line contains three integer numbers a1, t1 and p1 (1 β€ a1, t1, p1 β€ 107), where a1 is maximal sizes of downloaded data (in bytes), t1 is time to download one byte (in milliseconds), p1 is price of the package (in burles).
The third line contains a description of the second additional package. The line contains three integer numbers a2, t2 and p2 (1 β€ a2, t2, p2 β€ 107), where a2 is maximal sizes of downloaded data (in bytes), t2 is time to download one byte (in milliseconds), p2 is price of the package (in burles).
Polycarp can buy any package many times. Once package is bought it replaces the regular tariff until package data limit is completely used. While a package is in use Polycarp can't buy another package or switch back to the regular internet tariff.
Output
Print the minimum amount of money that Polycarp needs to pay to download B++ compiler no more than in T milliseconds. If there is no solution, print the only integer -1.
Examples
Input
120 964 20
26 8 8
13 10 4
Output
40
Input
10 200 20
1 1 1
2 2 3
Output
0
Input
8 81 11
4 10 16
3 10 12
Output
28
Input
8 79 11
4 10 16
3 10 12
Output
-1
Note
In the first example Polycarp has to buy the first additional package 5 times and do not buy the second additional package. He downloads 120 bytes (of total 26Β·5 = 130 bytes) in 120Β·8 = 960 milliseconds (960 β€ 964). He spends 8Β·5 = 40 burles on it.
In the second example Polycarp has enough time to download 10 bytes. It takes 10Β·20 = 200 milliseconds which equals to upper constraint on download time.
In the third example Polycarp has to buy one first additional package and one second additional package.
In the fourth example Polycarp has no way to download the file on time.
Submitted Solution:
```
f = 0
T = 0
t0 = 0
a1 = 0
t1 = 0
p1 = 0
a2 = 0
t2 = 0
p2 = 0
R = 0
def func(leftt, leftb, mid):
global f, T, t0, a1, t1, p1, a2, t2, p2, R
ft = 0
if (mid == R):
ft += (mid - 1) * a2;
keks = (leftt - (mid - 1) * a2 * t2) // t2
ft += keks;
else:
ft += (leftt - mid * a2 * t2) // t0
ft += mid * a2
return ft >= leftb
def keks(cnt):
global f, T, t0, a1, t1, p1, a2, t2, p2, R
ks = cnt * a1
if (ks * t1 >= T):
g = (cnt - 1) * a1 + (T - (cnt - 1) * t1 * a1) // t1
if (g >= f):
return cnt * p1
return 1e18
if (ks >= f):
return cnt * p1
leftt = T - ks * t1
leftb = f - ks
if (t2 < t0):
r = (leftt) // (a2 * t2) + 1
R = r
diff = leftb * t0 - leftt
sf = t0 - t2
keks = (diff * t2 + sf - 1) // sf
if (keks % a2 != 0):
keks+= a2 - keks % a2
keks //= a2
keks //= t2
ans = 1e18
for i in range(keks, keks + 1):
l = i
if (l >= 0 and l <= r):
if (func(leftt, leftb, l)):
ans = min(ans, cnt * p1 + l * p2)
if (func(leftt, leftb, 0)):
ans = min(ans, cnt * p1)
return ans;
else:
if (func(leftt, leftb, 0)):
return cnt * p
return 1e18;
def main():
global f, T, t0, a1, t1, p1, a2, t2, p2, R
f, T, t0 = map(int, input().split())
a1, t1, p1 = map(int, input().split())
a2, t2, p2 = map(int, input().split())
ans = 1e18;
if (t0 * f <= T):
ans = 0;
print(ans)
return
ll = 0;
rr = T // (t1 * a1) + 1
for g in range(ll, rr + 1):
ans = min(ans, keks(g))
if (ans > 9e17):
print(-1)
return
print(ans)
main()
```
No
| 94,100 | [
0.402587890625,
0.0452880859375,
0.2103271484375,
0.30126953125,
-0.42333984375,
-0.067626953125,
-0.084228515625,
-0.035736083984375,
-0.21484375,
0.40478515625,
0.919921875,
-0.1380615234375,
0.4287109375,
-0.74609375,
-0.57763671875,
0.447021484375,
-0.328125,
-0.587890625,
-0... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Only T milliseconds left before the start of well-known online programming contest Codehorses Round 2017.
Polycarp needs to download B++ compiler to take part in the contest. The size of the file is f bytes.
Polycarp's internet tariff allows to download data at the rate of one byte per t0 milliseconds. This tariff is already prepaid, and its use does not incur any expense for Polycarp. In addition, the Internet service provider offers two additional packages:
* download a1 bytes at the rate of one byte per t1 milliseconds, paying p1 burles for the package;
* download a2 bytes at the rate of one byte per t2 milliseconds, paying p2 burles for the package.
Polycarp can buy any package many times. When buying a package, its price (p1 or p2) is prepaid before usage. Once a package is bought it replaces the regular tariff until package data limit is completely used. After a package is consumed Polycarp can immediately buy a new package or switch to the regular tariff without loosing any time. While a package is in use Polycarp can't buy another package or switch back to the regular internet tariff.
Find the minimum amount of money Polycarp has to spend to download an f bytes file no more than in T milliseconds.
Note that because of technical reasons Polycarp can download only integer number of bytes using regular tariff and both packages. I.e. in each of three downloading modes the number of downloaded bytes will be integer. It means that Polycarp can't download a byte partially using the regular tariff or/and both packages.
Input
The first line contains three integer numbers f, T and t0 (1 β€ f, T, t0 β€ 107) β size of the file to download (in bytes), maximal time to download the file (in milliseconds) and number of milliseconds to download one byte using the regular internet tariff.
The second line contains a description of the first additional package. The line contains three integer numbers a1, t1 and p1 (1 β€ a1, t1, p1 β€ 107), where a1 is maximal sizes of downloaded data (in bytes), t1 is time to download one byte (in milliseconds), p1 is price of the package (in burles).
The third line contains a description of the second additional package. The line contains three integer numbers a2, t2 and p2 (1 β€ a2, t2, p2 β€ 107), where a2 is maximal sizes of downloaded data (in bytes), t2 is time to download one byte (in milliseconds), p2 is price of the package (in burles).
Polycarp can buy any package many times. Once package is bought it replaces the regular tariff until package data limit is completely used. While a package is in use Polycarp can't buy another package or switch back to the regular internet tariff.
Output
Print the minimum amount of money that Polycarp needs to pay to download B++ compiler no more than in T milliseconds. If there is no solution, print the only integer -1.
Examples
Input
120 964 20
26 8 8
13 10 4
Output
40
Input
10 200 20
1 1 1
2 2 3
Output
0
Input
8 81 11
4 10 16
3 10 12
Output
28
Input
8 79 11
4 10 16
3 10 12
Output
-1
Note
In the first example Polycarp has to buy the first additional package 5 times and do not buy the second additional package. He downloads 120 bytes (of total 26Β·5 = 130 bytes) in 120Β·8 = 960 milliseconds (960 β€ 964). He spends 8Β·5 = 40 burles on it.
In the second example Polycarp has enough time to download 10 bytes. It takes 10Β·20 = 200 milliseconds which equals to upper constraint on download time.
In the third example Polycarp has to buy one first additional package and one second additional package.
In the fourth example Polycarp has no way to download the file on time.
Submitted Solution:
```
f = 0
T = 0
t0 = 0
a1 = 0
t1 = 0
p1 = 0
a2 = 0
t2 = 0
p2 = 0
R = 0
def func(leftt, leftb, mid):
global f, T, t0, a1, t1, p1, a2, t2, p2, R
ft = 0
if (mid == R):
ft += (mid - 1) * a2;
keks = (leftt - (mid - 1) * a2 * t2) // t2
ft += keks;
else:
ft += (leftt - mid * a2 * t2) // t0
ft += mid * a2
return ft >= leftb
def keks(cnt):
global f, T, t0, a1, t1, p1, a2, t2, p2, R
ks = cnt * a1
if (ks * t1 >= T):
g = (cnt - 1) * a1 + (T - (cnt - 1) * t1 * a1) // t1
if (g >= f):
return cnt * p1
return 1e18
if (ks >= f):
return cnt * p1
leftt = T - ks * t1
leftb = f - ks
if (t2 < t0):
r = (leftt) // (a2 * t2) + 1
R = r
diff = leftb * t0 - leftt
sf = t0 - t2
keks = (diff * t2 + sf - 1) // sf
if (keks % a2 != 0):
keks+= a2 - keks % a2
keks //= a2
keks //= t2
ans = 1e18
for i in range(keks - 1, keks + 2):
l = i
if (l >= 0 and l <= r):
if (func(leftt, leftb, l)):
ans = min(ans, cnt * p1 + l * p2)
l = r;
if (func(leftt, leftb, l)):
ans = min(ans, cnt * p1 + l * p2)
return ans;
else:
if (func(leftt, leftb, 0)):
return cnt * p
return 1e18;
def main():
global f, T, t0, a1, t1, p1, a2, t2, p2, R
f, T, t0 = map(int, input().split())
a1, t1, p1 = map(int, input().split())
a2, t2, p2 = map(int, input().split())
ans = 1e18;
if (t0 * f <= T):
ans = 0;
print(ans)
return
ll = 0;
rr = T // (t1 * a1) + 1
for g in range(ll, rr + 1):
ans = min(ans, keks(g))
if (ans > 9e17):
print(-1)
return
print(ans)
main()
```
No
| 94,101 | [
0.402587890625,
0.0452880859375,
0.2103271484375,
0.30126953125,
-0.42333984375,
-0.067626953125,
-0.084228515625,
-0.035736083984375,
-0.21484375,
0.40478515625,
0.919921875,
-0.1380615234375,
0.4287109375,
-0.74609375,
-0.57763671875,
0.447021484375,
-0.328125,
-0.587890625,
-0... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus got an internship in one well-known social network. His test task is to count the number of unique users who have visited a social network during the day. Polycarpus was provided with information on all user requests for this time period. For each query, we know its time... and nothing else, because Polycarpus has already accidentally removed the user IDs corresponding to the requests from the database. Thus, it is now impossible to determine whether any two requests are made by the same person or by different people.
But wait, something is still known, because that day a record was achieved β M simultaneous users online! In addition, Polycarpus believes that if a user made a request at second s, then he was online for T seconds after that, that is, at seconds s, s + 1, s + 2, ..., s + T - 1. So, the user's time online can be calculated as the union of time intervals of the form [s, s + T - 1] over all times s of requests from him.
Guided by these thoughts, Polycarpus wants to assign a user ID to each request so that:
* the number of different users online did not exceed M at any moment,
* at some second the number of distinct users online reached value M,
* the total number of users (the number of distinct identifiers) was as much as possible.
Help Polycarpus cope with the test.
Input
The first line contains three integers n, M and T (1 β€ n, M β€ 20 000, 1 β€ T β€ 86400) β the number of queries, the record number of online users and the time when the user was online after a query was sent. Next n lines contain the times of the queries in the format "hh:mm:ss", where hh are hours, mm are minutes, ss are seconds. The times of the queries follow in the non-decreasing order, some of them can coincide. It is guaranteed that all the times and even all the segments of type [s, s + T - 1] are within one 24-hour range (from 00:00:00 to 23:59:59).
Output
In the first line print number R β the largest possible number of distinct users. The following n lines should contain the user IDs for requests in the same order in which the requests are given in the input. User IDs must be integers from 1 to R. The requests of the same user must correspond to the same identifiers, the requests of distinct users must correspond to distinct identifiers. If there are multiple solutions, print any of them. If there is no solution, print "No solution" (without the quotes).
Examples
Input
4 2 10
17:05:53
17:05:58
17:06:01
22:39:47
Output
3
1
2
2
3
Input
1 2 86400
00:00:00
Output
No solution
Note
Consider the first sample. The user who sent the first request was online from 17:05:53 to 17:06:02, the user who sent the second request was online from 17:05:58 to 17:06:07, the user who sent the third request, was online from 17:06:01 to 17:06:10. Thus, these IDs cannot belong to three distinct users, because in that case all these users would be online, for example, at 17:06:01. That is impossible, because M = 2. That means that some two of these queries belonged to the same user. One of the correct variants is given in the answer to the sample. For it user 1 was online from 17:05:53 to 17:06:02, user 2 β from 17:05:58 to 17:06:10 (he sent the second and third queries), user 3 β from 22:39:47 to 22:39:56.
In the second sample there is only one query. So, only one user visited the network within the 24-hour period and there couldn't be two users online on the network simultaneously. (The time the user spent online is the union of time intervals for requests, so users who didn't send requests could not be online in the network.)
Tags: greedy, two pointers
Correct Solution:
```
def main():
mode="filee"
if mode=="file":f=open("test.txt","r")
get = lambda :[int(x) for x in (f.readline() if mode=="file" else input()).split()]
gets = lambda :[str(x) for x in (f.readline()[:-1] if mode=="file" else input()).split(":")]
[n,m,t]=get()
[a,b]=[[0]*20002,[0]*20002]
if n<m:
print("No solution")
return
for i in range(1,n+1):
g = gets()
a[i] = int(g[-1]) + int(g[1])*60 + int(g[0])*3600
[p,count,sim,ist] = [1,0,0,False]
for i in range(1,n+1):
while p<i and a[i] - t + 1>a[p]:
p+=1
if b[p]!=b[p-1]:
sim = max(sim-1,0)
if a[i]<a[p]+t and sim<m:
[count,sim] = [count+1,sim+1]
if sim==m:
ist=True
b[i] = count
if ist==False:
print("No solution")
return
print(count)
for i in range(1,n+1):
print(b[i],end=' ')
if mode=="file":f.close()
if __name__=="__main__":
main()
```
| 94,800 | [
0.039764404296875,
0.343994140625,
-0.059661865234375,
0.409912109375,
-0.2220458984375,
-0.46630859375,
-0.4921875,
-0.070556640625,
0.806640625,
0.68359375,
0.488037109375,
-0.2099609375,
0.39111328125,
-0.61083984375,
-0.68212890625,
0.1378173828125,
-0.7939453125,
-0.4167480468... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus got an internship in one well-known social network. His test task is to count the number of unique users who have visited a social network during the day. Polycarpus was provided with information on all user requests for this time period. For each query, we know its time... and nothing else, because Polycarpus has already accidentally removed the user IDs corresponding to the requests from the database. Thus, it is now impossible to determine whether any two requests are made by the same person or by different people.
But wait, something is still known, because that day a record was achieved β M simultaneous users online! In addition, Polycarpus believes that if a user made a request at second s, then he was online for T seconds after that, that is, at seconds s, s + 1, s + 2, ..., s + T - 1. So, the user's time online can be calculated as the union of time intervals of the form [s, s + T - 1] over all times s of requests from him.
Guided by these thoughts, Polycarpus wants to assign a user ID to each request so that:
* the number of different users online did not exceed M at any moment,
* at some second the number of distinct users online reached value M,
* the total number of users (the number of distinct identifiers) was as much as possible.
Help Polycarpus cope with the test.
Input
The first line contains three integers n, M and T (1 β€ n, M β€ 20 000, 1 β€ T β€ 86400) β the number of queries, the record number of online users and the time when the user was online after a query was sent. Next n lines contain the times of the queries in the format "hh:mm:ss", where hh are hours, mm are minutes, ss are seconds. The times of the queries follow in the non-decreasing order, some of them can coincide. It is guaranteed that all the times and even all the segments of type [s, s + T - 1] are within one 24-hour range (from 00:00:00 to 23:59:59).
Output
In the first line print number R β the largest possible number of distinct users. The following n lines should contain the user IDs for requests in the same order in which the requests are given in the input. User IDs must be integers from 1 to R. The requests of the same user must correspond to the same identifiers, the requests of distinct users must correspond to distinct identifiers. If there are multiple solutions, print any of them. If there is no solution, print "No solution" (without the quotes).
Examples
Input
4 2 10
17:05:53
17:05:58
17:06:01
22:39:47
Output
3
1
2
2
3
Input
1 2 86400
00:00:00
Output
No solution
Note
Consider the first sample. The user who sent the first request was online from 17:05:53 to 17:06:02, the user who sent the second request was online from 17:05:58 to 17:06:07, the user who sent the third request, was online from 17:06:01 to 17:06:10. Thus, these IDs cannot belong to three distinct users, because in that case all these users would be online, for example, at 17:06:01. That is impossible, because M = 2. That means that some two of these queries belonged to the same user. One of the correct variants is given in the answer to the sample. For it user 1 was online from 17:05:53 to 17:06:02, user 2 β from 17:05:58 to 17:06:10 (he sent the second and third queries), user 3 β from 22:39:47 to 22:39:56.
In the second sample there is only one query. So, only one user visited the network within the 24-hour period and there couldn't be two users online on the network simultaneously. (The time the user spent online is the union of time intervals for requests, so users who didn't send requests could not be online in the network.)
Tags: greedy, two pointers
Correct Solution:
```
def main():
mode="filee"
if mode=="file":f=open("test.txt","r")
get = lambda :[int(x) for x in (f.readline() if mode=="file" else input()).split()]
gets = lambda :[str(x) for x in (f.readline()[:-1] if mode=="file" else input()).split(":")]
[n,m,t]=get()
a=[0]*20002
b=[0]*20002
if n<m:
print("No solution")
return
for i in range(1,1+n):
g = gets()
a[i] = int(g[-1]) + int(g[1])*60 + int(g[0])*3600
[p,count,sim] = [1,0,0]
is_solution_there=False
for i in range(1,n+1):
while p<i and a[i] - t + 1>a[p]:
p+=1
if b[p]!=b[p-1]:
sim = max(sim-1,0)
if a[i]<a[p]+t and sim<m:
count+=1
sim+=1
if sim==m:
is_solution_there=True
b[i] = count
if is_solution_there==False:
print("No solution")
return
print(count)
for i in range(1,n+1):
print(b[i],end=' ')
if mode=="file":f.close()
if __name__=="__main__":
main()
```
| 94,801 | [
0.039764404296875,
0.343994140625,
-0.059661865234375,
0.409912109375,
-0.2220458984375,
-0.46630859375,
-0.4921875,
-0.070556640625,
0.806640625,
0.68359375,
0.488037109375,
-0.2099609375,
0.39111328125,
-0.61083984375,
-0.68212890625,
0.1378173828125,
-0.7939453125,
-0.4167480468... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus got an internship in one well-known social network. His test task is to count the number of unique users who have visited a social network during the day. Polycarpus was provided with information on all user requests for this time period. For each query, we know its time... and nothing else, because Polycarpus has already accidentally removed the user IDs corresponding to the requests from the database. Thus, it is now impossible to determine whether any two requests are made by the same person or by different people.
But wait, something is still known, because that day a record was achieved β M simultaneous users online! In addition, Polycarpus believes that if a user made a request at second s, then he was online for T seconds after that, that is, at seconds s, s + 1, s + 2, ..., s + T - 1. So, the user's time online can be calculated as the union of time intervals of the form [s, s + T - 1] over all times s of requests from him.
Guided by these thoughts, Polycarpus wants to assign a user ID to each request so that:
* the number of different users online did not exceed M at any moment,
* at some second the number of distinct users online reached value M,
* the total number of users (the number of distinct identifiers) was as much as possible.
Help Polycarpus cope with the test.
Input
The first line contains three integers n, M and T (1 β€ n, M β€ 20 000, 1 β€ T β€ 86400) β the number of queries, the record number of online users and the time when the user was online after a query was sent. Next n lines contain the times of the queries in the format "hh:mm:ss", where hh are hours, mm are minutes, ss are seconds. The times of the queries follow in the non-decreasing order, some of them can coincide. It is guaranteed that all the times and even all the segments of type [s, s + T - 1] are within one 24-hour range (from 00:00:00 to 23:59:59).
Output
In the first line print number R β the largest possible number of distinct users. The following n lines should contain the user IDs for requests in the same order in which the requests are given in the input. User IDs must be integers from 1 to R. The requests of the same user must correspond to the same identifiers, the requests of distinct users must correspond to distinct identifiers. If there are multiple solutions, print any of them. If there is no solution, print "No solution" (without the quotes).
Examples
Input
4 2 10
17:05:53
17:05:58
17:06:01
22:39:47
Output
3
1
2
2
3
Input
1 2 86400
00:00:00
Output
No solution
Note
Consider the first sample. The user who sent the first request was online from 17:05:53 to 17:06:02, the user who sent the second request was online from 17:05:58 to 17:06:07, the user who sent the third request, was online from 17:06:01 to 17:06:10. Thus, these IDs cannot belong to three distinct users, because in that case all these users would be online, for example, at 17:06:01. That is impossible, because M = 2. That means that some two of these queries belonged to the same user. One of the correct variants is given in the answer to the sample. For it user 1 was online from 17:05:53 to 17:06:02, user 2 β from 17:05:58 to 17:06:10 (he sent the second and third queries), user 3 β from 22:39:47 to 22:39:56.
In the second sample there is only one query. So, only one user visited the network within the 24-hour period and there couldn't be two users online on the network simultaneously. (The time the user spent online is the union of time intervals for requests, so users who didn't send requests could not be online in the network.)
Submitted Solution:
```
def main():
mode="filee"
if mode=="file":f=open("test.txt","r")
get = lambda :[int(x) for x in (f.readline() if mode=="file" else input()).split()]
gets = lambda :[str(x) for x in (f.readline()[:-1] if mode=="file" else input()).split(":")]
[n,m,t]=get()
a=[0]*20002
b=[0]*20002
if n<m:
print("No solution")
return
for i in range(n):
g = gets()
temp = int(g[-1]) + int(g[1])*60 + int(g[0])*3600
a[i] = temp
[p,count,k,sim] = [0,0,0,0]
for i in range(n):
if a[p]<a[i] + t and sim<m:
count+=1
b[k] = count
sim+=1
else:
b[k] = count
p+=1
sim-=1
k+=1
print(count)
for i in range(20002):
if b[i] == 0:
break
print(b[i])
if mode=="file":f.close()
if __name__=="__main__":
main()
```
No
| 94,802 | [
0.1087646484375,
0.4248046875,
-0.0576171875,
0.423583984375,
-0.1578369140625,
-0.35693359375,
-0.5224609375,
0.02606201171875,
0.77880859375,
0.67578125,
0.413330078125,
-0.2147216796875,
0.378662109375,
-0.62744140625,
-0.7705078125,
0.08795166015625,
-0.83251953125,
-0.42016601... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus got an internship in one well-known social network. His test task is to count the number of unique users who have visited a social network during the day. Polycarpus was provided with information on all user requests for this time period. For each query, we know its time... and nothing else, because Polycarpus has already accidentally removed the user IDs corresponding to the requests from the database. Thus, it is now impossible to determine whether any two requests are made by the same person or by different people.
But wait, something is still known, because that day a record was achieved β M simultaneous users online! In addition, Polycarpus believes that if a user made a request at second s, then he was online for T seconds after that, that is, at seconds s, s + 1, s + 2, ..., s + T - 1. So, the user's time online can be calculated as the union of time intervals of the form [s, s + T - 1] over all times s of requests from him.
Guided by these thoughts, Polycarpus wants to assign a user ID to each request so that:
* the number of different users online did not exceed M at any moment,
* at some second the number of distinct users online reached value M,
* the total number of users (the number of distinct identifiers) was as much as possible.
Help Polycarpus cope with the test.
Input
The first line contains three integers n, M and T (1 β€ n, M β€ 20 000, 1 β€ T β€ 86400) β the number of queries, the record number of online users and the time when the user was online after a query was sent. Next n lines contain the times of the queries in the format "hh:mm:ss", where hh are hours, mm are minutes, ss are seconds. The times of the queries follow in the non-decreasing order, some of them can coincide. It is guaranteed that all the times and even all the segments of type [s, s + T - 1] are within one 24-hour range (from 00:00:00 to 23:59:59).
Output
In the first line print number R β the largest possible number of distinct users. The following n lines should contain the user IDs for requests in the same order in which the requests are given in the input. User IDs must be integers from 1 to R. The requests of the same user must correspond to the same identifiers, the requests of distinct users must correspond to distinct identifiers. If there are multiple solutions, print any of them. If there is no solution, print "No solution" (without the quotes).
Examples
Input
4 2 10
17:05:53
17:05:58
17:06:01
22:39:47
Output
3
1
2
2
3
Input
1 2 86400
00:00:00
Output
No solution
Note
Consider the first sample. The user who sent the first request was online from 17:05:53 to 17:06:02, the user who sent the second request was online from 17:05:58 to 17:06:07, the user who sent the third request, was online from 17:06:01 to 17:06:10. Thus, these IDs cannot belong to three distinct users, because in that case all these users would be online, for example, at 17:06:01. That is impossible, because M = 2. That means that some two of these queries belonged to the same user. One of the correct variants is given in the answer to the sample. For it user 1 was online from 17:05:53 to 17:06:02, user 2 β from 17:05:58 to 17:06:10 (he sent the second and third queries), user 3 β from 22:39:47 to 22:39:56.
In the second sample there is only one query. So, only one user visited the network within the 24-hour period and there couldn't be two users online on the network simultaneously. (The time the user spent online is the union of time intervals for requests, so users who didn't send requests could not be online in the network.)
Submitted Solution:
```
def main():
mode="filee"
if mode=="file":f=open("test.txt","r")
get = lambda :[int(x) for x in (f.readline() if mode=="file" else input()).split()]
gets = lambda :[str(x) for x in (f.readline()[:-1] if mode=="file" else input()).split(":")]
[n,m,t]=get()
a=[0]*20002
b=[0]*20002
if n<m:
print("No solution")
return
for i in range(n):
g = gets()
temp = int(g[-1]) + int(g[1])*60 + int(g[0])*3600
a[i] = temp
[p,count,k,sim] = [0,0,0,0]
for i in range(n):
while p<i and a[i] - t + 1>=a[p]:
p+=1
sim = min(sim,m,i-p+1)
#print(p,a[p],a[i],a[i] - a[p],sim,i-p)
if p==i or (a[i] - t +1<a[p] and sim<m):
count+=1
b[k] = count
sim+=1
else:
b[k] = count
k+=1
print(count)
for i in range(20002):
if b[i] == 0:
break
print(b[i])
if mode=="file":f.close()
if __name__=="__main__":
main()
```
No
| 94,803 | [
0.1087646484375,
0.4248046875,
-0.0576171875,
0.423583984375,
-0.1578369140625,
-0.35693359375,
-0.5224609375,
0.02606201171875,
0.77880859375,
0.67578125,
0.413330078125,
-0.2147216796875,
0.378662109375,
-0.62744140625,
-0.7705078125,
0.08795166015625,
-0.83251953125,
-0.42016601... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus got an internship in one well-known social network. His test task is to count the number of unique users who have visited a social network during the day. Polycarpus was provided with information on all user requests for this time period. For each query, we know its time... and nothing else, because Polycarpus has already accidentally removed the user IDs corresponding to the requests from the database. Thus, it is now impossible to determine whether any two requests are made by the same person or by different people.
But wait, something is still known, because that day a record was achieved β M simultaneous users online! In addition, Polycarpus believes that if a user made a request at second s, then he was online for T seconds after that, that is, at seconds s, s + 1, s + 2, ..., s + T - 1. So, the user's time online can be calculated as the union of time intervals of the form [s, s + T - 1] over all times s of requests from him.
Guided by these thoughts, Polycarpus wants to assign a user ID to each request so that:
* the number of different users online did not exceed M at any moment,
* at some second the number of distinct users online reached value M,
* the total number of users (the number of distinct identifiers) was as much as possible.
Help Polycarpus cope with the test.
Input
The first line contains three integers n, M and T (1 β€ n, M β€ 20 000, 1 β€ T β€ 86400) β the number of queries, the record number of online users and the time when the user was online after a query was sent. Next n lines contain the times of the queries in the format "hh:mm:ss", where hh are hours, mm are minutes, ss are seconds. The times of the queries follow in the non-decreasing order, some of them can coincide. It is guaranteed that all the times and even all the segments of type [s, s + T - 1] are within one 24-hour range (from 00:00:00 to 23:59:59).
Output
In the first line print number R β the largest possible number of distinct users. The following n lines should contain the user IDs for requests in the same order in which the requests are given in the input. User IDs must be integers from 1 to R. The requests of the same user must correspond to the same identifiers, the requests of distinct users must correspond to distinct identifiers. If there are multiple solutions, print any of them. If there is no solution, print "No solution" (without the quotes).
Examples
Input
4 2 10
17:05:53
17:05:58
17:06:01
22:39:47
Output
3
1
2
2
3
Input
1 2 86400
00:00:00
Output
No solution
Note
Consider the first sample. The user who sent the first request was online from 17:05:53 to 17:06:02, the user who sent the second request was online from 17:05:58 to 17:06:07, the user who sent the third request, was online from 17:06:01 to 17:06:10. Thus, these IDs cannot belong to three distinct users, because in that case all these users would be online, for example, at 17:06:01. That is impossible, because M = 2. That means that some two of these queries belonged to the same user. One of the correct variants is given in the answer to the sample. For it user 1 was online from 17:05:53 to 17:06:02, user 2 β from 17:05:58 to 17:06:10 (he sent the second and third queries), user 3 β from 22:39:47 to 22:39:56.
In the second sample there is only one query. So, only one user visited the network within the 24-hour period and there couldn't be two users online on the network simultaneously. (The time the user spent online is the union of time intervals for requests, so users who didn't send requests could not be online in the network.)
Submitted Solution:
```
def main():
mode="filee"
if mode=="file":f=open("test.txt","r")
get = lambda :[int(x) for x in (f.readline() if mode=="file" else input()).split()]
gets = lambda :[str(x) for x in (f.readline()[:-1] if mode=="file" else input()).split(":")]
[n,m,t]=get()
a=[0]*20002
b=[0]*20002
if n<m:
print("No solution")
return
for i in range(1,1+n):
g = gets()
temp = int(g[-1]) + int(g[1])*60 + int(g[0])*3600
a[i] = temp
[p,count,k,sim] = [1,0,0,0]
for i in range(1,n+1):
while p<i and a[i] - t + 1>=a[p]:
p+=1
if b[p]!=b[p-1]:
sim = max(sim-1,0)
#print(p,a[p],a[i],a[i] - a[p],sim,i-p)
if p==i or (a[i] - t +1<a[p] and sim<m):
count+=1
b[k] = count
sim+=1
else:
b[k] = count
k+=1
print(count)
for i in range(20002):
if b[i] == 0:
break
print(b[i])
if mode=="file":f.close()
if __name__=="__main__":
main()
```
No
| 94,804 | [
0.1087646484375,
0.4248046875,
-0.0576171875,
0.423583984375,
-0.1578369140625,
-0.35693359375,
-0.5224609375,
0.02606201171875,
0.77880859375,
0.67578125,
0.413330078125,
-0.2147216796875,
0.378662109375,
-0.62744140625,
-0.7705078125,
0.08795166015625,
-0.83251953125,
-0.42016601... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus got an internship in one well-known social network. His test task is to count the number of unique users who have visited a social network during the day. Polycarpus was provided with information on all user requests for this time period. For each query, we know its time... and nothing else, because Polycarpus has already accidentally removed the user IDs corresponding to the requests from the database. Thus, it is now impossible to determine whether any two requests are made by the same person or by different people.
But wait, something is still known, because that day a record was achieved β M simultaneous users online! In addition, Polycarpus believes that if a user made a request at second s, then he was online for T seconds after that, that is, at seconds s, s + 1, s + 2, ..., s + T - 1. So, the user's time online can be calculated as the union of time intervals of the form [s, s + T - 1] over all times s of requests from him.
Guided by these thoughts, Polycarpus wants to assign a user ID to each request so that:
* the number of different users online did not exceed M at any moment,
* at some second the number of distinct users online reached value M,
* the total number of users (the number of distinct identifiers) was as much as possible.
Help Polycarpus cope with the test.
Input
The first line contains three integers n, M and T (1 β€ n, M β€ 20 000, 1 β€ T β€ 86400) β the number of queries, the record number of online users and the time when the user was online after a query was sent. Next n lines contain the times of the queries in the format "hh:mm:ss", where hh are hours, mm are minutes, ss are seconds. The times of the queries follow in the non-decreasing order, some of them can coincide. It is guaranteed that all the times and even all the segments of type [s, s + T - 1] are within one 24-hour range (from 00:00:00 to 23:59:59).
Output
In the first line print number R β the largest possible number of distinct users. The following n lines should contain the user IDs for requests in the same order in which the requests are given in the input. User IDs must be integers from 1 to R. The requests of the same user must correspond to the same identifiers, the requests of distinct users must correspond to distinct identifiers. If there are multiple solutions, print any of them. If there is no solution, print "No solution" (without the quotes).
Examples
Input
4 2 10
17:05:53
17:05:58
17:06:01
22:39:47
Output
3
1
2
2
3
Input
1 2 86400
00:00:00
Output
No solution
Note
Consider the first sample. The user who sent the first request was online from 17:05:53 to 17:06:02, the user who sent the second request was online from 17:05:58 to 17:06:07, the user who sent the third request, was online from 17:06:01 to 17:06:10. Thus, these IDs cannot belong to three distinct users, because in that case all these users would be online, for example, at 17:06:01. That is impossible, because M = 2. That means that some two of these queries belonged to the same user. One of the correct variants is given in the answer to the sample. For it user 1 was online from 17:05:53 to 17:06:02, user 2 β from 17:05:58 to 17:06:10 (he sent the second and third queries), user 3 β from 22:39:47 to 22:39:56.
In the second sample there is only one query. So, only one user visited the network within the 24-hour period and there couldn't be two users online on the network simultaneously. (The time the user spent online is the union of time intervals for requests, so users who didn't send requests could not be online in the network.)
Submitted Solution:
```
def main():
mode="filee"
if mode=="file":f=open("test.txt","r")
get = lambda :[int(x) for x in (f.readline() if mode=="file" else input()).split()]
gets = lambda :[str(x) for x in (f.readline()[:-1] if mode=="file" else input()).split(":")]
[n,m,t]=get()
a=[0]*20002
b=[0]*20002
if n<m:
print("No solution")
return
for i in range(1,1+n):
g = gets()
temp = int(g[-1]) + int(g[1])*60 + int(g[0])*3600
a[i] = temp
#print(a[i])
[p,count,k,sim] = [1,0,1,0]
for i in range(1,n+1):
while p<i and a[i] - t + 1>=a[p]:
p+=1
#print("Dec",end=' ')
if b[p]!=b[p-1]:
#print("yes")
sim = max(sim-1,0)
#print(p,a[p],a[i],a[i] - a[p],sim,i-p)
if a[i]!=82126 and (i==p or (a[i] - t +1<a[p] and sim<m)):
count+=1
b[k] = count
sim+=1
else:
b[k] = count
k+=1
print(count)
for i in range(1,20002):
if b[i] == 0:
break
print(b[i],end=' ')
if mode=="file":f.close()
if __name__=="__main__":
main()
```
No
| 94,805 | [
0.1087646484375,
0.4248046875,
-0.0576171875,
0.423583984375,
-0.1578369140625,
-0.35693359375,
-0.5224609375,
0.02606201171875,
0.77880859375,
0.67578125,
0.413330078125,
-0.2147216796875,
0.378662109375,
-0.62744140625,
-0.7705078125,
0.08795166015625,
-0.83251953125,
-0.42016601... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus is a system administrator. There are two servers under his strict guidance β a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program results in two integers x and y (x + y = 10; x, y β₯ 0). These numbers mean that x packets successfully reached the corresponding server through the network and y packets were lost.
Today Polycarpus has performed overall n ping commands during his workday. Now for each server Polycarpus wants to know whether the server is "alive" or not. Polycarpus thinks that the server is "alive", if at least half of the packets that we send to this server reached it successfully along the network.
Help Polycarpus, determine for each server, whether it is "alive" or not by the given commands and their results.
Input
The first line contains a single integer n (2 β€ n β€ 1000) β the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers β the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 β€ ti β€ 2; xi, yi β₯ 0; xi + yi = 10). If ti = 1, then the i-th command is "ping a", otherwise the i-th command is "ping b". Numbers xi, yi represent the result of executing this command, that is, xi packets reached the corresponding server successfully and yi packets were lost.
It is guaranteed that the input has at least one "ping a" command and at least one "ping b" command.
Output
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes).
In the second line print the state of server b in the similar format.
Examples
Input
2
1 5 5
2 6 4
Output
LIVE
LIVE
Input
3
1 0 10
2 0 10
1 10 0
Output
LIVE
DEAD
Note
Consider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network.
Consider the second test case. There were overall 20 packages sent to server a, 10 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall 10 packets were sent to server b, 0 of them reached it. Therefore, less than half of all packets sent to this server successfully reached it through the network.
Tags: implementation
Correct Solution:
```
n=int(input())
a=[[0, 0], [0, 0]]
b=[]
for i in range(n):
b=input().split()
a[int(b[0])-1][0]+=int(b[1])
a[int(b[0])-1][1]+=int(b[2])
if a[0][0]>=a[0][1]:
print("LIVE")
else:
print("DEAD")
if a[1][0]>=a[1][1]:
print("LIVE")
else:
print("DEAD")
```
| 95,557 | [
0.1690673828125,
0.0140533447265625,
-0.2073974609375,
0.4130859375,
-0.45849609375,
-0.1885986328125,
-0.433837890625,
0.11907958984375,
0.50048828125,
0.7470703125,
0.54541015625,
0.049652099609375,
0.192626953125,
-0.58935546875,
-0.57080078125,
0.06396484375,
-0.548828125,
-0.3... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus is a system administrator. There are two servers under his strict guidance β a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program results in two integers x and y (x + y = 10; x, y β₯ 0). These numbers mean that x packets successfully reached the corresponding server through the network and y packets were lost.
Today Polycarpus has performed overall n ping commands during his workday. Now for each server Polycarpus wants to know whether the server is "alive" or not. Polycarpus thinks that the server is "alive", if at least half of the packets that we send to this server reached it successfully along the network.
Help Polycarpus, determine for each server, whether it is "alive" or not by the given commands and their results.
Input
The first line contains a single integer n (2 β€ n β€ 1000) β the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers β the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 β€ ti β€ 2; xi, yi β₯ 0; xi + yi = 10). If ti = 1, then the i-th command is "ping a", otherwise the i-th command is "ping b". Numbers xi, yi represent the result of executing this command, that is, xi packets reached the corresponding server successfully and yi packets were lost.
It is guaranteed that the input has at least one "ping a" command and at least one "ping b" command.
Output
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes).
In the second line print the state of server b in the similar format.
Examples
Input
2
1 5 5
2 6 4
Output
LIVE
LIVE
Input
3
1 0 10
2 0 10
1 10 0
Output
LIVE
DEAD
Note
Consider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network.
Consider the second test case. There were overall 20 packages sent to server a, 10 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall 10 packets were sent to server b, 0 of them reached it. Therefore, less than half of all packets sent to this server successfully reached it through the network.
Tags: implementation
Correct Solution:
```
n=int(input())
a=[0]*n
for i in range(n):
a[i] = [0]*3
a[i]=input().split()
a1 = a2 = b1 = b2 = 0
for i in range(n):
if (a[i][0]=='1'):
a1+=int(a[i][1])
a2+=int(a[i][2])
if (a[i][0]=='2'):
b1+=int(a[i][1])
b2+=int(a[i][2])
if (a1>=a2):
print("LIVE")
else:
print("DEAD")
if (b1>=b2):
print("LIVE")
else:
print("DEAD")
```
| 95,558 | [
0.1690673828125,
0.0140533447265625,
-0.2073974609375,
0.4130859375,
-0.45849609375,
-0.1885986328125,
-0.433837890625,
0.11907958984375,
0.50048828125,
0.7470703125,
0.54541015625,
0.049652099609375,
0.192626953125,
-0.58935546875,
-0.57080078125,
0.06396484375,
-0.548828125,
-0.3... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus is a system administrator. There are two servers under his strict guidance β a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program results in two integers x and y (x + y = 10; x, y β₯ 0). These numbers mean that x packets successfully reached the corresponding server through the network and y packets were lost.
Today Polycarpus has performed overall n ping commands during his workday. Now for each server Polycarpus wants to know whether the server is "alive" or not. Polycarpus thinks that the server is "alive", if at least half of the packets that we send to this server reached it successfully along the network.
Help Polycarpus, determine for each server, whether it is "alive" or not by the given commands and their results.
Input
The first line contains a single integer n (2 β€ n β€ 1000) β the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers β the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 β€ ti β€ 2; xi, yi β₯ 0; xi + yi = 10). If ti = 1, then the i-th command is "ping a", otherwise the i-th command is "ping b". Numbers xi, yi represent the result of executing this command, that is, xi packets reached the corresponding server successfully and yi packets were lost.
It is guaranteed that the input has at least one "ping a" command and at least one "ping b" command.
Output
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes).
In the second line print the state of server b in the similar format.
Examples
Input
2
1 5 5
2 6 4
Output
LIVE
LIVE
Input
3
1 0 10
2 0 10
1 10 0
Output
LIVE
DEAD
Note
Consider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network.
Consider the second test case. There were overall 20 packages sent to server a, 10 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall 10 packets were sent to server b, 0 of them reached it. Therefore, less than half of all packets sent to this server successfully reached it through the network.
Tags: implementation
Correct Solution:
```
n=int(input())
pinga=pingb=sum1=sum2=0
for i in range(n):
t,x,y=map(int,input().split())
if t==1:
pinga+=1
sum1+=x
elif t==2:
pingb+=1
sum2+=x
if sum1>=(pinga*10)//2:
print("LIVE")
else:
print("DEAD")
if sum2>=(pingb*10)//2:
print("LIVE")
else:
print("DEAD")
```
| 95,559 | [
0.1690673828125,
0.0140533447265625,
-0.2073974609375,
0.4130859375,
-0.45849609375,
-0.1885986328125,
-0.433837890625,
0.11907958984375,
0.50048828125,
0.7470703125,
0.54541015625,
0.049652099609375,
0.192626953125,
-0.58935546875,
-0.57080078125,
0.06396484375,
-0.548828125,
-0.3... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus is a system administrator. There are two servers under his strict guidance β a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program results in two integers x and y (x + y = 10; x, y β₯ 0). These numbers mean that x packets successfully reached the corresponding server through the network and y packets were lost.
Today Polycarpus has performed overall n ping commands during his workday. Now for each server Polycarpus wants to know whether the server is "alive" or not. Polycarpus thinks that the server is "alive", if at least half of the packets that we send to this server reached it successfully along the network.
Help Polycarpus, determine for each server, whether it is "alive" or not by the given commands and their results.
Input
The first line contains a single integer n (2 β€ n β€ 1000) β the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers β the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 β€ ti β€ 2; xi, yi β₯ 0; xi + yi = 10). If ti = 1, then the i-th command is "ping a", otherwise the i-th command is "ping b". Numbers xi, yi represent the result of executing this command, that is, xi packets reached the corresponding server successfully and yi packets were lost.
It is guaranteed that the input has at least one "ping a" command and at least one "ping b" command.
Output
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes).
In the second line print the state of server b in the similar format.
Examples
Input
2
1 5 5
2 6 4
Output
LIVE
LIVE
Input
3
1 0 10
2 0 10
1 10 0
Output
LIVE
DEAD
Note
Consider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network.
Consider the second test case. There were overall 20 packages sent to server a, 10 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall 10 packets were sent to server b, 0 of them reached it. Therefore, less than half of all packets sent to this server successfully reached it through the network.
Tags: implementation
Correct Solution:
```
T = int(input())
a_x,b_y = 0,0
A_x,B_y = 0,0
for i in range(T):
t,x,y = map(int,input().split())
if t == 1:
a_x += x
b_y += y
else:
A_x += x
B_y += y
if a_x >= b_y:
print('LIVE')
else:
print('DEAD')
if A_x > B_y:
print('LIVE')
else:
print('DEAD')
```
| 95,560 | [
0.1690673828125,
0.0140533447265625,
-0.2073974609375,
0.4130859375,
-0.45849609375,
-0.1885986328125,
-0.433837890625,
0.11907958984375,
0.50048828125,
0.7470703125,
0.54541015625,
0.049652099609375,
0.192626953125,
-0.58935546875,
-0.57080078125,
0.06396484375,
-0.548828125,
-0.3... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus is a system administrator. There are two servers under his strict guidance β a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program results in two integers x and y (x + y = 10; x, y β₯ 0). These numbers mean that x packets successfully reached the corresponding server through the network and y packets were lost.
Today Polycarpus has performed overall n ping commands during his workday. Now for each server Polycarpus wants to know whether the server is "alive" or not. Polycarpus thinks that the server is "alive", if at least half of the packets that we send to this server reached it successfully along the network.
Help Polycarpus, determine for each server, whether it is "alive" or not by the given commands and their results.
Input
The first line contains a single integer n (2 β€ n β€ 1000) β the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers β the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 β€ ti β€ 2; xi, yi β₯ 0; xi + yi = 10). If ti = 1, then the i-th command is "ping a", otherwise the i-th command is "ping b". Numbers xi, yi represent the result of executing this command, that is, xi packets reached the corresponding server successfully and yi packets were lost.
It is guaranteed that the input has at least one "ping a" command and at least one "ping b" command.
Output
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes).
In the second line print the state of server b in the similar format.
Examples
Input
2
1 5 5
2 6 4
Output
LIVE
LIVE
Input
3
1 0 10
2 0 10
1 10 0
Output
LIVE
DEAD
Note
Consider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network.
Consider the second test case. There were overall 20 packages sent to server a, 10 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall 10 packets were sent to server b, 0 of them reached it. Therefore, less than half of all packets sent to this server successfully reached it through the network.
Tags: implementation
Correct Solution:
```
n=int(input())
a=0
a1=0
b=0
b1=0
for i in range(n):
t,x,y=map(int,input().split())
if t==1:
a+=x
a1+=y
else:
b+=x
b1+=y
if a>=a1:
print('LIVE')
else:
print('DEAD')
if b>=b1:
print('LIVE')
else:
print('DEAD')
```
| 95,561 | [
0.1690673828125,
0.0140533447265625,
-0.2073974609375,
0.4130859375,
-0.45849609375,
-0.1885986328125,
-0.433837890625,
0.11907958984375,
0.50048828125,
0.7470703125,
0.54541015625,
0.049652099609375,
0.192626953125,
-0.58935546875,
-0.57080078125,
0.06396484375,
-0.548828125,
-0.3... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus is a system administrator. There are two servers under his strict guidance β a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program results in two integers x and y (x + y = 10; x, y β₯ 0). These numbers mean that x packets successfully reached the corresponding server through the network and y packets were lost.
Today Polycarpus has performed overall n ping commands during his workday. Now for each server Polycarpus wants to know whether the server is "alive" or not. Polycarpus thinks that the server is "alive", if at least half of the packets that we send to this server reached it successfully along the network.
Help Polycarpus, determine for each server, whether it is "alive" or not by the given commands and their results.
Input
The first line contains a single integer n (2 β€ n β€ 1000) β the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers β the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 β€ ti β€ 2; xi, yi β₯ 0; xi + yi = 10). If ti = 1, then the i-th command is "ping a", otherwise the i-th command is "ping b". Numbers xi, yi represent the result of executing this command, that is, xi packets reached the corresponding server successfully and yi packets were lost.
It is guaranteed that the input has at least one "ping a" command and at least one "ping b" command.
Output
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes).
In the second line print the state of server b in the similar format.
Examples
Input
2
1 5 5
2 6 4
Output
LIVE
LIVE
Input
3
1 0 10
2 0 10
1 10 0
Output
LIVE
DEAD
Note
Consider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network.
Consider the second test case. There were overall 20 packages sent to server a, 10 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall 10 packets were sent to server b, 0 of them reached it. Therefore, less than half of all packets sent to this server successfully reached it through the network.
Tags: implementation
Correct Solution:
```
n = int(input())
x1, y1, x2, y2 = 0, 0, 0, 0
for _ in range(n):
a = list(map(int, input().split()))
if a[0] == 1:
x1 = x1+a[1]
y1 = y1+a[2]
else:
x2 = x2+a[1]
y2 = y2+a[2]
if x1>=y1:
print("LIVE")
else:
print("DEAD")
if x2>=y2:
print("LIVE")
else:
print("DEAD")
```
| 95,562 | [
0.1690673828125,
0.0140533447265625,
-0.2073974609375,
0.4130859375,
-0.45849609375,
-0.1885986328125,
-0.433837890625,
0.11907958984375,
0.50048828125,
0.7470703125,
0.54541015625,
0.049652099609375,
0.192626953125,
-0.58935546875,
-0.57080078125,
0.06396484375,
-0.548828125,
-0.3... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus is a system administrator. There are two servers under his strict guidance β a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program results in two integers x and y (x + y = 10; x, y β₯ 0). These numbers mean that x packets successfully reached the corresponding server through the network and y packets were lost.
Today Polycarpus has performed overall n ping commands during his workday. Now for each server Polycarpus wants to know whether the server is "alive" or not. Polycarpus thinks that the server is "alive", if at least half of the packets that we send to this server reached it successfully along the network.
Help Polycarpus, determine for each server, whether it is "alive" or not by the given commands and their results.
Input
The first line contains a single integer n (2 β€ n β€ 1000) β the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers β the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 β€ ti β€ 2; xi, yi β₯ 0; xi + yi = 10). If ti = 1, then the i-th command is "ping a", otherwise the i-th command is "ping b". Numbers xi, yi represent the result of executing this command, that is, xi packets reached the corresponding server successfully and yi packets were lost.
It is guaranteed that the input has at least one "ping a" command and at least one "ping b" command.
Output
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes).
In the second line print the state of server b in the similar format.
Examples
Input
2
1 5 5
2 6 4
Output
LIVE
LIVE
Input
3
1 0 10
2 0 10
1 10 0
Output
LIVE
DEAD
Note
Consider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network.
Consider the second test case. There were overall 20 packages sent to server a, 10 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall 10 packets were sent to server b, 0 of them reached it. Therefore, less than half of all packets sent to this server successfully reached it through the network.
Tags: implementation
Correct Solution:
```
n=int(input())
sum1=0
sum2=0
z=0
c=0
for i in range(n):
t,x,y=map(int,input().split())
if t==1:
sum1+=x
z+=1
if t==2:
sum2+=x
c+=1
if sum1>=int(5*z):
print("LIVE")
else:
print("DEAD")
if sum2>=int(5*c):
print("LIVE")
else:
print("DEAD")
```
| 95,563 | [
0.1690673828125,
0.0140533447265625,
-0.2073974609375,
0.4130859375,
-0.45849609375,
-0.1885986328125,
-0.433837890625,
0.11907958984375,
0.50048828125,
0.7470703125,
0.54541015625,
0.049652099609375,
0.192626953125,
-0.58935546875,
-0.57080078125,
0.06396484375,
-0.548828125,
-0.3... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus is a system administrator. There are two servers under his strict guidance β a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program results in two integers x and y (x + y = 10; x, y β₯ 0). These numbers mean that x packets successfully reached the corresponding server through the network and y packets were lost.
Today Polycarpus has performed overall n ping commands during his workday. Now for each server Polycarpus wants to know whether the server is "alive" or not. Polycarpus thinks that the server is "alive", if at least half of the packets that we send to this server reached it successfully along the network.
Help Polycarpus, determine for each server, whether it is "alive" or not by the given commands and their results.
Input
The first line contains a single integer n (2 β€ n β€ 1000) β the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers β the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 β€ ti β€ 2; xi, yi β₯ 0; xi + yi = 10). If ti = 1, then the i-th command is "ping a", otherwise the i-th command is "ping b". Numbers xi, yi represent the result of executing this command, that is, xi packets reached the corresponding server successfully and yi packets were lost.
It is guaranteed that the input has at least one "ping a" command and at least one "ping b" command.
Output
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes).
In the second line print the state of server b in the similar format.
Examples
Input
2
1 5 5
2 6 4
Output
LIVE
LIVE
Input
3
1 0 10
2 0 10
1 10 0
Output
LIVE
DEAD
Note
Consider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network.
Consider the second test case. There were overall 20 packages sent to server a, 10 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall 10 packets were sent to server b, 0 of them reached it. Therefore, less than half of all packets sent to this server successfully reached it through the network.
Tags: implementation
Correct Solution:
```
x=int(input())
a,b,c,d=0,0,0,0
for i in range(x):
t,x,y=map(int,input().split())
if t==1:
a+=1
b+=x
if t==2:
c+=1
d+=x
if b>=a*5:
print('LIVE')
else:
print('DEAD')
if d>=c*5:
print('LIVE')
else:
print('DEAD')
```
| 95,564 | [
0.1690673828125,
0.0140533447265625,
-0.2073974609375,
0.4130859375,
-0.45849609375,
-0.1885986328125,
-0.433837890625,
0.11907958984375,
0.50048828125,
0.7470703125,
0.54541015625,
0.049652099609375,
0.192626953125,
-0.58935546875,
-0.57080078125,
0.06396484375,
-0.548828125,
-0.3... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus is a system administrator. There are two servers under his strict guidance β a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program results in two integers x and y (x + y = 10; x, y β₯ 0). These numbers mean that x packets successfully reached the corresponding server through the network and y packets were lost.
Today Polycarpus has performed overall n ping commands during his workday. Now for each server Polycarpus wants to know whether the server is "alive" or not. Polycarpus thinks that the server is "alive", if at least half of the packets that we send to this server reached it successfully along the network.
Help Polycarpus, determine for each server, whether it is "alive" or not by the given commands and their results.
Input
The first line contains a single integer n (2 β€ n β€ 1000) β the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers β the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 β€ ti β€ 2; xi, yi β₯ 0; xi + yi = 10). If ti = 1, then the i-th command is "ping a", otherwise the i-th command is "ping b". Numbers xi, yi represent the result of executing this command, that is, xi packets reached the corresponding server successfully and yi packets were lost.
It is guaranteed that the input has at least one "ping a" command and at least one "ping b" command.
Output
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes).
In the second line print the state of server b in the similar format.
Examples
Input
2
1 5 5
2 6 4
Output
LIVE
LIVE
Input
3
1 0 10
2 0 10
1 10 0
Output
LIVE
DEAD
Note
Consider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network.
Consider the second test case. There were overall 20 packages sent to server a, 10 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall 10 packets were sent to server b, 0 of them reached it. Therefore, less than half of all packets sent to this server successfully reached it through the network.
Submitted Solution:
```
n = int(input())
s = [[0, 0], [0, 0]]
for i in range(n):
x = [int(s) for s in input().split(' ')]
s[x[0] - 1][0] += x[1]
s[x[0] - 1][1] += x[2]
for server in s:
if server[0] >= server[1]:
print('LIVE')
else:
print('DEAD')
```
Yes
| 95,565 | [
0.2017822265625,
0.07281494140625,
-0.2371826171875,
0.37255859375,
-0.5390625,
-0.1475830078125,
-0.453125,
0.1864013671875,
0.429443359375,
0.7568359375,
0.51025390625,
0.08050537109375,
0.189697265625,
-0.55029296875,
-0.54443359375,
0.004123687744140625,
-0.53271484375,
-0.2912... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus is a system administrator. There are two servers under his strict guidance β a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program results in two integers x and y (x + y = 10; x, y β₯ 0). These numbers mean that x packets successfully reached the corresponding server through the network and y packets were lost.
Today Polycarpus has performed overall n ping commands during his workday. Now for each server Polycarpus wants to know whether the server is "alive" or not. Polycarpus thinks that the server is "alive", if at least half of the packets that we send to this server reached it successfully along the network.
Help Polycarpus, determine for each server, whether it is "alive" or not by the given commands and their results.
Input
The first line contains a single integer n (2 β€ n β€ 1000) β the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers β the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 β€ ti β€ 2; xi, yi β₯ 0; xi + yi = 10). If ti = 1, then the i-th command is "ping a", otherwise the i-th command is "ping b". Numbers xi, yi represent the result of executing this command, that is, xi packets reached the corresponding server successfully and yi packets were lost.
It is guaranteed that the input has at least one "ping a" command and at least one "ping b" command.
Output
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes).
In the second line print the state of server b in the similar format.
Examples
Input
2
1 5 5
2 6 4
Output
LIVE
LIVE
Input
3
1 0 10
2 0 10
1 10 0
Output
LIVE
DEAD
Note
Consider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network.
Consider the second test case. There were overall 20 packages sent to server a, 10 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall 10 packets were sent to server b, 0 of them reached it. Therefore, less than half of all packets sent to this server successfully reached it through the network.
Submitted Solution:
```
n = int(input())
live_a = 0
dead_a = 0
live_b = 0
dead_b = 0
status_a = False
status_b = False
for i in range(n):
x = list(map(int, input().split()))
if x[0] == 1:
live_a += x[1]
dead_a += x[2]
else:
live_b += x[1]
dead_b += x[2]
if live_a >= dead_a:
status_a = True
if live_b >= dead_b:
status_b = True
print("LIVE" if status_a == True else "DEAD")
print("LIVE" if status_b == True else "DEAD")
```
Yes
| 95,566 | [
0.2017822265625,
0.07281494140625,
-0.2371826171875,
0.37255859375,
-0.5390625,
-0.1475830078125,
-0.453125,
0.1864013671875,
0.429443359375,
0.7568359375,
0.51025390625,
0.08050537109375,
0.189697265625,
-0.55029296875,
-0.54443359375,
0.004123687744140625,
-0.53271484375,
-0.2912... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus is a system administrator. There are two servers under his strict guidance β a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program results in two integers x and y (x + y = 10; x, y β₯ 0). These numbers mean that x packets successfully reached the corresponding server through the network and y packets were lost.
Today Polycarpus has performed overall n ping commands during his workday. Now for each server Polycarpus wants to know whether the server is "alive" or not. Polycarpus thinks that the server is "alive", if at least half of the packets that we send to this server reached it successfully along the network.
Help Polycarpus, determine for each server, whether it is "alive" or not by the given commands and their results.
Input
The first line contains a single integer n (2 β€ n β€ 1000) β the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers β the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 β€ ti β€ 2; xi, yi β₯ 0; xi + yi = 10). If ti = 1, then the i-th command is "ping a", otherwise the i-th command is "ping b". Numbers xi, yi represent the result of executing this command, that is, xi packets reached the corresponding server successfully and yi packets were lost.
It is guaranteed that the input has at least one "ping a" command and at least one "ping b" command.
Output
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes).
In the second line print the state of server b in the similar format.
Examples
Input
2
1 5 5
2 6 4
Output
LIVE
LIVE
Input
3
1 0 10
2 0 10
1 10 0
Output
LIVE
DEAD
Note
Consider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network.
Consider the second test case. There were overall 20 packages sent to server a, 10 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall 10 packets were sent to server b, 0 of them reached it. Therefore, less than half of all packets sent to this server successfully reached it through the network.
Submitted Solution:
```
import math
t = int(input())
sum1 = 0
sum2 = 0
s1 = 0
s2 = 0
for i in range(t):
s, x, y = input().split()
if int(s) == 1:
sum1 += int(x)
s1 += 1
else:
sum2 += int(x)
s2 += 1
if sum1 >= s1*5:
print("LIVE")
else:
print("DEAD")
if sum2 >= s2*5:
print("LIVE")
else:
print("DEAD")
```
Yes
| 95,567 | [
0.2017822265625,
0.07281494140625,
-0.2371826171875,
0.37255859375,
-0.5390625,
-0.1475830078125,
-0.453125,
0.1864013671875,
0.429443359375,
0.7568359375,
0.51025390625,
0.08050537109375,
0.189697265625,
-0.55029296875,
-0.54443359375,
0.004123687744140625,
-0.53271484375,
-0.2912... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus is a system administrator. There are two servers under his strict guidance β a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program results in two integers x and y (x + y = 10; x, y β₯ 0). These numbers mean that x packets successfully reached the corresponding server through the network and y packets were lost.
Today Polycarpus has performed overall n ping commands during his workday. Now for each server Polycarpus wants to know whether the server is "alive" or not. Polycarpus thinks that the server is "alive", if at least half of the packets that we send to this server reached it successfully along the network.
Help Polycarpus, determine for each server, whether it is "alive" or not by the given commands and their results.
Input
The first line contains a single integer n (2 β€ n β€ 1000) β the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers β the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 β€ ti β€ 2; xi, yi β₯ 0; xi + yi = 10). If ti = 1, then the i-th command is "ping a", otherwise the i-th command is "ping b". Numbers xi, yi represent the result of executing this command, that is, xi packets reached the corresponding server successfully and yi packets were lost.
It is guaranteed that the input has at least one "ping a" command and at least one "ping b" command.
Output
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes).
In the second line print the state of server b in the similar format.
Examples
Input
2
1 5 5
2 6 4
Output
LIVE
LIVE
Input
3
1 0 10
2 0 10
1 10 0
Output
LIVE
DEAD
Note
Consider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network.
Consider the second test case. There were overall 20 packages sent to server a, 10 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall 10 packets were sent to server b, 0 of them reached it. Therefore, less than half of all packets sent to this server successfully reached it through the network.
Submitted Solution:
```
x = int(input())
y = []
k = 0
l = 0
s = 0
s1 = 0
for i in range(x):
y.append(list(map(int,input().split())))
for i in range(x):
if y[i][0] == 1:
t = y[i][1]
s = s + t
k = k + 1
if y[i][0] == 2:
g = y[i][1]
s1 = s1 + g
l = l + 1
if s>=5*k:
print("LIVE")
if s<5*k:
print("DEAD")
if s1>=5*l:
print("LIVE")
if s1<5*l:
print("DEAD")
```
Yes
| 95,568 | [
0.2017822265625,
0.07281494140625,
-0.2371826171875,
0.37255859375,
-0.5390625,
-0.1475830078125,
-0.453125,
0.1864013671875,
0.429443359375,
0.7568359375,
0.51025390625,
0.08050537109375,
0.189697265625,
-0.55029296875,
-0.54443359375,
0.004123687744140625,
-0.53271484375,
-0.2912... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus is a system administrator. There are two servers under his strict guidance β a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program results in two integers x and y (x + y = 10; x, y β₯ 0). These numbers mean that x packets successfully reached the corresponding server through the network and y packets were lost.
Today Polycarpus has performed overall n ping commands during his workday. Now for each server Polycarpus wants to know whether the server is "alive" or not. Polycarpus thinks that the server is "alive", if at least half of the packets that we send to this server reached it successfully along the network.
Help Polycarpus, determine for each server, whether it is "alive" or not by the given commands and their results.
Input
The first line contains a single integer n (2 β€ n β€ 1000) β the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers β the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 β€ ti β€ 2; xi, yi β₯ 0; xi + yi = 10). If ti = 1, then the i-th command is "ping a", otherwise the i-th command is "ping b". Numbers xi, yi represent the result of executing this command, that is, xi packets reached the corresponding server successfully and yi packets were lost.
It is guaranteed that the input has at least one "ping a" command and at least one "ping b" command.
Output
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes).
In the second line print the state of server b in the similar format.
Examples
Input
2
1 5 5
2 6 4
Output
LIVE
LIVE
Input
3
1 0 10
2 0 10
1 10 0
Output
LIVE
DEAD
Note
Consider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network.
Consider the second test case. There were overall 20 packages sent to server a, 10 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall 10 packets were sent to server b, 0 of them reached it. Therefore, less than half of all packets sent to this server successfully reached it through the network.
Submitted Solution:
```
n = int(input())
at, bt, al, bl = 0, 0, 0, 0
for _ in range(n):
t, x, y = map(int,input().split())
if t == 1:
at += x
al += y
if t == 2:
bt += x
bl += y
if at>=int((al+at)/2):
print("LIVE")
else:
print("DEAD")
if bt >= int((al+at)/2):
print("LIVE")
else:
print("DEAD")
```
No
| 95,569 | [
0.2017822265625,
0.07281494140625,
-0.2371826171875,
0.37255859375,
-0.5390625,
-0.1475830078125,
-0.453125,
0.1864013671875,
0.429443359375,
0.7568359375,
0.51025390625,
0.08050537109375,
0.189697265625,
-0.55029296875,
-0.54443359375,
0.004123687744140625,
-0.53271484375,
-0.2912... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus is a system administrator. There are two servers under his strict guidance β a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program results in two integers x and y (x + y = 10; x, y β₯ 0). These numbers mean that x packets successfully reached the corresponding server through the network and y packets were lost.
Today Polycarpus has performed overall n ping commands during his workday. Now for each server Polycarpus wants to know whether the server is "alive" or not. Polycarpus thinks that the server is "alive", if at least half of the packets that we send to this server reached it successfully along the network.
Help Polycarpus, determine for each server, whether it is "alive" or not by the given commands and their results.
Input
The first line contains a single integer n (2 β€ n β€ 1000) β the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers β the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 β€ ti β€ 2; xi, yi β₯ 0; xi + yi = 10). If ti = 1, then the i-th command is "ping a", otherwise the i-th command is "ping b". Numbers xi, yi represent the result of executing this command, that is, xi packets reached the corresponding server successfully and yi packets were lost.
It is guaranteed that the input has at least one "ping a" command and at least one "ping b" command.
Output
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes).
In the second line print the state of server b in the similar format.
Examples
Input
2
1 5 5
2 6 4
Output
LIVE
LIVE
Input
3
1 0 10
2 0 10
1 10 0
Output
LIVE
DEAD
Note
Consider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network.
Consider the second test case. There were overall 20 packages sent to server a, 10 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall 10 packets were sent to server b, 0 of them reached it. Therefore, less than half of all packets sent to this server successfully reached it through the network.
Submitted Solution:
```
n = int(input())
at, bt, al, bl = 0, 0, 0, 0
for _ in range(n):
t, x, y = map(int,input().split())
if t == 1:
at += x
al += y
if t == 2:
bt += x
bl += y
if at>=int(al/2):
print("LIVE")
else:
print("DEAD")
if bt >= int(bl/2):
print("LIVE")
else:
print("DEAD")
```
No
| 95,570 | [
0.2017822265625,
0.07281494140625,
-0.2371826171875,
0.37255859375,
-0.5390625,
-0.1475830078125,
-0.453125,
0.1864013671875,
0.429443359375,
0.7568359375,
0.51025390625,
0.08050537109375,
0.189697265625,
-0.55029296875,
-0.54443359375,
0.004123687744140625,
-0.53271484375,
-0.2912... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus is a system administrator. There are two servers under his strict guidance β a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program results in two integers x and y (x + y = 10; x, y β₯ 0). These numbers mean that x packets successfully reached the corresponding server through the network and y packets were lost.
Today Polycarpus has performed overall n ping commands during his workday. Now for each server Polycarpus wants to know whether the server is "alive" or not. Polycarpus thinks that the server is "alive", if at least half of the packets that we send to this server reached it successfully along the network.
Help Polycarpus, determine for each server, whether it is "alive" or not by the given commands and their results.
Input
The first line contains a single integer n (2 β€ n β€ 1000) β the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers β the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 β€ ti β€ 2; xi, yi β₯ 0; xi + yi = 10). If ti = 1, then the i-th command is "ping a", otherwise the i-th command is "ping b". Numbers xi, yi represent the result of executing this command, that is, xi packets reached the corresponding server successfully and yi packets were lost.
It is guaranteed that the input has at least one "ping a" command and at least one "ping b" command.
Output
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes).
In the second line print the state of server b in the similar format.
Examples
Input
2
1 5 5
2 6 4
Output
LIVE
LIVE
Input
3
1 0 10
2 0 10
1 10 0
Output
LIVE
DEAD
Note
Consider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network.
Consider the second test case. There were overall 20 packages sent to server a, 10 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall 10 packets were sent to server b, 0 of them reached it. Therefore, less than half of all packets sent to this server successfully reached it through the network.
Submitted Solution:
```
n=int(input())
l=[]
m=[]
count=0
add=0
for i in range(n):
li=list(map(int,input().split()))
if li[0]==1:
l.append(li)
count+=1
else:
m.append(li)
add+=1
sum1=0
sum2=0
for row in range(count):
sum1+=l[row][1]
for col in range(add):
sum2+=m[col][1]
if sum1>=int(count)*5:
print("live")
else:
print("dead")
if sum2>=int(add)*5:
print("live")
else:
print("dead")
```
No
| 95,571 | [
0.2017822265625,
0.07281494140625,
-0.2371826171875,
0.37255859375,
-0.5390625,
-0.1475830078125,
-0.453125,
0.1864013671875,
0.429443359375,
0.7568359375,
0.51025390625,
0.08050537109375,
0.189697265625,
-0.55029296875,
-0.54443359375,
0.004123687744140625,
-0.53271484375,
-0.2912... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus is a system administrator. There are two servers under his strict guidance β a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program results in two integers x and y (x + y = 10; x, y β₯ 0). These numbers mean that x packets successfully reached the corresponding server through the network and y packets were lost.
Today Polycarpus has performed overall n ping commands during his workday. Now for each server Polycarpus wants to know whether the server is "alive" or not. Polycarpus thinks that the server is "alive", if at least half of the packets that we send to this server reached it successfully along the network.
Help Polycarpus, determine for each server, whether it is "alive" or not by the given commands and their results.
Input
The first line contains a single integer n (2 β€ n β€ 1000) β the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers β the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 β€ ti β€ 2; xi, yi β₯ 0; xi + yi = 10). If ti = 1, then the i-th command is "ping a", otherwise the i-th command is "ping b". Numbers xi, yi represent the result of executing this command, that is, xi packets reached the corresponding server successfully and yi packets were lost.
It is guaranteed that the input has at least one "ping a" command and at least one "ping b" command.
Output
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes).
In the second line print the state of server b in the similar format.
Examples
Input
2
1 5 5
2 6 4
Output
LIVE
LIVE
Input
3
1 0 10
2 0 10
1 10 0
Output
LIVE
DEAD
Note
Consider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network.
Consider the second test case. There were overall 20 packages sent to server a, 10 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall 10 packets were sent to server b, 0 of them reached it. Therefore, less than half of all packets sent to this server successfully reached it through the network.
Submitted Solution:
```
x = int(input())
i1 = 0
i2 = 0
check = 0
for i in range(x):
l1 = [int(n) for n in input().split()]
check += l1[2]
if l1[0] == 1:
i1 += l1[1]
else:
i2 += l1[1]
if(i1 >= (check // 2)):
print("LIVE")
else:
print("DEAD")
if (i2 >= (check // 2)):
print("LIVE")
else:
print("DEAD")
```
No
| 95,572 | [
0.2017822265625,
0.07281494140625,
-0.2371826171875,
0.37255859375,
-0.5390625,
-0.1475830078125,
-0.453125,
0.1864013671875,
0.429443359375,
0.7568359375,
0.51025390625,
0.08050537109375,
0.189697265625,
-0.55029296875,
-0.54443359375,
0.004123687744140625,
-0.53271484375,
-0.2912... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts k days!
When Polycarp went to a doctor with his problem, the doctor asked him about his sleeping schedule (more specifically, the average amount of hours of sleep per week). Luckily, Polycarp kept records of sleep times for the last n days. So now he has a sequence a1, a2, ..., an, where ai is the sleep time on the i-th day.
The number of records is so large that Polycarp is unable to calculate the average value by himself. Thus he is asking you to help him with the calculations. To get the average Polycarp is going to consider k consecutive days as a week. So there will be n - k + 1 weeks to take into consideration. For example, if k = 2, n = 3 and a = [3, 4, 7], then the result is <image>.
You should write a program which will calculate average sleep times of Polycarp over all weeks.
Input
The first line contains two integer numbers n and k (1 β€ k β€ n β€ 2Β·105).
The second line contains n integer numbers a1, a2, ..., an (1 β€ ai β€ 105).
Output
Output average sleeping time over all weeks.
The answer is considered to be correct if its absolute or relative error does not exceed 10 - 6. In particular, it is enough to output real number with at least 6 digits after the decimal point.
Examples
Input
3 2
3 4 7
Output
9.0000000000
Input
1 1
10
Output
10.0000000000
Input
8 2
1 2 4 100000 123 456 789 1
Output
28964.2857142857
Note
In the third example there are n - k + 1 = 7 weeks, so the answer is sums of all weeks divided by 7.
Tags: data structures, implementation, math
Correct Solution:
```
n,k=map(int,input().split())
arr=list(map(int,input().split()))
ww=n-k+1
a=[]
a.append(0)
for i in range(n):
a.append(arr[i])
for i in range(1,n+1):
a[i]=a[i]+a[i-1]
ans=0
for i in range(k,n+1):
tmp=a[i]-a[i-k]
ans+=(tmp/ww)
print(ans)
```
| 95,764 | [
0.5390625,
0.49072265625,
0.1812744140625,
-0.05267333984375,
-0.333984375,
-0.1383056640625,
-0.1859130859375,
-0.181396484375,
0.246337890625,
0.5146484375,
1.009765625,
-0.425537109375,
0.380126953125,
-0.87158203125,
-0.41162109375,
0.07904052734375,
-0.5751953125,
-0.923339843... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts k days!
When Polycarp went to a doctor with his problem, the doctor asked him about his sleeping schedule (more specifically, the average amount of hours of sleep per week). Luckily, Polycarp kept records of sleep times for the last n days. So now he has a sequence a1, a2, ..., an, where ai is the sleep time on the i-th day.
The number of records is so large that Polycarp is unable to calculate the average value by himself. Thus he is asking you to help him with the calculations. To get the average Polycarp is going to consider k consecutive days as a week. So there will be n - k + 1 weeks to take into consideration. For example, if k = 2, n = 3 and a = [3, 4, 7], then the result is <image>.
You should write a program which will calculate average sleep times of Polycarp over all weeks.
Input
The first line contains two integer numbers n and k (1 β€ k β€ n β€ 2Β·105).
The second line contains n integer numbers a1, a2, ..., an (1 β€ ai β€ 105).
Output
Output average sleeping time over all weeks.
The answer is considered to be correct if its absolute or relative error does not exceed 10 - 6. In particular, it is enough to output real number with at least 6 digits after the decimal point.
Examples
Input
3 2
3 4 7
Output
9.0000000000
Input
1 1
10
Output
10.0000000000
Input
8 2
1 2 4 100000 123 456 789 1
Output
28964.2857142857
Note
In the third example there are n - k + 1 = 7 weeks, so the answer is sums of all weeks divided by 7.
Tags: data structures, implementation, math
Correct Solution:
```
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
s, v = sum(a[:k]), 0
for i in range(k, n + 1):
s += a[i] - a[i - k]
v += s
print(v / (n - k + 1))
```
| 95,765 | [
0.54541015625,
0.490966796875,
0.1844482421875,
-0.0421142578125,
-0.328857421875,
-0.1455078125,
-0.1898193359375,
-0.18359375,
0.2415771484375,
0.51220703125,
1.0048828125,
-0.414306640625,
0.388916015625,
-0.86767578125,
-0.4208984375,
0.07916259765625,
-0.58203125,
-0.922363281... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts k days!
When Polycarp went to a doctor with his problem, the doctor asked him about his sleeping schedule (more specifically, the average amount of hours of sleep per week). Luckily, Polycarp kept records of sleep times for the last n days. So now he has a sequence a1, a2, ..., an, where ai is the sleep time on the i-th day.
The number of records is so large that Polycarp is unable to calculate the average value by himself. Thus he is asking you to help him with the calculations. To get the average Polycarp is going to consider k consecutive days as a week. So there will be n - k + 1 weeks to take into consideration. For example, if k = 2, n = 3 and a = [3, 4, 7], then the result is <image>.
You should write a program which will calculate average sleep times of Polycarp over all weeks.
Input
The first line contains two integer numbers n and k (1 β€ k β€ n β€ 2Β·105).
The second line contains n integer numbers a1, a2, ..., an (1 β€ ai β€ 105).
Output
Output average sleeping time over all weeks.
The answer is considered to be correct if its absolute or relative error does not exceed 10 - 6. In particular, it is enough to output real number with at least 6 digits after the decimal point.
Examples
Input
3 2
3 4 7
Output
9.0000000000
Input
1 1
10
Output
10.0000000000
Input
8 2
1 2 4 100000 123 456 789 1
Output
28964.2857142857
Note
In the third example there are n - k + 1 = 7 weeks, so the answer is sums of all weeks divided by 7.
Tags: data structures, implementation, math
Correct Solution:
```
from sys import stdin
a,b=map(int,stdin.readline().split())
c=list(map(int,stdin.readline().split()))
s=sum(c[:b]);k=s
for i in range(1,a-b+1):k=k-c[i-1]+c[i+b-1];s+=k
print((s)/(a-b+1))
```
| 95,766 | [
0.55029296875,
0.501953125,
0.200927734375,
-0.052703857421875,
-0.356201171875,
-0.1197509765625,
-0.2117919921875,
-0.1981201171875,
0.2138671875,
0.48974609375,
0.9970703125,
-0.4365234375,
0.38720703125,
-0.85888671875,
-0.40869140625,
0.06396484375,
-0.57763671875,
-0.92236328... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts k days!
When Polycarp went to a doctor with his problem, the doctor asked him about his sleeping schedule (more specifically, the average amount of hours of sleep per week). Luckily, Polycarp kept records of sleep times for the last n days. So now he has a sequence a1, a2, ..., an, where ai is the sleep time on the i-th day.
The number of records is so large that Polycarp is unable to calculate the average value by himself. Thus he is asking you to help him with the calculations. To get the average Polycarp is going to consider k consecutive days as a week. So there will be n - k + 1 weeks to take into consideration. For example, if k = 2, n = 3 and a = [3, 4, 7], then the result is <image>.
You should write a program which will calculate average sleep times of Polycarp over all weeks.
Input
The first line contains two integer numbers n and k (1 β€ k β€ n β€ 2Β·105).
The second line contains n integer numbers a1, a2, ..., an (1 β€ ai β€ 105).
Output
Output average sleeping time over all weeks.
The answer is considered to be correct if its absolute or relative error does not exceed 10 - 6. In particular, it is enough to output real number with at least 6 digits after the decimal point.
Examples
Input
3 2
3 4 7
Output
9.0000000000
Input
1 1
10
Output
10.0000000000
Input
8 2
1 2 4 100000 123 456 789 1
Output
28964.2857142857
Note
In the third example there are n - k + 1 = 7 weeks, so the answer is sums of all weeks divided by 7.
Tags: data structures, implementation, math
Correct Solution:
```
while True:
try:
n, k = map(int, input().split(' '))
except:
break
L = [int(x) for x in input().split(' ')]
ans = sum = 0.0
for x in L[:k]:
sum += x
ans += sum
for i in range(k, n):
sum = sum - L[i - k] + L[i]
ans += sum
print('%.10f' % (ans / (n - k + 1)))
```
| 95,767 | [
0.54541015625,
0.487548828125,
0.18212890625,
-0.0487060546875,
-0.3212890625,
-0.138427734375,
-0.17236328125,
-0.1865234375,
0.2362060546875,
0.50146484375,
1.0078125,
-0.413818359375,
0.39697265625,
-0.876953125,
-0.4228515625,
0.082275390625,
-0.58251953125,
-0.9306640625,
-0... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts k days!
When Polycarp went to a doctor with his problem, the doctor asked him about his sleeping schedule (more specifically, the average amount of hours of sleep per week). Luckily, Polycarp kept records of sleep times for the last n days. So now he has a sequence a1, a2, ..., an, where ai is the sleep time on the i-th day.
The number of records is so large that Polycarp is unable to calculate the average value by himself. Thus he is asking you to help him with the calculations. To get the average Polycarp is going to consider k consecutive days as a week. So there will be n - k + 1 weeks to take into consideration. For example, if k = 2, n = 3 and a = [3, 4, 7], then the result is <image>.
You should write a program which will calculate average sleep times of Polycarp over all weeks.
Input
The first line contains two integer numbers n and k (1 β€ k β€ n β€ 2Β·105).
The second line contains n integer numbers a1, a2, ..., an (1 β€ ai β€ 105).
Output
Output average sleeping time over all weeks.
The answer is considered to be correct if its absolute or relative error does not exceed 10 - 6. In particular, it is enough to output real number with at least 6 digits after the decimal point.
Examples
Input
3 2
3 4 7
Output
9.0000000000
Input
1 1
10
Output
10.0000000000
Input
8 2
1 2 4 100000 123 456 789 1
Output
28964.2857142857
Note
In the third example there are n - k + 1 = 7 weeks, so the answer is sums of all weeks divided by 7.
Tags: data structures, implementation, math
Correct Solution:
```
def solve(n,k,a):
s = sum(a[:k])
tot = 0
l = 0
tot += s
for r in range(k,n):
s = s-a[l]+a[r]
tot += s
l+=1
return tot/(n-k+1)
def main():
n,k = map(int,input().split(' '))
a = [int(x) for x in input().split(' ')]
print('{:0.6f}'.format(solve(n,k,a)))
if __name__ == "__main__":
main()
```
| 95,768 | [
0.53955078125,
0.487060546875,
0.1732177734375,
-0.0113372802734375,
-0.318359375,
-0.177734375,
-0.1846923828125,
-0.1739501953125,
0.2489013671875,
0.50634765625,
1,
-0.39501953125,
0.392578125,
-0.87939453125,
-0.42626953125,
0.11468505859375,
-0.5703125,
-0.9267578125,
-0.387... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts k days!
When Polycarp went to a doctor with his problem, the doctor asked him about his sleeping schedule (more specifically, the average amount of hours of sleep per week). Luckily, Polycarp kept records of sleep times for the last n days. So now he has a sequence a1, a2, ..., an, where ai is the sleep time on the i-th day.
The number of records is so large that Polycarp is unable to calculate the average value by himself. Thus he is asking you to help him with the calculations. To get the average Polycarp is going to consider k consecutive days as a week. So there will be n - k + 1 weeks to take into consideration. For example, if k = 2, n = 3 and a = [3, 4, 7], then the result is <image>.
You should write a program which will calculate average sleep times of Polycarp over all weeks.
Input
The first line contains two integer numbers n and k (1 β€ k β€ n β€ 2Β·105).
The second line contains n integer numbers a1, a2, ..., an (1 β€ ai β€ 105).
Output
Output average sleeping time over all weeks.
The answer is considered to be correct if its absolute or relative error does not exceed 10 - 6. In particular, it is enough to output real number with at least 6 digits after the decimal point.
Examples
Input
3 2
3 4 7
Output
9.0000000000
Input
1 1
10
Output
10.0000000000
Input
8 2
1 2 4 100000 123 456 789 1
Output
28964.2857142857
Note
In the third example there are n - k + 1 = 7 weeks, so the answer is sums of all weeks divided by 7.
Tags: data structures, implementation, math
Correct Solution:
```
n,k=list(map(int,input().strip().split(' ')))
A=list(map(int,input().strip().split(' ')))
temp=0
total=0
for i in range(n-k+1):
if i==0:
temp=sum(A[:k])
total+=temp
else:
temp-=A[i-1]
temp+=A[i+k-1]
total+=temp
#print(temp)
ans=total/(n-k+1)
print(ans)
```
| 95,769 | [
0.5537109375,
0.49609375,
0.18212890625,
-0.057037353515625,
-0.32763671875,
-0.12213134765625,
-0.1868896484375,
-0.2078857421875,
0.238525390625,
0.51904296875,
1.0078125,
-0.416015625,
0.406982421875,
-0.8720703125,
-0.416748046875,
0.073974609375,
-0.580078125,
-0.9345703125,
... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts k days!
When Polycarp went to a doctor with his problem, the doctor asked him about his sleeping schedule (more specifically, the average amount of hours of sleep per week). Luckily, Polycarp kept records of sleep times for the last n days. So now he has a sequence a1, a2, ..., an, where ai is the sleep time on the i-th day.
The number of records is so large that Polycarp is unable to calculate the average value by himself. Thus he is asking you to help him with the calculations. To get the average Polycarp is going to consider k consecutive days as a week. So there will be n - k + 1 weeks to take into consideration. For example, if k = 2, n = 3 and a = [3, 4, 7], then the result is <image>.
You should write a program which will calculate average sleep times of Polycarp over all weeks.
Input
The first line contains two integer numbers n and k (1 β€ k β€ n β€ 2Β·105).
The second line contains n integer numbers a1, a2, ..., an (1 β€ ai β€ 105).
Output
Output average sleeping time over all weeks.
The answer is considered to be correct if its absolute or relative error does not exceed 10 - 6. In particular, it is enough to output real number with at least 6 digits after the decimal point.
Examples
Input
3 2
3 4 7
Output
9.0000000000
Input
1 1
10
Output
10.0000000000
Input
8 2
1 2 4 100000 123 456 789 1
Output
28964.2857142857
Note
In the third example there are n - k + 1 = 7 weeks, so the answer is sums of all weeks divided by 7.
Tags: data structures, implementation, math
Correct Solution:
```
import sys
input = sys.stdin.readline
'''
week = k days
ai sleep time on i-th day
'''
n, k = map(int, input().split())
a = list(map(int, input().split()))
k_sum = sum(a[:k])
tot = k_sum
left, right = 0, k
while right < n:
k_sum -= a[left]
k_sum += a[right]
tot += k_sum
left += 1
right += 1
print(tot / (n-k+1))
```
| 95,770 | [
0.54833984375,
0.52978515625,
0.149169921875,
-0.0782470703125,
-0.3505859375,
-0.09228515625,
-0.213623046875,
-0.1884765625,
0.236083984375,
0.4765625,
0.97705078125,
-0.420166015625,
0.40625,
-0.89697265625,
-0.4072265625,
0.062225341796875,
-0.5625,
-0.9267578125,
-0.37744140... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts k days!
When Polycarp went to a doctor with his problem, the doctor asked him about his sleeping schedule (more specifically, the average amount of hours of sleep per week). Luckily, Polycarp kept records of sleep times for the last n days. So now he has a sequence a1, a2, ..., an, where ai is the sleep time on the i-th day.
The number of records is so large that Polycarp is unable to calculate the average value by himself. Thus he is asking you to help him with the calculations. To get the average Polycarp is going to consider k consecutive days as a week. So there will be n - k + 1 weeks to take into consideration. For example, if k = 2, n = 3 and a = [3, 4, 7], then the result is <image>.
You should write a program which will calculate average sleep times of Polycarp over all weeks.
Input
The first line contains two integer numbers n and k (1 β€ k β€ n β€ 2Β·105).
The second line contains n integer numbers a1, a2, ..., an (1 β€ ai β€ 105).
Output
Output average sleeping time over all weeks.
The answer is considered to be correct if its absolute or relative error does not exceed 10 - 6. In particular, it is enough to output real number with at least 6 digits after the decimal point.
Examples
Input
3 2
3 4 7
Output
9.0000000000
Input
1 1
10
Output
10.0000000000
Input
8 2
1 2 4 100000 123 456 789 1
Output
28964.2857142857
Note
In the third example there are n - k + 1 = 7 weeks, so the answer is sums of all weeks divided by 7.
Tags: data structures, implementation, math
Correct Solution:
```
n,k = map(int, input().split())
values = list(map(int, input().split()))
total = sum(values[:k])
hours = total
for i in range(k,n):
total += values[i] - values[i-k]
hours += total
print("%.6f" % (hours/(n-k+1)))
```
| 95,771 | [
0.5341796875,
0.497314453125,
0.1695556640625,
-0.060821533203125,
-0.32470703125,
-0.1534423828125,
-0.178955078125,
-0.193115234375,
0.251953125,
0.498291015625,
1.0048828125,
-0.41357421875,
0.4111328125,
-0.86181640625,
-0.4091796875,
0.06781005859375,
-0.5927734375,
-0.9238281... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts k days!
When Polycarp went to a doctor with his problem, the doctor asked him about his sleeping schedule (more specifically, the average amount of hours of sleep per week). Luckily, Polycarp kept records of sleep times for the last n days. So now he has a sequence a1, a2, ..., an, where ai is the sleep time on the i-th day.
The number of records is so large that Polycarp is unable to calculate the average value by himself. Thus he is asking you to help him with the calculations. To get the average Polycarp is going to consider k consecutive days as a week. So there will be n - k + 1 weeks to take into consideration. For example, if k = 2, n = 3 and a = [3, 4, 7], then the result is <image>.
You should write a program which will calculate average sleep times of Polycarp over all weeks.
Input
The first line contains two integer numbers n and k (1 β€ k β€ n β€ 2Β·105).
The second line contains n integer numbers a1, a2, ..., an (1 β€ ai β€ 105).
Output
Output average sleeping time over all weeks.
The answer is considered to be correct if its absolute or relative error does not exceed 10 - 6. In particular, it is enough to output real number with at least 6 digits after the decimal point.
Examples
Input
3 2
3 4 7
Output
9.0000000000
Input
1 1
10
Output
10.0000000000
Input
8 2
1 2 4 100000 123 456 789 1
Output
28964.2857142857
Note
In the third example there are n - k + 1 = 7 weeks, so the answer is sums of all weeks divided by 7.
Submitted Solution:
```
n,k = map(int,input().split())
a=list(map(int,input().split()))
sum=0
for i in range(k):
sum+=a[i]
total = sum
i=1
while(i+k-1 < n):
sum-=a[i-1]
sum+=a[i+k-1]
i+=1
total+=sum
print(format(total/(n-k+1),'.6f'))
```
Yes
| 95,772 | [
0.59619140625,
0.488037109375,
0.06878662109375,
-0.02935791015625,
-0.463134765625,
-0.06549072265625,
-0.1812744140625,
-0.0084075927734375,
0.181396484375,
0.55224609375,
0.97021484375,
-0.3017578125,
0.34130859375,
-0.84619140625,
-0.458984375,
0.0113372802734375,
-0.54736328125,... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts k days!
When Polycarp went to a doctor with his problem, the doctor asked him about his sleeping schedule (more specifically, the average amount of hours of sleep per week). Luckily, Polycarp kept records of sleep times for the last n days. So now he has a sequence a1, a2, ..., an, where ai is the sleep time on the i-th day.
The number of records is so large that Polycarp is unable to calculate the average value by himself. Thus he is asking you to help him with the calculations. To get the average Polycarp is going to consider k consecutive days as a week. So there will be n - k + 1 weeks to take into consideration. For example, if k = 2, n = 3 and a = [3, 4, 7], then the result is <image>.
You should write a program which will calculate average sleep times of Polycarp over all weeks.
Input
The first line contains two integer numbers n and k (1 β€ k β€ n β€ 2Β·105).
The second line contains n integer numbers a1, a2, ..., an (1 β€ ai β€ 105).
Output
Output average sleeping time over all weeks.
The answer is considered to be correct if its absolute or relative error does not exceed 10 - 6. In particular, it is enough to output real number with at least 6 digits after the decimal point.
Examples
Input
3 2
3 4 7
Output
9.0000000000
Input
1 1
10
Output
10.0000000000
Input
8 2
1 2 4 100000 123 456 789 1
Output
28964.2857142857
Note
In the third example there are n - k + 1 = 7 weeks, so the answer is sums of all weeks divided by 7.
Submitted Solution:
```
from itertools import *
n,k = [int(x) for x in input().split()]
a = list(accumulate([0] + [int(x) for x in input().split()]))
print(sum([a[i] - a[i-k] for i in range(k,n+1)]) / (n-k+1))
```
Yes
| 95,773 | [
0.5927734375,
0.480224609375,
0.042236328125,
-0.04290771484375,
-0.4443359375,
-0.0665283203125,
-0.1895751953125,
-0.0567626953125,
0.2095947265625,
0.55517578125,
0.94775390625,
-0.337158203125,
0.369873046875,
-0.83056640625,
-0.423828125,
0.0237579345703125,
-0.54638671875,
-0... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts k days!
When Polycarp went to a doctor with his problem, the doctor asked him about his sleeping schedule (more specifically, the average amount of hours of sleep per week). Luckily, Polycarp kept records of sleep times for the last n days. So now he has a sequence a1, a2, ..., an, where ai is the sleep time on the i-th day.
The number of records is so large that Polycarp is unable to calculate the average value by himself. Thus he is asking you to help him with the calculations. To get the average Polycarp is going to consider k consecutive days as a week. So there will be n - k + 1 weeks to take into consideration. For example, if k = 2, n = 3 and a = [3, 4, 7], then the result is <image>.
You should write a program which will calculate average sleep times of Polycarp over all weeks.
Input
The first line contains two integer numbers n and k (1 β€ k β€ n β€ 2Β·105).
The second line contains n integer numbers a1, a2, ..., an (1 β€ ai β€ 105).
Output
Output average sleeping time over all weeks.
The answer is considered to be correct if its absolute or relative error does not exceed 10 - 6. In particular, it is enough to output real number with at least 6 digits after the decimal point.
Examples
Input
3 2
3 4 7
Output
9.0000000000
Input
1 1
10
Output
10.0000000000
Input
8 2
1 2 4 100000 123 456 789 1
Output
28964.2857142857
Note
In the third example there are n - k + 1 = 7 weeks, so the answer is sums of all weeks divided by 7.
Submitted Solution:
```
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
running_sum = []
acc = 0
for i in range(0, k):
acc += a[i]
running_sum.append(acc)
total = running_sum[k - 1]
for i in range(k, n):
acc += a[i]
running_sum.append(acc)
total += running_sum[i] - running_sum[i - k]
print("%.10f" % (total / (n - k + 1)))
```
Yes
| 95,774 | [
0.60302734375,
0.470703125,
0.06719970703125,
-0.046295166015625,
-0.419677734375,
-0.013519287109375,
-0.1724853515625,
-0.03692626953125,
0.19580078125,
0.486572265625,
0.96826171875,
-0.281494140625,
0.333984375,
-0.876953125,
-0.46630859375,
0.0012350082397460938,
-0.5205078125,
... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts k days!
When Polycarp went to a doctor with his problem, the doctor asked him about his sleeping schedule (more specifically, the average amount of hours of sleep per week). Luckily, Polycarp kept records of sleep times for the last n days. So now he has a sequence a1, a2, ..., an, where ai is the sleep time on the i-th day.
The number of records is so large that Polycarp is unable to calculate the average value by himself. Thus he is asking you to help him with the calculations. To get the average Polycarp is going to consider k consecutive days as a week. So there will be n - k + 1 weeks to take into consideration. For example, if k = 2, n = 3 and a = [3, 4, 7], then the result is <image>.
You should write a program which will calculate average sleep times of Polycarp over all weeks.
Input
The first line contains two integer numbers n and k (1 β€ k β€ n β€ 2Β·105).
The second line contains n integer numbers a1, a2, ..., an (1 β€ ai β€ 105).
Output
Output average sleeping time over all weeks.
The answer is considered to be correct if its absolute or relative error does not exceed 10 - 6. In particular, it is enough to output real number with at least 6 digits after the decimal point.
Examples
Input
3 2
3 4 7
Output
9.0000000000
Input
1 1
10
Output
10.0000000000
Input
8 2
1 2 4 100000 123 456 789 1
Output
28964.2857142857
Note
In the third example there are n - k + 1 = 7 weeks, so the answer is sums of all weeks divided by 7.
Submitted Solution:
```
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
r, s, x = n-k+1, 0, []
x.append(a[0])
for i in range(1, n+1):
x.append(x[i-1] + a[i-1])
for i in range(k, n+1):
s += x[i] - x[i-k]
print(s/r)
```
Yes
| 95,775 | [
0.59716796875,
0.4873046875,
0.0687255859375,
-0.0218505859375,
-0.47412109375,
-0.0562744140625,
-0.194091796875,
-0.016998291015625,
0.17041015625,
0.56103515625,
0.97705078125,
-0.308837890625,
0.33349609375,
-0.8505859375,
-0.454345703125,
0.01207733154296875,
-0.54296875,
-0.8... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts k days!
When Polycarp went to a doctor with his problem, the doctor asked him about his sleeping schedule (more specifically, the average amount of hours of sleep per week). Luckily, Polycarp kept records of sleep times for the last n days. So now he has a sequence a1, a2, ..., an, where ai is the sleep time on the i-th day.
The number of records is so large that Polycarp is unable to calculate the average value by himself. Thus he is asking you to help him with the calculations. To get the average Polycarp is going to consider k consecutive days as a week. So there will be n - k + 1 weeks to take into consideration. For example, if k = 2, n = 3 and a = [3, 4, 7], then the result is <image>.
You should write a program which will calculate average sleep times of Polycarp over all weeks.
Input
The first line contains two integer numbers n and k (1 β€ k β€ n β€ 2Β·105).
The second line contains n integer numbers a1, a2, ..., an (1 β€ ai β€ 105).
Output
Output average sleeping time over all weeks.
The answer is considered to be correct if its absolute or relative error does not exceed 10 - 6. In particular, it is enough to output real number with at least 6 digits after the decimal point.
Examples
Input
3 2
3 4 7
Output
9.0000000000
Input
1 1
10
Output
10.0000000000
Input
8 2
1 2 4 100000 123 456 789 1
Output
28964.2857142857
Note
In the third example there are n - k + 1 = 7 weeks, so the answer is sums of all weeks divided by 7.
Submitted Solution:
```
def computeAvg(n, k, a, ans=0.):
for i in range(n):
ans+=float(min(k,n+k-1,n-i,i+1))*a[i]/1.0/(n-k+1)
return float(ans)
if __name__ == "__main__":
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
print(computeAvg(n,k,a))
```
No
| 95,776 | [
0.56689453125,
0.50537109375,
0.02984619140625,
0.024505615234375,
-0.44775390625,
-0.09197998046875,
-0.1513671875,
-0.0176239013671875,
0.197265625,
0.54541015625,
0.98046875,
-0.34521484375,
0.337158203125,
-0.89404296875,
-0.45751953125,
0.071533203125,
-0.544921875,
-0.9199218... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts k days!
When Polycarp went to a doctor with his problem, the doctor asked him about his sleeping schedule (more specifically, the average amount of hours of sleep per week). Luckily, Polycarp kept records of sleep times for the last n days. So now he has a sequence a1, a2, ..., an, where ai is the sleep time on the i-th day.
The number of records is so large that Polycarp is unable to calculate the average value by himself. Thus he is asking you to help him with the calculations. To get the average Polycarp is going to consider k consecutive days as a week. So there will be n - k + 1 weeks to take into consideration. For example, if k = 2, n = 3 and a = [3, 4, 7], then the result is <image>.
You should write a program which will calculate average sleep times of Polycarp over all weeks.
Input
The first line contains two integer numbers n and k (1 β€ k β€ n β€ 2Β·105).
The second line contains n integer numbers a1, a2, ..., an (1 β€ ai β€ 105).
Output
Output average sleeping time over all weeks.
The answer is considered to be correct if its absolute or relative error does not exceed 10 - 6. In particular, it is enough to output real number with at least 6 digits after the decimal point.
Examples
Input
3 2
3 4 7
Output
9.0000000000
Input
1 1
10
Output
10.0000000000
Input
8 2
1 2 4 100000 123 456 789 1
Output
28964.2857142857
Note
In the third example there are n - k + 1 = 7 weeks, so the answer is sums of all weeks divided by 7.
Submitted Solution:
```
#puoy-tang 3, 808B, 2137, G O O D B O Y O puoy-tang
inp = input().split()
n, k = int(inp[0]), int(inp[1])
cunt = n-k+1
a = input().split()
tsum = 0
hlf = 1
for i in range(0,len(a)):
a[i] = int(a[i])
tsum += a[i]*min(hlf, k, cunt)
if hlf < len(a)/2:
hlf += 1
elif hlf > len(a)/2:
hlf -= 1
tsum /= n-k+1
print(tsum)
```
No
| 95,777 | [
0.63818359375,
0.4833984375,
0.0050201416015625,
-0.020263671875,
-0.46484375,
-0.064697265625,
-0.1556396484375,
-0.0279541015625,
0.200439453125,
0.544921875,
1.044921875,
-0.2279052734375,
0.359619140625,
-0.85009765625,
-0.478271484375,
0.023468017578125,
-0.46044921875,
-0.873... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts k days!
When Polycarp went to a doctor with his problem, the doctor asked him about his sleeping schedule (more specifically, the average amount of hours of sleep per week). Luckily, Polycarp kept records of sleep times for the last n days. So now he has a sequence a1, a2, ..., an, where ai is the sleep time on the i-th day.
The number of records is so large that Polycarp is unable to calculate the average value by himself. Thus he is asking you to help him with the calculations. To get the average Polycarp is going to consider k consecutive days as a week. So there will be n - k + 1 weeks to take into consideration. For example, if k = 2, n = 3 and a = [3, 4, 7], then the result is <image>.
You should write a program which will calculate average sleep times of Polycarp over all weeks.
Input
The first line contains two integer numbers n and k (1 β€ k β€ n β€ 2Β·105).
The second line contains n integer numbers a1, a2, ..., an (1 β€ ai β€ 105).
Output
Output average sleeping time over all weeks.
The answer is considered to be correct if its absolute or relative error does not exceed 10 - 6. In particular, it is enough to output real number with at least 6 digits after the decimal point.
Examples
Input
3 2
3 4 7
Output
9.0000000000
Input
1 1
10
Output
10.0000000000
Input
8 2
1 2 4 100000 123 456 789 1
Output
28964.2857142857
Note
In the third example there are n - k + 1 = 7 weeks, so the answer is sums of all weeks divided by 7.
Submitted Solution:
```
x=input()
x=x.split()
n=input()
n=n.split()
for i in range(0,len(x)):
x[i]=float(int(x[i]))
for i in range(0,len(n)):
n[i]=float(int(n[i]))
no=x[0]-x[1]+1
sum_=float(0);
for i in n:
sum_+=i
sum_*=2
sum_-=n[0]
sum_-=n[-1]
print(float(sum_)/float(x[0]-x[1]+1))
```
No
| 95,778 | [
0.615234375,
0.48974609375,
0.06634521484375,
-0.0231475830078125,
-0.46875,
-0.0701904296875,
-0.1864013671875,
-0.021728515625,
0.1905517578125,
0.56396484375,
0.98583984375,
-0.302490234375,
0.318603515625,
-0.86328125,
-0.446044921875,
0.015960693359375,
-0.54248046875,
-0.8886... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts k days!
When Polycarp went to a doctor with his problem, the doctor asked him about his sleeping schedule (more specifically, the average amount of hours of sleep per week). Luckily, Polycarp kept records of sleep times for the last n days. So now he has a sequence a1, a2, ..., an, where ai is the sleep time on the i-th day.
The number of records is so large that Polycarp is unable to calculate the average value by himself. Thus he is asking you to help him with the calculations. To get the average Polycarp is going to consider k consecutive days as a week. So there will be n - k + 1 weeks to take into consideration. For example, if k = 2, n = 3 and a = [3, 4, 7], then the result is <image>.
You should write a program which will calculate average sleep times of Polycarp over all weeks.
Input
The first line contains two integer numbers n and k (1 β€ k β€ n β€ 2Β·105).
The second line contains n integer numbers a1, a2, ..., an (1 β€ ai β€ 105).
Output
Output average sleeping time over all weeks.
The answer is considered to be correct if its absolute or relative error does not exceed 10 - 6. In particular, it is enough to output real number with at least 6 digits after the decimal point.
Examples
Input
3 2
3 4 7
Output
9.0000000000
Input
1 1
10
Output
10.0000000000
Input
8 2
1 2 4 100000 123 456 789 1
Output
28964.2857142857
Note
In the third example there are n - k + 1 = 7 weeks, so the answer is sums of all weeks divided by 7.
Submitted Solution:
```
from math import floor
def truncate(f, n):
return floor(f * 10 ** n) / 10 ** n
def bounded_sum(l, p1, p2):
r = 0
for i in range(p1, p2 + 1):
r += l[i]
return r
def solve(n, k, a):
pos = 0
total = 0
for i in range(n - k + 1):
total += bounded_sum(a, pos, pos + k - 1)
pos += k - 1
return total/(n - k + 1)
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print(truncate(solve(N, K, A), 10))
# 1521408685546
```
No
| 95,779 | [
0.609375,
0.4765625,
0.063720703125,
-0.0230712890625,
-0.452880859375,
-0.067138671875,
-0.1986083984375,
0.0185394287109375,
0.1971435546875,
0.51953125,
0.974609375,
-0.31494140625,
0.31982421875,
-0.82177734375,
-0.4697265625,
0.061187744140625,
-0.54345703125,
-0.88427734375,
... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string s consisting of n lowercase Latin letters. Polycarp wants to remove exactly k characters (k β€ n) from the string s. Polycarp uses the following algorithm k times:
* if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;
* if there is at least one letter 'b', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;
* ...
* remove the leftmost occurrence of the letter 'z' and stop the algorithm.
This algorithm removes a single letter from the string. Polycarp performs this algorithm exactly k times, thus removing exactly k characters.
Help Polycarp find the resulting string.
Input
The first line of input contains two integers n and k (1 β€ k β€ n β€ 4 β
10^5) β the length of the string and the number of letters Polycarp will remove.
The second line contains the string s consisting of n lowercase Latin letters.
Output
Print the string that will be obtained from s after Polycarp removes exactly k letters using the above algorithm k times.
If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
Examples
Input
15 3
cccaabababaccbc
Output
cccbbabaccbc
Input
15 9
cccaabababaccbc
Output
cccccc
Input
1 1
u
Output
Tags: implementation
Correct Solution:
```
from collections import Counter
N,K = map(int,input().split())
S = input()
C = Counter(S)
cnt = 0
for i in range(26):
c = chr(97+i)
if cnt + C[c] >= K:
break
else:
cnt += C[c]
S = S.replace(c,"")
t = ""
for s in S:
if s == c and cnt < K:
cnt += 1
else:
t += s
else:
S = t
print(S)
```
| 95,839 | [
0.27099609375,
0.29248046875,
0.5458984375,
0.3798828125,
-0.402099609375,
-0.482421875,
-0.2457275390625,
-0.27734375,
0.138427734375,
0.69189453125,
0.90087890625,
-0.25244140625,
-0.259521484375,
-0.80322265625,
-0.7666015625,
-0.031768798828125,
-0.408203125,
-0.50146484375,
... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string s consisting of n lowercase Latin letters. Polycarp wants to remove exactly k characters (k β€ n) from the string s. Polycarp uses the following algorithm k times:
* if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;
* if there is at least one letter 'b', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;
* ...
* remove the leftmost occurrence of the letter 'z' and stop the algorithm.
This algorithm removes a single letter from the string. Polycarp performs this algorithm exactly k times, thus removing exactly k characters.
Help Polycarp find the resulting string.
Input
The first line of input contains two integers n and k (1 β€ k β€ n β€ 4 β
10^5) β the length of the string and the number of letters Polycarp will remove.
The second line contains the string s consisting of n lowercase Latin letters.
Output
Print the string that will be obtained from s after Polycarp removes exactly k letters using the above algorithm k times.
If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
Examples
Input
15 3
cccaabababaccbc
Output
cccbbabaccbc
Input
15 9
cccaabababaccbc
Output
cccccc
Input
1 1
u
Output
Tags: implementation
Correct Solution:
```
_, k = map(int, input().split())
s = input()
for ch in 'abcdefghijklmnopqrstuvwxyz':
x = s.count(ch)
if x < k:
s = s.replace(ch, '', x)
k -= x
else:
s = s.replace(ch, '', k)
break
print(s)
```
| 95,842 | [
0.28271484375,
0.283447265625,
0.52490234375,
0.3623046875,
-0.45263671875,
-0.489501953125,
-0.306640625,
-0.26708984375,
0.1651611328125,
0.64892578125,
0.92626953125,
-0.2435302734375,
-0.267822265625,
-0.79248046875,
-0.74462890625,
-0.0274658203125,
-0.3876953125,
-0.510253906... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a string s consisting of n lowercase Latin letters. Polycarp wants to remove exactly k characters (k β€ n) from the string s. Polycarp uses the following algorithm k times:
* if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;
* if there is at least one letter 'b', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;
* ...
* remove the leftmost occurrence of the letter 'z' and stop the algorithm.
This algorithm removes a single letter from the string. Polycarp performs this algorithm exactly k times, thus removing exactly k characters.
Help Polycarp find the resulting string.
Input
The first line of input contains two integers n and k (1 β€ k β€ n β€ 4 β
10^5) β the length of the string and the number of letters Polycarp will remove.
The second line contains the string s consisting of n lowercase Latin letters.
Output
Print the string that will be obtained from s after Polycarp removes exactly k letters using the above algorithm k times.
If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
Examples
Input
15 3
cccaabababaccbc
Output
cccbbabaccbc
Input
15 9
cccaabababaccbc
Output
cccccc
Input
1 1
u
Output
Submitted Solution:
```
def fun(s,n,k):
occ=[0]*26
for i in s:
occ[ord(i)-97]+=1
r=k
i=-1
while r>0:
i+=1
r-=occ[i]
if i==-1:
return ''
last=occ[i]+r
occ[i]=last
ans=''
for j in s:
ch=ord(j)-97
if ch<=i and occ[ch]>0:
occ[ch]-=1
else:
ans+=j
return ans
n,k=map(int,input().split())
#n=int(input())
s=input()
print(fun(s,n,k))
```
Yes
| 95,847 | [
0.327392578125,
0.314697265625,
0.462646484375,
0.268798828125,
-0.496826171875,
-0.33984375,
-0.380859375,
-0.21435546875,
0.12646484375,
0.67138671875,
0.9296875,
-0.300048828125,
-0.349853515625,
-0.939453125,
-0.7568359375,
-0.02301025390625,
-0.384765625,
-0.54931640625,
-0.... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a string s consisting of n lowercase Latin letters. Polycarp wants to remove exactly k characters (k β€ n) from the string s. Polycarp uses the following algorithm k times:
* if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;
* if there is at least one letter 'b', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;
* ...
* remove the leftmost occurrence of the letter 'z' and stop the algorithm.
This algorithm removes a single letter from the string. Polycarp performs this algorithm exactly k times, thus removing exactly k characters.
Help Polycarp find the resulting string.
Input
The first line of input contains two integers n and k (1 β€ k β€ n β€ 4 β
10^5) β the length of the string and the number of letters Polycarp will remove.
The second line contains the string s consisting of n lowercase Latin letters.
Output
Print the string that will be obtained from s after Polycarp removes exactly k letters using the above algorithm k times.
If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
Examples
Input
15 3
cccaabababaccbc
Output
cccbbabaccbc
Input
15 9
cccaabababaccbc
Output
cccccc
Input
1 1
u
Output
Submitted Solution:
```
n, k = map(int, input().split())
s = list(input())
# count = Counter(s)
update = dict()
while k>0:
for i in range(26):
c = chr(i+97)
count = s.count(c)
if count < k:
update[c] = count
k -= count
else:
update[c] = k
k = 0
break
# print(update)
updated_str = []
for i in s:
if i in update and update[i]>0:
update[i] -= 1
continue
else:
updated_str.append(i)
print(''.join(updated_str))
```
Yes
| 95,848 | [
0.28564453125,
0.31884765625,
0.437744140625,
0.31103515625,
-0.5234375,
-0.298583984375,
-0.406982421875,
-0.20263671875,
0.1038818359375,
0.6591796875,
0.85986328125,
-0.257568359375,
-0.3125,
-0.85791015625,
-0.775390625,
-0.062255859375,
-0.3935546875,
-0.5322265625,
-0.36499... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a string s consisting of n lowercase Latin letters. Polycarp wants to remove exactly k characters (k β€ n) from the string s. Polycarp uses the following algorithm k times:
* if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;
* if there is at least one letter 'b', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;
* ...
* remove the leftmost occurrence of the letter 'z' and stop the algorithm.
This algorithm removes a single letter from the string. Polycarp performs this algorithm exactly k times, thus removing exactly k characters.
Help Polycarp find the resulting string.
Input
The first line of input contains two integers n and k (1 β€ k β€ n β€ 4 β
10^5) β the length of the string and the number of letters Polycarp will remove.
The second line contains the string s consisting of n lowercase Latin letters.
Output
Print the string that will be obtained from s after Polycarp removes exactly k letters using the above algorithm k times.
If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
Examples
Input
15 3
cccaabababaccbc
Output
cccbbabaccbc
Input
15 9
cccaabababaccbc
Output
cccccc
Input
1 1
u
Output
Submitted Solution:
```
from collections import defaultdict
n , k = [int(x) for x in input().split()]
s = input()
removed = set()
l = defaultdict(list)
for ind,i in enumerate(s) :
l[i].append(ind)
if k >= n :
pass
else :
while k > 0 :
for char in sorted(l.keys()) :
if k >= len(l[char]) :
for ind in l[char] :
removed.add(ind)
k -= len(l[char])
if k == 0 :
break
else :
for ind in l[char][:k] :
removed.add(ind)
k = 0
break
for ind,i in enumerate(s) :
if ind not in removed :
print(i , end = '')
```
Yes
| 95,849 | [
0.2393798828125,
0.323486328125,
0.447265625,
0.269775390625,
-0.56103515625,
-0.281982421875,
-0.39306640625,
-0.2000732421875,
0.08489990234375,
0.67822265625,
0.8720703125,
-0.279296875,
-0.2822265625,
-0.90087890625,
-0.82177734375,
-0.044677734375,
-0.4287109375,
-0.5419921875... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a string s consisting of n lowercase Latin letters. Polycarp wants to remove exactly k characters (k β€ n) from the string s. Polycarp uses the following algorithm k times:
* if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;
* if there is at least one letter 'b', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;
* ...
* remove the leftmost occurrence of the letter 'z' and stop the algorithm.
This algorithm removes a single letter from the string. Polycarp performs this algorithm exactly k times, thus removing exactly k characters.
Help Polycarp find the resulting string.
Input
The first line of input contains two integers n and k (1 β€ k β€ n β€ 4 β
10^5) β the length of the string and the number of letters Polycarp will remove.
The second line contains the string s consisting of n lowercase Latin letters.
Output
Print the string that will be obtained from s after Polycarp removes exactly k letters using the above algorithm k times.
If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
Examples
Input
15 3
cccaabababaccbc
Output
cccbbabaccbc
Input
15 9
cccaabababaccbc
Output
cccccc
Input
1 1
u
Output
Submitted Solution:
```
[n,k] = list(map(int,input().split(" ")))
s = input()
list_s = list(s)
#print(list_s)
y = [i for i in range(len(list_s))]
zipped = list(zip(list_s,y))
#print(zipped)
zipped.sort(key = lambda t: t[0])
#print('after',zipped)
result = list("*"*n)
#print(zipped[0][0],zipped[0][1])
for i in range(k,len(zipped)):
result[zipped[i][1]] = zipped[i][0]
#print('result',result)
final = ""
for c in result:
if c != '*':
final += c
print(final)
```
Yes
| 95,850 | [
0.2215576171875,
0.235107421875,
0.529296875,
0.390380859375,
-0.60791015625,
-0.315673828125,
-0.44873046875,
-0.1444091796875,
0.1204833984375,
0.79931640625,
0.8369140625,
-0.310302734375,
-0.2410888671875,
-0.935546875,
-0.79833984375,
-0.0098114013671875,
-0.341552734375,
-0.5... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a string s consisting of n lowercase Latin letters. Polycarp wants to remove exactly k characters (k β€ n) from the string s. Polycarp uses the following algorithm k times:
* if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;
* if there is at least one letter 'b', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;
* ...
* remove the leftmost occurrence of the letter 'z' and stop the algorithm.
This algorithm removes a single letter from the string. Polycarp performs this algorithm exactly k times, thus removing exactly k characters.
Help Polycarp find the resulting string.
Input
The first line of input contains two integers n and k (1 β€ k β€ n β€ 4 β
10^5) β the length of the string and the number of letters Polycarp will remove.
The second line contains the string s consisting of n lowercase Latin letters.
Output
Print the string that will be obtained from s after Polycarp removes exactly k letters using the above algorithm k times.
If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
Examples
Input
15 3
cccaabababaccbc
Output
cccbbabaccbc
Input
15 9
cccaabababaccbc
Output
cccccc
Input
1 1
u
Output
Submitted Solution:
```
number_of_testcases = 1 #int(input())
for _ in range(number_of_testcases):
len_of_given_str, num_of_letters_to_be_removed = map(int, input().split())
given_str = input()
freq_of_alpha = [0 for i in range(26)]
for char in given_str:
freq_of_alpha[ord(char)-97] += 1
#print(freq_of_alpha)
for i in range(26):
if freq_of_alpha[i] >= num_of_letters_to_be_removed:
freq_of_alpha[i] -= num_of_letters_to_be_removed
break
else:
num_of_letters_to_be_removed -= freq_of_alpha[i]
#print(freq_of_alpha)
resulting_str = []
for char in range(len_of_given_str-1, -1, -1):
char = given_str[char]
if freq_of_alpha[ord(char) - 97]:
resulting_str.append(char)
freq_of_alpha[ord(char) - 97] -= 1
#print(freq_of_alpha)
# print(resulting_str)
resulting_str.reverse()
print("".join(resulting_str))
```
No
| 95,851 | [
0.288818359375,
0.34228515625,
0.501953125,
0.319091796875,
-0.56884765625,
-0.30712890625,
-0.45263671875,
-0.2119140625,
0.06475830078125,
0.67431640625,
0.89404296875,
-0.232421875,
-0.275390625,
-0.90576171875,
-0.79736328125,
-0.03790283203125,
-0.4091796875,
-0.5556640625,
... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The King of Berland Polycarp LXXXIV has n daughters. To establish his power to the neighbouring kingdoms he wants to marry his daughters to the princes of these kingdoms. As a lucky coincidence there are n other kingdoms as well.
So Polycarp LXXXIV has enumerated his daughters from 1 to n and the kingdoms from 1 to n. For each daughter he has compiled a list of kingdoms princes of which she wanted to marry.
Polycarp LXXXIV is very busy, so he finds a couple for his daughters greedily one after another.
For the first daughter he takes the kingdom with the lowest number from her list and marries the daughter to their prince. For the second daughter he takes the kingdom with the lowest number from her list, prince of which hasn't been taken already. If there are no free princes in the list then the daughter marries nobody and Polycarp LXXXIV proceeds to the next daughter. The process ends after the n-th daughter.
For example, let there be 4 daughters and kingdoms, the lists daughters have are [2, 3], [1, 2], [3, 4], [3], respectively.
<image>
In that case daughter 1 marries the prince of kingdom 2, daughter 2 marries the prince of kingdom 1, daughter 3 marries the prince of kingdom 3, leaving daughter 4 nobody to marry to.
Actually, before starting the marriage process Polycarp LXXXIV has the time to convince one of his daughters that some prince is also worth marrying to. Effectively, that means that he can add exactly one kingdom to exactly one of his daughter's list. Note that this kingdom should not be present in the daughter's list.
Polycarp LXXXIV wants to increase the number of married couples.
Unfortunately, what he doesn't have the time for is determining what entry to add. If there is no way to increase the total number of married couples then output that the marriages are already optimal. Otherwise, find such an entry that the total number of married couples increases if Polycarp LXXXIV adds it.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
For your and our convenience you are asked to answer t independent test cases.
Input
The first line contains a single integer t (1 β€ t β€ 10^5) β the number of test cases.
Then t test cases follow.
The first line of each test case contains a single integer n (1 β€ n β€ 10^5) β the number of daughters and the number of kingdoms.
Each of the next n lines contains the description of each daughter's list. The first integer k (0 β€ k β€ n) is the number of entries in the i-th daughter's list. After that k distinct integers follow g_i[1], g_i[2], ..., g_i[k] (1 β€ g_i[j] β€ n) β the indices of the kingdoms in the list in the increasing order (g_i[1] < g_i[2] < ... < g_i[k]).
It's guaranteed that the total number of daughters over all test cases does not exceed 10^5.
It's also guaranteed that the total number of kingdoms in lists over all test cases does not exceed 10^5.
Output
For each test case print the answer to it.
Print "IMPROVE" in the first line if Polycarp LXXXIV can add some kingdom to some of his daughter's list so that the total number of married couples increases. The second line then should contain two integers β the index of the daughter and the index of the kingdom Polycarp LXXXIV should add to that daughter's list.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
Otherwise the only line should contain one word "OPTIMAL".
Example
Input
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
Output
IMPROVE
4 4
IMPROVE
1 1
OPTIMAL
OPTIMAL
OPTIMAL
Note
The first test case is depicted in the statement. Adding the fourth kingdom to the list of the fourth daughter makes her marry the prince of the fourth kingdom.
In the second test case any new entry will increase the number of marriages from 0 to 1.
In the third and the fourth test cases there is no way to add an entry.
In the fifth test case there is no way to change the marriages by adding any entry.
Tags: brute force, graphs, greedy
Correct Solution:
```
def main():
for _ in range(int(input())):
n=int(input())
visited=[False]*n
q=[list(map(int,input().split())) for i in range(n)]
t1,x=0,0
for i in range(n):
t=-1
if(len(q[i])>1):
t=min(q[i][1:],key=lambda x: n+1 if(visited[x-1]) else x)
elif(t1==0 and x==0):
t1=-1
x=i
if(t!=-1 and not visited[t-1]):
visited[t-1]=True
elif(t1==0 and x==0):
t1=-1
x=i
if(t1==-1):
print("IMPROVE")
print(x+1,visited.index(False)+1)
else:
print("OPTIMAL")
main()
```
| 97,117 | [
0.224365234375,
0.1796875,
0.0352783203125,
0.12127685546875,
-0.55224609375,
-0.281005859375,
-0.293701171875,
0.1663818359375,
0.438720703125,
0.62939453125,
0.8154296875,
-0.33251953125,
0.236572265625,
-0.413818359375,
-0.607421875,
0.1715087890625,
-0.5068359375,
-0.9150390625... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The King of Berland Polycarp LXXXIV has n daughters. To establish his power to the neighbouring kingdoms he wants to marry his daughters to the princes of these kingdoms. As a lucky coincidence there are n other kingdoms as well.
So Polycarp LXXXIV has enumerated his daughters from 1 to n and the kingdoms from 1 to n. For each daughter he has compiled a list of kingdoms princes of which she wanted to marry.
Polycarp LXXXIV is very busy, so he finds a couple for his daughters greedily one after another.
For the first daughter he takes the kingdom with the lowest number from her list and marries the daughter to their prince. For the second daughter he takes the kingdom with the lowest number from her list, prince of which hasn't been taken already. If there are no free princes in the list then the daughter marries nobody and Polycarp LXXXIV proceeds to the next daughter. The process ends after the n-th daughter.
For example, let there be 4 daughters and kingdoms, the lists daughters have are [2, 3], [1, 2], [3, 4], [3], respectively.
<image>
In that case daughter 1 marries the prince of kingdom 2, daughter 2 marries the prince of kingdom 1, daughter 3 marries the prince of kingdom 3, leaving daughter 4 nobody to marry to.
Actually, before starting the marriage process Polycarp LXXXIV has the time to convince one of his daughters that some prince is also worth marrying to. Effectively, that means that he can add exactly one kingdom to exactly one of his daughter's list. Note that this kingdom should not be present in the daughter's list.
Polycarp LXXXIV wants to increase the number of married couples.
Unfortunately, what he doesn't have the time for is determining what entry to add. If there is no way to increase the total number of married couples then output that the marriages are already optimal. Otherwise, find such an entry that the total number of married couples increases if Polycarp LXXXIV adds it.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
For your and our convenience you are asked to answer t independent test cases.
Input
The first line contains a single integer t (1 β€ t β€ 10^5) β the number of test cases.
Then t test cases follow.
The first line of each test case contains a single integer n (1 β€ n β€ 10^5) β the number of daughters and the number of kingdoms.
Each of the next n lines contains the description of each daughter's list. The first integer k (0 β€ k β€ n) is the number of entries in the i-th daughter's list. After that k distinct integers follow g_i[1], g_i[2], ..., g_i[k] (1 β€ g_i[j] β€ n) β the indices of the kingdoms in the list in the increasing order (g_i[1] < g_i[2] < ... < g_i[k]).
It's guaranteed that the total number of daughters over all test cases does not exceed 10^5.
It's also guaranteed that the total number of kingdoms in lists over all test cases does not exceed 10^5.
Output
For each test case print the answer to it.
Print "IMPROVE" in the first line if Polycarp LXXXIV can add some kingdom to some of his daughter's list so that the total number of married couples increases. The second line then should contain two integers β the index of the daughter and the index of the kingdom Polycarp LXXXIV should add to that daughter's list.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
Otherwise the only line should contain one word "OPTIMAL".
Example
Input
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
Output
IMPROVE
4 4
IMPROVE
1 1
OPTIMAL
OPTIMAL
OPTIMAL
Note
The first test case is depicted in the statement. Adding the fourth kingdom to the list of the fourth daughter makes her marry the prince of the fourth kingdom.
In the second test case any new entry will increase the number of marriages from 0 to 1.
In the third and the fourth test cases there is no way to add an entry.
In the fifth test case there is no way to change the marriages by adding any entry.
Tags: brute force, graphs, greedy
Correct Solution:
```
input = __import__('sys').stdin.readline
print = __import__('sys').stdout.write
for _ in range(int(input())):
n = int(input())
prince = set(range(1, n+1))
princess = set(range(1, n+1))
princess_list = [[] for _ in range(n+1)]
for i in range(n):
k = list(map(int, input().split()))[1:]
princess_list[i+1] = k
if k:
for j in k:
if j in prince:
prince.remove(j)
princess.remove(i+1)
break
# print(str(princess) + '\n')
# print(str(prince) + '\n')
# print(str(princess_list) +'\n')
# exit()Y
tmp = False
for pr1 in princess:
for pr2 in prince:
if pr2 in princess_list[pr1]:
continue
else:
print (f'IMPROVE\n')
print (f'{pr1} {pr2}\n')
tmp = True
break
if tmp:
break
else:
print ('OPTIMAL\n')
```
| 97,118 | [
0.224365234375,
0.1796875,
0.0352783203125,
0.12127685546875,
-0.55224609375,
-0.281005859375,
-0.293701171875,
0.1663818359375,
0.438720703125,
0.62939453125,
0.8154296875,
-0.33251953125,
0.236572265625,
-0.413818359375,
-0.607421875,
0.1715087890625,
-0.5068359375,
-0.9150390625... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The King of Berland Polycarp LXXXIV has n daughters. To establish his power to the neighbouring kingdoms he wants to marry his daughters to the princes of these kingdoms. As a lucky coincidence there are n other kingdoms as well.
So Polycarp LXXXIV has enumerated his daughters from 1 to n and the kingdoms from 1 to n. For each daughter he has compiled a list of kingdoms princes of which she wanted to marry.
Polycarp LXXXIV is very busy, so he finds a couple for his daughters greedily one after another.
For the first daughter he takes the kingdom with the lowest number from her list and marries the daughter to their prince. For the second daughter he takes the kingdom with the lowest number from her list, prince of which hasn't been taken already. If there are no free princes in the list then the daughter marries nobody and Polycarp LXXXIV proceeds to the next daughter. The process ends after the n-th daughter.
For example, let there be 4 daughters and kingdoms, the lists daughters have are [2, 3], [1, 2], [3, 4], [3], respectively.
<image>
In that case daughter 1 marries the prince of kingdom 2, daughter 2 marries the prince of kingdom 1, daughter 3 marries the prince of kingdom 3, leaving daughter 4 nobody to marry to.
Actually, before starting the marriage process Polycarp LXXXIV has the time to convince one of his daughters that some prince is also worth marrying to. Effectively, that means that he can add exactly one kingdom to exactly one of his daughter's list. Note that this kingdom should not be present in the daughter's list.
Polycarp LXXXIV wants to increase the number of married couples.
Unfortunately, what he doesn't have the time for is determining what entry to add. If there is no way to increase the total number of married couples then output that the marriages are already optimal. Otherwise, find such an entry that the total number of married couples increases if Polycarp LXXXIV adds it.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
For your and our convenience you are asked to answer t independent test cases.
Input
The first line contains a single integer t (1 β€ t β€ 10^5) β the number of test cases.
Then t test cases follow.
The first line of each test case contains a single integer n (1 β€ n β€ 10^5) β the number of daughters and the number of kingdoms.
Each of the next n lines contains the description of each daughter's list. The first integer k (0 β€ k β€ n) is the number of entries in the i-th daughter's list. After that k distinct integers follow g_i[1], g_i[2], ..., g_i[k] (1 β€ g_i[j] β€ n) β the indices of the kingdoms in the list in the increasing order (g_i[1] < g_i[2] < ... < g_i[k]).
It's guaranteed that the total number of daughters over all test cases does not exceed 10^5.
It's also guaranteed that the total number of kingdoms in lists over all test cases does not exceed 10^5.
Output
For each test case print the answer to it.
Print "IMPROVE" in the first line if Polycarp LXXXIV can add some kingdom to some of his daughter's list so that the total number of married couples increases. The second line then should contain two integers β the index of the daughter and the index of the kingdom Polycarp LXXXIV should add to that daughter's list.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
Otherwise the only line should contain one word "OPTIMAL".
Example
Input
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
Output
IMPROVE
4 4
IMPROVE
1 1
OPTIMAL
OPTIMAL
OPTIMAL
Note
The first test case is depicted in the statement. Adding the fourth kingdom to the list of the fourth daughter makes her marry the prince of the fourth kingdom.
In the second test case any new entry will increase the number of marriages from 0 to 1.
In the third and the fourth test cases there is no way to add an entry.
In the fifth test case there is no way to change the marriages by adding any entry.
Tags: brute force, graphs, greedy
Correct Solution:
```
t = int(input())
for _ in range(t):
n = int(input())
# daughters = [False for _ in range(n+1)]
# boys = [False for _ in range(n+1)]
boys = [False]*(n+1)
dul = -1
boys[0] = True
chk = True
for i in range(n):
x = list(map(int, input().split()))
for j in range(1, x[0]+1):
if boys[x[j]]==False:
boys[x[j]]=True
break
else:
if chk==True:
dul = i+1
chk = False
if dul!=-1:
print("IMPROVE")
print(dul, boys.index(False))
else:
print("OPTIMAL")
# print(boys)
# lst = [list(map(int, input().split())) for _ in range(n)]
```
| 97,119 | [
0.224365234375,
0.1796875,
0.0352783203125,
0.12127685546875,
-0.55224609375,
-0.281005859375,
-0.293701171875,
0.1663818359375,
0.438720703125,
0.62939453125,
0.8154296875,
-0.33251953125,
0.236572265625,
-0.413818359375,
-0.607421875,
0.1715087890625,
-0.5068359375,
-0.9150390625... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The King of Berland Polycarp LXXXIV has n daughters. To establish his power to the neighbouring kingdoms he wants to marry his daughters to the princes of these kingdoms. As a lucky coincidence there are n other kingdoms as well.
So Polycarp LXXXIV has enumerated his daughters from 1 to n and the kingdoms from 1 to n. For each daughter he has compiled a list of kingdoms princes of which she wanted to marry.
Polycarp LXXXIV is very busy, so he finds a couple for his daughters greedily one after another.
For the first daughter he takes the kingdom with the lowest number from her list and marries the daughter to their prince. For the second daughter he takes the kingdom with the lowest number from her list, prince of which hasn't been taken already. If there are no free princes in the list then the daughter marries nobody and Polycarp LXXXIV proceeds to the next daughter. The process ends after the n-th daughter.
For example, let there be 4 daughters and kingdoms, the lists daughters have are [2, 3], [1, 2], [3, 4], [3], respectively.
<image>
In that case daughter 1 marries the prince of kingdom 2, daughter 2 marries the prince of kingdom 1, daughter 3 marries the prince of kingdom 3, leaving daughter 4 nobody to marry to.
Actually, before starting the marriage process Polycarp LXXXIV has the time to convince one of his daughters that some prince is also worth marrying to. Effectively, that means that he can add exactly one kingdom to exactly one of his daughter's list. Note that this kingdom should not be present in the daughter's list.
Polycarp LXXXIV wants to increase the number of married couples.
Unfortunately, what he doesn't have the time for is determining what entry to add. If there is no way to increase the total number of married couples then output that the marriages are already optimal. Otherwise, find such an entry that the total number of married couples increases if Polycarp LXXXIV adds it.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
For your and our convenience you are asked to answer t independent test cases.
Input
The first line contains a single integer t (1 β€ t β€ 10^5) β the number of test cases.
Then t test cases follow.
The first line of each test case contains a single integer n (1 β€ n β€ 10^5) β the number of daughters and the number of kingdoms.
Each of the next n lines contains the description of each daughter's list. The first integer k (0 β€ k β€ n) is the number of entries in the i-th daughter's list. After that k distinct integers follow g_i[1], g_i[2], ..., g_i[k] (1 β€ g_i[j] β€ n) β the indices of the kingdoms in the list in the increasing order (g_i[1] < g_i[2] < ... < g_i[k]).
It's guaranteed that the total number of daughters over all test cases does not exceed 10^5.
It's also guaranteed that the total number of kingdoms in lists over all test cases does not exceed 10^5.
Output
For each test case print the answer to it.
Print "IMPROVE" in the first line if Polycarp LXXXIV can add some kingdom to some of his daughter's list so that the total number of married couples increases. The second line then should contain two integers β the index of the daughter and the index of the kingdom Polycarp LXXXIV should add to that daughter's list.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
Otherwise the only line should contain one word "OPTIMAL".
Example
Input
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
Output
IMPROVE
4 4
IMPROVE
1 1
OPTIMAL
OPTIMAL
OPTIMAL
Note
The first test case is depicted in the statement. Adding the fourth kingdom to the list of the fourth daughter makes her marry the prince of the fourth kingdom.
In the second test case any new entry will increase the number of marriages from 0 to 1.
In the third and the fourth test cases there is no way to add an entry.
In the fifth test case there is no way to change the marriages by adding any entry.
Tags: brute force, graphs, greedy
Correct Solution:
```
for _ in range(int(input())):
n = int(input())
dc ={}
for i in range(1,n+1):
dc[i] = []
prc = [False for i in range(n+1)]
pcc = [False for i in range(n+1)]
b = []
for i in range(1,n+1):
x = [int(o) for o in input().split()]
dc[i] = x[1:]
count = 0
for i in range(1,n+1):
if len(dc[i]) is 0:
continue
else:
temp = dc[i]
for boy in temp:
if prc[boy] is False:
pcc[i] = True
prc[boy] = True
count += 1
break
if count == n:
print("OPTIMAL")
else:
flag = 0
for girl in range(1,n+1):
if pcc[girl] is False:
for boy in range(1,n+1):
if prc[boy] is False and len(dc[girl]) is 0:
flag = 1
print("IMPROVE")
print(girl,boy)
break
elif prc[boy] is False and boy not in dc[girl]:
flag = 1
print("IMPROVE")
print(girl,boy)
break
if flag is 1:
break
if flag is 0:
print("OPTIMAL")
```
| 97,120 | [
0.224365234375,
0.1796875,
0.0352783203125,
0.12127685546875,
-0.55224609375,
-0.281005859375,
-0.293701171875,
0.1663818359375,
0.438720703125,
0.62939453125,
0.8154296875,
-0.33251953125,
0.236572265625,
-0.413818359375,
-0.607421875,
0.1715087890625,
-0.5068359375,
-0.9150390625... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The King of Berland Polycarp LXXXIV has n daughters. To establish his power to the neighbouring kingdoms he wants to marry his daughters to the princes of these kingdoms. As a lucky coincidence there are n other kingdoms as well.
So Polycarp LXXXIV has enumerated his daughters from 1 to n and the kingdoms from 1 to n. For each daughter he has compiled a list of kingdoms princes of which she wanted to marry.
Polycarp LXXXIV is very busy, so he finds a couple for his daughters greedily one after another.
For the first daughter he takes the kingdom with the lowest number from her list and marries the daughter to their prince. For the second daughter he takes the kingdom with the lowest number from her list, prince of which hasn't been taken already. If there are no free princes in the list then the daughter marries nobody and Polycarp LXXXIV proceeds to the next daughter. The process ends after the n-th daughter.
For example, let there be 4 daughters and kingdoms, the lists daughters have are [2, 3], [1, 2], [3, 4], [3], respectively.
<image>
In that case daughter 1 marries the prince of kingdom 2, daughter 2 marries the prince of kingdom 1, daughter 3 marries the prince of kingdom 3, leaving daughter 4 nobody to marry to.
Actually, before starting the marriage process Polycarp LXXXIV has the time to convince one of his daughters that some prince is also worth marrying to. Effectively, that means that he can add exactly one kingdom to exactly one of his daughter's list. Note that this kingdom should not be present in the daughter's list.
Polycarp LXXXIV wants to increase the number of married couples.
Unfortunately, what he doesn't have the time for is determining what entry to add. If there is no way to increase the total number of married couples then output that the marriages are already optimal. Otherwise, find such an entry that the total number of married couples increases if Polycarp LXXXIV adds it.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
For your and our convenience you are asked to answer t independent test cases.
Input
The first line contains a single integer t (1 β€ t β€ 10^5) β the number of test cases.
Then t test cases follow.
The first line of each test case contains a single integer n (1 β€ n β€ 10^5) β the number of daughters and the number of kingdoms.
Each of the next n lines contains the description of each daughter's list. The first integer k (0 β€ k β€ n) is the number of entries in the i-th daughter's list. After that k distinct integers follow g_i[1], g_i[2], ..., g_i[k] (1 β€ g_i[j] β€ n) β the indices of the kingdoms in the list in the increasing order (g_i[1] < g_i[2] < ... < g_i[k]).
It's guaranteed that the total number of daughters over all test cases does not exceed 10^5.
It's also guaranteed that the total number of kingdoms in lists over all test cases does not exceed 10^5.
Output
For each test case print the answer to it.
Print "IMPROVE" in the first line if Polycarp LXXXIV can add some kingdom to some of his daughter's list so that the total number of married couples increases. The second line then should contain two integers β the index of the daughter and the index of the kingdom Polycarp LXXXIV should add to that daughter's list.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
Otherwise the only line should contain one word "OPTIMAL".
Example
Input
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
Output
IMPROVE
4 4
IMPROVE
1 1
OPTIMAL
OPTIMAL
OPTIMAL
Note
The first test case is depicted in the statement. Adding the fourth kingdom to the list of the fourth daughter makes her marry the prince of the fourth kingdom.
In the second test case any new entry will increase the number of marriages from 0 to 1.
In the third and the fourth test cases there is no way to add an entry.
In the fifth test case there is no way to change the marriages by adding any entry.
Tags: brute force, graphs, greedy
Correct Solution:
```
t = int(input())
for _ in range(t):
n = int(input())
used = [False for i in range(n)]
v = -1
for i in range(n):
l = [int(x) - 1 for x in input().split()][1:]
for j in l:
if not used[j]:
used[j] = True
break
else:
v = i
if v == -1:
print("OPTIMAL")
else:
u = used.index(False)
print("IMPROVE")
print((v + 1) ,(u + 1))
```
| 97,121 | [
0.224365234375,
0.1796875,
0.0352783203125,
0.12127685546875,
-0.55224609375,
-0.281005859375,
-0.293701171875,
0.1663818359375,
0.438720703125,
0.62939453125,
0.8154296875,
-0.33251953125,
0.236572265625,
-0.413818359375,
-0.607421875,
0.1715087890625,
-0.5068359375,
-0.9150390625... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The King of Berland Polycarp LXXXIV has n daughters. To establish his power to the neighbouring kingdoms he wants to marry his daughters to the princes of these kingdoms. As a lucky coincidence there are n other kingdoms as well.
So Polycarp LXXXIV has enumerated his daughters from 1 to n and the kingdoms from 1 to n. For each daughter he has compiled a list of kingdoms princes of which she wanted to marry.
Polycarp LXXXIV is very busy, so he finds a couple for his daughters greedily one after another.
For the first daughter he takes the kingdom with the lowest number from her list and marries the daughter to their prince. For the second daughter he takes the kingdom with the lowest number from her list, prince of which hasn't been taken already. If there are no free princes in the list then the daughter marries nobody and Polycarp LXXXIV proceeds to the next daughter. The process ends after the n-th daughter.
For example, let there be 4 daughters and kingdoms, the lists daughters have are [2, 3], [1, 2], [3, 4], [3], respectively.
<image>
In that case daughter 1 marries the prince of kingdom 2, daughter 2 marries the prince of kingdom 1, daughter 3 marries the prince of kingdom 3, leaving daughter 4 nobody to marry to.
Actually, before starting the marriage process Polycarp LXXXIV has the time to convince one of his daughters that some prince is also worth marrying to. Effectively, that means that he can add exactly one kingdom to exactly one of his daughter's list. Note that this kingdom should not be present in the daughter's list.
Polycarp LXXXIV wants to increase the number of married couples.
Unfortunately, what he doesn't have the time for is determining what entry to add. If there is no way to increase the total number of married couples then output that the marriages are already optimal. Otherwise, find such an entry that the total number of married couples increases if Polycarp LXXXIV adds it.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
For your and our convenience you are asked to answer t independent test cases.
Input
The first line contains a single integer t (1 β€ t β€ 10^5) β the number of test cases.
Then t test cases follow.
The first line of each test case contains a single integer n (1 β€ n β€ 10^5) β the number of daughters and the number of kingdoms.
Each of the next n lines contains the description of each daughter's list. The first integer k (0 β€ k β€ n) is the number of entries in the i-th daughter's list. After that k distinct integers follow g_i[1], g_i[2], ..., g_i[k] (1 β€ g_i[j] β€ n) β the indices of the kingdoms in the list in the increasing order (g_i[1] < g_i[2] < ... < g_i[k]).
It's guaranteed that the total number of daughters over all test cases does not exceed 10^5.
It's also guaranteed that the total number of kingdoms in lists over all test cases does not exceed 10^5.
Output
For each test case print the answer to it.
Print "IMPROVE" in the first line if Polycarp LXXXIV can add some kingdom to some of his daughter's list so that the total number of married couples increases. The second line then should contain two integers β the index of the daughter and the index of the kingdom Polycarp LXXXIV should add to that daughter's list.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
Otherwise the only line should contain one word "OPTIMAL".
Example
Input
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
Output
IMPROVE
4 4
IMPROVE
1 1
OPTIMAL
OPTIMAL
OPTIMAL
Note
The first test case is depicted in the statement. Adding the fourth kingdom to the list of the fourth daughter makes her marry the prince of the fourth kingdom.
In the second test case any new entry will increase the number of marriages from 0 to 1.
In the third and the fourth test cases there is no way to add an entry.
In the fifth test case there is no way to change the marriages by adding any entry.
Tags: brute force, graphs, greedy
Correct Solution:
```
def main():
n = int(input())
prince = set()
princes = set()
for i in range(1, n + 1):
prince.add(i)
to_change = -1
for i in range(n):
lst = list(map(int, input().split()))
have = False
for k in lst[1:]:
if k in prince:
have = True
prince.remove(k)
princes.add(i)
break
if not have:
to_change = i
if to_change == -1:
print("OPTIMAL")
return
print("IMPROVE")
print(to_change + 1, min(prince))
if __name__ == "__main__":
t = int(input())
for i in range(t):
main()
```
| 97,122 | [
0.224365234375,
0.1796875,
0.0352783203125,
0.12127685546875,
-0.55224609375,
-0.281005859375,
-0.293701171875,
0.1663818359375,
0.438720703125,
0.62939453125,
0.8154296875,
-0.33251953125,
0.236572265625,
-0.413818359375,
-0.607421875,
0.1715087890625,
-0.5068359375,
-0.9150390625... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The King of Berland Polycarp LXXXIV has n daughters. To establish his power to the neighbouring kingdoms he wants to marry his daughters to the princes of these kingdoms. As a lucky coincidence there are n other kingdoms as well.
So Polycarp LXXXIV has enumerated his daughters from 1 to n and the kingdoms from 1 to n. For each daughter he has compiled a list of kingdoms princes of which she wanted to marry.
Polycarp LXXXIV is very busy, so he finds a couple for his daughters greedily one after another.
For the first daughter he takes the kingdom with the lowest number from her list and marries the daughter to their prince. For the second daughter he takes the kingdom with the lowest number from her list, prince of which hasn't been taken already. If there are no free princes in the list then the daughter marries nobody and Polycarp LXXXIV proceeds to the next daughter. The process ends after the n-th daughter.
For example, let there be 4 daughters and kingdoms, the lists daughters have are [2, 3], [1, 2], [3, 4], [3], respectively.
<image>
In that case daughter 1 marries the prince of kingdom 2, daughter 2 marries the prince of kingdom 1, daughter 3 marries the prince of kingdom 3, leaving daughter 4 nobody to marry to.
Actually, before starting the marriage process Polycarp LXXXIV has the time to convince one of his daughters that some prince is also worth marrying to. Effectively, that means that he can add exactly one kingdom to exactly one of his daughter's list. Note that this kingdom should not be present in the daughter's list.
Polycarp LXXXIV wants to increase the number of married couples.
Unfortunately, what he doesn't have the time for is determining what entry to add. If there is no way to increase the total number of married couples then output that the marriages are already optimal. Otherwise, find such an entry that the total number of married couples increases if Polycarp LXXXIV adds it.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
For your and our convenience you are asked to answer t independent test cases.
Input
The first line contains a single integer t (1 β€ t β€ 10^5) β the number of test cases.
Then t test cases follow.
The first line of each test case contains a single integer n (1 β€ n β€ 10^5) β the number of daughters and the number of kingdoms.
Each of the next n lines contains the description of each daughter's list. The first integer k (0 β€ k β€ n) is the number of entries in the i-th daughter's list. After that k distinct integers follow g_i[1], g_i[2], ..., g_i[k] (1 β€ g_i[j] β€ n) β the indices of the kingdoms in the list in the increasing order (g_i[1] < g_i[2] < ... < g_i[k]).
It's guaranteed that the total number of daughters over all test cases does not exceed 10^5.
It's also guaranteed that the total number of kingdoms in lists over all test cases does not exceed 10^5.
Output
For each test case print the answer to it.
Print "IMPROVE" in the first line if Polycarp LXXXIV can add some kingdom to some of his daughter's list so that the total number of married couples increases. The second line then should contain two integers β the index of the daughter and the index of the kingdom Polycarp LXXXIV should add to that daughter's list.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
Otherwise the only line should contain one word "OPTIMAL".
Example
Input
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
Output
IMPROVE
4 4
IMPROVE
1 1
OPTIMAL
OPTIMAL
OPTIMAL
Note
The first test case is depicted in the statement. Adding the fourth kingdom to the list of the fourth daughter makes her marry the prince of the fourth kingdom.
In the second test case any new entry will increase the number of marriages from 0 to 1.
In the third and the fourth test cases there is no way to add an entry.
In the fifth test case there is no way to change the marriages by adding any entry.
Tags: brute force, graphs, greedy
Correct Solution:
```
t=int(input())
for _ in range(t):
n=int(input())
l1=[False]*n
l2=[False]*n
for i in range(n):
l=list(map(int,input().split()))[1:]
for j in l:
if not l2[j-1]:
l1[i]=True
l2[j-1]=True
break
f1=0
f2=0
s=" "
for i in range(n):
if f1==0 and not l1[i]:
f1=1
s=str(i+1)+s
if f2==0 and not l2[i]:
f2=1
s=s+str(i+1)
if f1==1 and f2==1:
break
if f1==1 and f2==1:
print("IMPROVE")
print(s)
else:
print("OPTIMAL")
```
| 97,123 | [
0.224365234375,
0.1796875,
0.0352783203125,
0.12127685546875,
-0.55224609375,
-0.281005859375,
-0.293701171875,
0.1663818359375,
0.438720703125,
0.62939453125,
0.8154296875,
-0.33251953125,
0.236572265625,
-0.413818359375,
-0.607421875,
0.1715087890625,
-0.5068359375,
-0.9150390625... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The King of Berland Polycarp LXXXIV has n daughters. To establish his power to the neighbouring kingdoms he wants to marry his daughters to the princes of these kingdoms. As a lucky coincidence there are n other kingdoms as well.
So Polycarp LXXXIV has enumerated his daughters from 1 to n and the kingdoms from 1 to n. For each daughter he has compiled a list of kingdoms princes of which she wanted to marry.
Polycarp LXXXIV is very busy, so he finds a couple for his daughters greedily one after another.
For the first daughter he takes the kingdom with the lowest number from her list and marries the daughter to their prince. For the second daughter he takes the kingdom with the lowest number from her list, prince of which hasn't been taken already. If there are no free princes in the list then the daughter marries nobody and Polycarp LXXXIV proceeds to the next daughter. The process ends after the n-th daughter.
For example, let there be 4 daughters and kingdoms, the lists daughters have are [2, 3], [1, 2], [3, 4], [3], respectively.
<image>
In that case daughter 1 marries the prince of kingdom 2, daughter 2 marries the prince of kingdom 1, daughter 3 marries the prince of kingdom 3, leaving daughter 4 nobody to marry to.
Actually, before starting the marriage process Polycarp LXXXIV has the time to convince one of his daughters that some prince is also worth marrying to. Effectively, that means that he can add exactly one kingdom to exactly one of his daughter's list. Note that this kingdom should not be present in the daughter's list.
Polycarp LXXXIV wants to increase the number of married couples.
Unfortunately, what he doesn't have the time for is determining what entry to add. If there is no way to increase the total number of married couples then output that the marriages are already optimal. Otherwise, find such an entry that the total number of married couples increases if Polycarp LXXXIV adds it.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
For your and our convenience you are asked to answer t independent test cases.
Input
The first line contains a single integer t (1 β€ t β€ 10^5) β the number of test cases.
Then t test cases follow.
The first line of each test case contains a single integer n (1 β€ n β€ 10^5) β the number of daughters and the number of kingdoms.
Each of the next n lines contains the description of each daughter's list. The first integer k (0 β€ k β€ n) is the number of entries in the i-th daughter's list. After that k distinct integers follow g_i[1], g_i[2], ..., g_i[k] (1 β€ g_i[j] β€ n) β the indices of the kingdoms in the list in the increasing order (g_i[1] < g_i[2] < ... < g_i[k]).
It's guaranteed that the total number of daughters over all test cases does not exceed 10^5.
It's also guaranteed that the total number of kingdoms in lists over all test cases does not exceed 10^5.
Output
For each test case print the answer to it.
Print "IMPROVE" in the first line if Polycarp LXXXIV can add some kingdom to some of his daughter's list so that the total number of married couples increases. The second line then should contain two integers β the index of the daughter and the index of the kingdom Polycarp LXXXIV should add to that daughter's list.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
Otherwise the only line should contain one word "OPTIMAL".
Example
Input
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
Output
IMPROVE
4 4
IMPROVE
1 1
OPTIMAL
OPTIMAL
OPTIMAL
Note
The first test case is depicted in the statement. Adding the fourth kingdom to the list of the fourth daughter makes her marry the prince of the fourth kingdom.
In the second test case any new entry will increase the number of marriages from 0 to 1.
In the third and the fourth test cases there is no way to add an entry.
In the fifth test case there is no way to change the marriages by adding any entry.
Tags: brute force, graphs, greedy
Correct Solution:
```
import sys
input=sys.stdin.readline
from math import *
t=int(input())
while t>0:
t-=1
n=int(input())
f=[0 for i in range(n+1)]
l=[]
flag=0
for i in range(n):
a=[int(x) for x in input().split()]
a=a[1:]
a.sort()
p=0
for j in range(len(a)):
if f[a[j]]==0:
f[a[j]]=1
p=1
break
#print(f,p)
if p==0:
l.append(i)
#print(f)
if f[1:].count(0)>=1 and len(l)>0:
print("IMPROVE")
print(l[0]+1,f[1:].index(0)+1)
else:
print("OPTIMAL")
```
| 97,124 | [
0.224365234375,
0.1796875,
0.0352783203125,
0.12127685546875,
-0.55224609375,
-0.281005859375,
-0.293701171875,
0.1663818359375,
0.438720703125,
0.62939453125,
0.8154296875,
-0.33251953125,
0.236572265625,
-0.413818359375,
-0.607421875,
0.1715087890625,
-0.5068359375,
-0.9150390625... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The King of Berland Polycarp LXXXIV has n daughters. To establish his power to the neighbouring kingdoms he wants to marry his daughters to the princes of these kingdoms. As a lucky coincidence there are n other kingdoms as well.
So Polycarp LXXXIV has enumerated his daughters from 1 to n and the kingdoms from 1 to n. For each daughter he has compiled a list of kingdoms princes of which she wanted to marry.
Polycarp LXXXIV is very busy, so he finds a couple for his daughters greedily one after another.
For the first daughter he takes the kingdom with the lowest number from her list and marries the daughter to their prince. For the second daughter he takes the kingdom with the lowest number from her list, prince of which hasn't been taken already. If there are no free princes in the list then the daughter marries nobody and Polycarp LXXXIV proceeds to the next daughter. The process ends after the n-th daughter.
For example, let there be 4 daughters and kingdoms, the lists daughters have are [2, 3], [1, 2], [3, 4], [3], respectively.
<image>
In that case daughter 1 marries the prince of kingdom 2, daughter 2 marries the prince of kingdom 1, daughter 3 marries the prince of kingdom 3, leaving daughter 4 nobody to marry to.
Actually, before starting the marriage process Polycarp LXXXIV has the time to convince one of his daughters that some prince is also worth marrying to. Effectively, that means that he can add exactly one kingdom to exactly one of his daughter's list. Note that this kingdom should not be present in the daughter's list.
Polycarp LXXXIV wants to increase the number of married couples.
Unfortunately, what he doesn't have the time for is determining what entry to add. If there is no way to increase the total number of married couples then output that the marriages are already optimal. Otherwise, find such an entry that the total number of married couples increases if Polycarp LXXXIV adds it.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
For your and our convenience you are asked to answer t independent test cases.
Input
The first line contains a single integer t (1 β€ t β€ 10^5) β the number of test cases.
Then t test cases follow.
The first line of each test case contains a single integer n (1 β€ n β€ 10^5) β the number of daughters and the number of kingdoms.
Each of the next n lines contains the description of each daughter's list. The first integer k (0 β€ k β€ n) is the number of entries in the i-th daughter's list. After that k distinct integers follow g_i[1], g_i[2], ..., g_i[k] (1 β€ g_i[j] β€ n) β the indices of the kingdoms in the list in the increasing order (g_i[1] < g_i[2] < ... < g_i[k]).
It's guaranteed that the total number of daughters over all test cases does not exceed 10^5.
It's also guaranteed that the total number of kingdoms in lists over all test cases does not exceed 10^5.
Output
For each test case print the answer to it.
Print "IMPROVE" in the first line if Polycarp LXXXIV can add some kingdom to some of his daughter's list so that the total number of married couples increases. The second line then should contain two integers β the index of the daughter and the index of the kingdom Polycarp LXXXIV should add to that daughter's list.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
Otherwise the only line should contain one word "OPTIMAL".
Example
Input
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
Output
IMPROVE
4 4
IMPROVE
1 1
OPTIMAL
OPTIMAL
OPTIMAL
Note
The first test case is depicted in the statement. Adding the fourth kingdom to the list of the fourth daughter makes her marry the prince of the fourth kingdom.
In the second test case any new entry will increase the number of marriages from 0 to 1.
In the third and the fourth test cases there is no way to add an entry.
In the fifth test case there is no way to change the marriages by adding any entry.
Submitted Solution:
```
import bisect
import os
import io
from collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce
from collections import deque
import threading
# sys.setrecursionlimit(2000000)
# input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
def input():
return sys.stdin.readline().strip()
def iinput():
return int(input())
def tinput():
return input().split()
def rinput():
return map(int, tinput())
def rlinput():
return list(rinput())
mod = int(1e9)+7
def factors(n):
return set(reduce(list.__add__,
([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))
# ----------------------------------------------------
# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')
for _ in range(iinput()):
n = iinput()
val = []
for i in range(n):
a = rlinput()
a.pop(0)
val.append(a)
ans1 = -1
visited = [False]*(n+1)
for i in range(n):
flag = False
for j in val[i]:
if not visited[j]:
visited[j] = True
flag = True
break
if not flag:
ans1 = i+1
if ans1 == -1:
print('OPTIMAL')
else:
print('IMPROVE')
ans2 = -1
for i in range(1, n+1):
if not visited[i]:
ans2 = i
break
print(ans1, ans2)
```
Yes
| 97,125 | [
0.27001953125,
0.213134765625,
-0.01372528076171875,
0.1715087890625,
-0.6396484375,
-0.1712646484375,
-0.395263671875,
0.264404296875,
0.5224609375,
0.6005859375,
0.72216796875,
-0.29296875,
0.1961669921875,
-0.39208984375,
-0.671875,
0.13671875,
-0.482177734375,
-0.88427734375,
... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The King of Berland Polycarp LXXXIV has n daughters. To establish his power to the neighbouring kingdoms he wants to marry his daughters to the princes of these kingdoms. As a lucky coincidence there are n other kingdoms as well.
So Polycarp LXXXIV has enumerated his daughters from 1 to n and the kingdoms from 1 to n. For each daughter he has compiled a list of kingdoms princes of which she wanted to marry.
Polycarp LXXXIV is very busy, so he finds a couple for his daughters greedily one after another.
For the first daughter he takes the kingdom with the lowest number from her list and marries the daughter to their prince. For the second daughter he takes the kingdom with the lowest number from her list, prince of which hasn't been taken already. If there are no free princes in the list then the daughter marries nobody and Polycarp LXXXIV proceeds to the next daughter. The process ends after the n-th daughter.
For example, let there be 4 daughters and kingdoms, the lists daughters have are [2, 3], [1, 2], [3, 4], [3], respectively.
<image>
In that case daughter 1 marries the prince of kingdom 2, daughter 2 marries the prince of kingdom 1, daughter 3 marries the prince of kingdom 3, leaving daughter 4 nobody to marry to.
Actually, before starting the marriage process Polycarp LXXXIV has the time to convince one of his daughters that some prince is also worth marrying to. Effectively, that means that he can add exactly one kingdom to exactly one of his daughter's list. Note that this kingdom should not be present in the daughter's list.
Polycarp LXXXIV wants to increase the number of married couples.
Unfortunately, what he doesn't have the time for is determining what entry to add. If there is no way to increase the total number of married couples then output that the marriages are already optimal. Otherwise, find such an entry that the total number of married couples increases if Polycarp LXXXIV adds it.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
For your and our convenience you are asked to answer t independent test cases.
Input
The first line contains a single integer t (1 β€ t β€ 10^5) β the number of test cases.
Then t test cases follow.
The first line of each test case contains a single integer n (1 β€ n β€ 10^5) β the number of daughters and the number of kingdoms.
Each of the next n lines contains the description of each daughter's list. The first integer k (0 β€ k β€ n) is the number of entries in the i-th daughter's list. After that k distinct integers follow g_i[1], g_i[2], ..., g_i[k] (1 β€ g_i[j] β€ n) β the indices of the kingdoms in the list in the increasing order (g_i[1] < g_i[2] < ... < g_i[k]).
It's guaranteed that the total number of daughters over all test cases does not exceed 10^5.
It's also guaranteed that the total number of kingdoms in lists over all test cases does not exceed 10^5.
Output
For each test case print the answer to it.
Print "IMPROVE" in the first line if Polycarp LXXXIV can add some kingdom to some of his daughter's list so that the total number of married couples increases. The second line then should contain two integers β the index of the daughter and the index of the kingdom Polycarp LXXXIV should add to that daughter's list.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
Otherwise the only line should contain one word "OPTIMAL".
Example
Input
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
Output
IMPROVE
4 4
IMPROVE
1 1
OPTIMAL
OPTIMAL
OPTIMAL
Note
The first test case is depicted in the statement. Adding the fourth kingdom to the list of the fourth daughter makes her marry the prince of the fourth kingdom.
In the second test case any new entry will increase the number of marriages from 0 to 1.
In the third and the fourth test cases there is no way to add an entry.
In the fifth test case there is no way to change the marriages by adding any entry.
Submitted Solution:
```
t=int(input())
for i in range(t):
n=int(input())
arr = []
for j in range(n):
a1= input().split(" ")
arr.append([])
for c in range(len(a1)):
arr[j].append(int(a1[c]))
done = set()
remain = []
count=0
for k in range(len(arr)):
p = arr[k]
flag=0
for q in range(1,len(p)):
if(p[q] not in done):
done.add(p[q])
flag=1
count+=1
break
if(flag==0):
p.append(k)
remain.append(p)
if(count==n):
print("OPTIMAL")
continue
prince = list(done)
prince.sort()
num = -1
for w in range(len(prince)-1):
if(prince[w]!=prince[w+1]-1):
num = prince[w]+1
break
if(num==-1):
if(len(prince)>0 and prince[0]>=2):
num = 1
else:
num = len(prince)+1
add = -1
for z in range(len(remain)):
element = remain[z]
if(num not in element[1:len(element)-1]):
add = element[len(element)-1]
break
print("IMPROVE")
print(str(add+1),num)
```
Yes
| 97,126 | [
0.27001953125,
0.213134765625,
-0.01372528076171875,
0.1715087890625,
-0.6396484375,
-0.1712646484375,
-0.395263671875,
0.264404296875,
0.5224609375,
0.6005859375,
0.72216796875,
-0.29296875,
0.1961669921875,
-0.39208984375,
-0.671875,
0.13671875,
-0.482177734375,
-0.88427734375,
... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The King of Berland Polycarp LXXXIV has n daughters. To establish his power to the neighbouring kingdoms he wants to marry his daughters to the princes of these kingdoms. As a lucky coincidence there are n other kingdoms as well.
So Polycarp LXXXIV has enumerated his daughters from 1 to n and the kingdoms from 1 to n. For each daughter he has compiled a list of kingdoms princes of which she wanted to marry.
Polycarp LXXXIV is very busy, so he finds a couple for his daughters greedily one after another.
For the first daughter he takes the kingdom with the lowest number from her list and marries the daughter to their prince. For the second daughter he takes the kingdom with the lowest number from her list, prince of which hasn't been taken already. If there are no free princes in the list then the daughter marries nobody and Polycarp LXXXIV proceeds to the next daughter. The process ends after the n-th daughter.
For example, let there be 4 daughters and kingdoms, the lists daughters have are [2, 3], [1, 2], [3, 4], [3], respectively.
<image>
In that case daughter 1 marries the prince of kingdom 2, daughter 2 marries the prince of kingdom 1, daughter 3 marries the prince of kingdom 3, leaving daughter 4 nobody to marry to.
Actually, before starting the marriage process Polycarp LXXXIV has the time to convince one of his daughters that some prince is also worth marrying to. Effectively, that means that he can add exactly one kingdom to exactly one of his daughter's list. Note that this kingdom should not be present in the daughter's list.
Polycarp LXXXIV wants to increase the number of married couples.
Unfortunately, what he doesn't have the time for is determining what entry to add. If there is no way to increase the total number of married couples then output that the marriages are already optimal. Otherwise, find such an entry that the total number of married couples increases if Polycarp LXXXIV adds it.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
For your and our convenience you are asked to answer t independent test cases.
Input
The first line contains a single integer t (1 β€ t β€ 10^5) β the number of test cases.
Then t test cases follow.
The first line of each test case contains a single integer n (1 β€ n β€ 10^5) β the number of daughters and the number of kingdoms.
Each of the next n lines contains the description of each daughter's list. The first integer k (0 β€ k β€ n) is the number of entries in the i-th daughter's list. After that k distinct integers follow g_i[1], g_i[2], ..., g_i[k] (1 β€ g_i[j] β€ n) β the indices of the kingdoms in the list in the increasing order (g_i[1] < g_i[2] < ... < g_i[k]).
It's guaranteed that the total number of daughters over all test cases does not exceed 10^5.
It's also guaranteed that the total number of kingdoms in lists over all test cases does not exceed 10^5.
Output
For each test case print the answer to it.
Print "IMPROVE" in the first line if Polycarp LXXXIV can add some kingdom to some of his daughter's list so that the total number of married couples increases. The second line then should contain two integers β the index of the daughter and the index of the kingdom Polycarp LXXXIV should add to that daughter's list.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
Otherwise the only line should contain one word "OPTIMAL".
Example
Input
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
Output
IMPROVE
4 4
IMPROVE
1 1
OPTIMAL
OPTIMAL
OPTIMAL
Note
The first test case is depicted in the statement. Adding the fourth kingdom to the list of the fourth daughter makes her marry the prince of the fourth kingdom.
In the second test case any new entry will increase the number of marriages from 0 to 1.
In the third and the fourth test cases there is no way to add an entry.
In the fifth test case there is no way to change the marriages by adding any entry.
Submitted Solution:
```
t = int(input())
for j in range(t):
n = int(input())
taken_prince = [False for i in range(n)]
taken_princess = [False for i in range(n)]
for x in range(n):
wanted_prince_list = list(map(int, input().split()))
for i in wanted_prince_list[1:]:
if taken_prince[i-1] == False:
taken_prince[i-1] = True
taken_princess[x] = True
break
toprint = "OPTIMAL"
for i in range(n):
if taken_princess[i]==False:
u = taken_prince.index(False)
toprint = 'IMPROVE\n' + str(i+1) + ' ' + str(u+1)
break
print(toprint)
```
Yes
| 97,127 | [
0.27001953125,
0.213134765625,
-0.01372528076171875,
0.1715087890625,
-0.6396484375,
-0.1712646484375,
-0.395263671875,
0.264404296875,
0.5224609375,
0.6005859375,
0.72216796875,
-0.29296875,
0.1961669921875,
-0.39208984375,
-0.671875,
0.13671875,
-0.482177734375,
-0.88427734375,
... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The King of Berland Polycarp LXXXIV has n daughters. To establish his power to the neighbouring kingdoms he wants to marry his daughters to the princes of these kingdoms. As a lucky coincidence there are n other kingdoms as well.
So Polycarp LXXXIV has enumerated his daughters from 1 to n and the kingdoms from 1 to n. For each daughter he has compiled a list of kingdoms princes of which she wanted to marry.
Polycarp LXXXIV is very busy, so he finds a couple for his daughters greedily one after another.
For the first daughter he takes the kingdom with the lowest number from her list and marries the daughter to their prince. For the second daughter he takes the kingdom with the lowest number from her list, prince of which hasn't been taken already. If there are no free princes in the list then the daughter marries nobody and Polycarp LXXXIV proceeds to the next daughter. The process ends after the n-th daughter.
For example, let there be 4 daughters and kingdoms, the lists daughters have are [2, 3], [1, 2], [3, 4], [3], respectively.
<image>
In that case daughter 1 marries the prince of kingdom 2, daughter 2 marries the prince of kingdom 1, daughter 3 marries the prince of kingdom 3, leaving daughter 4 nobody to marry to.
Actually, before starting the marriage process Polycarp LXXXIV has the time to convince one of his daughters that some prince is also worth marrying to. Effectively, that means that he can add exactly one kingdom to exactly one of his daughter's list. Note that this kingdom should not be present in the daughter's list.
Polycarp LXXXIV wants to increase the number of married couples.
Unfortunately, what he doesn't have the time for is determining what entry to add. If there is no way to increase the total number of married couples then output that the marriages are already optimal. Otherwise, find such an entry that the total number of married couples increases if Polycarp LXXXIV adds it.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
For your and our convenience you are asked to answer t independent test cases.
Input
The first line contains a single integer t (1 β€ t β€ 10^5) β the number of test cases.
Then t test cases follow.
The first line of each test case contains a single integer n (1 β€ n β€ 10^5) β the number of daughters and the number of kingdoms.
Each of the next n lines contains the description of each daughter's list. The first integer k (0 β€ k β€ n) is the number of entries in the i-th daughter's list. After that k distinct integers follow g_i[1], g_i[2], ..., g_i[k] (1 β€ g_i[j] β€ n) β the indices of the kingdoms in the list in the increasing order (g_i[1] < g_i[2] < ... < g_i[k]).
It's guaranteed that the total number of daughters over all test cases does not exceed 10^5.
It's also guaranteed that the total number of kingdoms in lists over all test cases does not exceed 10^5.
Output
For each test case print the answer to it.
Print "IMPROVE" in the first line if Polycarp LXXXIV can add some kingdom to some of his daughter's list so that the total number of married couples increases. The second line then should contain two integers β the index of the daughter and the index of the kingdom Polycarp LXXXIV should add to that daughter's list.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
Otherwise the only line should contain one word "OPTIMAL".
Example
Input
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
Output
IMPROVE
4 4
IMPROVE
1 1
OPTIMAL
OPTIMAL
OPTIMAL
Note
The first test case is depicted in the statement. Adding the fourth kingdom to the list of the fourth daughter makes her marry the prince of the fourth kingdom.
In the second test case any new entry will increase the number of marriages from 0 to 1.
In the third and the fourth test cases there is no way to add an entry.
In the fifth test case there is no way to change the marriages by adding any entry.
Submitted Solution:
```
for _ in range(int(input())):
n=int(input())
dic={};m={};boo=True;ans=0
for i in range(n):
a=[int(j) for j in input().split()]
boo=True
for j in a[1:]:
if(j not in m.keys()):
m[j]=i+1
boo=False
break
if(boo):
ans=i+1
ans2=list(set(x for x in range(1,n+1))-set(m.keys()))
if(len(ans2)==0):
print('OPTIMAL')
else:
print('IMPROVE')
print(ans,ans2[0])
```
Yes
| 97,128 | [
0.27001953125,
0.213134765625,
-0.01372528076171875,
0.1715087890625,
-0.6396484375,
-0.1712646484375,
-0.395263671875,
0.264404296875,
0.5224609375,
0.6005859375,
0.72216796875,
-0.29296875,
0.1961669921875,
-0.39208984375,
-0.671875,
0.13671875,
-0.482177734375,
-0.88427734375,
... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The King of Berland Polycarp LXXXIV has n daughters. To establish his power to the neighbouring kingdoms he wants to marry his daughters to the princes of these kingdoms. As a lucky coincidence there are n other kingdoms as well.
So Polycarp LXXXIV has enumerated his daughters from 1 to n and the kingdoms from 1 to n. For each daughter he has compiled a list of kingdoms princes of which she wanted to marry.
Polycarp LXXXIV is very busy, so he finds a couple for his daughters greedily one after another.
For the first daughter he takes the kingdom with the lowest number from her list and marries the daughter to their prince. For the second daughter he takes the kingdom with the lowest number from her list, prince of which hasn't been taken already. If there are no free princes in the list then the daughter marries nobody and Polycarp LXXXIV proceeds to the next daughter. The process ends after the n-th daughter.
For example, let there be 4 daughters and kingdoms, the lists daughters have are [2, 3], [1, 2], [3, 4], [3], respectively.
<image>
In that case daughter 1 marries the prince of kingdom 2, daughter 2 marries the prince of kingdom 1, daughter 3 marries the prince of kingdom 3, leaving daughter 4 nobody to marry to.
Actually, before starting the marriage process Polycarp LXXXIV has the time to convince one of his daughters that some prince is also worth marrying to. Effectively, that means that he can add exactly one kingdom to exactly one of his daughter's list. Note that this kingdom should not be present in the daughter's list.
Polycarp LXXXIV wants to increase the number of married couples.
Unfortunately, what he doesn't have the time for is determining what entry to add. If there is no way to increase the total number of married couples then output that the marriages are already optimal. Otherwise, find such an entry that the total number of married couples increases if Polycarp LXXXIV adds it.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
For your and our convenience you are asked to answer t independent test cases.
Input
The first line contains a single integer t (1 β€ t β€ 10^5) β the number of test cases.
Then t test cases follow.
The first line of each test case contains a single integer n (1 β€ n β€ 10^5) β the number of daughters and the number of kingdoms.
Each of the next n lines contains the description of each daughter's list. The first integer k (0 β€ k β€ n) is the number of entries in the i-th daughter's list. After that k distinct integers follow g_i[1], g_i[2], ..., g_i[k] (1 β€ g_i[j] β€ n) β the indices of the kingdoms in the list in the increasing order (g_i[1] < g_i[2] < ... < g_i[k]).
It's guaranteed that the total number of daughters over all test cases does not exceed 10^5.
It's also guaranteed that the total number of kingdoms in lists over all test cases does not exceed 10^5.
Output
For each test case print the answer to it.
Print "IMPROVE" in the first line if Polycarp LXXXIV can add some kingdom to some of his daughter's list so that the total number of married couples increases. The second line then should contain two integers β the index of the daughter and the index of the kingdom Polycarp LXXXIV should add to that daughter's list.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
Otherwise the only line should contain one word "OPTIMAL".
Example
Input
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
Output
IMPROVE
4 4
IMPROVE
1 1
OPTIMAL
OPTIMAL
OPTIMAL
Note
The first test case is depicted in the statement. Adding the fourth kingdom to the list of the fourth daughter makes her marry the prince of the fourth kingdom.
In the second test case any new entry will increase the number of marriages from 0 to 1.
In the third and the fourth test cases there is no way to add an entry.
In the fifth test case there is no way to change the marriages by adding any entry.
Submitted Solution:
```
for _ in range(int(input())):
dlst = []
n = int(input())
prince = set(range(1, 1+n))
notf = None
for i in range(1, n+1):
dlst.append([int(x) for x in input().split()])
for val in dlst[-1]:
if val in prince:
prince.remove(val)
break
else:
notf = i
if len(prince) == 0:
ans = "OPTIMAL"
else:
ans = "IMPROVE\n"
ans += str(notf) + ' ' + str(prince.pop())
print(ans)
```
No
| 97,129 | [
0.27001953125,
0.213134765625,
-0.01372528076171875,
0.1715087890625,
-0.6396484375,
-0.1712646484375,
-0.395263671875,
0.264404296875,
0.5224609375,
0.6005859375,
0.72216796875,
-0.29296875,
0.1961669921875,
-0.39208984375,
-0.671875,
0.13671875,
-0.482177734375,
-0.88427734375,
... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The King of Berland Polycarp LXXXIV has n daughters. To establish his power to the neighbouring kingdoms he wants to marry his daughters to the princes of these kingdoms. As a lucky coincidence there are n other kingdoms as well.
So Polycarp LXXXIV has enumerated his daughters from 1 to n and the kingdoms from 1 to n. For each daughter he has compiled a list of kingdoms princes of which she wanted to marry.
Polycarp LXXXIV is very busy, so he finds a couple for his daughters greedily one after another.
For the first daughter he takes the kingdom with the lowest number from her list and marries the daughter to their prince. For the second daughter he takes the kingdom with the lowest number from her list, prince of which hasn't been taken already. If there are no free princes in the list then the daughter marries nobody and Polycarp LXXXIV proceeds to the next daughter. The process ends after the n-th daughter.
For example, let there be 4 daughters and kingdoms, the lists daughters have are [2, 3], [1, 2], [3, 4], [3], respectively.
<image>
In that case daughter 1 marries the prince of kingdom 2, daughter 2 marries the prince of kingdom 1, daughter 3 marries the prince of kingdom 3, leaving daughter 4 nobody to marry to.
Actually, before starting the marriage process Polycarp LXXXIV has the time to convince one of his daughters that some prince is also worth marrying to. Effectively, that means that he can add exactly one kingdom to exactly one of his daughter's list. Note that this kingdom should not be present in the daughter's list.
Polycarp LXXXIV wants to increase the number of married couples.
Unfortunately, what he doesn't have the time for is determining what entry to add. If there is no way to increase the total number of married couples then output that the marriages are already optimal. Otherwise, find such an entry that the total number of married couples increases if Polycarp LXXXIV adds it.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
For your and our convenience you are asked to answer t independent test cases.
Input
The first line contains a single integer t (1 β€ t β€ 10^5) β the number of test cases.
Then t test cases follow.
The first line of each test case contains a single integer n (1 β€ n β€ 10^5) β the number of daughters and the number of kingdoms.
Each of the next n lines contains the description of each daughter's list. The first integer k (0 β€ k β€ n) is the number of entries in the i-th daughter's list. After that k distinct integers follow g_i[1], g_i[2], ..., g_i[k] (1 β€ g_i[j] β€ n) β the indices of the kingdoms in the list in the increasing order (g_i[1] < g_i[2] < ... < g_i[k]).
It's guaranteed that the total number of daughters over all test cases does not exceed 10^5.
It's also guaranteed that the total number of kingdoms in lists over all test cases does not exceed 10^5.
Output
For each test case print the answer to it.
Print "IMPROVE" in the first line if Polycarp LXXXIV can add some kingdom to some of his daughter's list so that the total number of married couples increases. The second line then should contain two integers β the index of the daughter and the index of the kingdom Polycarp LXXXIV should add to that daughter's list.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
Otherwise the only line should contain one word "OPTIMAL".
Example
Input
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
Output
IMPROVE
4 4
IMPROVE
1 1
OPTIMAL
OPTIMAL
OPTIMAL
Note
The first test case is depicted in the statement. Adding the fourth kingdom to the list of the fourth daughter makes her marry the prince of the fourth kingdom.
In the second test case any new entry will increase the number of marriages from 0 to 1.
In the third and the fourth test cases there is no way to add an entry.
In the fifth test case there is no way to change the marriages by adding any entry.
Submitted Solution:
```
import sys
for _ in range(int(sys.stdin.readline())):
a=[]
b=int(sys.stdin.readline())
d=0
for i in range(b):
c=sys.stdin.readline()
if len(c)==1:
a.append(list())
else:
a.append(list(map(int,c.split())))
c=[i for i in range(1,b+1)]
for i in range(b):
for k in range(1,a[i][0]+1):
if a[i][k] in c:
c.remove(a[i][k])
break
elif k == a[i][0]:
d=i
if len(c)==0:
sys.stdout.write('OPTIMAL\n')
else:
sys.stdout.write('IMPROVE\n')
sys.stdout.write('{} {}\n'.format(d+1,c[0]))
```
No
| 97,130 | [
0.27001953125,
0.213134765625,
-0.01372528076171875,
0.1715087890625,
-0.6396484375,
-0.1712646484375,
-0.395263671875,
0.264404296875,
0.5224609375,
0.6005859375,
0.72216796875,
-0.29296875,
0.1961669921875,
-0.39208984375,
-0.671875,
0.13671875,
-0.482177734375,
-0.88427734375,
... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The King of Berland Polycarp LXXXIV has n daughters. To establish his power to the neighbouring kingdoms he wants to marry his daughters to the princes of these kingdoms. As a lucky coincidence there are n other kingdoms as well.
So Polycarp LXXXIV has enumerated his daughters from 1 to n and the kingdoms from 1 to n. For each daughter he has compiled a list of kingdoms princes of which she wanted to marry.
Polycarp LXXXIV is very busy, so he finds a couple for his daughters greedily one after another.
For the first daughter he takes the kingdom with the lowest number from her list and marries the daughter to their prince. For the second daughter he takes the kingdom with the lowest number from her list, prince of which hasn't been taken already. If there are no free princes in the list then the daughter marries nobody and Polycarp LXXXIV proceeds to the next daughter. The process ends after the n-th daughter.
For example, let there be 4 daughters and kingdoms, the lists daughters have are [2, 3], [1, 2], [3, 4], [3], respectively.
<image>
In that case daughter 1 marries the prince of kingdom 2, daughter 2 marries the prince of kingdom 1, daughter 3 marries the prince of kingdom 3, leaving daughter 4 nobody to marry to.
Actually, before starting the marriage process Polycarp LXXXIV has the time to convince one of his daughters that some prince is also worth marrying to. Effectively, that means that he can add exactly one kingdom to exactly one of his daughter's list. Note that this kingdom should not be present in the daughter's list.
Polycarp LXXXIV wants to increase the number of married couples.
Unfortunately, what he doesn't have the time for is determining what entry to add. If there is no way to increase the total number of married couples then output that the marriages are already optimal. Otherwise, find such an entry that the total number of married couples increases if Polycarp LXXXIV adds it.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
For your and our convenience you are asked to answer t independent test cases.
Input
The first line contains a single integer t (1 β€ t β€ 10^5) β the number of test cases.
Then t test cases follow.
The first line of each test case contains a single integer n (1 β€ n β€ 10^5) β the number of daughters and the number of kingdoms.
Each of the next n lines contains the description of each daughter's list. The first integer k (0 β€ k β€ n) is the number of entries in the i-th daughter's list. After that k distinct integers follow g_i[1], g_i[2], ..., g_i[k] (1 β€ g_i[j] β€ n) β the indices of the kingdoms in the list in the increasing order (g_i[1] < g_i[2] < ... < g_i[k]).
It's guaranteed that the total number of daughters over all test cases does not exceed 10^5.
It's also guaranteed that the total number of kingdoms in lists over all test cases does not exceed 10^5.
Output
For each test case print the answer to it.
Print "IMPROVE" in the first line if Polycarp LXXXIV can add some kingdom to some of his daughter's list so that the total number of married couples increases. The second line then should contain two integers β the index of the daughter and the index of the kingdom Polycarp LXXXIV should add to that daughter's list.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
Otherwise the only line should contain one word "OPTIMAL".
Example
Input
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
Output
IMPROVE
4 4
IMPROVE
1 1
OPTIMAL
OPTIMAL
OPTIMAL
Note
The first test case is depicted in the statement. Adding the fourth kingdom to the list of the fourth daughter makes her marry the prince of the fourth kingdom.
In the second test case any new entry will increase the number of marriages from 0 to 1.
In the third and the fourth test cases there is no way to add an entry.
In the fifth test case there is no way to change the marriages by adding any entry.
Submitted Solution:
```
t = int(input())
for i in range(t):
n = int(input())
pr = [0 for j in range(n+1)]
dr = [0 for j in range(n+1)]
if_good = 0
for j in range(1, n+1):
if_good = 0
flag = 0
dr[j] = list(map(int, input().split()))
if dr[j][0] == 0:
print(dr)
print('IMPROVE')
for p in range(1, n+1):
if pr[p]==0:
print(j, p)
flag = 1
break
if flag == 1:
break
else:
for p in dr[j][1:]:
if pr[p]==0:
pr[p]=1
flag = 1
if_good = 1
break
if (flag == 0):
for p in range(1, n+1):
if pr[p]==0:
print('IMPROVE')
print(j, p)
flag = 1
break
if if_good== 1:
print('OPTIMAL')
```
No
| 97,131 | [
0.27001953125,
0.213134765625,
-0.01372528076171875,
0.1715087890625,
-0.6396484375,
-0.1712646484375,
-0.395263671875,
0.264404296875,
0.5224609375,
0.6005859375,
0.72216796875,
-0.29296875,
0.1961669921875,
-0.39208984375,
-0.671875,
0.13671875,
-0.482177734375,
-0.88427734375,
... | 24 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The King of Berland Polycarp LXXXIV has n daughters. To establish his power to the neighbouring kingdoms he wants to marry his daughters to the princes of these kingdoms. As a lucky coincidence there are n other kingdoms as well.
So Polycarp LXXXIV has enumerated his daughters from 1 to n and the kingdoms from 1 to n. For each daughter he has compiled a list of kingdoms princes of which she wanted to marry.
Polycarp LXXXIV is very busy, so he finds a couple for his daughters greedily one after another.
For the first daughter he takes the kingdom with the lowest number from her list and marries the daughter to their prince. For the second daughter he takes the kingdom with the lowest number from her list, prince of which hasn't been taken already. If there are no free princes in the list then the daughter marries nobody and Polycarp LXXXIV proceeds to the next daughter. The process ends after the n-th daughter.
For example, let there be 4 daughters and kingdoms, the lists daughters have are [2, 3], [1, 2], [3, 4], [3], respectively.
<image>
In that case daughter 1 marries the prince of kingdom 2, daughter 2 marries the prince of kingdom 1, daughter 3 marries the prince of kingdom 3, leaving daughter 4 nobody to marry to.
Actually, before starting the marriage process Polycarp LXXXIV has the time to convince one of his daughters that some prince is also worth marrying to. Effectively, that means that he can add exactly one kingdom to exactly one of his daughter's list. Note that this kingdom should not be present in the daughter's list.
Polycarp LXXXIV wants to increase the number of married couples.
Unfortunately, what he doesn't have the time for is determining what entry to add. If there is no way to increase the total number of married couples then output that the marriages are already optimal. Otherwise, find such an entry that the total number of married couples increases if Polycarp LXXXIV adds it.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
For your and our convenience you are asked to answer t independent test cases.
Input
The first line contains a single integer t (1 β€ t β€ 10^5) β the number of test cases.
Then t test cases follow.
The first line of each test case contains a single integer n (1 β€ n β€ 10^5) β the number of daughters and the number of kingdoms.
Each of the next n lines contains the description of each daughter's list. The first integer k (0 β€ k β€ n) is the number of entries in the i-th daughter's list. After that k distinct integers follow g_i[1], g_i[2], ..., g_i[k] (1 β€ g_i[j] β€ n) β the indices of the kingdoms in the list in the increasing order (g_i[1] < g_i[2] < ... < g_i[k]).
It's guaranteed that the total number of daughters over all test cases does not exceed 10^5.
It's also guaranteed that the total number of kingdoms in lists over all test cases does not exceed 10^5.
Output
For each test case print the answer to it.
Print "IMPROVE" in the first line if Polycarp LXXXIV can add some kingdom to some of his daughter's list so that the total number of married couples increases. The second line then should contain two integers β the index of the daughter and the index of the kingdom Polycarp LXXXIV should add to that daughter's list.
If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.
Otherwise the only line should contain one word "OPTIMAL".
Example
Input
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
Output
IMPROVE
4 4
IMPROVE
1 1
OPTIMAL
OPTIMAL
OPTIMAL
Note
The first test case is depicted in the statement. Adding the fourth kingdom to the list of the fourth daughter makes her marry the prince of the fourth kingdom.
In the second test case any new entry will increase the number of marriages from 0 to 1.
In the third and the fourth test cases there is no way to add an entry.
In the fifth test case there is no way to change the marriages by adding any entry.
Submitted Solution:
```
t=int(input())
while t>0:
t-=1
n=int(input())
li=[]
for i in range(n):
x=map(int,input().split())
li.append(x)
a=[]
b=[]
for i in range(n):
for j in li[i]:
if j not in a and j!=0:
a.append(j)
b.append(i+1)
break
#print(a)
#print(b)
z=0
for i in range(1,n+1):
if i not in b:
z=i
break
for i in range(1,n+1):
if i not in a:
print('IMPROVE')
print(z,i)
break
elif i==n and i in a:
print('OPTIMAL')
```
No
| 97,132 | [
0.27001953125,
0.213134765625,
-0.01372528076171875,
0.1715087890625,
-0.6396484375,
-0.1712646484375,
-0.395263671875,
0.264404296875,
0.5224609375,
0.6005859375,
0.72216796875,
-0.29296875,
0.1961669921875,
-0.39208984375,
-0.671875,
0.13671875,
-0.482177734375,
-0.88427734375,
... | 24 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus has been working in the analytic department of the "F.R.A.U.D." company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value ai, the company's profit on the i-th day. If ai is negative, then the company suffered losses on the i-th day.
Polycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.
It is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (ai < 0), he loses his temper and his wrath is terrible.
Therefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.
Write a program that, given sequence ai, will print the minimum number of folders.
Input
The first line contains integer n (1 β€ n β€ 100), n is the number of days. The second line contains a sequence of integers a1, a2, ..., an (|ai| β€ 100), where ai means the company profit on the i-th day. It is possible that the company has no days with the negative ai.
Output
Print an integer k β the required minimum number of folders. In the second line print a sequence of integers b1, b2, ..., bk, where bj is the number of day reports in the j-th folder.
If there are multiple ways to sort the reports into k days, print any of them.
Examples
Input
11
1 2 3 -4 -5 -6 5 -5 -6 -7 6
Output
3
5 3 3
Input
5
0 -1 100 -1 0
Output
1
5
Note
Here goes a way to sort the reports from the first sample into three folders:
1 2 3 -4 -5 | -6 5 -5 | -6 -7 6
In the second sample you can put all five reports in one folder.
Tags: greedy
Correct Solution:
```
n=int(input())
l=list(map(int,input().split()))
c,x=0,0
d=[]
for i in range(n):
if(l[i]<0):
c=c+1
x=x+1
if(x==2):
d.append(c)
x=0
c=0
else:
c=c+1
if(d==[]):
d.append(c)
c=0
if(c>0 and x==0):
d[-1]+=c
elif(c>0 and x!=0):
d.append(c)
print(len(d))
print(*d)
```
| 97,267 | [
0.4033203125,
0.359375,
0.257080078125,
-0.0595703125,
-0.330810546875,
-0.1614990234375,
-0.52880859375,
0.036895751953125,
-0.0439453125,
0.75439453125,
0.65625,
-0.197998046875,
0.00933074951171875,
-0.39013671875,
-0.52978515625,
-0.1575927734375,
-0.4482421875,
-0.364990234375... | 24 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.