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 a correct Python 3 solution for this coding contest problem. For given $N$ points in the 2D Euclidean plane, find the distance of the shortest tour that meets the following criteria: * Visit the points according to the following steps: 1. It starts from the leftmost point (starting point), goes strictly from ...
instruction
0
4,137
23
8,274
"Correct Solution: ``` import sys sys.setrecursionlimit(1000000) def calc(p1, p2, v): dists_v = dists[v] if v == n - 1: return dists_v[p1] + dists_v[p2] if visited[p1][p2]: return dp[p1][p2] dp[p1][p2] = min(dists_v[p1] + calc(p2, v, v + 1), dists_v[p2] + calc(p1, v, v + 1)) visited...
output
1
4,137
23
8,275
Provide a correct Python 3 solution for this coding contest problem. For given $N$ points in the 2D Euclidean plane, find the distance of the shortest tour that meets the following criteria: * Visit the points according to the following steps: 1. It starts from the leftmost point (starting point), goes strictly from ...
instruction
0
4,138
23
8,276
"Correct Solution: ``` #!python3 import sys from math import sqrt sys.setrecursionlimit(1000000) iim = lambda: map(int, input().rstrip().split()) def resolve(): N = int(input()) P = [list(iim()) for i in range(N)] def dist(i, j): x = P[i][0] - P[j][0] y = P[i][1] - P[j][1] retur...
output
1
4,138
23
8,277
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. For given $N$ points in the 2D Euclidean plane, find the distance of the shortest tour that meets the following criteria: * Visit the points according to the following steps: 1. It starts from ...
instruction
0
4,139
23
8,278
No
output
1
4,139
23
8,279
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. For given $N$ points in the 2D Euclidean plane, find the distance of the shortest tour that meets the following criteria: * Visit the points according to the following steps: 1. It starts from ...
instruction
0
4,140
23
8,280
No
output
1
4,140
23
8,281
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are a set of points S on the plane. This set doesn't contain the origin O(0, 0), and for each two distinct points in the set A and B, the triangle OAB has strictly positive area. Consider...
instruction
0
4,532
23
9,064
No
output
1
4,532
23
9,065
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. An n × n square matrix is special, if: * it is binary, that is, each cell contains either a 0, or a 1; * the number of ones in each row and column equals 2. You are given n and the fir...
instruction
0
4,592
23
9,184
No
output
1
4,592
23
9,185
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. An n × n square matrix is special, if: * it is binary, that is, each cell contains either a 0, or a 1; * the number of ones in each row and column equals 2. You are given n and the fir...
instruction
0
4,593
23
9,186
No
output
1
4,593
23
9,187
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. An n × n square matrix is special, if: * it is binary, that is, each cell contains either a 0, or a 1; * the number of ones in each row and column equals 2. You are given n and the fir...
instruction
0
4,594
23
9,188
No
output
1
4,594
23
9,189
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. An n × n square matrix is special, if: * it is binary, that is, each cell contains either a 0, or a 1; * the number of ones in each row and column equals 2. You are given n and the fir...
instruction
0
4,595
23
9,190
No
output
1
4,595
23
9,191
Provide a correct Python 3 solution for this coding contest problem. Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so. Constraints * 1 ≤ length of the side ≤ 1,000 * N ≤ 1,000 Input Input consists...
instruction
0
4,931
23
9,862
"Correct Solution: ``` n=int(input()) a_list=[] for i in range(n): k=list(map(int,input().split(" "))) L,M,N=sorted(k) if L**2+M**2==N**2: a_list.append("YES") else: a_list.append("NO") for i in a_list: print(i) ```
output
1
4,931
23
9,863
Provide a correct Python 3 solution for this coding contest problem. Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so. Constraints * 1 ≤ length of the side ≤ 1,000 * N ≤ 1,000 Input Input consists...
instruction
0
4,932
23
9,864
"Correct Solution: ``` n=int(input()) for i in range(n): x=list(map(int,input().split())) a,b,c=sorted(x) if a**2+b**2==c**2: print('YES') else: print('NO') ```
output
1
4,932
23
9,865
Provide a correct Python 3 solution for this coding contest problem. Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so. Constraints * 1 ≤ length of the side ≤ 1,000 * N ≤ 1,000 Input Input consists...
instruction
0
4,933
23
9,866
"Correct Solution: ``` num=int(input()) for i in range(num): a=list(map(int,input().split(" "))) a.sort() if(a[0]**2+a[1]**2==a[2]**2): print("YES") else: print("NO") ```
output
1
4,933
23
9,867
Provide a correct Python 3 solution for this coding contest problem. Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so. Constraints * 1 ≤ length of the side ≤ 1,000 * N ≤ 1,000 Input Input consists...
instruction
0
4,934
23
9,868
"Correct Solution: ``` n = int(input()) for _ in range(n): a, b, c = sorted([int(x) for x in input().split()]) if c*c == b*b + a*a: print("YES") else: print("NO") ```
output
1
4,934
23
9,869
Provide a correct Python 3 solution for this coding contest problem. Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so. Constraints * 1 ≤ length of the side ≤ 1,000 * N ≤ 1,000 Input Input consists...
instruction
0
4,935
23
9,870
"Correct Solution: ``` n=int(input()) r=[sorted(list(map(int,input().split()))) for _ in range(n)] for i in range(n): if r[i][0]**2+r[i][1]**2==r[i][2]**2: print('YES') else: print('NO') ```
output
1
4,935
23
9,871
Provide a correct Python 3 solution for this coding contest problem. Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so. Constraints * 1 ≤ length of the side ≤ 1,000 * N ≤ 1,000 Input Input consists...
instruction
0
4,936
23
9,872
"Correct Solution: ``` n = int(input()) for _ in range(n): tr = list(map(int, input().split())) c = max(tr) tr.remove(c) wa = sum(map((lambda x: x**2), tr)) if c**2 == wa: print('YES') else: print('NO') ```
output
1
4,936
23
9,873
Provide a correct Python 3 solution for this coding contest problem. Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so. Constraints * 1 ≤ length of the side ≤ 1,000 * N ≤ 1,000 Input Input consists...
instruction
0
4,937
23
9,874
"Correct Solution: ``` line = int(input()) for i in range(line): a,b,c = sorted([int(i) for i in input().split(' ')]) if a**2 + b**2 == c**2: print('YES') else: print('NO') ```
output
1
4,937
23
9,875
Provide a correct Python 3 solution for this coding contest problem. Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so. Constraints * 1 ≤ length of the side ≤ 1,000 * N ≤ 1,000 Input Input consists...
instruction
0
4,938
23
9,876
"Correct Solution: ``` for _ in range(int(input())): x = list(sorted(map(int, input().split()))) print("YES" if x[0]**2 + x[1]**2 == x[2]**2 else "NO") ```
output
1
4,938
23
9,877
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so. Constraints * 1 ≤ lengt...
instruction
0
4,939
23
9,878
Yes
output
1
4,939
23
9,879
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so. Constraints * 1 ≤ lengt...
instruction
0
4,940
23
9,880
Yes
output
1
4,940
23
9,881
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so. Constraints * 1 ≤ lengt...
instruction
0
4,944
23
9,888
No
output
1
4,944
23
9,889
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so. Constraints * 1 ≤ lengt...
instruction
0
4,945
23
9,890
No
output
1
4,945
23
9,891
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so. Constraints * 1 ≤ lengt...
instruction
0
4,946
23
9,892
No
output
1
4,946
23
9,893
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. One day Vasya came up to the blackboard and wrote out n distinct integers from 1 to n in some order in a circle. Then he drew arcs to join the pairs of integers (a, b) (a ≠ b), that are either e...
instruction
0
5,303
23
10,606
No
output
1
5,303
23
10,607
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. One day Vasya came up to the blackboard and wrote out n distinct integers from 1 to n in some order in a circle. Then he drew arcs to join the pairs of integers (a, b) (a ≠ b), that are either e...
instruction
0
5,304
23
10,608
No
output
1
5,304
23
10,609
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. One day Vasya came up to the blackboard and wrote out n distinct integers from 1 to n in some order in a circle. Then he drew arcs to join the pairs of integers (a, b) (a ≠ b), that are either e...
instruction
0
5,305
23
10,610
No
output
1
5,305
23
10,611
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. One day Vasya came up to the blackboard and wrote out n distinct integers from 1 to n in some order in a circle. Then he drew arcs to join the pairs of integers (a, b) (a ≠ b), that are either e...
instruction
0
5,306
23
10,612
No
output
1
5,306
23
10,613
Provide tags and a correct Python 3 solution for this coding contest problem. Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of...
instruction
0
5,355
23
10,710
Tags: brute force, implementation Correct Solution: ``` n = int(input()) seq = list(map(int, input().split())) if n == 1: print("no") exit(0) pairs = [] cur = [-1, seq[0]] fail = False for i in range(1, len(seq)): cur[0], cur[1] = cur[1], seq[i] if cur[1] < cur[0]: pairs.append([cur[1], cur[0]]) else: pairs...
output
1
5,355
23
10,711
Provide tags and a correct Python 3 solution for this coding contest problem. Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of...
instruction
0
5,356
23
10,712
Tags: brute force, implementation Correct Solution: ``` n = int(input()) Min = -1e10 Max = 1e10 ans = "no" def f(x, y): return x[0] < y[0] < x[1] < y[1] or \ y[0] < x[0] < y[1] < x[1] xs = list(map(int, input().split())) for i in range(1, len(xs) - 1): for j in range(0, i): if f([min(xs[i:i+2]), max(x...
output
1
5,356
23
10,713
Provide tags and a correct Python 3 solution for this coding contest problem. Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of...
instruction
0
5,357
23
10,714
Tags: brute force, implementation Correct Solution: ``` n,l=int(input()),list(map(int,input().split())) for i in range(n-1): for j in range(n-1): x=sorted([l[i],l[i+1]])+sorted([l[j],l[j+1]]) if x[0]<x[2]<x[1]<x[3]: exit(print('yes')) print('no') ```
output
1
5,357
23
10,715
Provide tags and a correct Python 3 solution for this coding contest problem. Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of...
instruction
0
5,358
23
10,716
Tags: brute force, implementation Correct Solution: ``` def self_intersect(points:list): for i in range(len(points)): check_point = points[i] for j in range(len(points)): if i != j: check_point2 = points[j] if check_point[0] < check_point2[0] < check_point...
output
1
5,358
23
10,717
Provide tags and a correct Python 3 solution for this coding contest problem. Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of...
instruction
0
5,359
23
10,718
Tags: brute force, implementation Correct Solution: ``` n = int(input()) arr = list(map(int, input().split())) flag = 0 for i in range(n-1): for j in range(i+1,n-1): a,b = min(arr[i],arr[i+1]),max(arr[i],arr[i+1]) c,d = min(arr[j],arr[j+1]),max(arr[j],arr[j+1]) if a<c<b<d or c<a<d<b: ...
output
1
5,359
23
10,719
Provide tags and a correct Python 3 solution for this coding contest problem. Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of...
instruction
0
5,360
23
10,720
Tags: brute force, implementation Correct Solution: ``` def intersect(p1,p2): if (p2[0] < p1[1] and p2[0] > p1[0] and p2[1] > p1[1]) or (p2[1] < p1[1] and p2[1] > p1[0] and p2[0] < p1[0]): return True return False def check(points): for x in range(len(points)): for i in range(x + 1,len(poin...
output
1
5,360
23
10,721
Provide tags and a correct Python 3 solution for this coding contest problem. Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of...
instruction
0
5,361
23
10,722
Tags: brute force, implementation Correct Solution: ``` #http://codeforces.com/problemset/problem/358/A #not accepted n = eval(input()) points = [(int)(i) for i in input().split()] poles = [] ''' left = 0 right = 0 prevDir = '-' currentDir = '-' ''' def is_intersect(points): if(n <= 2): return False; ...
output
1
5,361
23
10,723
Provide tags and a correct Python 3 solution for this coding contest problem. Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of...
instruction
0
5,362
23
10,724
Tags: brute force, implementation Correct Solution: ``` n = int(input()) x = [int(i) for i in input().split()] if (n < 3): print ('no') else: ans = 'no' for i in range(3, n): prev = x[i - 1] num = x[i] for j in range(i - 2): num1 = min(x[j], x[j + 1]) num2 = ...
output
1
5,362
23
10,725
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework...
instruction
0
5,363
23
10,726
Yes
output
1
5,363
23
10,727
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework...
instruction
0
5,364
23
10,728
Yes
output
1
5,364
23
10,729
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework...
instruction
0
5,365
23
10,730
Yes
output
1
5,365
23
10,731
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework...
instruction
0
5,366
23
10,732
Yes
output
1
5,366
23
10,733
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework...
instruction
0
5,367
23
10,734
No
output
1
5,367
23
10,735
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework...
instruction
0
5,368
23
10,736
No
output
1
5,368
23
10,737
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework...
instruction
0
5,369
23
10,738
No
output
1
5,369
23
10,739
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework...
instruction
0
5,370
23
10,740
No
output
1
5,370
23
10,741
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Petya is preparing for the first contact with aliens. He knows that alien spaceships have shapes of non-degenerate triangles and there will be exactly 4 ships. Landing platform for a ship...
instruction
0
5,478
23
10,956
No
output
1
5,478
23
10,957
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Petya is preparing for the first contact with aliens. He knows that alien spaceships have shapes of non-degenerate triangles and there will be exactly 4 ships. Landing platform for a ship...
instruction
0
5,479
23
10,958
No
output
1
5,479
23
10,959
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Petya is preparing for the first contact with aliens. He knows that alien spaceships have shapes of non-degenerate triangles and there will be exactly 4 ships. Landing platform for a ship...
instruction
0
5,480
23
10,960
No
output
1
5,480
23
10,961
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Petya is preparing for the first contact with aliens. He knows that alien spaceships have shapes of non-degenerate triangles and there will be exactly 4 ships. Landing platform for a ship...
instruction
0
5,481
23
10,962
No
output
1
5,481
23
10,963
Provide tags and a correct Python 3 solution for this coding contest problem. Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single se...
instruction
0
5,482
23
10,964
Tags: greedy, math Correct Solution: ``` def get_next(T): [a,b,c] = sorted(T) return [b,c,b+c-1] def main(): y,x = [int(s) for s in input().split()] T = [x,x,x] i = 0 while max(T) < y: T = get_next(T) i += 1 print(2+i) main() ```
output
1
5,482
23
10,965
Provide tags and a correct Python 3 solution for this coding contest problem. Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single se...
instruction
0
5,483
23
10,966
Tags: greedy, math Correct Solution: ``` import math x, y = map(int, input().split()) res = 0 now = [y, y, y] while min(now) < x: res += 1 ind = now.index(min(now)) o1, o2 = (ind + 1) % 3, (ind + 2) % 3 now[ind] = now[o1] + now[o2] - 1 print(res) ```
output
1
5,483
23
10,967
Provide tags and a correct Python 3 solution for this coding contest problem. Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single se...
instruction
0
5,484
23
10,968
Tags: greedy, math Correct Solution: ``` # (a[0], a[1], a[2]) => (y, y, y) def triangle(a, y, prt=False): if min(a) >= y: return 0 elif a[1] + a[2] - 1 >= y: return triangle([a[1], a[2], y], y) + 1 else: return triangle([a[1], a[2], a[1] + a[2] - 1], y) + 1 def main(): x, y = l...
output
1
5,484
23
10,969
Provide tags and a correct Python 3 solution for this coding contest problem. Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single se...
instruction
0
5,485
23
10,970
Tags: greedy, math Correct Solution: ``` b,a=map(int,input().split()) t=0 s=[a,a,a] while min(s)<b: x=min(s) if s[0]==x: s[0]=min(s[1]+s[2]-1,b) elif s[1]==x: s[1]=min(s[0]+s[2]-1,b) else: s[2]=min(s[0]+s[1]-1,b) t+=1 print(t) ```
output
1
5,485
23
10,971