message
stringlengths
2
20.1k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
1.95k
109k
cluster
float64
17
17
__index_level_0__
int64
3.91k
217k
Provide a correct Python 3 solution for this coding contest problem. <image> The International Clown and Pierrot Competition (ICPC), is one of the most distinguished and also the most popular events on earth in the show business. One of the unique features of this contest is the great number of judges that sometimes...
instruction
0
50,444
17
100,888
"Correct Solution: ``` a=[] i=0 while True: N=int(input()) if N==0: break else: for i in range(N): n=int(input()) a.append(n) a.sort() a.pop() a.pop(0) print(sum(a) // len(a)) a.clear() ```
output
1
50,444
17
100,889
Provide a correct Python 3 solution for this coding contest problem. <image> The International Clown and Pierrot Competition (ICPC), is one of the most distinguished and also the most popular events on earth in the show business. One of the unique features of this contest is the great number of judges that sometimes...
instruction
0
50,445
17
100,890
"Correct Solution: ``` import math while True: n = int(input()) if n == 0: break s = [] for i in range(n): s.append(int(input())) print(math.floor((sum(s) - min(s) - max(s)) / (n - 2))) ```
output
1
50,445
17
100,891
Provide a correct Python 3 solution for this coding contest problem. <image> The International Clown and Pierrot Competition (ICPC), is one of the most distinguished and also the most popular events on earth in the show business. One of the unique features of this contest is the great number of judges that sometimes...
instruction
0
50,446
17
100,892
"Correct Solution: ``` N=int(input()) while N!=0: data=[] for i in range(N): data.append(int(input())) data.sort() Sum=0 Count=0 for i in range(N-2): Sum+=data[i+1] Count+=1 print(Sum//Count) N=int(input()) ```
output
1
50,446
17
100,893
Provide tags and a correct Python 3 solution for this coding contest problem. «Polygon» is a system which allows to create programming tasks in a simple and professional way. When you add a test to the problem, the corresponding form asks you for the test index. As in most cases it is clear which index the next test w...
instruction
0
51,622
17
103,244
Tags: implementation, sortings Correct Solution: ``` n=int(input()) l=[int(x) for x in input().split()] l.sort() j=1 flag=0 for i in l: if(i==j): j+=1 else: print(j) flag=1 break else: print(j) ```
output
1
51,622
17
103,245
Provide tags and a correct Python 3 solution for this coding contest problem. «Polygon» is a system which allows to create programming tasks in a simple and professional way. When you add a test to the problem, the corresponding form asks you for the test index. As in most cases it is clear which index the next test w...
instruction
0
51,623
17
103,246
Tags: implementation, sortings Correct Solution: ``` n=int(input()) a=list(map(int,input().split())) dp=[0]*(3002) for _ in range(n): dp[a[_]]+=1 for _ in range(1,3002): if dp[_]==0: print(_) break ```
output
1
51,623
17
103,247
Provide tags and a correct Python 3 solution for this coding contest problem. «Polygon» is a system which allows to create programming tasks in a simple and professional way. When you add a test to the problem, the corresponding form asks you for the test index. As in most cases it is clear which index the next test w...
instruction
0
51,624
17
103,248
Tags: implementation, sortings Correct Solution: ``` n = int(input()) l = sorted(map(int, input().split())) p = 0 for e in l: if e != p + 1: break else: p = e print(p + 1) ```
output
1
51,624
17
103,249
Provide tags and a correct Python 3 solution for this coding contest problem. «Polygon» is a system which allows to create programming tasks in a simple and professional way. When you add a test to the problem, the corresponding form asks you for the test index. As in most cases it is clear which index the next test w...
instruction
0
51,626
17
103,252
Tags: implementation, sortings Correct Solution: ``` a=int(input()) b=[int(i) for i in input().split()] c=sorted(b) d=1 flag=0 for i in range(0,len(c)): if(c[i]!=d): flag=1 break else: d=d+1 print(d) ```
output
1
51,626
17
103,253
Provide tags and a correct Python 3 solution for this coding contest problem. «Polygon» is a system which allows to create programming tasks in a simple and professional way. When you add a test to the problem, the corresponding form asks you for the test index. As in most cases it is clear which index the next test w...
instruction
0
51,627
17
103,254
Tags: implementation, sortings Correct Solution: ``` n=int( input() ) l=list(map(int, input().strip().split())) h=[0 for a in range(0, 30000)] for i in l: h[i]+=1 for i in range(1,30000): if h[ i]==0: print(i) break ```
output
1
51,627
17
103,255
Provide tags and a correct Python 3 solution for this coding contest problem. «Polygon» is a system which allows to create programming tasks in a simple and professional way. When you add a test to the problem, the corresponding form asks you for the test index. As in most cases it is clear which index the next test w...
instruction
0
51,629
17
103,258
Tags: implementation, sortings Correct Solution: ``` n=int(input()) a=sorted([int(x) for x in input().split()]) for i in range(n+1): if i==n or i+1!=a[i]: print(i+1) break ```
output
1
51,629
17
103,259
Provide tags and a correct Python 3 solution for this coding contest problem. A class of students wrote a multiple-choice test. There are n students in the class. The test had m questions, each of them had 5 possible answers (A, B, C, D or E). There is exactly one correct answer for each question. The correct answer ...
instruction
0
52,298
17
104,596
Tags: implementation, strings Correct Solution: ``` n, m = map(int, input().split()) ds = [{} for _ in range(m)] for i in range(n): a = input() for ind, c in enumerate(a): ds[ind][c] = ds[ind].get(c, 0) + 1 bs = map(int, input().split()) res = 0 for d, b in zip(ds, bs): res += b*max(d.values()) ...
output
1
52,298
17
104,597
Provide tags and a correct Python 3 solution for this coding contest problem. A class of students wrote a multiple-choice test. There are n students in the class. The test had m questions, each of them had 5 possible answers (A, B, C, D or E). There is exactly one correct answer for each question. The correct answer ...
instruction
0
52,299
17
104,598
Tags: implementation, strings Correct Solution: ``` n,m=list(map(int,input().split())) A=[] Ans = 0 for _ in range(n): A.append(input()) Val= list(map(int,input().split())) D={'A':0,'B':0,'C':0,'D':0,'E':0} for i in range(m): D={'A':0,'B':0,'C':0,'D':0,'E':0} for j in range(n): D[A[j][i]] += 1 M...
output
1
52,299
17
104,599
Provide tags and a correct Python 3 solution for this coding contest problem. A class of students wrote a multiple-choice test. There are n students in the class. The test had m questions, each of them had 5 possible answers (A, B, C, D or E). There is exactly one correct answer for each question. The correct answer ...
instruction
0
52,300
17
104,600
Tags: implementation, strings Correct Solution: ``` n, m = map(int, input().split()) answer, total = [], 0 for i in range(n): answer.append(input()) points = list(map(int, input().split())) for j in range(m): correct = [0] * 5 for i in range(n): correct[ord(answer[i][j]) - 65] += 1 total += max(...
output
1
52,300
17
104,601
Provide tags and a correct Python 3 solution for this coding contest problem. A class of students wrote a multiple-choice test. There are n students in the class. The test had m questions, each of them had 5 possible answers (A, B, C, D or E). There is exactly one correct answer for each question. The correct answer ...
instruction
0
52,301
17
104,602
Tags: implementation, strings Correct Solution: ``` n, m = map(int, input().split()) a = [[0,0,0,0,0] for i in range(m)] for i in range(n): s = input() for j in range(len(s)): if s[j] == "A": a[j][0]+=1 if s[j] == "B": a[j][1]+=1 if s[j] == "C": a[j][...
output
1
52,301
17
104,603
Provide tags and a correct Python 3 solution for this coding contest problem. A class of students wrote a multiple-choice test. There are n students in the class. The test had m questions, each of them had 5 possible answers (A, B, C, D or E). There is exactly one correct answer for each question. The correct answer ...
instruction
0
52,302
17
104,604
Tags: implementation, strings Correct Solution: ``` import operator n,m = map(int,input().split()) lit = [] for i in range(n): x = list(input()) lit.append(x) # print(lit) wait = list(map(int,input().split())) # print(wait) dict1 = {'A':0,'B':0,'C':0,'D':0,'E':0} count = 0 for i in range(m): for j in range...
output
1
52,302
17
104,605
Provide tags and a correct Python 3 solution for this coding contest problem. A class of students wrote a multiple-choice test. There are n students in the class. The test had m questions, each of them had 5 possible answers (A, B, C, D or E). There is exactly one correct answer for each question. The correct answer ...
instruction
0
52,303
17
104,606
Tags: implementation, strings Correct Solution: ``` n,m=[int(x) for x in input().split()] answer=[[0]*5 for i in range(m)] for j in range(n): a=input() for i in range(m): item=a[i] if item=='A': answer[i][0]+=1 elif item=='B': answer[i][1]+=1 elif item=='C...
output
1
52,303
17
104,607
Provide tags and a correct Python 3 solution for this coding contest problem. A class of students wrote a multiple-choice test. There are n students in the class. The test had m questions, each of them had 5 possible answers (A, B, C, D or E). There is exactly one correct answer for each question. The correct answer ...
instruction
0
52,304
17
104,608
Tags: implementation, strings Correct Solution: ``` n, m = map(int, input().split()) g = [0]*n for i in range(n): g[i] = input() a = list(map(int, input().split())) end = 0 for i in range(m): temp = [t[i] for t in g] maxt = max([sum([t == c for t in temp]) for c in "ABCDE"]) end += maxt * a[i] print(end...
output
1
52,304
17
104,609
Provide tags and a correct Python 3 solution for this coding contest problem. A class of students wrote a multiple-choice test. There are n students in the class. The test had m questions, each of them had 5 possible answers (A, B, C, D or E). There is exactly one correct answer for each question. The correct answer ...
instruction
0
52,305
17
104,610
Tags: implementation, strings Correct Solution: ``` n, m = map(int, input().split()) s = [] ans = [] for i in range(n): s.append(input()) z = list(map(int, input().split())) q = {k: [] for k in range(m)} for i in s: for j in range(m): q[j].append(i[j]) for i in q.values(): a = i.count('A') b = i...
output
1
52,305
17
104,611
Provide a correct Python 3 solution for this coding contest problem. In order to participate in the Asian Regional Qualifiers of the International Collegiate Programming Contest held every year in Japan, we must break through the strict domestic qualifiers. Even though it is a university competition, multiple teams f...
instruction
0
52,982
17
105,964
"Correct Solution: ``` from collections import defaultdict while True: n = int(input()) if n == 0: break teams = [] for _ in range(n): i, u, a, p = map(int, input().split()) teams.append((-a, p, i, u)) teams.sort() u_counter = defaultdict(int) all_counter = 0 selected = [] for _, _, i, ...
output
1
52,982
17
105,965
Provide a correct Python 3 solution for this coding contest problem. In order to participate in the Asian Regional Qualifiers of the International Collegiate Programming Contest held every year in Japan, we must break through the strict domestic qualifiers. Even though it is a university competition, multiple teams f...
instruction
0
52,983
17
105,966
"Correct Solution: ``` while True: n = int(input()) if n == 0:break p = [tuple(map(int, input().split())) for _ in range(n)] p.sort() p.sort(key = lambda x:x[3]) p.sort(key = lambda x:x[2], reverse = True) s = 0 sg = {} for i in p: if s < 10: try: ...
output
1
52,983
17
105,967
Provide a correct Python 3 solution for this coding contest problem. In order to participate in the Asian Regional Qualifiers of the International Collegiate Programming Contest held every year in Japan, we must break through the strict domestic qualifiers. Even though it is a university competition, multiple teams f...
instruction
0
52,984
17
105,968
"Correct Solution: ``` while 1: n = int(input()) if n == 0: break data = [] for _ in range(n): i, u, a, p = map(int, input().split()) data.append([i, u, a, p]) data = sorted(data, key=lambda x: (-x[2], x[3], x[0])) union = [0] * 1001 cnt = 0 for d in data: ...
output
1
52,984
17
105,969
Provide a correct Python 3 solution for this coding contest problem. In order to participate in the Asian Regional Qualifiers of the International Collegiate Programming Contest held every year in Japan, we must break through the strict domestic qualifiers. Even though it is a university competition, multiple teams f...
instruction
0
52,985
17
105,970
"Correct Solution: ``` def team_sort(teams, n): for i in range(n - 1): #print(i) for j in range(n - i - 1): #print(i, j, teams[j][2], teams[j+1][2]) if (teams[j][2] < teams[j + 1][2]): tmp = teams[j] teams[j] = teams[j+1] teams[...
output
1
52,985
17
105,971
Provide a correct Python 3 solution for this coding contest problem. In order to participate in the Asian Regional Qualifiers of the International Collegiate Programming Contest held every year in Japan, we must break through the strict domestic qualifiers. Even though it is a university competition, multiple teams f...
instruction
0
52,986
17
105,972
"Correct Solution: ``` while True : n = int(input()) if n == 0 : break Team = [list(map(int, input().split())) for i in range(n)] Team.sort(key=lambda x: (-x[2], x[3], x[0])) Senbatsu_Syozoku = [0] * 1001 Senbatsu_amount = 0 for i in range(n) : if Senbatsu_amount < ...
output
1
52,986
17
105,973
Provide a correct Python 3 solution for this coding contest problem. In order to participate in the Asian Regional Qualifiers of the International Collegiate Programming Contest held every year in Japan, we must break through the strict domestic qualifiers. Even though it is a university competition, multiple teams f...
instruction
0
52,987
17
105,974
"Correct Solution: ``` def main(): while True: n = int(input()) if n == 0: break teams = [] for i in range(n): teams.append(list(map(int, input().split()))) def same_len(l): return len(list(filter(lambda x: x[1] == e[1], ans))) ans =...
output
1
52,987
17
105,975
Provide a correct Python 3 solution for this coding contest problem. In order to participate in the Asian Regional Qualifiers of the International Collegiate Programming Contest held every year in Japan, we must break through the strict domestic qualifiers. Even though it is a university competition, multiple teams f...
instruction
0
52,988
17
105,976
"Correct Solution: ``` while 1: in_tmp = input() if (in_tmp == "0"): break list_team = [] for i in range(int(in_tmp)): list_team.append(list(map(int,input().split()))) list_sorted = sorted(list_team, key=lambda x:(-x[2], x[3], x[0])) cnt_passed = 0 dict_passed = {} f...
output
1
52,988
17
105,977
Provide a correct Python 3 solution for this coding contest problem. In order to participate in the Asian Regional Qualifiers of the International Collegiate Programming Contest held every year in Japan, we must break through the strict domestic qualifiers. Even though it is a university competition, multiple teams f...
instruction
0
52,989
17
105,978
"Correct Solution: ``` # AOJ 1043: Selecting Teams Advanced to Regional # Python3 2018.7.6 bal4u def pr(i, u): global total print(team[i][0]) total, affi[u] = total+1, affi[u]+1 while True: n = int(input()) if n == 0: break team = [] for i in range(n): id, u, a, p = map(int, input().split()) team.append((i...
output
1
52,989
17
105,979
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In order to participate in the Asian Regional Qualifiers of the International Collegiate Programming Contest held every year in Japan, we must break through the strict domestic qualifiers. Even...
instruction
0
52,990
17
105,980
Yes
output
1
52,990
17
105,981
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In order to participate in the Asian Regional Qualifiers of the International Collegiate Programming Contest held every year in Japan, we must break through the strict domestic qualifiers. Even...
instruction
0
52,991
17
105,982
Yes
output
1
52,991
17
105,983
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In order to participate in the Asian Regional Qualifiers of the International Collegiate Programming Contest held every year in Japan, we must break through the strict domestic qualifiers. Even...
instruction
0
52,992
17
105,984
No
output
1
52,992
17
105,985
Provide tags and a correct Python 3 solution for this coding contest problem. The tournament «Sleepyhead-2010» in the rapid falling asleep has just finished in Berland. n best participants from the country have participated in it. The tournament consists of games, each of them is a match between two participants. n·(n...
instruction
0
53,363
17
106,726
Tags: bitmasks, brute force, dfs and similar, greedy Correct Solution: ``` a=int(input()) z=(a*(a-1))//2-1 k=[] for i in range(a):k.append([0]*a) for i in range(z): u,v=map(int,input().split()) u-=1;v-=1 k[u][v]=1 k[v][u]=-1 x,y=0,0 for i in range(a): for j in range(1+i,a): if (k[i][j]==0):x,...
output
1
53,363
17
106,727
Provide tags and a correct Python 3 solution for this coding contest problem. The tournament «Sleepyhead-2010» in the rapid falling asleep has just finished in Berland. n best participants from the country have participated in it. The tournament consists of games, each of them is a match between two participants. n·(n...
instruction
0
53,364
17
106,728
Tags: bitmasks, brute force, dfs and similar, greedy Correct Solution: ``` # _ ##################################################################################################################### def missingRecord(nParticipants, currRecord): storage = {str(participant): set() for participant in range(1, nParticip...
output
1
53,364
17
106,729
Provide tags and a correct Python 3 solution for this coding contest problem. The tournament «Sleepyhead-2010» in the rapid falling asleep has just finished in Berland. n best participants from the country have participated in it. The tournament consists of games, each of them is a match between two participants. n·(n...
instruction
0
53,365
17
106,730
Tags: bitmasks, brute force, dfs and similar, greedy Correct Solution: ``` from collections import defaultdict n = int(input()) wins = defaultdict(int) #loses = defaultdict(int) total = defaultdict(int) for i in range(n*(n-1)//2-1): x,y = [int(x) for x in str(input()).split()] wins[x]+=1 #loses[y]+=1 total[...
output
1
53,365
17
106,731
Provide tags and a correct Python 3 solution for this coding contest problem. The tournament «Sleepyhead-2010» in the rapid falling asleep has just finished in Berland. n best participants from the country have participated in it. The tournament consists of games, each of them is a match between two participants. n·(n...
instruction
0
53,366
17
106,732
Tags: bitmasks, brute force, dfs and similar, greedy Correct Solution: ``` n=int(input()) L=[0 for i in range(n+1)] wins={} p=(n*(n-1))//2-1 for i in range(p): a,b=map(int,input().split()) L[a]+=1 L[b]+=1 if a in wins: wins[a].append(b) else: wins[a]=[b] M=[] for i in range(1,n+1): ...
output
1
53,366
17
106,733
Provide tags and a correct Python 3 solution for this coding contest problem. The tournament «Sleepyhead-2010» in the rapid falling asleep has just finished in Berland. n best participants from the country have participated in it. The tournament consists of games, each of them is a match between two participants. n·(n...
instruction
0
53,367
17
106,734
Tags: bitmasks, brute force, dfs and similar, greedy Correct Solution: ``` def bfs(d,n,u,v): visited=[False]*n queue=[] queue.append(u) while queue: s=queue.pop(0) if s==v: return True visited[s]=True for i in d[s]: if visited[i]==False: ...
output
1
53,367
17
106,735
Provide tags and a correct Python 3 solution for this coding contest problem. The tournament «Sleepyhead-2010» in the rapid falling asleep has just finished in Berland. n best participants from the country have participated in it. The tournament consists of games, each of them is a match between two participants. n·(n...
instruction
0
53,368
17
106,736
Tags: bitmasks, brute force, dfs and similar, greedy Correct Solution: ``` def bfs(graph,source,destination): queue=[source] visited={source:True} while queue: s=queue.pop(0) if graph.get(s)!=None: for node in graph[s]: if visited.get(node)==None: ...
output
1
53,368
17
106,737
Provide tags and a correct Python 3 solution for this coding contest problem. The tournament «Sleepyhead-2010» in the rapid falling asleep has just finished in Berland. n best participants from the country have participated in it. The tournament consists of games, each of them is a match between two participants. n·(n...
instruction
0
53,369
17
106,738
Tags: bitmasks, brute force, dfs and similar, greedy Correct Solution: ``` n = int(input()) freq = {} wins = {} for i in range(1, n+1): freq[i] = 0 wins[i] = 0 for i in range(n*(n-1)//2 - 1): a, b = [int(p) for p in input().split()] freq[a] += 1 freq[b] += 1 wins[a] += 1 final = [] for i in freq...
output
1
53,369
17
106,739
Provide tags and a correct Python 3 solution for this coding contest problem. The tournament «Sleepyhead-2010» in the rapid falling asleep has just finished in Berland. n best participants from the country have participated in it. The tournament consists of games, each of them is a match between two participants. n·(n...
instruction
0
53,370
17
106,740
Tags: bitmasks, brute force, dfs and similar, greedy Correct Solution: ``` import sys def make_larger(cur, value=0): if value < max(values[cur], value): return value = max(values[cur], value) values[cur] = value if cur not in set_larger: return for new in set_larger[...
output
1
53,370
17
106,741
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The tournament «Sleepyhead-2010» in the rapid falling asleep has just finished in Berland. n best participants from the country have participated in it. The tournament consists of games, each of...
instruction
0
53,371
17
106,742
Yes
output
1
53,371
17
106,743
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The tournament «Sleepyhead-2010» in the rapid falling asleep has just finished in Berland. n best participants from the country have participated in it. The tournament consists of games, each of...
instruction
0
53,372
17
106,744
Yes
output
1
53,372
17
106,745
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The tournament «Sleepyhead-2010» in the rapid falling asleep has just finished in Berland. n best participants from the country have participated in it. The tournament consists of games, each of...
instruction
0
53,373
17
106,746
Yes
output
1
53,373
17
106,747
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The tournament «Sleepyhead-2010» in the rapid falling asleep has just finished in Berland. n best participants from the country have participated in it. The tournament consists of games, each of...
instruction
0
53,374
17
106,748
Yes
output
1
53,374
17
106,749
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The tournament «Sleepyhead-2010» in the rapid falling asleep has just finished in Berland. n best participants from the country have participated in it. The tournament consists of games, each of...
instruction
0
53,375
17
106,750
No
output
1
53,375
17
106,751
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The tournament «Sleepyhead-2010» in the rapid falling asleep has just finished in Berland. n best participants from the country have participated in it. The tournament consists of games, each of...
instruction
0
53,376
17
106,752
No
output
1
53,376
17
106,753
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The tournament «Sleepyhead-2010» in the rapid falling asleep has just finished in Berland. n best participants from the country have participated in it. The tournament consists of games, each of...
instruction
0
53,377
17
106,754
No
output
1
53,377
17
106,755
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The tournament «Sleepyhead-2010» in the rapid falling asleep has just finished in Berland. n best participants from the country have participated in it. The tournament consists of games, each of...
instruction
0
53,378
17
106,756
No
output
1
53,378
17
106,757
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start i...
instruction
0
53,598
17
107,196
Yes
output
1
53,598
17
107,197
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start i...
instruction
0
53,599
17
107,198
No
output
1
53,599
17
107,199
Provide tags and a correct Python 3 solution for this coding contest problem. You have n students under your control and you have to compose exactly two teams consisting of some subset of your students. Each student had his own skill, the i-th student skill is denoted by an integer a_i (different students can have the...
instruction
0
54,077
17
108,154
Tags: binary search, greedy, implementation, sortings Correct Solution: ``` def solve(a): d = {} for x in a: d[x] = d.get(x, 0) + 1 mf = max(f for x, f in d.items()) return max(min(len(d)-1, mf), min(len(d), mf-1)) t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, i...
output
1
54,077
17
108,155
Provide tags and a correct Python 3 solution for this coding contest problem. You have n students under your control and you have to compose exactly two teams consisting of some subset of your students. Each student had his own skill, the i-th student skill is denoted by an integer a_i (different students can have the...
instruction
0
54,078
17
108,156
Tags: binary search, greedy, implementation, sortings Correct Solution: ``` from collections import* for s in[*open(0)][2::2]:a=Counter(s.split()).values();x=len(a);y=max(a);print(min(x,y)-(x==y)) ```
output
1
54,078
17
108,157
Provide tags and a correct Python 3 solution for this coding contest problem. You have n students under your control and you have to compose exactly two teams consisting of some subset of your students. Each student had his own skill, the i-th student skill is denoted by an integer a_i (different students can have the...
instruction
0
54,079
17
108,158
Tags: binary search, greedy, implementation, sortings Correct Solution: ``` from collections import defaultdict t = int(input()) for _ in range(t): n = int(input()) a = map(int, input().split()) d = defaultdict(int) for i in a: d[i] += 1 first_team = len(d.keys()) second_team = max(d.va...
output
1
54,079
17
108,159
Provide tags and a correct Python 3 solution for this coding contest problem. You have n students under your control and you have to compose exactly two teams consisting of some subset of your students. Each student had his own skill, the i-th student skill is denoted by an integer a_i (different students can have the...
instruction
0
54,080
17
108,160
Tags: binary search, greedy, implementation, sortings Correct Solution: ``` for q in range(int(input())): n = int(input()) a = list(map(int,input().split())) d = {} uni = 0 for i in a: if d.get(i, 0) == 0: uni+=1 d[i] = 1 else: d[i]+=1 res = 0 uni-=1 for k in d.keys(): res = max(min(d[k], uni),re...
output
1
54,080
17
108,161