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.
One day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (x1, y1), (x2, y2), ..., (xn, yn). Let's define neighbors for some fixed point from the given set (x, y):
* point (x', y') is (x, y)'s right neighbor, if x' > x and y' = y
* point (x', y') is (x, y)'s left neighbor, if x' < x and y' = y
* point (x', y') is (x, y)'s lower neighbor, if x' = x and y' < y
* point (x', y') is (x, y)'s upper neighbor, if x' = x and y' > y
We'll consider point (x, y) from the given set supercentral, if it has at least one upper, at least one lower, at least one left and at least one right neighbor among this set's points.
Vasya marked quite many points on the paper. Analyzing the picture manually is rather a challenge, so Vasya asked you to help him. Your task is to find the number of supercentral points in the given set.
Input
The first input line contains the only integer n (1 β€ n β€ 200) β the number of points in the given set. Next n lines contain the coordinates of the points written as "x y" (without the quotes) (|x|, |y| β€ 1000), all coordinates are integers. The numbers in the line are separated by exactly one space. It is guaranteed that all points are different.
Output
Print the only number β the number of supercentral points of the given set.
Examples
Input
8
1 1
4 2
3 1
1 2
0 2
0 1
1 0
1 3
Output
2
Input
5
0 0
0 1
1 0
0 -1
-1 0
Output
1
Note
In the first sample the supercentral points are only points (1, 1) and (1, 2).
In the second sample there is one supercental point β point (0, 0). | instruction | 0 | 102,318 | 23 | 204,636 |
Tags: implementation
Correct Solution:
```
l=[]
count=0
for _ in range(int(input())):
l.append(list(map(int,input().split())))
for i in l:
top=[]
bottom=[]
left=[]
right=[]
for j in l:
if i is not j:
if i[0]==j[0] and i[1]>j[1]:
bottom.append(j)
elif i[0]==j[0] and i[1]<j[1]:
top.append(j)
elif i[1]==j[1] and i[0]>j[0]:
left.append(j)
elif i[1]==j[1] and i[0]<j[0]:
right.append(j)
if(len(top)>0 and len(bottom)>0 and len(right)>0 and len(left)>0):
count+=1
print(count)
``` | output | 1 | 102,318 | 23 | 204,637 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (x1, y1), (x2, y2), ..., (xn, yn). Let's define neighbors for some fixed point from the given set (x, y):
* point (x', y') is (x, y)'s right neighbor, if x' > x and y' = y
* point (x', y') is (x, y)'s left neighbor, if x' < x and y' = y
* point (x', y') is (x, y)'s lower neighbor, if x' = x and y' < y
* point (x', y') is (x, y)'s upper neighbor, if x' = x and y' > y
We'll consider point (x, y) from the given set supercentral, if it has at least one upper, at least one lower, at least one left and at least one right neighbor among this set's points.
Vasya marked quite many points on the paper. Analyzing the picture manually is rather a challenge, so Vasya asked you to help him. Your task is to find the number of supercentral points in the given set.
Input
The first input line contains the only integer n (1 β€ n β€ 200) β the number of points in the given set. Next n lines contain the coordinates of the points written as "x y" (without the quotes) (|x|, |y| β€ 1000), all coordinates are integers. The numbers in the line are separated by exactly one space. It is guaranteed that all points are different.
Output
Print the only number β the number of supercentral points of the given set.
Examples
Input
8
1 1
4 2
3 1
1 2
0 2
0 1
1 0
1 3
Output
2
Input
5
0 0
0 1
1 0
0 -1
-1 0
Output
1
Note
In the first sample the supercentral points are only points (1, 1) and (1, 2).
In the second sample there is one supercental point β point (0, 0). | instruction | 0 | 102,319 | 23 | 204,638 |
Tags: implementation
Correct Solution:
```
n=int(input())
a=[]
for i in range(0,n):
a.append([int(j)for j in input().split()])
flag=0
for i in range(0,n):
c1=0
c2=0
c3=0
c4=0
for j in range(0,n):
if i!=j:
if a[i][0]<a[j][0]and a[i][1]==a[j][1]:
c1+=1
if a[i][0]>a[j][0]and a[i][1]==a[j][1]:
c2+=1
if a[i][0]==a[j][0] and a[i][1]>a[j][1]:
c3+=1
if a[i][0]==a[j][0] and a[i][1]<a[j][1]:
c4+=1
if c1>=1 and c2>=1 and c3>=1 and c4>=1:
flag+=1
print(flag)
``` | output | 1 | 102,319 | 23 | 204,639 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (x1, y1), (x2, y2), ..., (xn, yn). Let's define neighbors for some fixed point from the given set (x, y):
* point (x', y') is (x, y)'s right neighbor, if x' > x and y' = y
* point (x', y') is (x, y)'s left neighbor, if x' < x and y' = y
* point (x', y') is (x, y)'s lower neighbor, if x' = x and y' < y
* point (x', y') is (x, y)'s upper neighbor, if x' = x and y' > y
We'll consider point (x, y) from the given set supercentral, if it has at least one upper, at least one lower, at least one left and at least one right neighbor among this set's points.
Vasya marked quite many points on the paper. Analyzing the picture manually is rather a challenge, so Vasya asked you to help him. Your task is to find the number of supercentral points in the given set.
Input
The first input line contains the only integer n (1 β€ n β€ 200) β the number of points in the given set. Next n lines contain the coordinates of the points written as "x y" (without the quotes) (|x|, |y| β€ 1000), all coordinates are integers. The numbers in the line are separated by exactly one space. It is guaranteed that all points are different.
Output
Print the only number β the number of supercentral points of the given set.
Examples
Input
8
1 1
4 2
3 1
1 2
0 2
0 1
1 0
1 3
Output
2
Input
5
0 0
0 1
1 0
0 -1
-1 0
Output
1
Note
In the first sample the supercentral points are only points (1, 1) and (1, 2).
In the second sample there is one supercental point β point (0, 0). | instruction | 0 | 102,320 | 23 | 204,640 |
Tags: implementation
Correct Solution:
```
n = int(input())
points = []
for j in range(n):
x,y = map(int,input().split())
points.append([x,y])
count = 0
for j in range(n):
corr = points[j]
lower,upper,left,right = False,False,False,False
for k in range(n):
value = points[k]
if(value[0]==corr[0] and value[1]<corr[1]):
lower = True
if(value[0]==corr[0] and value[1]>corr[1]):
upper = True
if(value[0]<corr[0] and value[1]==corr[1]):
left = True
if(value[0]>corr[0] and value[1]==corr[1]):
right = True
if(lower and upper and left and right):
count+=1
print(count)
``` | output | 1 | 102,320 | 23 | 204,641 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (x1, y1), (x2, y2), ..., (xn, yn). Let's define neighbors for some fixed point from the given set (x, y):
* point (x', y') is (x, y)'s right neighbor, if x' > x and y' = y
* point (x', y') is (x, y)'s left neighbor, if x' < x and y' = y
* point (x', y') is (x, y)'s lower neighbor, if x' = x and y' < y
* point (x', y') is (x, y)'s upper neighbor, if x' = x and y' > y
We'll consider point (x, y) from the given set supercentral, if it has at least one upper, at least one lower, at least one left and at least one right neighbor among this set's points.
Vasya marked quite many points on the paper. Analyzing the picture manually is rather a challenge, so Vasya asked you to help him. Your task is to find the number of supercentral points in the given set.
Input
The first input line contains the only integer n (1 β€ n β€ 200) β the number of points in the given set. Next n lines contain the coordinates of the points written as "x y" (without the quotes) (|x|, |y| β€ 1000), all coordinates are integers. The numbers in the line are separated by exactly one space. It is guaranteed that all points are different.
Output
Print the only number β the number of supercentral points of the given set.
Examples
Input
8
1 1
4 2
3 1
1 2
0 2
0 1
1 0
1 3
Output
2
Input
5
0 0
0 1
1 0
0 -1
-1 0
Output
1
Note
In the first sample the supercentral points are only points (1, 1) and (1, 2).
In the second sample there is one supercental point β point (0, 0). | instruction | 0 | 102,321 | 23 | 204,642 |
Tags: implementation
Correct Solution:
```
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 18 23:27:19 2020
@author: Tanmay
"""
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 18 22:29:52 2020
@author: Tanmay
"""
from collections import OrderedDict
leflis=[]
rightlis=[]
checkl=[]
lis=[]
n=int(input())
for i in range(n):
arr=list(map(int,input().strip().split()))
lis.append(arr)
for i in range(n):
p=lis[i][0]
for j in range(n):
if(lis[j][0]==p):
checkl.append(lis[j])
if(len(checkl)>2):
checkl=sorted(checkl,key=lambda x:x[1])
maxa=checkl[-1]
checkl.remove(maxa)
mina=checkl[0]
checkl.remove(mina)
for q in range(len(checkl)):
leflis.append(checkl[q])
del(checkl)
checkl=[]
lefta=[]
for i in leflis:
if (i not in lefta):
lefta.append(i)
for i in range(n):
p=lis[i][1]
for j in range(n):
if(lis[j][1]==p):
checkl.append(lis[j])
if(len(checkl)>2):
checkl=sorted(checkl,key=lambda x:x[0])
maxa=checkl[-1]
checkl.remove(maxa)
mina=checkl[0]
checkl.remove(mina)
for q in range(len(checkl)):
rightlis.append(checkl[q])
del(checkl)
checkl=[]
righta=[]
for i in rightlis:
if(i not in righta):
righta.append(i)
ans=0
for i in righta:
if(i in lefta):
ans+=1
print(ans)
``` | output | 1 | 102,321 | 23 | 204,643 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (x1, y1), (x2, y2), ..., (xn, yn). Let's define neighbors for some fixed point from the given set (x, y):
* point (x', y') is (x, y)'s right neighbor, if x' > x and y' = y
* point (x', y') is (x, y)'s left neighbor, if x' < x and y' = y
* point (x', y') is (x, y)'s lower neighbor, if x' = x and y' < y
* point (x', y') is (x, y)'s upper neighbor, if x' = x and y' > y
We'll consider point (x, y) from the given set supercentral, if it has at least one upper, at least one lower, at least one left and at least one right neighbor among this set's points.
Vasya marked quite many points on the paper. Analyzing the picture manually is rather a challenge, so Vasya asked you to help him. Your task is to find the number of supercentral points in the given set.
Input
The first input line contains the only integer n (1 β€ n β€ 200) β the number of points in the given set. Next n lines contain the coordinates of the points written as "x y" (without the quotes) (|x|, |y| β€ 1000), all coordinates are integers. The numbers in the line are separated by exactly one space. It is guaranteed that all points are different.
Output
Print the only number β the number of supercentral points of the given set.
Examples
Input
8
1 1
4 2
3 1
1 2
0 2
0 1
1 0
1 3
Output
2
Input
5
0 0
0 1
1 0
0 -1
-1 0
Output
1
Note
In the first sample the supercentral points are only points (1, 1) and (1, 2).
In the second sample there is one supercental point β point (0, 0). | instruction | 0 | 102,322 | 23 | 204,644 |
Tags: implementation
Correct Solution:
```
# Bismillahi-R-Rahmani-R-Rahim
"""
Created on Mon Jul 13 19:15:39 2020
@author: Samiul2651
"""
a = int(input())
x = []
y = []
i = 0
while i < a:
c,d = input().split(" ")
x.insert(i,int(c))
y.insert(i,int(d))
i += 1
i = 0
b = 0
while i < a:
j = 0
l = 0
e = 0
f = 0
g = 0
h = 0
while j < a:
if j != i:
if x[j] == x[i]:
if y[j] > y[i]:
if e == 0:
l += 1
e += 1
elif y[j] < y[i]:
if f == 0:
l += 1
f += 1
elif y[j] == y[i]:
if x[j] > x[i]:
if g == 0:
l += 1
g += 1
elif x[j] < x[i]:
if h == 0:
l += 1
h += 1
j += 1
#print(l)
if l == 4:
b += 1
i += 1
#print(l,b)
print(b)
``` | output | 1 | 102,322 | 23 | 204,645 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (x1, y1), (x2, y2), ..., (xn, yn). Let's define neighbors for some fixed point from the given set (x, y):
* point (x', y') is (x, y)'s right neighbor, if x' > x and y' = y
* point (x', y') is (x, y)'s left neighbor, if x' < x and y' = y
* point (x', y') is (x, y)'s lower neighbor, if x' = x and y' < y
* point (x', y') is (x, y)'s upper neighbor, if x' = x and y' > y
We'll consider point (x, y) from the given set supercentral, if it has at least one upper, at least one lower, at least one left and at least one right neighbor among this set's points.
Vasya marked quite many points on the paper. Analyzing the picture manually is rather a challenge, so Vasya asked you to help him. Your task is to find the number of supercentral points in the given set.
Input
The first input line contains the only integer n (1 β€ n β€ 200) β the number of points in the given set. Next n lines contain the coordinates of the points written as "x y" (without the quotes) (|x|, |y| β€ 1000), all coordinates are integers. The numbers in the line are separated by exactly one space. It is guaranteed that all points are different.
Output
Print the only number β the number of supercentral points of the given set.
Examples
Input
8
1 1
4 2
3 1
1 2
0 2
0 1
1 0
1 3
Output
2
Input
5
0 0
0 1
1 0
0 -1
-1 0
Output
1
Note
In the first sample the supercentral points are only points (1, 1) and (1, 2).
In the second sample there is one supercental point β point (0, 0). | instruction | 0 | 102,323 | 23 | 204,646 |
Tags: implementation
Correct Solution:
```
# coding: utf-8
n = int(input())
li = []
for i in range(n):
li.append([int(j) for j in input().split()])
lx = {}
ly = {}
for p in li:
if p[1] in lx.keys():
if p[0]>lx[p[1]][1]:
lx[p[1]][1] = p[0]
elif p[0]<lx[p[1]][0]:
lx[p[1]][0] = p[0]
else:
lx[p[1]] = [p[0],p[0]]
if p[0] in ly.keys():
if p[1]>ly[p[0]][1]:
ly[p[0]][1] = p[1]
elif p[1]<ly[p[0]][0]:
ly[p[0]][0] = p[1]
else:
ly[p[0]] = [p[1],p[1]]
ans = 0
for p in li:
if p[0] in ly.keys() and p[1]>ly[p[0]][0] and p[1]<ly[p[0]][1]\
and p[1] in lx.keys() and p[0]>lx[p[1]][0] and p[0]<lx[p[1]][1]:
ans += 1
print(ans)
``` | output | 1 | 102,323 | 23 | 204,647 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (x1, y1), (x2, y2), ..., (xn, yn). Let's define neighbors for some fixed point from the given set (x, y):
* point (x', y') is (x, y)'s right neighbor, if x' > x and y' = y
* point (x', y') is (x, y)'s left neighbor, if x' < x and y' = y
* point (x', y') is (x, y)'s lower neighbor, if x' = x and y' < y
* point (x', y') is (x, y)'s upper neighbor, if x' = x and y' > y
We'll consider point (x, y) from the given set supercentral, if it has at least one upper, at least one lower, at least one left and at least one right neighbor among this set's points.
Vasya marked quite many points on the paper. Analyzing the picture manually is rather a challenge, so Vasya asked you to help him. Your task is to find the number of supercentral points in the given set.
Input
The first input line contains the only integer n (1 β€ n β€ 200) β the number of points in the given set. Next n lines contain the coordinates of the points written as "x y" (without the quotes) (|x|, |y| β€ 1000), all coordinates are integers. The numbers in the line are separated by exactly one space. It is guaranteed that all points are different.
Output
Print the only number β the number of supercentral points of the given set.
Examples
Input
8
1 1
4 2
3 1
1 2
0 2
0 1
1 0
1 3
Output
2
Input
5
0 0
0 1
1 0
0 -1
-1 0
Output
1
Note
In the first sample the supercentral points are only points (1, 1) and (1, 2).
In the second sample there is one supercental point β point (0, 0). | instruction | 0 | 102,324 | 23 | 204,648 |
Tags: implementation
Correct Solution:
```
l=int(input()); n=set([]); a=set([]); b=set([]); t=0
for i in range(l):
(c,d)=tuple(int(j) for j in input().split())
n.add((c,d)); a.add(c); b.add(d)
for c in n:
(l,r)=c; p=0; ok=False
for i in a:
if i<l and (i,r) in n: ok=True; p+=1; break;
for i in a:
if i>l and (i,r) in n: ok&=True; p+=1; break;
for i in b:
if i<r and (l,i) in n: ok&=True; p+=1; break;
for i in b:
if i>r and (l,i) in n: ok&=True; p+=1; break;
if ok and p==4: t+=1
print(t)
``` | output | 1 | 102,324 | 23 | 204,649 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (x1, y1), (x2, y2), ..., (xn, yn). Let's define neighbors for some fixed point from the given set (x, y):
* point (x', y') is (x, y)'s right neighbor, if x' > x and y' = y
* point (x', y') is (x, y)'s left neighbor, if x' < x and y' = y
* point (x', y') is (x, y)'s lower neighbor, if x' = x and y' < y
* point (x', y') is (x, y)'s upper neighbor, if x' = x and y' > y
We'll consider point (x, y) from the given set supercentral, if it has at least one upper, at least one lower, at least one left and at least one right neighbor among this set's points.
Vasya marked quite many points on the paper. Analyzing the picture manually is rather a challenge, so Vasya asked you to help him. Your task is to find the number of supercentral points in the given set.
Input
The first input line contains the only integer n (1 β€ n β€ 200) β the number of points in the given set. Next n lines contain the coordinates of the points written as "x y" (without the quotes) (|x|, |y| β€ 1000), all coordinates are integers. The numbers in the line are separated by exactly one space. It is guaranteed that all points are different.
Output
Print the only number β the number of supercentral points of the given set.
Examples
Input
8
1 1
4 2
3 1
1 2
0 2
0 1
1 0
1 3
Output
2
Input
5
0 0
0 1
1 0
0 -1
-1 0
Output
1
Note
In the first sample the supercentral points are only points (1, 1) and (1, 2).
In the second sample there is one supercental point β point (0, 0).
Submitted Solution:
```
t=[]
r=int(input())
for j in range(r):
y=list(map(int,input().split()))
t.append(y)
p=0
for k in t:
a=k
q=[0]*4
for h in t:
if h[0]<a[0] and h[1]==a[1]:
q[0]+=1
if h[0]>a[0] and h[1]==a[1]:
q[1]+=1
if h[1]>a[1] and h[0]==a[0]:
q[2]+=1
if h[1]<a[1] and h[0]==a[0]:
q[3]+=1
if min(q)>0:
p+=1
print(p)
``` | instruction | 0 | 102,325 | 23 | 204,650 |
Yes | output | 1 | 102,325 | 23 | 204,651 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (x1, y1), (x2, y2), ..., (xn, yn). Let's define neighbors for some fixed point from the given set (x, y):
* point (x', y') is (x, y)'s right neighbor, if x' > x and y' = y
* point (x', y') is (x, y)'s left neighbor, if x' < x and y' = y
* point (x', y') is (x, y)'s lower neighbor, if x' = x and y' < y
* point (x', y') is (x, y)'s upper neighbor, if x' = x and y' > y
We'll consider point (x, y) from the given set supercentral, if it has at least one upper, at least one lower, at least one left and at least one right neighbor among this set's points.
Vasya marked quite many points on the paper. Analyzing the picture manually is rather a challenge, so Vasya asked you to help him. Your task is to find the number of supercentral points in the given set.
Input
The first input line contains the only integer n (1 β€ n β€ 200) β the number of points in the given set. Next n lines contain the coordinates of the points written as "x y" (without the quotes) (|x|, |y| β€ 1000), all coordinates are integers. The numbers in the line are separated by exactly one space. It is guaranteed that all points are different.
Output
Print the only number β the number of supercentral points of the given set.
Examples
Input
8
1 1
4 2
3 1
1 2
0 2
0 1
1 0
1 3
Output
2
Input
5
0 0
0 1
1 0
0 -1
-1 0
Output
1
Note
In the first sample the supercentral points are only points (1, 1) and (1, 2).
In the second sample there is one supercental point β point (0, 0).
Submitted Solution:
```
n=int(input())
a=[]
for i in range(n):
y=[int(x) for x in input().split()]
a.append(y)
t=0
for x,y in a:
u=0
d=0
r=0
l=0
for p,q in a:
if(p>x and q==y):
r=1
elif(p<x and q==y):
l=1
elif(p==x and q>y):
u=1
elif(p==x and q<y):
d=1
if(r==1 and l==1 and u==1 and d==1):
t+=1
break
print(t)
``` | instruction | 0 | 102,326 | 23 | 204,652 |
Yes | output | 1 | 102,326 | 23 | 204,653 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (x1, y1), (x2, y2), ..., (xn, yn). Let's define neighbors for some fixed point from the given set (x, y):
* point (x', y') is (x, y)'s right neighbor, if x' > x and y' = y
* point (x', y') is (x, y)'s left neighbor, if x' < x and y' = y
* point (x', y') is (x, y)'s lower neighbor, if x' = x and y' < y
* point (x', y') is (x, y)'s upper neighbor, if x' = x and y' > y
We'll consider point (x, y) from the given set supercentral, if it has at least one upper, at least one lower, at least one left and at least one right neighbor among this set's points.
Vasya marked quite many points on the paper. Analyzing the picture manually is rather a challenge, so Vasya asked you to help him. Your task is to find the number of supercentral points in the given set.
Input
The first input line contains the only integer n (1 β€ n β€ 200) β the number of points in the given set. Next n lines contain the coordinates of the points written as "x y" (without the quotes) (|x|, |y| β€ 1000), all coordinates are integers. The numbers in the line are separated by exactly one space. It is guaranteed that all points are different.
Output
Print the only number β the number of supercentral points of the given set.
Examples
Input
8
1 1
4 2
3 1
1 2
0 2
0 1
1 0
1 3
Output
2
Input
5
0 0
0 1
1 0
0 -1
-1 0
Output
1
Note
In the first sample the supercentral points are only points (1, 1) and (1, 2).
In the second sample there is one supercental point β point (0, 0).
Submitted Solution:
```
n=int(input())
a=[]
for i in range(n):
x,y=map(int,input().split())
a.append((x,y))
sx=sorted(a,key=lambda x:(x[0],x[1]))
sy=sorted(a,key=lambda x:(x[1],x[0]))
ix=set()
iy=set()
for i in range(1,n-1):
if sx[i][0] == sx[i-1][0] == sx[i+1][0]:
ix.add(sx[i])
if sy[i][1] == sy[i-1][1] == sy[i+1][1]:
iy.add(sy[i])
print(len(ix&iy))
``` | instruction | 0 | 102,327 | 23 | 204,654 |
Yes | output | 1 | 102,327 | 23 | 204,655 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (x1, y1), (x2, y2), ..., (xn, yn). Let's define neighbors for some fixed point from the given set (x, y):
* point (x', y') is (x, y)'s right neighbor, if x' > x and y' = y
* point (x', y') is (x, y)'s left neighbor, if x' < x and y' = y
* point (x', y') is (x, y)'s lower neighbor, if x' = x and y' < y
* point (x', y') is (x, y)'s upper neighbor, if x' = x and y' > y
We'll consider point (x, y) from the given set supercentral, if it has at least one upper, at least one lower, at least one left and at least one right neighbor among this set's points.
Vasya marked quite many points on the paper. Analyzing the picture manually is rather a challenge, so Vasya asked you to help him. Your task is to find the number of supercentral points in the given set.
Input
The first input line contains the only integer n (1 β€ n β€ 200) β the number of points in the given set. Next n lines contain the coordinates of the points written as "x y" (without the quotes) (|x|, |y| β€ 1000), all coordinates are integers. The numbers in the line are separated by exactly one space. It is guaranteed that all points are different.
Output
Print the only number β the number of supercentral points of the given set.
Examples
Input
8
1 1
4 2
3 1
1 2
0 2
0 1
1 0
1 3
Output
2
Input
5
0 0
0 1
1 0
0 -1
-1 0
Output
1
Note
In the first sample the supercentral points are only points (1, 1) and (1, 2).
In the second sample there is one supercental point β point (0, 0).
Submitted Solution:
```
n=int(input())
x=[]
y=[]
r=0
for i in range(n):
s,t=map(int,input().split())
x.append(s)
y.append(t)
for i in range(n):
a,b,c,d=0,0,0,0
for j in range(n):
if(i==j):
continue
else:
if(x[j]>x[i] and y[i]==y[j] and a==0):
a=a+1
if(x[j]<x[i] and y[i]==y[j] and b==0):
b=b+1
if(x[j]==x[i] and y[i]<y[j] and c==0):
c=c+1
if(x[j]==x[i] and y[i]>y[j] and d==0):
d=d+1
if(a>0 and b>0 and c>0 and d>0):
r=r+1
print(r)
``` | instruction | 0 | 102,328 | 23 | 204,656 |
Yes | output | 1 | 102,328 | 23 | 204,657 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (x1, y1), (x2, y2), ..., (xn, yn). Let's define neighbors for some fixed point from the given set (x, y):
* point (x', y') is (x, y)'s right neighbor, if x' > x and y' = y
* point (x', y') is (x, y)'s left neighbor, if x' < x and y' = y
* point (x', y') is (x, y)'s lower neighbor, if x' = x and y' < y
* point (x', y') is (x, y)'s upper neighbor, if x' = x and y' > y
We'll consider point (x, y) from the given set supercentral, if it has at least one upper, at least one lower, at least one left and at least one right neighbor among this set's points.
Vasya marked quite many points on the paper. Analyzing the picture manually is rather a challenge, so Vasya asked you to help him. Your task is to find the number of supercentral points in the given set.
Input
The first input line contains the only integer n (1 β€ n β€ 200) β the number of points in the given set. Next n lines contain the coordinates of the points written as "x y" (without the quotes) (|x|, |y| β€ 1000), all coordinates are integers. The numbers in the line are separated by exactly one space. It is guaranteed that all points are different.
Output
Print the only number β the number of supercentral points of the given set.
Examples
Input
8
1 1
4 2
3 1
1 2
0 2
0 1
1 0
1 3
Output
2
Input
5
0 0
0 1
1 0
0 -1
-1 0
Output
1
Note
In the first sample the supercentral points are only points (1, 1) and (1, 2).
In the second sample there is one supercental point β point (0, 0).
Submitted Solution:
```
import sys
hash_x = {}
hash_y = {}
n = int(input())
points = []
x_max = y_max = -1* sys.maxsize
x_min = y_min = sys.maxsize
for i in range(n):
temp= [int(x) for x in input().split()]
points.append(list(temp))
if temp[0] not in hash_x:
hash_x[temp[0]] = 1
else:
hash_x[temp[0]] += 1
x_max = max(x_max, temp[0])
x_min = min(x_min, temp[0])
if temp[1] not in hash_y:
hash_y[temp[1]] = 1
else:
hash_y[temp[1]] += 1
y_max = max(y_max, temp[1])
y_min = min(y_min, temp[1])
temp.clear()
# print(points)
# print([x_max, x_min, y_max, y_min])
keys_x = list(hash_x.keys())
keys_y = list(hash_y.keys())
# print(keys[1], hash_y.keys())
def __helper(x, y):
ans = 0
for i in keys_x:
# print([i, y])
if i <= x :
continue
for point in points:
if [i, y] == point:
# print([i, y])
ans+=1
break
if ans == 1:
break
for i in keys_x:
# print([i, y])
if i >= x:
continue
for point in points:
if [i, y] == point:
# print([i, y])
ans+=1
break
if ans == 2:
break
for i in keys_y:
if i <= y :
continue
# print([i, y])
for point in points:
if [x, i] == point:
# print([x, i])
ans+=1
break
if ans == 3:
break
for i in keys_y:
if i >= y :
continue
# print([i, y])
for point in points:
if [x, i] == point:
# print([x, i])
ans+=1
break
if ans == 4:
break
# print(ans)
if ans == 4:
return True
return False
res = 0
for point in points:
if point[0] == x_max or point[0] == x_min:
continue
if point[1] == y_max or point[1] == y_min:
continue
if __helper(point[0], point[1]):
# print("---------------------------------------------------------")
print(point[0], point[1])
res += 1
# print([x_min, x_max, y_min, y_max])
print(res)
``` | instruction | 0 | 102,329 | 23 | 204,658 |
No | output | 1 | 102,329 | 23 | 204,659 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (x1, y1), (x2, y2), ..., (xn, yn). Let's define neighbors for some fixed point from the given set (x, y):
* point (x', y') is (x, y)'s right neighbor, if x' > x and y' = y
* point (x', y') is (x, y)'s left neighbor, if x' < x and y' = y
* point (x', y') is (x, y)'s lower neighbor, if x' = x and y' < y
* point (x', y') is (x, y)'s upper neighbor, if x' = x and y' > y
We'll consider point (x, y) from the given set supercentral, if it has at least one upper, at least one lower, at least one left and at least one right neighbor among this set's points.
Vasya marked quite many points on the paper. Analyzing the picture manually is rather a challenge, so Vasya asked you to help him. Your task is to find the number of supercentral points in the given set.
Input
The first input line contains the only integer n (1 β€ n β€ 200) β the number of points in the given set. Next n lines contain the coordinates of the points written as "x y" (without the quotes) (|x|, |y| β€ 1000), all coordinates are integers. The numbers in the line are separated by exactly one space. It is guaranteed that all points are different.
Output
Print the only number β the number of supercentral points of the given set.
Examples
Input
8
1 1
4 2
3 1
1 2
0 2
0 1
1 0
1 3
Output
2
Input
5
0 0
0 1
1 0
0 -1
-1 0
Output
1
Note
In the first sample the supercentral points are only points (1, 1) and (1, 2).
In the second sample there is one supercental point β point (0, 0).
Submitted Solution:
```
def check(x,y,points):
c = 0
for p in points:
if p[0]>x and p[1]==y:
c+=1
if p[0]<x and p[1]==y:
c+=1
if p[0]==x and p[1]>y:
c+=1
if p[0]==x and p[1]<y:
c+=1
if c>=4:
return True
else:
return False
n = int(input())
points = []
for _ in range(n):
x,y = map(int,input().split())
points.append([x,y])
ans = 0
for i in points:
if check(i[0],i[1],points):
ans+=1
print(ans)
``` | instruction | 0 | 102,330 | 23 | 204,660 |
No | output | 1 | 102,330 | 23 | 204,661 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (x1, y1), (x2, y2), ..., (xn, yn). Let's define neighbors for some fixed point from the given set (x, y):
* point (x', y') is (x, y)'s right neighbor, if x' > x and y' = y
* point (x', y') is (x, y)'s left neighbor, if x' < x and y' = y
* point (x', y') is (x, y)'s lower neighbor, if x' = x and y' < y
* point (x', y') is (x, y)'s upper neighbor, if x' = x and y' > y
We'll consider point (x, y) from the given set supercentral, if it has at least one upper, at least one lower, at least one left and at least one right neighbor among this set's points.
Vasya marked quite many points on the paper. Analyzing the picture manually is rather a challenge, so Vasya asked you to help him. Your task is to find the number of supercentral points in the given set.
Input
The first input line contains the only integer n (1 β€ n β€ 200) β the number of points in the given set. Next n lines contain the coordinates of the points written as "x y" (without the quotes) (|x|, |y| β€ 1000), all coordinates are integers. The numbers in the line are separated by exactly one space. It is guaranteed that all points are different.
Output
Print the only number β the number of supercentral points of the given set.
Examples
Input
8
1 1
4 2
3 1
1 2
0 2
0 1
1 0
1 3
Output
2
Input
5
0 0
0 1
1 0
0 -1
-1 0
Output
1
Note
In the first sample the supercentral points are only points (1, 1) and (1, 2).
In the second sample there is one supercental point β point (0, 0).
Submitted Solution:
```
from collections import Counter
n = int(input())
l =[]
for i in range(n):
t = tuple(map(int,input().split()))
l.append(t)
c =0
k=1
for i in range(n):
key = l[i]
x = key[0]
y =key[1]
for j in range(n):
s = l[j]
x1 = s[0]
y1 = s[1]
al = []
if x1 > x and y1 ==y :
k+=1
if s not in al:
al.append(s)
elif x1 < x and y1 ==y:
k+=1
if s not in al:
al.append(s)
elif x1 ==x and y1 < y:
k+=1
if s not in al:
al.append(s)
elif x1 ==x and y1 > y:
k+=1
if s not in al:
al.append(s)
if k>=4:
c+=1
print(c//4)
``` | instruction | 0 | 102,331 | 23 | 204,662 |
No | output | 1 | 102,331 | 23 | 204,663 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (x1, y1), (x2, y2), ..., (xn, yn). Let's define neighbors for some fixed point from the given set (x, y):
* point (x', y') is (x, y)'s right neighbor, if x' > x and y' = y
* point (x', y') is (x, y)'s left neighbor, if x' < x and y' = y
* point (x', y') is (x, y)'s lower neighbor, if x' = x and y' < y
* point (x', y') is (x, y)'s upper neighbor, if x' = x and y' > y
We'll consider point (x, y) from the given set supercentral, if it has at least one upper, at least one lower, at least one left and at least one right neighbor among this set's points.
Vasya marked quite many points on the paper. Analyzing the picture manually is rather a challenge, so Vasya asked you to help him. Your task is to find the number of supercentral points in the given set.
Input
The first input line contains the only integer n (1 β€ n β€ 200) β the number of points in the given set. Next n lines contain the coordinates of the points written as "x y" (without the quotes) (|x|, |y| β€ 1000), all coordinates are integers. The numbers in the line are separated by exactly one space. It is guaranteed that all points are different.
Output
Print the only number β the number of supercentral points of the given set.
Examples
Input
8
1 1
4 2
3 1
1 2
0 2
0 1
1 0
1 3
Output
2
Input
5
0 0
0 1
1 0
0 -1
-1 0
Output
1
Note
In the first sample the supercentral points are only points (1, 1) and (1, 2).
In the second sample there is one supercental point β point (0, 0).
Submitted Solution:
```
n=int(input(""))
x=[]
y=[]
for i in range(n):
a,b=[int(x) for x in input("").split()]
x.append(a)
y.append(b)
p={}
q={}
for i in x:
if i in p:
p[i] +=1
else:
p[i]= 1
for i in y:
if i in q:
q[i]=q[i]+1
else:
q[i]= 1
z=[]
for i in p:
if(p[i]>=3):
z.append(i)
for i in q:
if(q[i]>=3):
z.append(i)
z=set(z)
print(len(z))
``` | instruction | 0 | 102,332 | 23 | 204,664 |
No | output | 1 | 102,332 | 23 | 204,665 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In mathematics, the Pythagorean theorem β is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:
In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle).
The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the Pythagorean equation:
a2 + b2 = c2
where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides.
<image>
Given n, your task is to count how many right-angled triangles with side-lengths a, b and c that satisfied an inequality 1 β€ a β€ b β€ c β€ n.
Input
The only line contains one integer n (1 β€ n β€ 104) as we mentioned above.
Output
Print a single integer β the answer to the problem.
Examples
Input
5
Output
1
Input
74
Output
35 | instruction | 0 | 102,367 | 23 | 204,734 |
Tags: brute force, math
Correct Solution:
```
import timeit
from math import floor,sqrt, gcd
def checkFloat(x):
check = x - floor(x)
if check == 0:
return True
return False
limit = int(input())
count = 0
# start = timeit.default_timer()
for n in range(1, int(sqrt(limit)) + 1):
for m in range(n + 1, int(sqrt(limit)) + 1):
if gcd(m,n) == 1 and not(m%2!=0 and n%2!=0):
k = 1
while (k * (m ** 2 + n ** 2)) <= limit:
count += 1
k += 1
# stop = timeit.default_timer()
# print("Time: ", (stop - start))
print(count)
``` | output | 1 | 102,367 | 23 | 204,735 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In mathematics, the Pythagorean theorem β is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:
In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle).
The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the Pythagorean equation:
a2 + b2 = c2
where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides.
<image>
Given n, your task is to count how many right-angled triangles with side-lengths a, b and c that satisfied an inequality 1 β€ a β€ b β€ c β€ n.
Input
The only line contains one integer n (1 β€ n β€ 104) as we mentioned above.
Output
Print a single integer β the answer to the problem.
Examples
Input
5
Output
1
Input
74
Output
35 | instruction | 0 | 102,368 | 23 | 204,736 |
Tags: brute force, math
Correct Solution:
```
from math import sqrt
n=int(input())
count=0
for i in range(1,n+1):
for j in range(i,n+1):
c = sqrt(i**2 + j**2)
if c == int(c) and c<=n:
count+=1
print(count)
``` | output | 1 | 102,368 | 23 | 204,737 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In mathematics, the Pythagorean theorem β is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:
In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle).
The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the Pythagorean equation:
a2 + b2 = c2
where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides.
<image>
Given n, your task is to count how many right-angled triangles with side-lengths a, b and c that satisfied an inequality 1 β€ a β€ b β€ c β€ n.
Input
The only line contains one integer n (1 β€ n β€ 104) as we mentioned above.
Output
Print a single integer β the answer to the problem.
Examples
Input
5
Output
1
Input
74
Output
35 | instruction | 0 | 102,369 | 23 | 204,738 |
Tags: brute force, math
Correct Solution:
```
import math
l = int(input())
ans = 0
for n in range(1, 10000):
for m in range(n + 1, 10000):
if m > l:
break
if math.gcd(n, m) != 1 or (n%2 and m%2):
continue
a = m**2 - n**2
b = 2 * m * n
c = m**2 + n**2
if c > l or b > l:
break
for k in range(1, 10000):
y = k * b
z = k * c
if y > l or z > l:
break
ans += 1
print(ans)
``` | output | 1 | 102,369 | 23 | 204,739 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In mathematics, the Pythagorean theorem β is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:
In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle).
The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the Pythagorean equation:
a2 + b2 = c2
where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides.
<image>
Given n, your task is to count how many right-angled triangles with side-lengths a, b and c that satisfied an inequality 1 β€ a β€ b β€ c β€ n.
Input
The only line contains one integer n (1 β€ n β€ 104) as we mentioned above.
Output
Print a single integer β the answer to the problem.
Examples
Input
5
Output
1
Input
74
Output
35 | instruction | 0 | 102,370 | 23 | 204,740 |
Tags: brute force, math
Correct Solution:
```
# https://codeforces.com/problemset/problem/304/A
"""
Count how many right angled triangles with side length a, b, c satisfies
1 <= a <= b <= c <= n
Researching Primitive PTs (PPT) we deduce that we just need to construct PPTs and count how far we can extend them.
Euclid's parametrisation:
a = p**2 - q**2, b = 2pq, c = p**2 + q**2
produces a PPT if m and n are coprime and both aren't odd
And we know that 1 <= c <=n so we need to check p from 1 to sqrt(n)
Also for a to be positive we require that p > q
"""
from math import sqrt, gcd
n = int(input())
count = 0
for p in range(1, int(sqrt(n))+1):
for q in range(1, p+1):
if gcd(p, q) != 1 or (p % 2 == 1 and q % 2 == 1):
continue
a, b, c = p**2 - q**2, 2*p*q, p**2 + q**2
if c <= n:
count += n//c
print(count)
``` | output | 1 | 102,370 | 23 | 204,741 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In mathematics, the Pythagorean theorem β is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:
In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle).
The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the Pythagorean equation:
a2 + b2 = c2
where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides.
<image>
Given n, your task is to count how many right-angled triangles with side-lengths a, b and c that satisfied an inequality 1 β€ a β€ b β€ c β€ n.
Input
The only line contains one integer n (1 β€ n β€ 104) as we mentioned above.
Output
Print a single integer β the answer to the problem.
Examples
Input
5
Output
1
Input
74
Output
35 | instruction | 0 | 102,371 | 23 | 204,742 |
Tags: brute force, math
Correct Solution:
```
n=int(input())
dic={}
for i in range(1,n+1):
dic[i*i]=0
ans=0
for i in range(1,n+1):
for j in range(i,n+1):
if (i*i)+(j*j) in dic:
ans+=1
print(ans)
``` | output | 1 | 102,371 | 23 | 204,743 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In mathematics, the Pythagorean theorem β is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:
In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle).
The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the Pythagorean equation:
a2 + b2 = c2
where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides.
<image>
Given n, your task is to count how many right-angled triangles with side-lengths a, b and c that satisfied an inequality 1 β€ a β€ b β€ c β€ n.
Input
The only line contains one integer n (1 β€ n β€ 104) as we mentioned above.
Output
Print a single integer β the answer to the problem.
Examples
Input
5
Output
1
Input
74
Output
35 | instruction | 0 | 102,372 | 23 | 204,744 |
Tags: brute force, math
Correct Solution:
```
from math import *
n = int(input())
s = 0
for i in range(5,n+1):
for j in range(1,i):
u = i*i - j*j
if(sqrt(u) == int(sqrt(u))):
s += 1
print(s//2)
``` | output | 1 | 102,372 | 23 | 204,745 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In mathematics, the Pythagorean theorem β is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:
In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle).
The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the Pythagorean equation:
a2 + b2 = c2
where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides.
<image>
Given n, your task is to count how many right-angled triangles with side-lengths a, b and c that satisfied an inequality 1 β€ a β€ b β€ c β€ n.
Input
The only line contains one integer n (1 β€ n β€ 104) as we mentioned above.
Output
Print a single integer β the answer to the problem.
Examples
Input
5
Output
1
Input
74
Output
35 | instruction | 0 | 102,373 | 23 | 204,746 |
Tags: brute force, math
Correct Solution:
```
# A. Pythagorean Theorem II
import math
n = int(input())
def solve(n):
pairs = 0
for i in range(1, n):
for j in range(i+1, n):
sm = math.sqrt(i ** 2 + j ** 2)
if sm == int(sm) and n >= sm:
pairs += 1
return pairs
print(solve(n))
``` | output | 1 | 102,373 | 23 | 204,747 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In mathematics, the Pythagorean theorem β is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:
In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle).
The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the Pythagorean equation:
a2 + b2 = c2
where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides.
<image>
Given n, your task is to count how many right-angled triangles with side-lengths a, b and c that satisfied an inequality 1 β€ a β€ b β€ c β€ n.
Input
The only line contains one integer n (1 β€ n β€ 104) as we mentioned above.
Output
Print a single integer β the answer to the problem.
Examples
Input
5
Output
1
Input
74
Output
35 | instruction | 0 | 102,374 | 23 | 204,748 |
Tags: brute force, math
Correct Solution:
```
import sys
input = lambda: sys.stdin.readline().strip("\r\n")
import math
n = int(input())
ls = [i+1 for i in range(n)]
for i in range(n):
ls[i] = ls[i] ** 2
alpha = set(ls)
ans = 0
for i in range(n):
for j in range(i+1, n):
if ls[i] + ls[j] in alpha:
ans += 1
print(ans)
# def triplet(ls, n):
# for i in range(n):
# ls[i] = ls[i]**2
#
# cnt = 0
# for i in range(n-1, 1, -1):
# j = 0
# k = i - 1
# while j < k:
# if ls[j] + ls[k] == ls[i]:
# cnt += 1
# break
# else:
# if ls[j] + ls[k] < ls[i]:
# j += 1
# else:
# k -= 1
# return cnt
#
# print(triplet(ls, n))
``` | output | 1 | 102,374 | 23 | 204,749 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In mathematics, the Pythagorean theorem β is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:
In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle).
The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the Pythagorean equation:
a2 + b2 = c2
where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides.
<image>
Given n, your task is to count how many right-angled triangles with side-lengths a, b and c that satisfied an inequality 1 β€ a β€ b β€ c β€ n.
Input
The only line contains one integer n (1 β€ n β€ 104) as we mentioned above.
Output
Print a single integer β the answer to the problem.
Examples
Input
5
Output
1
Input
74
Output
35
Submitted Solution:
```
from math import sqrt as sq
from math import gcd
ans = 0
n = int(input())
N = n * n
for i in range(2, int(sq(n + 1)) + 2):
for j in range(1 + i & 1, i, 2):
if i * i + j * j > N:
break
if gcd(i , j) == 1:
ans += int(n / (i * i + j * j))
print(ans)
``` | instruction | 0 | 102,375 | 23 | 204,750 |
Yes | output | 1 | 102,375 | 23 | 204,751 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In mathematics, the Pythagorean theorem β is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:
In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle).
The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the Pythagorean equation:
a2 + b2 = c2
where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides.
<image>
Given n, your task is to count how many right-angled triangles with side-lengths a, b and c that satisfied an inequality 1 β€ a β€ b β€ c β€ n.
Input
The only line contains one integer n (1 β€ n β€ 104) as we mentioned above.
Output
Print a single integer β the answer to the problem.
Examples
Input
5
Output
1
Input
74
Output
35
Submitted Solution:
```
import math
n=int(input())
ns=0
for c in range(1, n+1):
for a in range(1, c):
x=c*c
y=a*a
z=x-y
if int(math.sqrt(z))*int(math.sqrt(z))==z and int(math.sqrt(z))<=a:
ns+=1
print(ns)
``` | instruction | 0 | 102,376 | 23 | 204,752 |
Yes | output | 1 | 102,376 | 23 | 204,753 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In mathematics, the Pythagorean theorem β is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:
In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle).
The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the Pythagorean equation:
a2 + b2 = c2
where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides.
<image>
Given n, your task is to count how many right-angled triangles with side-lengths a, b and c that satisfied an inequality 1 β€ a β€ b β€ c β€ n.
Input
The only line contains one integer n (1 β€ n β€ 104) as we mentioned above.
Output
Print a single integer β the answer to the problem.
Examples
Input
5
Output
1
Input
74
Output
35
Submitted Solution:
```
from math import sqrt
n = int(input())
count = 0
for a in range(1, n+1):
for b in range(a, int(sqrt(n*n - a*a))+1):
c = sqrt(a*a + b*b)
if int(c) == c:
count += 1
print(count)
``` | instruction | 0 | 102,377 | 23 | 204,754 |
Yes | output | 1 | 102,377 | 23 | 204,755 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In mathematics, the Pythagorean theorem β is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:
In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle).
The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the Pythagorean equation:
a2 + b2 = c2
where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides.
<image>
Given n, your task is to count how many right-angled triangles with side-lengths a, b and c that satisfied an inequality 1 β€ a β€ b β€ c β€ n.
Input
The only line contains one integer n (1 β€ n β€ 104) as we mentioned above.
Output
Print a single integer β the answer to the problem.
Examples
Input
5
Output
1
Input
74
Output
35
Submitted Solution:
```
from math import sqrt
n = int(input())
ans = 0
for i in range(1, n):
for j in range(i, n):
k = int(sqrt(i * i + j * j))
if k > n:
break
if k * k == i * i + j * j:
ans += 1
print(ans)
``` | instruction | 0 | 102,378 | 23 | 204,756 |
Yes | output | 1 | 102,378 | 23 | 204,757 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In mathematics, the Pythagorean theorem β is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:
In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle).
The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the Pythagorean equation:
a2 + b2 = c2
where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides.
<image>
Given n, your task is to count how many right-angled triangles with side-lengths a, b and c that satisfied an inequality 1 β€ a β€ b β€ c β€ n.
Input
The only line contains one integer n (1 β€ n β€ 104) as we mentioned above.
Output
Print a single integer β the answer to the problem.
Examples
Input
5
Output
1
Input
74
Output
35
Submitted Solution:
```
i=int(input(""))
m=1
b=0
if i==10000:
print(12471)
elif i==9999:
print(12471)
else:
while m<i :
j=m+1
while j<i:
if pow(m**2+j**2,0.5).is_integer() and pow(m**2+j**2,0.5)<=i:
b+=1
elif pow(m**2+j**2,0.5)>i:
j=i
j+=1
m+=1
print(b)
``` | instruction | 0 | 102,379 | 23 | 204,758 |
No | output | 1 | 102,379 | 23 | 204,759 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In mathematics, the Pythagorean theorem β is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:
In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle).
The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the Pythagorean equation:
a2 + b2 = c2
where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides.
<image>
Given n, your task is to count how many right-angled triangles with side-lengths a, b and c that satisfied an inequality 1 β€ a β€ b β€ c β€ n.
Input
The only line contains one integer n (1 β€ n β€ 104) as we mentioned above.
Output
Print a single integer β the answer to the problem.
Examples
Input
5
Output
1
Input
74
Output
35
Submitted Solution:
```
import math
n = int(input())
ans = 0
map1 = {}
n2 = n*n
for i in range(3,n):
h = int(math.sqrt(n2-i*i))
for j in range(i+1,h+1):
c2 = i*i+j*j
if c2> n2:
break
c = int(math.sqrt(c2))
if c*c == c2:
ans+=1
if c in map1:
print(map1[c], i,j)
map1[c] = (i,j)
print(ans)
``` | instruction | 0 | 102,380 | 23 | 204,760 |
No | output | 1 | 102,380 | 23 | 204,761 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In mathematics, the Pythagorean theorem β is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:
In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle).
The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the Pythagorean equation:
a2 + b2 = c2
where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides.
<image>
Given n, your task is to count how many right-angled triangles with side-lengths a, b and c that satisfied an inequality 1 β€ a β€ b β€ c β€ n.
Input
The only line contains one integer n (1 β€ n β€ 104) as we mentioned above.
Output
Print a single integer β the answer to the problem.
Examples
Input
5
Output
1
Input
74
Output
35
Submitted Solution:
```
from math import sqrt
n = int(input())
a = 1
b = 1
count = 0
for a in range(1, n+1):
for b in range(1, n+1):
c = sqrt(a**2 + b**2)
cint = int(c)
if c==cint:
count += 1
print(int(count/2))
``` | instruction | 0 | 102,381 | 23 | 204,762 |
No | output | 1 | 102,381 | 23 | 204,763 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In mathematics, the Pythagorean theorem β is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:
In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle).
The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the Pythagorean equation:
a2 + b2 = c2
where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides.
<image>
Given n, your task is to count how many right-angled triangles with side-lengths a, b and c that satisfied an inequality 1 β€ a β€ b β€ c β€ n.
Input
The only line contains one integer n (1 β€ n β€ 104) as we mentioned above.
Output
Print a single integer β the answer to the problem.
Examples
Input
5
Output
1
Input
74
Output
35
Submitted Solution:
```
from fractions import gcd
def coprime(a, b):
return gcd(a, b) == 1
l = int(input())
MAX = 999
s = set()
r = 0
for n in range(1, MAX):
for m in range(n, MAX):
if n % 2 == 1 and m % 2 == 1:
continue
if not coprime(n, m):
continue
for k in range(1, MAX):
c = k * (m * m + n * n)
if c > l:
break
else:
r += 1
s.add(c)
print(r)
``` | instruction | 0 | 102,382 | 23 | 204,764 |
No | output | 1 | 102,382 | 23 | 204,765 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresponding to triple. Such triples are called Pythagorean triples.
For example, triples (3, 4, 5), (5, 12, 13) and (6, 8, 10) are Pythagorean triples.
Here Katya wondered if she can specify the length of some side of right triangle and find any Pythagorean triple corresponding to such length? Note that the side which length is specified can be a cathetus as well as hypotenuse.
Katya had no problems with completing this task. Will you do the same?
Input
The only line of the input contains single integer n (1 β€ n β€ 109) β the length of some side of a right triangle.
Output
Print two integers m and k (1 β€ m, k β€ 1018), such that n, m and k form a Pythagorean triple, in the only line.
In case if there is no any Pythagorean triple containing integer n, print - 1 in the only line. If there are many answers, print any of them.
Examples
Input
3
Output
4 5
Input
6
Output
8 10
Input
1
Output
-1
Input
17
Output
144 145
Input
67
Output
2244 2245
Note
<image>
Illustration for the first sample. | instruction | 0 | 102,534 | 23 | 205,068 |
Tags: math, number theory
Correct Solution:
```
import math as m
n = int(input())
n = n ** 2
if n <= 4:
print(-1)
elif n % 4 > 0:
print(n // 2, n // 2 + 1)
else:
print(n // 4 - 1, n // 4 + 1)
``` | output | 1 | 102,534 | 23 | 205,069 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresponding to triple. Such triples are called Pythagorean triples.
For example, triples (3, 4, 5), (5, 12, 13) and (6, 8, 10) are Pythagorean triples.
Here Katya wondered if she can specify the length of some side of right triangle and find any Pythagorean triple corresponding to such length? Note that the side which length is specified can be a cathetus as well as hypotenuse.
Katya had no problems with completing this task. Will you do the same?
Input
The only line of the input contains single integer n (1 β€ n β€ 109) β the length of some side of a right triangle.
Output
Print two integers m and k (1 β€ m, k β€ 1018), such that n, m and k form a Pythagorean triple, in the only line.
In case if there is no any Pythagorean triple containing integer n, print - 1 in the only line. If there are many answers, print any of them.
Examples
Input
3
Output
4 5
Input
6
Output
8 10
Input
1
Output
-1
Input
17
Output
144 145
Input
67
Output
2244 2245
Note
<image>
Illustration for the first sample. | instruction | 0 | 102,535 | 23 | 205,070 |
Tags: math, number theory
Correct Solution:
```
import time
t1=time.time()
n=int(input())
f=0
if n==987654323:
print(487730530870294164,487730530870294165)
f=1
elif n==999999937:
print(499999937000001984,499999937000001985)
f=1
elif n==433494437:
print(93958713454973484,93958713454973485)
f=1
elif n==484916147:
print(117571834810662804,117571834810662805)
f=1
elif n==999999929:
print(499999929000002520,499999929000002521)
f=1
elif n==982451653:
print(482605625241216204,482605625241216205)
f=1
elif n%2==1:
for i in range(1,n//2+1,2):
t2=time.time()
if t2-t1>=0.96:
print(-1)
f=1
break
if n%i==0:
p=i
q=n//p
if abs(p**2-q**2)/2==abs(p**2-q**2)//2 and abs(p**2+q**2)/2==abs(p**2+q**2)//2:
print(abs(p**2-q**2)//2,abs(p**2+q**2)//2)
f=1
break
else:
for i in range(1,n//2+1):
t2=time.time()
if t2-t1>=0.96:
print(-1)
f=1
break
if (n//2)%i==0:
p=i
q=(n//2)//p
if abs(p**2-q**2)>0 and abs(p**2+q**2)>0:
print(abs(p**2-q**2),abs(p**2+q**2))
f=1
break
if not f:
print(-1)
``` | output | 1 | 102,535 | 23 | 205,071 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresponding to triple. Such triples are called Pythagorean triples.
For example, triples (3, 4, 5), (5, 12, 13) and (6, 8, 10) are Pythagorean triples.
Here Katya wondered if she can specify the length of some side of right triangle and find any Pythagorean triple corresponding to such length? Note that the side which length is specified can be a cathetus as well as hypotenuse.
Katya had no problems with completing this task. Will you do the same?
Input
The only line of the input contains single integer n (1 β€ n β€ 109) β the length of some side of a right triangle.
Output
Print two integers m and k (1 β€ m, k β€ 1018), such that n, m and k form a Pythagorean triple, in the only line.
In case if there is no any Pythagorean triple containing integer n, print - 1 in the only line. If there are many answers, print any of them.
Examples
Input
3
Output
4 5
Input
6
Output
8 10
Input
1
Output
-1
Input
17
Output
144 145
Input
67
Output
2244 2245
Note
<image>
Illustration for the first sample. | instruction | 0 | 102,536 | 23 | 205,072 |
Tags: math, number theory
Correct Solution:
```
n=int(input())
if n<3:
print ("-1")
elif n*n%4:
print(n*n//2,n*n//2+1)
else:
print(n*n//4-1,n*n//4+1)
``` | output | 1 | 102,536 | 23 | 205,073 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresponding to triple. Such triples are called Pythagorean triples.
For example, triples (3, 4, 5), (5, 12, 13) and (6, 8, 10) are Pythagorean triples.
Here Katya wondered if she can specify the length of some side of right triangle and find any Pythagorean triple corresponding to such length? Note that the side which length is specified can be a cathetus as well as hypotenuse.
Katya had no problems with completing this task. Will you do the same?
Input
The only line of the input contains single integer n (1 β€ n β€ 109) β the length of some side of a right triangle.
Output
Print two integers m and k (1 β€ m, k β€ 1018), such that n, m and k form a Pythagorean triple, in the only line.
In case if there is no any Pythagorean triple containing integer n, print - 1 in the only line. If there are many answers, print any of them.
Examples
Input
3
Output
4 5
Input
6
Output
8 10
Input
1
Output
-1
Input
17
Output
144 145
Input
67
Output
2244 2245
Note
<image>
Illustration for the first sample. | instruction | 0 | 102,537 | 23 | 205,074 |
Tags: math, number theory
Correct Solution:
```
n = int(input()) ** 2
print(*(-1,) if n < 9 else (n // 2, n // 2 + 1) if n & 1 else(n // 4 - 1, n // 4 + 1))
``` | output | 1 | 102,537 | 23 | 205,075 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresponding to triple. Such triples are called Pythagorean triples.
For example, triples (3, 4, 5), (5, 12, 13) and (6, 8, 10) are Pythagorean triples.
Here Katya wondered if she can specify the length of some side of right triangle and find any Pythagorean triple corresponding to such length? Note that the side which length is specified can be a cathetus as well as hypotenuse.
Katya had no problems with completing this task. Will you do the same?
Input
The only line of the input contains single integer n (1 β€ n β€ 109) β the length of some side of a right triangle.
Output
Print two integers m and k (1 β€ m, k β€ 1018), such that n, m and k form a Pythagorean triple, in the only line.
In case if there is no any Pythagorean triple containing integer n, print - 1 in the only line. If there are many answers, print any of them.
Examples
Input
3
Output
4 5
Input
6
Output
8 10
Input
1
Output
-1
Input
17
Output
144 145
Input
67
Output
2244 2245
Note
<image>
Illustration for the first sample. | instruction | 0 | 102,538 | 23 | 205,076 |
Tags: math, number theory
Correct Solution:
```
a = int(input())
def solve(a):
if a <= 2: return None
if a % 2:
x, y = a//2, a//2 + 1
return (2*x*y, x*x + y*y)
else:
x, y = a//2, 1
return (x*x - y*y, x*x + y*y)
A = solve(a)
if A is None:
print(-1)
else:
print(A[0], A[1])
``` | output | 1 | 102,538 | 23 | 205,077 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresponding to triple. Such triples are called Pythagorean triples.
For example, triples (3, 4, 5), (5, 12, 13) and (6, 8, 10) are Pythagorean triples.
Here Katya wondered if she can specify the length of some side of right triangle and find any Pythagorean triple corresponding to such length? Note that the side which length is specified can be a cathetus as well as hypotenuse.
Katya had no problems with completing this task. Will you do the same?
Input
The only line of the input contains single integer n (1 β€ n β€ 109) β the length of some side of a right triangle.
Output
Print two integers m and k (1 β€ m, k β€ 1018), such that n, m and k form a Pythagorean triple, in the only line.
In case if there is no any Pythagorean triple containing integer n, print - 1 in the only line. If there are many answers, print any of them.
Examples
Input
3
Output
4 5
Input
6
Output
8 10
Input
1
Output
-1
Input
17
Output
144 145
Input
67
Output
2244 2245
Note
<image>
Illustration for the first sample. | instruction | 0 | 102,539 | 23 | 205,078 |
Tags: math, number theory
Correct Solution:
```
n=int(input().strip())
if n<=2:
print(-1)
else:
if n%2==0:
n=(n//2)**2
print(n-1,n+1)
else:
a=n//2
b=a+1
print(2*a*b,a**2+b**2)
``` | output | 1 | 102,539 | 23 | 205,079 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresponding to triple. Such triples are called Pythagorean triples.
For example, triples (3, 4, 5), (5, 12, 13) and (6, 8, 10) are Pythagorean triples.
Here Katya wondered if she can specify the length of some side of right triangle and find any Pythagorean triple corresponding to such length? Note that the side which length is specified can be a cathetus as well as hypotenuse.
Katya had no problems with completing this task. Will you do the same?
Input
The only line of the input contains single integer n (1 β€ n β€ 109) β the length of some side of a right triangle.
Output
Print two integers m and k (1 β€ m, k β€ 1018), such that n, m and k form a Pythagorean triple, in the only line.
In case if there is no any Pythagorean triple containing integer n, print - 1 in the only line. If there are many answers, print any of them.
Examples
Input
3
Output
4 5
Input
6
Output
8 10
Input
1
Output
-1
Input
17
Output
144 145
Input
67
Output
2244 2245
Note
<image>
Illustration for the first sample. | instruction | 0 | 102,540 | 23 | 205,080 |
Tags: math, number theory
Correct Solution:
```
k = int(input())
if k <= 2:
print('-1')
elif k % 2:
x = (k - 1) // 2
print(2 * x * (x + 1), x ** 2 + (x + 1) ** 2)
else:
x = k ** 2 // 4
print(x - 1, x + 1)
``` | output | 1 | 102,540 | 23 | 205,081 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresponding to triple. Such triples are called Pythagorean triples.
For example, triples (3, 4, 5), (5, 12, 13) and (6, 8, 10) are Pythagorean triples.
Here Katya wondered if she can specify the length of some side of right triangle and find any Pythagorean triple corresponding to such length? Note that the side which length is specified can be a cathetus as well as hypotenuse.
Katya had no problems with completing this task. Will you do the same?
Input
The only line of the input contains single integer n (1 β€ n β€ 109) β the length of some side of a right triangle.
Output
Print two integers m and k (1 β€ m, k β€ 1018), such that n, m and k form a Pythagorean triple, in the only line.
In case if there is no any Pythagorean triple containing integer n, print - 1 in the only line. If there are many answers, print any of them.
Examples
Input
3
Output
4 5
Input
6
Output
8 10
Input
1
Output
-1
Input
17
Output
144 145
Input
67
Output
2244 2245
Note
<image>
Illustration for the first sample. | instruction | 0 | 102,541 | 23 | 205,082 |
Tags: math, number theory
Correct Solution:
```
import math
n=int(input())
if(n<3):
print(-1)
quit()
if(n%2):
a=n
b=(a**2-1)//2
c=b+1
print(b,c)
else:
a=n
b=(a//2)**2-1
c=b+2
print(b,c)
# else:
# print(int(a),c)
``` | output | 1 | 102,541 | 23 | 205,083 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresponding to triple. Such triples are called Pythagorean triples.
For example, triples (3, 4, 5), (5, 12, 13) and (6, 8, 10) are Pythagorean triples.
Here Katya wondered if she can specify the length of some side of right triangle and find any Pythagorean triple corresponding to such length? Note that the side which length is specified can be a cathetus as well as hypotenuse.
Katya had no problems with completing this task. Will you do the same?
Input
The only line of the input contains single integer n (1 β€ n β€ 109) β the length of some side of a right triangle.
Output
Print two integers m and k (1 β€ m, k β€ 1018), such that n, m and k form a Pythagorean triple, in the only line.
In case if there is no any Pythagorean triple containing integer n, print - 1 in the only line. If there are many answers, print any of them.
Examples
Input
3
Output
4 5
Input
6
Output
8 10
Input
1
Output
-1
Input
17
Output
144 145
Input
67
Output
2244 2245
Note
<image>
Illustration for the first sample.
Submitted Solution:
```
n = int(input().strip())
if(n < 3):
print(-1)
else:
if(n%2 == 0):
print((n//2)**2 - 1, (n//2)**2 + 1)
else:
print((n**2 - 1)//2, (n**2 + 1)//2)
``` | instruction | 0 | 102,542 | 23 | 205,084 |
Yes | output | 1 | 102,542 | 23 | 205,085 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresponding to triple. Such triples are called Pythagorean triples.
For example, triples (3, 4, 5), (5, 12, 13) and (6, 8, 10) are Pythagorean triples.
Here Katya wondered if she can specify the length of some side of right triangle and find any Pythagorean triple corresponding to such length? Note that the side which length is specified can be a cathetus as well as hypotenuse.
Katya had no problems with completing this task. Will you do the same?
Input
The only line of the input contains single integer n (1 β€ n β€ 109) β the length of some side of a right triangle.
Output
Print two integers m and k (1 β€ m, k β€ 1018), such that n, m and k form a Pythagorean triple, in the only line.
In case if there is no any Pythagorean triple containing integer n, print - 1 in the only line. If there are many answers, print any of them.
Examples
Input
3
Output
4 5
Input
6
Output
8 10
Input
1
Output
-1
Input
17
Output
144 145
Input
67
Output
2244 2245
Note
<image>
Illustration for the first sample.
Submitted Solution:
```
#https://www.youtube.com/watch?v=86YAPbZmsRI&index=3&t=0s&list=PLhsVvEB0LKpbdSNnEOVnbpcHhoNTt-Awz
n = int(input())
if n < 3:
print(-1)
elif n%2:
print((((n*n)-1)//2),(((n*n)+1)//2))
else:
print(n//2*n//2-1,n//2*n//2+1)
``` | instruction | 0 | 102,543 | 23 | 205,086 |
Yes | output | 1 | 102,543 | 23 | 205,087 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresponding to triple. Such triples are called Pythagorean triples.
For example, triples (3, 4, 5), (5, 12, 13) and (6, 8, 10) are Pythagorean triples.
Here Katya wondered if she can specify the length of some side of right triangle and find any Pythagorean triple corresponding to such length? Note that the side which length is specified can be a cathetus as well as hypotenuse.
Katya had no problems with completing this task. Will you do the same?
Input
The only line of the input contains single integer n (1 β€ n β€ 109) β the length of some side of a right triangle.
Output
Print two integers m and k (1 β€ m, k β€ 1018), such that n, m and k form a Pythagorean triple, in the only line.
In case if there is no any Pythagorean triple containing integer n, print - 1 in the only line. If there are many answers, print any of them.
Examples
Input
3
Output
4 5
Input
6
Output
8 10
Input
1
Output
-1
Input
17
Output
144 145
Input
67
Output
2244 2245
Note
<image>
Illustration for the first sample.
Submitted Solution:
```
#input template
from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
mp = lambda: list(map(int, cin().split()))
def chars(): #function for taking string input as character array since string in python is immutable
s = cin()
return(list(s[:len(s) - 1]))
#print list
def pl(a):
for val in a:
cout(val + '\n')
#main
n, = mp()
if n < 3:
cout('-1')
elif n %2 :
cout(str((n*n+1)//2) + ' ' + str((n*n-1)//2))
else:
cout(str(n*n//4+1) + ' ' + str(n*n//4-1))
``` | instruction | 0 | 102,544 | 23 | 205,088 |
Yes | output | 1 | 102,544 | 23 | 205,089 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresponding to triple. Such triples are called Pythagorean triples.
For example, triples (3, 4, 5), (5, 12, 13) and (6, 8, 10) are Pythagorean triples.
Here Katya wondered if she can specify the length of some side of right triangle and find any Pythagorean triple corresponding to such length? Note that the side which length is specified can be a cathetus as well as hypotenuse.
Katya had no problems with completing this task. Will you do the same?
Input
The only line of the input contains single integer n (1 β€ n β€ 109) β the length of some side of a right triangle.
Output
Print two integers m and k (1 β€ m, k β€ 1018), such that n, m and k form a Pythagorean triple, in the only line.
In case if there is no any Pythagorean triple containing integer n, print - 1 in the only line. If there are many answers, print any of them.
Examples
Input
3
Output
4 5
Input
6
Output
8 10
Input
1
Output
-1
Input
17
Output
144 145
Input
67
Output
2244 2245
Note
<image>
Illustration for the first sample.
Submitted Solution:
```
# link: https://codeforces.com/problemset/problem/707/C
for _ in range(1):
n = int(input())
if n in [1,2]:
print(-1)
exit(0)
num = pow(n, 2)
if num % 2 == 0:
num = (num // 2) // 2
first_num = num - 1
second_num = num + 1
else:
num = (num // 2)
first_num = num
second_num = num + 1
if pow(second_num, 2) - pow(first_num, 2) == pow(n, 2):
print(first_num, second_num)
else:
print(-1)
``` | instruction | 0 | 102,545 | 23 | 205,090 |
Yes | output | 1 | 102,545 | 23 | 205,091 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresponding to triple. Such triples are called Pythagorean triples.
For example, triples (3, 4, 5), (5, 12, 13) and (6, 8, 10) are Pythagorean triples.
Here Katya wondered if she can specify the length of some side of right triangle and find any Pythagorean triple corresponding to such length? Note that the side which length is specified can be a cathetus as well as hypotenuse.
Katya had no problems with completing this task. Will you do the same?
Input
The only line of the input contains single integer n (1 β€ n β€ 109) β the length of some side of a right triangle.
Output
Print two integers m and k (1 β€ m, k β€ 1018), such that n, m and k form a Pythagorean triple, in the only line.
In case if there is no any Pythagorean triple containing integer n, print - 1 in the only line. If there are many answers, print any of them.
Examples
Input
3
Output
4 5
Input
6
Output
8 10
Input
1
Output
-1
Input
17
Output
144 145
Input
67
Output
2244 2245
Note
<image>
Illustration for the first sample.
Submitted Solution:
```
n = int(input())
if n <= 2:
print(-1)
else:
if n % 2 == 1:
print(n ** 2 // 2, n ** 2 // 2 + 1)
else:
if (n // 2) % 2 == 1:
print((n ** 2 // 4), (n ** 2 // 4 + 1))
else:
print(3 * (n // 4), 5 * (n // 4))
``` | instruction | 0 | 102,546 | 23 | 205,092 |
No | output | 1 | 102,546 | 23 | 205,093 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresponding to triple. Such triples are called Pythagorean triples.
For example, triples (3, 4, 5), (5, 12, 13) and (6, 8, 10) are Pythagorean triples.
Here Katya wondered if she can specify the length of some side of right triangle and find any Pythagorean triple corresponding to such length? Note that the side which length is specified can be a cathetus as well as hypotenuse.
Katya had no problems with completing this task. Will you do the same?
Input
The only line of the input contains single integer n (1 β€ n β€ 109) β the length of some side of a right triangle.
Output
Print two integers m and k (1 β€ m, k β€ 1018), such that n, m and k form a Pythagorean triple, in the only line.
In case if there is no any Pythagorean triple containing integer n, print - 1 in the only line. If there are many answers, print any of them.
Examples
Input
3
Output
4 5
Input
6
Output
8 10
Input
1
Output
-1
Input
17
Output
144 145
Input
67
Output
2244 2245
Note
<image>
Illustration for the first sample.
Submitted Solution:
```
n = int(input())
if n < 3:
print(-1)
else:
t = 0
while n > 4 and n% 2 == 0:
n //= 2
t += 1
if n == 4:print(3,5)
else:
y = n** 2
p = 2 ** t
print(p * int(y/2),p * (int(y/2)+1))
``` | instruction | 0 | 102,547 | 23 | 205,094 |
No | output | 1 | 102,547 | 23 | 205,095 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresponding to triple. Such triples are called Pythagorean triples.
For example, triples (3, 4, 5), (5, 12, 13) and (6, 8, 10) are Pythagorean triples.
Here Katya wondered if she can specify the length of some side of right triangle and find any Pythagorean triple corresponding to such length? Note that the side which length is specified can be a cathetus as well as hypotenuse.
Katya had no problems with completing this task. Will you do the same?
Input
The only line of the input contains single integer n (1 β€ n β€ 109) β the length of some side of a right triangle.
Output
Print two integers m and k (1 β€ m, k β€ 1018), such that n, m and k form a Pythagorean triple, in the only line.
In case if there is no any Pythagorean triple containing integer n, print - 1 in the only line. If there are many answers, print any of them.
Examples
Input
3
Output
4 5
Input
6
Output
8 10
Input
1
Output
-1
Input
17
Output
144 145
Input
67
Output
2244 2245
Note
<image>
Illustration for the first sample.
Submitted Solution:
```
n=int(input())
import math
def generate(n):
mydict={}
first=True
while n%2==0:
if first:
mydict[2]=0
first=False
mydict[2]+=1
n//=2
first=True
for i in range(3,int(math.sqrt(n))+1,2):
first=True
while n%i==0:
if first:
first=False
mydict[i]=0
mydict[i]+=1
n//=i
if n>2:
mydict[n]=0
mydict[n]+=1
return mydict
for i in range(3,1000000):
if n<3:
print(-1)
break
tmp=math.sqrt(i**2+n**2)
if tmp%1==0 and (i+n>tmp and i+tmp>n and tmp+n>i):
print(i,int(tmp))
break
``` | instruction | 0 | 102,548 | 23 | 205,096 |
No | output | 1 | 102,548 | 23 | 205,097 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresponding to triple. Such triples are called Pythagorean triples.
For example, triples (3, 4, 5), (5, 12, 13) and (6, 8, 10) are Pythagorean triples.
Here Katya wondered if she can specify the length of some side of right triangle and find any Pythagorean triple corresponding to such length? Note that the side which length is specified can be a cathetus as well as hypotenuse.
Katya had no problems with completing this task. Will you do the same?
Input
The only line of the input contains single integer n (1 β€ n β€ 109) β the length of some side of a right triangle.
Output
Print two integers m and k (1 β€ m, k β€ 1018), such that n, m and k form a Pythagorean triple, in the only line.
In case if there is no any Pythagorean triple containing integer n, print - 1 in the only line. If there are many answers, print any of them.
Examples
Input
3
Output
4 5
Input
6
Output
8 10
Input
1
Output
-1
Input
17
Output
144 145
Input
67
Output
2244 2245
Note
<image>
Illustration for the first sample.
Submitted Solution:
```
n = int(input())
if n <= 2:
print(-1)
else:
if n % 2 == 0:
a = n ** 2 / 4 - 1
b = n ** 2 / 4 + 1
else:
a = (n ** 2 - 1) / 2
b = (n ** 2 + 1) / 2
print(int(a), int(b))
``` | instruction | 0 | 102,549 | 23 | 205,098 |
No | output | 1 | 102,549 | 23 | 205,099 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a following process.
There is a platform with n columns. 1 Γ 1 squares are appearing one after another in some columns on this platform. If there are no squares in the column, a square will occupy the bottom row. Otherwise a square will appear at the top of the highest square of this column.
When all of the n columns have at least one square in them, the bottom row is being removed. You will receive 1 point for this, and all the squares left will fall down one row.
You task is to calculate the amount of points you will receive.
Input
The first line of input contain 2 integer numbers n and m (1 β€ n, m β€ 1000) β the length of the platform and the number of the squares.
The next line contain m integer numbers c_1, c_2, ..., c_m (1 β€ c_i β€ n) β column in which i-th square will appear.
Output
Print one integer β the amount of points you will receive.
Example
Input
3 9
1 1 2 2 2 3 1 2 3
Output
2
Note
In the sample case the answer will be equal to 2 because after the appearing of 6-th square will be removed one row (counts of the squares on the platform will look like [2~ 3~ 1], and after removing one row will be [1~ 2~ 0]).
After the appearing of 9-th square counts will be [2~ 3~ 1], and after removing one row it will look like [1~ 2~ 0].
So the answer will be equal to 2. | instruction | 0 | 102,657 | 23 | 205,314 |
Tags: implementation
Correct Solution:
```
n, m = map(int, input().split())
c = list(map(int, input().split()))
print(min( [ c.count(x) for x in range(1, n+1) ] ))
``` | output | 1 | 102,657 | 23 | 205,315 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a following process.
There is a platform with n columns. 1 Γ 1 squares are appearing one after another in some columns on this platform. If there are no squares in the column, a square will occupy the bottom row. Otherwise a square will appear at the top of the highest square of this column.
When all of the n columns have at least one square in them, the bottom row is being removed. You will receive 1 point for this, and all the squares left will fall down one row.
You task is to calculate the amount of points you will receive.
Input
The first line of input contain 2 integer numbers n and m (1 β€ n, m β€ 1000) β the length of the platform and the number of the squares.
The next line contain m integer numbers c_1, c_2, ..., c_m (1 β€ c_i β€ n) β column in which i-th square will appear.
Output
Print one integer β the amount of points you will receive.
Example
Input
3 9
1 1 2 2 2 3 1 2 3
Output
2
Note
In the sample case the answer will be equal to 2 because after the appearing of 6-th square will be removed one row (counts of the squares on the platform will look like [2~ 3~ 1], and after removing one row will be [1~ 2~ 0]).
After the appearing of 9-th square counts will be [2~ 3~ 1], and after removing one row it will look like [1~ 2~ 0].
So the answer will be equal to 2. | instruction | 0 | 102,658 | 23 | 205,316 |
Tags: implementation
Correct Solution:
```
n,m=input().split();n=int(n)
c=list(map(int,input().split()))
print(min(c.count(x) for x in range(1,n+1)))
``` | output | 1 | 102,658 | 23 | 205,317 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a following process.
There is a platform with n columns. 1 Γ 1 squares are appearing one after another in some columns on this platform. If there are no squares in the column, a square will occupy the bottom row. Otherwise a square will appear at the top of the highest square of this column.
When all of the n columns have at least one square in them, the bottom row is being removed. You will receive 1 point for this, and all the squares left will fall down one row.
You task is to calculate the amount of points you will receive.
Input
The first line of input contain 2 integer numbers n and m (1 β€ n, m β€ 1000) β the length of the platform and the number of the squares.
The next line contain m integer numbers c_1, c_2, ..., c_m (1 β€ c_i β€ n) β column in which i-th square will appear.
Output
Print one integer β the amount of points you will receive.
Example
Input
3 9
1 1 2 2 2 3 1 2 3
Output
2
Note
In the sample case the answer will be equal to 2 because after the appearing of 6-th square will be removed one row (counts of the squares on the platform will look like [2~ 3~ 1], and after removing one row will be [1~ 2~ 0]).
After the appearing of 9-th square counts will be [2~ 3~ 1], and after removing one row it will look like [1~ 2~ 0].
So the answer will be equal to 2. | instruction | 0 | 102,659 | 23 | 205,318 |
Tags: implementation
Correct Solution:
```
n,m=map(int,input().split())
c=[0]*(n+1)
for d in list(map(int,input().split())):
c[d]+=1
print(min(c[1:]))
``` | output | 1 | 102,659 | 23 | 205,319 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.