message
stringlengths
2
44.5k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
276
109k
cluster
float64
23
23
__index_level_0__
int64
552
217k
Provide tags and a correct Python 3 solution for this coding contest problem. Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different. In Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and the number of angles coul...
instruction
0
93,781
23
187,562
Tags: geometry, math Correct Solution: ``` from math import * p =[list(map(float,input().split())) for i in range(3)] a,b,c=[hypot(x1-x2,y1-y2) for (x1,y1),(x2,y2) in [(p[0],p[1]),(p[0],p[2]),(p[1],p[2])]] A,B,C=[acos((y*y+z*z-x*x)/2/z/y) for x,y,z in [(a,b,c),(b,c,a),(c,a,b)]] R=a/2/sin(A) def g(x,y):return x if y<1e-...
output
1
93,781
23
187,563
Provide tags and a correct Python 3 solution for this coding contest problem. Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different. In Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and the number of angles coul...
instruction
0
93,782
23
187,564
Tags: geometry, math Correct Solution: ``` from math import sqrt, asin, pi, sin, cos eps = 1e-6 def dist2(ax, ay, bx, by): return (ax-bx)**2 + (ay-by)**2 def cross_prod(ax, ay, bx, by): return ax*by - ay*bx def inner_prod(ax, ay, bx, by): return ax*bx + ay*by def find(x, y, s, c): for i in range(le...
output
1
93,782
23
187,565
Provide tags and a correct Python 3 solution for this coding contest problem. Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different. In Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and the number of angles coul...
instruction
0
93,783
23
187,566
Tags: geometry, math Correct Solution: ``` import math from fractions import Fraction line = input() data = line.split() x1, y1 = float(data[0]), float(data[1]) line = input() data = line.split() x2, y2 = float(data[0]), float(data[1]) line = input() data = line.split() x3, y3 = float(data[0]), float(data[1]) dis12 = (...
output
1
93,783
23
187,567
Provide tags and a correct Python 3 solution for this coding contest problem. Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different. In Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and the number of angles coul...
instruction
0
93,784
23
187,568
Tags: geometry, math Correct Solution: ``` import math x1, y1 = map(float, input().split()) x2, y2 = map(float, input().split()) x3, y3 = map(float, input().split()) c1 = (x2 ** 2 - x1 ** 2 + y2 ** 2 - y1 ** 2) / 2 c2 = (x3 ** 2 - x2 ** 2 + y3 ** 2 - y2 ** 2) / 2 # dist x1-x2 r1 = (c1 * (y3 - y2) - c2 * (y2 - y1)) / ...
output
1
93,784
23
187,569
Provide tags and a correct Python 3 solution for this coding contest problem. Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different. In Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and the number of angles coul...
instruction
0
93,785
23
187,570
Tags: geometry, math Correct Solution: ``` import math import sys eps=1e-4 def getABC(x1,y1,x2,y2): A=x2-x1 B=y2-y1 C=(x1*x1-x2*x2+y1*y1-y2*y2)/2 return A,B,C # assume they are not parallel def getIntersection(a1,b1,c1,a2,b2,c2): x=(c2*b1-c1*b2)/(a1*b2-a2*b1) y=(a1*c2-a2*c1)/(a2*b1-a1*b2) return x,y def getAng...
output
1
93,785
23
187,571
Provide tags and a correct Python 3 solution for this coding contest problem. Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different. In Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and the number of angles coul...
instruction
0
93,786
23
187,572
Tags: geometry, math Correct Solution: ``` import math EPS = 1e-6 class Point: def __init__(self, x, y): self.x = x self.y = y def dist(self, p:"Point"): return math.sqrt((self.x - p.x) ** 2 + (self.y - p.y) ** 2) def dist_square(self, p:"Point"): return (self.x -...
output
1
93,786
23
187,573
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different. In Ancient Berland arenas in circuses were shaped as a regular (equiangular) ...
instruction
0
93,787
23
187,574
Yes
output
1
93,787
23
187,575
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different. In Ancient Berland arenas in circuses were shaped as a regular (equiangular) ...
instruction
0
93,788
23
187,576
Yes
output
1
93,788
23
187,577
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different. In Ancient Berland arenas in circuses were shaped as a regular (equiangular) ...
instruction
0
93,789
23
187,578
Yes
output
1
93,789
23
187,579
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different. In Ancient Berland arenas in circuses were shaped as a regular (equiangular) ...
instruction
0
93,790
23
187,580
Yes
output
1
93,790
23
187,581
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different. In Ancient Berland arenas in circuses were shaped as a regular (equiangular) ...
instruction
0
93,791
23
187,582
No
output
1
93,791
23
187,583
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different. In Ancient Berland arenas in circuses were shaped as a regular (equiangular) ...
instruction
0
93,792
23
187,584
No
output
1
93,792
23
187,585
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different. In Ancient Berland arenas in circuses were shaped as a regular (equiangular) ...
instruction
0
93,793
23
187,586
No
output
1
93,793
23
187,587
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different. In Ancient Berland arenas in circuses were shaped as a regular (equiangular) ...
instruction
0
93,794
23
187,588
No
output
1
93,794
23
187,589
Provide tags and a correct Python 3 solution for this coding contest problem. Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task was just to construct a triangle out of four sti...
instruction
0
93,994
23
187,988
Tags: brute force, geometry Correct Solution: ``` ints,answer = list(reversed(sorted(list(map(int, input().split(' ')))))), "IMPOSSIBLE" if ints[0] < ints[1] + ints[2]: #0 did work answer = "TRIANGLE" elif ints[0] == ints[1] + ints[2]: #segment only a triangle is better. answer = "SEGMENT" if ints[1] < ints[2] + i...
output
1
93,994
23
187,989
Provide tags and a correct Python 3 solution for this coding contest problem. Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task was just to construct a triangle out of four sti...
instruction
0
93,995
23
187,990
Tags: brute force, geometry Correct Solution: ``` def task(): a,b,c,d = input().split() a,b,c,d = [int(a),int(b),int(c),int(d)] if (a+b>c and a+c>b and c+b>a) or (d+a>b and d+b>a and a+b>d) or (a+c>d and c+d>a and d+a>c) or (b+c>d and b+d>c and d+c>b): return("TRIANGLE") elif a+b==c or a+d==c or...
output
1
93,995
23
187,991
Provide tags and a correct Python 3 solution for this coding contest problem. Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task was just to construct a triangle out of four sti...
instruction
0
93,996
23
187,992
Tags: brute force, geometry Correct Solution: ``` arr = list(map(int, input().strip().split())) arr.sort() a, b, c, d = arr if a+b < c: if b+c > d: print('TRIANGLE') elif b+c == d: print('SEGMENT') else: print('IMPOSSIBLE') elif a+b == c: if b+c > d: print('TRIANGLE') else: print('SEGMENT') else: print(...
output
1
93,996
23
187,993
Provide tags and a correct Python 3 solution for this coding contest problem. Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task was just to construct a triangle out of four sti...
instruction
0
93,997
23
187,994
Tags: brute force, geometry Correct Solution: ``` a=list(map(int,input().split())) a.sort() if a[0]+a[1]>a[2]: print("TRIANGLE") elif a[1]+a[2]>a[3]: print("TRIANGLE") elif a[0]+a[1]==a[2] or a[1]+a[2]==a[3]: print("SEGMENT") else: print("IMPOSSIBLE") ```
output
1
93,997
23
187,995
Provide tags and a correct Python 3 solution for this coding contest problem. Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task was just to construct a triangle out of four sti...
instruction
0
93,998
23
187,996
Tags: brute force, geometry Correct Solution: ``` x,y,z,w=map(int,input().split()) arr=[] arr.append(x) arr.append(y) arr.append(z) arr.append(w) arr.sort() # print(arr) if (arr[0]+arr[1]>arr[2]) or (arr[0]+arr[1]>arr[3]) or (arr[1]+arr[2]>arr[3]): print("TRIANGLE") elif (arr[0]+arr[1]==arr[2]) or (arr[0]+arr[1]==a...
output
1
93,998
23
187,997
Provide tags and a correct Python 3 solution for this coding contest problem. Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task was just to construct a triangle out of four sti...
instruction
0
93,999
23
187,998
Tags: brute force, geometry Correct Solution: ``` l = list(map(int, input().split())) m = l[0] l.sort() if ((l[0]+l[1])>l[2]) or ((l[1]+l[2])>l[3]): print('TRIANGLE') elif ((l[0]+l[1]) == l[2]) or ((l[1]+l[2]) == l[3]): print('SEGMENT') else: print('IMPOSSIBLE') ```
output
1
93,999
23
187,999
Provide tags and a correct Python 3 solution for this coding contest problem. Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task was just to construct a triangle out of four sti...
instruction
0
94,000
23
188,000
Tags: brute force, geometry Correct Solution: ``` dic = {"t": False, "s": False} a, b, c, d = list(map(int, input().split(" "))) l = [[a, b, c], [a, b, d], [a, c, d], [b, c, d]] for x, y, z in l: if(x + y > z and y + z > x and x + z > y): dic["t"] = True break elif(x + y == z or y + z == x or x ...
output
1
94,000
23
188,001
Provide tags and a correct Python 3 solution for this coding contest problem. Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task was just to construct a triangle out of four sti...
instruction
0
94,001
23
188,002
Tags: brute force, geometry Correct Solution: ``` import sys from itertools import combinations sticks = list(map(int,sys.stdin.readline().split())) for edges in combinations(sticks, 3): edges = sorted(edges) # edges.sort() # print(edges) if edges[0] + edges[1] > edges[-1] and edges[-1] - edges[0] < ed...
output
1
94,001
23
188,003
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task w...
instruction
0
94,002
23
188,004
Yes
output
1
94,002
23
188,005
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task w...
instruction
0
94,003
23
188,006
Yes
output
1
94,003
23
188,007
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task w...
instruction
0
94,004
23
188,008
Yes
output
1
94,004
23
188,009
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task w...
instruction
0
94,005
23
188,010
Yes
output
1
94,005
23
188,011
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task w...
instruction
0
94,006
23
188,012
No
output
1
94,006
23
188,013
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task w...
instruction
0
94,007
23
188,014
No
output
1
94,007
23
188,015
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task w...
instruction
0
94,008
23
188,016
No
output
1
94,008
23
188,017
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task w...
instruction
0
94,009
23
188,018
No
output
1
94,009
23
188,019
Provide a correct Python 3 solution for this coding contest problem. There is a cube which consists of n Γ— n Γ— n small cubes. Small cubes have marks on their surfaces. An example where n = 4 is shown in the following figure. <image> Then, as shown in the figure above (right), make a hole that penetrates horizontal...
instruction
0
94,342
23
188,684
"Correct Solution: ``` # AOJ 1030 Cubes Without Holes # Python3 2018.7.6 bal4u import sys from sys import stdin input = stdin.readline # n <= 500, 2^9 = 512 while True: n, h = map(int, input().split()) if n == 0: break ans = [] for i in range(h): c, a, b = input().split() a, b = int(a)-1, int(b)-1 if c == ...
output
1
94,342
23
188,685
Provide a correct Python 3 solution for this coding contest problem. There is a cube which consists of n Γ— n Γ— n small cubes. Small cubes have marks on their surfaces. An example where n = 4 is shown in the following figure. <image> Then, as shown in the figure above (right), make a hole that penetrates horizontal...
instruction
0
94,343
23
188,686
"Correct Solution: ``` while True: n, h = map(int, input().split()) if n == 0: break hit = set() for _ in range(h): c, a, b = input().split() if c == "xy": add = {(int(a), int(b), z) for z in range(1, n + 1)} elif c == "xz": add = {(int(a), y, int(b)) for y in range(1, n + 1)} el...
output
1
94,343
23
188,687
Provide a correct Python 3 solution for this coding contest problem. There is a cube which consists of n Γ— n Γ— n small cubes. Small cubes have marks on their surfaces. An example where n = 4 is shown in the following figure. <image> Then, as shown in the figure above (right), make a hole that penetrates horizontal...
instruction
0
94,344
23
188,688
"Correct Solution: ``` # AOJ 1030 Cubes Without Holes # Python3 2018.7.6 bal4u import sys from sys import stdin input = stdin.readline # n <= 500, 2^9 = 512 while True: n, h = map(int, input().split()) if n == 0: break ans = [] for i in range(h): s = input() c = s[:2] a, b = s[3:].split() a, b = int(a)-1...
output
1
94,344
23
188,689
Provide a correct Python 3 solution for this coding contest problem. There is a cube which consists of n Γ— n Γ— n small cubes. Small cubes have marks on their surfaces. An example where n = 4 is shown in the following figure. <image> Then, as shown in the figure above (right), make a hole that penetrates horizontal...
instruction
0
94,345
23
188,690
"Correct Solution: ``` def solve(): while True: n, h = map(int, input().split()) if n == 0: break s = set() for _ in [0]*h: t, *a = input().split() i, j = map(lambda x: int(x)-1, a) k = 1 if t == "xy": j *= ...
output
1
94,345
23
188,691
Provide a correct Python 3 solution for this coding contest problem. There is a cube which consists of n Γ— n Γ— n small cubes. Small cubes have marks on their surfaces. An example where n = 4 is shown in the following figure. <image> Then, as shown in the figure above (right), make a hole that penetrates horizontal...
instruction
0
94,346
23
188,692
"Correct Solution: ``` while 1: N, H = map(int, input().split()) if N == H == 0: break s = set() for i in range(H): c, a, b = input().split(); a = int(a)-1; b = int(b)-1 if c == "xy": s.update((a, b, i) for i in range(N)) if c == "xz": s.update((a,...
output
1
94,346
23
188,693
Provide a correct Python 3 solution for this coding contest problem. There is a cube which consists of n Γ— n Γ— n small cubes. Small cubes have marks on their surfaces. An example where n = 4 is shown in the following figure. <image> Then, as shown in the figure above (right), make a hole that penetrates horizontal...
instruction
0
94,347
23
188,694
"Correct Solution: ``` # AOJ 1030 Cubes Without Holes # Python3 2018.7.6 bal4u import sys from sys import stdin input = stdin.readline while True: n, h = map(int, input().split()) if n == 0: break ans = [] for i in range(h): c, a, b = input().split() a, b = int(a)-1, int(b)-1 if c == "xy": ans += [a+b*n+...
output
1
94,347
23
188,695
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a cube which consists of n Γ— n Γ— n small cubes. Small cubes have marks on their surfaces. An example where n = 4 is shown in the following figure. <image> Then, as shown in the figu...
instruction
0
94,348
23
188,696
No
output
1
94,348
23
188,697
Provide a correct Python 3 solution for this coding contest problem. Suppose that P1 is an infinite-height prism whose axis is parallel to the z-axis, and P2 is also an infinite-height prism whose axis is parallel to the y-axis. P1 is defined by the polygon C1 which is the cross section of P1 and the xy-plane, and P2 ...
instruction
0
94,365
23
188,730
"Correct Solution: ``` # aoj 1313 import sys input = sys.stdin.readline # the width of the polygon sliced at x def width(X, Y, x): n = len(X) lb, ub = float('inf'), -float('inf') for i in range(n): x1, y1, x2, y2 = X[i], Y[i], X[(i+1) % n], Y[(i+1) % n] if (x1-x)*(x2-x) <= 0 and x1 != x2: ...
output
1
94,365
23
188,731
Provide a correct Python 3 solution for this coding contest problem. Suppose that P1 is an infinite-height prism whose axis is parallel to the z-axis, and P2 is also an infinite-height prism whose axis is parallel to the y-axis. P1 is defined by the polygon C1 which is the cross section of P1 and the xy-plane, and P2 ...
instruction
0
94,366
23
188,732
"Correct Solution: ``` import sys readline = sys.stdin.readline write = sys.stdout.write def solve(): M, N = map(int, readline().split()) if M == N == 0: return False P = [list(map(int, readline().split())) for i in range(M)] Q = [list(map(int, readline().split())) for i in range(N)] xs = se...
output
1
94,366
23
188,733
Provide a correct Python 3 solution for this coding contest problem. Suppose that P1 is an infinite-height prism whose axis is parallel to the z-axis, and P2 is also an infinite-height prism whose axis is parallel to the y-axis. P1 is defined by the polygon C1 which is the cross section of P1 and the xy-plane, and P2 ...
instruction
0
94,367
23
188,734
"Correct Solution: ``` def width(_X, _Y, _n, _x): lb = float("inf") ub = -float("inf") for j in range(0, _n): x1 = _X[j] y1 = _Y[j] x2 = _X[(j + 1) % _n] y2 = _Y[(j + 1) % _n] if (x1 - _x) * (x2 - _x) <= 0 and x1 != x2: y = y1 + (y2 - y1) * (_x - x1) / (...
output
1
94,367
23
188,735
Provide a correct Python 3 solution for this coding contest problem. Suppose that P1 is an infinite-height prism whose axis is parallel to the z-axis, and P2 is also an infinite-height prism whose axis is parallel to the y-axis. P1 is defined by the polygon C1 which is the cross section of P1 and the xy-plane, and P2 ...
instruction
0
94,368
23
188,736
"Correct Solution: ``` def width(X,Y,x): n = len(X) lb,ub = float('inf'),-float('inf') for i in range(n): x1,y1,x2,y2 = X[i],Y[i],X[(i+1)%n],Y[(i+1)%n] if (x1-x)*(x2-x) <= 0 and x1 != x2: y = y1 + (y2-y1)*(x-x1)/(x2-x1) lb = min(lb,y) ub = ...
output
1
94,368
23
188,737
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n intervals in form [l; r] on a number line. You are also given m queries in form [x; y]. What is the minimal number of intervals you have to take so that every point (not necessa...
instruction
0
94,474
23
188,948
No
output
1
94,474
23
188,949
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n intervals in form [l; r] on a number line. You are also given m queries in form [x; y]. What is the minimal number of intervals you have to take so that every point (not necessa...
instruction
0
94,475
23
188,950
No
output
1
94,475
23
188,951
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n intervals in form [l; r] on a number line. You are also given m queries in form [x; y]. What is the minimal number of intervals you have to take so that every point (not necessa...
instruction
0
94,476
23
188,952
No
output
1
94,476
23
188,953
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n intervals in form [l; r] on a number line. You are also given m queries in form [x; y]. What is the minimal number of intervals you have to take so that every point (not necessa...
instruction
0
94,477
23
188,954
No
output
1
94,477
23
188,955
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n integers. You need to choose a subset and put the chosen numbers in a beautiful rectangle (rectangular matrix). Each chosen number should occupy one of its rectangle cells, each cell must be filled with exactly one chosen num...
instruction
0
94,494
23
188,988
Tags: brute force, combinatorics, constructive algorithms, data structures, greedy, math Correct Solution: ``` n = int(input()) l = list(map(int,input().split())) if n == 1: print(1) print(1,1) print(l[0]) else: d = {} for i in l: d[i] = 0 for i in l: d[i] += 1 equal = [0] * (n + 1) for i in d: equal[d[i]...
output
1
94,494
23
188,989
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n integers. You need to choose a subset and put the chosen numbers in a beautiful rectangle (rectangular matrix). Each chosen number should occupy one of its rectangle cells, each cell must be filled with exactly one chosen num...
instruction
0
94,496
23
188,992
Tags: brute force, combinatorics, constructive algorithms, data structures, greedy, math Correct Solution: ``` n = int(input()) arr = list(map(int, input().split())) d = {} for i in arr: d[i] = d.get(i, 0) + 1 d2 = {} for k, v in d.items(): d2.setdefault(v, []).append(k) s = n prev = 0 ansp = ansq = anss = 0 f...
output
1
94,496
23
188,993
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n integers. You need to choose a subset and put the chosen numbers in a beautiful rectangle (rectangular matrix). Each chosen number should occupy one of its rectangle cells, each cell must be filled with exactly one chosen num...
instruction
0
94,497
23
188,994
Tags: brute force, combinatorics, constructive algorithms, data structures, greedy, math Correct Solution: ``` from sys import stdin, stdout def getmaxrectangle(n, a): dic = {} dicCntVals = {} for va in a: if va not in dic: dic[va] = 0 dic[va] += 1 for val in dic.keys():...
output
1
94,497
23
188,995
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n integers. You need to choose a subset and put the chosen numbers in a beautiful rectangle (rectangular matrix). Each chosen number should occupy one of its rectangle cells, each cell must be filled with exactly one chosen num...
instruction
0
94,498
23
188,996
Tags: brute force, combinatorics, constructive algorithms, data structures, greedy, math Correct Solution: ``` from itertools import accumulate import math from collections import Counter import sys input = sys.stdin.readline n = int(input()) A = list(map(int, input().split())) D = Counter(A) MAXV = max(max(D.valu...
output
1
94,498
23
188,997
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n integers. You need to choose a subset and put the chosen numbers in a beautiful rectangle (rectangular matrix). Each chosen number should occupy one of its rectangle cells, each cell must be filled with exactly one chosen num...
instruction
0
94,499
23
188,998
Tags: brute force, combinatorics, constructive algorithms, data structures, greedy, math Correct Solution: ``` from collections import Counter from sys import stdin def input(): return next(stdin)[:-1] def main(): n = int(input()) aa = input().split() cc = list(Counter(aa).most_common()) if n % c...
output
1
94,499
23
188,999