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
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya studies music. He has learned lots of interesting stuff. For example, he knows that there are 12 notes: C, C#, D, D#, E, F, F#, G, G#, A, B, H. He also knows that the notes are repeated cyclically: after H goes C again, and before C ...
instruction
0
8,785
14
17,570
Tags: brute force, implementation Correct Solution: ``` # Problem: 88A # Time Created: August 10(Monday) 2020 || 11:37:58 #>-------------------------<# import sys input = sys.stdin.readline #>-------------------------<# from itertools import permutations # Helper Functions. -> Don't cluster your code. def check_cho...
output
1
8,785
14
17,571
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya studies music. He has learned lots of interesting stuff. For example, he knows that there are 12 notes: C, C#, D, D#, E, F, F#, G, G#, A, B, H. He also knows that the notes are repeated cyclically: after H goes C again, and before C ...
instruction
0
8,786
14
17,572
Tags: brute force, implementation Correct Solution: ``` a,b,c=map(str,input().split()) def pos(a,b): d={"C":1, "C#":2, "D":3, "D#":4, "E":5, "F":6, "F#":7, "G":8, "G#":9, "A":10, "B":11, "H":12} if d[a]<d[b]: return d[b]-d[a] else: return 12-d[a]+d[b] l=[[a,b,c],[b,a,c],[a,c,b],[c,a,b],[b,c,...
output
1
8,786
14
17,573
Provide tags and a correct Python 3 solution for this coding contest problem. While Grisha was celebrating New Year with Ded Moroz, Misha gifted Sasha a small rectangular pond of size n × m, divided into cells of size 1 × 1, inhabited by tiny evil fishes (no more than one fish per cell, otherwise they'll strife!). Th...
instruction
0
8,795
14
17,590
Tags: data structures, graphs, greedy, probabilities, shortest paths Correct Solution: ``` n, m, r, k = map(int, input().split()) def count(y, x): minx = max(0, x-(r-1)) maxx = min(m-1-(r-1), x) miny = max(0, y-(r-1)) maxy = min(n-1-(r-1), y) res = (maxy-miny+1)*(maxx-minx+1) return res #X = [...
output
1
8,795
14
17,591
Provide tags and a correct Python 3 solution for this coding contest problem. While Grisha was celebrating New Year with Ded Moroz, Misha gifted Sasha a small rectangular pond of size n × m, divided into cells of size 1 × 1, inhabited by tiny evil fishes (no more than one fish per cell, otherwise they'll strife!). Th...
instruction
0
8,796
14
17,592
Tags: data structures, graphs, greedy, probabilities, shortest paths Correct Solution: ``` import queue q = queue.PriorityQueue() n, m, r, k = map(int, input().split()) a = min(r, n - r + 1) b = min(r, m - r + 1) u = n - 2 * a + 2 v = m - 2 * b + 2 for i in range(1, a + 1): q.put((-b * i, i)) t = 0 while k: s, i = ...
output
1
8,796
14
17,593
Provide tags and a correct Python 3 solution for this coding contest problem. While Grisha was celebrating New Year with Ded Moroz, Misha gifted Sasha a small rectangular pond of size n × m, divided into cells of size 1 × 1, inhabited by tiny evil fishes (no more than one fish per cell, otherwise they'll strife!). Th...
instruction
0
8,797
14
17,594
Tags: data structures, graphs, greedy, probabilities, shortest paths Correct Solution: ``` class TupleHeap(object): def __init__(self): self.heap = [0] def mult(self, i): return self.heap[i][0] * self.heap[i][1] def __str__(self): return " ".join(map(str, self.heap)) def add(self...
output
1
8,797
14
17,595
Provide tags and a correct Python 3 solution for this coding contest problem. While Grisha was celebrating New Year with Ded Moroz, Misha gifted Sasha a small rectangular pond of size n × m, divided into cells of size 1 × 1, inhabited by tiny evil fishes (no more than one fish per cell, otherwise they'll strife!). Th...
instruction
0
8,798
14
17,596
Tags: data structures, graphs, greedy, probabilities, shortest paths Correct Solution: ``` # https://codeforces.com/problemset/problem/912/D import heapq from heapq import heappush as push from heapq import heappop as pop base = 100009 Q=[] used={} ans=0 dx = [0,0,-1,1] dy = [-1,1,0,0] def f(x, y): x1, x2 = min...
output
1
8,798
14
17,597
Provide tags and a correct Python 3 solution for this coding contest problem. While Grisha was celebrating New Year with Ded Moroz, Misha gifted Sasha a small rectangular pond of size n × m, divided into cells of size 1 × 1, inhabited by tiny evil fishes (no more than one fish per cell, otherwise they'll strife!). Th...
instruction
0
8,799
14
17,598
Tags: data structures, graphs, greedy, probabilities, shortest paths Correct Solution: ``` import heapq as hq from queue import PriorityQueue import math n,m,r, k= input().split() N = int(n) M = int(m) R = int(r) K = int(k) q = PriorityQueue() for i in range(1,math.floor((N+1)/2) + 1): maxi = min(min(i,N-i+1),...
output
1
8,799
14
17,599
Provide tags and a correct Python 3 solution for this coding contest problem. While Grisha was celebrating New Year with Ded Moroz, Misha gifted Sasha a small rectangular pond of size n × m, divided into cells of size 1 × 1, inhabited by tiny evil fishes (no more than one fish per cell, otherwise they'll strife!). Th...
instruction
0
8,800
14
17,600
Tags: data structures, graphs, greedy, probabilities, shortest paths Correct Solution: ``` from heapq import * n, m, r, k = map(int, input().split()) u, v = n // 2, m // 2 h = [] g = lambda z, l: min(z + 1, l - z, l - r + 1, r) def f(x, y): if 0 <= x < n and 0 <= y < m: s = g(x, n) * g(y, m) heappus...
output
1
8,800
14
17,601
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. While Grisha was celebrating New Year with Ded Moroz, Misha gifted Sasha a small rectangular pond of size n × m, divided into cells of size 1 × 1, inhabited by tiny evil fishes (no more than one...
instruction
0
8,801
14
17,602
No
output
1
8,801
14
17,603
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. While Grisha was celebrating New Year with Ded Moroz, Misha gifted Sasha a small rectangular pond of size n × m, divided into cells of size 1 × 1, inhabited by tiny evil fishes (no more than one...
instruction
0
8,802
14
17,604
No
output
1
8,802
14
17,605
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. While Grisha was celebrating New Year with Ded Moroz, Misha gifted Sasha a small rectangular pond of size n × m, divided into cells of size 1 × 1, inhabited by tiny evil fishes (no more than one...
instruction
0
8,803
14
17,606
No
output
1
8,803
14
17,607
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. While Grisha was celebrating New Year with Ded Moroz, Misha gifted Sasha a small rectangular pond of size n × m, divided into cells of size 1 × 1, inhabited by tiny evil fishes (no more than one...
instruction
0
8,804
14
17,608
No
output
1
8,804
14
17,609
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Today is the open campus of Z University. Every year during the lunch break on this day, many high school students line up for the school cafeteria. Therefore, the secretariat of Z University de...
instruction
0
8,984
14
17,968
No
output
1
8,984
14
17,969
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Today is the open campus of Z University. Every year during the lunch break on this day, many high school students line up for the school cafeteria. Therefore, the secretariat of Z University de...
instruction
0
8,985
14
17,970
No
output
1
8,985
14
17,971
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Today is the open campus of Z University. Every year during the lunch break on this day, many high school students line up for the school cafeteria. Therefore, the secretariat of Z University de...
instruction
0
8,986
14
17,972
No
output
1
8,986
14
17,973
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Today is the open campus of Z University. Every year during the lunch break on this day, many high school students line up for the school cafeteria. Therefore, the secretariat of Z University de...
instruction
0
8,987
14
17,974
No
output
1
8,987
14
17,975
Provide a correct Python 3 solution for this coding contest problem. Write a program which reads relations in a SNS (Social Network Service), and judges that given pairs of users are reachable each other through the network. Constraints * $2 \leq n \leq 100,000$ * $0 \leq m \leq 100,000$ * $1 \leq q \leq 10,000$ In...
instruction
0
9,024
14
18,048
"Correct Solution: ``` from collections import deque def bfs(graph, start): visited = {start: None} unvisited = deque() unvisited.append(start) while unvisited: now = unvisited.popleft() for next in graph[now]: if not (next in visited): unvisited.append(next)...
output
1
9,024
14
18,049
Provide a correct Python 3 solution for this coding contest problem. Write a program which reads relations in a SNS (Social Network Service), and judges that given pairs of users are reachable each other through the network. Constraints * $2 \leq n \leq 100,000$ * $0 \leq m \leq 100,000$ * $1 \leq q \leq 10,000$ In...
instruction
0
9,025
14
18,050
"Correct Solution: ``` n, m = map(int,input().split()) g = {} for i in range(m): s,t = map(int,input().split()) val = g.get(s,[]) val.append(t) g[s] = val val = g.get(t,[]) val.append(s) g[t] = val color = 1 done = [-1] + [-1] * n def dfs(g, s): done[s] = color stack = [s] whi...
output
1
9,025
14
18,051
Provide a correct Python 3 solution for this coding contest problem. Write a program which reads relations in a SNS (Social Network Service), and judges that given pairs of users are reachable each other through the network. Constraints * $2 \leq n \leq 100,000$ * $0 \leq m \leq 100,000$ * $1 \leq q \leq 10,000$ In...
instruction
0
9,026
14
18,052
"Correct Solution: ``` # coding: UTF-8 from collections import deque n,m = map(int,input().split()) link = [[] for _ in range(n)] part = [-1 for _ in range(n)] for _ in range(m): u,v = map(int,input().split()) link[u].append(v) link[v].append(u) searched = set() queue = deque() pindex = 0 for u in range(n): if...
output
1
9,026
14
18,053
Provide a correct Python 3 solution for this coding contest problem. Write a program which reads relations in a SNS (Social Network Service), and judges that given pairs of users are reachable each other through the network. Constraints * $2 \leq n \leq 100,000$ * $0 \leq m \leq 100,000$ * $1 \leq q \leq 10,000$ In...
instruction
0
9,027
14
18,054
"Correct Solution: ``` from collections import deque n,m = [int(i) for i in input().split()] F = [{} for i in range(n)] for _ in range(m): i,j = [int(i) for i in input().split()] F[i][j] = 1 F[j][i] = 1 q = int(input()) DP = [0 for i in range(n)] c = 1 d = deque() for i in range(n): if DP[i]: co...
output
1
9,027
14
18,055
Provide a correct Python 3 solution for this coding contest problem. Write a program which reads relations in a SNS (Social Network Service), and judges that given pairs of users are reachable each other through the network. Constraints * $2 \leq n \leq 100,000$ * $0 \leq m \leq 100,000$ * $1 \leq q \leq 10,000$ In...
instruction
0
9,028
14
18,056
"Correct Solution: ``` #!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 10 9 0 1 0 2 3 4 5 7 5 6 6 7 6 8 7 8 8 9 3 0 1 5 9 1 3 output: yes yes no """ import sys def assign_color(): v_color = 0 for v in range(v_num): if color[v] == -1: graph_dfs(v, v_color) # use int...
output
1
9,028
14
18,057
Provide a correct Python 3 solution for this coding contest problem. Write a program which reads relations in a SNS (Social Network Service), and judges that given pairs of users are reachable each other through the network. Constraints * $2 \leq n \leq 100,000$ * $0 \leq m \leq 100,000$ * $1 \leq q \leq 10,000$ In...
instruction
0
9,029
14
18,058
"Correct Solution: ``` n, m = map(int, input().split()) # 隣接リストの雛形 D = dict() for i in range(n): D[i] = [] # グラフを入力 for _ in range(m): s, t = map(int, input().split()) D[s].append(t) D[t].append(s) group = [-1]*n cnt = 0 for i in range(n): if group[i] == -1: group[i] = cnt stack =...
output
1
9,029
14
18,059
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which reads relations in a SNS (Social Network Service), and judges that given pairs of users are reachable each other through the network. Constraints * $2 \leq n \leq 100,000...
instruction
0
9,032
14
18,064
Yes
output
1
9,032
14
18,065
Provide tags and a correct Python 3 solution for this coding contest problem. There are n kids, numbered from 1 to n, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as p_1, p_2, ..., p_n (all these numbers are from 1 to n and are distinct, so p is a permutation). Let the n...
instruction
0
9,118
14
18,236
Tags: implementation Correct Solution: ``` n = int(input()) nextnode = [[] for i in range(n+1)] visited = [False]*(n+1) fir, sec = -1, -1 for i in range(n): x, y = map(int, input().split()) nextnode[x].append(y) nextnode[y].append(x) if i == 0: fir, sec = x, y visited[fir] = True ...
output
1
9,118
14
18,237
Provide tags and a correct Python 3 solution for this coding contest problem. There are n kids, numbered from 1 to n, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as p_1, p_2, ..., p_n (all these numbers are from 1 to n and are distinct, so p is a permutation). Let the n...
instruction
0
9,119
14
18,238
Tags: implementation Correct Solution: ``` from sys import stdin n=int(input()) if n==3: print("3 1 2") else: pairs=[(0,0)] for i in range(n): a,b=[int(x) for x in stdin.readline().split()] pairs.append((a,b)) ans=[] j=1 while len(ans)<n: p=pairs[j] if set([p...
output
1
9,119
14
18,239
Provide tags and a correct Python 3 solution for this coding contest problem. There are n kids, numbered from 1 to n, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as p_1, p_2, ..., p_n (all these numbers are from 1 to n and are distinct, so p is a permutation). Let the n...
instruction
0
9,120
14
18,240
Tags: implementation Correct Solution: ``` def kk(): n = int(input()) if n == 3: return '1 2 3' kids = [[] for i in range(n+1)] for i in range(1,n+1): a,b = [int(i) for i in input().split()] kids[i].append(a) kids[i].append(b) res = '1' curr = 1 init = 1 w...
output
1
9,120
14
18,241
Provide tags and a correct Python 3 solution for this coding contest problem. There are n kids, numbered from 1 to n, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as p_1, p_2, ..., p_n (all these numbers are from 1 to n and are distinct, so p is a permutation). Let the n...
instruction
0
9,121
14
18,242
Tags: implementation Correct Solution: ``` n=int(input()) R=lambda:map(int,input().split()) l=[0] for i in range(n): x,y=R() l.append([x,y]) r=[1]*n i=0 while i<n-2: p=l[r[i]][0] q=l[r[i]][1] i+=1 if q in l[p]: r[i]=p else: r[i]=q p=l[r[n-2]][0] q=l[r[n-2]][1] if p!=1: r[n-1]...
output
1
9,121
14
18,243
Provide tags and a correct Python 3 solution for this coding contest problem. There are n kids, numbered from 1 to n, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as p_1, p_2, ..., p_n (all these numbers are from 1 to n and are distinct, so p is a permutation). Let the n...
instruction
0
9,122
14
18,244
Tags: implementation Correct Solution: ``` #15:35 n = int(input()) circ = [] l = [] for i in range(n): a1, a2 = map(int, input().split()) a1 -= 1 a2 -= 1 l.append((a1, a2)) circ.append(l[0][0]) circ.append(l[0][1]) for i in range(0, n - 1): p = l[circ[i]] if circ[i + 1] not in p: ...
output
1
9,122
14
18,245
Provide tags and a correct Python 3 solution for this coding contest problem. There are n kids, numbered from 1 to n, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as p_1, p_2, ..., p_n (all these numbers are from 1 to n and are distinct, so p is a permutation). Let the n...
instruction
0
9,123
14
18,246
Tags: implementation Correct Solution: ``` n = int(input()) if n == 3: print(3, 2, 1) exit() d = [] d.append([0, 0]) for i in range(n): x, y = map(int, input().split()) d.append([x, y]) x = 1 ans = [] ans.append(1) while True: t = d[x][0] if d[t][0] == d[x][1] or d[t][1] == d[x][1]: ans....
output
1
9,123
14
18,247
Provide tags and a correct Python 3 solution for this coding contest problem. There are n kids, numbered from 1 to n, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as p_1, p_2, ..., p_n (all these numbers are from 1 to n and are distinct, so p is a permutation). Let the n...
instruction
0
9,124
14
18,248
Tags: implementation Correct Solution: ``` import math n = int(input()) a = [] for i in range(n): a1, a2 = map(int, input().split()) a1 = a1-1 a2 = a2-1 a.append([a1, a2]) st = 0 b = [0]*n for i in range(n): print(st+1, end=" ") b[st] = 1 a1 = a[st][0] a2 = a[st][1] if (a[a2][0]==a...
output
1
9,124
14
18,249
Provide tags and a correct Python 3 solution for this coding contest problem. There are n kids, numbered from 1 to n, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as p_1, p_2, ..., p_n (all these numbers are from 1 to n and are distinct, so p is a permutation). Let the n...
instruction
0
9,125
14
18,250
Tags: implementation Correct Solution: ``` from sys import stdin input=stdin.buffer.readline n=int(input()) d={} for i in range(1,n+1): x,y=map(int,input().split()) d[i]=(x,y) ans=[1] while len(ans)<n: x=ans[-1] a=d[x][0] b=d[x][1] if b in d[a]: ans.append(a) ans.append(b) ...
output
1
9,125
14
18,251
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n kids, numbered from 1 to n, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as p_1, p_2, ..., p_n (all these numbers are from 1 to n and ...
instruction
0
9,126
14
18,252
Yes
output
1
9,126
14
18,253
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n kids, numbered from 1 to n, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as p_1, p_2, ..., p_n (all these numbers are from 1 to n and ...
instruction
0
9,127
14
18,254
Yes
output
1
9,127
14
18,255
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n kids, numbered from 1 to n, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as p_1, p_2, ..., p_n (all these numbers are from 1 to n and ...
instruction
0
9,128
14
18,256
Yes
output
1
9,128
14
18,257
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n kids, numbered from 1 to n, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as p_1, p_2, ..., p_n (all these numbers are from 1 to n and ...
instruction
0
9,129
14
18,258
Yes
output
1
9,129
14
18,259
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n kids, numbered from 1 to n, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as p_1, p_2, ..., p_n (all these numbers are from 1 to n and ...
instruction
0
9,130
14
18,260
No
output
1
9,130
14
18,261
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n kids, numbered from 1 to n, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as p_1, p_2, ..., p_n (all these numbers are from 1 to n and ...
instruction
0
9,131
14
18,262
No
output
1
9,131
14
18,263
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n kids, numbered from 1 to n, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as p_1, p_2, ..., p_n (all these numbers are from 1 to n and ...
instruction
0
9,132
14
18,264
No
output
1
9,132
14
18,265
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n kids, numbered from 1 to n, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as p_1, p_2, ..., p_n (all these numbers are from 1 to n and ...
instruction
0
9,133
14
18,266
No
output
1
9,133
14
18,267
Provide tags and a correct Python 3 solution for this coding contest problem. This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite o...
instruction
0
9,154
14
18,308
Tags: data structures, implementation Correct Solution: ``` n = int(input()) lis = [0]+list(map(int,input().split())) d=[0]*(100005) ans=0 c=0 mx=0 cnt=[0]*(100005) for i in range(1,n+1): # print(lis[i]) cnt[d[lis[i]]]-=1 d[lis[i]]+=1 cnt[d[lis[i]]]+=1 mx = max(mx,d[lis[i]]) # print(d[:20],cnt[:20...
output
1
9,154
14
18,309
Provide tags and a correct Python 3 solution for this coding contest problem. This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite o...
instruction
0
9,155
14
18,310
Tags: data structures, implementation Correct Solution: ``` n = int(input()) a = list(map(int, input().split())) p = [[0] * 10for i in range(n + 1)] for i in range(1, n + 1): p[i][a[i - 1] - 1] += 1 for j in range(10): p[i][j] += p[i - 1][j] for i in range(n, 0, -1): k = set(p[i]) if 0 in k: ...
output
1
9,155
14
18,311
Provide tags and a correct Python 3 solution for this coding contest problem. This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite o...
instruction
0
9,156
14
18,312
Tags: data structures, implementation Correct Solution: ``` '''input 5 10 2 5 4 1 ''' from sys import stdin, setrecursionlimit from bisect import bisect_right setrecursionlimit(15000) def freq(num, mylist): count = 0 for i in mylist: if i == num: count += 1 return count def update_x(mydict, index, x): myse...
output
1
9,156
14
18,313
Provide tags and a correct Python 3 solution for this coding contest problem. This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite o...
instruction
0
9,157
14
18,314
Tags: data structures, implementation Correct Solution: ``` n=int(input()) a=list(map(int,input().split())) u=[0]*10 sl=0 for i in range(n): u[a[i]-1]+=1 s=sorted(u) for j in range(10): if(s[j]!=0): break if(s[j]==s[8] and s[9]-s[8]==1): sl=max(sl,i+1) elif(s[j]==1 and s[...
output
1
9,157
14
18,315
Provide tags and a correct Python 3 solution for this coding contest problem. This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite o...
instruction
0
9,158
14
18,316
Tags: data structures, implementation Correct Solution: ``` def streak(arr,l): x=[] for i in arr: if(i!=0): x.append(i) # print(x) mini = min(x) maxi = max(x) mincount = x.count(mini) maxcount = x.count(maxi) # print(mini,mincount,maxi,maxcount) if(mini==1 and min...
output
1
9,158
14
18,317
Provide tags and a correct Python 3 solution for this coding contest problem. This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite o...
instruction
0
9,159
14
18,318
Tags: data structures, implementation Correct Solution: ``` import sys from collections import defaultdict as di n = int(input()) A = [int(x) for x in input().split()] C = di(int) CC = di(int) for a in A: C[a] += 1 for c in C: CC[C[c]] += 1 for a in reversed(A): if len(CC) == 2: aa,bb = sorted(...
output
1
9,159
14
18,319
Provide tags and a correct Python 3 solution for this coding contest problem. This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite o...
instruction
0
9,160
14
18,320
Tags: data structures, implementation Correct Solution: ``` input() a,b={},{} r=i=0 for u in input().split(): i+=1;c=a.get(u,0) if c: b[c]-=1 if b[c]==0:del b[c] c+=1;a[u]=c;b[c]=b.get(c,0)+1 if len(b)==next(iter(b))==1or len(a)==1:r=i if len(b)==2: x,y=sorted(b) if x==b[x]==1or y-x==b[y]==1:r=i print(r) `...
output
1
9,160
14
18,321
Provide tags and a correct Python 3 solution for this coding contest problem. This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite o...
instruction
0
9,161
14
18,322
Tags: data structures, implementation Correct Solution: ``` import sys import collections import math import heapq from operator import itemgetter def getint(): return int(input()) def getints(): return [int(x) for x in input().split(' ')] n = getint() u = getints() result = 0 colorCounts = [0] * (10 ** 5 +...
output
1
9,161
14
18,323
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, h...
instruction
0
9,162
14
18,324
Yes
output
1
9,162
14
18,325
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, h...
instruction
0
9,163
14
18,326
Yes
output
1
9,163
14
18,327
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This problem is same as the next one, but has smaller constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, h...
instruction
0
9,164
14
18,328
Yes
output
1
9,164
14
18,329