message
stringlengths
2
44.5k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
276
109k
cluster
float64
23
23
__index_level_0__
int64
552
217k
Provide tags and a correct Python 3 solution for this coding contest problem. The Squareland national forest is divided into equal 1 Γ— 1 square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates (x, y) of its south-west corner. Three friends, ...
instruction
0
19,456
23
38,912
Tags: implementation, math Correct Solution: ``` def ii(): return int(input()) def mi(): return map(int, input().split()) def li(): return list(mi()) # A. Connect Three a = [tuple(mi()) for i in range(3)] a.sort() up1 = a[1][1] >= a[0][1] up2 = a[2][1] >= a[0][1] ans = {a[0]} x, y = a[0] if up1 and up2: ...
output
1
19,456
23
38,913
Provide tags and a correct Python 3 solution for this coding contest problem. The Squareland national forest is divided into equal 1 Γ— 1 square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates (x, y) of its south-west corner. Three friends, ...
instruction
0
19,457
23
38,914
Tags: implementation, math Correct Solution: ``` a=list(map(int,input().split())) b=list(map(int,input().split())) c=list(map(int,input().split())) a, b, c = sorted([a,b,c]) ans = [] for i in range(min(a[1],b[1],c[1]),max(a[1],b[1],c[1])+1): ans.append((b[0],i)) for i in range(a[0],b[0]+1): ans.append((i,a[1]...
output
1
19,457
23
38,915
Provide tags and a correct Python 3 solution for this coding contest problem. The Squareland national forest is divided into equal 1 Γ— 1 square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates (x, y) of its south-west corner. Three friends, ...
instruction
0
19,458
23
38,916
Tags: implementation, math Correct Solution: ``` xa, ya = map(int, input().split()) xb, yb = map(int, input().split()) xc, yc = map(int, input().split()) xs = [xa, xb, xc] xs.sort() ys = [ya, yb, yc] ys.sort() mx, my = xs[1], ys[1] field = [[False]*1001 for _ in range(1001)] for sx, sy in [(xa, ya), (xb, yb), (xc, yc)...
output
1
19,458
23
38,917
Provide tags and a correct Python 3 solution for this coding contest problem. The Squareland national forest is divided into equal 1 Γ— 1 square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates (x, y) of its south-west corner. Three friends, ...
instruction
0
19,459
23
38,918
Tags: implementation, math Correct Solution: ``` def doWay(x, y, x1, y1, x2, y2): global answer while x < x1 and x < x2: x += 1 answer.add((x, y)) while y < y1 and y < y2: y += 1 answer.add((x, y)) while x > x1 and x > x2: x -= 1 answer.add((x, y)) whi...
output
1
19,459
23
38,919
Provide tags and a correct Python 3 solution for this coding contest problem. The Squareland national forest is divided into equal 1 Γ— 1 square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates (x, y) of its south-west corner. Three friends, ...
instruction
0
19,460
23
38,920
Tags: implementation, math Correct Solution: ``` def main(): a = tuple(map(int, input().split())) b = tuple(map(int, input().split())) c = tuple(map(int, input().split())) a, b, c = sorted((a, b, c)) (x1, y1) = a (x2, y2) = b (x3, y3) = c dy2 = y2 - y1 dy3 = y3 - y1 sy2 = 1 if...
output
1
19,460
23
38,921
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Squareland national forest is divided into equal 1 Γ— 1 square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates (x...
instruction
0
19,461
23
38,922
Yes
output
1
19,461
23
38,923
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Squareland national forest is divided into equal 1 Γ— 1 square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates (x...
instruction
0
19,462
23
38,924
Yes
output
1
19,462
23
38,925
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Squareland national forest is divided into equal 1 Γ— 1 square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates (x...
instruction
0
19,463
23
38,926
Yes
output
1
19,463
23
38,927
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Squareland national forest is divided into equal 1 Γ— 1 square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates (x...
instruction
0
19,464
23
38,928
Yes
output
1
19,464
23
38,929
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Squareland national forest is divided into equal 1 Γ— 1 square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates (x...
instruction
0
19,465
23
38,930
No
output
1
19,465
23
38,931
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Squareland national forest is divided into equal 1 Γ— 1 square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates (x...
instruction
0
19,466
23
38,932
No
output
1
19,466
23
38,933
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Squareland national forest is divided into equal 1 Γ— 1 square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates (x...
instruction
0
19,467
23
38,934
No
output
1
19,467
23
38,935
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Squareland national forest is divided into equal 1 Γ— 1 square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates (x...
instruction
0
19,468
23
38,936
No
output
1
19,468
23
38,937
Provide tags and a correct Python 3 solution for this coding contest problem. Lunar New Year is approaching, and you bought a matrix with lots of "crosses". This matrix M of size n Γ— n contains only 'X' and '.' (without quotes). The element in the i-th row and the j-th column (i, j) is defined as M(i, j), where 1 ≀ i...
instruction
0
19,469
23
38,938
Tags: implementation Correct Solution: ``` n = int(input()) s = [] for i in range(n): ip = input() s.append(ip) count = 0 for i in range(1,n-1): for j in range(1,n-1): if s[i][j] == 'X' and s[i-1][j-1] == 'X' and s[i-1][j+1] == 'X' and s[i+1][j-1] == 'X' and s[i+1][j+1] == 'X': count +...
output
1
19,469
23
38,939
Provide tags and a correct Python 3 solution for this coding contest problem. Lunar New Year is approaching, and you bought a matrix with lots of "crosses". This matrix M of size n Γ— n contains only 'X' and '.' (without quotes). The element in the i-th row and the j-th column (i, j) is defined as M(i, j), where 1 ≀ i...
instruction
0
19,470
23
38,940
Tags: implementation Correct Solution: ``` import sys data = sys.stdin.read().splitlines() n = int(data[0]) grid = [line for line in data[1:]] cnt = 0 for i in range(1, n - 1): for j in range(1, n - 1): if grid[i][j] == grid[i - 1][j - 1] == grid[i - 1][j + 1] == grid[i + 1][j - 1] == gri...
output
1
19,470
23
38,941
Provide tags and a correct Python 3 solution for this coding contest problem. Lunar New Year is approaching, and you bought a matrix with lots of "crosses". This matrix M of size n Γ— n contains only 'X' and '.' (without quotes). The element in the i-th row and the j-th column (i, j) is defined as M(i, j), where 1 ≀ i...
instruction
0
19,471
23
38,942
Tags: implementation Correct Solution: ``` n = int(input()) m = [] for _ in range(n): tmp = input() m.append(tmp) # print(n,m[0][0]) res = 0 def check(i,j): return m[i-1][j-1]=='X' and m[i-1][j+1]=='X' and m[i+1][j-1]== 'X' and m[i+1][j+1]=='X' for i in range(1,n-1): for j in range(1,n-1): if m...
output
1
19,471
23
38,943
Provide tags and a correct Python 3 solution for this coding contest problem. Lunar New Year is approaching, and you bought a matrix with lots of "crosses". This matrix M of size n Γ— n contains only 'X' and '.' (without quotes). The element in the i-th row and the j-th column (i, j) is defined as M(i, j), where 1 ≀ i...
instruction
0
19,472
23
38,944
Tags: implementation Correct Solution: ``` n=int(input()) M=[input() for i in range(n)] ANS=0 for i in range(1,n-1): for j in range(1,n-1): if M[i][j]==M[i-1][j-1]==M[i-1][j+1]==M[i+1][j-1]==M[i+1][j+1]=="X": ANS+=1 print(ANS) ```
output
1
19,472
23
38,945
Provide tags and a correct Python 3 solution for this coding contest problem. Lunar New Year is approaching, and you bought a matrix with lots of "crosses". This matrix M of size n Γ— n contains only 'X' and '.' (without quotes). The element in the i-th row and the j-th column (i, j) is defined as M(i, j), where 1 ≀ i...
instruction
0
19,473
23
38,946
Tags: implementation Correct Solution: ``` n = int(input()) m = [ input() for i in range(n)] c=0 for i in range(1,n-1): for j in range(1,n-1): if m[i][j] == 'X' and m[i-1][j-1]=='X' and m[i+1][j-1]=='X' and m[i-1][j+1]=='X' and m[i+1][j+1]=='X': c+=1 print(c) ```
output
1
19,473
23
38,947
Provide tags and a correct Python 3 solution for this coding contest problem. Lunar New Year is approaching, and you bought a matrix with lots of "crosses". This matrix M of size n Γ— n contains only 'X' and '.' (without quotes). The element in the i-th row and the j-th column (i, j) is defined as M(i, j), where 1 ≀ i...
instruction
0
19,474
23
38,948
Tags: implementation Correct Solution: ``` def rlist(): return list(map(int, input().split())) def rdi(): return int(input()) n = rdi() line = list() for i in range(n): line.append(input()) cnt = 0 for i in range(1, n - 1): for j in range(1, n - 1): if line[i][j] == line[i - 1][j - 1] == line[i - 1][j ...
output
1
19,474
23
38,949
Provide tags and a correct Python 3 solution for this coding contest problem. Lunar New Year is approaching, and you bought a matrix with lots of "crosses". This matrix M of size n Γ— n contains only 'X' and '.' (without quotes). The element in the i-th row and the j-th column (i, j) is defined as M(i, j), where 1 ≀ i...
instruction
0
19,475
23
38,950
Tags: implementation Correct Solution: ``` from sys import stdin,stdout from itertools import combinations from collections import defaultdict def listIn(): return list((map(int,stdin.readline().strip().split()))) def stringListIn(): return([x for x in stdin.readline().split()]) def intIn(): return (...
output
1
19,475
23
38,951
Provide tags and a correct Python 3 solution for this coding contest problem. Lunar New Year is approaching, and you bought a matrix with lots of "crosses". This matrix M of size n Γ— n contains only 'X' and '.' (without quotes). The element in the i-th row and the j-th column (i, j) is defined as M(i, j), where 1 ≀ i...
instruction
0
19,476
23
38,952
Tags: implementation Correct Solution: ``` #A - CrossCounting number = int(input()) mat = [] ans = 0 for i in range(number): mat.append(' '.join(input()).split()) for i in range(1,number-1): for j in range(1,number-1): if mat[i][j] == "X": if mat[i-1][j-1] == "X": if mat[i-1]...
output
1
19,476
23
38,953
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Lunar New Year is approaching, and you bought a matrix with lots of "crosses". This matrix M of size n Γ— n contains only 'X' and '.' (without quotes). The element in the i-th row and the j-th c...
instruction
0
19,477
23
38,954
Yes
output
1
19,477
23
38,955
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Lunar New Year is approaching, and you bought a matrix with lots of "crosses". This matrix M of size n Γ— n contains only 'X' and '.' (without quotes). The element in the i-th row and the j-th c...
instruction
0
19,478
23
38,956
Yes
output
1
19,478
23
38,957
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Lunar New Year is approaching, and you bought a matrix with lots of "crosses". This matrix M of size n Γ— n contains only 'X' and '.' (without quotes). The element in the i-th row and the j-th c...
instruction
0
19,479
23
38,958
Yes
output
1
19,479
23
38,959
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Lunar New Year is approaching, and you bought a matrix with lots of "crosses". This matrix M of size n Γ— n contains only 'X' and '.' (without quotes). The element in the i-th row and the j-th c...
instruction
0
19,480
23
38,960
Yes
output
1
19,480
23
38,961
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Lunar New Year is approaching, and you bought a matrix with lots of "crosses". This matrix M of size n Γ— n contains only 'X' and '.' (without quotes). The element in the i-th row and the j-th c...
instruction
0
19,481
23
38,962
No
output
1
19,481
23
38,963
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Lunar New Year is approaching, and you bought a matrix with lots of "crosses". This matrix M of size n Γ— n contains only 'X' and '.' (without quotes). The element in the i-th row and the j-th c...
instruction
0
19,482
23
38,964
No
output
1
19,482
23
38,965
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Lunar New Year is approaching, and you bought a matrix with lots of "crosses". This matrix M of size n Γ— n contains only 'X' and '.' (without quotes). The element in the i-th row and the j-th c...
instruction
0
19,483
23
38,966
No
output
1
19,483
23
38,967
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Lunar New Year is approaching, and you bought a matrix with lots of "crosses". This matrix M of size n Γ— n contains only 'X' and '.' (without quotes). The element in the i-th row and the j-th c...
instruction
0
19,484
23
38,968
No
output
1
19,484
23
38,969
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Sereja painted n points on the plane, point number i (1 ≀ i ≀ n) has coordinates (i, 0). Then Sereja marked each point with a small or large English letter. Sereja don't like letter "x", so he d...
instruction
0
19,730
23
39,460
No
output
1
19,730
23
39,461
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N boxes arranged in a circle. The i-th box contains A_i stones. Determine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operati...
instruction
0
20,155
23
40,310
Yes
output
1
20,155
23
40,311
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N boxes arranged in a circle. The i-th box contains A_i stones. Determine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operati...
instruction
0
20,158
23
40,316
No
output
1
20,158
23
40,317
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N boxes arranged in a circle. The i-th box contains A_i stones. Determine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operati...
instruction
0
20,160
23
40,320
No
output
1
20,160
23
40,321
Provide tags and a correct Python 3 solution for this coding contest problem. Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordin...
instruction
0
20,264
23
40,528
Tags: brute force, implementation, math, sortings Correct Solution: ``` n = int(input()) a = [int(v) for v in input().split()] a.sort() ans = (a[-1] - a[n]) * (a[n - 1] - a[0]) for i in range(1, n): ans = min(ans, (a[-1] - a[0]) * (a[i + n - 1] - a[i])) print(ans) ```
output
1
20,264
23
40,529
Provide tags and a correct Python 3 solution for this coding contest problem. Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordin...
instruction
0
20,265
23
40,530
Tags: brute force, implementation, math, sortings Correct Solution: ``` n=int(input()) a=sorted(map(int,input().split())) print(min([(a[n-1]-a[0])*(a[-1]-a[n])]+[(a[-1]-a[0])*(y-x) for x,y in zip(a,a[n-1:])])) ```
output
1
20,265
23
40,531
Provide tags and a correct Python 3 solution for this coding contest problem. Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordin...
instruction
0
20,266
23
40,532
Tags: brute force, implementation, math, sortings Correct Solution: ``` n=int(input()) a=sorted(map(int,input().split())) r=0 if n>1:r=min((a[n-1]-a[0])*(a[-1]-a[n]),(a[-1]-a[0])*min(y-x for x,y in zip(a[1:],a[n:-1]))) print(r) ```
output
1
20,266
23
40,533
Provide tags and a correct Python 3 solution for this coding contest problem. Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordin...
instruction
0
20,267
23
40,534
Tags: brute force, implementation, math, sortings Correct Solution: ``` def main(): n = int(input()) a = [int(i) for i in input().split()] a.sort() x = a[n - 1] - a[0] y = a[2 * n - 1] - a[n] c1 = x * y x = a[2 * n - 1] - a[0] for i in range(1, n): c1 = min(c1, x * (a[i + n ...
output
1
20,267
23
40,535
Provide tags and a correct Python 3 solution for this coding contest problem. Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordin...
instruction
0
20,268
23
40,536
Tags: brute force, implementation, math, sortings Correct Solution: ``` n = int(input()) a = sorted(list(map(int, input().split()))) res = (a[n-1] - a[0])*(a[-1] - a[n]) for i in range(1, n): if (a[-1] - a[0])*(a[n + i - 1] - a[i]) < res: res = (a[-1] - a[0])*(a[n + i - 1] - a[i]) print(res) ```
output
1
20,268
23
40,537
Provide tags and a correct Python 3 solution for this coding contest problem. Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordin...
instruction
0
20,269
23
40,538
Tags: brute force, implementation, math, sortings Correct Solution: ``` n = int(input()) a = list(map(int, input().split())) a.sort() s1 = (a[n-1]-a[0])*(a[-1]-a[n]) tmp = a[-1] - a[0] for i in range(1, n): if tmp * (a[n+i-1]-a[i]) < s1: s1 = tmp * (a[n+i-1]-a[i]) print(s1) ```
output
1
20,269
23
40,539
Provide tags and a correct Python 3 solution for this coding contest problem. Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordin...
instruction
0
20,270
23
40,540
Tags: brute force, implementation, math, sortings Correct Solution: ``` n=int(input()) a=list(map(int,input().split())) a.sort() k=12122121212121 for i in range(1,n): k=min(k,a[i+n-1]-a[i]) k=k*(a[2*n-1]-a[0]) z=abs(a[0]-a[n-1])*abs(a[n]-a[2*n-1]) print(min(k,z)) ```
output
1
20,270
23
40,541
Provide tags and a correct Python 3 solution for this coding contest problem. Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordin...
instruction
0
20,271
23
40,542
Tags: brute force, implementation, math, sortings Correct Solution: ``` n = int(input()) records = list(map(int,input().split())) records.sort() diffArr = [] for i in range(n+1): if i == 0: diffArr.append([records[n-1]-records[0],records[-1]-records[n]]) elif i == n: diffArr.append([records[-1]-records[n],recor...
output
1
20,271
23
40,543
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaki...
instruction
0
20,272
23
40,544
Yes
output
1
20,272
23
40,545
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaki...
instruction
0
20,273
23
40,546
Yes
output
1
20,273
23
40,547
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaki...
instruction
0
20,274
23
40,548
Yes
output
1
20,274
23
40,549
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaki...
instruction
0
20,275
23
40,550
Yes
output
1
20,275
23
40,551
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaki...
instruction
0
20,276
23
40,552
No
output
1
20,276
23
40,553
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaki...
instruction
0
20,277
23
40,554
No
output
1
20,277
23
40,555
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaki...
instruction
0
20,278
23
40,556
No
output
1
20,278
23
40,557
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaki...
instruction
0
20,279
23
40,558
No
output
1
20,279
23
40,559
Provide tags and a correct Python 3 solution for this coding contest problem. Like any unknown mathematician, Yuri has favourite numbers: A, B, C, and D, where A ≀ B ≀ C ≀ D. Yuri also likes triangles and once he thought: how many non-degenerate triangles with integer sides x, y, and z exist, such that A ≀ x ≀ B ≀ y ≀...
instruction
0
20,420
23
40,840
Tags: binary search, implementation, math, two pointers Correct Solution: ``` import sys input = sys.stdin.readline def sum1(x): k = min(d, c + x - 1, b + x - 1) if k < c: return 0 else: return (c - b + 1) * (k - c + 1) def sum2(x): k = min(d, c + x - 1) l = max(b + x, c) if k < l: return(0) else: re...
output
1
20,420
23
40,841