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. Peter got a new snow blower as a New Year present. Of course, Peter decided to try it immediately. After reading the instructions he realized that it does not work like regular snow blowing machines. In order to make it work, you need to tie...
instruction
0
27,899
23
55,798
Tags: binary search, geometry, ternary search Correct Solution: ``` def main(): n, a, b = map(int, input().split()) l, res = [], [] for _ in range(n): u, v = input().split() l.append((int(u) - a, int(v) - b)) x0, y0 = l[-1] for x1, y1 in l: res.append(x1 * x1 + y1 * y1) ...
output
1
27,899
23
55,799
Provide tags and a correct Python 3 solution for this coding contest problem. Peter got a new snow blower as a New Year present. Of course, Peter decided to try it immediately. After reading the instructions he realized that it does not work like regular snow blowing machines. In order to make it work, you need to tie...
instruction
0
27,900
23
55,800
Tags: binary search, geometry, ternary search Correct Solution: ``` import math def dotproduct(point1, point2): x1, y1 = point1 x2, y2 = point2 product = (x1 * x2) + (y1 * y2) return product def crossproduct(point1, point2): x1, y1 = point1 x2, y2 = point2 product = (x1 * y2) - (y1 * x2) ...
output
1
27,900
23
55,801
Provide a correct Python 3 solution for this coding contest problem. On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to t...
instruction
0
28,130
23
56,260
"Correct Solution: ``` N, M = map(int, input().split()) X = list(map(int, input().split())) Y = list(map(int, input().split())) MOD = 10 ** 9 + 7 numx = 0 for i in range(N): numx += -(N - i - 1) * X[i] + i * X[i] numy = 0 for i in range(M): numy += -(M - i - 1) * Y[i] + i * Y[i] print(numy * numx % MOD) ```
output
1
28,130
23
56,261
Provide a correct Python 3 solution for this coding contest problem. On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to t...
instruction
0
28,131
23
56,262
"Correct Solution: ``` N,M=map(int,input().split()) x=[int(i) for i in input().split()] y=[int(i) for i in input().split()] P=10**9+7 X=0 Y=0 for i in range(1,N+1): X+=x[i-1]*(2*i-1-N) X=X%P for j in range(1,M+1): Y+=y[j-1]*(2*j-1-M) Y=Y%P print((X*Y)%P) ```
output
1
28,131
23
56,263
Provide a correct Python 3 solution for this coding contest problem. On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to t...
instruction
0
28,132
23
56,264
"Correct Solution: ``` n, m = map(int, input().split()) x = [x for x in map(int, input().split())] y = [y for y in map(int, input().split())] sum_x = 0 sum_y = 0 ans = 0 for i in range(n): sum_x += (2*i - n + 1) * x[i] for j in range(m): sum_y += (2*j - m + 1) * y[j] ans = sum_x * sum_y print(ans%1000000007) `...
output
1
28,132
23
56,265
Provide a correct Python 3 solution for this coding contest problem. On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to t...
instruction
0
28,133
23
56,266
"Correct Solution: ``` n,m = map(int, input().split()) x = list(map(int, input().split())) y = list(map(int, input().split())) xlen=0 ylen=0 for i in range(1,n): xlen+=i*(n-i)*(x[i]-x[i-1]) for i in range(1,m): ylen+=i*(m-i)*(y[i]-y[i-1]) print(xlen*ylen%(10**9+7)) ```
output
1
28,133
23
56,267
Provide a correct Python 3 solution for this coding contest problem. On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to t...
instruction
0
28,134
23
56,268
"Correct Solution: ``` n, m = map(int, input().split()) *x, = map(int, input().split()) *y, = map(int, input().split()) MOD = 10**9+7 def calc(v, l): r = 0 for i in range(l): r = r + i*v[i] - (l-1-i)*v[i] r %= MOD return r print((calc(x, n)*calc(y, m)) % MOD) ```
output
1
28,134
23
56,269
Provide a correct Python 3 solution for this coding contest problem. On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to t...
instruction
0
28,135
23
56,270
"Correct Solution: ``` N, M = map(int, input().split()) X = list(map(int, input().split())) Y = list(map(int, input().split())) mod = 10**9+7 x = 0 y = 0 for i in range(N): x += (-N+1+2*i)*X[i] x %= mod for i in range(M): y += (-M+1+2*i)*Y[i] y %= mod print(x*y % mod) ```
output
1
28,135
23
56,271
Provide a correct Python 3 solution for this coding contest problem. On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to t...
instruction
0
28,136
23
56,272
"Correct Solution: ``` n, m = input().split() n = int(n) m = int(m) x = [int(i) for i in input().split()] y = [int(i) for i in input().split()] def sum(a, n): sum_a = 0 for i in range(0, n): sum_a += i * a[i] - (n-1-i) * a[i] return sum_a sum_x = sum(x,n) sum_y = sum(y,m) s = sum_x * sum_y % (10*...
output
1
28,136
23
56,273
Provide a correct Python 3 solution for this coding contest problem. On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to t...
instruction
0
28,137
23
56,274
"Correct Solution: ``` MOD=10**9+7 n,m=map(int,input().split()) xs=list(map(int,input().split())) ys=list(map(int,input().split())) x=0 for i in range(n): x+=(2*(i+1)-n-1)*xs[i] x%=MOD y=0 for j in range(m): y+=(2*(j+1)-m-1)*ys[j] y%=MOD print(x*y%MOD) ```
output
1
28,137
23
56,275
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represen...
instruction
0
28,138
23
56,276
Yes
output
1
28,138
23
56,277
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represen...
instruction
0
28,139
23
56,278
Yes
output
1
28,139
23
56,279
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represen...
instruction
0
28,140
23
56,280
Yes
output
1
28,140
23
56,281
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represen...
instruction
0
28,141
23
56,282
Yes
output
1
28,141
23
56,283
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represen...
instruction
0
28,142
23
56,284
No
output
1
28,142
23
56,285
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represen...
instruction
0
28,143
23
56,286
No
output
1
28,143
23
56,287
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represen...
instruction
0
28,144
23
56,288
No
output
1
28,144
23
56,289
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represen...
instruction
0
28,145
23
56,290
No
output
1
28,145
23
56,291
Provide a correct Python 3 solution for this coding contest problem. Problem Statement Alice is a private teacher. One of her job is to prepare the learning materials for her student. Now, as part of the materials, she is drawing a Venn diagram between two sets $A$ and $B$. Venn diagram is a diagram which illustrate...
instruction
0
28,213
23
56,426
"Correct Solution: ``` import sys readline = sys.stdin.readline write = sys.stdout.write from math import pi, sqrt, acos, sin def solve(): EPS = 1e-9 W, H, A, B, C = map(int, readline().split()) if W == 0: return False a = sqrt(A / pi); b = sqrt(B / pi) mx = max(a, b) if 2*mx > min(W, ...
output
1
28,213
23
56,427
Provide tags and a correct Python 3 solution for this coding contest problem. You have n × n square grid and an integer k. Put an integer in each cell while satisfying the conditions below. * All numbers in the grid should be between 1 and k inclusive. * Minimum number of the i-th row is 1 (1 ≤ i ≤ n). * Mini...
instruction
0
28,354
23
56,708
Tags: combinatorics, dp, math Correct Solution: ``` n, k = list(map(int,input().split())) M = 10 ** 9 + 7 def binom(a,b): num = 1 for i in range(a,a-b,-1): num = (num*i)%M denom = 1 for i in range(1,b+1): denom = (denom*i)%M return (num * pow(denom,M-2,M)) binomMem = [0] * (251 ...
output
1
28,354
23
56,709
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have n × n square grid and an integer k. Put an integer in each cell while satisfying the conditions below. * All numbers in the grid should be between 1 and k inclusive. * Minimum num...
instruction
0
28,362
23
56,724
Yes
output
1
28,362
23
56,725
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have n × n square grid and an integer k. Put an integer in each cell while satisfying the conditions below. * All numbers in the grid should be between 1 and k inclusive. * Minimum num...
instruction
0
28,363
23
56,726
Yes
output
1
28,363
23
56,727
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have n × n square grid and an integer k. Put an integer in each cell while satisfying the conditions below. * All numbers in the grid should be between 1 and k inclusive. * Minimum num...
instruction
0
28,364
23
56,728
Yes
output
1
28,364
23
56,729
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have n × n square grid and an integer k. Put an integer in each cell while satisfying the conditions below. * All numbers in the grid should be between 1 and k inclusive. * Minimum num...
instruction
0
28,365
23
56,730
Yes
output
1
28,365
23
56,731
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have n × n square grid and an integer k. Put an integer in each cell while satisfying the conditions below. * All numbers in the grid should be between 1 and k inclusive. * Minimum num...
instruction
0
28,366
23
56,732
No
output
1
28,366
23
56,733
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have n × n square grid and an integer k. Put an integer in each cell while satisfying the conditions below. * All numbers in the grid should be between 1 and k inclusive. * Minimum num...
instruction
0
28,367
23
56,734
No
output
1
28,367
23
56,735
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have n × n square grid and an integer k. Put an integer in each cell while satisfying the conditions below. * All numbers in the grid should be between 1 and k inclusive. * Minimum num...
instruction
0
28,368
23
56,736
No
output
1
28,368
23
56,737
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a set of n≥ 2 pairwise different points with integer coordinates. Your task is to partition these points into two nonempty groups A and B, such that the following condition holds: For every two points P and Q, write the [Eucli...
instruction
0
28,369
23
56,738
Tags: constructive algorithms, geometry, math Correct Solution: ``` import sys input = sys.stdin.readline n=int(input()) P=[tuple(map(int,input().split())) for i in range(n)] while True: ANS=[] for i in range(n): x,y=P[i] if (x+y)%2==0: ANS.append(i+1) if len(ANS)!=0 and...
output
1
28,369
23
56,739
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a set of n≥ 2 pairwise different points with integer coordinates. Your task is to partition these points into two nonempty groups A and B, such that the following condition holds: For every two points P and Q, write the [Eucli...
instruction
0
28,370
23
56,740
Tags: constructive algorithms, geometry, math Correct Solution: ``` import sys n = int(sys.stdin.readline().strip()) x = [0] * n y = [0] * n z = [0] * n for i in range (0, n): x[i], y[i] = list(map(int, sys.stdin.readline().strip().split())) z[i] = (x[i] + y[i]) % 2 while sum(z) % n == 0: if z[0] == 1: ...
output
1
28,370
23
56,741
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a set of n≥ 2 pairwise different points with integer coordinates. Your task is to partition these points into two nonempty groups A and B, such that the following condition holds: For every two points P and Q, write the [Eucli...
instruction
0
28,371
23
56,742
Tags: constructive algorithms, geometry, math Correct Solution: ``` def solve(XY): while True: groups = {} for i in range(len(XY)): x, y = XY[i] groups.setdefault((x%2, y%2), []).append(i) if len(groups) == 2: return next(iter(groups.values())) el...
output
1
28,371
23
56,743
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a set of n≥ 2 pairwise different points with integer coordinates. Your task is to partition these points into two nonempty groups A and B, such that the following condition holds: For every two points P and Q, write the [Eucli...
instruction
0
28,372
23
56,744
Tags: constructive algorithms, geometry, math Correct Solution: ``` import sys n = int(input()) xy = [] for i in range(n): x,y = map(int,input().split()) xy.append([x,y]) loop = 2 while True: dic = {} for i in range(n): x = xy[i][0] y = xy[i][1] if (x+y) % loop not in dic:...
output
1
28,372
23
56,745
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a set of n≥ 2 pairwise different points with integer coordinates. Your task is to partition these points into two nonempty groups A and B, such that the following condition holds: For every two points P and Q, write the [Eucli...
instruction
0
28,373
23
56,746
Tags: constructive algorithms, geometry, math Correct Solution: ``` from collections import Counter def main(): n = int(input()) pp = [] gg = [[[],[]],[[],[]]] for i in range(n): x, y = map(int, input().split()) pp.append((x, y)) gg[x %2][y%2].append(i) while len([len(gg[i][...
output
1
28,373
23
56,747
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a set of n≥ 2 pairwise different points with integer coordinates. Your task is to partition these points into two nonempty groups A and B, such that the following condition holds: For every two points P and Q, write the [Eucli...
instruction
0
28,374
23
56,748
Tags: constructive algorithms, geometry, math Correct Solution: ``` from bisect import bisect_left as bl from bisect import bisect_right as br import heapq import math from collections import * from functools import reduce,cmp_to_key import sys input = sys.stdin.readline # M = mod = 998244353 def factors(n):return so...
output
1
28,374
23
56,749
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a set of n≥ 2 pairwise different points with integer coordinates. Your task is to partition these points into two nonempty groups A and B, such that the following condition holds: For every two points P and Q, write the [Eucli...
instruction
0
28,375
23
56,750
Tags: constructive algorithms, geometry, math Correct Solution: ``` import sys def cin(): return [int(i) for i in sys.stdin.readline().split()] n, = cin() x0,y0 = cin() arr = [0] for i in range(n-1): x,y = cin() arr.append((x-x0)**2 + (y-y0)**2) while not any(i&1 for i in arr): for j in range(n): ...
output
1
28,375
23
56,751
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a set of n≥ 2 pairwise different points with integer coordinates. Your task is to partition these points into two nonempty groups A and B, such that the following condition holds: For every two points P and Q, write the [Eucli...
instruction
0
28,376
23
56,752
Tags: constructive algorithms, geometry, math Correct Solution: ``` n=int(input()) points = [tuple(map(int, input().split())) for _ in range(n)] while True: a_count = b_count = 0 for x, y in points: if (x + y) & 1: a_count += 1 else: b_count += 1 if a_count and b_coun...
output
1
28,376
23
56,753
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a set of n≥ 2 pairwise different points with integer coordinates. Your task is to partition these points into two nonempty groups A and B, such that the following condition holds: ...
instruction
0
28,377
23
56,754
Yes
output
1
28,377
23
56,755
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a set of n≥ 2 pairwise different points with integer coordinates. Your task is to partition these points into two nonempty groups A and B, such that the following condition holds: ...
instruction
0
28,378
23
56,756
Yes
output
1
28,378
23
56,757
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a set of n≥ 2 pairwise different points with integer coordinates. Your task is to partition these points into two nonempty groups A and B, such that the following condition holds: ...
instruction
0
28,379
23
56,758
Yes
output
1
28,379
23
56,759
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a set of n≥ 2 pairwise different points with integer coordinates. Your task is to partition these points into two nonempty groups A and B, such that the following condition holds: ...
instruction
0
28,380
23
56,760
Yes
output
1
28,380
23
56,761
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a set of n≥ 2 pairwise different points with integer coordinates. Your task is to partition these points into two nonempty groups A and B, such that the following condition holds: ...
instruction
0
28,381
23
56,762
No
output
1
28,381
23
56,763
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a set of n≥ 2 pairwise different points with integer coordinates. Your task is to partition these points into two nonempty groups A and B, such that the following condition holds: ...
instruction
0
28,382
23
56,764
No
output
1
28,382
23
56,765
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a set of n≥ 2 pairwise different points with integer coordinates. Your task is to partition these points into two nonempty groups A and B, such that the following condition holds: ...
instruction
0
28,383
23
56,766
No
output
1
28,383
23
56,767
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a set of n≥ 2 pairwise different points with integer coordinates. Your task is to partition these points into two nonempty groups A and B, such that the following condition holds: ...
instruction
0
28,384
23
56,768
No
output
1
28,384
23
56,769
Provide tags and a correct Python 3 solution for this coding contest problem. Phoenix is playing with a new puzzle, which consists of n identical puzzle pieces. Each puzzle piece is a right isosceles triangle as shown below. <image> A puzzle piece The goal of the puzzle is to create a square using the n pieces. He i...
instruction
0
28,490
23
56,980
Tags: brute force, geometry, math, number theory Correct Solution: ``` import math t = int(input()) for _ in range(t): n = int(input()) if(n%4==0 and int(math.sqrt(n/4)+0.5)**2 == n/4): print("YES") continue if(n%2==0 and int(math.sqrt(n/2)+0.5)**2 == n/2): print("YES") co...
output
1
28,490
23
56,981
Provide tags and a correct Python 3 solution for this coding contest problem. Phoenix is playing with a new puzzle, which consists of n identical puzzle pieces. Each puzzle piece is a right isosceles triangle as shown below. <image> A puzzle piece The goal of the puzzle is to create a square using the n pieces. He i...
instruction
0
28,491
23
56,982
Tags: brute force, geometry, math, number theory Correct Solution: ``` for v in range(int(input())): var=False n=int(input()) if n%2==0: a=int(n/2) if a**0.5==int(a**0.5): var=True if n%4==0: a=int(n/4) if a**0.5==int(a**0.5): var=True if var==...
output
1
28,491
23
56,983
Provide tags and a correct Python 3 solution for this coding contest problem. Phoenix is playing with a new puzzle, which consists of n identical puzzle pieces. Each puzzle piece is a right isosceles triangle as shown below. <image> A puzzle piece The goal of the puzzle is to create a square using the n pieces. He i...
instruction
0
28,492
23
56,984
Tags: brute force, geometry, math, number theory Correct Solution: ``` import math for _ in range(int(input())): n=int(input()) if n%2==0 and math.sqrt(n)==math.ceil(math.sqrt(n)): print("YES") continue if n%2==0 and math.sqrt(n//2)==math.ceil(math.sqrt(n//2)): print("YES") c...
output
1
28,492
23
56,985
Provide tags and a correct Python 3 solution for this coding contest problem. Phoenix is playing with a new puzzle, which consists of n identical puzzle pieces. Each puzzle piece is a right isosceles triangle as shown below. <image> A puzzle piece The goal of the puzzle is to create a square using the n pieces. He i...
instruction
0
28,493
23
56,986
Tags: brute force, geometry, math, number theory Correct Solution: ``` from math import log2 as log for _ in range(int(input())): n = int(input()) if n&1: print("NO") else: f = 0 i = 1 while i*i <= n: if(i*i==n): f=1 i += 1 ...
output
1
28,493
23
56,987
Provide tags and a correct Python 3 solution for this coding contest problem. Phoenix is playing with a new puzzle, which consists of n identical puzzle pieces. Each puzzle piece is a right isosceles triangle as shown below. <image> A puzzle piece The goal of the puzzle is to create a square using the n pieces. He i...
instruction
0
28,494
23
56,988
Tags: brute force, geometry, math, number theory Correct Solution: ``` import math t=int(input()) for i in range(t): n=int(input()) z=n/2 y=n/4 if (y**0.5)-int(y**0.5)==0: print("YES") elif (z**0.5)-int(z**0.5)==0: print("YES") else: print("NO") ```
output
1
28,494
23
56,989
Provide tags and a correct Python 3 solution for this coding contest problem. Phoenix is playing with a new puzzle, which consists of n identical puzzle pieces. Each puzzle piece is a right isosceles triangle as shown below. <image> A puzzle piece The goal of the puzzle is to create a square using the n pieces. He i...
instruction
0
28,495
23
56,990
Tags: brute force, geometry, math, number theory Correct Solution: ``` t = int(input()) for q in range(t): n = int(input()) a = (n/2)**(0.5) b = (n/4)**(0.5) if a%1 == 0 or b%1 == 0: print("YES") else: print("NO") ```
output
1
28,495
23
56,991
Provide tags and a correct Python 3 solution for this coding contest problem. Phoenix is playing with a new puzzle, which consists of n identical puzzle pieces. Each puzzle piece is a right isosceles triangle as shown below. <image> A puzzle piece The goal of the puzzle is to create a square using the n pieces. He i...
instruction
0
28,496
23
56,992
Tags: brute force, geometry, math, number theory Correct Solution: ``` import math def isSquare(x): if(x >= 0): sr = math.sqrt(x) # print(sr) s = math.floor(sr) # print(s) return ((s*s) == x) return False for _ in range(int(input())): n = int(input()) ...
output
1
28,496
23
56,993