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.
We will consider the numbers a and b as adjacent if they differ by exactly one, that is, |a-b|=1.
We will consider cells of a square matrix n × n as adjacent if they have a common side, that is... | instruction | 0 | 70,987 | 23 | 141,974 |
Yes | output | 1 | 70,987 | 23 | 141,975 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We will consider the numbers a and b as adjacent if they differ by exactly one, that is, |a-b|=1.
We will consider cells of a square matrix n × n as adjacent if they have a common side, that is... | instruction | 0 | 70,989 | 23 | 141,978 |
No | output | 1 | 70,989 | 23 | 141,979 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We will consider the numbers a and b as adjacent if they differ by exactly one, that is, |a-b|=1.
We will consider cells of a square matrix n × n as adjacent if they have a common side, that is... | instruction | 0 | 70,990 | 23 | 141,980 |
No | output | 1 | 70,990 | 23 | 141,981 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We will consider the numbers a and b as adjacent if they differ by exactly one, that is, |a-b|=1.
We will consider cells of a square matrix n × n as adjacent if they have a common side, that is... | instruction | 0 | 70,991 | 23 | 141,982 |
No | output | 1 | 70,991 | 23 | 141,983 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We will consider the numbers a and b as adjacent if they differ by exactly one, that is, |a-b|=1.
We will consider cells of a square matrix n × n as adjacent if they have a common side, that is... | instruction | 0 | 70,992 | 23 | 141,984 |
No | output | 1 | 70,992 | 23 | 141,985 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program that reads the coordinates of the vertices of a convex n-sided polygon (a polygon whose internal angles are less than 180 degrees, that is, a polygon that is not dented) and outputs its area. The vertices are named Vertex 1, Vertex 2,... | instruction | 0 | 71,495 | 23 | 142,990 |
"Correct Solution:
```
p= []
try:
while True:
x,y = map(float,input().split(","))
p.append(complex(x,y))
except EOFError:
pass
n=len(p)
sum=0.0
for i in range(1,n-1):
a,b= p[i]-p[0], p[i+1]-p[0]
s= (a.conjugate()* b).imag
sum+= s
print("%.6f" % (abs(sum)/2.0))
``` | output | 1 | 71,495 | 23 | 142,991 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program that reads the coordinates of the vertices of a convex n-sided polygon (a polygon whose internal angles are less than 180 degrees, that is, a polygon that is not dented) and outputs its area. The vertices are named Vertex 1, Vertex 2,... | instruction | 0 | 71,496 | 23 | 142,992 |
"Correct Solution:
```
# coding=utf-8
###
### for python program
###
import sys
import math
# math class
class mymath:
### pi
pi = 3.14159265358979323846264338
### Prime Number
def pnum_eratosthenes(self, n):
ptable = [0 for i in range(n+1)]
plist = []
for i in range(2, n+1)... | output | 1 | 71,496 | 23 | 142,993 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program that reads the coordinates of the vertices of a convex n-sided polygon (a polygon whose internal angles are less than 180 degrees, that is, a polygon that is not dented) and outputs its area. The vertices are named Vertex 1, Vertex 2,... | instruction | 0 | 71,497 | 23 | 142,994 |
"Correct Solution:
```
import math
f = []
while True:
try:
st = input().strip().split(',')
x,y = list(map(float,st ))
f.append(x + y*1j)
except EOFError:
break
px = [p.real for p in f]
ox = (max(px) + min(px)) / 2.0
py = [p.imag for p in f]
oy = (max(py) + min(py)) / 2.0
fo = ... | output | 1 | 71,497 | 23 | 142,995 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program that reads the coordinates of the vertices of a convex n-sided polygon (a polygon whose internal angles are less than 180 degrees, that is, a polygon that is not dented) and outputs its area. The vertices are named Vertex 1, Vertex 2,... | instruction | 0 | 71,498 | 23 | 142,996 |
"Correct Solution:
```
import sys,math
l=[list(map(float,i.split(","))) for i in sys.stdin]
S=0
for (i,j) in enumerate(l):
xn,yn=j
if i!=len(l)-1:
xn_1,yn_1=l[i+1]
else:
xn_1,yn_1=l[0]
a=math.sqrt(xn**2+yn**2)
b=math.sqrt(xn_1**2+yn_1**2)
c=math.sqrt((xn_1-xn)**2+(yn_1-yn)**2)
... | output | 1 | 71,498 | 23 | 142,997 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program that reads the coordinates of the vertices of a convex n-sided polygon (a polygon whose internal angles are less than 180 degrees, that is, a polygon that is not dented) and outputs its area. The vertices are named Vertex 1, Vertex 2,... | instruction | 0 | 71,499 | 23 | 142,998 |
"Correct Solution:
```
import math
def calc_d(a, b):
return math.sqrt((a[0] - b[0])**2 + (a[1] - b[1])**2)
p = []
while True:
try:
p.append(list(map(float, input().split(","))))
except:
break
n = len(p)
s = 0
for i in range(1, n - 1):
a = calc_d(p[0], p[i])
b = calc_d(p[0], p[i+1]... | output | 1 | 71,499 | 23 | 142,999 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program that reads the coordinates of the vertices of a convex n-sided polygon (a polygon whose internal angles are less than 180 degrees, that is, a polygon that is not dented) and outputs its area. The vertices are named Vertex 1, Vertex 2,... | instruction | 0 | 71,500 | 23 | 143,000 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0079
"""
import sys
from math import sqrt, atan2, acos, sin, cos, hypot
from sys import stdin
input = stdin.readline
class Point(object):
epsilon = 1e-10
def __init__(self, x=0.0, y=0.0):
if i... | output | 1 | 71,500 | 23 | 143,001 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program that reads the coordinates of the vertices of a convex n-sided polygon (a polygon whose internal angles are less than 180 degrees, that is, a polygon that is not dented) and outputs its area. The vertices are named Vertex 1, Vertex 2,... | instruction | 0 | 71,501 | 23 | 143,002 |
"Correct Solution:
```
def op(u,v):
return (complex.conjugate(u)*v).imag
f = []
while True:
try:
st = input().strip().split(',')
x,y = list(map(float,st ))
f.append(x + y*1j)
except EOFError:
break
s = 0.0
fo = f[0]
for j in range(2,len(f)):
i = j - 1
s += op(f[i]-f... | output | 1 | 71,501 | 23 | 143,003 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program that reads the coordinates of the vertices of a convex n-sided polygon (a polygon whose internal angles are less than 180 degrees, that is, a polygon that is not dented) and outputs its area. The vertices are named Vertex 1, Vertex 2,... | instruction | 0 | 71,502 | 23 | 143,004 |
"Correct Solution:
```
def solve():
from sys import stdin
lines = stdin
x1, y1 = map(float, lines.readline().split(','))
x2, y2 = map(float, lines.readline().split(','))
vx1 = x2 - x1
vy1 = y2 - y1
area = 0
for line in lines:
x3, y3 = map(float, line.split(','))
... | output | 1 | 71,502 | 23 | 143,005 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program that reads the coordinates of the vertices of a convex n-sided polygon (a polygon whose internal angles are less than 180 degrees, that is, a polygon that is not dented) and outp... | instruction | 0 | 71,503 | 23 | 143,006 |
Yes | output | 1 | 71,503 | 23 | 143,007 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program that reads the coordinates of the vertices of a convex n-sided polygon (a polygon whose internal angles are less than 180 degrees, that is, a polygon that is not dented) and outp... | instruction | 0 | 71,504 | 23 | 143,008 |
Yes | output | 1 | 71,504 | 23 | 143,009 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program that reads the coordinates of the vertices of a convex n-sided polygon (a polygon whose internal angles are less than 180 degrees, that is, a polygon that is not dented) and outp... | instruction | 0 | 71,505 | 23 | 143,010 |
Yes | output | 1 | 71,505 | 23 | 143,011 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program that reads the coordinates of the vertices of a convex n-sided polygon (a polygon whose internal angles are less than 180 degrees, that is, a polygon that is not dented) and outp... | instruction | 0 | 71,506 | 23 | 143,012 |
Yes | output | 1 | 71,506 | 23 | 143,013 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program that reads the coordinates of the vertices of a convex n-sided polygon (a polygon whose internal angles are less than 180 degrees, that is, a polygon that is not dented) and outp... | instruction | 0 | 71,507 | 23 | 143,014 |
No | output | 1 | 71,507 | 23 | 143,015 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program that reads the coordinates of the vertices of a convex n-sided polygon (a polygon whose internal angles are less than 180 degrees, that is, a polygon that is not dented) and outp... | instruction | 0 | 71,508 | 23 | 143,016 |
No | output | 1 | 71,508 | 23 | 143,017 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program that reads the coordinates of the vertices of a convex n-sided polygon (a polygon whose internal angles are less than 180 degrees, that is, a polygon that is not dented) and outp... | instruction | 0 | 71,509 | 23 | 143,018 |
No | output | 1 | 71,509 | 23 | 143,019 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program that reads the coordinates of the vertices of a convex n-sided polygon (a polygon whose internal angles are less than 180 degrees, that is, a polygon that is not dented) and outp... | instruction | 0 | 71,510 | 23 | 143,020 |
No | output | 1 | 71,510 | 23 | 143,021 |
Provide a correct Python 3 solution for this coding contest problem.
For given n points in metric space, find the distance of the closest points.
Constraints
* 2 ≤ n ≤ 100,000
* -100 ≤ x, y ≤ 100
Input
n
x0 y0
x1 y1
:
xn-1 yn-1
The first integer n is the number of points.
In the following n lines, the coordina... | instruction | 0 | 71,597 | 23 | 143,194 |
"Correct Solution:
```
import sys
from operator import itemgetter
from itertools import combinations, takewhile
from math import sqrt
def solve(a: list, sorted_axis: int = -1):
length = len(a)
if length <= 3:
return sqrt(min((x1-x2)**2+(y1-y2)**2 for (x1, y1), (x2, y2) in combinations(a, 2)))
x_se... | output | 1 | 71,597 | 23 | 143,195 |
Provide a correct Python 3 solution for this coding contest problem.
For given n points in metric space, find the distance of the closest points.
Constraints
* 2 ≤ n ≤ 100,000
* -100 ≤ x, y ≤ 100
Input
n
x0 y0
x1 y1
:
xn-1 yn-1
The first integer n is the number of points.
In the following n lines, the coordina... | instruction | 0 | 71,598 | 23 | 143,196 |
"Correct Solution:
```
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
3
0.0 0.0
2.0 0.0
1.0 1.0
output:
1.41421356237
"""
import sys
from operator import attrgetter
class ClosestPair(object):
def __init__(self, in_data):
"""
Init closest pairs points set.
"""
self.p_nu... | output | 1 | 71,598 | 23 | 143,197 |
Provide a correct Python 3 solution for this coding contest problem.
For given n points in metric space, find the distance of the closest points.
Constraints
* 2 ≤ n ≤ 100,000
* -100 ≤ x, y ≤ 100
Input
n
x0 y0
x1 y1
:
xn-1 yn-1
The first integer n is the number of points.
In the following n lines, the coordina... | instruction | 0 | 71,599 | 23 | 143,198 |
"Correct Solution:
```
import itertools
def _get_distance(p1, p2):
return ((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) ** 0.5
def _get_min_distance(points):
min_d = 400
for p1, p2 in itertools.combinations(points, 2):
min_d = min(min_d, _get_distance(p1, p2))
return min_d
def closest_pair_di... | output | 1 | 71,599 | 23 | 143,199 |
Provide a correct Python 3 solution for this coding contest problem.
For given n points in metric space, find the distance of the closest points.
Constraints
* 2 ≤ n ≤ 100,000
* -100 ≤ x, y ≤ 100
Input
n
x0 y0
x1 y1
:
xn-1 yn-1
The first integer n is the number of points.
In the following n lines, the coordina... | instruction | 0 | 71,600 | 23 | 143,200 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
"""
Closest Pair
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_5_A&lang=ja
TLE
"""
import sys
from collections import deque
def closest_pair(points):
return find_closest(sorted(points)) ** 0.5
def find_closest(points):
n = len(points)
if n <= ... | output | 1 | 71,600 | 23 | 143,201 |
Provide a correct Python 3 solution for this coding contest problem.
For given n points in metric space, find the distance of the closest points.
Constraints
* 2 ≤ n ≤ 100,000
* -100 ≤ x, y ≤ 100
Input
n
x0 y0
x1 y1
:
xn-1 yn-1
The first integer n is the number of points.
In the following n lines, the coordina... | instruction | 0 | 71,602 | 23 | 143,204 |
"Correct Solution:
```
# 最近点対を分割統治法で求める
from math import sqrt
n = int(input())
ps = [list(map(float, input().strip().split())) for i in range(n)]
# print(ps)
# Q: なぜ、最初にx座標についてソートされている必要があるのか?
# A: 二つの区間が統合されるとき、dには2つの区間における最小2点間距離が入っており、
# 統合された区間における最小値は、それ以下を探索するようになっている。
# この時、各区間A:[i, i+m), B:[i+m, n)での最小値は、... | output | 1 | 71,602 | 23 | 143,205 |
Provide a correct Python 3 solution for this coding contest problem.
For given n points in metric space, find the distance of the closest points.
Constraints
* 2 ≤ n ≤ 100,000
* -100 ≤ x, y ≤ 100
Input
n
x0 y0
x1 y1
:
xn-1 yn-1
The first integer n is the number of points.
In the following n lines, the coordina... | instruction | 0 | 71,603 | 23 | 143,206 |
"Correct Solution:
```
import sys
from operator import itemgetter
from itertools import permutations
from math import sqrt
def solve(a: list):
length = len(a)
if length <= 3:
return min(sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2) for p1, p2 in permutations(a, 2))
x_set_len = len(set(x for (x, _) in a)... | output | 1 | 71,603 | 23 | 143,207 |
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 metric space, find the distance of the closest points.
Constraints
* 2 ≤ n ≤ 100,000
* -100 ≤ x, y ≤ 100
Input
n
x0 y0
x1 y1
:
xn-1 yn-1
The first integer n is the n... | instruction | 0 | 71,604 | 23 | 143,208 |
Yes | output | 1 | 71,604 | 23 | 143,209 |
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 metric space, find the distance of the closest points.
Constraints
* 2 ≤ n ≤ 100,000
* -100 ≤ x, y ≤ 100
Input
n
x0 y0
x1 y1
:
xn-1 yn-1
The first integer n is the n... | instruction | 0 | 71,605 | 23 | 143,210 |
Yes | output | 1 | 71,605 | 23 | 143,211 |
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 metric space, find the distance of the closest points.
Constraints
* 2 ≤ n ≤ 100,000
* -100 ≤ x, y ≤ 100
Input
n
x0 y0
x1 y1
:
xn-1 yn-1
The first integer n is the n... | instruction | 0 | 71,606 | 23 | 143,212 |
Yes | output | 1 | 71,606 | 23 | 143,213 |
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 metric space, find the distance of the closest points.
Constraints
* 2 ≤ n ≤ 100,000
* -100 ≤ x, y ≤ 100
Input
n
x0 y0
x1 y1
:
xn-1 yn-1
The first integer n is the n... | instruction | 0 | 71,607 | 23 | 143,214 |
Yes | output | 1 | 71,607 | 23 | 143,215 |
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 metric space, find the distance of the closest points.
Constraints
* 2 ≤ n ≤ 100,000
* -100 ≤ x, y ≤ 100
Input
n
x0 y0
x1 y1
:
xn-1 yn-1
The first integer n is the n... | instruction | 0 | 71,610 | 23 | 143,220 |
No | output | 1 | 71,610 | 23 | 143,221 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This problem is same as the previous one, but has larger constraints.
It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the... | instruction | 0 | 71,712 | 23 | 143,424 |
Tags: data structures, geometry, implementation, math
Correct Solution:
```
from collections import defaultdict as dd
from itertools import combinations
import math
import heapq
def nn():
return int(input())
def li():
return list(input())
def mi():
return map(int, input().split())
def lm():
return list(map(int, ... | output | 1 | 71,712 | 23 | 143,425 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This problem is same as the previous one, but has larger constraints.
It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the... | instruction | 0 | 71,714 | 23 | 143,428 |
Tags: data structures, geometry, implementation, math
Correct Solution:
```
from fractions import Fraction
VERT = object()
n = int(input())
points = [tuple(map(int, input().split())) for _ in range(n)]
d = {}
for i, p in enumerate(points):
x1, y1 = p
for x2, y2 in points[i + 1:]:
if x1 < x2:
... | output | 1 | 71,714 | 23 | 143,429 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This problem is same as the previous one, but has larger constraints.
It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the... | instruction | 0 | 71,717 | 23 | 143,434 |
Tags: data structures, geometry, implementation, math
Correct Solution:
```
from collections import defaultdict
import math
n = int(input().lstrip())
numbers = []
for _ in range(n):
numbers.append(list(map(int, input().lstrip().split())))
def gcd(a, b):
if not a:
return b
return gcd(b % a, a)
... | output | 1 | 71,717 | 23 | 143,435 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a convex polygon. Count, please, the number of triangles that contain a given point in the plane and their vertices are the vertices of the polygon. It is guaranteed, that the poin... | instruction | 0 | 72,066 | 23 | 144,132 |
No | output | 1 | 72,066 | 23 | 144,133 |
Provide tags and a correct Python 3 solution for this coding contest problem.
n evenly spaced points have been marked around the edge of a circle. There is a number written at each point. You choose a positive real number k. Then you may repeatedly select a set of 2 or more points which are evenly spaced, and either i... | instruction | 0 | 72,224 | 23 | 144,448 |
Tags: math
Correct Solution:
```
#Circle of Numbers
import math
def centre(n, pts):
x, y = 0, 0
for j in [7,11,13,17,19,23,29,31,37,1193,1663,2711,4007,65537]:
if math.gcd(n,j) == 1:
for i in range(n):
k = int(pts[i])
x += k*math.cos(math.pi * 2*i*j/n)
... | output | 1 | 72,224 | 23 | 144,449 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
n evenly spaced points have been marked around the edge of a circle. There is a number written at each point. You choose a positive real number k. Then you may repeatedly select a set of 2 or mo... | instruction | 0 | 72,225 | 23 | 144,450 |
No | output | 1 | 72,225 | 23 | 144,451 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
n evenly spaced points have been marked around the edge of a circle. There is a number written at each point. You choose a positive real number k. Then you may repeatedly select a set of 2 or mo... | instruction | 0 | 72,226 | 23 | 144,452 |
No | output | 1 | 72,226 | 23 | 144,453 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
n evenly spaced points have been marked around the edge of a circle. There is a number written at each point. You choose a positive real number k. Then you may repeatedly select a set of 2 or mo... | instruction | 0 | 72,227 | 23 | 144,454 |
No | output | 1 | 72,227 | 23 | 144,455 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
n evenly spaced points have been marked around the edge of a circle. There is a number written at each point. You choose a positive real number k. Then you may repeatedly select a set of 2 or mo... | instruction | 0 | 72,228 | 23 | 144,456 |
No | output | 1 | 72,228 | 23 | 144,457 |
Provide a correct Python 3 solution for this coding contest problem.
A crop circle suddenly appeared on the vast agricultural land of Argentina. A total of n crop circles were confirmed, including overlapping, popping, large, and small ones.
When a mystery hunter tried to capture the whole picture of a crop circle fr... | instruction | 0 | 72,444 | 23 | 144,888 |
"Correct Solution:
```
def string_to_float(s):
return list(map(float, s.split()))
def solve():
from sys import stdin
lines = stdin.readlines()
from itertools import combinations
from math import acos, pi
from cmath import phase
from bisect import insort
while True:
n = int(... | output | 1 | 72,444 | 23 | 144,889 |
Provide a correct Python 3 solution for this coding contest problem.
F: Grid number
problem
Ebi-chan is trying to write exactly one integer from 1 to 2 \ times n in a grid with n columns horizontally and 2 rows vertically.
Only one integer can be written to each cell in the grid.
It's not fun just to write normall... | instruction | 0 | 72,459 | 23 | 144,918 |
"Correct Solution:
```
from collections import Counter
N, K, mod = map(int, input().split())
dp = [Counter() for _ in range(2*N)]
dp[0][(None, (0,))] = 1
for i in range(2*N-1):
for (left, top), v in dp[i].items():
if len(top) > K+1:
continue
if left == None:
if top and i+1 -... | output | 1 | 72,459 | 23 | 144,919 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Your math teacher gave you the following problem:
There are n segments on the x-axis, [l_1; r_1], [l_2; r_2], …, [l_n; r_n]. The segment [l; r] includes the bounds, i.e. it is a set of such x that l ≤ x ≤ r. The length of the segment [l; r]... | instruction | 0 | 72,587 | 23 | 145,174 |
Tags: math
Correct Solution:
```
from sys import stdin
t = int(stdin.readline())
for q in range(t):
n = int(stdin.readline())
m1, m2 = 10**9+1, 0
for i in range(n):
l, r = map(int, stdin.readline().split())
m1 = min(m1, r)
m2 = max(m2, l)
print(max(0, m2 - m1))
``` | output | 1 | 72,587 | 23 | 145,175 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Your math teacher gave you the following problem:
There are n segments on the x-axis, [l_1; r_1], [l_2; r_2], …, [l_n; r_n]. The segment [l; r] includes the bounds, i.e. it is a set of such x that l ≤ x ≤ r. The length of the segment [l; r]... | instruction | 0 | 72,588 | 23 | 145,176 |
Tags: math
Correct Solution:
```
t = int(input())
otv = list()
for i in range(t):
x = 1
y = 1000000001
n = int(input())
for j in range(n):
a, b = map(int, input().split())
x = max(a, x)
y = min(b, y)
otv.append(max(0, x - y))
for i in otv:
print(i)
``` | output | 1 | 72,588 | 23 | 145,177 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Your math teacher gave you the following problem:
There are n segments on the x-axis, [l_1; r_1], [l_2; r_2], …, [l_n; r_n]. The segment [l; r] includes the bounds, i.e. it is a set of such x that l ≤ x ≤ r. The length of the segment [l; r]... | instruction | 0 | 72,589 | 23 | 145,178 |
Tags: math
Correct Solution:
```
for _ in range(int(input())):
n = int(input())
data = []
max_l = -1
min_r = 10 ** 10
for i in range(n):
l, r = map(int, input().split())
max_l = max(max_l, l)
min_r = min(min_r, r)
print(max(max_l - min_r, 0))
``` | output | 1 | 72,589 | 23 | 145,179 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Your math teacher gave you the following problem:
There are n segments on the x-axis, [l_1; r_1], [l_2; r_2], …, [l_n; r_n]. The segment [l; r] includes the bounds, i.e. it is a set of such x that l ≤ x ≤ r. The length of the segment [l; r]... | instruction | 0 | 72,590 | 23 | 145,180 |
Tags: math
Correct Solution:
```
t = int(input())
for i in range(t):
n = int(input())
arr = []
for k in range(n):
arr.append(tuple(map(int, input().split())))
l_max, r_min = arr[0][1], arr[0][0]
for l, r in arr:
if l_max > r:
l_max = r
if r_min < l:
r_... | output | 1 | 72,590 | 23 | 145,181 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Your math teacher gave you the following problem:
There are n segments on the x-axis, [l_1; r_1], [l_2; r_2], …, [l_n; r_n]. The segment [l; r] includes the bounds, i.e. it is a set of such x that l ≤ x ≤ r. The length of the segment [l; r]... | instruction | 0 | 72,591 | 23 | 145,182 |
Tags: math
Correct Solution:
```
z = int(input())
i = 0
sp = []
while i != z:
n = int(input())
ch = input().split(' ')
xmax = int(ch[0])
ymin = int(ch[1])
while n != 1:
ch = input().split(' ')
x = int(ch[0])
if x > xmax:
xmax = x
y = int(ch[1])
if ... | output | 1 | 72,591 | 23 | 145,183 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Your math teacher gave you the following problem:
There are n segments on the x-axis, [l_1; r_1], [l_2; r_2], …, [l_n; r_n]. The segment [l; r] includes the bounds, i.e. it is a set of such x that l ≤ x ≤ r. The length of the segment [l; r]... | instruction | 0 | 72,592 | 23 | 145,184 |
Tags: math
Correct Solution:
```
for _ in " "*int(int(input())):
z=0;z1=10**9
for i in range(int(input())):a,b=map(int,input().split());z=max(a,z);z1=min(b,z1)
print(max(0,z-z1))
``` | output | 1 | 72,592 | 23 | 145,185 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Your math teacher gave you the following problem:
There are n segments on the x-axis, [l_1; r_1], [l_2; r_2], …, [l_n; r_n]. The segment [l; r] includes the bounds, i.e. it is a set of such x that l ≤ x ≤ r. The length of the segment [l; r]... | instruction | 0 | 72,593 | 23 | 145,186 |
Tags: math
Correct Solution:
```
for i in range(int(input())):
a = []
b = []
for q in range(int(input())):
k = input().split()
a.append(int(k[0]))
b.append(int(k[1]))
print(int((abs(max(a) - min(b)) + max(a) - min(b)) / 2))
``` | output | 1 | 72,593 | 23 | 145,187 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.