message
stringlengths
2
65.1k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
0
108k
cluster
float64
14
14
__index_level_0__
int64
0
217k
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Gaius Julius Caesar, a famous general, loved to line up his soldiers. Overall the army had n1 footmen and n2 horsemen. Caesar thought that an arrangement is not beautiful if somewhere in the line there are strictly more that k1 footmen standing successively one after another, or there are strictly more than k2 horsemen standing successively one after another. Find the number of beautiful arrangements of the soldiers. Note that all n1 + n2 warriors should be present at each arrangement. All footmen are considered indistinguishable among themselves. Similarly, all horsemen are considered indistinguishable among themselves. Input The only line contains four space-separated integers n1, n2, k1, k2 (1 ≀ n1, n2 ≀ 100, 1 ≀ k1, k2 ≀ 10) which represent how many footmen and horsemen there are and the largest acceptable number of footmen and horsemen standing in succession, correspondingly. Output Print the number of beautiful arrangements of the army modulo 100000000 (108). That is, print the number of such ways to line up the soldiers, that no more than k1 footmen stand successively, and no more than k2 horsemen stand successively. Examples Input 2 1 1 10 Output 1 Input 2 3 1 2 Output 5 Input 2 4 1 1 Output 0 Note Let's mark a footman as 1, and a horseman as 2. In the first sample the only beautiful line-up is: 121 In the second sample 5 beautiful line-ups exist: 12122, 12212, 21212, 21221, 22121 Submitted Solution: ``` t = 10**8 n1, n2, k1, k2 = map(int, input().split()) dp = [[[0 for i in range(2)]for i in range(n2 + 1)]for i in range(n1 + 1)] for i in range(min(n1 + 1, k1 + 1)): dp[i][0][0] = 1 for i in range(min(n2 + 1, k2 + 1)): dp[0][i][1] = 1 for i in range(1, n1 + 1): for j in range(1, n2 + 1): for k in range(1, min(k1, i) + 1): dp[i][j][0] = ((dp[i][j][0] % t) + (dp[i - k][j][1] % t)) % t for k in range(1, min(k2, j) + 1): dp[i][j][1] = ((dp[i][j][1] % t) + (dp[i][j - k][0] % t)) % t print((dp[n1][n2][0] + dp[n1][n2][1]) % t) ```
instruction
0
25,664
14
51,328
Yes
output
1
25,664
14
51,329
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Gaius Julius Caesar, a famous general, loved to line up his soldiers. Overall the army had n1 footmen and n2 horsemen. Caesar thought that an arrangement is not beautiful if somewhere in the line there are strictly more that k1 footmen standing successively one after another, or there are strictly more than k2 horsemen standing successively one after another. Find the number of beautiful arrangements of the soldiers. Note that all n1 + n2 warriors should be present at each arrangement. All footmen are considered indistinguishable among themselves. Similarly, all horsemen are considered indistinguishable among themselves. Input The only line contains four space-separated integers n1, n2, k1, k2 (1 ≀ n1, n2 ≀ 100, 1 ≀ k1, k2 ≀ 10) which represent how many footmen and horsemen there are and the largest acceptable number of footmen and horsemen standing in succession, correspondingly. Output Print the number of beautiful arrangements of the army modulo 100000000 (108). That is, print the number of such ways to line up the soldiers, that no more than k1 footmen stand successively, and no more than k2 horsemen stand successively. Examples Input 2 1 1 10 Output 1 Input 2 3 1 2 Output 5 Input 2 4 1 1 Output 0 Note Let's mark a footman as 1, and a horseman as 2. In the first sample the only beautiful line-up is: 121 In the second sample 5 beautiful line-ups exist: 12122, 12212, 21212, 21221, 22121 Submitted Solution: ``` import math from os import curdir, startfile import random from queue import Queue import time import heapq import sys def main(n1,n2,k1,k2): dp=[[[0 for i in range(2)] for j in range(n2+1)] for k in range(n1+1)] dp[0][0][1]=1 dp[0][0][0]=1 for i in range(0,len(dp)): for j in range(0,len(dp[0])): for k in range(0,len(dp[0][0])): if k==0: for l in range(1,min(k1+1,i+1)): dp[i][j][k]+=dp[i-l][j][1] if k==1: for l in range(1,min(k2+1,j+1)): dp[i][j][k]+=dp[i][j-l][0] return sum(dp[-1][-1]) n1,n2,k1,k2=list(map(int,input().split())) print(main(n1,n2,k1,k2)) ```
instruction
0
25,665
14
51,330
No
output
1
25,665
14
51,331
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Gaius Julius Caesar, a famous general, loved to line up his soldiers. Overall the army had n1 footmen and n2 horsemen. Caesar thought that an arrangement is not beautiful if somewhere in the line there are strictly more that k1 footmen standing successively one after another, or there are strictly more than k2 horsemen standing successively one after another. Find the number of beautiful arrangements of the soldiers. Note that all n1 + n2 warriors should be present at each arrangement. All footmen are considered indistinguishable among themselves. Similarly, all horsemen are considered indistinguishable among themselves. Input The only line contains four space-separated integers n1, n2, k1, k2 (1 ≀ n1, n2 ≀ 100, 1 ≀ k1, k2 ≀ 10) which represent how many footmen and horsemen there are and the largest acceptable number of footmen and horsemen standing in succession, correspondingly. Output Print the number of beautiful arrangements of the army modulo 100000000 (108). That is, print the number of such ways to line up the soldiers, that no more than k1 footmen stand successively, and no more than k2 horsemen stand successively. Examples Input 2 1 1 10 Output 1 Input 2 3 1 2 Output 5 Input 2 4 1 1 Output 0 Note Let's mark a footman as 1, and a horseman as 2. In the first sample the only beautiful line-up is: 121 In the second sample 5 beautiful line-ups exist: 12122, 12212, 21212, 21221, 22121 Submitted Solution: ``` import sys from math import sqrt import math input = sys.stdin.readline ############ ---- Input Functions ---- ############ def inp(): return(int(input())) def inlt(): return(list(map(int,input().split()))) def insr(): s = input() return(list(s[:len(s) - 1])) def invr(): return(map(int,input().split())) limit_f = 0; limit_h = 0 mod = 100000000 dp = [[[[ -1 for i in range(11)] for j in range(11)] for k in range(101)] for l in range(101)] def solve(f,h,k1,k2): x=0;y=0 if f+h==0: return 1 if dp[f][h][k1][k2] != -1: return dp[f][h][k1][k2] #insert f if f>0 and k1>0: x = solve(f-1,h,k1-1,limit_h) #insert h if h>0 and k2>0: y = solve(f,h-1,limit_f,k2-1) dp[f][h][k1][k2] = (x+y)%mod return x+y n1,n2,limit_f,limit_h = map(int,input().split()) res = solve(n1,n2,limit_f,limit_h) print(res) ```
instruction
0
25,666
14
51,332
No
output
1
25,666
14
51,333
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Gaius Julius Caesar, a famous general, loved to line up his soldiers. Overall the army had n1 footmen and n2 horsemen. Caesar thought that an arrangement is not beautiful if somewhere in the line there are strictly more that k1 footmen standing successively one after another, or there are strictly more than k2 horsemen standing successively one after another. Find the number of beautiful arrangements of the soldiers. Note that all n1 + n2 warriors should be present at each arrangement. All footmen are considered indistinguishable among themselves. Similarly, all horsemen are considered indistinguishable among themselves. Input The only line contains four space-separated integers n1, n2, k1, k2 (1 ≀ n1, n2 ≀ 100, 1 ≀ k1, k2 ≀ 10) which represent how many footmen and horsemen there are and the largest acceptable number of footmen and horsemen standing in succession, correspondingly. Output Print the number of beautiful arrangements of the army modulo 100000000 (108). That is, print the number of such ways to line up the soldiers, that no more than k1 footmen stand successively, and no more than k2 horsemen stand successively. Examples Input 2 1 1 10 Output 1 Input 2 3 1 2 Output 5 Input 2 4 1 1 Output 0 Note Let's mark a footman as 1, and a horseman as 2. In the first sample the only beautiful line-up is: 121 In the second sample 5 beautiful line-ups exist: 12122, 12212, 21212, 21221, 22121 Submitted Solution: ``` # cook your dish here import math n1,n2,k1,k2=map(int,input().split()) y=0 z=0 x=math.factorial(n1+n2)//(math.factorial(n1)*math.factorial(n2)) if n1>=k1: y=math.factorial(n1)//(math.factorial(k1)*math.factorial(n1-k1)) if n2>=k2: z=math.factorial(n2)//(math.factorial(k2)*math.factorial(n2-k2)) if (n1+n2)<=2*(k1+k2): print(x-y-z) else: print(0) ```
instruction
0
25,667
14
51,334
No
output
1
25,667
14
51,335
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Gaius Julius Caesar, a famous general, loved to line up his soldiers. Overall the army had n1 footmen and n2 horsemen. Caesar thought that an arrangement is not beautiful if somewhere in the line there are strictly more that k1 footmen standing successively one after another, or there are strictly more than k2 horsemen standing successively one after another. Find the number of beautiful arrangements of the soldiers. Note that all n1 + n2 warriors should be present at each arrangement. All footmen are considered indistinguishable among themselves. Similarly, all horsemen are considered indistinguishable among themselves. Input The only line contains four space-separated integers n1, n2, k1, k2 (1 ≀ n1, n2 ≀ 100, 1 ≀ k1, k2 ≀ 10) which represent how many footmen and horsemen there are and the largest acceptable number of footmen and horsemen standing in succession, correspondingly. Output Print the number of beautiful arrangements of the army modulo 100000000 (108). That is, print the number of such ways to line up the soldiers, that no more than k1 footmen stand successively, and no more than k2 horsemen stand successively. Examples Input 2 1 1 10 Output 1 Input 2 3 1 2 Output 5 Input 2 4 1 1 Output 0 Note Let's mark a footman as 1, and a horseman as 2. In the first sample the only beautiful line-up is: 121 In the second sample 5 beautiful line-ups exist: 12122, 12212, 21212, 21221, 22121 Submitted Solution: ``` def isPossible(n1, n2, k1, k2, isHorse, dp): if n1 <=0 or n2 <= 0 : if (n2 == 0 or n1 == 0) and n1 <= k1 and n2 <= k2 : return 1 else : return 0 elif (n1, n2, isHorse) not in dp : dp[n1, n2, isHorse] = 0 for i in range(1, 1+min(n1 if isHorse else n2, k1 if isHorse else k2)): dp[n1, n2, isHorse] += isPossible(n1 - i if isHorse else n1, n2 - i if not isHorse else n2, k1, k2, not isHorse, dp) return dp[n1, n2, isHorse] n1, n2, k1, k2 = (int(var) for var in input().split()) dp = {} print(isPossible(n1, n2, k1, k2, True, dp) + isPossible(n1, n2, k1, k2, False, dp)) # print(dp) ```
instruction
0
25,668
14
51,336
No
output
1
25,668
14
51,337
Provide tags and a correct Python 3 solution for this coding contest problem. Valera runs a 24/7 fast food cafe. He magically learned that next day n people will visit his cafe. For each person we know the arrival time: the i-th person comes exactly at hi hours mi minutes. The cafe spends less than a minute to serve each client, but if a client comes in and sees that there is no free cash, than he doesn't want to wait and leaves the cafe immediately. Valera is very greedy, so he wants to serve all n customers next day (and get more profit). However, for that he needs to ensure that at each moment of time the number of working cashes is no less than the number of clients in the cafe. Help Valera count the minimum number of cashes to work at his cafe next day, so that they can serve all visitors. Input The first line contains a single integer n (1 ≀ n ≀ 105), that is the number of cafe visitors. Each of the following n lines has two space-separated integers hi and mi (0 ≀ hi ≀ 23; 0 ≀ mi ≀ 59), representing the time when the i-th person comes into the cafe. Note that the time is given in the chronological order. All time is given within one 24-hour period. Output Print a single integer β€” the minimum number of cashes, needed to serve all clients next day. Examples Input 4 8 0 8 10 8 10 8 45 Output 2 Input 3 0 12 10 11 22 22 Output 1 Note In the first sample it is not enough one cash to serve all clients, because two visitors will come into cafe in 8:10. Therefore, if there will be one cash in cafe, then one customer will be served by it, and another one will not wait and will go away. In the second sample all visitors will come in different times, so it will be enough one cash.
instruction
0
25,898
14
51,796
Tags: implementation Correct Solution: ``` from collections import Counter n = int(input()) lookup = [input() for _ in range(n)] lookup=Counter(lookup).most_common() print(lookup[0][1]) ```
output
1
25,898
14
51,797
Provide tags and a correct Python 3 solution for this coding contest problem. Valera runs a 24/7 fast food cafe. He magically learned that next day n people will visit his cafe. For each person we know the arrival time: the i-th person comes exactly at hi hours mi minutes. The cafe spends less than a minute to serve each client, but if a client comes in and sees that there is no free cash, than he doesn't want to wait and leaves the cafe immediately. Valera is very greedy, so he wants to serve all n customers next day (and get more profit). However, for that he needs to ensure that at each moment of time the number of working cashes is no less than the number of clients in the cafe. Help Valera count the minimum number of cashes to work at his cafe next day, so that they can serve all visitors. Input The first line contains a single integer n (1 ≀ n ≀ 105), that is the number of cafe visitors. Each of the following n lines has two space-separated integers hi and mi (0 ≀ hi ≀ 23; 0 ≀ mi ≀ 59), representing the time when the i-th person comes into the cafe. Note that the time is given in the chronological order. All time is given within one 24-hour period. Output Print a single integer β€” the minimum number of cashes, needed to serve all clients next day. Examples Input 4 8 0 8 10 8 10 8 45 Output 2 Input 3 0 12 10 11 22 22 Output 1 Note In the first sample it is not enough one cash to serve all clients, because two visitors will come into cafe in 8:10. Therefore, if there will be one cash in cafe, then one customer will be served by it, and another one will not wait and will go away. In the second sample all visitors will come in different times, so it will be enough one cash.
instruction
0
25,899
14
51,798
Tags: implementation Correct Solution: ``` import collections n = int(input()) print(max(collections.Counter(input() for _ in range(n)).values())) ```
output
1
25,899
14
51,799
Provide tags and a correct Python 3 solution for this coding contest problem. Valera runs a 24/7 fast food cafe. He magically learned that next day n people will visit his cafe. For each person we know the arrival time: the i-th person comes exactly at hi hours mi minutes. The cafe spends less than a minute to serve each client, but if a client comes in and sees that there is no free cash, than he doesn't want to wait and leaves the cafe immediately. Valera is very greedy, so he wants to serve all n customers next day (and get more profit). However, for that he needs to ensure that at each moment of time the number of working cashes is no less than the number of clients in the cafe. Help Valera count the minimum number of cashes to work at his cafe next day, so that they can serve all visitors. Input The first line contains a single integer n (1 ≀ n ≀ 105), that is the number of cafe visitors. Each of the following n lines has two space-separated integers hi and mi (0 ≀ hi ≀ 23; 0 ≀ mi ≀ 59), representing the time when the i-th person comes into the cafe. Note that the time is given in the chronological order. All time is given within one 24-hour period. Output Print a single integer β€” the minimum number of cashes, needed to serve all clients next day. Examples Input 4 8 0 8 10 8 10 8 45 Output 2 Input 3 0 12 10 11 22 22 Output 1 Note In the first sample it is not enough one cash to serve all clients, because two visitors will come into cafe in 8:10. Therefore, if there will be one cash in cafe, then one customer will be served by it, and another one will not wait and will go away. In the second sample all visitors will come in different times, so it will be enough one cash.
instruction
0
25,900
14
51,800
Tags: implementation Correct Solution: ``` n=int(input()) l=[] max=1 l2=[] cnt=1 for i in range(n): d=list(map(int,input().split())) if(d==l2): cnt+=1 if(max<cnt): max=cnt else: cnt=1 l2=d print(max) ```
output
1
25,900
14
51,801
Provide tags and a correct Python 3 solution for this coding contest problem. Valera runs a 24/7 fast food cafe. He magically learned that next day n people will visit his cafe. For each person we know the arrival time: the i-th person comes exactly at hi hours mi minutes. The cafe spends less than a minute to serve each client, but if a client comes in and sees that there is no free cash, than he doesn't want to wait and leaves the cafe immediately. Valera is very greedy, so he wants to serve all n customers next day (and get more profit). However, for that he needs to ensure that at each moment of time the number of working cashes is no less than the number of clients in the cafe. Help Valera count the minimum number of cashes to work at his cafe next day, so that they can serve all visitors. Input The first line contains a single integer n (1 ≀ n ≀ 105), that is the number of cafe visitors. Each of the following n lines has two space-separated integers hi and mi (0 ≀ hi ≀ 23; 0 ≀ mi ≀ 59), representing the time when the i-th person comes into the cafe. Note that the time is given in the chronological order. All time is given within one 24-hour period. Output Print a single integer β€” the minimum number of cashes, needed to serve all clients next day. Examples Input 4 8 0 8 10 8 10 8 45 Output 2 Input 3 0 12 10 11 22 22 Output 1 Note In the first sample it is not enough one cash to serve all clients, because two visitors will come into cafe in 8:10. Therefore, if there will be one cash in cafe, then one customer will be served by it, and another one will not wait and will go away. In the second sample all visitors will come in different times, so it will be enough one cash.
instruction
0
25,901
14
51,802
Tags: implementation Correct Solution: ``` d={} for _ in [0]*int(input()): s=input() if s in d:d[s]+=1 else:d[s]=1 print(max(d.values())) ```
output
1
25,901
14
51,803
Provide tags and a correct Python 3 solution for this coding contest problem. Valera runs a 24/7 fast food cafe. He magically learned that next day n people will visit his cafe. For each person we know the arrival time: the i-th person comes exactly at hi hours mi minutes. The cafe spends less than a minute to serve each client, but if a client comes in and sees that there is no free cash, than he doesn't want to wait and leaves the cafe immediately. Valera is very greedy, so he wants to serve all n customers next day (and get more profit). However, for that he needs to ensure that at each moment of time the number of working cashes is no less than the number of clients in the cafe. Help Valera count the minimum number of cashes to work at his cafe next day, so that they can serve all visitors. Input The first line contains a single integer n (1 ≀ n ≀ 105), that is the number of cafe visitors. Each of the following n lines has two space-separated integers hi and mi (0 ≀ hi ≀ 23; 0 ≀ mi ≀ 59), representing the time when the i-th person comes into the cafe. Note that the time is given in the chronological order. All time is given within one 24-hour period. Output Print a single integer β€” the minimum number of cashes, needed to serve all clients next day. Examples Input 4 8 0 8 10 8 10 8 45 Output 2 Input 3 0 12 10 11 22 22 Output 1 Note In the first sample it is not enough one cash to serve all clients, because two visitors will come into cafe in 8:10. Therefore, if there will be one cash in cafe, then one customer will be served by it, and another one will not wait and will go away. In the second sample all visitors will come in different times, so it will be enough one cash.
instruction
0
25,902
14
51,804
Tags: implementation Correct Solution: ``` n = int(input()) h_l = [] m_l = [] for i in range(n): h, m = map(int, input().split()) h_l.append(h) m_l.append(m) count = 1 max_c = 1 for i in range(n - 1): if h_l[i] == h_l[i + 1] and m_l[i] == m_l[i + 1]: count += 1 else: max_c = max(max_c, count) count = 1 max_c = max(max_c, count) print(max_c) ```
output
1
25,902
14
51,805
Provide tags and a correct Python 3 solution for this coding contest problem. Valera runs a 24/7 fast food cafe. He magically learned that next day n people will visit his cafe. For each person we know the arrival time: the i-th person comes exactly at hi hours mi minutes. The cafe spends less than a minute to serve each client, but if a client comes in and sees that there is no free cash, than he doesn't want to wait and leaves the cafe immediately. Valera is very greedy, so he wants to serve all n customers next day (and get more profit). However, for that he needs to ensure that at each moment of time the number of working cashes is no less than the number of clients in the cafe. Help Valera count the minimum number of cashes to work at his cafe next day, so that they can serve all visitors. Input The first line contains a single integer n (1 ≀ n ≀ 105), that is the number of cafe visitors. Each of the following n lines has two space-separated integers hi and mi (0 ≀ hi ≀ 23; 0 ≀ mi ≀ 59), representing the time when the i-th person comes into the cafe. Note that the time is given in the chronological order. All time is given within one 24-hour period. Output Print a single integer β€” the minimum number of cashes, needed to serve all clients next day. Examples Input 4 8 0 8 10 8 10 8 45 Output 2 Input 3 0 12 10 11 22 22 Output 1 Note In the first sample it is not enough one cash to serve all clients, because two visitors will come into cafe in 8:10. Therefore, if there will be one cash in cafe, then one customer will be served by it, and another one will not wait and will go away. In the second sample all visitors will come in different times, so it will be enough one cash.
instruction
0
25,903
14
51,806
Tags: implementation Correct Solution: ``` # -*- coding: utf-8 -*- """ Created on Thu Dec 21 15:32:25 2017 @author: admin """ n = int(input()) cash = 1 output=[] time = [[int(x) for x in input().split()]] for i in range(1,n): time.append([int(x) for x in input().split()]) if time[i]==time[i-1]: cash+=1 else: output.append(cash) cash = 1 else: output.append(cash) print(max(output)) ```
output
1
25,903
14
51,807
Provide tags and a correct Python 3 solution for this coding contest problem. Valera runs a 24/7 fast food cafe. He magically learned that next day n people will visit his cafe. For each person we know the arrival time: the i-th person comes exactly at hi hours mi minutes. The cafe spends less than a minute to serve each client, but if a client comes in and sees that there is no free cash, than he doesn't want to wait and leaves the cafe immediately. Valera is very greedy, so he wants to serve all n customers next day (and get more profit). However, for that he needs to ensure that at each moment of time the number of working cashes is no less than the number of clients in the cafe. Help Valera count the minimum number of cashes to work at his cafe next day, so that they can serve all visitors. Input The first line contains a single integer n (1 ≀ n ≀ 105), that is the number of cafe visitors. Each of the following n lines has two space-separated integers hi and mi (0 ≀ hi ≀ 23; 0 ≀ mi ≀ 59), representing the time when the i-th person comes into the cafe. Note that the time is given in the chronological order. All time is given within one 24-hour period. Output Print a single integer β€” the minimum number of cashes, needed to serve all clients next day. Examples Input 4 8 0 8 10 8 10 8 45 Output 2 Input 3 0 12 10 11 22 22 Output 1 Note In the first sample it is not enough one cash to serve all clients, because two visitors will come into cafe in 8:10. Therefore, if there will be one cash in cafe, then one customer will be served by it, and another one will not wait and will go away. In the second sample all visitors will come in different times, so it will be enough one cash.
instruction
0
25,904
14
51,808
Tags: implementation Correct Solution: ``` l=[] ans=[[0 for i in range(60)]for j in range(25)] c=0 n=int(input()) for i in range(n): a,b=map(int,input().split()) ans[a][b]+=1 for i in range(0,24): for j in range(0,60): if ans[i][j]>c: c=ans[i][j] print(c) ```
output
1
25,904
14
51,809
Provide tags and a correct Python 3 solution for this coding contest problem. Valera runs a 24/7 fast food cafe. He magically learned that next day n people will visit his cafe. For each person we know the arrival time: the i-th person comes exactly at hi hours mi minutes. The cafe spends less than a minute to serve each client, but if a client comes in and sees that there is no free cash, than he doesn't want to wait and leaves the cafe immediately. Valera is very greedy, so he wants to serve all n customers next day (and get more profit). However, for that he needs to ensure that at each moment of time the number of working cashes is no less than the number of clients in the cafe. Help Valera count the minimum number of cashes to work at his cafe next day, so that they can serve all visitors. Input The first line contains a single integer n (1 ≀ n ≀ 105), that is the number of cafe visitors. Each of the following n lines has two space-separated integers hi and mi (0 ≀ hi ≀ 23; 0 ≀ mi ≀ 59), representing the time when the i-th person comes into the cafe. Note that the time is given in the chronological order. All time is given within one 24-hour period. Output Print a single integer β€” the minimum number of cashes, needed to serve all clients next day. Examples Input 4 8 0 8 10 8 10 8 45 Output 2 Input 3 0 12 10 11 22 22 Output 1 Note In the first sample it is not enough one cash to serve all clients, because two visitors will come into cafe in 8:10. Therefore, if there will be one cash in cafe, then one customer will be served by it, and another one will not wait and will go away. In the second sample all visitors will come in different times, so it will be enough one cash.
instruction
0
25,905
14
51,810
Tags: implementation Correct Solution: ``` from collections import * a = [] for i in range(int(input())): x = input() a.append(x) print(Counter(a).most_common()[0][1]) ```
output
1
25,905
14
51,811
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Valera runs a 24/7 fast food cafe. He magically learned that next day n people will visit his cafe. For each person we know the arrival time: the i-th person comes exactly at hi hours mi minutes. The cafe spends less than a minute to serve each client, but if a client comes in and sees that there is no free cash, than he doesn't want to wait and leaves the cafe immediately. Valera is very greedy, so he wants to serve all n customers next day (and get more profit). However, for that he needs to ensure that at each moment of time the number of working cashes is no less than the number of clients in the cafe. Help Valera count the minimum number of cashes to work at his cafe next day, so that they can serve all visitors. Input The first line contains a single integer n (1 ≀ n ≀ 105), that is the number of cafe visitors. Each of the following n lines has two space-separated integers hi and mi (0 ≀ hi ≀ 23; 0 ≀ mi ≀ 59), representing the time when the i-th person comes into the cafe. Note that the time is given in the chronological order. All time is given within one 24-hour period. Output Print a single integer β€” the minimum number of cashes, needed to serve all clients next day. Examples Input 4 8 0 8 10 8 10 8 45 Output 2 Input 3 0 12 10 11 22 22 Output 1 Note In the first sample it is not enough one cash to serve all clients, because two visitors will come into cafe in 8:10. Therefore, if there will be one cash in cafe, then one customer will be served by it, and another one will not wait and will go away. In the second sample all visitors will come in different times, so it will be enough one cash. Submitted Solution: ``` a=int(input()) d=-1 e=-1 count=0 q=[0] for i in range(a): b,c=map(int,input().split()) if b==d and c==e: count+=1 else: q=q+[count] count=0 d=b e=c q=q+[count] print(max(q)+1) ```
instruction
0
25,907
14
51,814
Yes
output
1
25,907
14
51,815
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Valera runs a 24/7 fast food cafe. He magically learned that next day n people will visit his cafe. For each person we know the arrival time: the i-th person comes exactly at hi hours mi minutes. The cafe spends less than a minute to serve each client, but if a client comes in and sees that there is no free cash, than he doesn't want to wait and leaves the cafe immediately. Valera is very greedy, so he wants to serve all n customers next day (and get more profit). However, for that he needs to ensure that at each moment of time the number of working cashes is no less than the number of clients in the cafe. Help Valera count the minimum number of cashes to work at his cafe next day, so that they can serve all visitors. Input The first line contains a single integer n (1 ≀ n ≀ 105), that is the number of cafe visitors. Each of the following n lines has two space-separated integers hi and mi (0 ≀ hi ≀ 23; 0 ≀ mi ≀ 59), representing the time when the i-th person comes into the cafe. Note that the time is given in the chronological order. All time is given within one 24-hour period. Output Print a single integer β€” the minimum number of cashes, needed to serve all clients next day. Examples Input 4 8 0 8 10 8 10 8 45 Output 2 Input 3 0 12 10 11 22 22 Output 1 Note In the first sample it is not enough one cash to serve all clients, because two visitors will come into cafe in 8:10. Therefore, if there will be one cash in cafe, then one customer will be served by it, and another one will not wait and will go away. In the second sample all visitors will come in different times, so it will be enough one cash. Submitted Solution: ``` n = int ( input () ) f = [] for i in range ( n ) : h = input () f += [h] count = 0 count1 = 0 for i in range ( 0, len ( f ) - 1 ) : if f[i] == f[i+1] : count += 1 if count > count1 : count1 = count else : count = 0 print ( count1 + 1 ) ```
instruction
0
25,908
14
51,816
Yes
output
1
25,908
14
51,817
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Valera runs a 24/7 fast food cafe. He magically learned that next day n people will visit his cafe. For each person we know the arrival time: the i-th person comes exactly at hi hours mi minutes. The cafe spends less than a minute to serve each client, but if a client comes in and sees that there is no free cash, than he doesn't want to wait and leaves the cafe immediately. Valera is very greedy, so he wants to serve all n customers next day (and get more profit). However, for that he needs to ensure that at each moment of time the number of working cashes is no less than the number of clients in the cafe. Help Valera count the minimum number of cashes to work at his cafe next day, so that they can serve all visitors. Input The first line contains a single integer n (1 ≀ n ≀ 105), that is the number of cafe visitors. Each of the following n lines has two space-separated integers hi and mi (0 ≀ hi ≀ 23; 0 ≀ mi ≀ 59), representing the time when the i-th person comes into the cafe. Note that the time is given in the chronological order. All time is given within one 24-hour period. Output Print a single integer β€” the minimum number of cashes, needed to serve all clients next day. Examples Input 4 8 0 8 10 8 10 8 45 Output 2 Input 3 0 12 10 11 22 22 Output 1 Note In the first sample it is not enough one cash to serve all clients, because two visitors will come into cafe in 8:10. Therefore, if there will be one cash in cafe, then one customer will be served by it, and another one will not wait and will go away. In the second sample all visitors will come in different times, so it will be enough one cash. Submitted Solution: ``` l=[] n=int(input()) for i in range(n): z=input().strip().split() x=''.join(z) if x not in l: l.append(x) print(n-len(l)+1) ```
instruction
0
25,911
14
51,822
No
output
1
25,911
14
51,823
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Valera runs a 24/7 fast food cafe. He magically learned that next day n people will visit his cafe. For each person we know the arrival time: the i-th person comes exactly at hi hours mi minutes. The cafe spends less than a minute to serve each client, but if a client comes in and sees that there is no free cash, than he doesn't want to wait and leaves the cafe immediately. Valera is very greedy, so he wants to serve all n customers next day (and get more profit). However, for that he needs to ensure that at each moment of time the number of working cashes is no less than the number of clients in the cafe. Help Valera count the minimum number of cashes to work at his cafe next day, so that they can serve all visitors. Input The first line contains a single integer n (1 ≀ n ≀ 105), that is the number of cafe visitors. Each of the following n lines has two space-separated integers hi and mi (0 ≀ hi ≀ 23; 0 ≀ mi ≀ 59), representing the time when the i-th person comes into the cafe. Note that the time is given in the chronological order. All time is given within one 24-hour period. Output Print a single integer β€” the minimum number of cashes, needed to serve all clients next day. Examples Input 4 8 0 8 10 8 10 8 45 Output 2 Input 3 0 12 10 11 22 22 Output 1 Note In the first sample it is not enough one cash to serve all clients, because two visitors will come into cafe in 8:10. Therefore, if there will be one cash in cafe, then one customer will be served by it, and another one will not wait and will go away. In the second sample all visitors will come in different times, so it will be enough one cash. Submitted Solution: ``` n = int(input()) h=[] m=[] for i in range(n): a,b = [int(i) for i in input().split()] h.append(a) m.append(b) cnt=1 for i in range(n-1): if(h[i]==h[i+1] and m[i]==m[i+1]): cnt+=1 print(cnt) ```
instruction
0
25,912
14
51,824
No
output
1
25,912
14
51,825
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Valera runs a 24/7 fast food cafe. He magically learned that next day n people will visit his cafe. For each person we know the arrival time: the i-th person comes exactly at hi hours mi minutes. The cafe spends less than a minute to serve each client, but if a client comes in and sees that there is no free cash, than he doesn't want to wait and leaves the cafe immediately. Valera is very greedy, so he wants to serve all n customers next day (and get more profit). However, for that he needs to ensure that at each moment of time the number of working cashes is no less than the number of clients in the cafe. Help Valera count the minimum number of cashes to work at his cafe next day, so that they can serve all visitors. Input The first line contains a single integer n (1 ≀ n ≀ 105), that is the number of cafe visitors. Each of the following n lines has two space-separated integers hi and mi (0 ≀ hi ≀ 23; 0 ≀ mi ≀ 59), representing the time when the i-th person comes into the cafe. Note that the time is given in the chronological order. All time is given within one 24-hour period. Output Print a single integer β€” the minimum number of cashes, needed to serve all clients next day. Examples Input 4 8 0 8 10 8 10 8 45 Output 2 Input 3 0 12 10 11 22 22 Output 1 Note In the first sample it is not enough one cash to serve all clients, because two visitors will come into cafe in 8:10. Therefore, if there will be one cash in cafe, then one customer will be served by it, and another one will not wait and will go away. In the second sample all visitors will come in different times, so it will be enough one cash. Submitted Solution: ``` n = int(input()) prev, curr = [], [] count = 1 mini = 0 prev = [int(x) for x in input().split()] for i in range(1,n): curr = [int(x) for x in input().split()] if prev == curr: count +=1 if count > mini: mini = count if prev != curr: count = 1 prev = curr print(mini) ```
instruction
0
25,913
14
51,826
No
output
1
25,913
14
51,827
Provide tags and a correct Python 3 solution for this coding contest problem. The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups. Meanwhile, crimes keeps occurring within the city. One member of the police force can investigate only one crime during his/her lifetime. If there is no police officer free (isn't busy with crime) during the occurrence of a crime, it will go untreated. Given the chronological order of crime occurrences and recruit hirings, find the number of crimes which will go untreated. Input The first line of input will contain an integer n (1 ≀ n ≀ 105), the number of events. The next line will contain n space-separated integers. If the integer is -1 then it means a crime has occurred. Otherwise, the integer will be positive, the number of officers recruited together at that time. No more than 10 officers will be recruited at a time. Output Print a single integer, the number of crimes which will go untreated. Examples Input 3 -1 -1 1 Output 2 Input 8 1 -1 1 -1 -1 1 1 1 Output 1 Input 11 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 Output 8 Note Lets consider the second example: 1. Firstly one person is hired. 2. Then crime appears, the last hired person will investigate this crime. 3. One more person is hired. 4. One more crime appears, the last hired person will investigate this crime. 5. Crime appears. There is no free policeman at the time, so this crime will go untreated. 6. One more person is hired. 7. One more person is hired. 8. One more person is hired. The answer is one, as one crime (on step 5) will go untreated.
instruction
0
25,971
14
51,942
Tags: implementation Correct Solution: ``` n=int(input()) hired=0 untrated=0 a=list(map(int,input().split())) for i in a: if i>0: hired+=i elif i<0 and hired>0: hired-=1 elif i<0 : untrated+=1 print(untrated) ```
output
1
25,971
14
51,943
Provide tags and a correct Python 3 solution for this coding contest problem. The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups. Meanwhile, crimes keeps occurring within the city. One member of the police force can investigate only one crime during his/her lifetime. If there is no police officer free (isn't busy with crime) during the occurrence of a crime, it will go untreated. Given the chronological order of crime occurrences and recruit hirings, find the number of crimes which will go untreated. Input The first line of input will contain an integer n (1 ≀ n ≀ 105), the number of events. The next line will contain n space-separated integers. If the integer is -1 then it means a crime has occurred. Otherwise, the integer will be positive, the number of officers recruited together at that time. No more than 10 officers will be recruited at a time. Output Print a single integer, the number of crimes which will go untreated. Examples Input 3 -1 -1 1 Output 2 Input 8 1 -1 1 -1 -1 1 1 1 Output 1 Input 11 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 Output 8 Note Lets consider the second example: 1. Firstly one person is hired. 2. Then crime appears, the last hired person will investigate this crime. 3. One more person is hired. 4. One more crime appears, the last hired person will investigate this crime. 5. Crime appears. There is no free policeman at the time, so this crime will go untreated. 6. One more person is hired. 7. One more person is hired. 8. One more person is hired. The answer is one, as one crime (on step 5) will go untreated.
instruction
0
25,972
14
51,944
Tags: implementation Correct Solution: ``` n=int(input()) l=list(map(int,input().split())) i=0 v=0 a=0 while i<len(l): if l[i]!=-1: a+=l[i] else: if a==0: v+=1 else: a-=1 i+=1 print(v) ```
output
1
25,972
14
51,945
Provide tags and a correct Python 3 solution for this coding contest problem. The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups. Meanwhile, crimes keeps occurring within the city. One member of the police force can investigate only one crime during his/her lifetime. If there is no police officer free (isn't busy with crime) during the occurrence of a crime, it will go untreated. Given the chronological order of crime occurrences and recruit hirings, find the number of crimes which will go untreated. Input The first line of input will contain an integer n (1 ≀ n ≀ 105), the number of events. The next line will contain n space-separated integers. If the integer is -1 then it means a crime has occurred. Otherwise, the integer will be positive, the number of officers recruited together at that time. No more than 10 officers will be recruited at a time. Output Print a single integer, the number of crimes which will go untreated. Examples Input 3 -1 -1 1 Output 2 Input 8 1 -1 1 -1 -1 1 1 1 Output 1 Input 11 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 Output 8 Note Lets consider the second example: 1. Firstly one person is hired. 2. Then crime appears, the last hired person will investigate this crime. 3. One more person is hired. 4. One more crime appears, the last hired person will investigate this crime. 5. Crime appears. There is no free policeman at the time, so this crime will go untreated. 6. One more person is hired. 7. One more person is hired. 8. One more person is hired. The answer is one, as one crime (on step 5) will go untreated.
instruction
0
25,973
14
51,946
Tags: implementation Correct Solution: ``` n = int(input()) a = list(map(int, input().split())) cops, uninv = 0, 0 for i in range(n): if a[i] > 0: cops += a[i] continue cops += a[i] if cops < 0: uninv += abs(cops) cops = 0 print(uninv) ```
output
1
25,973
14
51,947
Provide tags and a correct Python 3 solution for this coding contest problem. The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups. Meanwhile, crimes keeps occurring within the city. One member of the police force can investigate only one crime during his/her lifetime. If there is no police officer free (isn't busy with crime) during the occurrence of a crime, it will go untreated. Given the chronological order of crime occurrences and recruit hirings, find the number of crimes which will go untreated. Input The first line of input will contain an integer n (1 ≀ n ≀ 105), the number of events. The next line will contain n space-separated integers. If the integer is -1 then it means a crime has occurred. Otherwise, the integer will be positive, the number of officers recruited together at that time. No more than 10 officers will be recruited at a time. Output Print a single integer, the number of crimes which will go untreated. Examples Input 3 -1 -1 1 Output 2 Input 8 1 -1 1 -1 -1 1 1 1 Output 1 Input 11 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 Output 8 Note Lets consider the second example: 1. Firstly one person is hired. 2. Then crime appears, the last hired person will investigate this crime. 3. One more person is hired. 4. One more crime appears, the last hired person will investigate this crime. 5. Crime appears. There is no free policeman at the time, so this crime will go untreated. 6. One more person is hired. 7. One more person is hired. 8. One more person is hired. The answer is one, as one crime (on step 5) will go untreated.
instruction
0
25,974
14
51,948
Tags: implementation Correct Solution: ``` temp = input() data = [int(i) for i in input().split()] police = 0 crime = 0 for i in data: if(i == -1): if(police>0): police -=1 else: crime += 1 else: police += i print(crime) #print(data) ```
output
1
25,974
14
51,949
Provide tags and a correct Python 3 solution for this coding contest problem. The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups. Meanwhile, crimes keeps occurring within the city. One member of the police force can investigate only one crime during his/her lifetime. If there is no police officer free (isn't busy with crime) during the occurrence of a crime, it will go untreated. Given the chronological order of crime occurrences and recruit hirings, find the number of crimes which will go untreated. Input The first line of input will contain an integer n (1 ≀ n ≀ 105), the number of events. The next line will contain n space-separated integers. If the integer is -1 then it means a crime has occurred. Otherwise, the integer will be positive, the number of officers recruited together at that time. No more than 10 officers will be recruited at a time. Output Print a single integer, the number of crimes which will go untreated. Examples Input 3 -1 -1 1 Output 2 Input 8 1 -1 1 -1 -1 1 1 1 Output 1 Input 11 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 Output 8 Note Lets consider the second example: 1. Firstly one person is hired. 2. Then crime appears, the last hired person will investigate this crime. 3. One more person is hired. 4. One more crime appears, the last hired person will investigate this crime. 5. Crime appears. There is no free policeman at the time, so this crime will go untreated. 6. One more person is hired. 7. One more person is hired. 8. One more person is hired. The answer is one, as one crime (on step 5) will go untreated.
instruction
0
25,975
14
51,950
Tags: implementation Correct Solution: ``` n = int(input()) l = list(map(int, input().split(' '))) sum = 0 resp = 0 for i in l: if i > 0: sum += i else: if sum > 0: sum -= 1 else: resp += 1 print(resp) ```
output
1
25,975
14
51,951
Provide tags and a correct Python 3 solution for this coding contest problem. The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups. Meanwhile, crimes keeps occurring within the city. One member of the police force can investigate only one crime during his/her lifetime. If there is no police officer free (isn't busy with crime) during the occurrence of a crime, it will go untreated. Given the chronological order of crime occurrences and recruit hirings, find the number of crimes which will go untreated. Input The first line of input will contain an integer n (1 ≀ n ≀ 105), the number of events. The next line will contain n space-separated integers. If the integer is -1 then it means a crime has occurred. Otherwise, the integer will be positive, the number of officers recruited together at that time. No more than 10 officers will be recruited at a time. Output Print a single integer, the number of crimes which will go untreated. Examples Input 3 -1 -1 1 Output 2 Input 8 1 -1 1 -1 -1 1 1 1 Output 1 Input 11 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 Output 8 Note Lets consider the second example: 1. Firstly one person is hired. 2. Then crime appears, the last hired person will investigate this crime. 3. One more person is hired. 4. One more crime appears, the last hired person will investigate this crime. 5. Crime appears. There is no free policeman at the time, so this crime will go untreated. 6. One more person is hired. 7. One more person is hired. 8. One more person is hired. The answer is one, as one crime (on step 5) will go untreated.
instruction
0
25,976
14
51,952
Tags: implementation Correct Solution: ``` n = int(input()) l = list(map(int, input().split())) recruits = 0 count = 0 for e in l: if e == -1: if recruits < 1: count += 1 else: recruits -= 1 else: recruits += e print(count) ```
output
1
25,976
14
51,953
Provide tags and a correct Python 3 solution for this coding contest problem. The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups. Meanwhile, crimes keeps occurring within the city. One member of the police force can investigate only one crime during his/her lifetime. If there is no police officer free (isn't busy with crime) during the occurrence of a crime, it will go untreated. Given the chronological order of crime occurrences and recruit hirings, find the number of crimes which will go untreated. Input The first line of input will contain an integer n (1 ≀ n ≀ 105), the number of events. The next line will contain n space-separated integers. If the integer is -1 then it means a crime has occurred. Otherwise, the integer will be positive, the number of officers recruited together at that time. No more than 10 officers will be recruited at a time. Output Print a single integer, the number of crimes which will go untreated. Examples Input 3 -1 -1 1 Output 2 Input 8 1 -1 1 -1 -1 1 1 1 Output 1 Input 11 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 Output 8 Note Lets consider the second example: 1. Firstly one person is hired. 2. Then crime appears, the last hired person will investigate this crime. 3. One more person is hired. 4. One more crime appears, the last hired person will investigate this crime. 5. Crime appears. There is no free policeman at the time, so this crime will go untreated. 6. One more person is hired. 7. One more person is hired. 8. One more person is hired. The answer is one, as one crime (on step 5) will go untreated.
instruction
0
25,977
14
51,954
Tags: implementation Correct Solution: ``` n = input() lst = [int(i) for i in input().split()] dil = 0 police = 0 for i in lst: if i == -1: if police == 0: dil += 1 else: police -= 1 else: police += i print(dil) ```
output
1
25,977
14
51,955
Provide tags and a correct Python 3 solution for this coding contest problem. The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups. Meanwhile, crimes keeps occurring within the city. One member of the police force can investigate only one crime during his/her lifetime. If there is no police officer free (isn't busy with crime) during the occurrence of a crime, it will go untreated. Given the chronological order of crime occurrences and recruit hirings, find the number of crimes which will go untreated. Input The first line of input will contain an integer n (1 ≀ n ≀ 105), the number of events. The next line will contain n space-separated integers. If the integer is -1 then it means a crime has occurred. Otherwise, the integer will be positive, the number of officers recruited together at that time. No more than 10 officers will be recruited at a time. Output Print a single integer, the number of crimes which will go untreated. Examples Input 3 -1 -1 1 Output 2 Input 8 1 -1 1 -1 -1 1 1 1 Output 1 Input 11 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 Output 8 Note Lets consider the second example: 1. Firstly one person is hired. 2. Then crime appears, the last hired person will investigate this crime. 3. One more person is hired. 4. One more crime appears, the last hired person will investigate this crime. 5. Crime appears. There is no free policeman at the time, so this crime will go untreated. 6. One more person is hired. 7. One more person is hired. 8. One more person is hired. The answer is one, as one crime (on step 5) will go untreated.
instruction
0
25,978
14
51,956
Tags: implementation Correct Solution: ``` n=int(input()) l=list(map(int, input().split())) sum=0 count=0 for i in range(n): if l[i]==-1 and sum<=0: count+=1 elif l[i]>=1 or sum>0: sum+=l[i] print(count) ```
output
1
25,978
14
51,957
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups. Meanwhile, crimes keeps occurring within the city. One member of the police force can investigate only one crime during his/her lifetime. If there is no police officer free (isn't busy with crime) during the occurrence of a crime, it will go untreated. Given the chronological order of crime occurrences and recruit hirings, find the number of crimes which will go untreated. Input The first line of input will contain an integer n (1 ≀ n ≀ 105), the number of events. The next line will contain n space-separated integers. If the integer is -1 then it means a crime has occurred. Otherwise, the integer will be positive, the number of officers recruited together at that time. No more than 10 officers will be recruited at a time. Output Print a single integer, the number of crimes which will go untreated. Examples Input 3 -1 -1 1 Output 2 Input 8 1 -1 1 -1 -1 1 1 1 Output 1 Input 11 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 Output 8 Note Lets consider the second example: 1. Firstly one person is hired. 2. Then crime appears, the last hired person will investigate this crime. 3. One more person is hired. 4. One more crime appears, the last hired person will investigate this crime. 5. Crime appears. There is no free policeman at the time, so this crime will go untreated. 6. One more person is hired. 7. One more person is hired. 8. One more person is hired. The answer is one, as one crime (on step 5) will go untreated. Submitted Solution: ``` import sys def main(): n = int(input()) a = list(map(int, input().split())) i = _sum = 0 while i < n: if(a[i] > 0): _sum += a[i] i += 1 while i < n and a[i] > 0: _sum += a[i] i += 1 while i < n and _sum > 0 and a[i] < 0: a[i] = 0 _sum -= 1 i += 1 else: i += 1 print(a.count(-1)) return if __name__ == "__main__": sys.exit(main()) ```
instruction
0
25,979
14
51,958
Yes
output
1
25,979
14
51,959
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups. Meanwhile, crimes keeps occurring within the city. One member of the police force can investigate only one crime during his/her lifetime. If there is no police officer free (isn't busy with crime) during the occurrence of a crime, it will go untreated. Given the chronological order of crime occurrences and recruit hirings, find the number of crimes which will go untreated. Input The first line of input will contain an integer n (1 ≀ n ≀ 105), the number of events. The next line will contain n space-separated integers. If the integer is -1 then it means a crime has occurred. Otherwise, the integer will be positive, the number of officers recruited together at that time. No more than 10 officers will be recruited at a time. Output Print a single integer, the number of crimes which will go untreated. Examples Input 3 -1 -1 1 Output 2 Input 8 1 -1 1 -1 -1 1 1 1 Output 1 Input 11 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 Output 8 Note Lets consider the second example: 1. Firstly one person is hired. 2. Then crime appears, the last hired person will investigate this crime. 3. One more person is hired. 4. One more crime appears, the last hired person will investigate this crime. 5. Crime appears. There is no free policeman at the time, so this crime will go untreated. 6. One more person is hired. 7. One more person is hired. 8. One more person is hired. The answer is one, as one crime (on step 5) will go untreated. Submitted Solution: ``` n = int(input()) m = list(map(int, input().split())) a=0 b=0 for i in m: a=a+i if a<0 : b=b+1 a=0 print(b) ```
instruction
0
25,980
14
51,960
Yes
output
1
25,980
14
51,961
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups. Meanwhile, crimes keeps occurring within the city. One member of the police force can investigate only one crime during his/her lifetime. If there is no police officer free (isn't busy with crime) during the occurrence of a crime, it will go untreated. Given the chronological order of crime occurrences and recruit hirings, find the number of crimes which will go untreated. Input The first line of input will contain an integer n (1 ≀ n ≀ 105), the number of events. The next line will contain n space-separated integers. If the integer is -1 then it means a crime has occurred. Otherwise, the integer will be positive, the number of officers recruited together at that time. No more than 10 officers will be recruited at a time. Output Print a single integer, the number of crimes which will go untreated. Examples Input 3 -1 -1 1 Output 2 Input 8 1 -1 1 -1 -1 1 1 1 Output 1 Input 11 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 Output 8 Note Lets consider the second example: 1. Firstly one person is hired. 2. Then crime appears, the last hired person will investigate this crime. 3. One more person is hired. 4. One more crime appears, the last hired person will investigate this crime. 5. Crime appears. There is no free policeman at the time, so this crime will go untreated. 6. One more person is hired. 7. One more person is hired. 8. One more person is hired. The answer is one, as one crime (on step 5) will go untreated. Submitted Solution: ``` n= input() l = list(int(x) for x in input().split()) police = 0 crime = 0 for x in l: if x < 0: if police == 0: crime += abs(x) else: police += x if x > 0: police += x print(crime) ```
instruction
0
25,981
14
51,962
Yes
output
1
25,981
14
51,963
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups. Meanwhile, crimes keeps occurring within the city. One member of the police force can investigate only one crime during his/her lifetime. If there is no police officer free (isn't busy with crime) during the occurrence of a crime, it will go untreated. Given the chronological order of crime occurrences and recruit hirings, find the number of crimes which will go untreated. Input The first line of input will contain an integer n (1 ≀ n ≀ 105), the number of events. The next line will contain n space-separated integers. If the integer is -1 then it means a crime has occurred. Otherwise, the integer will be positive, the number of officers recruited together at that time. No more than 10 officers will be recruited at a time. Output Print a single integer, the number of crimes which will go untreated. Examples Input 3 -1 -1 1 Output 2 Input 8 1 -1 1 -1 -1 1 1 1 Output 1 Input 11 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 Output 8 Note Lets consider the second example: 1. Firstly one person is hired. 2. Then crime appears, the last hired person will investigate this crime. 3. One more person is hired. 4. One more crime appears, the last hired person will investigate this crime. 5. Crime appears. There is no free policeman at the time, so this crime will go untreated. 6. One more person is hired. 7. One more person is hired. 8. One more person is hired. The answer is one, as one crime (on step 5) will go untreated. Submitted Solution: ``` n=int(input()) l=list(map(int,input().split())) c=0 p=0 k=0 for i in l: if i<0 and p==0 and k==0: c+=1 elif i>0: p=p+i k=1 elif i<0 and k==1: p=p+i if p==0: k=0 print(c) ```
instruction
0
25,982
14
51,964
Yes
output
1
25,982
14
51,965
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups. Meanwhile, crimes keeps occurring within the city. One member of the police force can investigate only one crime during his/her lifetime. If there is no police officer free (isn't busy with crime) during the occurrence of a crime, it will go untreated. Given the chronological order of crime occurrences and recruit hirings, find the number of crimes which will go untreated. Input The first line of input will contain an integer n (1 ≀ n ≀ 105), the number of events. The next line will contain n space-separated integers. If the integer is -1 then it means a crime has occurred. Otherwise, the integer will be positive, the number of officers recruited together at that time. No more than 10 officers will be recruited at a time. Output Print a single integer, the number of crimes which will go untreated. Examples Input 3 -1 -1 1 Output 2 Input 8 1 -1 1 -1 -1 1 1 1 Output 1 Input 11 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 Output 8 Note Lets consider the second example: 1. Firstly one person is hired. 2. Then crime appears, the last hired person will investigate this crime. 3. One more person is hired. 4. One more crime appears, the last hired person will investigate this crime. 5. Crime appears. There is no free policeman at the time, so this crime will go untreated. 6. One more person is hired. 7. One more person is hired. 8. One more person is hired. The answer is one, as one crime (on step 5) will go untreated. Submitted Solution: ``` i = 0 x = 0 a = int(input()) b = [int(i) for i in input().split()] for i in range (a-1): if b[i]<0: x += 1 elif i <a : if b[i] >= 0: b[i+1] = b[i] + b[i+1] if i == 0: if b[i]<0: print(x+1) if b[i]>=0: print(x) if (i >= 1) and (i < a): if b[i+1]>=0: print(x) elif b[i+1]<0: print(x+1) ```
instruction
0
25,983
14
51,966
No
output
1
25,983
14
51,967
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups. Meanwhile, crimes keeps occurring within the city. One member of the police force can investigate only one crime during his/her lifetime. If there is no police officer free (isn't busy with crime) during the occurrence of a crime, it will go untreated. Given the chronological order of crime occurrences and recruit hirings, find the number of crimes which will go untreated. Input The first line of input will contain an integer n (1 ≀ n ≀ 105), the number of events. The next line will contain n space-separated integers. If the integer is -1 then it means a crime has occurred. Otherwise, the integer will be positive, the number of officers recruited together at that time. No more than 10 officers will be recruited at a time. Output Print a single integer, the number of crimes which will go untreated. Examples Input 3 -1 -1 1 Output 2 Input 8 1 -1 1 -1 -1 1 1 1 Output 1 Input 11 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 Output 8 Note Lets consider the second example: 1. Firstly one person is hired. 2. Then crime appears, the last hired person will investigate this crime. 3. One more person is hired. 4. One more crime appears, the last hired person will investigate this crime. 5. Crime appears. There is no free policeman at the time, so this crime will go untreated. 6. One more person is hired. 7. One more person is hired. 8. One more person is hired. The answer is one, as one crime (on step 5) will go untreated. Submitted Solution: ``` # -*- coding: utf-8 -*- """ Created on Sun Jun 28 14:41:03 2020 @author: pc612 """ n = int(input()) l = list(map(int, input().split())) m = max(l) burles = 0 for _ in l: if _ != m: burles += (m-_) print(burles) ```
instruction
0
25,984
14
51,968
No
output
1
25,984
14
51,969
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups. Meanwhile, crimes keeps occurring within the city. One member of the police force can investigate only one crime during his/her lifetime. If there is no police officer free (isn't busy with crime) during the occurrence of a crime, it will go untreated. Given the chronological order of crime occurrences and recruit hirings, find the number of crimes which will go untreated. Input The first line of input will contain an integer n (1 ≀ n ≀ 105), the number of events. The next line will contain n space-separated integers. If the integer is -1 then it means a crime has occurred. Otherwise, the integer will be positive, the number of officers recruited together at that time. No more than 10 officers will be recruited at a time. Output Print a single integer, the number of crimes which will go untreated. Examples Input 3 -1 -1 1 Output 2 Input 8 1 -1 1 -1 -1 1 1 1 Output 1 Input 11 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 Output 8 Note Lets consider the second example: 1. Firstly one person is hired. 2. Then crime appears, the last hired person will investigate this crime. 3. One more person is hired. 4. One more crime appears, the last hired person will investigate this crime. 5. Crime appears. There is no free policeman at the time, so this crime will go untreated. 6. One more person is hired. 7. One more person is hired. 8. One more person is hired. The answer is one, as one crime (on step 5) will go untreated. Submitted Solution: ``` def main(): n = int(input()) a = [int(x) for x in input().split()] b = c = 0 for i in a: if i > 0: b = b + i if b > 0 and i < 0: b = b - 1 if i < 0: c = c + 1 print(c) if __name__ == '__main__': main() ```
instruction
0
25,985
14
51,970
No
output
1
25,985
14
51,971
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups. Meanwhile, crimes keeps occurring within the city. One member of the police force can investigate only one crime during his/her lifetime. If there is no police officer free (isn't busy with crime) during the occurrence of a crime, it will go untreated. Given the chronological order of crime occurrences and recruit hirings, find the number of crimes which will go untreated. Input The first line of input will contain an integer n (1 ≀ n ≀ 105), the number of events. The next line will contain n space-separated integers. If the integer is -1 then it means a crime has occurred. Otherwise, the integer will be positive, the number of officers recruited together at that time. No more than 10 officers will be recruited at a time. Output Print a single integer, the number of crimes which will go untreated. Examples Input 3 -1 -1 1 Output 2 Input 8 1 -1 1 -1 -1 1 1 1 Output 1 Input 11 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 Output 8 Note Lets consider the second example: 1. Firstly one person is hired. 2. Then crime appears, the last hired person will investigate this crime. 3. One more person is hired. 4. One more crime appears, the last hired person will investigate this crime. 5. Crime appears. There is no free policeman at the time, so this crime will go untreated. 6. One more person is hired. 7. One more person is hired. 8. One more person is hired. The answer is one, as one crime (on step 5) will go untreated. Submitted Solution: ``` n=int(input()) l=map(int,input().split()) s=0 Nb=0 for i in l: if i>0: s+=i if s>10: s=10 else: s-=1 if s<0: Nb+=1 s=0 print(Nb) ```
instruction
0
25,986
14
51,972
No
output
1
25,986
14
51,973
Provide tags and a correct Python 3 solution for this coding contest problem. A factory produces thimbles in bulk. Typically, it can produce up to a thimbles a day. However, some of the machinery is defective, so it can currently only produce b thimbles each day. The factory intends to choose a k-day period to do maintenance and construction; it cannot produce any thimbles during this time, but will be restored to its full production of a thimbles per day after the k days are complete. Initially, no orders are pending. The factory receives updates of the form di, ai, indicating that ai new orders have been placed for the di-th day. Each order requires a single thimble to be produced on precisely the specified day. The factory may opt to fill as many or as few of the orders in a single batch as it likes. As orders come in, the factory owner would like to know the maximum number of orders he will be able to fill if he starts repairs on a given day pi. Help the owner answer his questions. Input The first line contains five integers n, k, a, b, and q (1 ≀ k ≀ n ≀ 200 000, 1 ≀ b < a ≀ 10 000, 1 ≀ q ≀ 200 000) β€” the number of days, the length of the repair time, the production rates of the factory, and the number of updates, respectively. The next q lines contain the descriptions of the queries. Each query is of one of the following two forms: * 1 di ai (1 ≀ di ≀ n, 1 ≀ ai ≀ 10 000), representing an update of ai orders on day di, or * 2 pi (1 ≀ pi ≀ n - k + 1), representing a question: at the moment, how many orders could be filled if the factory decided to commence repairs on day pi? It's guaranteed that the input will contain at least one query of the second type. Output For each query of the second type, print a line containing a single integer β€” the maximum number of orders that the factory can fill over all n days. Examples Input 5 2 2 1 8 1 1 2 1 5 3 1 2 1 2 2 1 4 2 1 3 2 2 1 2 3 Output 3 6 4 Input 5 4 10 1 6 1 1 5 1 5 5 1 3 2 1 5 2 2 1 2 2 Output 7 1 Note Consider the first sample. We produce up to 1 thimble a day currently and will produce up to 2 thimbles a day after repairs. Repairs take 2 days. For the first question, we are able to fill 1 order on day 1, no orders on days 2 and 3 since we are repairing, no orders on day 4 since no thimbles have been ordered for that day, and 2 orders for day 5 since we are limited to our production capacity, for a total of 3 orders filled. For the third question, we are able to fill 1 order on day 1, 1 order on day 2, and 2 orders on day 5, for a total of 4 orders.
instruction
0
26,060
14
52,120
Tags: data structures Correct Solution: ``` from functools import reduce class SegmentTree(): def __init__(self, L, function = lambda x,y: x+y, initilizer = None): self.function = function self.initilizer = initilizer N = self.size = len(L) M = 1 << N.bit_length() self.margin = 2*M - N self.L = [None for i in range(self.margin)] + L for i in range(M-1, 0, -1): x, y = self.L[i<<1], self.L[i<<1|1] self.L[i] = None if x is None or y is None else function(x, y) def modify(self, pos, value): p = pos + self.margin self.L[p] = value while p > 1: x, y = self.L[p], self.L[p^1] if p&1: x, y = y, x self.L[p>>1] = None if x is None or y is None else self.function(x, y) p>>=1 def query(self, left, right): l, r = left + self.margin, right + self.margin stack = [] void = True if self.initilizer is not None: void = False result = self.initilizer while l < r: if l&1: if void: result = self.L[l] void = False else: result = self.function(result, self.L[l]) l+=1 if r&1: r-=1 stack.append(self.L[r]) l>>=1 r>>=1 init = stack.pop() if void else result return reduce(self.function, reversed(stack), init) import sys n, k, a, b, q = [int(x) for x in input().split()] orders = [0]*(n+2) a_tree, b_tree = SegmentTree(orders, initilizer = 0), SegmentTree(orders, initilizer = 0) for line in sys.stdin: s = [int(x) for x in line.split()] if s[0] == 1: orders[s[1]] += s[2] a_tree.modify(s[1], min(a, orders[s[1]])) b_tree.modify(s[1], min(b, orders[s[1]])) else: query = b_tree.query(0, s[1]) + a_tree.query(s[1]+k, n+1) print(query) ```
output
1
26,060
14
52,121
Provide tags and a correct Python 3 solution for this coding contest problem. The elections to Berland parliament are happening today. Voting is in full swing! Totally there are n candidates, they are numbered from 1 to n. Based on election results k (1 ≀ k ≀ n) top candidates will take seats in the parliament. After the end of the voting the number of votes for each candidate is calculated. In the resulting table the candidates are ordered by the number of votes. In case of tie (equal number of votes) they are ordered by the time of the last vote given. The candidate with ealier last vote stands higher in the resulting table. So in the resulting table candidates are sorted by the number of votes (more votes stand for the higher place) and if two candidates have equal number of votes they are sorted by the time of last vote (earlier last vote stands for the higher place). There is no way for a candidate with zero votes to take a seat in the parliament. So it is possible that less than k candidates will take a seat in the parliament. In Berland there are m citizens who can vote. Each of them will vote for some candidate. Each citizen will give a vote to exactly one of n candidates. There is no option "against everyone" on the elections. It is not accepted to spoil bulletins or not to go to elections. So each of m citizens will vote for exactly one of n candidates. At the moment a citizens have voted already (1 ≀ a ≀ m). This is an open election, so for each citizen it is known the candidate for which the citizen has voted. Formally, the j-th citizen voted for the candidate gj. The citizens who already voted are numbered in chronological order; i.e. the (j + 1)-th citizen voted after the j-th. The remaining m - a citizens will vote before the end of elections, each of them will vote for one of n candidates. Your task is to determine for each of n candidates one of the three possible outcomes: * a candidate will be elected to the parliament regardless of votes of the remaining m - a citizens; * a candidate has chance to be elected to the parliament after all n citizens have voted; * a candidate has no chances to be elected to the parliament regardless of votes of the remaining m - a citizens. Input The first line contains four integers n, k, m and a (1 ≀ k ≀ n ≀ 100, 1 ≀ m ≀ 100, 1 ≀ a ≀ m) β€” the number of candidates, the number of seats in the parliament, the number of Berland citizens and the number of citizens who already have voted. The second line contains a sequence of a integers g1, g2, ..., ga (1 ≀ gj ≀ n), where gj is the candidate for which the j-th citizen has voted. Citizens who already voted are numbered in increasing order of voting times. Output Print the sequence consisting of n integers r1, r2, ..., rn where: * ri = 1 means that the i-th candidate is guaranteed to take seat in the parliament regardless of votes of the remaining m - a citizens; * ri = 2 means that the i-th candidate has a chance to take a seat in the parliament, i.e. the remaining m - a citizens can vote in such a way that the candidate will take a seat in the parliament; * ri = 3 means that the i-th candidate will not take a seat in the parliament regardless of votes of the remaining m - a citizens. Examples Input 3 1 5 4 1 2 1 3 Output 1 3 3 Input 3 1 5 3 1 3 1 Output 2 3 2 Input 3 2 5 3 1 3 1 Output 1 2 2
instruction
0
26,164
14
52,328
Tags: greedy, sortings Correct Solution: ``` from copy import deepcopy n, k, m, a = [int(i) for i in input().split()] cn = [0] * (n + 1) last = [-1] * (n + 1) v = [int(i) for i in input().split()] for i in range(len(v)): last[v[i]] = i cn[v[i]] += 1 cn1 = deepcopy(cn) last1 = deepcopy(last) for i in range(1, n + 1): cn = deepcopy(cn1) last = deepcopy(last1) res = [i1 for i1 in range(1, n + 1)] res.sort(key=lambda x: (cn[x], -last[x]), reverse = True) #print(res) for j in range(len(res)): if res[j] != i: continue j1 = j + 1 lft = m - a while j1 < n and lft: pls = min(lft, cn[i] - cn[res[j1]] + 1) cn[res[j1]] += min(lft, cn[i] - cn[res[j1]] + 1) last[res[j1]] = m lft -= pls j1 += 1 res.sort(key=lambda x: (cn[x], -last[x]), reverse = True) sans = 0 for j in range(len(res)): if res[j] != i: continue if cn[i] == 0 or j >= k: sans = 0 else: sans = 1 break if sans == 1: print(1, end= ' ') continue cn = deepcopy(cn1) last = deepcopy(last1) if m - a: cn[i] += m - a last[i] = m - 1 res.sort(key=lambda x: (cn[x], 0 -last[x]), reverse = True) for j in range(len(res)): if res[j] != i: continue if cn[i] == 0 or j >= k: sans = 0 else: sans = 1 break if sans: print(2, end=' ') else: print(3, end=' ') ```
output
1
26,164
14
52,329
Provide tags and a correct Python 3 solution for this coding contest problem. The elections to Berland parliament are happening today. Voting is in full swing! Totally there are n candidates, they are numbered from 1 to n. Based on election results k (1 ≀ k ≀ n) top candidates will take seats in the parliament. After the end of the voting the number of votes for each candidate is calculated. In the resulting table the candidates are ordered by the number of votes. In case of tie (equal number of votes) they are ordered by the time of the last vote given. The candidate with ealier last vote stands higher in the resulting table. So in the resulting table candidates are sorted by the number of votes (more votes stand for the higher place) and if two candidates have equal number of votes they are sorted by the time of last vote (earlier last vote stands for the higher place). There is no way for a candidate with zero votes to take a seat in the parliament. So it is possible that less than k candidates will take a seat in the parliament. In Berland there are m citizens who can vote. Each of them will vote for some candidate. Each citizen will give a vote to exactly one of n candidates. There is no option "against everyone" on the elections. It is not accepted to spoil bulletins or not to go to elections. So each of m citizens will vote for exactly one of n candidates. At the moment a citizens have voted already (1 ≀ a ≀ m). This is an open election, so for each citizen it is known the candidate for which the citizen has voted. Formally, the j-th citizen voted for the candidate gj. The citizens who already voted are numbered in chronological order; i.e. the (j + 1)-th citizen voted after the j-th. The remaining m - a citizens will vote before the end of elections, each of them will vote for one of n candidates. Your task is to determine for each of n candidates one of the three possible outcomes: * a candidate will be elected to the parliament regardless of votes of the remaining m - a citizens; * a candidate has chance to be elected to the parliament after all n citizens have voted; * a candidate has no chances to be elected to the parliament regardless of votes of the remaining m - a citizens. Input The first line contains four integers n, k, m and a (1 ≀ k ≀ n ≀ 100, 1 ≀ m ≀ 100, 1 ≀ a ≀ m) β€” the number of candidates, the number of seats in the parliament, the number of Berland citizens and the number of citizens who already have voted. The second line contains a sequence of a integers g1, g2, ..., ga (1 ≀ gj ≀ n), where gj is the candidate for which the j-th citizen has voted. Citizens who already voted are numbered in increasing order of voting times. Output Print the sequence consisting of n integers r1, r2, ..., rn where: * ri = 1 means that the i-th candidate is guaranteed to take seat in the parliament regardless of votes of the remaining m - a citizens; * ri = 2 means that the i-th candidate has a chance to take a seat in the parliament, i.e. the remaining m - a citizens can vote in such a way that the candidate will take a seat in the parliament; * ri = 3 means that the i-th candidate will not take a seat in the parliament regardless of votes of the remaining m - a citizens. Examples Input 3 1 5 4 1 2 1 3 Output 1 3 3 Input 3 1 5 3 1 3 1 Output 2 3 2 Input 3 2 5 3 1 3 1 Output 1 2 2
instruction
0
26,165
14
52,330
Tags: greedy, sortings Correct Solution: ``` class State: __slots__ = ['candidate', 'votes', 'last_vote'] def __init__(self, cand, votes, last): self.candidate = cand self.votes = votes self.last_vote = last def beats(self, other, extra): return self.votes + extra > other.votes def main(): candidates, seats, people, voted = map(int, input().split()) votes = [0 for i in range(candidates)] last_vote = [0 for i in range(candidates)] if candidates == 1: print(1) return v = list(map(int, input().split())) for t in range(voted): cand = v[t] - 1 votes[cand] += 1 last_vote[cand] = t states = [State(i, votes[i], last_vote[i]) for i in range(candidates)] states = sorted(states, key = lambda x : (x.votes, -x.last_vote)) res = [0 for i in range(candidates)] for i in range(candidates): if i < candidates - seats: low = candidates - seats if states[i].beats(states[low], people - voted): res[states[i].candidate] = 2 else: res[states[i].candidate] = 3 else: extra = people - voted other = i - 1 place = i if extra == 0 and states[i].votes == 0: res[states[i].candidate] = 3 continue while other >= 0 and extra > 0: needed = states[i].votes - states[other].votes + 1 if needed <= extra: extra -= needed; place -= 1 other -= 1 else: break res[states[i].candidate] = (1 if place + seats >= candidates and states[i].votes > 0 else 2) for i in res: print(i, end = ' ') main() ```
output
1
26,165
14
52,331
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The elections to Berland parliament are happening today. Voting is in full swing! Totally there are n candidates, they are numbered from 1 to n. Based on election results k (1 ≀ k ≀ n) top candidates will take seats in the parliament. After the end of the voting the number of votes for each candidate is calculated. In the resulting table the candidates are ordered by the number of votes. In case of tie (equal number of votes) they are ordered by the time of the last vote given. The candidate with ealier last vote stands higher in the resulting table. So in the resulting table candidates are sorted by the number of votes (more votes stand for the higher place) and if two candidates have equal number of votes they are sorted by the time of last vote (earlier last vote stands for the higher place). There is no way for a candidate with zero votes to take a seat in the parliament. So it is possible that less than k candidates will take a seat in the parliament. In Berland there are m citizens who can vote. Each of them will vote for some candidate. Each citizen will give a vote to exactly one of n candidates. There is no option "against everyone" on the elections. It is not accepted to spoil bulletins or not to go to elections. So each of m citizens will vote for exactly one of n candidates. At the moment a citizens have voted already (1 ≀ a ≀ m). This is an open election, so for each citizen it is known the candidate for which the citizen has voted. Formally, the j-th citizen voted for the candidate gj. The citizens who already voted are numbered in chronological order; i.e. the (j + 1)-th citizen voted after the j-th. The remaining m - a citizens will vote before the end of elections, each of them will vote for one of n candidates. Your task is to determine for each of n candidates one of the three possible outcomes: * a candidate will be elected to the parliament regardless of votes of the remaining m - a citizens; * a candidate has chance to be elected to the parliament after all n citizens have voted; * a candidate has no chances to be elected to the parliament regardless of votes of the remaining m - a citizens. Input The first line contains four integers n, k, m and a (1 ≀ k ≀ n ≀ 100, 1 ≀ m ≀ 100, 1 ≀ a ≀ m) β€” the number of candidates, the number of seats in the parliament, the number of Berland citizens and the number of citizens who already have voted. The second line contains a sequence of a integers g1, g2, ..., ga (1 ≀ gj ≀ n), where gj is the candidate for which the j-th citizen has voted. Citizens who already voted are numbered in increasing order of voting times. Output Print the sequence consisting of n integers r1, r2, ..., rn where: * ri = 1 means that the i-th candidate is guaranteed to take seat in the parliament regardless of votes of the remaining m - a citizens; * ri = 2 means that the i-th candidate has a chance to take a seat in the parliament, i.e. the remaining m - a citizens can vote in such a way that the candidate will take a seat in the parliament; * ri = 3 means that the i-th candidate will not take a seat in the parliament regardless of votes of the remaining m - a citizens. Examples Input 3 1 5 4 1 2 1 3 Output 1 3 3 Input 3 1 5 3 1 3 1 Output 2 3 2 Input 3 2 5 3 1 3 1 Output 1 2 2 Submitted Solution: ``` from copy import deepcopy n, k, m, a = [int(i) for i in input().split()] cn = [0] * (n + 1) last = [-1] * (n + 1) v = [int(i) for i in input().split()] for i in range(len(v)): last[v[i]] = i cn[v[i]] += 1 cn1 = deepcopy(cn) last1 = deepcopy(last) for i in range(1, n + 1): cn = deepcopy(cn1) last = deepcopy(last1) res = [i1 for i1 in range(1, n + 1)] res.sort(key=lambda x: (cn[x], -last[x]), reverse = True) for j in range(len(res)): if res[j] != i: continue j1 = j + 1 lft = m - a while j1 < n and lft: cn[res[j1]] += min(lft, cn[i] - cn[res[j1]] + 1) last[res[j1]] = m lft -= min(lft, cn[i] - cn[res[j1]] + 1) j1 += 1 res.sort(key=lambda x: (cn[x], -last[x]), reverse = True) sans = 0 for j in range(len(res)): if res[j] != i: continue if cn[i] == 0 or j >= k: sans = 0 else: sans = 1 break if sans == 1: print(1, end= ' ') continue cn = deepcopy(cn1) last = deepcopy(last1) if m - a: cn[i] += m - a last[i] = m - 1 res.sort(key=lambda x: (cn[x], 0 -last[x]), reverse = True) for j in range(len(res)): if res[j] != i: continue if cn[i] == 0 or j >= k: sans = 0 else: sans = 1 break if sans: print(2, end=' ') else: print(3, end=' ') ```
instruction
0
26,166
14
52,332
No
output
1
26,166
14
52,333
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The elections to Berland parliament are happening today. Voting is in full swing! Totally there are n candidates, they are numbered from 1 to n. Based on election results k (1 ≀ k ≀ n) top candidates will take seats in the parliament. After the end of the voting the number of votes for each candidate is calculated. In the resulting table the candidates are ordered by the number of votes. In case of tie (equal number of votes) they are ordered by the time of the last vote given. The candidate with ealier last vote stands higher in the resulting table. So in the resulting table candidates are sorted by the number of votes (more votes stand for the higher place) and if two candidates have equal number of votes they are sorted by the time of last vote (earlier last vote stands for the higher place). There is no way for a candidate with zero votes to take a seat in the parliament. So it is possible that less than k candidates will take a seat in the parliament. In Berland there are m citizens who can vote. Each of them will vote for some candidate. Each citizen will give a vote to exactly one of n candidates. There is no option "against everyone" on the elections. It is not accepted to spoil bulletins or not to go to elections. So each of m citizens will vote for exactly one of n candidates. At the moment a citizens have voted already (1 ≀ a ≀ m). This is an open election, so for each citizen it is known the candidate for which the citizen has voted. Formally, the j-th citizen voted for the candidate gj. The citizens who already voted are numbered in chronological order; i.e. the (j + 1)-th citizen voted after the j-th. The remaining m - a citizens will vote before the end of elections, each of them will vote for one of n candidates. Your task is to determine for each of n candidates one of the three possible outcomes: * a candidate will be elected to the parliament regardless of votes of the remaining m - a citizens; * a candidate has chance to be elected to the parliament after all n citizens have voted; * a candidate has no chances to be elected to the parliament regardless of votes of the remaining m - a citizens. Input The first line contains four integers n, k, m and a (1 ≀ k ≀ n ≀ 100, 1 ≀ m ≀ 100, 1 ≀ a ≀ m) β€” the number of candidates, the number of seats in the parliament, the number of Berland citizens and the number of citizens who already have voted. The second line contains a sequence of a integers g1, g2, ..., ga (1 ≀ gj ≀ n), where gj is the candidate for which the j-th citizen has voted. Citizens who already voted are numbered in increasing order of voting times. Output Print the sequence consisting of n integers r1, r2, ..., rn where: * ri = 1 means that the i-th candidate is guaranteed to take seat in the parliament regardless of votes of the remaining m - a citizens; * ri = 2 means that the i-th candidate has a chance to take a seat in the parliament, i.e. the remaining m - a citizens can vote in such a way that the candidate will take a seat in the parliament; * ri = 3 means that the i-th candidate will not take a seat in the parliament regardless of votes of the remaining m - a citizens. Examples Input 3 1 5 4 1 2 1 3 Output 1 3 3 Input 3 1 5 3 1 3 1 Output 2 3 2 Input 3 2 5 3 1 3 1 Output 1 2 2 Submitted Solution: ``` class State: __slots__ = ['candidate', 'votes', 'last_vote'] def __init__(self, cand, votes, last): self.candidate = cand self.votes = votes self.last_vote = last def beats(self, other, extra): return self.votes + extra > other.votes def main(): candidates, seats, people, voted = map(int, input().split()) votes = [0 for i in range(candidates)] last_vote = [0 for i in range(candidates)] if candidates == 1: print(1) return v = list(map(int, input().split())) for t in range(voted): cand = v[t] - 1 votes[cand] += 1 last_vote[cand] = t states = [State(i, votes[i], last_vote[i]) for i in range(candidates)] states = sorted(states, key = lambda x : (x.votes, -x.last_vote)) res = [0 for i in range(candidates)] for i in range(candidates): if i < candidates - seats: low = candidates - seats if states[i].beats(states[low], people - voted): res[states[i].candidate] = 2 else: res[states[i].candidate] = 3 else: extra = people - voted other = i - 1 place = i while other >= 0 and extra > 0: needed = states[i].votes - states[other].votes + 1 if needed <= extra: extra -= needed; place -= 1 other -= 1 else: break res[states[i].candidate] = (1 if place + seats >= candidates else 2) for i in res: print(i, end = ' ') main() ```
instruction
0
26,167
14
52,334
No
output
1
26,167
14
52,335
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The elections to Berland parliament are happening today. Voting is in full swing! Totally there are n candidates, they are numbered from 1 to n. Based on election results k (1 ≀ k ≀ n) top candidates will take seats in the parliament. After the end of the voting the number of votes for each candidate is calculated. In the resulting table the candidates are ordered by the number of votes. In case of tie (equal number of votes) they are ordered by the time of the last vote given. The candidate with ealier last vote stands higher in the resulting table. So in the resulting table candidates are sorted by the number of votes (more votes stand for the higher place) and if two candidates have equal number of votes they are sorted by the time of last vote (earlier last vote stands for the higher place). There is no way for a candidate with zero votes to take a seat in the parliament. So it is possible that less than k candidates will take a seat in the parliament. In Berland there are m citizens who can vote. Each of them will vote for some candidate. Each citizen will give a vote to exactly one of n candidates. There is no option "against everyone" on the elections. It is not accepted to spoil bulletins or not to go to elections. So each of m citizens will vote for exactly one of n candidates. At the moment a citizens have voted already (1 ≀ a ≀ m). This is an open election, so for each citizen it is known the candidate for which the citizen has voted. Formally, the j-th citizen voted for the candidate gj. The citizens who already voted are numbered in chronological order; i.e. the (j + 1)-th citizen voted after the j-th. The remaining m - a citizens will vote before the end of elections, each of them will vote for one of n candidates. Your task is to determine for each of n candidates one of the three possible outcomes: * a candidate will be elected to the parliament regardless of votes of the remaining m - a citizens; * a candidate has chance to be elected to the parliament after all n citizens have voted; * a candidate has no chances to be elected to the parliament regardless of votes of the remaining m - a citizens. Input The first line contains four integers n, k, m and a (1 ≀ k ≀ n ≀ 100, 1 ≀ m ≀ 100, 1 ≀ a ≀ m) β€” the number of candidates, the number of seats in the parliament, the number of Berland citizens and the number of citizens who already have voted. The second line contains a sequence of a integers g1, g2, ..., ga (1 ≀ gj ≀ n), where gj is the candidate for which the j-th citizen has voted. Citizens who already voted are numbered in increasing order of voting times. Output Print the sequence consisting of n integers r1, r2, ..., rn where: * ri = 1 means that the i-th candidate is guaranteed to take seat in the parliament regardless of votes of the remaining m - a citizens; * ri = 2 means that the i-th candidate has a chance to take a seat in the parliament, i.e. the remaining m - a citizens can vote in such a way that the candidate will take a seat in the parliament; * ri = 3 means that the i-th candidate will not take a seat in the parliament regardless of votes of the remaining m - a citizens. Examples Input 3 1 5 4 1 2 1 3 Output 1 3 3 Input 3 1 5 3 1 3 1 Output 2 3 2 Input 3 2 5 3 1 3 1 Output 1 2 2 Submitted Solution: ``` class State: __slots__ = ['candidate', 'votes', 'last_vote'] def __init__(self, cand, votes, last): self.candidate = cand self.votes = votes self.last_vote = last def beats(self, other, extra): return self.votes + extra > other.votes def main(): candidates, seats, people, voted = map(int, input().split()) votes = [0 for i in range(candidates)] last_vote = [0 for i in range(candidates)] if candidates == 1: print(1) return v = list(map(int, input().split())) for t in range(voted): cand = v[t] - 1 votes[cand] += 1 last_vote[cand] = t states = [State(i, votes[i], last_vote[i]) for i in range(candidates)] states = sorted(states, key = lambda x : (x.votes, -x.last_vote)) res = [0 for i in range(candidates)] for i in range(candidates): if i < candidates - seats: low = candidates - seats if states[i].beats(states[low], people - voted): res[states[i].candidate] = 2 else: res[states[i].candidate] = 3 else: extra = people - voted other = i - 1 place = i if extra == 0 and states[i].votes == 0: res[states[i].candidate] = 3 continue while other >= 0 and extra > 0: needed = states[i].votes - states[other].votes + 1 if needed <= extra: extra -= needed; place -= 1 other -= 1 else: break res[states[i].candidate] = (1 if place + seats >= candidates else 2) for i in res: print(i, end = ' ') main() ```
instruction
0
26,168
14
52,336
No
output
1
26,168
14
52,337
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The elections to Berland parliament are happening today. Voting is in full swing! Totally there are n candidates, they are numbered from 1 to n. Based on election results k (1 ≀ k ≀ n) top candidates will take seats in the parliament. After the end of the voting the number of votes for each candidate is calculated. In the resulting table the candidates are ordered by the number of votes. In case of tie (equal number of votes) they are ordered by the time of the last vote given. The candidate with ealier last vote stands higher in the resulting table. So in the resulting table candidates are sorted by the number of votes (more votes stand for the higher place) and if two candidates have equal number of votes they are sorted by the time of last vote (earlier last vote stands for the higher place). There is no way for a candidate with zero votes to take a seat in the parliament. So it is possible that less than k candidates will take a seat in the parliament. In Berland there are m citizens who can vote. Each of them will vote for some candidate. Each citizen will give a vote to exactly one of n candidates. There is no option "against everyone" on the elections. It is not accepted to spoil bulletins or not to go to elections. So each of m citizens will vote for exactly one of n candidates. At the moment a citizens have voted already (1 ≀ a ≀ m). This is an open election, so for each citizen it is known the candidate for which the citizen has voted. Formally, the j-th citizen voted for the candidate gj. The citizens who already voted are numbered in chronological order; i.e. the (j + 1)-th citizen voted after the j-th. The remaining m - a citizens will vote before the end of elections, each of them will vote for one of n candidates. Your task is to determine for each of n candidates one of the three possible outcomes: * a candidate will be elected to the parliament regardless of votes of the remaining m - a citizens; * a candidate has chance to be elected to the parliament after all n citizens have voted; * a candidate has no chances to be elected to the parliament regardless of votes of the remaining m - a citizens. Input The first line contains four integers n, k, m and a (1 ≀ k ≀ n ≀ 100, 1 ≀ m ≀ 100, 1 ≀ a ≀ m) β€” the number of candidates, the number of seats in the parliament, the number of Berland citizens and the number of citizens who already have voted. The second line contains a sequence of a integers g1, g2, ..., ga (1 ≀ gj ≀ n), where gj is the candidate for which the j-th citizen has voted. Citizens who already voted are numbered in increasing order of voting times. Output Print the sequence consisting of n integers r1, r2, ..., rn where: * ri = 1 means that the i-th candidate is guaranteed to take seat in the parliament regardless of votes of the remaining m - a citizens; * ri = 2 means that the i-th candidate has a chance to take a seat in the parliament, i.e. the remaining m - a citizens can vote in such a way that the candidate will take a seat in the parliament; * ri = 3 means that the i-th candidate will not take a seat in the parliament regardless of votes of the remaining m - a citizens. Examples Input 3 1 5 4 1 2 1 3 Output 1 3 3 Input 3 1 5 3 1 3 1 Output 2 3 2 Input 3 2 5 3 1 3 1 Output 1 2 2 Submitted Solution: ``` from copy import deepcopy n, k, m, a = [int(i) for i in input().split()] cn = [0] * (n + 1) last = [-1] * (n + 1) v = [int(i) for i in input().split()] for i in range(len(v)): last[v[i]] = i cn[v[i]] += 1 cn1 = deepcopy(cn) last1 = deepcopy(last) for i in range(1, n + 1): #print(i) res = [i1 for i1 in range(1, n + 1)] res.sort(key=lambda x: (cn[x], -last[x]), reverse = True) for j in range(len(res)): if res[j] != i: continue j1 = j + 1 lft = m - a while j1 < n and lft: cn[res[j1]] += min(lft, cn[i] - cn[res[j1]] + 1) last[res[j1]] = m lft -= min(lft, cn[i] - cn[res[j1]] + 1) j1 += 1 res.sort(key=lambda x: (cn[x], -last[x]), reverse = True) sans = 0 for j in range(len(res)): if res[j] != i: continue if cn[i] == 0 or j >= k: sans = 0 else: sans = 1 break if sans == 1: print(1, end= ' ') continue cn = deepcopy(cn1) last = deepcopy(last1) if m - a: cn[i] += m - a last[i] = m - 1 res.sort(key=lambda x: (cn[x], 0 -last[x]), reverse = True) for j in range(len(res)): if res[j] != i: continue if cn[i] == 0 or j >= k: sans = 0 else: sans = 1 break cn = deepcopy(cn1) last = deepcopy(last1) if sans: print(2, end=' ') else: print(3, end=' ') ```
instruction
0
26,169
14
52,338
No
output
1
26,169
14
52,339
Provide tags and a correct Python 3 solution for this coding contest problem. Winters are just damn freezing cold in Nvodsk! That's why a group of n friends prefers to take a taxi, order a pizza and call girls. The phone numbers in the city consist of three pairs of digits (for example, 12-34-56). Each friend has a phonebook of size si (that's the number of phone numbers). We know that taxi numbers consist of six identical digits (for example, 22-22-22), the numbers of pizza deliveries should necessarily be decreasing sequences of six different digits (for example, 98-73-21), all other numbers are the girls' numbers. You are given your friends' phone books. Calculate which friend is best to go to when you are interested in each of those things (who has maximal number of phone numbers of each type). If the phone book of one person contains some number two times, you should count it twice. That is, each number should be taken into consideration the number of times it occurs in the phone book. Input The first line contains an integer n (1 ≀ n ≀ 100) β€” the number of friends. Then follow n data blocks that describe each friend's phone books. Each block is presented in the following form: first goes the line that contains integer si and string namei (0 ≀ si ≀ 100) β€” the number of phone numbers in the phone book of the i-th friend and the name of the i-th friend. The name is a non-empty sequence of uppercase and lowercase Latin letters, containing no more than 20 characters. Next si lines contain numbers as "XX-XX-XX", where X is arbitrary digits from 0 to 9. Output In the first line print the phrase "If you want to call a taxi, you should call: ". Then print names of all friends whose phone books contain maximal number of taxi phone numbers. In the second line print the phrase "If you want to order a pizza, you should call: ". Then print names of all friends who have maximal number of pizza phone numbers. In the third line print the phrase "If you want to go to a cafe with a wonderful girl, you should call: ". Then print names of all friends who have maximal number of girls' phone numbers. Print the names in the order in which they are given in the input data. Separate two consecutive names with a comma and a space. Each line should end with exactly one point. For clarifications concerning the output form, see sample tests. It is necessary that you follow the output form strictly. Extra spaces are not allowed. Examples Input 4 2 Fedorov 22-22-22 98-76-54 3 Melnikov 75-19-09 23-45-67 99-99-98 7 Rogulenko 22-22-22 11-11-11 33-33-33 44-44-44 55-55-55 66-66-66 95-43-21 3 Kaluzhin 11-11-11 99-99-99 98-65-32 Output If you want to call a taxi, you should call: Rogulenko. If you want to order a pizza, you should call: Fedorov, Rogulenko, Kaluzhin. If you want to go to a cafe with a wonderful girl, you should call: Melnikov. Input 3 5 Gleb 66-66-66 55-55-55 01-01-01 65-43-21 12-34-56 3 Serega 55-55-55 87-65-43 65-55-21 5 Melnik 12-42-12 87-73-01 36-04-12 88-12-22 82-11-43 Output If you want to call a taxi, you should call: Gleb. If you want to order a pizza, you should call: Gleb, Serega. If you want to go to a cafe with a wonderful girl, you should call: Melnik. Input 3 3 Kulczynski 22-22-22 65-43-21 98-12-00 4 Pachocki 11-11-11 11-11-11 11-11-11 98-76-54 0 Smietanka Output If you want to call a taxi, you should call: Pachocki. If you want to order a pizza, you should call: Kulczynski, Pachocki. If you want to go to a cafe with a wonderful girl, you should call: Kulczynski. Note In the first sample you are given four friends. Fedorov's phone book contains one taxi number and one pizza delivery number, Melnikov's phone book only has 3 numbers of girls, Rogulenko's one has 6 taxi numbers and one pizza delivery number, Kaluzhin's one contains 2 taxi numbers and one pizza delivery number. Thus, if you need to order a taxi, you should obviously call Rogulenko, if you need to order a pizza you should call anybody of the following: Rogulenko, Fedorov, Kaluzhin (each of them has one number). Melnikov has maximal number of phone numbers of girls.
instruction
0
26,774
14
53,548
Tags: implementation, strings Correct Solution: ``` class CodeforcesTask151BSolution: def __init__(self): self.result = '' self.n = 0 self.friends = [] self.books = [] def read_input(self): self.n = int(input()) for x in range(self.n): self.friends.append(input().split(" ")) self.books.append([]) for y in range(int(self.friends[-1][0])): self.books[-1].append([int(x) for x in "".join(input().split("-"))]) def process_task(self): taxiars = [] pizzaman = [] cafes = [] for x in range(self.n): for y in range(int(self.friends[x][0])): if self.books[x][y].count(self.books[x][y][0]) == 6: taxiars.append(self.friends[x][1]) elif self.books[x][y] == sorted(self.books[x][y], reverse=True) and sum([self.books[x][y].count(z) ** 2 for z in self.books[x][y]]) == 6: pizzaman.append(self.friends[x][1]) else: cafes.append(self.friends[x][1]) names = [x[1] for x in self.friends] taxi_chosen = [] max_taxi = 0 for taxi in list(set(taxiars)): cnt = taxiars.count(taxi) max_taxi = max(max_taxi, cnt) for taxi in names: cnt = taxiars.count(taxi) if cnt == max_taxi: taxi_chosen.append(taxi) pizza_chosen = [] max_pizza = 0 for pizza in list(set(pizzaman)): cnt = pizzaman.count(pizza) max_pizza = max(max_pizza, cnt) for pizza in names: cnt = pizzaman.count(pizza) if cnt == max_pizza: pizza_chosen.append(pizza) cafe_chosen = [] max_cafe = 0 for cafe in list(set(cafes)): cnt = cafes.count(cafe) max_cafe = max(max_cafe, cnt) for cafe in names: cnt = cafes.count(cafe) if cnt == max_cafe: cafe_chosen.append(cafe) self.result = "If you want to call a taxi, you should call: {0}.\n".format(", ".join(taxi_chosen)) self.result += "If you want to order a pizza, you should call: {0}.\n".format(", ".join(pizza_chosen)) self.result += "If you want to go to a cafe with a wonderful girl, you should call: {0}.".format(", ".join(cafe_chosen)) def get_result(self): return self.result if __name__ == "__main__": Solution = CodeforcesTask151BSolution() Solution.read_input() Solution.process_task() print(Solution.get_result()) ```
output
1
26,774
14
53,549
Provide tags and a correct Python 3 solution for this coding contest problem. Winters are just damn freezing cold in Nvodsk! That's why a group of n friends prefers to take a taxi, order a pizza and call girls. The phone numbers in the city consist of three pairs of digits (for example, 12-34-56). Each friend has a phonebook of size si (that's the number of phone numbers). We know that taxi numbers consist of six identical digits (for example, 22-22-22), the numbers of pizza deliveries should necessarily be decreasing sequences of six different digits (for example, 98-73-21), all other numbers are the girls' numbers. You are given your friends' phone books. Calculate which friend is best to go to when you are interested in each of those things (who has maximal number of phone numbers of each type). If the phone book of one person contains some number two times, you should count it twice. That is, each number should be taken into consideration the number of times it occurs in the phone book. Input The first line contains an integer n (1 ≀ n ≀ 100) β€” the number of friends. Then follow n data blocks that describe each friend's phone books. Each block is presented in the following form: first goes the line that contains integer si and string namei (0 ≀ si ≀ 100) β€” the number of phone numbers in the phone book of the i-th friend and the name of the i-th friend. The name is a non-empty sequence of uppercase and lowercase Latin letters, containing no more than 20 characters. Next si lines contain numbers as "XX-XX-XX", where X is arbitrary digits from 0 to 9. Output In the first line print the phrase "If you want to call a taxi, you should call: ". Then print names of all friends whose phone books contain maximal number of taxi phone numbers. In the second line print the phrase "If you want to order a pizza, you should call: ". Then print names of all friends who have maximal number of pizza phone numbers. In the third line print the phrase "If you want to go to a cafe with a wonderful girl, you should call: ". Then print names of all friends who have maximal number of girls' phone numbers. Print the names in the order in which they are given in the input data. Separate two consecutive names with a comma and a space. Each line should end with exactly one point. For clarifications concerning the output form, see sample tests. It is necessary that you follow the output form strictly. Extra spaces are not allowed. Examples Input 4 2 Fedorov 22-22-22 98-76-54 3 Melnikov 75-19-09 23-45-67 99-99-98 7 Rogulenko 22-22-22 11-11-11 33-33-33 44-44-44 55-55-55 66-66-66 95-43-21 3 Kaluzhin 11-11-11 99-99-99 98-65-32 Output If you want to call a taxi, you should call: Rogulenko. If you want to order a pizza, you should call: Fedorov, Rogulenko, Kaluzhin. If you want to go to a cafe with a wonderful girl, you should call: Melnikov. Input 3 5 Gleb 66-66-66 55-55-55 01-01-01 65-43-21 12-34-56 3 Serega 55-55-55 87-65-43 65-55-21 5 Melnik 12-42-12 87-73-01 36-04-12 88-12-22 82-11-43 Output If you want to call a taxi, you should call: Gleb. If you want to order a pizza, you should call: Gleb, Serega. If you want to go to a cafe with a wonderful girl, you should call: Melnik. Input 3 3 Kulczynski 22-22-22 65-43-21 98-12-00 4 Pachocki 11-11-11 11-11-11 11-11-11 98-76-54 0 Smietanka Output If you want to call a taxi, you should call: Pachocki. If you want to order a pizza, you should call: Kulczynski, Pachocki. If you want to go to a cafe with a wonderful girl, you should call: Kulczynski. Note In the first sample you are given four friends. Fedorov's phone book contains one taxi number and one pizza delivery number, Melnikov's phone book only has 3 numbers of girls, Rogulenko's one has 6 taxi numbers and one pizza delivery number, Kaluzhin's one contains 2 taxi numbers and one pizza delivery number. Thus, if you need to order a taxi, you should obviously call Rogulenko, if you need to order a pizza you should call anybody of the following: Rogulenko, Fedorov, Kaluzhin (each of them has one number). Melnikov has maximal number of phone numbers of girls.
instruction
0
26,775
14
53,550
Tags: implementation, strings Correct Solution: ``` def mi(): return map(int, input().split()) ''' 4 2 Fedorov 22-22-22 98-76-54 3 Melnikov 75-19-09 23-45-67 99-99-98 7 Rogulenko 22-22-22 11-11-11 33-33-33 44-44-44 55-55-55 66-66-66 95-43-21 3 Kaluzhin 11-11-11 99-99-99 98-65-32 ''' f = int(input()) name = [0]*f girl = name.copy() taxi = name.copy() pizza = name.copy() for i in range(f): n, name[i] = input().split() n = int(n) for __ in range(n): no = input() s = [no[0],no[1],no[3],no[4],no[6], no[7]] if len(set(s))==6 and s==sorted(s, reverse=True): pizza[i]+=1 elif len(set(s))==1: taxi[i]+=1 else: girl[i]+=1 mg = max(girl) mp = max(pizza) mt = max(taxi) print ('If you want to call a taxi, you should call: ', end = '') ct = taxi.count(mt) k = 0 for i in range(f): if taxi[i]==mt: print (name[i], end = '') k+=1 if k==ct: print ('.') else: print (', ', end = '') print ('If you want to order a pizza, you should call: ', end = '') cp = pizza.count(mp) k = 0 for i in range(f): if pizza[i]==mp: print (name[i], end = '') k+=1 if k==cp: print ('.') else: print (', ', end = '') print ('If you want to go to a cafe with a wonderful girl, you should call: ', end = '') cg = girl.count(mg) k = 0 for i in range(f): if girl[i]==mg: print (name[i], end = '') k+=1 if k==cg: print ('.') else: print (', ', end = '') ```
output
1
26,775
14
53,551
Provide tags and a correct Python 3 solution for this coding contest problem. Winters are just damn freezing cold in Nvodsk! That's why a group of n friends prefers to take a taxi, order a pizza and call girls. The phone numbers in the city consist of three pairs of digits (for example, 12-34-56). Each friend has a phonebook of size si (that's the number of phone numbers). We know that taxi numbers consist of six identical digits (for example, 22-22-22), the numbers of pizza deliveries should necessarily be decreasing sequences of six different digits (for example, 98-73-21), all other numbers are the girls' numbers. You are given your friends' phone books. Calculate which friend is best to go to when you are interested in each of those things (who has maximal number of phone numbers of each type). If the phone book of one person contains some number two times, you should count it twice. That is, each number should be taken into consideration the number of times it occurs in the phone book. Input The first line contains an integer n (1 ≀ n ≀ 100) β€” the number of friends. Then follow n data blocks that describe each friend's phone books. Each block is presented in the following form: first goes the line that contains integer si and string namei (0 ≀ si ≀ 100) β€” the number of phone numbers in the phone book of the i-th friend and the name of the i-th friend. The name is a non-empty sequence of uppercase and lowercase Latin letters, containing no more than 20 characters. Next si lines contain numbers as "XX-XX-XX", where X is arbitrary digits from 0 to 9. Output In the first line print the phrase "If you want to call a taxi, you should call: ". Then print names of all friends whose phone books contain maximal number of taxi phone numbers. In the second line print the phrase "If you want to order a pizza, you should call: ". Then print names of all friends who have maximal number of pizza phone numbers. In the third line print the phrase "If you want to go to a cafe with a wonderful girl, you should call: ". Then print names of all friends who have maximal number of girls' phone numbers. Print the names in the order in which they are given in the input data. Separate two consecutive names with a comma and a space. Each line should end with exactly one point. For clarifications concerning the output form, see sample tests. It is necessary that you follow the output form strictly. Extra spaces are not allowed. Examples Input 4 2 Fedorov 22-22-22 98-76-54 3 Melnikov 75-19-09 23-45-67 99-99-98 7 Rogulenko 22-22-22 11-11-11 33-33-33 44-44-44 55-55-55 66-66-66 95-43-21 3 Kaluzhin 11-11-11 99-99-99 98-65-32 Output If you want to call a taxi, you should call: Rogulenko. If you want to order a pizza, you should call: Fedorov, Rogulenko, Kaluzhin. If you want to go to a cafe with a wonderful girl, you should call: Melnikov. Input 3 5 Gleb 66-66-66 55-55-55 01-01-01 65-43-21 12-34-56 3 Serega 55-55-55 87-65-43 65-55-21 5 Melnik 12-42-12 87-73-01 36-04-12 88-12-22 82-11-43 Output If you want to call a taxi, you should call: Gleb. If you want to order a pizza, you should call: Gleb, Serega. If you want to go to a cafe with a wonderful girl, you should call: Melnik. Input 3 3 Kulczynski 22-22-22 65-43-21 98-12-00 4 Pachocki 11-11-11 11-11-11 11-11-11 98-76-54 0 Smietanka Output If you want to call a taxi, you should call: Pachocki. If you want to order a pizza, you should call: Kulczynski, Pachocki. If you want to go to a cafe with a wonderful girl, you should call: Kulczynski. Note In the first sample you are given four friends. Fedorov's phone book contains one taxi number and one pizza delivery number, Melnikov's phone book only has 3 numbers of girls, Rogulenko's one has 6 taxi numbers and one pizza delivery number, Kaluzhin's one contains 2 taxi numbers and one pizza delivery number. Thus, if you need to order a taxi, you should obviously call Rogulenko, if you need to order a pizza you should call anybody of the following: Rogulenko, Fedorov, Kaluzhin (each of them has one number). Melnikov has maximal number of phone numbers of girls.
instruction
0
26,776
14
53,552
Tags: implementation, strings Correct Solution: ``` def check(b): g=[] for i in b: for j in i: g.append(int(j)) #print(g) for i in range(1,len(g)): if g[i]>=g[i-1]: return 0 return 1 ans=[] t=int(input()) for iii in range(t): a=input().split() taxi=0 girls=0 pizz=0 for i in range(int(a[0])): b=input().rstrip().split('-') if b.count(b[0])==len(b) and b[0][0]==b[1][1]: taxi+=1 elif check(b): #print(b,'b') pizz+=1 else: girls+=1 ans.append((a[1],taxi,girls,pizz,iii)) #print(ans) ans.sort(key=lambda x:x[1] , reverse=True) te=[] for i in ans: if i[1]==ans[0][1]: te.append((i[0],i[4])) ans.sort(key=lambda x:x[2] , reverse=True) girl=[] for i in ans: if i[2]==ans[0][2]: girl.append((i[0],i[4])) ans.sort(key=lambda x:x[3] , reverse=True) pizza=[] for i in ans: if i[3]==ans[0][3]: pizza.append((i[0],i[4])) te.sort(key=lambda x:x[1]) girl.sort(key=lambda x:x[1]) pizza.sort(key=lambda x:x[1]) te=[i[0] for i in te] pizza=[i[0] for i in pizza] girl=[i[0] for i in girl] ans1='If you want to call a taxi, you should call:' ans2='If you want to order a pizza, you should call:' ans3='If you want to go to a cafe with a wonderful girl, you should call:' te=', '.join(te)+'.' girl=', '.join(girl)+'.' pizza=', '.join(pizza)+'.' print(ans1,te) print(ans2,pizza) print(ans3,girl) ```
output
1
26,776
14
53,553
Provide tags and a correct Python 3 solution for this coding contest problem. Winters are just damn freezing cold in Nvodsk! That's why a group of n friends prefers to take a taxi, order a pizza and call girls. The phone numbers in the city consist of three pairs of digits (for example, 12-34-56). Each friend has a phonebook of size si (that's the number of phone numbers). We know that taxi numbers consist of six identical digits (for example, 22-22-22), the numbers of pizza deliveries should necessarily be decreasing sequences of six different digits (for example, 98-73-21), all other numbers are the girls' numbers. You are given your friends' phone books. Calculate which friend is best to go to when you are interested in each of those things (who has maximal number of phone numbers of each type). If the phone book of one person contains some number two times, you should count it twice. That is, each number should be taken into consideration the number of times it occurs in the phone book. Input The first line contains an integer n (1 ≀ n ≀ 100) β€” the number of friends. Then follow n data blocks that describe each friend's phone books. Each block is presented in the following form: first goes the line that contains integer si and string namei (0 ≀ si ≀ 100) β€” the number of phone numbers in the phone book of the i-th friend and the name of the i-th friend. The name is a non-empty sequence of uppercase and lowercase Latin letters, containing no more than 20 characters. Next si lines contain numbers as "XX-XX-XX", where X is arbitrary digits from 0 to 9. Output In the first line print the phrase "If you want to call a taxi, you should call: ". Then print names of all friends whose phone books contain maximal number of taxi phone numbers. In the second line print the phrase "If you want to order a pizza, you should call: ". Then print names of all friends who have maximal number of pizza phone numbers. In the third line print the phrase "If you want to go to a cafe with a wonderful girl, you should call: ". Then print names of all friends who have maximal number of girls' phone numbers. Print the names in the order in which they are given in the input data. Separate two consecutive names with a comma and a space. Each line should end with exactly one point. For clarifications concerning the output form, see sample tests. It is necessary that you follow the output form strictly. Extra spaces are not allowed. Examples Input 4 2 Fedorov 22-22-22 98-76-54 3 Melnikov 75-19-09 23-45-67 99-99-98 7 Rogulenko 22-22-22 11-11-11 33-33-33 44-44-44 55-55-55 66-66-66 95-43-21 3 Kaluzhin 11-11-11 99-99-99 98-65-32 Output If you want to call a taxi, you should call: Rogulenko. If you want to order a pizza, you should call: Fedorov, Rogulenko, Kaluzhin. If you want to go to a cafe with a wonderful girl, you should call: Melnikov. Input 3 5 Gleb 66-66-66 55-55-55 01-01-01 65-43-21 12-34-56 3 Serega 55-55-55 87-65-43 65-55-21 5 Melnik 12-42-12 87-73-01 36-04-12 88-12-22 82-11-43 Output If you want to call a taxi, you should call: Gleb. If you want to order a pizza, you should call: Gleb, Serega. If you want to go to a cafe with a wonderful girl, you should call: Melnik. Input 3 3 Kulczynski 22-22-22 65-43-21 98-12-00 4 Pachocki 11-11-11 11-11-11 11-11-11 98-76-54 0 Smietanka Output If you want to call a taxi, you should call: Pachocki. If you want to order a pizza, you should call: Kulczynski, Pachocki. If you want to go to a cafe with a wonderful girl, you should call: Kulczynski. Note In the first sample you are given four friends. Fedorov's phone book contains one taxi number and one pizza delivery number, Melnikov's phone book only has 3 numbers of girls, Rogulenko's one has 6 taxi numbers and one pizza delivery number, Kaluzhin's one contains 2 taxi numbers and one pizza delivery number. Thus, if you need to order a taxi, you should obviously call Rogulenko, if you need to order a pizza you should call anybody of the following: Rogulenko, Fedorov, Kaluzhin (each of them has one number). Melnikov has maximal number of phone numbers of girls.
instruction
0
26,777
14
53,554
Tags: implementation, strings Correct Solution: ``` import math import sys import collections from collections import defaultdict from sys import stdin, stdout sys.setrecursionlimit(10**9) # n, k, l, c, d, p, nl, np=map(int,input().split()) # ans=min((k*l)//nl,d*c,p//np)//n # print(ans) n=int(input()) piza,taxi,girl=-1,-1,-1 pname,tname,gname=[],[],[] for _ in range(n): cnt0,cnt1,cnt2=0,0,0 s,name=map(str,input().split()) for i in range(int(s)): str1=input() temp=[] for j in range(len(str1)): if str1[j]!='-': temp.append(int(str1[j])) flag=1 for j in range(1,len(temp)): if temp[j-1]!=temp[j]: flag=0 break if flag==1: cnt1+=1 else: t=0 for j in range(1,len(temp)): if temp[j-1]>temp[j]: t+=1 if t==5: flag=0 else: flag=2 if flag==0: cnt0+=1 else: cnt2+=1 # print(flag,cnt0,cnt1,cnt2) if cnt0>piza: pname=[] pname.append(name) piza=cnt0 elif cnt0==piza: pname.append(name) piza=cnt0 if cnt1>taxi: tname=[] tname.append(name) taxi=cnt1 elif cnt1==taxi: tname.append(name) taxi=cnt1 if cnt2>girl: gname=[] gname.append(name) girl=cnt2 elif cnt2==girl: gname.append(name) girl=cnt2 print("If you want to call a taxi, you should call: ",end='') for i in range(len(tname)-1): print(tname[i]+', ',end='') print(tname[len(tname)-1]+".") print("If you want to order a pizza, you should call: ",end='') for i in range(len(pname)-1): print(pname[i]+', ',end='') print(pname[len(pname)-1]+".") print("If you want to go to a cafe with a wonderful girl, you should call: ",end='') for i in range(len(gname)-1): print(gname[i]+', ',end='') print(gname[len(gname)-1]+".") ```
output
1
26,777
14
53,555
Provide tags and a correct Python 3 solution for this coding contest problem. Winters are just damn freezing cold in Nvodsk! That's why a group of n friends prefers to take a taxi, order a pizza and call girls. The phone numbers in the city consist of three pairs of digits (for example, 12-34-56). Each friend has a phonebook of size si (that's the number of phone numbers). We know that taxi numbers consist of six identical digits (for example, 22-22-22), the numbers of pizza deliveries should necessarily be decreasing sequences of six different digits (for example, 98-73-21), all other numbers are the girls' numbers. You are given your friends' phone books. Calculate which friend is best to go to when you are interested in each of those things (who has maximal number of phone numbers of each type). If the phone book of one person contains some number two times, you should count it twice. That is, each number should be taken into consideration the number of times it occurs in the phone book. Input The first line contains an integer n (1 ≀ n ≀ 100) β€” the number of friends. Then follow n data blocks that describe each friend's phone books. Each block is presented in the following form: first goes the line that contains integer si and string namei (0 ≀ si ≀ 100) β€” the number of phone numbers in the phone book of the i-th friend and the name of the i-th friend. The name is a non-empty sequence of uppercase and lowercase Latin letters, containing no more than 20 characters. Next si lines contain numbers as "XX-XX-XX", where X is arbitrary digits from 0 to 9. Output In the first line print the phrase "If you want to call a taxi, you should call: ". Then print names of all friends whose phone books contain maximal number of taxi phone numbers. In the second line print the phrase "If you want to order a pizza, you should call: ". Then print names of all friends who have maximal number of pizza phone numbers. In the third line print the phrase "If you want to go to a cafe with a wonderful girl, you should call: ". Then print names of all friends who have maximal number of girls' phone numbers. Print the names in the order in which they are given in the input data. Separate two consecutive names with a comma and a space. Each line should end with exactly one point. For clarifications concerning the output form, see sample tests. It is necessary that you follow the output form strictly. Extra spaces are not allowed. Examples Input 4 2 Fedorov 22-22-22 98-76-54 3 Melnikov 75-19-09 23-45-67 99-99-98 7 Rogulenko 22-22-22 11-11-11 33-33-33 44-44-44 55-55-55 66-66-66 95-43-21 3 Kaluzhin 11-11-11 99-99-99 98-65-32 Output If you want to call a taxi, you should call: Rogulenko. If you want to order a pizza, you should call: Fedorov, Rogulenko, Kaluzhin. If you want to go to a cafe with a wonderful girl, you should call: Melnikov. Input 3 5 Gleb 66-66-66 55-55-55 01-01-01 65-43-21 12-34-56 3 Serega 55-55-55 87-65-43 65-55-21 5 Melnik 12-42-12 87-73-01 36-04-12 88-12-22 82-11-43 Output If you want to call a taxi, you should call: Gleb. If you want to order a pizza, you should call: Gleb, Serega. If you want to go to a cafe with a wonderful girl, you should call: Melnik. Input 3 3 Kulczynski 22-22-22 65-43-21 98-12-00 4 Pachocki 11-11-11 11-11-11 11-11-11 98-76-54 0 Smietanka Output If you want to call a taxi, you should call: Pachocki. If you want to order a pizza, you should call: Kulczynski, Pachocki. If you want to go to a cafe with a wonderful girl, you should call: Kulczynski. Note In the first sample you are given four friends. Fedorov's phone book contains one taxi number and one pizza delivery number, Melnikov's phone book only has 3 numbers of girls, Rogulenko's one has 6 taxi numbers and one pizza delivery number, Kaluzhin's one contains 2 taxi numbers and one pizza delivery number. Thus, if you need to order a taxi, you should obviously call Rogulenko, if you need to order a pizza you should call anybody of the following: Rogulenko, Fedorov, Kaluzhin (each of them has one number). Melnikov has maximal number of phone numbers of girls.
instruction
0
26,778
14
53,556
Tags: implementation, strings Correct Solution: ``` def t(s): if s.count(s[0]) == 6: return 0 elif s[0] > s[1] and s[1] > s[3] and s[3] > s[4] and s[4] > s[6] and s[6] > s[7]: return 1 else: return 2 a = ['call a taxi', 'order a pizza', 'go to a cafe with a wonderful girl'] nm, c = [], [] for i in range(int(input())): nn, nmi = input().split() nn = int(nn) c.append([0, 0, 0]) nm.append(nmi) for j in range(nn): c[i][t(input())] += 1 for j in range(len(a)): vn, vnm = 0, [] for nmi, ci in zip(nm, c): if ci[j] > vn: vn = ci[j] vnm = [nmi] elif ci[j] == vn: vnm.append(nmi) print('If you want to ', a[j], ', you should call: ', ', '.join(vnm), '.', sep='') ```
output
1
26,778
14
53,557
Provide tags and a correct Python 3 solution for this coding contest problem. Winters are just damn freezing cold in Nvodsk! That's why a group of n friends prefers to take a taxi, order a pizza and call girls. The phone numbers in the city consist of three pairs of digits (for example, 12-34-56). Each friend has a phonebook of size si (that's the number of phone numbers). We know that taxi numbers consist of six identical digits (for example, 22-22-22), the numbers of pizza deliveries should necessarily be decreasing sequences of six different digits (for example, 98-73-21), all other numbers are the girls' numbers. You are given your friends' phone books. Calculate which friend is best to go to when you are interested in each of those things (who has maximal number of phone numbers of each type). If the phone book of one person contains some number two times, you should count it twice. That is, each number should be taken into consideration the number of times it occurs in the phone book. Input The first line contains an integer n (1 ≀ n ≀ 100) β€” the number of friends. Then follow n data blocks that describe each friend's phone books. Each block is presented in the following form: first goes the line that contains integer si and string namei (0 ≀ si ≀ 100) β€” the number of phone numbers in the phone book of the i-th friend and the name of the i-th friend. The name is a non-empty sequence of uppercase and lowercase Latin letters, containing no more than 20 characters. Next si lines contain numbers as "XX-XX-XX", where X is arbitrary digits from 0 to 9. Output In the first line print the phrase "If you want to call a taxi, you should call: ". Then print names of all friends whose phone books contain maximal number of taxi phone numbers. In the second line print the phrase "If you want to order a pizza, you should call: ". Then print names of all friends who have maximal number of pizza phone numbers. In the third line print the phrase "If you want to go to a cafe with a wonderful girl, you should call: ". Then print names of all friends who have maximal number of girls' phone numbers. Print the names in the order in which they are given in the input data. Separate two consecutive names with a comma and a space. Each line should end with exactly one point. For clarifications concerning the output form, see sample tests. It is necessary that you follow the output form strictly. Extra spaces are not allowed. Examples Input 4 2 Fedorov 22-22-22 98-76-54 3 Melnikov 75-19-09 23-45-67 99-99-98 7 Rogulenko 22-22-22 11-11-11 33-33-33 44-44-44 55-55-55 66-66-66 95-43-21 3 Kaluzhin 11-11-11 99-99-99 98-65-32 Output If you want to call a taxi, you should call: Rogulenko. If you want to order a pizza, you should call: Fedorov, Rogulenko, Kaluzhin. If you want to go to a cafe with a wonderful girl, you should call: Melnikov. Input 3 5 Gleb 66-66-66 55-55-55 01-01-01 65-43-21 12-34-56 3 Serega 55-55-55 87-65-43 65-55-21 5 Melnik 12-42-12 87-73-01 36-04-12 88-12-22 82-11-43 Output If you want to call a taxi, you should call: Gleb. If you want to order a pizza, you should call: Gleb, Serega. If you want to go to a cafe with a wonderful girl, you should call: Melnik. Input 3 3 Kulczynski 22-22-22 65-43-21 98-12-00 4 Pachocki 11-11-11 11-11-11 11-11-11 98-76-54 0 Smietanka Output If you want to call a taxi, you should call: Pachocki. If you want to order a pizza, you should call: Kulczynski, Pachocki. If you want to go to a cafe with a wonderful girl, you should call: Kulczynski. Note In the first sample you are given four friends. Fedorov's phone book contains one taxi number and one pizza delivery number, Melnikov's phone book only has 3 numbers of girls, Rogulenko's one has 6 taxi numbers and one pizza delivery number, Kaluzhin's one contains 2 taxi numbers and one pizza delivery number. Thus, if you need to order a taxi, you should obviously call Rogulenko, if you need to order a pizza you should call anybody of the following: Rogulenko, Fedorov, Kaluzhin (each of them has one number). Melnikov has maximal number of phone numbers of girls.
instruction
0
26,779
14
53,558
Tags: implementation, strings Correct Solution: ``` n = int(input()) names = [] records = [] for i in range(n): records.append([0, 0, 0]) phone_numebers = [] temp = n i = 0 while temp > 0: s, name = [x for x in input().split()] names.append(name) s = int(s) while s > 0: number = input() phone_numebers.append((number, i)) s -= 1 i += 1 temp -= 1 #checking each phone numbers and updating the records for i in phone_numebers: number = i[0] ind = i[1] list1 = number.split("-") #taxi if (list1[0] == list1[1] == list1[2]) and (list1[0][0] == list1[0][1] and list1[1][0] == list1[1][1] and list1[2][0] == list1[2][1]): records[ind][0] += 1 elif(list1[0][0] > list1[0][1] and list1[0][1] > list1[1][0] and list1[1][0] > list1[1][1] and list1[1][1] > list1[2][0] and list1[2][0] > list1[2][1]): #pizza records[ind][1] += 1 else: records[ind][2] += 1 #girls maxi_taxi = 0 maxi_pizza = 0 maxi_girl = 0 for record in records: if record[0] > maxi_taxi: maxi_taxi = record[0] if record[1] > maxi_pizza: maxi_pizza = record[1] if record[2] > maxi_girl: maxi_girl = record[2] taxi_guys = [] pizza_guys = [] girls_guys = [] for i in range(n): if records[i][0] == maxi_taxi: taxi_guys.append(names[i]) if records[i][1] == maxi_pizza: pizza_guys.append(names[i]) if records[i][2] == maxi_girl: girls_guys.append(names[i]) # print(taxi_guys) # print(pizza_guys) # print(girls_guys) print("If you want to call a taxi, you should call: ", end = "") for i in range(len(taxi_guys)): if i == len(taxi_guys) - 1: print(taxi_guys[i] + ".") else: print(taxi_guys[i], end = ", ") print("If you want to order a pizza, you should call: ", end = "") for i in range(len(pizza_guys)): if i == len(pizza_guys) - 1: print(pizza_guys[i] + ".") else: print(pizza_guys[i], end = ", ") print("If you want to go to a cafe with a wonderful girl, you should call: ", end = "") for i in range(len(girls_guys)): if i == len(girls_guys) - 1: print(girls_guys[i] + ".") else: print(girls_guys[i], end = ", ") ```
output
1
26,779
14
53,559
Provide tags and a correct Python 3 solution for this coding contest problem. Winters are just damn freezing cold in Nvodsk! That's why a group of n friends prefers to take a taxi, order a pizza and call girls. The phone numbers in the city consist of three pairs of digits (for example, 12-34-56). Each friend has a phonebook of size si (that's the number of phone numbers). We know that taxi numbers consist of six identical digits (for example, 22-22-22), the numbers of pizza deliveries should necessarily be decreasing sequences of six different digits (for example, 98-73-21), all other numbers are the girls' numbers. You are given your friends' phone books. Calculate which friend is best to go to when you are interested in each of those things (who has maximal number of phone numbers of each type). If the phone book of one person contains some number two times, you should count it twice. That is, each number should be taken into consideration the number of times it occurs in the phone book. Input The first line contains an integer n (1 ≀ n ≀ 100) β€” the number of friends. Then follow n data blocks that describe each friend's phone books. Each block is presented in the following form: first goes the line that contains integer si and string namei (0 ≀ si ≀ 100) β€” the number of phone numbers in the phone book of the i-th friend and the name of the i-th friend. The name is a non-empty sequence of uppercase and lowercase Latin letters, containing no more than 20 characters. Next si lines contain numbers as "XX-XX-XX", where X is arbitrary digits from 0 to 9. Output In the first line print the phrase "If you want to call a taxi, you should call: ". Then print names of all friends whose phone books contain maximal number of taxi phone numbers. In the second line print the phrase "If you want to order a pizza, you should call: ". Then print names of all friends who have maximal number of pizza phone numbers. In the third line print the phrase "If you want to go to a cafe with a wonderful girl, you should call: ". Then print names of all friends who have maximal number of girls' phone numbers. Print the names in the order in which they are given in the input data. Separate two consecutive names with a comma and a space. Each line should end with exactly one point. For clarifications concerning the output form, see sample tests. It is necessary that you follow the output form strictly. Extra spaces are not allowed. Examples Input 4 2 Fedorov 22-22-22 98-76-54 3 Melnikov 75-19-09 23-45-67 99-99-98 7 Rogulenko 22-22-22 11-11-11 33-33-33 44-44-44 55-55-55 66-66-66 95-43-21 3 Kaluzhin 11-11-11 99-99-99 98-65-32 Output If you want to call a taxi, you should call: Rogulenko. If you want to order a pizza, you should call: Fedorov, Rogulenko, Kaluzhin. If you want to go to a cafe with a wonderful girl, you should call: Melnikov. Input 3 5 Gleb 66-66-66 55-55-55 01-01-01 65-43-21 12-34-56 3 Serega 55-55-55 87-65-43 65-55-21 5 Melnik 12-42-12 87-73-01 36-04-12 88-12-22 82-11-43 Output If you want to call a taxi, you should call: Gleb. If you want to order a pizza, you should call: Gleb, Serega. If you want to go to a cafe with a wonderful girl, you should call: Melnik. Input 3 3 Kulczynski 22-22-22 65-43-21 98-12-00 4 Pachocki 11-11-11 11-11-11 11-11-11 98-76-54 0 Smietanka Output If you want to call a taxi, you should call: Pachocki. If you want to order a pizza, you should call: Kulczynski, Pachocki. If you want to go to a cafe with a wonderful girl, you should call: Kulczynski. Note In the first sample you are given four friends. Fedorov's phone book contains one taxi number and one pizza delivery number, Melnikov's phone book only has 3 numbers of girls, Rogulenko's one has 6 taxi numbers and one pizza delivery number, Kaluzhin's one contains 2 taxi numbers and one pizza delivery number. Thus, if you need to order a taxi, you should obviously call Rogulenko, if you need to order a pizza you should call anybody of the following: Rogulenko, Fedorov, Kaluzhin (each of them has one number). Melnikov has maximal number of phone numbers of girls.
instruction
0
26,780
14
53,560
Tags: implementation, strings Correct Solution: ``` names = [['', 0, 0, 0] for _ in range (110)] max = 0; max2 = 0; max3 = 0 qu_taxi = ['If you want to call a taxi, you should call: '] qu_pizza = ['If you want to order a pizza, you should call: '] qu_girl = ['If you want to go to a cafe with a wonderful girl, you should call: '] def checker (y) : # 0 = taxi, 1 = pizza, 2 = girl y = list (y) new = [] for i in range (len (y)) : if y[i] != '-' : new.append (int (y[i])) if len (set (new)) == 1 : return 0 for i in range (len (new) - 1) : if new[i] > new[i + 1] : continue else : return 2 return 1 def printy (qu_list) : print (qu_list[0], sep = '', end = '') for i in range (1, len (qu_list)) : if i == len (qu_list) - 1 : print (qu_list[i], '.', sep = '', end = '') else : print (qu_list[i], ', ', sep = '', end = '') n = int (input()) for i in range (n) : x = input ().split() names[i][0] += x[1] for j in range (int (x[0])) : y = input() value = checker(y) if value == 0 : names[i][1] += 1 elif value == 1 : names[i][2] += 1 else : names[i][3] += 1 for i in range (n) : if names[i][1] > max : max = names[i][1] if names[i][2] > max2 : max2 = names[i][2] if names[i][3] > max3 : max3 = names[i][3] for i in range (n) : if names[i][1] == max : qu_taxi.append(names[i][0]) if names[i][2] == max2 : qu_pizza.append(names[i][0]) if names[i][3] == max3 : qu_girl.append(names[i][0]) printy(qu_taxi) print () printy(qu_pizza) print () printy(qu_girl) ```
output
1
26,780
14
53,561
Provide tags and a correct Python 3 solution for this coding contest problem. Winters are just damn freezing cold in Nvodsk! That's why a group of n friends prefers to take a taxi, order a pizza and call girls. The phone numbers in the city consist of three pairs of digits (for example, 12-34-56). Each friend has a phonebook of size si (that's the number of phone numbers). We know that taxi numbers consist of six identical digits (for example, 22-22-22), the numbers of pizza deliveries should necessarily be decreasing sequences of six different digits (for example, 98-73-21), all other numbers are the girls' numbers. You are given your friends' phone books. Calculate which friend is best to go to when you are interested in each of those things (who has maximal number of phone numbers of each type). If the phone book of one person contains some number two times, you should count it twice. That is, each number should be taken into consideration the number of times it occurs in the phone book. Input The first line contains an integer n (1 ≀ n ≀ 100) β€” the number of friends. Then follow n data blocks that describe each friend's phone books. Each block is presented in the following form: first goes the line that contains integer si and string namei (0 ≀ si ≀ 100) β€” the number of phone numbers in the phone book of the i-th friend and the name of the i-th friend. The name is a non-empty sequence of uppercase and lowercase Latin letters, containing no more than 20 characters. Next si lines contain numbers as "XX-XX-XX", where X is arbitrary digits from 0 to 9. Output In the first line print the phrase "If you want to call a taxi, you should call: ". Then print names of all friends whose phone books contain maximal number of taxi phone numbers. In the second line print the phrase "If you want to order a pizza, you should call: ". Then print names of all friends who have maximal number of pizza phone numbers. In the third line print the phrase "If you want to go to a cafe with a wonderful girl, you should call: ". Then print names of all friends who have maximal number of girls' phone numbers. Print the names in the order in which they are given in the input data. Separate two consecutive names with a comma and a space. Each line should end with exactly one point. For clarifications concerning the output form, see sample tests. It is necessary that you follow the output form strictly. Extra spaces are not allowed. Examples Input 4 2 Fedorov 22-22-22 98-76-54 3 Melnikov 75-19-09 23-45-67 99-99-98 7 Rogulenko 22-22-22 11-11-11 33-33-33 44-44-44 55-55-55 66-66-66 95-43-21 3 Kaluzhin 11-11-11 99-99-99 98-65-32 Output If you want to call a taxi, you should call: Rogulenko. If you want to order a pizza, you should call: Fedorov, Rogulenko, Kaluzhin. If you want to go to a cafe with a wonderful girl, you should call: Melnikov. Input 3 5 Gleb 66-66-66 55-55-55 01-01-01 65-43-21 12-34-56 3 Serega 55-55-55 87-65-43 65-55-21 5 Melnik 12-42-12 87-73-01 36-04-12 88-12-22 82-11-43 Output If you want to call a taxi, you should call: Gleb. If you want to order a pizza, you should call: Gleb, Serega. If you want to go to a cafe with a wonderful girl, you should call: Melnik. Input 3 3 Kulczynski 22-22-22 65-43-21 98-12-00 4 Pachocki 11-11-11 11-11-11 11-11-11 98-76-54 0 Smietanka Output If you want to call a taxi, you should call: Pachocki. If you want to order a pizza, you should call: Kulczynski, Pachocki. If you want to go to a cafe with a wonderful girl, you should call: Kulczynski. Note In the first sample you are given four friends. Fedorov's phone book contains one taxi number and one pizza delivery number, Melnikov's phone book only has 3 numbers of girls, Rogulenko's one has 6 taxi numbers and one pizza delivery number, Kaluzhin's one contains 2 taxi numbers and one pizza delivery number. Thus, if you need to order a taxi, you should obviously call Rogulenko, if you need to order a pizza you should call anybody of the following: Rogulenko, Fedorov, Kaluzhin (each of them has one number). Melnikov has maximal number of phone numbers of girls.
instruction
0
26,781
14
53,562
Tags: implementation, strings Correct Solution: ``` n=int(input()) L=[] M=[] MaxTaxi=0 MaxGirls=0 MaxPizza=0 WhoHasMaxTaxiNumbers=[] WhoHasMaxGirlsNumbers=[] WhoHasMaxPizzaNumbers=[] Names=[] for i in range(n): NumberTaxi=0 NumberGirls=0 NumberPizza=0 L=input().split() Names+=[L[1]] for j in range(int(L[0])): N=input().split('-') if N[0][0]==N[0][1]==N[1][0]==N[1][1]==N[2][0]==N[2][1]: NumberTaxi+=1 elif int(N[0][0])>int(N[0][1])>int(N[1][0])>int(N[1][1])>int(N[2][0])>int(N[2][1]) : NumberPizza+=1 else: NumberGirls+=1 if NumberTaxi>MaxTaxi: WhoHasMaxTaxiNumbers=[L[1]] MaxTaxi=NumberTaxi elif NumberTaxi==MaxTaxi: WhoHasMaxTaxiNumbers+=[L[1]] if NumberGirls>MaxGirls: WhoHasMaxGirlsNumbers=[L[1]] MaxGirls=NumberGirls elif NumberGirls==MaxGirls: WhoHasMaxGirlsNumbers+=[L[1]] if NumberPizza>MaxPizza: WhoHasMaxPizzaNumbers=[L[1]] MaxPizza=NumberPizza elif NumberPizza==MaxPizza: WhoHasMaxPizzaNumbers+=[L[1]] if len(WhoHasMaxTaxiNumbers)==0: print("If you want to call a taxi, you should call: ", end='') for i in range(len(Names) - 1): print(Names[i], end=', ') print(Names[-1],end='.') else: print( "If you want to call a taxi, you should call: ",end='') for i in range(len(WhoHasMaxTaxiNumbers)-1): print(WhoHasMaxTaxiNumbers[i],end=', ') print(WhoHasMaxTaxiNumbers[-1],end='.\n') if len(WhoHasMaxPizzaNumbers)==0: print("If you want to order a pizza, you should call: ", end='') for i in range(len(Names)-1): print(Names[i],end=', ') print(Names[-1],end='.\n') else: print( "If you want to order a pizza, you should call: ",end='') for i in range(len(WhoHasMaxPizzaNumbers)-1): print(WhoHasMaxPizzaNumbers[i],end=', ') print(WhoHasMaxPizzaNumbers[-1],end='.\n') if len(WhoHasMaxGirlsNumbers)==0: print("If you want to go to a cafe with a wonderful girl, you should call: ", end='') for i in range(len(Names) - 1): print(Names[i], end=', ') print(Names[-1], end='.') else: print( "If you want to go to a cafe with a wonderful girl, you should call: ",end='') for i in range(len(WhoHasMaxGirlsNumbers)-1): print(WhoHasMaxGirlsNumbers[i],end=', ') print(WhoHasMaxGirlsNumbers[-1],end='.') ```
output
1
26,781
14
53,563
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Winters are just damn freezing cold in Nvodsk! That's why a group of n friends prefers to take a taxi, order a pizza and call girls. The phone numbers in the city consist of three pairs of digits (for example, 12-34-56). Each friend has a phonebook of size si (that's the number of phone numbers). We know that taxi numbers consist of six identical digits (for example, 22-22-22), the numbers of pizza deliveries should necessarily be decreasing sequences of six different digits (for example, 98-73-21), all other numbers are the girls' numbers. You are given your friends' phone books. Calculate which friend is best to go to when you are interested in each of those things (who has maximal number of phone numbers of each type). If the phone book of one person contains some number two times, you should count it twice. That is, each number should be taken into consideration the number of times it occurs in the phone book. Input The first line contains an integer n (1 ≀ n ≀ 100) β€” the number of friends. Then follow n data blocks that describe each friend's phone books. Each block is presented in the following form: first goes the line that contains integer si and string namei (0 ≀ si ≀ 100) β€” the number of phone numbers in the phone book of the i-th friend and the name of the i-th friend. The name is a non-empty sequence of uppercase and lowercase Latin letters, containing no more than 20 characters. Next si lines contain numbers as "XX-XX-XX", where X is arbitrary digits from 0 to 9. Output In the first line print the phrase "If you want to call a taxi, you should call: ". Then print names of all friends whose phone books contain maximal number of taxi phone numbers. In the second line print the phrase "If you want to order a pizza, you should call: ". Then print names of all friends who have maximal number of pizza phone numbers. In the third line print the phrase "If you want to go to a cafe with a wonderful girl, you should call: ". Then print names of all friends who have maximal number of girls' phone numbers. Print the names in the order in which they are given in the input data. Separate two consecutive names with a comma and a space. Each line should end with exactly one point. For clarifications concerning the output form, see sample tests. It is necessary that you follow the output form strictly. Extra spaces are not allowed. Examples Input 4 2 Fedorov 22-22-22 98-76-54 3 Melnikov 75-19-09 23-45-67 99-99-98 7 Rogulenko 22-22-22 11-11-11 33-33-33 44-44-44 55-55-55 66-66-66 95-43-21 3 Kaluzhin 11-11-11 99-99-99 98-65-32 Output If you want to call a taxi, you should call: Rogulenko. If you want to order a pizza, you should call: Fedorov, Rogulenko, Kaluzhin. If you want to go to a cafe with a wonderful girl, you should call: Melnikov. Input 3 5 Gleb 66-66-66 55-55-55 01-01-01 65-43-21 12-34-56 3 Serega 55-55-55 87-65-43 65-55-21 5 Melnik 12-42-12 87-73-01 36-04-12 88-12-22 82-11-43 Output If you want to call a taxi, you should call: Gleb. If you want to order a pizza, you should call: Gleb, Serega. If you want to go to a cafe with a wonderful girl, you should call: Melnik. Input 3 3 Kulczynski 22-22-22 65-43-21 98-12-00 4 Pachocki 11-11-11 11-11-11 11-11-11 98-76-54 0 Smietanka Output If you want to call a taxi, you should call: Pachocki. If you want to order a pizza, you should call: Kulczynski, Pachocki. If you want to go to a cafe with a wonderful girl, you should call: Kulczynski. Note In the first sample you are given four friends. Fedorov's phone book contains one taxi number and one pizza delivery number, Melnikov's phone book only has 3 numbers of girls, Rogulenko's one has 6 taxi numbers and one pizza delivery number, Kaluzhin's one contains 2 taxi numbers and one pizza delivery number. Thus, if you need to order a taxi, you should obviously call Rogulenko, if you need to order a pizza you should call anybody of the following: Rogulenko, Fedorov, Kaluzhin (each of them has one number). Melnikov has maximal number of phone numbers of girls. Submitted Solution: ``` from collections import Counter from pprint import pprint n = int(input().strip()) t = n books = [] while t > 0: friend = input().strip().split() phonebook = [] friend[0] = int(friend[0]) si = friend[0] while si > 0: number = input().strip() phno = [] for val in number: if val != '-': phno.append(int(val)) phonebook.append(phno) si -= 1 books.append((friend[1], phonebook)) t -= 1 number_categories = {} max_pizza = 0 max_girls = 0 max_taxi = 0 for book in books: friend = book[0] number_categories[friend] = Counter() for contact in book[1]: digit_dict = Counter(contact) if len(digit_dict) == 1: number_categories[friend]['taxi'] += 1 elif len(digit_dict) != len(contact): number_categories[friend]['girls'] += 1 else: flag = False for i in range(1, len(contact)): if contact[i] > contact[i-1]: flag = True break if flag == False: number_categories[friend]['pizza'] += 1 else: number_categories[friend]['girls'] += 1 max_pizza = max(max_pizza, number_categories[friend]['pizza']) max_taxi = max(max_taxi, number_categories[friend]['taxi']) max_girls = max(max_girls, number_categories[friend]['girls']) max_taxi_list = [book[0] for book in books if number_categories[book[0]]['taxi'] == max_taxi] max_pizza_list = [book[0] for book in books if number_categories[book[0]]['pizza'] == max_pizza] max_girls_list = [book[0] for book in books if number_categories[book[0]]['girls'] == max_girls] print('If you want to call a taxi, you should call:', ", ".join(max_taxi_list), end='.\n') print('If you want to order a pizza, you should call:', ", ".join(max_pizza_list), end='.\n') print('If you want to go to a cafe with a wonderful girl, you should call:', ", ".join(max_girls_list), end='.\n') ```
instruction
0
26,782
14
53,564
Yes
output
1
26,782
14
53,565