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
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's assume that we are given a matrix b of size x Γ— y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x Γ— y matrix c which has the following properties: * the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; * the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n Γ— m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain? Input The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a. Output In the single line, print the answer to the problem β€” the minimum number of rows of matrix b. Examples Input 4 3 0 0 1 1 1 0 1 1 0 0 0 1 Output 2 Input 3 3 0 0 0 0 0 0 0 0 0 Output 3 Input 8 1 0 1 1 0 0 1 1 0 Output 2 Note In the first test sample the answer is a 2 Γ— 3 matrix b: 001 110 If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input: 001 110 110 001 Submitted Solution: ``` def inverte(arr): return arr[::-1] def solve(arr, i): normal = arr[:i] c = 1 for j in range(i, len(arr), i): if c % 2 == 0: # normal if normal != arr[j:j+i]: return False else: # invertida if normal != inverte(arr[j:j+i]): #print(normal, inverte(arr[j:j+i])) return False c += 1 return True linha = [int(i) for i in input().split()] n = linha[0] m = linha[1] arr = [] for i in range(n): arr.append([int(i) for i in input().split()]) ans = n for i in range(2, n): if n % i == 0: if solve(arr, i): ans = i break print(ans) ```
instruction
0
38,030
23
76,060
No
output
1
38,030
23
76,061
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's assume that we are given a matrix b of size x Γ— y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x Γ— y matrix c which has the following properties: * the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; * the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n Γ— m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain? Input The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a. Output In the single line, print the answer to the problem β€” the minimum number of rows of matrix b. Examples Input 4 3 0 0 1 1 1 0 1 1 0 0 0 1 Output 2 Input 3 3 0 0 0 0 0 0 0 0 0 Output 3 Input 8 1 0 1 1 0 0 1 1 0 Output 2 Note In the first test sample the answer is a 2 Γ— 3 matrix b: 001 110 If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input: 001 110 110 001 Submitted Solution: ``` import sys n,m = map(int,input().split()) a=[] for i in range(n): a.append(''.join(input().split())) if n==1 or n==2: print(1) sys.exit() if n%2: print(n) sys.exit() d=n//2 small=n while d: i=d-1 symmetry=True for j in range(d,2*d,1): if a[i] != a[j]: symmetry=False break i-=1 if symmetry: small=d else: break if d%2: break d//=2 print(small) ```
instruction
0
38,031
23
76,062
No
output
1
38,031
23
76,063
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's assume that we are given a matrix b of size x Γ— y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x Γ— y matrix c which has the following properties: * the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; * the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n Γ— m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain? Input The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a. Output In the single line, print the answer to the problem β€” the minimum number of rows of matrix b. Examples Input 4 3 0 0 1 1 1 0 1 1 0 0 0 1 Output 2 Input 3 3 0 0 0 0 0 0 0 0 0 Output 3 Input 8 1 0 1 1 0 0 1 1 0 Output 2 Note In the first test sample the answer is a 2 Γ— 3 matrix b: 001 110 If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input: 001 110 110 001 Submitted Solution: ``` from sys import stdin,stdout k=[] x,y= map(int,(stdin.readline().split())) for i in range(x): p=list(map(int,stdin.readline().split())) k.append(p) remainder = 0 count = 0 if x%2==0: while (x%2==0) and k[int((x-1)/2)]==k[int(x/2)]: x/=2 count+=1 stdout.write(str(int(x))+'\n') ```
instruction
0
38,032
23
76,064
No
output
1
38,032
23
76,065
Provide tags and a correct Python 3 solution for this coding contest problem. You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed not to increase the length of any stick. Determine the number of ways to increase the lengths of some sticks so that you can form from them a non-degenerate (that is, having a positive area) triangle. Two ways are considered different, if the length of some stick is increased by different number of centimeters in them. Input The single line contains 4 integers a, b, c, l (1 ≀ a, b, c ≀ 3Β·105, 0 ≀ l ≀ 3Β·105). Output Print a single integer β€” the number of ways to increase the sizes of the sticks by the total of at most l centimeters, so that you can make a non-degenerate triangle from it. Examples Input 1 1 1 2 Output 4 Input 1 2 3 1 Output 2 Input 10 2 1 7 Output 0 Note In the first sample test you can either not increase any stick or increase any two sticks by 1 centimeter. In the second sample test you can increase either the first or the second stick by one centimeter. Note that the triangle made from the initial sticks is degenerate and thus, doesn't meet the conditions.
instruction
0
38,102
23
76,204
Tags: combinatorics, implementation, math Correct Solution: ``` def f(a, b, c, l): k = min(l, a - b - c) return 0 if a < b + c else (k + 1) * (k + 2) // 2 solve = lambda i: f(a + i, b, c, l - i) + f(b + i, c, a, l - i) + f(c + i, a, b, l - i) a, b, c, l = map(int, input().split()) ans = (l + 1) * (l + 2) * (l + 3) // 6 - sum(solve(i) for i in range(l + 1)) print(ans) ```
output
1
38,102
23
76,205
Provide tags and a correct Python 3 solution for this coding contest problem. You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed not to increase the length of any stick. Determine the number of ways to increase the lengths of some sticks so that you can form from them a non-degenerate (that is, having a positive area) triangle. Two ways are considered different, if the length of some stick is increased by different number of centimeters in them. Input The single line contains 4 integers a, b, c, l (1 ≀ a, b, c ≀ 3Β·105, 0 ≀ l ≀ 3Β·105). Output Print a single integer β€” the number of ways to increase the sizes of the sticks by the total of at most l centimeters, so that you can make a non-degenerate triangle from it. Examples Input 1 1 1 2 Output 4 Input 1 2 3 1 Output 2 Input 10 2 1 7 Output 0 Note In the first sample test you can either not increase any stick or increase any two sticks by 1 centimeter. In the second sample test you can increase either the first or the second stick by one centimeter. Note that the triangle made from the initial sticks is degenerate and thus, doesn't meet the conditions.
instruction
0
38,103
23
76,206
Tags: combinatorics, implementation, math Correct Solution: ``` a, b, c, l = map(int, input().split()) ans = (l + 3) * (l + 2) * (l + 1) // 3 for z in (a, b, c): s = 2 * z - a - b - c for x in range(max(0, -s), l + 1): m = min(s + x, l - x) ans -= (m + 1) * (m + 2) print(ans // 2) # Made By Mostafa_Khaled ```
output
1
38,103
23
76,207
Provide tags and a correct Python 3 solution for this coding contest problem. You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed not to increase the length of any stick. Determine the number of ways to increase the lengths of some sticks so that you can form from them a non-degenerate (that is, having a positive area) triangle. Two ways are considered different, if the length of some stick is increased by different number of centimeters in them. Input The single line contains 4 integers a, b, c, l (1 ≀ a, b, c ≀ 3Β·105, 0 ≀ l ≀ 3Β·105). Output Print a single integer β€” the number of ways to increase the sizes of the sticks by the total of at most l centimeters, so that you can make a non-degenerate triangle from it. Examples Input 1 1 1 2 Output 4 Input 1 2 3 1 Output 2 Input 10 2 1 7 Output 0 Note In the first sample test you can either not increase any stick or increase any two sticks by 1 centimeter. In the second sample test you can increase either the first or the second stick by one centimeter. Note that the triangle made from the initial sticks is degenerate and thus, doesn't meet the conditions.
instruction
0
38,104
23
76,208
Tags: combinatorics, implementation, math Correct Solution: ``` def f(a,b,c,l): if a<b+c: return 0 else: c=min(l,a-b-c) return (c+1)*(c+2)/2 a,b,c,l = map(int,input().split()) z=(l+1)*(l+2)*(l+3)/6 i=0 while i<=l: z-=f(a+i,b,c,l-i)+f(b+i,c,a,l-i)+f(c+i,a,b,l-i) i+=1 print(int(z)) ```
output
1
38,104
23
76,209
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed not to increase the length of any stick. Determine the number of ways to increase the lengths of some sticks so that you can form from them a non-degenerate (that is, having a positive area) triangle. Two ways are considered different, if the length of some stick is increased by different number of centimeters in them. Input The single line contains 4 integers a, b, c, l (1 ≀ a, b, c ≀ 3Β·105, 0 ≀ l ≀ 3Β·105). Output Print a single integer β€” the number of ways to increase the sizes of the sticks by the total of at most l centimeters, so that you can make a non-degenerate triangle from it. Examples Input 1 1 1 2 Output 4 Input 1 2 3 1 Output 2 Input 10 2 1 7 Output 0 Note In the first sample test you can either not increase any stick or increase any two sticks by 1 centimeter. In the second sample test you can increase either the first or the second stick by one centimeter. Note that the triangle made from the initial sticks is degenerate and thus, doesn't meet the conditions. Submitted Solution: ``` def f(a,b,c,l): if a<b+c: return 0 else: c=min(l,a-b-c) return (c+1)*(c+2)/2 a,b,c,l = map(int,input().split()) z=(l+1)*(l+2)*(l+3)/6 i=0 while i<=l: z-=f(a+i,b,c,l-i)+f(b+i,c,a,l-i)+f(c+i,a,b,l-i) i+=1 print(z) ```
instruction
0
38,105
23
76,210
No
output
1
38,105
23
76,211
Provide tags and a correct Python 3 solution for this coding contest problem. Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees. Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≀ x, y. There is a tree in such a point, and it has x + y bananas. There are no trees nor bananas in other points. Now, Okabe draws a line with equation <image>. Okabe can select a single rectangle with axis aligned sides with all points on or under the line and cut all the trees in all points that are inside or on the border of this rectangle and take their bananas. Okabe's rectangle can be degenerate; that is, it can be a line segment or even a point. Help Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely. Okabe is sure that the answer does not exceed 1018. You can trust him. Input The first line of input contains two space-separated integers m and b (1 ≀ m ≀ 1000, 1 ≀ b ≀ 10000). Output Print the maximum number of bananas Okabe can get from the trees he cuts. Examples Input 1 5 Output 30 Input 2 3 Output 25 Note <image> The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas.
instruction
0
38,232
23
76,464
Tags: brute force, math Correct Solution: ``` m, b = map(int, input().split()) x, y = m*b, b s = 0 for j in range(y+1): i = m * (b - j) a1 = i * (1 + i) >> 1 d = i + 1 n = j + 1 s = max(s, n * (2 * a1 + (n - 1) * d) >> 1) print(s) ```
output
1
38,232
23
76,465
Provide tags and a correct Python 3 solution for this coding contest problem. Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees. Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≀ x, y. There is a tree in such a point, and it has x + y bananas. There are no trees nor bananas in other points. Now, Okabe draws a line with equation <image>. Okabe can select a single rectangle with axis aligned sides with all points on or under the line and cut all the trees in all points that are inside or on the border of this rectangle and take their bananas. Okabe's rectangle can be degenerate; that is, it can be a line segment or even a point. Help Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely. Okabe is sure that the answer does not exceed 1018. You can trust him. Input The first line of input contains two space-separated integers m and b (1 ≀ m ≀ 1000, 1 ≀ b ≀ 10000). Output Print the maximum number of bananas Okabe can get from the trees he cuts. Examples Input 1 5 Output 30 Input 2 3 Output 25 Note <image> The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas.
instruction
0
38,233
23
76,466
Tags: brute force, math Correct Solution: ``` def sigma(n): return n * (n + 1) // 2 def banans(p, q): return (p + 1) * sigma(q) + (q + 1) * sigma(p) m, b = [int(x) for x in input().split()] r = 0 for i in range(m * b + 1): if i % m == 0: p, q = i, b - i // m r = max(r, banans(p, q)) print(r) ```
output
1
38,233
23
76,467
Provide tags and a correct Python 3 solution for this coding contest problem. Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees. Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≀ x, y. There is a tree in such a point, and it has x + y bananas. There are no trees nor bananas in other points. Now, Okabe draws a line with equation <image>. Okabe can select a single rectangle with axis aligned sides with all points on or under the line and cut all the trees in all points that are inside or on the border of this rectangle and take their bananas. Okabe's rectangle can be degenerate; that is, it can be a line segment or even a point. Help Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely. Okabe is sure that the answer does not exceed 1018. You can trust him. Input The first line of input contains two space-separated integers m and b (1 ≀ m ≀ 1000, 1 ≀ b ≀ 10000). Output Print the maximum number of bananas Okabe can get from the trees he cuts. Examples Input 1 5 Output 30 Input 2 3 Output 25 Note <image> The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas.
instruction
0
38,234
23
76,468
Tags: brute force, math Correct Solution: ``` import math as mt import sys,string input=sys.stdin.readline import random from collections import deque,defaultdict L=lambda : list(map(int,input().split())) Ls=lambda : list(input().split()) M=lambda : map(int,input().split()) I=lambda :int(input()) def x(s,e): return (e*(e+1))//2-(s*(s-1))//2 m,b=M() w=(b-1)//2 h=m*b-m*w ans=0 k=0 for i in range(m*b,-1,-m): h=i w=k p=h*(h+1)*(w+1) p//=2 q=w*(w+1)*(h+1) q//=2 ans=max(ans,p+q) k+=1 print(ans) ```
output
1
38,234
23
76,469
Provide tags and a correct Python 3 solution for this coding contest problem. Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees. Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≀ x, y. There is a tree in such a point, and it has x + y bananas. There are no trees nor bananas in other points. Now, Okabe draws a line with equation <image>. Okabe can select a single rectangle with axis aligned sides with all points on or under the line and cut all the trees in all points that are inside or on the border of this rectangle and take their bananas. Okabe's rectangle can be degenerate; that is, it can be a line segment or even a point. Help Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely. Okabe is sure that the answer does not exceed 1018. You can trust him. Input The first line of input contains two space-separated integers m and b (1 ≀ m ≀ 1000, 1 ≀ b ≀ 10000). Output Print the maximum number of bananas Okabe can get from the trees he cuts. Examples Input 1 5 Output 30 Input 2 3 Output 25 Note <image> The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas.
instruction
0
38,235
23
76,470
Tags: brute force, math Correct Solution: ``` import math,sys,bisect,heapq from collections import defaultdict,Counter,deque from itertools import groupby,accumulate #sys.setrecursionlimit(200000000) int1 = lambda x: int(x) - 1 input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__ ilele = lambda: map(int,input().split()) alele = lambda: list(map(int, input().split())) ilelec = lambda: map(int1,input().split()) alelec = lambda: list(map(int1, input().split())) def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] #MOD = 1000000000 + 7 def Y(c): print(["NO","YES"][c]) def y(c): print(["no","yes"][c]) def Yy(c): print(["No","Yes"][c]) m,b = ilele() #y = b - x/m Ans = 0 def fun(x,y): return ((y*(y+1))//2)*(x+1) for y in range(b,-1,-1): x= m*(b - y) a= fun(x,y) + fun(y,x) Ans = max(Ans,a) print(Ans) ```
output
1
38,235
23
76,471
Provide tags and a correct Python 3 solution for this coding contest problem. Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees. Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≀ x, y. There is a tree in such a point, and it has x + y bananas. There are no trees nor bananas in other points. Now, Okabe draws a line with equation <image>. Okabe can select a single rectangle with axis aligned sides with all points on or under the line and cut all the trees in all points that are inside or on the border of this rectangle and take their bananas. Okabe's rectangle can be degenerate; that is, it can be a line segment or even a point. Help Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely. Okabe is sure that the answer does not exceed 1018. You can trust him. Input The first line of input contains two space-separated integers m and b (1 ≀ m ≀ 1000, 1 ≀ b ≀ 10000). Output Print the maximum number of bananas Okabe can get from the trees he cuts. Examples Input 1 5 Output 30 Input 2 3 Output 25 Note <image> The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas.
instruction
0
38,236
23
76,472
Tags: brute force, math Correct Solution: ``` # Time : 2017-6-26 13:30 # Auther : Anjone # URL : http://codeforces.com/contest/821/problem/B from math import floor; getsum = lambda x,y : int((int(y)+1) * (int(x)+int(y)) * (int(x)+1) // 2) m,b = map(int,input().split()) ans = 0 for i in range(b+1): x = (b-i)*m ans = max(ans, getsum(x,i)) print(ans) ```
output
1
38,236
23
76,473
Provide tags and a correct Python 3 solution for this coding contest problem. Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees. Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≀ x, y. There is a tree in such a point, and it has x + y bananas. There are no trees nor bananas in other points. Now, Okabe draws a line with equation <image>. Okabe can select a single rectangle with axis aligned sides with all points on or under the line and cut all the trees in all points that are inside or on the border of this rectangle and take their bananas. Okabe's rectangle can be degenerate; that is, it can be a line segment or even a point. Help Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely. Okabe is sure that the answer does not exceed 1018. You can trust him. Input The first line of input contains two space-separated integers m and b (1 ≀ m ≀ 1000, 1 ≀ b ≀ 10000). Output Print the maximum number of bananas Okabe can get from the trees he cuts. Examples Input 1 5 Output 30 Input 2 3 Output 25 Note <image> The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas.
instruction
0
38,237
23
76,474
Tags: brute force, math Correct Solution: ``` def series(x): return x*(x+1)//2 def max(a,b): # print(type(a)) return a if a>b else b m,b=map(int,input().split()) mymax=0 for y in range(0,b+1): x = m*(b-y) # t = 0 t=(x+1)*series(y)+(y+1)*series(x) mymax = int(max(mymax, t)) print((mymax)) ```
output
1
38,237
23
76,475
Provide tags and a correct Python 3 solution for this coding contest problem. Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees. Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≀ x, y. There is a tree in such a point, and it has x + y bananas. There are no trees nor bananas in other points. Now, Okabe draws a line with equation <image>. Okabe can select a single rectangle with axis aligned sides with all points on or under the line and cut all the trees in all points that are inside or on the border of this rectangle and take their bananas. Okabe's rectangle can be degenerate; that is, it can be a line segment or even a point. Help Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely. Okabe is sure that the answer does not exceed 1018. You can trust him. Input The first line of input contains two space-separated integers m and b (1 ≀ m ≀ 1000, 1 ≀ b ≀ 10000). Output Print the maximum number of bananas Okabe can get from the trees he cuts. Examples Input 1 5 Output 30 Input 2 3 Output 25 Note <image> The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas.
instruction
0
38,238
23
76,476
Tags: brute force, math Correct Solution: ``` ans = [] m,b = map(int,input().split()) for x in range(m*b + 1): y = -x/m + b if y.is_integer(): y = -x//m + b start = (0 + x)*(x+1)//2 end = (start + y*(x+1)) ans.append(int((start+end)*(y+1)//2)) print(max(ans)) ```
output
1
38,238
23
76,477
Provide tags and a correct Python 3 solution for this coding contest problem. Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees. Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≀ x, y. There is a tree in such a point, and it has x + y bananas. There are no trees nor bananas in other points. Now, Okabe draws a line with equation <image>. Okabe can select a single rectangle with axis aligned sides with all points on or under the line and cut all the trees in all points that are inside or on the border of this rectangle and take their bananas. Okabe's rectangle can be degenerate; that is, it can be a line segment or even a point. Help Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely. Okabe is sure that the answer does not exceed 1018. You can trust him. Input The first line of input contains two space-separated integers m and b (1 ≀ m ≀ 1000, 1 ≀ b ≀ 10000). Output Print the maximum number of bananas Okabe can get from the trees he cuts. Examples Input 1 5 Output 30 Input 2 3 Output 25 Note <image> The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas.
instruction
0
38,239
23
76,478
Tags: brute force, math Correct Solution: ``` m, b = [int(i) for i in input().split()] res = 0 for i in range(b + 1): j = (b - i) * m res = max(res, (i + 1) * (j + 1) * (i + j) // 2) print(res) ```
output
1
38,239
23
76,479
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees. Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≀ x, y. There is a tree in such a point, and it has x + y bananas. There are no trees nor bananas in other points. Now, Okabe draws a line with equation <image>. Okabe can select a single rectangle with axis aligned sides with all points on or under the line and cut all the trees in all points that are inside or on the border of this rectangle and take their bananas. Okabe's rectangle can be degenerate; that is, it can be a line segment or even a point. Help Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely. Okabe is sure that the answer does not exceed 1018. You can trust him. Input The first line of input contains two space-separated integers m and b (1 ≀ m ≀ 1000, 1 ≀ b ≀ 10000). Output Print the maximum number of bananas Okabe can get from the trees he cuts. Examples Input 1 5 Output 30 Input 2 3 Output 25 Note <image> The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas. Submitted Solution: ``` # Time : 2017-6-26 13:30 # Auther : Anjone # URL : http://codeforces.com/contest/821/problem/B from math import floor; getsum = lambda x,y : ( y + 1 ) * ( x + y ) * (x+1) // 2 m,b = map(int,input().split()) ans = 0 for i in range(b+1): ans = max(ans, getsum( ( b - i ) * m, i)) print(ans) ```
instruction
0
38,240
23
76,480
Yes
output
1
38,240
23
76,481
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees. Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≀ x, y. There is a tree in such a point, and it has x + y bananas. There are no trees nor bananas in other points. Now, Okabe draws a line with equation <image>. Okabe can select a single rectangle with axis aligned sides with all points on or under the line and cut all the trees in all points that are inside or on the border of this rectangle and take their bananas. Okabe's rectangle can be degenerate; that is, it can be a line segment or even a point. Help Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely. Okabe is sure that the answer does not exceed 1018. You can trust him. Input The first line of input contains two space-separated integers m and b (1 ≀ m ≀ 1000, 1 ≀ b ≀ 10000). Output Print the maximum number of bananas Okabe can get from the trees he cuts. Examples Input 1 5 Output 30 Input 2 3 Output 25 Note <image> The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas. Submitted Solution: ``` m,b = input().strip().split() m,b = int(m),int(b) sum_s = [] x_zero = m*b y_zero = b for i in range(0,b*m + 1,m): x = i y = b - i/m y =int(y) s = ((1+y)*y//2)*(x+1) s += ((1+x)*x//2)*(y+1) sum_s.append(s) print(max(sum_s)) ```
instruction
0
38,242
23
76,484
Yes
output
1
38,242
23
76,485
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees. Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≀ x, y. There is a tree in such a point, and it has x + y bananas. There are no trees nor bananas in other points. Now, Okabe draws a line with equation <image>. Okabe can select a single rectangle with axis aligned sides with all points on or under the line and cut all the trees in all points that are inside or on the border of this rectangle and take their bananas. Okabe's rectangle can be degenerate; that is, it can be a line segment or even a point. Help Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely. Okabe is sure that the answer does not exceed 1018. You can trust him. Input The first line of input contains two space-separated integers m and b (1 ≀ m ≀ 1000, 1 ≀ b ≀ 10000). Output Print the maximum number of bananas Okabe can get from the trees he cuts. Examples Input 1 5 Output 30 Input 2 3 Output 25 Note <image> The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas. Submitted Solution: ``` m,b=list(map(int,input().split())) u=0 for j in range(b-1,-1,-1): y=j x=m*(b-j) s=x*(x+1)//2 t=y*(y+1)//2 p=t+s+(s)*y+t*x if p>u: u=p print(u) ```
instruction
0
38,243
23
76,486
Yes
output
1
38,243
23
76,487
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees. Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≀ x, y. There is a tree in such a point, and it has x + y bananas. There are no trees nor bananas in other points. Now, Okabe draws a line with equation <image>. Okabe can select a single rectangle with axis aligned sides with all points on or under the line and cut all the trees in all points that are inside or on the border of this rectangle and take their bananas. Okabe's rectangle can be degenerate; that is, it can be a line segment or even a point. Help Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely. Okabe is sure that the answer does not exceed 1018. You can trust him. Input The first line of input contains two space-separated integers m and b (1 ≀ m ≀ 1000, 1 ≀ b ≀ 10000). Output Print the maximum number of bananas Okabe can get from the trees he cuts. Examples Input 1 5 Output 30 Input 2 3 Output 25 Note <image> The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas. Submitted Solution: ``` from math import ceil, floor def f(x1, y1): # print(x1, y1) c = y1 * (y1+1) // 2 * (x1+1) # k = 0 # for x in range(x1+1): # k += x # # for y in range(y1+1): # # # print('xy', x, y) # # c += x + y k = x1 * (x1+1) // 2 c += k * (y1+1) return c m, b = map(int, input().split()) y1 = b x1 = b*m # print(x1, y1, x1//2+1, y1//2+1) x2 = x1 / 2 x2c = ceil(x2) y2c = int(-x2c / m + b) x2f = floor(x2) if x2f != x2c: y2f = int(-x2f / m + b) res = max(f(x2c, y2c), f(x2f, y2f)) else: res = f(x2c, y2c) y2 = y1 / 2 y2c = ceil(y2) x2c = (b - y2c) * m y2f = floor(y2) if y2f != y2c: x2f = (b - y2f) * m res = max(res, f(x2c, y2c), f(x2f, y2f)) else: res = max(res, f(x2c, y2c)) print(res) ```
instruction
0
38,244
23
76,488
No
output
1
38,244
23
76,489
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees. Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≀ x, y. There is a tree in such a point, and it has x + y bananas. There are no trees nor bananas in other points. Now, Okabe draws a line with equation <image>. Okabe can select a single rectangle with axis aligned sides with all points on or under the line and cut all the trees in all points that are inside or on the border of this rectangle and take their bananas. Okabe's rectangle can be degenerate; that is, it can be a line segment or even a point. Help Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely. Okabe is sure that the answer does not exceed 1018. You can trust him. Input The first line of input contains two space-separated integers m and b (1 ≀ m ≀ 1000, 1 ≀ b ≀ 10000). Output Print the maximum number of bananas Okabe can get from the trees he cuts. Examples Input 1 5 Output 30 Input 2 3 Output 25 Note <image> The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas. Submitted Solution: ``` import math line = input() line = line.split() m = float(line[0]) b = float(line[1]) x = 0 y = b max = b while ( y >= 0): if (y == math.floor(y)): sum = 0 for i in range(int(x)+1): for j in range(int(y)+1): sum = sum + i + j if sum > max: max = sum x = x + 1 if ( x == (m*b) ): y = 0 else: y = y - 1.0/m print(max) ```
instruction
0
38,245
23
76,490
No
output
1
38,245
23
76,491
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees. Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≀ x, y. There is a tree in such a point, and it has x + y bananas. There are no trees nor bananas in other points. Now, Okabe draws a line with equation <image>. Okabe can select a single rectangle with axis aligned sides with all points on or under the line and cut all the trees in all points that are inside or on the border of this rectangle and take their bananas. Okabe's rectangle can be degenerate; that is, it can be a line segment or even a point. Help Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely. Okabe is sure that the answer does not exceed 1018. You can trust him. Input The first line of input contains two space-separated integers m and b (1 ≀ m ≀ 1000, 1 ≀ b ≀ 10000). Output Print the maximum number of bananas Okabe can get from the trees he cuts. Examples Input 1 5 Output 30 Input 2 3 Output 25 Note <image> The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas. Submitted Solution: ``` """ Perfection is achieved not when there is nothing more to add, but rather when there is nothing more to take away. """ import sys input = sys.stdin.readline # from bisect import bisect_left as lower_bound; # from bisect import bisect_right as upper_bound; # from math import ceil, factorial; def ceil(x): if x != int(x): x = int(x) + 1; return x; def factorial(x, m): val = 1 while x>0: val = (val * x) % m x -= 1 return val # swap_array function def swaparr(arr, a,b): temp = arr[a]; arr[a] = arr[b]; arr[b] = temp; ## gcd function def gcd(a,b): if b == 0: return a; return gcd(b, a % b); ## nCr function efficient using Binomial Cofficient def nCr(n, k): if(k > n - k): k = n - k; res = 1; for i in range(k): res = res * (n - i); res = res / (i + 1); return int(res); ## upper bound function code -- such that e in a[:i] e < x; def upper_bound(a, x, lo=0, hi = None): if hi == None: hi = len(a); while lo < hi: mid = (lo+hi)//2; if a[mid] < x: lo = mid+1; else: hi = mid; return lo; ## prime factorization def primefs(n): ## if n == 1 ## calculating primes primes = {} while(n%2 == 0 and n > 0): primes[2] = primes.get(2, 0) + 1 n = n//2 for i in range(3, int(n**0.5)+2, 2): while(n%i == 0 and n > 0): primes[i] = primes.get(i, 0) + 1 n = n//i if n > 2: primes[n] = primes.get(n, 0) + 1 ## prime factoriazation of n is stored in dictionary ## primes and can be accesed. O(sqrt n) return primes ## MODULAR EXPONENTIATION FUNCTION def power(x, y, p): res = 1 x = x % p if (x == 0) : return 0 while (y > 0) : if ((y & 1) == 1) : res = (res * x) % p y = y >> 1 x = (x * x) % p return res ## DISJOINT SET UNINON FUNCTIONS def swap(a,b): temp = a a = b b = temp return a,b; # find function with path compression included (recursive) # def find(x, link): # if link[x] == x: # return x # link[x] = find(link[x], link); # return link[x]; # find function with path compression (ITERATIVE) def find(x, link): p = x; while( p != link[p]): p = link[p]; while( x != p): nex = link[x]; link[x] = p; x = nex; return p; # the union function which makes union(x,y) # of two nodes x and y def union(x, y, link, size): x = find(x, link) y = find(y, link) if size[x] < size[y]: x,y = swap(x,y) if x != y: size[x] += size[y] link[y] = x ## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES def sieve(n): prime = [True for i in range(n+1)] p = 2 while (p * p <= n): if (prime[p] == True): for i in range(p * p, n+1, p): prime[i] = False p += 1 return prime #### PRIME FACTORIZATION IN O(log n) using Sieve #### MAXN = int(1e5 + 5) def spf_sieve(): spf[1] = 1; for i in range(2, MAXN): spf[i] = i; for i in range(4, MAXN, 2): spf[i] = 2; for i in range(3, ceil(MAXN ** 0.5), 2): if spf[i] == i: for j in range(i*i, MAXN, i): if spf[j] == j: spf[j] = i; ## function for storing smallest prime factors (spf) in the array ################## un-comment below 2 lines when using factorization ################# # spf = [0 for i in range(MAXN)] # spf_sieve(); def factoriazation(x): ret = {}; while x != 1: ret[spf[x]] = ret.get(spf[x], 0) + 1; x = x//spf[x] return ret; ## this function is useful for multiple queries only, o/w use ## primefs function above. complexity O(log n) ## taking integer array input def int_array(): return list(map(int, input().strip().split())); def float_array(): return list(map(float, input().strip().split())); ## taking string array input def str_array(): return input().strip().split(); #defining a couple constants MOD = int(1e9)+7; CMOD = 998244353; INF = float('inf'); NINF = -float('inf'); ################### ---------------- TEMPLATE ENDS HERE ---------------- ################### from itertools import permutations import math def solve(): m, b = map(int, input().split()) x_, y_ = m * b, b xval = 0 yval = 0 area = 0 for y in range(y_ + 1): x = (b - y) * m if x * y > area: area = x * y xval, yval = x, y print((xval * (xval + 1) * (yval + 1) // 2) + (yval * (yval + 1) * (xval + 1) // 2)) if __name__ == '__main__': for _ in range(1): solve() # fin_time = datetime.now() # print("Execution time (for loop): ", (fin_time-init_time)) ```
instruction
0
38,246
23
76,492
No
output
1
38,246
23
76,493
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees. Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≀ x, y. There is a tree in such a point, and it has x + y bananas. There are no trees nor bananas in other points. Now, Okabe draws a line with equation <image>. Okabe can select a single rectangle with axis aligned sides with all points on or under the line and cut all the trees in all points that are inside or on the border of this rectangle and take their bananas. Okabe's rectangle can be degenerate; that is, it can be a line segment or even a point. Help Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely. Okabe is sure that the answer does not exceed 1018. You can trust him. Input The first line of input contains two space-separated integers m and b (1 ≀ m ≀ 1000, 1 ≀ b ≀ 10000). Output Print the maximum number of bananas Okabe can get from the trees he cuts. Examples Input 1 5 Output 30 Input 2 3 Output 25 Note <image> The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas. Submitted Solution: ``` tmp = input() tmp = tmp.split(" ") m = int(tmp[0]) b = int(tmp[1]) maxx=0 for i in range(1, b): x=m*i y=b-i maxx=max(maxx, (x+1)*x/2*(y+1)+(y+1)*y/2*(x+1)) print(int(maxx)) ```
instruction
0
38,247
23
76,494
No
output
1
38,247
23
76,495
Provide a correct Python 3 solution for this coding contest problem. Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.) We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base. When will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water. Constraints * All values in input are integers. * 1 \leq a \leq 100 * 1 \leq b \leq 100 * 1 \leq x \leq a^2b Input Input is given from Standard Input in the following format: a b x Output Print the maximum angle in which we can tilt the bottle without spilling any water, in degrees. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. Examples Input 2 2 4 Output 45.0000000000 Input 12 21 10 Output 89.7834636934 Input 3 1 8 Output 4.2363947991
instruction
0
38,360
23
76,720
"Correct Solution: ``` from math import* a,b,x=map(int,input().split()) print(atan(2*(b/a-x/a**3)if x>a*a*b/2else a*b*b/2/x)/pi*180) ```
output
1
38,360
23
76,721
Provide a correct Python 3 solution for this coding contest problem. Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.) We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base. When will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water. Constraints * All values in input are integers. * 1 \leq a \leq 100 * 1 \leq b \leq 100 * 1 \leq x \leq a^2b Input Input is given from Standard Input in the following format: a b x Output Print the maximum angle in which we can tilt the bottle without spilling any water, in degrees. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. Examples Input 2 2 4 Output 45.0000000000 Input 12 21 10 Output 89.7834636934 Input 3 1 8 Output 4.2363947991
instruction
0
38,361
23
76,722
"Correct Solution: ``` from math import atan, degrees a, b, x = map(int, input().split()) rad = atan(2*(b/a-x/(a**3))) if x>=(a**2)*b/2 else atan(a*(b**2)/2/x) print(degrees(rad)) ```
output
1
38,361
23
76,723
Provide a correct Python 3 solution for this coding contest problem. Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.) We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base. When will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water. Constraints * All values in input are integers. * 1 \leq a \leq 100 * 1 \leq b \leq 100 * 1 \leq x \leq a^2b Input Input is given from Standard Input in the following format: a b x Output Print the maximum angle in which we can tilt the bottle without spilling any water, in degrees. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. Examples Input 2 2 4 Output 45.0000000000 Input 12 21 10 Output 89.7834636934 Input 3 1 8 Output 4.2363947991
instruction
0
38,362
23
76,724
"Correct Solution: ``` from math import atan,degrees a,b,x = map(int,input().split()) if x <= a*a*b/2: ans = atan(a*b*b/(2*x)) else: ans = atan(2*b/a-2*x/a**3) print(degrees(ans)) ```
output
1
38,362
23
76,725
Provide a correct Python 3 solution for this coding contest problem. Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.) We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base. When will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water. Constraints * All values in input are integers. * 1 \leq a \leq 100 * 1 \leq b \leq 100 * 1 \leq x \leq a^2b Input Input is given from Standard Input in the following format: a b x Output Print the maximum angle in which we can tilt the bottle without spilling any water, in degrees. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. Examples Input 2 2 4 Output 45.0000000000 Input 12 21 10 Output 89.7834636934 Input 3 1 8 Output 4.2363947991
instruction
0
38,363
23
76,726
"Correct Solution: ``` from math import atan,pi a,b,x=map(int,input().split()) if b-x/a**2 <= x/a**2:print(atan((b-x/a**2)/(a/2))*(180/pi)) else: y = x/a*2/b print(atan(b/y)*(180/pi)) ```
output
1
38,363
23
76,727
Provide a correct Python 3 solution for this coding contest problem. Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.) We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base. When will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water. Constraints * All values in input are integers. * 1 \leq a \leq 100 * 1 \leq b \leq 100 * 1 \leq x \leq a^2b Input Input is given from Standard Input in the following format: a b x Output Print the maximum angle in which we can tilt the bottle without spilling any water, in degrees. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. Examples Input 2 2 4 Output 45.0000000000 Input 12 21 10 Output 89.7834636934 Input 3 1 8 Output 4.2363947991
instruction
0
38,364
23
76,728
"Correct Solution: ``` import math a, b, x = map(int, input().split()) if (x/a**2)*2 < b: print (math.degrees(math.atan((a*b*b)/(2*x)))) else: print (math.degrees(math.atan((b-x/a**2)*2/a))) ```
output
1
38,364
23
76,729
Provide a correct Python 3 solution for this coding contest problem. Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.) We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base. When will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water. Constraints * All values in input are integers. * 1 \leq a \leq 100 * 1 \leq b \leq 100 * 1 \leq x \leq a^2b Input Input is given from Standard Input in the following format: a b x Output Print the maximum angle in which we can tilt the bottle without spilling any water, in degrees. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. Examples Input 2 2 4 Output 45.0000000000 Input 12 21 10 Output 89.7834636934 Input 3 1 8 Output 4.2363947991
instruction
0
38,365
23
76,730
"Correct Solution: ``` from math import * a,b,x=map(int,input().split()) if 2*x<a*a*b: print(atan(a*b*b/2/x)/pi*180) else: print(atan(-2/a/a/a*(x-a*a*b))/pi*180) ```
output
1
38,365
23
76,731
Provide a correct Python 3 solution for this coding contest problem. Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.) We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base. When will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water. Constraints * All values in input are integers. * 1 \leq a \leq 100 * 1 \leq b \leq 100 * 1 \leq x \leq a^2b Input Input is given from Standard Input in the following format: a b x Output Print the maximum angle in which we can tilt the bottle without spilling any water, in degrees. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. Examples Input 2 2 4 Output 45.0000000000 Input 12 21 10 Output 89.7834636934 Input 3 1 8 Output 4.2363947991
instruction
0
38,366
23
76,732
"Correct Solution: ``` a,b,x=map(int,input().split()) x/=a import math if x<=a*b/2: print(math.degrees(math.atan(b*b/2/x))) else: print(math.degrees(math.atan(2*(a*b-x)/a/a))) ```
output
1
38,366
23
76,733
Provide a correct Python 3 solution for this coding contest problem. Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.) We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base. When will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water. Constraints * All values in input are integers. * 1 \leq a \leq 100 * 1 \leq b \leq 100 * 1 \leq x \leq a^2b Input Input is given from Standard Input in the following format: a b x Output Print the maximum angle in which we can tilt the bottle without spilling any water, in degrees. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. Examples Input 2 2 4 Output 45.0000000000 Input 12 21 10 Output 89.7834636934 Input 3 1 8 Output 4.2363947991
instruction
0
38,367
23
76,734
"Correct Solution: ``` import math a,b,x=map(int,input().split()) v=a*a*b if x>v/2: print(math.degrees(math.atan(2*(b-x/(a**2))/a))) else: print(math.degrees(math.atan(a*b*b/(2*x)))) ```
output
1
38,367
23
76,735
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.) We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base. When will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water. Constraints * All values in input are integers. * 1 \leq a \leq 100 * 1 \leq b \leq 100 * 1 \leq x \leq a^2b Input Input is given from Standard Input in the following format: a b x Output Print the maximum angle in which we can tilt the bottle without spilling any water, in degrees. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. Examples Input 2 2 4 Output 45.0000000000 Input 12 21 10 Output 89.7834636934 Input 3 1 8 Output 4.2363947991 Submitted Solution: ``` import math a,b,x=map(int,input().split()) if x/a>=a*b/2: tangent= 2*b/a-2*x/a**3 else: tangent=a*b*b /(2*x) print(math.degrees(math.atan(tangent))) ```
instruction
0
38,368
23
76,736
Yes
output
1
38,368
23
76,737
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.) We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base. When will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water. Constraints * All values in input are integers. * 1 \leq a \leq 100 * 1 \leq b \leq 100 * 1 \leq x \leq a^2b Input Input is given from Standard Input in the following format: a b x Output Print the maximum angle in which we can tilt the bottle without spilling any water, in degrees. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. Examples Input 2 2 4 Output 45.0000000000 Input 12 21 10 Output 89.7834636934 Input 3 1 8 Output 4.2363947991 Submitted Solution: ``` import math a,b,x = map(int, input().split()) if x <= a*a*b / 2: rad = math.atan(a*b*b/2/x) else: rad = math.atan(2*(a*a*b - x)/a**3) print(math.degrees(rad)) ```
instruction
0
38,369
23
76,738
Yes
output
1
38,369
23
76,739
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.) We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base. When will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water. Constraints * All values in input are integers. * 1 \leq a \leq 100 * 1 \leq b \leq 100 * 1 \leq x \leq a^2b Input Input is given from Standard Input in the following format: a b x Output Print the maximum angle in which we can tilt the bottle without spilling any water, in degrees. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. Examples Input 2 2 4 Output 45.0000000000 Input 12 21 10 Output 89.7834636934 Input 3 1 8 Output 4.2363947991 Submitted Solution: ``` import math a,b,x = map(int,input().split()) if a*a*b/2 <= x: j = 2*(b/a - x/(a**3)) else: j = b*b*a/(2*x) ans = math.degrees(math.atan(j)) print(ans) ```
instruction
0
38,370
23
76,740
Yes
output
1
38,370
23
76,741
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.) We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base. When will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water. Constraints * All values in input are integers. * 1 \leq a \leq 100 * 1 \leq b \leq 100 * 1 \leq x \leq a^2b Input Input is given from Standard Input in the following format: a b x Output Print the maximum angle in which we can tilt the bottle without spilling any water, in degrees. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. Examples Input 2 2 4 Output 45.0000000000 Input 12 21 10 Output 89.7834636934 Input 3 1 8 Output 4.2363947991 Submitted Solution: ``` import math a,b,x=map(int,input().split()) if x>=a*b*a/2: theta=math.atan(2*b/a-2*x/(a**3)) else: theta=math.atan(b**2*a/(2*x)) print(theta/math.pi*180) ```
instruction
0
38,371
23
76,742
Yes
output
1
38,371
23
76,743
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.) We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base. When will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water. Constraints * All values in input are integers. * 1 \leq a \leq 100 * 1 \leq b \leq 100 * 1 \leq x \leq a^2b Input Input is given from Standard Input in the following format: a b x Output Print the maximum angle in which we can tilt the bottle without spilling any water, in degrees. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. Examples Input 2 2 4 Output 45.0000000000 Input 12 21 10 Output 89.7834636934 Input 3 1 8 Output 4.2363947991 Submitted Solution: ``` from math import degrees, atan2 a, b, x = map(int, input().split()) S = x / a if S >= a * b / 2: h = 2 * (a * b - S) / a theta = atan2(h, a) else: w = S / b theta = atan2(b, w) print(degrees(theta)) ```
instruction
0
38,372
23
76,744
No
output
1
38,372
23
76,745
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.) We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base. When will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water. Constraints * All values in input are integers. * 1 \leq a \leq 100 * 1 \leq b \leq 100 * 1 \leq x \leq a^2b Input Input is given from Standard Input in the following format: a b x Output Print the maximum angle in which we can tilt the bottle without spilling any water, in degrees. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. Examples Input 2 2 4 Output 45.0000000000 Input 12 21 10 Output 89.7834636934 Input 3 1 8 Output 4.2363947991 Submitted Solution: ``` import math a, b, x = map(int, input().split()) t1 = x * (2/(a*(b**2))) t2 = a/(2 * b - x * (2/(a**2))) if t1 < (a/b): print(90.-math.degrees(math.atan(t1))) else: print(90.-math.degrees(math.atan(t2))) ```
instruction
0
38,373
23
76,746
No
output
1
38,373
23
76,747
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.) We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base. When will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water. Constraints * All values in input are integers. * 1 \leq a \leq 100 * 1 \leq b \leq 100 * 1 \leq x \leq a^2b Input Input is given from Standard Input in the following format: a b x Output Print the maximum angle in which we can tilt the bottle without spilling any water, in degrees. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. Examples Input 2 2 4 Output 45.0000000000 Input 12 21 10 Output 89.7834636934 Input 3 1 8 Output 4.2363947991 Submitted Solution: ``` import math a, b, x = map(int, input().split()) t = x / a / a maxim = b-t ans = math.degrees(math.atan(2*maxim/a)) if ans <= 45: print(ans) else: ans = 90 - math.degrees((math.atan(2*x/a/b/b))) print(ans) ```
instruction
0
38,374
23
76,748
No
output
1
38,374
23
76,749
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.) We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base. When will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water. Constraints * All values in input are integers. * 1 \leq a \leq 100 * 1 \leq b \leq 100 * 1 \leq x \leq a^2b Input Input is given from Standard Input in the following format: a b x Output Print the maximum angle in which we can tilt the bottle without spilling any water, in degrees. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. Examples Input 2 2 4 Output 45.0000000000 Input 12 21 10 Output 89.7834636934 Input 3 1 8 Output 4.2363947991 Submitted Solution: ``` import math a, b, x = map(int, input().split()) if a**2*b == x: print(0) if x > (a**2*b)/2: p = a/(2*(b-x/a**2)) print(90-math.degrees(math.atan(p))) else: p = 2*x/(a*b**2) print(90-math.degrees(math.atan(p))) ```
instruction
0
38,375
23
76,750
No
output
1
38,375
23
76,751
Provide tags and a correct Python 3 solution for this coding contest problem. You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points. Input The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide. Output The only line of output should contain the required sum of squares of distances between all pairs of points. Examples Input 4 1 1 -1 -1 1 -1 -1 1 Output 32
instruction
0
39,212
23
78,424
Tags: implementation, math Correct Solution: ``` import sys import os from io import BytesIO, IOBase ######################### # imgur.com/Pkt7iIf.png # ######################### # returns the list of prime numbers less than or equal to n: '''def sieve(n): if n < 2: return list() prime = [True for _ in range(n + 1)] p = 3 while p * p <= n: if prime[p]: for i in range(p * p, n + 1, p): prime[i] = False p += 2 r = [2] for p in range(3, n + 1, 2): if prime[p]: r.append(p) return r''' # returns all the divisors of a number n(takes an additional parameter start): '''def divs(n, start=1): divisors = [] for i in range(start, int(n**.5) + 1): if n % i == 0: if n / i == i: divisors.append(i) else: divisors.extend([i, n // i]) return len(divisors)''' # returns the number of factors of a given number if a primes list is given: '''def divn(n, primes): divs_number = 1 for i in primes: if n == 1: return divs_number t = 1 while n % i == 0: t += 1 n //= i divs_number *= t return divs_number''' # returns the leftmost and rightmost positions of x in a given list d(if x isnot present then returns (-1,-1)): '''def flin(d, x, default=-1): left = right = -1 for i in range(len(d)): if d[i] == x: if left == -1: left = i right = i if left == -1: return (default, default) else: return (left, right)''' #count xor of numbers from 1 to n: '''def xor1_n(n): d={0:n,1:1,2:n+1,3:0} return d[n&3]''' def cel(n, k): return n // k + (n % k != 0) def ii(): return int(input()) def mi(): return map(int, input().split()) def li(): return list(map(int, input().split())) def lcm(a, b): return abs(a * b) // math.gcd(a, b) def prr(a, sep=' '): print(sep.join(map(str, a))) def dd(): return defaultdict(int) def ddl(): return defaultdict(list) def ddd(): return defaultdict(defaultdict(int)) # region fastio 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" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) input = lambda: sys.stdin.readline().rstrip("\r\n") from collections import defaultdict #from collections import deque #from collections import OrderedDict #from math import gcd #import time #import itertools #import timeit #import random #from bisect import bisect_left as bl #from bisect import bisect_right as br #from bisect import insort_left as il #from bisect import insort_right as ir #from heapq import * #mod=998244353 #mod=10**9+7 # for counting path pass prev as argument: # for counting level of each node w.r.t to s pass lvl instead of prev: n=ii() X=[0 for i in range(n)] Y=[0 for i in range(n)] for i in range(n): x,y=mi() X[i]=x Y[i]=y ans_x,ans_y=0,0 tot_x=sum(X) tot_y=sum(Y) for i in range(n): ans_x+=(n-1)*((X[i])**2) ans_x-=X[i]*(tot_x-X[i]) ans_y+=(n-1)*(Y[i]**2) ans_y-=Y[i]*(tot_y-Y[i]) print(ans_x+ans_y) ```
output
1
39,212
23
78,425
Provide tags and a correct Python 3 solution for this coding contest problem. You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points. Input The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide. Output The only line of output should contain the required sum of squares of distances between all pairs of points. Examples Input 4 1 1 -1 -1 1 -1 -1 1 Output 32
instruction
0
39,213
23
78,426
Tags: implementation, math Correct Solution: ``` ab = int(input()) lst1=[] lst = [] lst2 =[] lst3 = [] for i in range(ab): m,n = map(int,input().split()) lst.append(m) lst1.append(n) for i in lst: lst2.append(i**2) for x in lst1: lst3.append(x**2) print(ab*sum(lst2)+sum(lst)*(-(sum(lst)))+ab*sum(lst3)+sum(lst1)*(-(sum(lst1)))) ```
output
1
39,213
23
78,427
Provide tags and a correct Python 3 solution for this coding contest problem. You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points. Input The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide. Output The only line of output should contain the required sum of squares of distances between all pairs of points. Examples Input 4 1 1 -1 -1 1 -1 -1 1 Output 32
instruction
0
39,214
23
78,428
Tags: implementation, math Correct Solution: ``` n = int(input()) total_sum = 0 distance_x, distance_y = 0, 0 for _ in range(n): x, y = map(int, input().split()) total_sum += x ** 2 + y ** 2 distance_x += x distance_y += y distance_x *= distance_x distance_y *= distance_y print( n * total_sum - ( distance_x + distance_y)) ```
output
1
39,214
23
78,429
Provide tags and a correct Python 3 solution for this coding contest problem. You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points. Input The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide. Output The only line of output should contain the required sum of squares of distances between all pairs of points. Examples Input 4 1 1 -1 -1 1 -1 -1 1 Output 32
instruction
0
39,215
23
78,430
Tags: implementation, math Correct Solution: ``` n=int(input()) ans= 0 xp=[] yp=[] for i in range(n): x,y=map(int,input().split()) ans+=(x**2)*(n-1) ans+=(y**2)*(n-1) xp.append(x) yp.append(y) sqrx=sum(i*i for i in xp) sqry=sum(i*i for i in yp) minusx=sum(xp)*sum(xp)-sqrx minusy=sum(yp)*sum(yp)-sqry ans=ans-minusx-minusy print(ans) ```
output
1
39,215
23
78,431
Provide tags and a correct Python 3 solution for this coding contest problem. You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points. Input The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide. Output The only line of output should contain the required sum of squares of distances between all pairs of points. Examples Input 4 1 1 -1 -1 1 -1 -1 1 Output 32
instruction
0
39,216
23
78,432
Tags: implementation, math Correct Solution: ``` import sys input = sys.stdin.readline n = int(input()) x = [] y = [] out = 0 for _ in range(n): a, b = map(int, input().split()) x.append(a) y.append(b) for l in (x,y): sos = 0 tot = 0 count = 0 for v in l: out += count * v * v + sos - 2 * v * tot sos += v * v tot += v count += 1 print(out) ```
output
1
39,216
23
78,433
Provide tags and a correct Python 3 solution for this coding contest problem. You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points. Input The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide. Output The only line of output should contain the required sum of squares of distances between all pairs of points. Examples Input 4 1 1 -1 -1 1 -1 -1 1 Output 32
instruction
0
39,217
23
78,434
Tags: implementation, math Correct Solution: ``` import math t = int(input()) x_sum = 0 y_sum = 0 x2_sum = 0 y2_sum = 0 for i in range(t): x,y = map(int, input().split()) x_sum += x y_sum += y x2_sum += x**2 y2_sum += y**2 x_sum *= x_sum y_sum *= y_sum ans = (t)*x2_sum + (t)*y2_sum - x_sum - y_sum print(ans) ```
output
1
39,217
23
78,435
Provide tags and a correct Python 3 solution for this coding contest problem. You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points. Input The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide. Output The only line of output should contain the required sum of squares of distances between all pairs of points. Examples Input 4 1 1 -1 -1 1 -1 -1 1 Output 32
instruction
0
39,218
23
78,436
Tags: implementation, math Correct Solution: ``` import math if __name__== '__main__': n = int(input()) n_1= n- 1 totalDistance= 0 Xs= [] Ys= [] xs= [] ys= [] xAddition= 0 yAddition= 0 for _ in range(n): x, y= [int(x) for x in input().split()] Xs.append(n_1* x* x) Ys.append(n_1* y* y) xs.append(x) ys.append(y) xAddition+= x yAddition+= y for index in range(n): xAddition-= xs[index] subtract= 2* xs[index]* xAddition totalDistance+= Xs[index]- subtract yAddition-= ys[index] subtract= 2* ys[index]* yAddition totalDistance+= Ys[index]- subtract print(totalDistance) ```
output
1
39,218
23
78,437
Provide tags and a correct Python 3 solution for this coding contest problem. You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points. Input The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide. Output The only line of output should contain the required sum of squares of distances between all pairs of points. Examples Input 4 1 1 -1 -1 1 -1 -1 1 Output 32
instruction
0
39,219
23
78,438
Tags: implementation, math Correct Solution: ``` import math def solve(): n, = map(int, input().split()) a = [(0, 0) for _ in range(n)] sum_x = 0 sum_y = 0 for i in range(n): x, y = map(int, input().split()) a[i] = x, y sum_x += a[i][0] sum_y += a[i][1] ans = 0 for i in range(n): ans += 2 * (n - 1) * (a[i][0] ** 2 + a[i][1] ** 2) ans -= 2 * (a[i][0] * (sum_x - a[i][0]) + a[i][1] * (sum_y - a[i][1])) print(ans // 2) if __name__ == "__main__": t = 1 # t = int(input()) for _ in range(t): solve() ```
output
1
39,219
23
78,439
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points. Input The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide. Output The only line of output should contain the required sum of squares of distances between all pairs of points. Examples Input 4 1 1 -1 -1 1 -1 -1 1 Output 32 Submitted Solution: ``` #Code by Sounak, IIESTS #------------------------------warmup---------------------------- import os import sys import math from io import BytesIO, IOBase from fractions import Fraction import collections from itertools import permutations from collections import defaultdict from collections import deque import threading threading.stack_size(10**8) sys.setrecursionlimit(300000) 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" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) input = lambda: sys.stdin.readline().rstrip("\r\n") #-------------------game starts now----------------------------------------------------- class Factorial: def __init__(self, MOD): self.MOD = MOD self.factorials = [1, 1] self.invModulos = [0, 1] self.invFactorial_ = [1, 1] def calc(self, n): if n <= -1: print("Invalid argument to calculate n!") print("n must be non-negative value. But the argument was " + str(n)) exit() if n < len(self.factorials): return self.factorials[n] nextArr = [0] * (n + 1 - len(self.factorials)) initialI = len(self.factorials) prev = self.factorials[-1] m = self.MOD for i in range(initialI, n + 1): prev = nextArr[i - initialI] = prev * i % m self.factorials += nextArr return self.factorials[n] def inv(self, n): if n <= -1: print("Invalid argument to calculate n^(-1)") print("n must be non-negative value. But the argument was " + str(n)) exit() p = self.MOD pi = n % p if pi < len(self.invModulos): return self.invModulos[pi] nextArr = [0] * (n + 1 - len(self.invModulos)) initialI = len(self.invModulos) for i in range(initialI, min(p, n + 1)): next = -self.invModulos[p % i] * (p // i) % p self.invModulos.append(next) return self.invModulos[pi] def invFactorial(self, n): if n <= -1: print("Invalid argument to calculate (n^(-1))!") print("n must be non-negative value. But the argument was " + str(n)) exit() if n < len(self.invFactorial_): return self.invFactorial_[n] self.inv(n) # To make sure already calculated n^-1 nextArr = [0] * (n + 1 - len(self.invFactorial_)) initialI = len(self.invFactorial_) prev = self.invFactorial_[-1] p = self.MOD for i in range(initialI, n + 1): prev = nextArr[i - initialI] = (prev * self.invModulos[i % p]) % p self.invFactorial_ += nextArr return self.invFactorial_[n] class Combination: def __init__(self, MOD): self.MOD = MOD self.factorial = Factorial(MOD) def ncr(self, n, k): if k < 0 or n < k: return 0 k = min(k, n - k) f = self.factorial return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD #------------------------------------------------------------------------- mod=10**9+7 n=int(input()) a=list() x,y=0,0 r=0 for i in range (n): x1,y1=map(int,input().split()) a.append((x1,y1)) x+=x1 y+=y1 r+=(n-1)*(x1*x1+y1*y1) #print(r,x,y) for i in range (n): p,q=a[i] r-=(p*(x-p)+q*(y-q)) print(r) ```
instruction
0
39,220
23
78,440
Yes
output
1
39,220
23
78,441
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points. Input The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide. Output The only line of output should contain the required sum of squares of distances between all pairs of points. Examples Input 4 1 1 -1 -1 1 -1 -1 1 Output 32 Submitted Solution: ``` n=int(input()) x_sum,y_sum,x_squared,y_squared=0,0,0,0 for i in range(n): x,y=input().split() x,y=int(x),int(y) x_sum+=x y_sum+=y x_squared+=x*x y_squared+=y*y x_sum*=x_sum y_sum*=y_sum print(n*x_squared+n*y_squared-x_sum-y_sum) ```
instruction
0
39,221
23
78,442
Yes
output
1
39,221
23
78,443
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points. Input The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide. Output The only line of output should contain the required sum of squares of distances between all pairs of points. Examples Input 4 1 1 -1 -1 1 -1 -1 1 Output 32 Submitted Solution: ``` n=int(input()) ar=[list(map(int,input().split())) for i in range(n)] ans=0 c1=0 s1=0 for i in range(n): e=ar[i][0] ans+=i*e*e+c1-2*s1*e c1+=e*e s1+=e c1,s1=0,0 for i in range(n): e=ar[i][1] ans+=i*e*e+c1-2*s1*e c1+=e*e s1+=e print(ans) ```
instruction
0
39,222
23
78,444
Yes
output
1
39,222
23
78,445
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points. Input The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide. Output The only line of output should contain the required sum of squares of distances between all pairs of points. Examples Input 4 1 1 -1 -1 1 -1 -1 1 Output 32 Submitted Solution: ``` import math if __name__== '__main__': n = int(input()) totalDistance= 0 Xs= [] Ys= [] xs= [] ys= [] x_ve= 0 y_ve= 0 for _ in range(n): x, y= [int(x) for x in input().split()] Xs.append((n- 1)* x) Ys.append((n- 1)* y) xs.append(x) ys.append(y) x_ve+= (-1* x) y_ve+= (-1* y) #print('Xs: '+str(Xs)) #print('Ys: '+str(Ys)) #print('xs: '+str(xs)) #print('ys: '+str(ys)) #print('x_ve: '+str(x_ve)) #print('y_ve: '+str(y_ve)) #print('#'*10) for index in range(n): #print('xs: '+str(xs[index])) #print('Xs: '+str(Xs[index])) if(index== 0): subtract= 2* xs[index] else: subtract= (2* xs[index]- xs[index- 1]) #print('subtract: '+str(subtract)) x_ve+= subtract #print('x_ve: '+str(x_ve)) totalDistance+= Xs[index]* x_ve #print('Xs[index]* x_ve: '+str(Xs[index]* x_ve)) #print() #print('ys: '+str(ys[index])) #print('Ys: '+str(Ys[index])) if(index== 0): subtract= 2* ys[index] else: subtract= (2* ys[index]- ys[index- 1]) #print('subtract: '+str(subtract)) y_ve+= subtract #print('y_ve: '+str(y_ve)) totalDistance+= Ys[index]* y_ve #print('Ys[index]* y_ve: '+str(Ys[index]* y_ve)) #print() #print() print(totalDistance) ```
instruction
0
39,223
23
78,446
No
output
1
39,223
23
78,447