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. While playing with geometric figures Alex has accidentally invented a concept of a n-th order rhombus in a cell grid. A 1-st order rhombus is just a square 1 × 1 (i.e just a cell). A n-th order rhombus for all n ≥ 2 one obtains from a n-1-th order rhombus adding all cells which have a common side with it to it (look at the picture to understand it better). <image> Alex asks you to compute the number of cells in a n-th order rhombus. Input The first and only input line contains integer n (1 ≤ n ≤ 100) — order of a rhombus whose numbers of cells should be computed. Output Print exactly one integer — the number of cells in a n-th order rhombus. Examples Input 1 Output 1 Input 2 Output 5 Input 3 Output 13 Note Images of rhombus corresponding to the examples are given in the statement. Submitted Solution: ``` dp = dict() dp[1] = 1 def testCase(): # pass n = int(input()) for i in range(2, n+1): dp[i] = dp[i-1] + (i-1)*4 print("{}".format(dp[n])) # main #test = int(input()) test = 1 while test: testCase() test -= 1 ```
instruction
0
98,686
23
197,372
Yes
output
1
98,686
23
197,373
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. While playing with geometric figures Alex has accidentally invented a concept of a n-th order rhombus in a cell grid. A 1-st order rhombus is just a square 1 × 1 (i.e just a cell). A n-th order rhombus for all n ≥ 2 one obtains from a n-1-th order rhombus adding all cells which have a common side with it to it (look at the picture to understand it better). <image> Alex asks you to compute the number of cells in a n-th order rhombus. Input The first and only input line contains integer n (1 ≤ n ≤ 100) — order of a rhombus whose numbers of cells should be computed. Output Print exactly one integer — the number of cells in a n-th order rhombus. Examples Input 1 Output 1 Input 2 Output 5 Input 3 Output 13 Note Images of rhombus corresponding to the examples are given in the statement. Submitted Solution: ``` n = int(input()) if n % 2 == 0: print(((n-1)**2) + 4*(((n*(n+1))//2) - ((n)*(n+2))//4)) else: print((n**2) + 4*((((n-2)*(n-1))//2) - (((n-2)//2)*(((n-2)//2)+1)))) ```
instruction
0
98,687
23
197,374
Yes
output
1
98,687
23
197,375
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. While playing with geometric figures Alex has accidentally invented a concept of a n-th order rhombus in a cell grid. A 1-st order rhombus is just a square 1 × 1 (i.e just a cell). A n-th order rhombus for all n ≥ 2 one obtains from a n-1-th order rhombus adding all cells which have a common side with it to it (look at the picture to understand it better). <image> Alex asks you to compute the number of cells in a n-th order rhombus. Input The first and only input line contains integer n (1 ≤ n ≤ 100) — order of a rhombus whose numbers of cells should be computed. Output Print exactly one integer — the number of cells in a n-th order rhombus. Examples Input 1 Output 1 Input 2 Output 5 Input 3 Output 13 Note Images of rhombus corresponding to the examples are given in the statement. Submitted Solution: ``` n=int(input()) from math import ceil x=((n*2 - 1)**2)/2 print(ceil(x)) ```
instruction
0
98,688
23
197,376
Yes
output
1
98,688
23
197,377
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. While playing with geometric figures Alex has accidentally invented a concept of a n-th order rhombus in a cell grid. A 1-st order rhombus is just a square 1 × 1 (i.e just a cell). A n-th order rhombus for all n ≥ 2 one obtains from a n-1-th order rhombus adding all cells which have a common side with it to it (look at the picture to understand it better). <image> Alex asks you to compute the number of cells in a n-th order rhombus. Input The first and only input line contains integer n (1 ≤ n ≤ 100) — order of a rhombus whose numbers of cells should be computed. Output Print exactly one integer — the number of cells in a n-th order rhombus. Examples Input 1 Output 1 Input 2 Output 5 Input 3 Output 13 Note Images of rhombus corresponding to the examples are given in the statement. Submitted Solution: ``` n = int(input()) if n == 1: print(1) if n == 2: print(5) else: print((2*n-3)**2+4) ```
instruction
0
98,689
23
197,378
No
output
1
98,689
23
197,379
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. While playing with geometric figures Alex has accidentally invented a concept of a n-th order rhombus in a cell grid. A 1-st order rhombus is just a square 1 × 1 (i.e just a cell). A n-th order rhombus for all n ≥ 2 one obtains from a n-1-th order rhombus adding all cells which have a common side with it to it (look at the picture to understand it better). <image> Alex asks you to compute the number of cells in a n-th order rhombus. Input The first and only input line contains integer n (1 ≤ n ≤ 100) — order of a rhombus whose numbers of cells should be computed. Output Print exactly one integer — the number of cells in a n-th order rhombus. Examples Input 1 Output 1 Input 2 Output 5 Input 3 Output 13 Note Images of rhombus corresponding to the examples are given in the statement. Submitted Solution: ``` num = int(input()) s = 1 for i in range(1,num): s+=2**(i+1) print(s) ```
instruction
0
98,690
23
197,380
No
output
1
98,690
23
197,381
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. While playing with geometric figures Alex has accidentally invented a concept of a n-th order rhombus in a cell grid. A 1-st order rhombus is just a square 1 × 1 (i.e just a cell). A n-th order rhombus for all n ≥ 2 one obtains from a n-1-th order rhombus adding all cells which have a common side with it to it (look at the picture to understand it better). <image> Alex asks you to compute the number of cells in a n-th order rhombus. Input The first and only input line contains integer n (1 ≤ n ≤ 100) — order of a rhombus whose numbers of cells should be computed. Output Print exactly one integer — the number of cells in a n-th order rhombus. Examples Input 1 Output 1 Input 2 Output 5 Input 3 Output 13 Note Images of rhombus corresponding to the examples are given in the statement. Submitted Solution: ``` k = int(input()) if k == 1: print(1) else: print(4*(2**(k-1)-1)+1) ```
instruction
0
98,691
23
197,382
No
output
1
98,691
23
197,383
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. While playing with geometric figures Alex has accidentally invented a concept of a n-th order rhombus in a cell grid. A 1-st order rhombus is just a square 1 × 1 (i.e just a cell). A n-th order rhombus for all n ≥ 2 one obtains from a n-1-th order rhombus adding all cells which have a common side with it to it (look at the picture to understand it better). <image> Alex asks you to compute the number of cells in a n-th order rhombus. Input The first and only input line contains integer n (1 ≤ n ≤ 100) — order of a rhombus whose numbers of cells should be computed. Output Print exactly one integer — the number of cells in a n-th order rhombus. Examples Input 1 Output 1 Input 2 Output 5 Input 3 Output 13 Note Images of rhombus corresponding to the examples are given in the statement. Submitted Solution: ``` n = int(input()) print((n+1)**2+4) ```
instruction
0
98,692
23
197,384
No
output
1
98,692
23
197,385
Provide tags and a correct Python 3 solution for this coding contest problem. Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a program for rectangles detection. According to his plan, the program detects if the four given segments form a rectangle of a positive area and with sides parallel to coordinate axes. As Alex does badly at school and can't write this program by himself, he asks you to help him. Input The input data contain four lines. Each of these lines contains four integers x1, y1, x2, y2 ( - 109 ≤ x1, y1, x2, y2 ≤ 109) — coordinates of segment's beginning and end positions. The given segments can degenerate into points. Output Output the word «YES», if the given four segments form the required rectangle, otherwise output «NO». Examples Input 1 1 6 1 1 0 6 0 6 0 6 1 1 1 1 0 Output YES Input 0 0 0 3 2 0 0 0 2 2 2 0 0 2 2 2 Output NO
instruction
0
98,848
23
197,696
Tags: brute force, constructive algorithms, geometry, implementation, math Correct Solution: ``` from collections import Counter puntos = Counter() segmentos = Counter() for _ in range(4): px, py, qx, qy = list(map(int, input().split())) p = (px, py) q = (qx, qy) puntos[p] += 1 puntos[q] += 1 if (q, p) not in segmentos.keys(): segmentos[(p, q)] += 1 else: segmentos[(q, p)] += 1 def f(puntos, segmentos): if len(puntos) == 4 and len(segmentos) == 4: v, h = 0, 0 for L in segmentos: p, q = L[0], L[1] if p == q: return('NO') # si un segmento es un punto retorna no else: px, py = p[0], p[1] qx, qy = q[0], q[1] if qx - px == 0: v += 1 elif qy - py == 0: h += 1 else: return('NO') # si no es h ni v retorna no if v == 2 and h == 2: return('YES') # si hay 2 h y 2 v retorna si else: return('NO') # si no hay 2 h y no hay 2 v retorna no else: return('NO') print(f(puntos, segmentos)) ```
output
1
98,848
23
197,697
Provide tags and a correct Python 3 solution for this coding contest problem. Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a program for rectangles detection. According to his plan, the program detects if the four given segments form a rectangle of a positive area and with sides parallel to coordinate axes. As Alex does badly at school and can't write this program by himself, he asks you to help him. Input The input data contain four lines. Each of these lines contains four integers x1, y1, x2, y2 ( - 109 ≤ x1, y1, x2, y2 ≤ 109) — coordinates of segment's beginning and end positions. The given segments can degenerate into points. Output Output the word «YES», if the given four segments form the required rectangle, otherwise output «NO». Examples Input 1 1 6 1 1 0 6 0 6 0 6 1 1 1 1 0 Output YES Input 0 0 0 3 2 0 0 0 2 2 2 0 0 2 2 2 Output NO
instruction
0
98,849
23
197,698
Tags: brute force, constructive algorithms, geometry, implementation, math Correct Solution: ``` def main(): line_1 = input().strip().split() line_1 = list(map(int, line_1)) line_2 = input().strip().split() line_2 = list(map(int, line_2)) line_3 = input().strip().split() line_3 = list(map(int, line_3)) line_4 = input().strip().split() line_4 = list(map(int, line_4)) x_line_count = 0 y_line_count = 0 points = set() if line_1 == line_2 or line_1 == line_3 or line_1 == line_4 or line_2 == line_3 or line_2 == line_4 or line_3 == line_4: return 'NO' for line in (line_1, line_2, line_3, line_4): if line[0] == line[2] and line[1] != line[3]: x_line_count += 1 elif line[1] == line[3] and line[0] != line[2]: y_line_count += 1 points.add((line[0], line[1])) points.add((line[2], line[3])) if x_line_count != 2 or y_line_count != 2: return 'NO' if len(points) != 4: return 'NO' return 'YES' print(main()) ```
output
1
98,849
23
197,699
Provide tags and a correct Python 3 solution for this coding contest problem. Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a program for rectangles detection. According to his plan, the program detects if the four given segments form a rectangle of a positive area and with sides parallel to coordinate axes. As Alex does badly at school and can't write this program by himself, he asks you to help him. Input The input data contain four lines. Each of these lines contains four integers x1, y1, x2, y2 ( - 109 ≤ x1, y1, x2, y2 ≤ 109) — coordinates of segment's beginning and end positions. The given segments can degenerate into points. Output Output the word «YES», if the given four segments form the required rectangle, otherwise output «NO». Examples Input 1 1 6 1 1 0 6 0 6 0 6 1 1 1 1 0 Output YES Input 0 0 0 3 2 0 0 0 2 2 2 0 0 2 2 2 Output NO
instruction
0
98,850
23
197,700
Tags: brute force, constructive algorithms, geometry, implementation, math Correct Solution: ``` def main(): line_1 = input().strip().split() line_1 = list(map(int, line_1)) line_2 = input().strip().split() line_2 = list(map(int, line_2)) line_3 = input().strip().split() line_3 = list(map(int, line_3)) line_4 = input().strip().split() line_4 = list(map(int, line_4)) x_line_count = 0 y_line_count = 0 points = {} if line_1 == line_2 or line_1 == line_3 or line_1 == line_4 or line_2 == line_3 or line_2 == line_4 or line_3 == line_4: return 'NO' for line in (line_1, line_2, line_3, line_4): if line[0] == line[2] and line[1] != line[3]: x_line_count += 1 elif line[1] == line[3] and line[0] != line[2]: y_line_count += 1 if (line[0], line[1]) in points: points[(line[0], line[1])] += 1 else: points[(line[0], line[1])] = 1 if (line[2], line[3]) in points: points[(line[2], line[3])] += 1 else: points[(line[2], line[3])] = 1 if x_line_count != 2 or y_line_count != 2: return 'NO' if len(points) != 4: return 'NO' return 'YES' print(main()) ```
output
1
98,850
23
197,701
Provide tags and a correct Python 3 solution for this coding contest problem. Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a program for rectangles detection. According to his plan, the program detects if the four given segments form a rectangle of a positive area and with sides parallel to coordinate axes. As Alex does badly at school and can't write this program by himself, he asks you to help him. Input The input data contain four lines. Each of these lines contains four integers x1, y1, x2, y2 ( - 109 ≤ x1, y1, x2, y2 ≤ 109) — coordinates of segment's beginning and end positions. The given segments can degenerate into points. Output Output the word «YES», if the given four segments form the required rectangle, otherwise output «NO». Examples Input 1 1 6 1 1 0 6 0 6 0 6 1 1 1 1 0 Output YES Input 0 0 0 3 2 0 0 0 2 2 2 0 0 2 2 2 Output NO
instruction
0
98,851
23
197,702
Tags: brute force, constructive algorithms, geometry, implementation, math Correct Solution: ``` # Try to do in 30 minutes # 4 segments are given def read_points(): hSegs = [] vSegs = [] for i in range(4): rawline = input().split() line = {"p1":[int(rawline[0]),int(rawline[1])],"p2":[int(rawline[2]),int(rawline[3])]} if line["p1"][0] == line["p2"][0]: # X values the same, Vertical line if line["p1"][1] > line["p2"][1]: # Swap order so p1 is smaller line["p2"][1], line["p1"][1] = line["p1"][1], line["p2"][1] vSegs.append(line) elif line["p1"][1] == line["p2"][1]: # Y values the same, horizontal line if line["p1"][0] > line["p2"][0]: # Swap order so p1 is smaller line["p2"][0], line["p1"][0] = line["p1"][0], line["p2"][0] hSegs.append(line) else: return False if line["p1"][1] == line["p2"][1] and line["p1"][0] == line["p2"][0]: # line segments length = 0 return False if len(hSegs) != 2 or len(vSegs) != 2: return False hSegs.sort(key=lambda a : a["p1"][1]) vSegs.sort(key=lambda a : a["p1"][0]) if hSegs[0]['p1'][1] == hSegs[1]['p1'][1] or vSegs[0]['p1'][0] == vSegs[1]['p1'][0]: # no area return False for h in hSegs: if h['p1'][0] != vSegs[0]['p1'][0]: #line does not touch 1st vert return False if h['p2'][0] != vSegs[1]['p1'][0]: #line does not touch 2nd vert return False for v in vSegs: if v['p1'][1] != hSegs[0]['p1'][1]: #line does not touch 1st horizontal return False if v['p2'][1] != hSegs[1]['p1'][1]: #line does not touch 2nd horizontal return False return True print("YES" if read_points() else "NO") ```
output
1
98,851
23
197,703
Provide tags and a correct Python 3 solution for this coding contest problem. Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a program for rectangles detection. According to his plan, the program detects if the four given segments form a rectangle of a positive area and with sides parallel to coordinate axes. As Alex does badly at school and can't write this program by himself, he asks you to help him. Input The input data contain four lines. Each of these lines contains four integers x1, y1, x2, y2 ( - 109 ≤ x1, y1, x2, y2 ≤ 109) — coordinates of segment's beginning and end positions. The given segments can degenerate into points. Output Output the word «YES», if the given four segments form the required rectangle, otherwise output «NO». Examples Input 1 1 6 1 1 0 6 0 6 0 6 1 1 1 1 0 Output YES Input 0 0 0 3 2 0 0 0 2 2 2 0 0 2 2 2 Output NO
instruction
0
98,852
23
197,704
Tags: brute force, constructive algorithms, geometry, implementation, math Correct Solution: ``` def is_rect(es): v = set([]) for e in es: if not ((e[0] == e[2]) or (e[1] == e[3])): return False v.add((e[0], e[1])) v.add((e[2], e[3])) if len(v) != 4: return False xs = set([]) ys = set([]) for vi in v: xs.add(vi[0]) ys.add(vi[1]) if len(xs) != 2 or len(ys) != 2: return False t = b = r = l = False for e in es: t = t or (e[1] == e[3] and e[0] != e[2] and e[1] == max(ys)) b = b or (e[1] == e[3] and e[0] != e[2] and e[1] == min(ys)) r = r or (e[0] == e[2] and e[1] != e[3] and e[0] == max(xs)) l = l or (e[0] == e[2] and e[1] != e[3] and e[0] == min(xs)) return t and b and l and r e1 = list(map(int, input().split(' '))) e2 = list(map(int, input().split(' '))) e3 = list(map(int, input().split(' '))) e4 = list(map(int, input().split(' '))) if is_rect((e1, e2, e3, e4)): print("YES") else: print("NO") ```
output
1
98,852
23
197,705
Provide tags and a correct Python 3 solution for this coding contest problem. Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a program for rectangles detection. According to his plan, the program detects if the four given segments form a rectangle of a positive area and with sides parallel to coordinate axes. As Alex does badly at school and can't write this program by himself, he asks you to help him. Input The input data contain four lines. Each of these lines contains four integers x1, y1, x2, y2 ( - 109 ≤ x1, y1, x2, y2 ≤ 109) — coordinates of segment's beginning and end positions. The given segments can degenerate into points. Output Output the word «YES», if the given four segments form the required rectangle, otherwise output «NO». Examples Input 1 1 6 1 1 0 6 0 6 0 6 1 1 1 1 0 Output YES Input 0 0 0 3 2 0 0 0 2 2 2 0 0 2 2 2 Output NO
instruction
0
98,853
23
197,706
Tags: brute force, constructive algorithms, geometry, implementation, math Correct Solution: ``` def is_rect(): def seg(): [x0, y0, x1, y1] = input().split(' ') return int(x0), int(y0), int(x1), int(y1) def parallel(x0, x1, y0, y1, x2, x3, y2, y3): return y0 == y1 and y2 == y3 and y0 != y2 and ((x2 == x0 and x3 == x1) or (x3 == x0 and x2 == x1)) def shared(sx0, sy0, x1, y1, x2, y2): return sx0, y1, x2, y1, x2, sy0, x2, y1 x0, y0, x1, y1 = seg() x2, y2, x3, y3 = seg() x4, y4, x5, y5 = seg() x6, y6, x7, y7 = seg() def find_corner(x0, y0, x1, y1, x2, y2, x3, y3): if x0 == x2 and y0 == y2: return x0, y0 elif x0 == x3 and y0 == y3: return x0, y0 elif x1 == x2 and y1 == y2: return x1, y1 elif x1 == x3 and y1 == y3: return x1, y1 else: return None, None def flip_seg(cx, cy, x0, y0, x1, y1): if cx == x0 and cy == y0: return x0, y0, x1, y1 elif cx == x1 and cy == y1: return x1, y1, x0, y0 cx0, cy0 = find_corner(x0, y0, x1, y1, x2, y2, x3, y3) if cx0 == None: # Segments are parallel cx0, cy0 = find_corner(x0, y0, x1, y1, x4, y4, x5, y5) if cx0 == None: cx0, cy0 = find_corner(x0, y0, x1, y1, x6, y6, x7, y7) if cx0 == None: return False else: x2, y2, x3, y3, x6, y6, x7, y7 = x6, y6, x7, y7, x2, y2, x3, y3 else: x2, y2, x3, y3, x4, y4, x5, y5 = x4, y4, x5, y5, x2, y2, x3, y3 cx1, cy1 = find_corner(x4, y4, x5, y5, x6, y6, x7, y7) if cx1 == None: return False if cx0 == cx1 or cy0 == cy1: return False x0, y0, x1, y1 = flip_seg(cx0, cy0, x0, y0, x1, y1) x2, y2, x3, y3 = flip_seg(cx0, cy0, x2, y2, x3, y3) x4, y4, x5, y5 = flip_seg(cx1, cy1, x4, y4, x5, y5) x6, y6, x7, y7 = flip_seg(cx1, cy1, x6, y6, x7, y7) if x1 == x0: pass elif y1 == y0: x0, y0, x1, y1, x2, y2, x3, y3 = x2, y2, x3, y3, x0, y0, x1, y1 else: return False if x0 != x1 or y2 != y3: return False if x5 == x4: pass elif y5 == y4: x4, y4, x5, y5, x6, y6, x7, y7 = x6, y6, x7, y7, x4, y4, x5, y5 else: return False if x4 != x5 or y6 != y7: return False if y1 == cy1 and x3 == cx1 and y5 == cy0 and x7 == cx0: return True else: return False if is_rect(): print("YES") else: print("NO") ```
output
1
98,853
23
197,707
Provide tags and a correct Python 3 solution for this coding contest problem. Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a program for rectangles detection. According to his plan, the program detects if the four given segments form a rectangle of a positive area and with sides parallel to coordinate axes. As Alex does badly at school and can't write this program by himself, he asks you to help him. Input The input data contain four lines. Each of these lines contains four integers x1, y1, x2, y2 ( - 109 ≤ x1, y1, x2, y2 ≤ 109) — coordinates of segment's beginning and end positions. The given segments can degenerate into points. Output Output the word «YES», if the given four segments form the required rectangle, otherwise output «NO». Examples Input 1 1 6 1 1 0 6 0 6 0 6 1 1 1 1 0 Output YES Input 0 0 0 3 2 0 0 0 2 2 2 0 0 2 2 2 Output NO
instruction
0
98,854
23
197,708
Tags: brute force, constructive algorithms, geometry, implementation, math Correct Solution: ``` accepted = True lines = [] dic = {} for i in range(4): line = list(map(int,input().split(" "))) if line[0] == line[2] and line[1] == line[3]: accepted = False lines.append(((line[0], line[1]),(line[2],line[3]))) if not (line[0] == line[2] or line[1] == line[3]): accepted = False if lines[-1][0] not in dic.keys(): dic[lines[-1][0]] = [(i, 0)] else: dic[lines[-1][0]].append((i,0)) if lines[-1][1] not in dic.keys(): dic[lines[-1][1]] = [(i, 1)] else: dic[lines[-1][1]].append((i,1)) zero, one = set(), set() for key in dic.keys(): if len(set(dic[key])) != 2: accepted = False zero.add(key[0]) one.add(key[1]) j = 0 for entry1 in lines[j:]: for entry2 in lines[j+1:]: if entry1[0] == entry2[1] and entry1[1] == entry2[0]: accepted = False if entry1 == entry2: accepted = False j+=1 if len(zero) == 1 or len(one) == 1: accepted = False print("YES") if accepted else print("NO") #http://codeforces.com/problemset/problem/14/C ```
output
1
98,854
23
197,709
Provide tags and a correct Python 3 solution for this coding contest problem. Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a program for rectangles detection. According to his plan, the program detects if the four given segments form a rectangle of a positive area and with sides parallel to coordinate axes. As Alex does badly at school and can't write this program by himself, he asks you to help him. Input The input data contain four lines. Each of these lines contains four integers x1, y1, x2, y2 ( - 109 ≤ x1, y1, x2, y2 ≤ 109) — coordinates of segment's beginning and end positions. The given segments can degenerate into points. Output Output the word «YES», if the given four segments form the required rectangle, otherwise output «NO». Examples Input 1 1 6 1 1 0 6 0 6 0 6 1 1 1 1 0 Output YES Input 0 0 0 3 2 0 0 0 2 2 2 0 0 2 2 2 Output NO
instruction
0
98,855
23
197,710
Tags: brute force, constructive algorithms, geometry, implementation, math Correct Solution: ``` liste=[] i=0 i2=0 distance=[] answer='YES' for _ in range(4): x1,y1,x2,y2=map(int,input().split(" ")) liste.append([(x1,y1),(x2,y2)]) def perpendiculaire(vect1,vect2): return vect1[0]*vect2[0]+vect1[1]*vect2[1] def search(liste,point,excluded_index): for i in range(4): if point in liste[i] and i!=excluded_index: return i,liste[i].index(point) return -1,-1 index,i=0,0 for _ in range(4): element=liste[index] (x1,y1),(x2,y2)=element[i],element[1-i] vector1=(x2-x1,y2-y1) distance.append(abs(x2-x1)+abs(y2-y1)) index,i=search(liste,(x2,y2),index) if index==-1: answer='NO' break element=liste[index] (x1,y1),(x2,y2)=element[i],element[1-i] vector2=(x2-x1,y2-y1) if perpendiculaire(vector1,vector2)!=0 or 0 not in vector1 or 0 not in vector2 or vector1==(0,0) or vector2==(0,0): answer='NO' break if answer=='YES': if distance[0]!=distance[2] or distance[1]!=distance[3]: answer='NO' print(answer) ```
output
1
98,855
23
197,711
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a program for rectangles detection. According to his plan, the program detects if the four given segments form a rectangle of a positive area and with sides parallel to coordinate axes. As Alex does badly at school and can't write this program by himself, he asks you to help him. Input The input data contain four lines. Each of these lines contains four integers x1, y1, x2, y2 ( - 109 ≤ x1, y1, x2, y2 ≤ 109) — coordinates of segment's beginning and end positions. The given segments can degenerate into points. Output Output the word «YES», if the given four segments form the required rectangle, otherwise output «NO». Examples Input 1 1 6 1 1 0 6 0 6 0 6 1 1 1 1 0 Output YES Input 0 0 0 3 2 0 0 0 2 2 2 0 0 2 2 2 Output NO Submitted Solution: ``` a={} ox,oy=0,0 for i in range(4): x1,y1,x2,y2=map(int,input().split()) a[(x1,y1)]=a.get((x1,y1),0)+1 a[(x2,y2)]=a.get((x2,y2),0)+1 if x1==x2 and y1!=y2: ox+=1 if y1==y2 and x1!=x2: oy+=1 ans="YES" for p in a.values(): if p!=2: ans="NO" break if ox!=2 or oy!=2: ans="NO" print(ans) ```
instruction
0
98,856
23
197,712
Yes
output
1
98,856
23
197,713
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a program for rectangles detection. According to his plan, the program detects if the four given segments form a rectangle of a positive area and with sides parallel to coordinate axes. As Alex does badly at school and can't write this program by himself, he asks you to help him. Input The input data contain four lines. Each of these lines contains four integers x1, y1, x2, y2 ( - 109 ≤ x1, y1, x2, y2 ≤ 109) — coordinates of segment's beginning and end positions. The given segments can degenerate into points. Output Output the word «YES», if the given four segments form the required rectangle, otherwise output «NO». Examples Input 1 1 6 1 1 0 6 0 6 0 6 1 1 1 1 0 Output YES Input 0 0 0 3 2 0 0 0 2 2 2 0 0 2 2 2 Output NO Submitted Solution: ``` Lines = 4*[None] for i in range(4): Lines[i] = list(map(int, input().split())) if Lines[i][0] == Lines[i][2] and Lines[i][1] == Lines[i][3]: print("NO") exit(0) if Lines[i][0] == Lines[i][2]: Lines[i][1], Lines[i][3] = min( Lines[i][1], Lines[i][3]), max(Lines[i][1], Lines[i][3]) elif Lines[i][1] == Lines[i][3]: Lines[i][0], Lines[i][2] = min( Lines[i][0], Lines[i][2]), max(Lines[i][0], Lines[i][2]) else: print("NO") exit(0) Lines.sort() if Lines[0] == Lines[1] or Lines[1] == Lines[2] or Lines[2] == Lines[3]: print("NO") exit(0) if Lines[0][:2] == Lines[1][:2] and Lines[0][2:] == Lines[2][:2] and Lines[1][2:] == Lines[3][:2] and Lines[2][2:] == Lines[3][2:]: print("YES") else: print("NO") ```
instruction
0
98,857
23
197,714
Yes
output
1
98,857
23
197,715
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a program for rectangles detection. According to his plan, the program detects if the four given segments form a rectangle of a positive area and with sides parallel to coordinate axes. As Alex does badly at school and can't write this program by himself, he asks you to help him. Input The input data contain four lines. Each of these lines contains four integers x1, y1, x2, y2 ( - 109 ≤ x1, y1, x2, y2 ≤ 109) — coordinates of segment's beginning and end positions. The given segments can degenerate into points. Output Output the word «YES», if the given four segments form the required rectangle, otherwise output «NO». Examples Input 1 1 6 1 1 0 6 0 6 0 6 1 1 1 1 0 Output YES Input 0 0 0 3 2 0 0 0 2 2 2 0 0 2 2 2 Output NO Submitted Solution: ``` puntos={0:0,1:0} for i in range(4): linea=list(map(int,input().split())) p1=(linea[0],linea[1]) p2=(linea[2],linea[3]) if p1[0]==p2[0] and p1[1]!=p2[1]: puntos[0]+=1 elif p1[0]!=p2[0] and p1[1]==p2[1]: puntos[1]+=1 for punto in [p1,p2]: puntos[punto]=puntos.get(punto,0)+1 if all( i==2 for i in puntos.values()): print("YES") else: print("NO") ```
instruction
0
98,858
23
197,716
Yes
output
1
98,858
23
197,717
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a program for rectangles detection. According to his plan, the program detects if the four given segments form a rectangle of a positive area and with sides parallel to coordinate axes. As Alex does badly at school and can't write this program by himself, he asks you to help him. Input The input data contain four lines. Each of these lines contains four integers x1, y1, x2, y2 ( - 109 ≤ x1, y1, x2, y2 ≤ 109) — coordinates of segment's beginning and end positions. The given segments can degenerate into points. Output Output the word «YES», if the given four segments form the required rectangle, otherwise output «NO». Examples Input 1 1 6 1 1 0 6 0 6 0 6 1 1 1 1 0 Output YES Input 0 0 0 3 2 0 0 0 2 2 2 0 0 2 2 2 Output NO Submitted Solution: ``` def segmentos_iguales(l1, l2): return (l1[:2] == l2[2:4] and l1[2:4] == l2[:2]) or (l1 == l2) def paralela(linea): return linea[0] == linea[2] or linea[1] == linea[3] def degenerada(linea): return linea[0] == linea[2] and linea[1] == linea[3] lineas = [] for _ in range(4): lineas.append(input().split()) x, y = set(), set() for i in range(4): x.add(lineas[i][0]) y.add(lineas[i][1]) x.add(lineas[i][2]) y.add(lineas[i][3]) if len(x) != 2 or len(y) != 2: print("NO") else: for i in range(4): if not paralela(lineas[i]) or degenerada(lineas[i]): print("NO") break else: flag = False for i in range(3): for j in range(i+1, 4): if segmentos_iguales(lineas[i], lineas[j]): print("NO") flag = True break if flag: break else: print("YES") ```
instruction
0
98,859
23
197,718
Yes
output
1
98,859
23
197,719
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a program for rectangles detection. According to his plan, the program detects if the four given segments form a rectangle of a positive area and with sides parallel to coordinate axes. As Alex does badly at school and can't write this program by himself, he asks you to help him. Input The input data contain four lines. Each of these lines contains four integers x1, y1, x2, y2 ( - 109 ≤ x1, y1, x2, y2 ≤ 109) — coordinates of segment's beginning and end positions. The given segments can degenerate into points. Output Output the word «YES», if the given four segments form the required rectangle, otherwise output «NO». Examples Input 1 1 6 1 1 0 6 0 6 0 6 1 1 1 1 0 Output YES Input 0 0 0 3 2 0 0 0 2 2 2 0 0 2 2 2 Output NO Submitted Solution: ``` def distance(a, b, c, d): return (d - b) ** 2 + (c - a) ** 2 def slope(a, b, c, d): if a == c: return float('inf') else: return (d - b) / (c - a) def CF14C(): infinity = 0 zero = 0 counter = {} # Sides counter points = set() for i in range(4): a, b, c, d = list(map(int, input().split())) points.add((a, b)) points.add((c, d)) s = slope(a, b, c, d) if s == float('inf'): infinity += 1 elif s == 0: zero += 1 side = distance(a, b, c, d) counter[side] = counter.get(side, 0) + 1 # There should be two sides parallel to x-axis and two sides parallel to y-axis if zero != 2 and infinity != 2: return False # print("Slopes ma problem vayena") # There should be only two values and both of them should have two elements if len(counter) != 2: return False counts = list(counter.values()) if counts[1] != counts[0]: return False # print("Sides pani duita equal cha") # Lets do the pythagoras test now. Final test. points = sorted(list(points), key = lambda x: (x[0], x[1])) a, b = points[0] c, d = points[1] e, f = points[2] sides = list(counter.keys()) d1 = distance(a, b, c, d) d2 = distance(b, c, d, e) d3 = distance(a, b, e, f) if sides[0] + sides[1] != max(d1, d2, d3): return False # For everything else. return True res = CF14C() print("YES" if res else "NO") print(res) ```
instruction
0
98,860
23
197,720
No
output
1
98,860
23
197,721
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a program for rectangles detection. According to his plan, the program detects if the four given segments form a rectangle of a positive area and with sides parallel to coordinate axes. As Alex does badly at school and can't write this program by himself, he asks you to help him. Input The input data contain four lines. Each of these lines contains four integers x1, y1, x2, y2 ( - 109 ≤ x1, y1, x2, y2 ≤ 109) — coordinates of segment's beginning and end positions. The given segments can degenerate into points. Output Output the word «YES», if the given four segments form the required rectangle, otherwise output «NO». Examples Input 1 1 6 1 1 0 6 0 6 0 6 1 1 1 1 0 Output YES Input 0 0 0 3 2 0 0 0 2 2 2 0 0 2 2 2 Output NO Submitted Solution: ``` from sys import stdin class my_vector: def __init__(self, x1, y1, x2, y2): self.i_coord = (x1, y1) self.end_coord = (x2, y2) self.my_vector = (y2 - y1, x2 - x1) def __mul__(self, other): return self.my_vector[0] * other.my_vector[0] + self.my_vector[1] * other.my_vector[1] def problem(lines): v_dict = {} number = 0 for row in lines: number += 1 x1, y1, x2, y2 = row.strip().split() v_dict[number] = my_vector(int(x1), int(y1), int(x2), int(y2)) # Check if the first my_vector has connected i and end: A = 1 B = [] C = [] D = [] possible_candidates = {2, 3, 4} for i in range(2, 5): if v_dict[A].i_coord == v_dict[i].i_coord: if v_dict[A].end_coord == v_dict[i].end_coord: return False possible_candidates.remove(i) B.append(i) elif v_dict[A].i_coord == v_dict[i].end_coord: if v_dict[A].end_coord == v_dict[i].i_coord: return False possible_candidates.remove(i) B.append(i) elif v_dict[A].end_coord == v_dict[i].end_coord: if v_dict[A].i_coord == v_dict[i].i_coord: return False possible_candidates.remove(i) C.append(i) elif v_dict[A].end_coord == v_dict[i].i_coord: if v_dict[A].i_coord == v_dict[i].end_coord: return False possible_candidates.remove(i) C.append(i) if len(B) == 1 and len(C) == 1: B = B.pop() C = C.pop() D = possible_candidates.pop() if v_dict[D].i_coord == v_dict[B].i_coord or v_dict[D].i_coord == v_dict[B].end_coord: if v_dict[D].end_coord != v_dict[C].i_coord and v_dict[D].end_coord != v_dict[C].end_coord: return False elif v_dict[D].end_coord == v_dict[B].i_coord or v_dict[D].end_coord == v_dict[B].end_coord: if v_dict[D].i_coord != v_dict[C].i_coord and v_dict[D].i_coord != v_dict[C].end_coord: return False else: return False else: return False x_coord = my_vector(0,0,0,1) y_coord = my_vector(0,0,1,0) for i in range(1, 5): if x_coord * v_dict[i] != 0 and y_coord * v_dict[i] != 0: return False min_x = min(v_dict[A].i_coord[0], v_dict[B].i_coord[0],v_dict[C].i_coord[0]) max_x = max(v_dict[A].i_coord[0], v_dict[B].i_coord[0],v_dict[C].i_coord[0]) min_y = min(v_dict[A].i_coord[1], v_dict[B].i_coord[1],v_dict[C].i_coord[1]) max_y = max(v_dict[A].i_coord[1], v_dict[B].i_coord[1],v_dict[C].i_coord[1]) if min_y < 0: area = max_y * (max_x - min_x) + min_y * (max_x - min_x) else: area = max_y * (max_x - min_x) - min_y * (max_x - min_x) if area <= 0: return False return True def main(): if problem(stdin.readlines()): print("YES") else: print("NO") main() ```
instruction
0
98,861
23
197,722
No
output
1
98,861
23
197,723
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a program for rectangles detection. According to his plan, the program detects if the four given segments form a rectangle of a positive area and with sides parallel to coordinate axes. As Alex does badly at school and can't write this program by himself, he asks you to help him. Input The input data contain four lines. Each of these lines contains four integers x1, y1, x2, y2 ( - 109 ≤ x1, y1, x2, y2 ≤ 109) — coordinates of segment's beginning and end positions. The given segments can degenerate into points. Output Output the word «YES», if the given four segments form the required rectangle, otherwise output «NO». Examples Input 1 1 6 1 1 0 6 0 6 0 6 1 1 1 1 0 Output YES Input 0 0 0 3 2 0 0 0 2 2 2 0 0 2 2 2 Output NO Submitted Solution: ``` from collections import Counter def main(): segs = [tuple(map(int, input().split())) for _ in range(4)] points = [] for x1, y1, x2, y2 in segs: if (x1, y1) == (x2, y2): print('NO') return points.append((x1, y1)) points.append((x2, y2)) c = Counter(points) xs = Counter(p[0] for p in points) ys = Counter(p[1] for p in points) if any(c[p] != 2 for p in c): print('NO') return if any(xs[x] != 4 for x in xs): print('NO') return if any(ys[y] != 4 for y in ys): print('NO') return if len(set(points)) != 4: print('NO') return print('YES') main() ```
instruction
0
98,862
23
197,724
No
output
1
98,862
23
197,725
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a program for rectangles detection. According to his plan, the program detects if the four given segments form a rectangle of a positive area and with sides parallel to coordinate axes. As Alex does badly at school and can't write this program by himself, he asks you to help him. Input The input data contain four lines. Each of these lines contains four integers x1, y1, x2, y2 ( - 109 ≤ x1, y1, x2, y2 ≤ 109) — coordinates of segment's beginning and end positions. The given segments can degenerate into points. Output Output the word «YES», if the given four segments form the required rectangle, otherwise output «NO». Examples Input 1 1 6 1 1 0 6 0 6 0 6 1 1 1 1 0 Output YES Input 0 0 0 3 2 0 0 0 2 2 2 0 0 2 2 2 Output NO Submitted Solution: ``` def Prod_punto(v1,v2): return v1[0]*v2[0]+v1[1]*v2[1] puntos = [] rect = True for i in range(4): a = tuple(input().split(" ")) for k,j in enumerate(a): if k%2 == 0: b = [j] else: b.append(j) puntos.append(tuple(b)) for j,i in enumerate(puntos): if puntos.count(i) != 2: rect = False break if j%2 == 0 and j+1 <= 7: if i == puntos[j+1]: rect = False break segmentos = [] for i in range(0,len(puntos),2): punto = (int(puntos[i][0])-int(puntos[i+1][0])),(int(puntos[i][1])-int(puntos[i+1][1])) segmentos.append(punto) largos = [] for i in segmentos: largos.append(Prod_punto(i,i)) for i in largos: if largos.count(i) != 2: rect = False if rect: for i,j in zip(segmentos,largos): suma = 0 for k in segmentos: suma += abs(Prod_punto(i,k)) if suma != 2*j: rect = False if rect: print("YES") else: print("NO") ```
instruction
0
98,863
23
197,726
No
output
1
98,863
23
197,727
Provide tags and a correct Python 3 solution for this coding contest problem. Input The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points on a plane. Each of the next n lines contains two real coordinates xi and yi of the <image> point, specified with exactly 2 fractional digits. All coordinates are between - 1000 and 1000, inclusive. Output Output a single real number θ — the answer to the problem statement. The absolute or relative error of your answer should be at most 10 - 2. Examples Input 8 -2.14 2.06 -1.14 2.04 -2.16 1.46 -2.14 0.70 -1.42 0.40 -0.94 -0.48 -1.42 -1.28 -2.16 -1.62 Output 5.410 Input 5 2.26 1.44 2.28 0.64 2.30 -0.30 1.58 0.66 3.24 0.66 Output 5.620 Input 8 6.98 2.06 6.40 1.12 5.98 0.24 5.54 -0.60 7.16 0.30 7.82 1.24 8.34 0.24 8.74 -0.76 Output 5.480 Input 5 10.44 2.06 10.90 0.80 11.48 -0.48 12.06 0.76 12.54 2.06 Output 6.040 Input 8 16.94 2.42 15.72 2.38 14.82 1.58 14.88 0.50 15.76 -0.16 16.86 -0.20 17.00 0.88 16.40 0.92 Output 6.040 Input 7 20.62 3.00 21.06 2.28 21.56 1.36 21.66 0.56 21.64 -0.52 22.14 2.32 22.62 3.04 Output 6.720
instruction
0
98,990
23
197,980
Tags: *special, geometry Correct Solution: ``` a = int(input()) s = 0 for i in range(a): s += float(input().split()[1]) d = round(s / a, 3) + 5 l = len(str(d).split(".")[1]) if l < 3: print(str(d) + "0" * (3 - l)) else: print(d) ```
output
1
98,990
23
197,981
Provide tags and a correct Python 3 solution for this coding contest problem. Input The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points on a plane. Each of the next n lines contains two real coordinates xi and yi of the <image> point, specified with exactly 2 fractional digits. All coordinates are between - 1000 and 1000, inclusive. Output Output a single real number θ — the answer to the problem statement. The absolute or relative error of your answer should be at most 10 - 2. Examples Input 8 -2.14 2.06 -1.14 2.04 -2.16 1.46 -2.14 0.70 -1.42 0.40 -0.94 -0.48 -1.42 -1.28 -2.16 -1.62 Output 5.410 Input 5 2.26 1.44 2.28 0.64 2.30 -0.30 1.58 0.66 3.24 0.66 Output 5.620 Input 8 6.98 2.06 6.40 1.12 5.98 0.24 5.54 -0.60 7.16 0.30 7.82 1.24 8.34 0.24 8.74 -0.76 Output 5.480 Input 5 10.44 2.06 10.90 0.80 11.48 -0.48 12.06 0.76 12.54 2.06 Output 6.040 Input 8 16.94 2.42 15.72 2.38 14.82 1.58 14.88 0.50 15.76 -0.16 16.86 -0.20 17.00 0.88 16.40 0.92 Output 6.040 Input 7 20.62 3.00 21.06 2.28 21.56 1.36 21.66 0.56 21.64 -0.52 22.14 2.32 22.62 3.04 Output 6.720
instruction
0
98,991
23
197,982
Tags: *special, geometry Correct Solution: ``` n = int(input()) P = [[float(x) for x in input().split()] for _ in range(n)] print(5 + sum(b for a,b in P)/n) ```
output
1
98,991
23
197,983
Provide tags and a correct Python 3 solution for this coding contest problem. Input The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points on a plane. Each of the next n lines contains two real coordinates xi and yi of the <image> point, specified with exactly 2 fractional digits. All coordinates are between - 1000 and 1000, inclusive. Output Output a single real number θ — the answer to the problem statement. The absolute or relative error of your answer should be at most 10 - 2. Examples Input 8 -2.14 2.06 -1.14 2.04 -2.16 1.46 -2.14 0.70 -1.42 0.40 -0.94 -0.48 -1.42 -1.28 -2.16 -1.62 Output 5.410 Input 5 2.26 1.44 2.28 0.64 2.30 -0.30 1.58 0.66 3.24 0.66 Output 5.620 Input 8 6.98 2.06 6.40 1.12 5.98 0.24 5.54 -0.60 7.16 0.30 7.82 1.24 8.34 0.24 8.74 -0.76 Output 5.480 Input 5 10.44 2.06 10.90 0.80 11.48 -0.48 12.06 0.76 12.54 2.06 Output 6.040 Input 8 16.94 2.42 15.72 2.38 14.82 1.58 14.88 0.50 15.76 -0.16 16.86 -0.20 17.00 0.88 16.40 0.92 Output 6.040 Input 7 20.62 3.00 21.06 2.28 21.56 1.36 21.66 0.56 21.64 -0.52 22.14 2.32 22.62 3.04 Output 6.720
instruction
0
98,992
23
197,984
Tags: *special, geometry Correct Solution: ``` import sys def solve(): n = int(input()) avg = sum([list(map(float, input().split()))[1] for _ in range(n)])/n return avg + 5 if sys.hexversion == 50594544 : sys.stdin = open("test.txt") print(solve()) ```
output
1
98,992
23
197,985
Provide tags and a correct Python 3 solution for this coding contest problem. Input The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points on a plane. Each of the next n lines contains two real coordinates xi and yi of the <image> point, specified with exactly 2 fractional digits. All coordinates are between - 1000 and 1000, inclusive. Output Output a single real number θ — the answer to the problem statement. The absolute or relative error of your answer should be at most 10 - 2. Examples Input 8 -2.14 2.06 -1.14 2.04 -2.16 1.46 -2.14 0.70 -1.42 0.40 -0.94 -0.48 -1.42 -1.28 -2.16 -1.62 Output 5.410 Input 5 2.26 1.44 2.28 0.64 2.30 -0.30 1.58 0.66 3.24 0.66 Output 5.620 Input 8 6.98 2.06 6.40 1.12 5.98 0.24 5.54 -0.60 7.16 0.30 7.82 1.24 8.34 0.24 8.74 -0.76 Output 5.480 Input 5 10.44 2.06 10.90 0.80 11.48 -0.48 12.06 0.76 12.54 2.06 Output 6.040 Input 8 16.94 2.42 15.72 2.38 14.82 1.58 14.88 0.50 15.76 -0.16 16.86 -0.20 17.00 0.88 16.40 0.92 Output 6.040 Input 7 20.62 3.00 21.06 2.28 21.56 1.36 21.66 0.56 21.64 -0.52 22.14 2.32 22.62 3.04 Output 6.720
instruction
0
98,993
23
197,986
Tags: *special, geometry Correct Solution: ``` n = int(input()) sum = 0 for _ in range(n): sum += [float(i) for i in input().split(" ")][1] print(5 + sum/n) ```
output
1
98,993
23
197,987
Provide tags and a correct Python 3 solution for this coding contest problem. Input The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points on a plane. Each of the next n lines contains two real coordinates xi and yi of the <image> point, specified with exactly 2 fractional digits. All coordinates are between - 1000 and 1000, inclusive. Output Output a single real number θ — the answer to the problem statement. The absolute or relative error of your answer should be at most 10 - 2. Examples Input 8 -2.14 2.06 -1.14 2.04 -2.16 1.46 -2.14 0.70 -1.42 0.40 -0.94 -0.48 -1.42 -1.28 -2.16 -1.62 Output 5.410 Input 5 2.26 1.44 2.28 0.64 2.30 -0.30 1.58 0.66 3.24 0.66 Output 5.620 Input 8 6.98 2.06 6.40 1.12 5.98 0.24 5.54 -0.60 7.16 0.30 7.82 1.24 8.34 0.24 8.74 -0.76 Output 5.480 Input 5 10.44 2.06 10.90 0.80 11.48 -0.48 12.06 0.76 12.54 2.06 Output 6.040 Input 8 16.94 2.42 15.72 2.38 14.82 1.58 14.88 0.50 15.76 -0.16 16.86 -0.20 17.00 0.88 16.40 0.92 Output 6.040 Input 7 20.62 3.00 21.06 2.28 21.56 1.36 21.66 0.56 21.64 -0.52 22.14 2.32 22.62 3.04 Output 6.720
instruction
0
98,994
23
197,988
Tags: *special, geometry Correct Solution: ``` n=int(input()) sum=0.00 for i in range(1,n+1): s=input().split() sum+=float(s[1]) print(sum/n+5) ```
output
1
98,994
23
197,989
Provide tags and a correct Python 3 solution for this coding contest problem. Input The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points on a plane. Each of the next n lines contains two real coordinates xi and yi of the <image> point, specified with exactly 2 fractional digits. All coordinates are between - 1000 and 1000, inclusive. Output Output a single real number θ — the answer to the problem statement. The absolute or relative error of your answer should be at most 10 - 2. Examples Input 8 -2.14 2.06 -1.14 2.04 -2.16 1.46 -2.14 0.70 -1.42 0.40 -0.94 -0.48 -1.42 -1.28 -2.16 -1.62 Output 5.410 Input 5 2.26 1.44 2.28 0.64 2.30 -0.30 1.58 0.66 3.24 0.66 Output 5.620 Input 8 6.98 2.06 6.40 1.12 5.98 0.24 5.54 -0.60 7.16 0.30 7.82 1.24 8.34 0.24 8.74 -0.76 Output 5.480 Input 5 10.44 2.06 10.90 0.80 11.48 -0.48 12.06 0.76 12.54 2.06 Output 6.040 Input 8 16.94 2.42 15.72 2.38 14.82 1.58 14.88 0.50 15.76 -0.16 16.86 -0.20 17.00 0.88 16.40 0.92 Output 6.040 Input 7 20.62 3.00 21.06 2.28 21.56 1.36 21.66 0.56 21.64 -0.52 22.14 2.32 22.62 3.04 Output 6.720
instruction
0
98,995
23
197,990
Tags: *special, geometry Correct Solution: ``` n = int(input()) s = 0.0 for i in range(0, n): data = input().split() x, y = float(data[0]), float(data[1]) s += y print("%.3f" % (5 + s/n)) ```
output
1
98,995
23
197,991
Provide tags and a correct Python 3 solution for this coding contest problem. Input The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points on a plane. Each of the next n lines contains two real coordinates xi and yi of the <image> point, specified with exactly 2 fractional digits. All coordinates are between - 1000 and 1000, inclusive. Output Output a single real number θ — the answer to the problem statement. The absolute or relative error of your answer should be at most 10 - 2. Examples Input 8 -2.14 2.06 -1.14 2.04 -2.16 1.46 -2.14 0.70 -1.42 0.40 -0.94 -0.48 -1.42 -1.28 -2.16 -1.62 Output 5.410 Input 5 2.26 1.44 2.28 0.64 2.30 -0.30 1.58 0.66 3.24 0.66 Output 5.620 Input 8 6.98 2.06 6.40 1.12 5.98 0.24 5.54 -0.60 7.16 0.30 7.82 1.24 8.34 0.24 8.74 -0.76 Output 5.480 Input 5 10.44 2.06 10.90 0.80 11.48 -0.48 12.06 0.76 12.54 2.06 Output 6.040 Input 8 16.94 2.42 15.72 2.38 14.82 1.58 14.88 0.50 15.76 -0.16 16.86 -0.20 17.00 0.88 16.40 0.92 Output 6.040 Input 7 20.62 3.00 21.06 2.28 21.56 1.36 21.66 0.56 21.64 -0.52 22.14 2.32 22.62 3.04 Output 6.720
instruction
0
98,996
23
197,992
Tags: *special, geometry Correct Solution: ``` a=int(input());print(sum([float(input().split(' ')[1]) for i in range(a)])/a+5) ```
output
1
98,996
23
197,993
Provide tags and a correct Python 3 solution for this coding contest problem. Input The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points on a plane. Each of the next n lines contains two real coordinates xi and yi of the <image> point, specified with exactly 2 fractional digits. All coordinates are between - 1000 and 1000, inclusive. Output Output a single real number θ — the answer to the problem statement. The absolute or relative error of your answer should be at most 10 - 2. Examples Input 8 -2.14 2.06 -1.14 2.04 -2.16 1.46 -2.14 0.70 -1.42 0.40 -0.94 -0.48 -1.42 -1.28 -2.16 -1.62 Output 5.410 Input 5 2.26 1.44 2.28 0.64 2.30 -0.30 1.58 0.66 3.24 0.66 Output 5.620 Input 8 6.98 2.06 6.40 1.12 5.98 0.24 5.54 -0.60 7.16 0.30 7.82 1.24 8.34 0.24 8.74 -0.76 Output 5.480 Input 5 10.44 2.06 10.90 0.80 11.48 -0.48 12.06 0.76 12.54 2.06 Output 6.040 Input 8 16.94 2.42 15.72 2.38 14.82 1.58 14.88 0.50 15.76 -0.16 16.86 -0.20 17.00 0.88 16.40 0.92 Output 6.040 Input 7 20.62 3.00 21.06 2.28 21.56 1.36 21.66 0.56 21.64 -0.52 22.14 2.32 22.62 3.04 Output 6.720
instruction
0
98,997
23
197,994
Tags: *special, geometry Correct Solution: ``` n = int(input()) theta = 5.0 for i in range(n): theta += list(map(float, input().split()))[1] / n print('%.3f' % theta) ```
output
1
98,997
23
197,995
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Input The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points on a plane. Each of the next n lines contains two real coordinates xi and yi of the <image> point, specified with exactly 2 fractional digits. All coordinates are between - 1000 and 1000, inclusive. Output Output a single real number θ — the answer to the problem statement. The absolute or relative error of your answer should be at most 10 - 2. Examples Input 8 -2.14 2.06 -1.14 2.04 -2.16 1.46 -2.14 0.70 -1.42 0.40 -0.94 -0.48 -1.42 -1.28 -2.16 -1.62 Output 5.410 Input 5 2.26 1.44 2.28 0.64 2.30 -0.30 1.58 0.66 3.24 0.66 Output 5.620 Input 8 6.98 2.06 6.40 1.12 5.98 0.24 5.54 -0.60 7.16 0.30 7.82 1.24 8.34 0.24 8.74 -0.76 Output 5.480 Input 5 10.44 2.06 10.90 0.80 11.48 -0.48 12.06 0.76 12.54 2.06 Output 6.040 Input 8 16.94 2.42 15.72 2.38 14.82 1.58 14.88 0.50 15.76 -0.16 16.86 -0.20 17.00 0.88 16.40 0.92 Output 6.040 Input 7 20.62 3.00 21.06 2.28 21.56 1.36 21.66 0.56 21.64 -0.52 22.14 2.32 22.62 3.04 Output 6.720 Submitted Solution: ``` n,num = int(input()),0 for i in range(n): num += float(input().split()[1]) print(f'{num / n + 5:.3f}') ```
instruction
0
98,998
23
197,996
Yes
output
1
98,998
23
197,997
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Input The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points on a plane. Each of the next n lines contains two real coordinates xi and yi of the <image> point, specified with exactly 2 fractional digits. All coordinates are between - 1000 and 1000, inclusive. Output Output a single real number θ — the answer to the problem statement. The absolute or relative error of your answer should be at most 10 - 2. Examples Input 8 -2.14 2.06 -1.14 2.04 -2.16 1.46 -2.14 0.70 -1.42 0.40 -0.94 -0.48 -1.42 -1.28 -2.16 -1.62 Output 5.410 Input 5 2.26 1.44 2.28 0.64 2.30 -0.30 1.58 0.66 3.24 0.66 Output 5.620 Input 8 6.98 2.06 6.40 1.12 5.98 0.24 5.54 -0.60 7.16 0.30 7.82 1.24 8.34 0.24 8.74 -0.76 Output 5.480 Input 5 10.44 2.06 10.90 0.80 11.48 -0.48 12.06 0.76 12.54 2.06 Output 6.040 Input 8 16.94 2.42 15.72 2.38 14.82 1.58 14.88 0.50 15.76 -0.16 16.86 -0.20 17.00 0.88 16.40 0.92 Output 6.040 Input 7 20.62 3.00 21.06 2.28 21.56 1.36 21.66 0.56 21.64 -0.52 22.14 2.32 22.62 3.04 Output 6.720 Submitted Solution: ``` """ Codeforces April Fools Contest 2014 Problem G Author : chaotic_iak Language: Python 3.3.4 """ class InputHandlerObject(object): inputs = [] def getInput(self, n = 0): res = "" inputs = self.inputs if not inputs: inputs.extend(input().split(" ")) if n == 0: res = inputs[:] inputs[:] = [] while n > len(inputs): inputs.extend(input().split(" ")) if n > 0: res = inputs[:n] inputs[:n] = [] return res InputHandler = InputHandlerObject() g = InputHandler.getInput ############################## SOLUTION ############################## n = int(input()) sum = 0 for i in range(n): nx, ny = g() sum += float(ny) print(5 + (sum/n)) ```
instruction
0
98,999
23
197,998
Yes
output
1
98,999
23
197,999
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Input The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points on a plane. Each of the next n lines contains two real coordinates xi and yi of the <image> point, specified with exactly 2 fractional digits. All coordinates are between - 1000 and 1000, inclusive. Output Output a single real number θ — the answer to the problem statement. The absolute or relative error of your answer should be at most 10 - 2. Examples Input 8 -2.14 2.06 -1.14 2.04 -2.16 1.46 -2.14 0.70 -1.42 0.40 -0.94 -0.48 -1.42 -1.28 -2.16 -1.62 Output 5.410 Input 5 2.26 1.44 2.28 0.64 2.30 -0.30 1.58 0.66 3.24 0.66 Output 5.620 Input 8 6.98 2.06 6.40 1.12 5.98 0.24 5.54 -0.60 7.16 0.30 7.82 1.24 8.34 0.24 8.74 -0.76 Output 5.480 Input 5 10.44 2.06 10.90 0.80 11.48 -0.48 12.06 0.76 12.54 2.06 Output 6.040 Input 8 16.94 2.42 15.72 2.38 14.82 1.58 14.88 0.50 15.76 -0.16 16.86 -0.20 17.00 0.88 16.40 0.92 Output 6.040 Input 7 20.62 3.00 21.06 2.28 21.56 1.36 21.66 0.56 21.64 -0.52 22.14 2.32 22.62 3.04 Output 6.720 Submitted Solution: ``` s = 0 n = int(input()) for i in range(n): x, y = map(float, input().split()) s += y print(s / n + 5) ```
instruction
0
99,000
23
198,000
Yes
output
1
99,000
23
198,001
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Input The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points on a plane. Each of the next n lines contains two real coordinates xi and yi of the <image> point, specified with exactly 2 fractional digits. All coordinates are between - 1000 and 1000, inclusive. Output Output a single real number θ — the answer to the problem statement. The absolute or relative error of your answer should be at most 10 - 2. Examples Input 8 -2.14 2.06 -1.14 2.04 -2.16 1.46 -2.14 0.70 -1.42 0.40 -0.94 -0.48 -1.42 -1.28 -2.16 -1.62 Output 5.410 Input 5 2.26 1.44 2.28 0.64 2.30 -0.30 1.58 0.66 3.24 0.66 Output 5.620 Input 8 6.98 2.06 6.40 1.12 5.98 0.24 5.54 -0.60 7.16 0.30 7.82 1.24 8.34 0.24 8.74 -0.76 Output 5.480 Input 5 10.44 2.06 10.90 0.80 11.48 -0.48 12.06 0.76 12.54 2.06 Output 6.040 Input 8 16.94 2.42 15.72 2.38 14.82 1.58 14.88 0.50 15.76 -0.16 16.86 -0.20 17.00 0.88 16.40 0.92 Output 6.040 Input 7 20.62 3.00 21.06 2.28 21.56 1.36 21.66 0.56 21.64 -0.52 22.14 2.32 22.62 3.04 Output 6.720 Submitted Solution: ``` n=int(input()) print(sum([float(input().split()[1])for i in range(n)])/n+5) ```
instruction
0
99,001
23
198,002
Yes
output
1
99,001
23
198,003
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Input The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points on a plane. Each of the next n lines contains two real coordinates xi and yi of the <image> point, specified with exactly 2 fractional digits. All coordinates are between - 1000 and 1000, inclusive. Output Output a single real number θ — the answer to the problem statement. The absolute or relative error of your answer should be at most 10 - 2. Examples Input 8 -2.14 2.06 -1.14 2.04 -2.16 1.46 -2.14 0.70 -1.42 0.40 -0.94 -0.48 -1.42 -1.28 -2.16 -1.62 Output 5.410 Input 5 2.26 1.44 2.28 0.64 2.30 -0.30 1.58 0.66 3.24 0.66 Output 5.620 Input 8 6.98 2.06 6.40 1.12 5.98 0.24 5.54 -0.60 7.16 0.30 7.82 1.24 8.34 0.24 8.74 -0.76 Output 5.480 Input 5 10.44 2.06 10.90 0.80 11.48 -0.48 12.06 0.76 12.54 2.06 Output 6.040 Input 8 16.94 2.42 15.72 2.38 14.82 1.58 14.88 0.50 15.76 -0.16 16.86 -0.20 17.00 0.88 16.40 0.92 Output 6.040 Input 7 20.62 3.00 21.06 2.28 21.56 1.36 21.66 0.56 21.64 -0.52 22.14 2.32 22.62 3.04 Output 6.720 Submitted Solution: ``` print('_1001000110001100'[int(input())]) ```
instruction
0
99,002
23
198,004
No
output
1
99,002
23
198,005
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Input The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points on a plane. Each of the next n lines contains two real coordinates xi and yi of the <image> point, specified with exactly 2 fractional digits. All coordinates are between - 1000 and 1000, inclusive. Output Output a single real number θ — the answer to the problem statement. The absolute or relative error of your answer should be at most 10 - 2. Examples Input 8 -2.14 2.06 -1.14 2.04 -2.16 1.46 -2.14 0.70 -1.42 0.40 -0.94 -0.48 -1.42 -1.28 -2.16 -1.62 Output 5.410 Input 5 2.26 1.44 2.28 0.64 2.30 -0.30 1.58 0.66 3.24 0.66 Output 5.620 Input 8 6.98 2.06 6.40 1.12 5.98 0.24 5.54 -0.60 7.16 0.30 7.82 1.24 8.34 0.24 8.74 -0.76 Output 5.480 Input 5 10.44 2.06 10.90 0.80 11.48 -0.48 12.06 0.76 12.54 2.06 Output 6.040 Input 8 16.94 2.42 15.72 2.38 14.82 1.58 14.88 0.50 15.76 -0.16 16.86 -0.20 17.00 0.88 16.40 0.92 Output 6.040 Input 7 20.62 3.00 21.06 2.28 21.56 1.36 21.66 0.56 21.64 -0.52 22.14 2.32 22.62 3.04 Output 6.720 Submitted Solution: ``` print('_1001000101001100'[int(input())]) ```
instruction
0
99,003
23
198,006
No
output
1
99,003
23
198,007
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Input The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points on a plane. Each of the next n lines contains two real coordinates xi and yi of the <image> point, specified with exactly 2 fractional digits. All coordinates are between - 1000 and 1000, inclusive. Output Output a single real number θ — the answer to the problem statement. The absolute or relative error of your answer should be at most 10 - 2. Examples Input 8 -2.14 2.06 -1.14 2.04 -2.16 1.46 -2.14 0.70 -1.42 0.40 -0.94 -0.48 -1.42 -1.28 -2.16 -1.62 Output 5.410 Input 5 2.26 1.44 2.28 0.64 2.30 -0.30 1.58 0.66 3.24 0.66 Output 5.620 Input 8 6.98 2.06 6.40 1.12 5.98 0.24 5.54 -0.60 7.16 0.30 7.82 1.24 8.34 0.24 8.74 -0.76 Output 5.480 Input 5 10.44 2.06 10.90 0.80 11.48 -0.48 12.06 0.76 12.54 2.06 Output 6.040 Input 8 16.94 2.42 15.72 2.38 14.82 1.58 14.88 0.50 15.76 -0.16 16.86 -0.20 17.00 0.88 16.40 0.92 Output 6.040 Input 7 20.62 3.00 21.06 2.28 21.56 1.36 21.66 0.56 21.64 -0.52 22.14 2.32 22.62 3.04 Output 6.720 Submitted Solution: ``` print('_1001000111011100'[int(input())]) ```
instruction
0
99,004
23
198,008
No
output
1
99,004
23
198,009
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Input The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points on a plane. Each of the next n lines contains two real coordinates xi and yi of the <image> point, specified with exactly 2 fractional digits. All coordinates are between - 1000 and 1000, inclusive. Output Output a single real number θ — the answer to the problem statement. The absolute or relative error of your answer should be at most 10 - 2. Examples Input 8 -2.14 2.06 -1.14 2.04 -2.16 1.46 -2.14 0.70 -1.42 0.40 -0.94 -0.48 -1.42 -1.28 -2.16 -1.62 Output 5.410 Input 5 2.26 1.44 2.28 0.64 2.30 -0.30 1.58 0.66 3.24 0.66 Output 5.620 Input 8 6.98 2.06 6.40 1.12 5.98 0.24 5.54 -0.60 7.16 0.30 7.82 1.24 8.34 0.24 8.74 -0.76 Output 5.480 Input 5 10.44 2.06 10.90 0.80 11.48 -0.48 12.06 0.76 12.54 2.06 Output 6.040 Input 8 16.94 2.42 15.72 2.38 14.82 1.58 14.88 0.50 15.76 -0.16 16.86 -0.20 17.00 0.88 16.40 0.92 Output 6.040 Input 7 20.62 3.00 21.06 2.28 21.56 1.36 21.66 0.56 21.64 -0.52 22.14 2.32 22.62 3.04 Output 6.720 Submitted Solution: ``` print('_1001000111101100'[int(input())]) ```
instruction
0
99,005
23
198,010
No
output
1
99,005
23
198,011
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a n × m field consisting only of periods ('.') and asterisks ('*'). Your task is to count all right triangles with two sides parallel to the square sides, whose vertices are in the centers of '*'-cells. A right triangle is a triangle in which one angle is a right angle (that is, a 90 degree angle). Input The first line contains two positive integer numbers n and m (1 ≤ n, m ≤ 1000). The following n lines consist of m characters each, describing the field. Only '.' and '*' are allowed. Output Output a single number — total number of square triangles in the field. Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d). Examples Input 2 2 ** *. Output 1 Input 3 4 *..* .**. *.** Output 9
instruction
0
99,038
23
198,076
Tags: combinatorics Correct Solution: ``` u=input n,m=map(int,u().split()) l=[list(u()) for _ in range(n)] R=[p.count('*') for p in l] C=[p.count('*') for p in zip(*l)] t=0 for i in range(n): for j in range(m): if(l[i][j]=='*'): t+=(R[i]-1)*(C[j]-1) print(t) ```
output
1
99,038
23
198,077
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a n × m field consisting only of periods ('.') and asterisks ('*'). Your task is to count all right triangles with two sides parallel to the square sides, whose vertices are in the centers of '*'-cells. A right triangle is a triangle in which one angle is a right angle (that is, a 90 degree angle). Input The first line contains two positive integer numbers n and m (1 ≤ n, m ≤ 1000). The following n lines consist of m characters each, describing the field. Only '.' and '*' are allowed. Output Output a single number — total number of square triangles in the field. Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d). Examples Input 2 2 ** *. Output 1 Input 3 4 *..* .**. *.** Output 9
instruction
0
99,039
23
198,078
Tags: combinatorics Correct Solution: ``` n,m = map(int,input().split()) ma = [] for i in range(n): ma.append(input()) x = [0] * n y = [0] * m for i in range(n): for j in range(m): if ma[i][j] == "*": x[i] += 1 y[j] += 1 ans = 0 for i in range(n): for j in range(m): if ma[i][j] == "*": ans += (x[i] - 1) * (y[j] - 1) print(ans) ```
output
1
99,039
23
198,079
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a n × m field consisting only of periods ('.') and asterisks ('*'). Your task is to count all right triangles with two sides parallel to the square sides, whose vertices are in the centers of '*'-cells. A right triangle is a triangle in which one angle is a right angle (that is, a 90 degree angle). Input The first line contains two positive integer numbers n and m (1 ≤ n, m ≤ 1000). The following n lines consist of m characters each, describing the field. Only '.' and '*' are allowed. Output Output a single number — total number of square triangles in the field. Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d). Examples Input 2 2 ** *. Output 1 Input 3 4 *..* .**. *.** Output 9
instruction
0
99,040
23
198,080
Tags: combinatorics Correct Solution: ``` n,m=map(int,input().split()) a,r,c=[""]*n,[0]*n,[0]*m for i in range(n): a[i]=input() for i in range(n): for j in range(m): if a[i][j]=="*": r[i]+=1 c[j]+=1 ans=0 for i in range(n): for j in range(m): if a[i][j]=="*": ans+=(r[i]-1)*(c[j]-1) print(ans) ```
output
1
99,040
23
198,081
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a n × m field consisting only of periods ('.') and asterisks ('*'). Your task is to count all right triangles with two sides parallel to the square sides, whose vertices are in the centers of '*'-cells. A right triangle is a triangle in which one angle is a right angle (that is, a 90 degree angle). Input The first line contains two positive integer numbers n and m (1 ≤ n, m ≤ 1000). The following n lines consist of m characters each, describing the field. Only '.' and '*' are allowed. Output Output a single number — total number of square triangles in the field. Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d). Examples Input 2 2 ** *. Output 1 Input 3 4 *..* .**. *.** Output 9
instruction
0
99,041
23
198,082
Tags: combinatorics Correct Solution: ``` n, m = [int(x) for x in input().split()] a = [] for _ in range(n): a.append(input()) cnt_rows = [0] * n cnt_cols = [0] * m for i in range(n): for j in range(m): if a[i][j] == '*': cnt_rows[i] +=1 cnt_cols[j] += 1 res = 0 for i in range(n): for j in range(m): if a[i][j] == '*': res += (cnt_cols[j] - 1) * (cnt_rows[i] - 1) print(res) ```
output
1
99,041
23
198,083
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a n × m field consisting only of periods ('.') and asterisks ('*'). Your task is to count all right triangles with two sides parallel to the square sides, whose vertices are in the centers of '*'-cells. A right triangle is a triangle in which one angle is a right angle (that is, a 90 degree angle). Input The first line contains two positive integer numbers n and m (1 ≤ n, m ≤ 1000). The following n lines consist of m characters each, describing the field. Only '.' and '*' are allowed. Output Output a single number — total number of square triangles in the field. Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d). Examples Input 2 2 ** *. Output 1 Input 3 4 *..* .**. *.** Output 9
instruction
0
99,042
23
198,084
Tags: combinatorics Correct Solution: ``` u=input n,m=map(int,u().split()) l=[list(u()) for _ in range(n)] R=[p.count('*') for p in l] C=[p.count('*') for p in zip(*l)] t=0 for i in range(n): for j in range(m): if(l[i][j]=='*'): t+=(R[i]-1)*(C[j]-1) print(t) # Made By Mostafa_Khaled ```
output
1
99,042
23
198,085
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a n × m field consisting only of periods ('.') and asterisks ('*'). Your task is to count all right triangles with two sides parallel to the square sides, whose vertices are in the centers of '*'-cells. A right triangle is a triangle in which one angle is a right angle (that is, a 90 degree angle). Input The first line contains two positive integer numbers n and m (1 ≤ n, m ≤ 1000). The following n lines consist of m characters each, describing the field. Only '.' and '*' are allowed. Output Output a single number — total number of square triangles in the field. Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d). Examples Input 2 2 ** *. Output 1 Input 3 4 *..* .**. *.** Output 9
instruction
0
99,043
23
198,086
Tags: combinatorics Correct Solution: ``` n, m = map(int, input().split()) a = [] for i in range(n): a.append(input()) r = [0] * n c = [0] * m for i in range(n): for j in range(m): if a[i][j] == '*': r[i] += 1 c[j] += 1 s = 0 for i in range(n): for j in range(m): if a[i][j] == '*': s += (r[i] - 1) * (c[j] - 1) print(s) ```
output
1
99,043
23
198,087
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a n × m field consisting only of periods ('.') and asterisks ('*'). Your task is to count all right triangles with two sides parallel to the square sides, whose vertices are in the centers of '*'-cells. A right triangle is a triangle in which one angle is a right angle (that is, a 90 degree angle). Input The first line contains two positive integer numbers n and m (1 ≤ n, m ≤ 1000). The following n lines consist of m characters each, describing the field. Only '.' and '*' are allowed. Output Output a single number — total number of square triangles in the field. Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d). Examples Input 2 2 ** *. Output 1 Input 3 4 *..* .**. *.** Output 9
instruction
0
99,044
23
198,088
Tags: combinatorics Correct Solution: ``` n,m=list(map(int,input().split())) a=[input() for i in range(n)] b=[-1]*n c=[-1]*m for i in range(n): for j in range(m): if a[i][j]=='*': b[i]+=1 c[j]+=1 d=0 for i in range(n): for j in range(m): if a[i][j]=='*': d+=b[i]*c[j] print(d) ```
output
1
99,044
23
198,089
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a n × m field consisting only of periods ('.') and asterisks ('*'). Your task is to count all right triangles with two sides parallel to the square sides, whose vertices are in the centers of '*'-cells. A right triangle is a triangle in which one angle is a right angle (that is, a 90 degree angle). Input The first line contains two positive integer numbers n and m (1 ≤ n, m ≤ 1000). The following n lines consist of m characters each, describing the field. Only '.' and '*' are allowed. Output Output a single number — total number of square triangles in the field. Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d). Examples Input 2 2 ** *. Output 1 Input 3 4 *..* .**. *.** Output 9
instruction
0
99,045
23
198,090
Tags: combinatorics Correct Solution: ``` import sys from array import array # noqa: F401 def input(): return sys.stdin.buffer.readline().decode('utf-8') n, m = map(int, input().split()) a = ([[0] * (m + 2)] + [[0] + list(1 if c == '*' else 0 for c in input().rstrip()) + [0] for _ in range(n)] + [[0] * (m + 2)]) lr = [[0] * (m + 2) for _ in range(n + 2)] ud = [[0] * (m + 2) for _ in range(n + 2)] for i in range(1, n + 1): for j in range(1, m + 2): lr[i][j] = lr[i][j - 1] + a[i][j] for j in range(1, m + 1): for i in range(1, n + 2): ud[i][j] = ud[i - 1][j] + a[i][j] ans = 0 for i in range(1, n + 1): for j in range(1, m + 1): if a[i][j]: l, r, u, d = lr[i][j - 1], lr[i][-1] - lr[i][j], ud[i - 1][j], ud[-1][j] - ud[i][j] ans += u * r + r * d + d * l + l * u print(ans) ```
output
1
99,045
23
198,091
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a n × m field consisting only of periods ('.') and asterisks ('*'). Your task is to count all right triangles with two sides parallel to the square sides, whose vertices are in the centers of '*'-cells. A right triangle is a triangle in which one angle is a right angle (that is, a 90 degree angle). Input The first line contains two positive integer numbers n and m (1 ≤ n, m ≤ 1000). The following n lines consist of m characters each, describing the field. Only '.' and '*' are allowed. Output Output a single number — total number of square triangles in the field. Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d). Examples Input 2 2 ** *. Output 1 Input 3 4 *..* .**. *.** Output 9 Submitted Solution: ``` n,m=map(int,input().split()) c,r=[0]*n,[0]*m vals=[] for i in range(n): s=input() vals.append(s) for j in range(m): if(s[j]=='*'): c[i]+=1 r[j]+=1 ans=0 for i in range(n): for j in range(m): if(vals[i][j]=='*'): ans+=(c[i]-1)*(r[j]-1) print(ans) ```
instruction
0
99,046
23
198,092
Yes
output
1
99,046
23
198,093
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a n × m field consisting only of periods ('.') and asterisks ('*'). Your task is to count all right triangles with two sides parallel to the square sides, whose vertices are in the centers of '*'-cells. A right triangle is a triangle in which one angle is a right angle (that is, a 90 degree angle). Input The first line contains two positive integer numbers n and m (1 ≤ n, m ≤ 1000). The following n lines consist of m characters each, describing the field. Only '.' and '*' are allowed. Output Output a single number — total number of square triangles in the field. Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d). Examples Input 2 2 ** *. Output 1 Input 3 4 *..* .**. *.** Output 9 Submitted Solution: ``` import sys data = [] line1 = True asterisks = [] cols = [] for line in sys.stdin: if line1: line1 = False dim = line[:-1].split(" ") for i in range(int(dim[1])): cols.append(0) else: row = [] for i, c in enumerate(line): if c == "*": row.append(i+1) cols[i] += 1 asterisks.append(row) sum = 0 for row in asterisks: if len(row) >= 2: vertices = [] for i, item in enumerate(row): sum += (cols[item-1] - 1) * (len(row) - 1) print(sum) ```
instruction
0
99,047
23
198,094
Yes
output
1
99,047
23
198,095
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a n × m field consisting only of periods ('.') and asterisks ('*'). Your task is to count all right triangles with two sides parallel to the square sides, whose vertices are in the centers of '*'-cells. A right triangle is a triangle in which one angle is a right angle (that is, a 90 degree angle). Input The first line contains two positive integer numbers n and m (1 ≤ n, m ≤ 1000). The following n lines consist of m characters each, describing the field. Only '.' and '*' are allowed. Output Output a single number — total number of square triangles in the field. Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d). Examples Input 2 2 ** *. Output 1 Input 3 4 *..* .**. *.** Output 9 Submitted Solution: ``` n, m = map(int, input().split()) grid = [input() for _ in range(n)] a = [[0 for _ in range(m)] for i in range(n)] b = [[0 for _ in range(m)] for i in range(n)] for i in range(n): for j in range(m): a[i][j] = a[i][j - 1] + (grid[i][j] == '*') if i: b[i][j] = b[i - 1][j] b[i][j] += grid[i][j] == '*' ans = 0 for i in range(n): for j in range(m): if grid[i][j] == '*': l = r = u = d = 0 if j: l = a[i][j - 1] r = a[i][-1] - a[i][j] if i: u = b[i - 1][j] d = b[-1][j] - b[i][j] ans += (l + r) * (u + d) print(ans) ```
instruction
0
99,048
23
198,096
Yes
output
1
99,048
23
198,097