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. Little Sofia is in fourth grade. Today in the geometry lesson she learned about segments and squares. On the way home, she decided to draw n squares in the snow with a side length of 1. For simplicity, we assume that Sofia lives on a plane a...
instruction
0
106,157
23
212,314
Tags: binary search, constructive algorithms, math Correct Solution: ``` n=int(input()) for i in range(1, 40000): if i*i>=n: x=i break print(n//x+i+int(n%x>0)) ```
output
1
106,157
23
212,315
Provide tags and a correct Python 3 solution for this coding contest problem. Little Sofia is in fourth grade. Today in the geometry lesson she learned about segments and squares. On the way home, she decided to draw n squares in the snow with a side length of 1. For simplicity, we assume that Sofia lives on a plane a...
instruction
0
106,158
23
212,316
Tags: binary search, constructive algorithms, math Correct Solution: ``` import math n = int(input()) q = math.sqrt(n) if q == int(q): q = int(q) print(2 * q) elif q - int(q) >= 0.5: q = int(q) + 1 print(2 * q) else: q = int(q) print(2 * q + 1) ```
output
1
106,158
23
212,317
Provide tags and a correct Python 3 solution for this coding contest problem. Little Sofia is in fourth grade. Today in the geometry lesson she learned about segments and squares. On the way home, she decided to draw n squares in the snow with a side length of 1. For simplicity, we assume that Sofia lives on a plane a...
instruction
0
106,159
23
212,318
Tags: binary search, constructive algorithms, math Correct Solution: ``` n=int(input()) from math import ceil def res(n): return ceil(2*n**0.5) print(res(n)) ```
output
1
106,159
23
212,319
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Sofia is in fourth grade. Today in the geometry lesson she learned about segments and squares. On the way home, she decided to draw n squares in the snow with a side length of 1. For simp...
instruction
0
106,160
23
212,320
Yes
output
1
106,160
23
212,321
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Sofia is in fourth grade. Today in the geometry lesson she learned about segments and squares. On the way home, she decided to draw n squares in the snow with a side length of 1. For simp...
instruction
0
106,161
23
212,322
Yes
output
1
106,161
23
212,323
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Sofia is in fourth grade. Today in the geometry lesson she learned about segments and squares. On the way home, she decided to draw n squares in the snow with a side length of 1. For simp...
instruction
0
106,162
23
212,324
Yes
output
1
106,162
23
212,325
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Sofia is in fourth grade. Today in the geometry lesson she learned about segments and squares. On the way home, she decided to draw n squares in the snow with a side length of 1. For simp...
instruction
0
106,163
23
212,326
Yes
output
1
106,163
23
212,327
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Sofia is in fourth grade. Today in the geometry lesson she learned about segments and squares. On the way home, she decided to draw n squares in the snow with a side length of 1. For simp...
instruction
0
106,164
23
212,328
No
output
1
106,164
23
212,329
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Sofia is in fourth grade. Today in the geometry lesson she learned about segments and squares. On the way home, she decided to draw n squares in the snow with a side length of 1. For simp...
instruction
0
106,165
23
212,330
No
output
1
106,165
23
212,331
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Sofia is in fourth grade. Today in the geometry lesson she learned about segments and squares. On the way home, she decided to draw n squares in the snow with a side length of 1. For simp...
instruction
0
106,166
23
212,332
No
output
1
106,166
23
212,333
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Sofia is in fourth grade. Today in the geometry lesson she learned about segments and squares. On the way home, she decided to draw n squares in the snow with a side length of 1. For simp...
instruction
0
106,167
23
212,334
No
output
1
106,167
23
212,335
Provide tags and a correct Python 3 solution for this coding contest problem. Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher's Day, the students have gifted him a collection of wooden sticks, where every stick has an integer length. Now Alexey wants to gr...
instruction
0
106,237
23
212,474
Tags: greedy, math, sortings Correct Solution: ``` x = int(input()) y = list(map(int, input().split())) a = int(x/2) b = 0 c = 0 y.sort() for i in range(a, x): b+=y[i] for i in range(a): c+=y[i] print(b**2+c**2) ```
output
1
106,237
23
212,475
Provide tags and a correct Python 3 solution for this coding contest problem. Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher's Day, the students have gifted him a collection of wooden sticks, where every stick has an integer length. Now Alexey wants to gr...
instruction
0
106,238
23
212,476
Tags: greedy, math, sortings Correct Solution: ``` def ii(): return int(input()) def si(): return input() def mi(): return map(int,input().split()) def li(): return list(mi()) n=ii() a=li() a.sort() x=y=0 for i in range(n//2): x+=a[i] y+=a[n-i-1] if n%2: y+=a[n//2] print(x*x+y*y) ```
output
1
106,238
23
212,477
Provide tags and a correct Python 3 solution for this coding contest problem. Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher's Day, the students have gifted him a collection of wooden sticks, where every stick has an integer length. Now Alexey wants to gr...
instruction
0
106,239
23
212,478
Tags: greedy, math, sortings Correct Solution: ``` n = int(input()) a = list(map(int, input().split())) a.sort() mp = n // 2 sl = sum(a[:mp]) sm = sum(a[mp:]) smd = sl**2 + sm**2 print(smd) ```
output
1
106,239
23
212,479
Provide tags and a correct Python 3 solution for this coding contest problem. Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher's Day, the students have gifted him a collection of wooden sticks, where every stick has an integer length. Now Alexey wants to gr...
instruction
0
106,240
23
212,480
Tags: greedy, math, sortings Correct Solution: ``` n = int(input()) ar = list(map(int, input().split())) ar.sort() x, y = 0, 0 for i in range((n + 1) // 2): if i * 2 == n - 1: y += ar[i] else: x += ar[i] y += ar[n - i - 1] print(x * x + y * y) ```
output
1
106,240
23
212,481
Provide tags and a correct Python 3 solution for this coding contest problem. Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher's Day, the students have gifted him a collection of wooden sticks, where every stick has an integer length. Now Alexey wants to gr...
instruction
0
106,241
23
212,482
Tags: greedy, math, sortings Correct Solution: ``` n=int(input()) a=list(map(int,input().split())) a.sort() if n%2==0: d=(n//2) else: d=((n//2)+1)-1 b=sum(a[0:d]) c=sum(a[d:n]) print((b*b)+(c*c)) ```
output
1
106,241
23
212,483
Provide tags and a correct Python 3 solution for this coding contest problem. Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher's Day, the students have gifted him a collection of wooden sticks, where every stick has an integer length. Now Alexey wants to gr...
instruction
0
106,242
23
212,484
Tags: greedy, math, sortings Correct Solution: ``` from collections import deque n = int(input()) a = deque(sorted(map(int, input().split()))) up = 0 right = 0 for i in range(n): if i % 2: up += a.popleft() else: right += a.pop() print(up * up + right * right) ```
output
1
106,242
23
212,485
Provide tags and a correct Python 3 solution for this coding contest problem. Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher's Day, the students have gifted him a collection of wooden sticks, where every stick has an integer length. Now Alexey wants to gr...
instruction
0
106,243
23
212,486
Tags: greedy, math, sortings Correct Solution: ``` n=int(input()) a=list(map(int,input().split(" "))) a.sort() sum1=0 sum2=0 for i in range (n): if(i<int(n/2)): sum1+=a[i] else: sum2+=a[i] print(sum1*sum1+sum2*sum2) ```
output
1
106,243
23
212,487
Provide tags and a correct Python 3 solution for this coding contest problem. Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher's Day, the students have gifted him a collection of wooden sticks, where every stick has an integer length. Now Alexey wants to gr...
instruction
0
106,244
23
212,488
Tags: greedy, math, sortings Correct Solution: ``` n = int(input()) u = list(map(int, input().split())) u.sort() a = sum(u[:n // 2]) b = sum(u) - a print(a * a + b * b) ```
output
1
106,244
23
212,489
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher's Day, the students have gifted him a collection of wooden sticks, where every stic...
instruction
0
106,245
23
212,490
Yes
output
1
106,245
23
212,491
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher's Day, the students have gifted him a collection of wooden sticks, where every stic...
instruction
0
106,246
23
212,492
Yes
output
1
106,246
23
212,493
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher's Day, the students have gifted him a collection of wooden sticks, where every stic...
instruction
0
106,247
23
212,494
Yes
output
1
106,247
23
212,495
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher's Day, the students have gifted him a collection of wooden sticks, where every stic...
instruction
0
106,248
23
212,496
Yes
output
1
106,248
23
212,497
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher's Day, the students have gifted him a collection of wooden sticks, where every stic...
instruction
0
106,249
23
212,498
No
output
1
106,249
23
212,499
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher's Day, the students have gifted him a collection of wooden sticks, where every stic...
instruction
0
106,250
23
212,500
No
output
1
106,250
23
212,501
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher's Day, the students have gifted him a collection of wooden sticks, where every stic...
instruction
0
106,251
23
212,502
No
output
1
106,251
23
212,503
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher's Day, the students have gifted him a collection of wooden sticks, where every stic...
instruction
0
106,252
23
212,504
No
output
1
106,252
23
212,505
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya claims that he had a paper square. He cut it into two rectangular parts using one vertical or horizontal cut. Then Vasya informed you the dimensions of these two rectangular parts. You need to check whether Vasya originally had a squar...
instruction
0
106,289
23
212,578
Tags: brute force, implementation, math Correct Solution: ``` t = int(input()) for _ in range(t): a1, b1 = map(int, input().split()) a2, b2 = map(int, input().split()) x1 = min(a1, b1) + min(a2, b2) if max(a1, b1) == max(a2, b2): if x1 == max(a1, b1): print("YES") else: ...
output
1
106,289
23
212,579
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya claims that he had a paper square. He cut it into two rectangular parts using one vertical or horizontal cut. Then Vasya informed you the dimensions of these two rectangular parts. You need to check whether Vasya originally had a squar...
instruction
0
106,290
23
212,580
Tags: brute force, implementation, math Correct Solution: ``` for _ in range(int(input())): a = list(map(int,input().split())) b = list(map(int,input().split())) print('YES') if min(a)==(abs(b[1]-b[0])) and max(a)==max(b) else print('NO') ```
output
1
106,290
23
212,581
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya claims that he had a paper square. He cut it into two rectangular parts using one vertical or horizontal cut. Then Vasya informed you the dimensions of these two rectangular parts. You need to check whether Vasya originally had a squar...
instruction
0
106,291
23
212,582
Tags: brute force, implementation, math Correct Solution: ``` import os import sys from io import BytesIO, IOBase def main(): pass # region fastio BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self...
output
1
106,291
23
212,583
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya claims that he had a paper square. He cut it into two rectangular parts using one vertical or horizontal cut. Then Vasya informed you the dimensions of these two rectangular parts. You need to check whether Vasya originally had a squar...
instruction
0
106,292
23
212,584
Tags: brute force, implementation, math Correct Solution: ``` num = int(input()) results = [] for T in range(num): x = [int(i) for i in input().split()] y = [int(i) for i in input().split()] """ x[0] y[1] |--- | --| x[1] | | | y[0] |___ | __| x[0] x[1] |--------| ...
output
1
106,292
23
212,585
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya claims that he had a paper square. He cut it into two rectangular parts using one vertical or horizontal cut. Then Vasya informed you the dimensions of these two rectangular parts. You need to check whether Vasya originally had a squar...
instruction
0
106,293
23
212,586
Tags: brute force, implementation, math Correct Solution: ``` import math n=int(input()) for i in range(n): a=list(map(int,input().split())) b=list(map(int,input().split())) if(a[0]==b[0] and a[1]+b[1]==a[0]): print("Yes") elif(a[0]==b[1] and a[1]+b[0]==a[0]): print("Yes") elif(a[1]==b[0] and a[0]+b[1]==a[1]):...
output
1
106,293
23
212,587
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya claims that he had a paper square. He cut it into two rectangular parts using one vertical or horizontal cut. Then Vasya informed you the dimensions of these two rectangular parts. You need to check whether Vasya originally had a squar...
instruction
0
106,294
23
212,588
Tags: brute force, implementation, math Correct Solution: ``` from itertools import combinations t = int(input()) for i in range(t): a1, b1 = input().split() a2, b2 = input().split() f = 0 if a1 == a2: if int(a1) == int(b1) + int(b2): print("YES") f = 1 if a1 == b2: ...
output
1
106,294
23
212,589
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya claims that he had a paper square. He cut it into two rectangular parts using one vertical or horizontal cut. Then Vasya informed you the dimensions of these two rectangular parts. You need to check whether Vasya originally had a squar...
instruction
0
106,295
23
212,590
Tags: brute force, implementation, math Correct Solution: ``` t=int(input()) for _ in range(t): arr1 = list(map(int, input().split())) arr2 = list(map(int, input().split())) arr3=[i for i in arr1 for j in arr2 if i==j] c1=0 c2=0 if(len(arr3)==0): print("No") continue #print(a...
output
1
106,295
23
212,591
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya claims that he had a paper square. He cut it into two rectangular parts using one vertical or horizontal cut. Then Vasya informed you the dimensions of these two rectangular parts. You need to check whether Vasya originally had a squar...
instruction
0
106,296
23
212,592
Tags: brute force, implementation, math Correct Solution: ``` # Vasya claims that he had a paper square. He cut it into two rectangular parts using one vertical or horizontal cut. Then Vasya informed you the dimensions of these two rectangular parts. You need to check whether Vasya originally had a square. In other wor...
output
1
106,296
23
212,593
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya claims that he had a paper square. He cut it into two rectangular parts using one vertical or horizontal cut. Then Vasya informed you the dimensions of these two rectangular parts. You nee...
instruction
0
106,297
23
212,594
Yes
output
1
106,297
23
212,595
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya claims that he had a paper square. He cut it into two rectangular parts using one vertical or horizontal cut. Then Vasya informed you the dimensions of these two rectangular parts. You nee...
instruction
0
106,298
23
212,596
Yes
output
1
106,298
23
212,597
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya claims that he had a paper square. He cut it into two rectangular parts using one vertical or horizontal cut. Then Vasya informed you the dimensions of these two rectangular parts. You nee...
instruction
0
106,299
23
212,598
Yes
output
1
106,299
23
212,599
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya claims that he had a paper square. He cut it into two rectangular parts using one vertical or horizontal cut. Then Vasya informed you the dimensions of these two rectangular parts. You nee...
instruction
0
106,300
23
212,600
Yes
output
1
106,300
23
212,601
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya claims that he had a paper square. He cut it into two rectangular parts using one vertical or horizontal cut. Then Vasya informed you the dimensions of these two rectangular parts. You nee...
instruction
0
106,301
23
212,602
No
output
1
106,301
23
212,603
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya claims that he had a paper square. He cut it into two rectangular parts using one vertical or horizontal cut. Then Vasya informed you the dimensions of these two rectangular parts. You nee...
instruction
0
106,302
23
212,604
No
output
1
106,302
23
212,605
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya claims that he had a paper square. He cut it into two rectangular parts using one vertical or horizontal cut. Then Vasya informed you the dimensions of these two rectangular parts. You nee...
instruction
0
106,303
23
212,606
No
output
1
106,303
23
212,607
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya claims that he had a paper square. He cut it into two rectangular parts using one vertical or horizontal cut. Then Vasya informed you the dimensions of these two rectangular parts. You nee...
instruction
0
106,304
23
212,608
No
output
1
106,304
23
212,609
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two rectangles on a plane. The centers of both rectangles are located in the origin of coordinates (meaning the center of the rectangle's symmetry). The first rectangle's sides are parallel to the coordinate axes: the length of...
instruction
0
106,460
23
212,920
Tags: geometry Correct Solution: ``` import os import sys from io import BytesIO, IOBase import math def main(): pass BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r...
output
1
106,460
23
212,921
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two rectangles on a plane. The centers of both rectangles are located in the origin of coordinates (meaning the center of the rectangle's symmetry). The first rectangle's sides are parallel to the coordinate axes: the length of...
instruction
0
106,461
23
212,922
Tags: geometry Correct Solution: ``` #!/usr/bin/python3 from math import sin, cos, pi, atan2 w, h, a = tuple(map(int, input().split())) if a in [0, 180]: print(w * h) elif a == 90: print(min(w, h)**2) else: a *= pi / 180 w /= 2 h /= 2 base = [(w, h), (-w, h), (-w, -h), (w, -h)] rot = [(x *...
output
1
106,461
23
212,923
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two rectangles on a plane. The centers of both rectangles are located in the origin of coordinates (meaning the center of the rectangle's symmetry). The first rectangle's sides are parallel to the coordinate axes: the length of...
instruction
0
106,462
23
212,924
Tags: geometry Correct Solution: ``` import sys import math def read_input(input_path=None): if input_path is None: f = sys.stdin else: f = open(input_path, 'r') w, h, a = map(int, f.readline().split()) return w, h, a def sol(w, h, a): if h > w: w, h = h, w if a > ...
output
1
106,462
23
212,925
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two rectangles on a plane. The centers of both rectangles are located in the origin of coordinates (meaning the center of the rectangle's symmetry). The first rectangle's sides are parallel to the coordinate axes: the length of...
instruction
0
106,463
23
212,926
Tags: geometry Correct Solution: ``` import math from decimal import * getcontext().prec = 40 EPS = Decimal(0.000000000000000000001) PI = Decimal(3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328) def labs(x): if x < 0: return -x return x class Po...
output
1
106,463
23
212,927
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two rectangles on a plane. The centers of both rectangles are located in the origin of coordinates (meaning the center of the rectangle's symmetry). The first rectangle's sides are parallel to the coordinate axes: the length of...
instruction
0
106,464
23
212,928
Tags: geometry Correct Solution: ``` from math import sin,cos,tan PI = 3.141592653589793238463 [w,h,a] =[int(i) for i in input().split()] if h > w: h,w = w,h if a > 90: a = 180 - a if a==0: print(w*h) else: b = (a*PI)/180 w = w/2.0 h = h/2.0 if tan(b/2) >= h/w: print (4*h*h/sin(b)) ...
output
1
106,464
23
212,929
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two rectangles on a plane. The centers of both rectangles are located in the origin of coordinates (meaning the center of the rectangle's symmetry). The first rectangle's sides are parallel to the coordinate axes: the length of...
instruction
0
106,465
23
212,930
Tags: geometry Correct Solution: ``` from math import * w,h,alpha = [int(x) for x in input().strip().split()] if alpha > 90 : alpha = 180 - alpha if w < h: w,h = h,w c = cos(alpha * pi / 180.0) s = sin(alpha * pi / 180.0) t = tan(alpha * pi / 360.0) print(h * h / s) if t > h / w else print( (w * h - (w * w + h * h)...
output
1
106,465
23
212,931
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two rectangles on a plane. The centers of both rectangles are located in the origin of coordinates (meaning the center of the rectangle's symmetry). The first rectangle's sides are parallel to the coordinate axes: the length of...
instruction
0
106,466
23
212,932
Tags: geometry Correct Solution: ``` from math import sin, cos, tan, atan, pi def main(): w, h, a = map(int, input().split()) a = min(a, 180 - a) * pi / 180 if h > w: h, w = w, h if h * (1 + cos(a)) < w * sin(a): res = h * h / sin(a) else: res = h * w - ((w - h * tan(a / 2)...
output
1
106,466
23
212,933