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. You are given n points on a plane. All points are different. Find the number of different groups of three points (A, B, C) such that point B is the middle of segment AC. The groups of three points are considered unordered, that is, if point B is the middle of segment AC, then groups (A, B, C) and (C, B, A) are considered the same. Input The first line contains a single integer n (3 ≀ n ≀ 3000) β€” the number of points. Next n lines contain the points. The i-th line contains coordinates of the i-th point: two space-separated integers xi, yi ( - 1000 ≀ xi, yi ≀ 1000). It is guaranteed that all given points are different. Output Print the single number β€” the answer to the problem. Examples Input 3 1 1 2 2 3 3 Output 1 Input 3 0 0 -1 0 0 1 Output 0
instruction
0
58,294
23
116,588
Tags: binary search, brute force Correct Solution: ``` mod = 1000000007 ii = lambda : int(input()) si = lambda : input() dgl = lambda : list(map(int, input())) f = lambda : map(int, input().split()) il = lambda : list(map(int, input().split())) ls = lambda : list(input()) n=ii() s=set() xs=[] ys=[] for _ in range(n): x,y=f() xs.append(x) ys.append(y) s.add((x,y)) c=0 for i in range(n-1): for j in range(i+1,n): smx=xs[i]+xs[j] smy=ys[i]+ys[j] if smx%2==0 and smy%2==0 and (smx//2,smy//2) in s: c+=1 print(c) ```
output
1
58,294
23
116,589
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n points on a plane. All points are different. Find the number of different groups of three points (A, B, C) such that point B is the middle of segment AC. The groups of three points are considered unordered, that is, if point B is the middle of segment AC, then groups (A, B, C) and (C, B, A) are considered the same. Input The first line contains a single integer n (3 ≀ n ≀ 3000) β€” the number of points. Next n lines contain the points. The i-th line contains coordinates of the i-th point: two space-separated integers xi, yi ( - 1000 ≀ xi, yi ≀ 1000). It is guaranteed that all given points are different. Output Print the single number β€” the answer to the problem. Examples Input 3 1 1 2 2 3 3 Output 1 Input 3 0 0 -1 0 0 1 Output 0
instruction
0
58,295
23
116,590
Tags: binary search, brute force Correct Solution: ``` n = int(input()) ans = 0 l = [] d = {} for i in range(n): x,y = map(int,input().split()) if x in d: d[x].append(y) else: d[x] = [y] l.append([x,y]) for i in range(n-1): for j in range(i+1,n): if (l[i][0]+l[j][0])%2==0 and (l[i][1]+l[j][1])%2==0: if (l[i][0]+l[j][0])//2 in d: if (l[i][1]+l[j][1])//2 in d[(l[i][0]+l[j][0])//2]: ans += 1 print(ans) ```
output
1
58,295
23
116,591
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n points on a plane. All points are different. Find the number of different groups of three points (A, B, C) such that point B is the middle of segment AC. The groups of three points are considered unordered, that is, if point B is the middle of segment AC, then groups (A, B, C) and (C, B, A) are considered the same. Input The first line contains a single integer n (3 ≀ n ≀ 3000) β€” the number of points. Next n lines contain the points. The i-th line contains coordinates of the i-th point: two space-separated integers xi, yi ( - 1000 ≀ xi, yi ≀ 1000). It is guaranteed that all given points are different. Output Print the single number β€” the answer to the problem. Examples Input 3 1 1 2 2 3 3 Output 1 Input 3 0 0 -1 0 0 1 Output 0
instruction
0
58,296
23
116,592
Tags: binary search, brute force Correct Solution: ``` s, n = 0, int(input()) a = [0] * n for i in range(n): x, y = map(int, input().split()) a[i] = 4000 * x + y a.sort() b = set(2 * k for k in a) for i, u in enumerate(a, 2): for v in a[i: ]: if v + u in b: s += 1 print(s) ```
output
1
58,296
23
116,593
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n points on a plane. All points are different. Find the number of different groups of three points (A, B, C) such that point B is the middle of segment AC. The groups of three points are considered unordered, that is, if point B is the middle of segment AC, then groups (A, B, C) and (C, B, A) are considered the same. Input The first line contains a single integer n (3 ≀ n ≀ 3000) β€” the number of points. Next n lines contain the points. The i-th line contains coordinates of the i-th point: two space-separated integers xi, yi ( - 1000 ≀ xi, yi ≀ 1000). It is guaranteed that all given points are different. Output Print the single number β€” the answer to the problem. Examples Input 3 1 1 2 2 3 3 Output 1 Input 3 0 0 -1 0 0 1 Output 0
instruction
0
58,297
23
116,594
Tags: binary search, brute force Correct Solution: ``` # n=int(input()) # n,k=map(int,input().split()) # arr=list(map(int,input().split())) # n=int(input()) # n,k=map(int,input().split()) # arr=list(map(int,input().split())) ls=set() dx=[] dy=[] cnt = 0 n=int(input()) for _ in range(n): x,y= map(int, input().split()) dx.append(x) dy.append(y) ls.add((x,y)) #ls = list(ls) for i in range(n): for j in range(i + 1,n): sumx, sumy = (dx[i]+dx[j]),(dy[i]+dy[j]) if sumx % 2 == 0 and sumy % 2 == 0 : var = sumx // 2 ans = sumy // 2 if (var,ans) in ls: cnt += 1 print(cnt) ```
output
1
58,297
23
116,595
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n points on a plane. All points are different. Find the number of different groups of three points (A, B, C) such that point B is the middle of segment AC. The groups of three points are considered unordered, that is, if point B is the middle of segment AC, then groups (A, B, C) and (C, B, A) are considered the same. Input The first line contains a single integer n (3 ≀ n ≀ 3000) β€” the number of points. Next n lines contain the points. The i-th line contains coordinates of the i-th point: two space-separated integers xi, yi ( - 1000 ≀ xi, yi ≀ 1000). It is guaranteed that all given points are different. Output Print the single number β€” the answer to the problem. Examples Input 3 1 1 2 2 3 3 Output 1 Input 3 0 0 -1 0 0 1 Output 0
instruction
0
58,298
23
116,596
Tags: binary search, brute force Correct Solution: ``` import bisect from itertools import accumulate import os import sys import math from decimal import * from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) def input(): return sys.stdin.readline().rstrip("\r\n") def factors(n): fac=[] while(n%2==0): fac.append(2) n=n//2 for i in range(3,int(math.sqrt(n))+2): while(n%i==0): fac.append(i) n=n//i if n>1: fac.append(n) return fac # ------------------- fast io --------------------]] s, n = 0, int(input()) a = [0] * n for i in range(n): x, y = map(int, input().split()) a[i] = 4000 * x + y a.sort() b = set(2 * k for k in a) for i, u in enumerate(a, 2): for v in a[i: ]: if v + u in b: s += 1 print(s) ```
output
1
58,298
23
116,597
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n points on a plane. All points are different. Find the number of different groups of three points (A, B, C) such that point B is the middle of segment AC. The groups of three points are considered unordered, that is, if point B is the middle of segment AC, then groups (A, B, C) and (C, B, A) are considered the same. Input The first line contains a single integer n (3 ≀ n ≀ 3000) β€” the number of points. Next n lines contain the points. The i-th line contains coordinates of the i-th point: two space-separated integers xi, yi ( - 1000 ≀ xi, yi ≀ 1000). It is guaranteed that all given points are different. Output Print the single number β€” the answer to the problem. Examples Input 3 1 1 2 2 3 3 Output 1 Input 3 0 0 -1 0 0 1 Output 0
instruction
0
58,299
23
116,598
Tags: binary search, brute force Correct Solution: ``` n = int(input()) l = [] s = set() for _ in range(n): x, y = map(int, input().split()) l.append((x, y)) s.add((x, y)) ans = 0 for i in range(n-1): for j in range(i+1, n): t_x = l[i][0]+l[j][0] t_y = l[i][1]+l[j][1] if not(t_x%2) and not(t_y%2) and (t_x//2, t_y//2) in s: ans += 1 print(ans) """ counter = 0 for i in c(l, 3): if (i[0][0]+i[1][0]) == i[2][0]*2 and (i[0][1]+i[1][1]) == i[2][1]*2: counter += 1 if (i[0][0]+i[2][0]) == i[1][0]*2 and (i[0][1]+i[2][1]) == i[1][1]*2: counter += 1 if (i[2][0]+i[1][0]) == i[0][0]*2 and (i[2][1]+i[1][1]) == i[0][1]*2: counter += 1 print(counter) """ ```
output
1
58,299
23
116,599
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n points on a plane. All points are different. Find the number of different groups of three points (A, B, C) such that point B is the middle of segment AC. The groups of three points are considered unordered, that is, if point B is the middle of segment AC, then groups (A, B, C) and (C, B, A) are considered the same. Input The first line contains a single integer n (3 ≀ n ≀ 3000) β€” the number of points. Next n lines contain the points. The i-th line contains coordinates of the i-th point: two space-separated integers xi, yi ( - 1000 ≀ xi, yi ≀ 1000). It is guaranteed that all given points are different. Output Print the single number β€” the answer to the problem. Examples Input 3 1 1 2 2 3 3 Output 1 Input 3 0 0 -1 0 0 1 Output 0 Submitted Solution: ``` N = 1000 n = int(input()) x = [] y = [] f = [[0 for x in range(3*N)] for y in range(3*N)] s = 0 for i in range(n): u, v = map(int, input().split()) x.append(u) y.append(v) f[u+N][v+N] = 1 for i in range(n): for j in range(i+1, n): u = x[i]+x[j] v = y[i]+y[j] s += not(u % 2 or v % 2) and f[u//2+N][v//2+N] print(s) ```
instruction
0
58,300
23
116,600
Yes
output
1
58,300
23
116,601
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n points on a plane. All points are different. Find the number of different groups of three points (A, B, C) such that point B is the middle of segment AC. The groups of three points are considered unordered, that is, if point B is the middle of segment AC, then groups (A, B, C) and (C, B, A) are considered the same. Input The first line contains a single integer n (3 ≀ n ≀ 3000) β€” the number of points. Next n lines contain the points. The i-th line contains coordinates of the i-th point: two space-separated integers xi, yi ( - 1000 ≀ xi, yi ≀ 1000). It is guaranteed that all given points are different. Output Print the single number β€” the answer to the problem. Examples Input 3 1 1 2 2 3 3 Output 1 Input 3 0 0 -1 0 0 1 Output 0 Submitted Solution: ``` import operator as op from io import BytesIO import os input = BytesIO(os.read(0, os.fstat(0).st_size)).readline from collections import defaultdict def isOdd(num): return num % 2 != 0 def main(): space = defaultdict(set) cases = int(input()) points = [] for _ in range(cases): a, b = map(int, input().split()) space[a].add(b) points.append((a,b)) answer = 0 points.sort(key=op.itemgetter(0,1)) for left in range(cases-2): for right in range(left+2, cases): start = points[left] end = points[right] x = start[0] + end[0] y = start[1] + end[1] if isOdd(x) or isOdd(y): continue if x//2 in space and y//2 in space.get(x//2): answer += 1 print(answer) if __name__ == "__main__": main() ```
instruction
0
58,301
23
116,602
Yes
output
1
58,301
23
116,603
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n points on a plane. All points are different. Find the number of different groups of three points (A, B, C) such that point B is the middle of segment AC. The groups of three points are considered unordered, that is, if point B is the middle of segment AC, then groups (A, B, C) and (C, B, A) are considered the same. Input The first line contains a single integer n (3 ≀ n ≀ 3000) β€” the number of points. Next n lines contain the points. The i-th line contains coordinates of the i-th point: two space-separated integers xi, yi ( - 1000 ≀ xi, yi ≀ 1000). It is guaranteed that all given points are different. Output Print the single number β€” the answer to the problem. Examples Input 3 1 1 2 2 3 3 Output 1 Input 3 0 0 -1 0 0 1 Output 0 Submitted Solution: ``` from sys import stdin a=int(stdin.readline()) k=[[int(i)+1000 for i in map(int,input().split())] for _ in " "*a] ok=[[0]*(2001) for _ in " "*2001] for i in k:ok[i[0]][i[1]]=1 ans=0 for i in range(a): for j in range(i+1,a): if (k[i][0]+k[j][0])%2==0 and (k[i][1]+k[j][1])%2==0 and ok[(k[i][0]+k[j][0])//2][(k[i][1]+k[j][1])//2]:ans+=1 print(ans) ```
instruction
0
58,302
23
116,604
Yes
output
1
58,302
23
116,605
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n points on a plane. All points are different. Find the number of different groups of three points (A, B, C) such that point B is the middle of segment AC. The groups of three points are considered unordered, that is, if point B is the middle of segment AC, then groups (A, B, C) and (C, B, A) are considered the same. Input The first line contains a single integer n (3 ≀ n ≀ 3000) β€” the number of points. Next n lines contain the points. The i-th line contains coordinates of the i-th point: two space-separated integers xi, yi ( - 1000 ≀ xi, yi ≀ 1000). It is guaranteed that all given points are different. Output Print the single number β€” the answer to the problem. Examples Input 3 1 1 2 2 3 3 Output 1 Input 3 0 0 -1 0 0 1 Output 0 Submitted Solution: ``` n = int(input()) l1,l2 = [],[] s = set() for _ in range(n): a,b = map(int , input().split()) s.add((a,b)) l1.append(a) l2.append(b) c=0 x,y=0,0 for i in range(n): for j in range(i+1,n): x,y = (l1[i]+l1[j]) , (l2[i]+l2[j]) if abs(x)%2==0 and abs(y)%2==0: x,y=x//2,y//2 if (x,y) in s: c+=1 #print(c,(x,y)) print(c) ```
instruction
0
58,303
23
116,606
Yes
output
1
58,303
23
116,607
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n points on a plane. All points are different. Find the number of different groups of three points (A, B, C) such that point B is the middle of segment AC. The groups of three points are considered unordered, that is, if point B is the middle of segment AC, then groups (A, B, C) and (C, B, A) are considered the same. Input The first line contains a single integer n (3 ≀ n ≀ 3000) β€” the number of points. Next n lines contain the points. The i-th line contains coordinates of the i-th point: two space-separated integers xi, yi ( - 1000 ≀ xi, yi ≀ 1000). It is guaranteed that all given points are different. Output Print the single number β€” the answer to the problem. Examples Input 3 1 1 2 2 3 3 Output 1 Input 3 0 0 -1 0 0 1 Output 0 Submitted Solution: ``` from math import * n = int(input()) points = {} mets = [] ans = 0 for i in range(n): #print(ans) #print(points) #print(mets) x1, y1 = map(int, input().split()) for met in mets: x2, y2 = met[0], met[1] if x1 + (x1 - x2) in points and y1 + (y1 - y2) in points[x1 + (x1 - x2)]: ans += 1 if x2 + (x2 - x1) in points and y2 + (y2 - y1) in points[y2 + (y2 - y1)]: ans += 1 if (x1 - x2) / 2 in points and (y2 - y1) / 2 in points[(x1 - x2) / 2]: ans += 1 mets += [[x1, y1]] if x1 not in points: points[x1] = {y1} else: points[x1].add(y1) print(ans) ```
instruction
0
58,304
23
116,608
No
output
1
58,304
23
116,609
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n points on a plane. All points are different. Find the number of different groups of three points (A, B, C) such that point B is the middle of segment AC. The groups of three points are considered unordered, that is, if point B is the middle of segment AC, then groups (A, B, C) and (C, B, A) are considered the same. Input The first line contains a single integer n (3 ≀ n ≀ 3000) β€” the number of points. Next n lines contain the points. The i-th line contains coordinates of the i-th point: two space-separated integers xi, yi ( - 1000 ≀ xi, yi ≀ 1000). It is guaranteed that all given points are different. Output Print the single number β€” the answer to the problem. Examples Input 3 1 1 2 2 3 3 Output 1 Input 3 0 0 -1 0 0 1 Output 0 Submitted Solution: ``` #n=int(input()) #n,k=map(int,input().split()) #arr=list(map(int,input().split())) ls=[] for _ in range(int(input())): n,k=map(int,input().split()) ls.append((n,k)) cnt=0 for i in range(len(ls)): for j in range(i+1,len(ls)): var=(ls[i][0]+ls[j][0])//2 ans=(ls[i][1]+ls[j][1])//2 if (var,ans) in ls: if ((ls[i][0]-var)**2+(ls[i][1]-ans)**2)**0.5==((ls[j][0]-var)**2+(ls[j][1]-ans)**2)**0.5: cnt+=1 print(cnt) ```
instruction
0
58,305
23
116,610
No
output
1
58,305
23
116,611
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n points on a plane. All points are different. Find the number of different groups of three points (A, B, C) such that point B is the middle of segment AC. The groups of three points are considered unordered, that is, if point B is the middle of segment AC, then groups (A, B, C) and (C, B, A) are considered the same. Input The first line contains a single integer n (3 ≀ n ≀ 3000) β€” the number of points. Next n lines contain the points. The i-th line contains coordinates of the i-th point: two space-separated integers xi, yi ( - 1000 ≀ xi, yi ≀ 1000). It is guaranteed that all given points are different. Output Print the single number β€” the answer to the problem. Examples Input 3 1 1 2 2 3 3 Output 1 Input 3 0 0 -1 0 0 1 Output 0 Submitted Solution: ``` from math import * n = int(input()) slopes = {} points = [] for i in range(n): x, y = map(int, input().split()) for point in points: if point[0] != x: m = (point[1] - y) / (point[0] - x) const = y - (m*x) else: m, const = inf, inf if str(m) + '-' + str(const) not in slopes: slopes[str(m) + '-' + str(const)] = {str(x) + '-' + str(y), str(point[0]) + '-' + str(point[1])} else: slopes[str(m) + '-' + str(const)].add(str(x) + '-' + str(y)) points += [[x, y]] ans = 0 for slope, elements in slopes.items(): if len(elements) > 2: ans += len(elements) * (len(elements)-1) * (len(elements) - 2) // 6 print(ans) ```
instruction
0
58,306
23
116,612
No
output
1
58,306
23
116,613
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n points on a plane. All points are different. Find the number of different groups of three points (A, B, C) such that point B is the middle of segment AC. The groups of three points are considered unordered, that is, if point B is the middle of segment AC, then groups (A, B, C) and (C, B, A) are considered the same. Input The first line contains a single integer n (3 ≀ n ≀ 3000) β€” the number of points. Next n lines contain the points. The i-th line contains coordinates of the i-th point: two space-separated integers xi, yi ( - 1000 ≀ xi, yi ≀ 1000). It is guaranteed that all given points are different. Output Print the single number β€” the answer to the problem. Examples Input 3 1 1 2 2 3 3 Output 1 Input 3 0 0 -1 0 0 1 Output 0 Submitted Solution: ``` n = int(input()) l,l1 = [],[] l1 = set(l1) for _ in range(n): a,b = map(int , input().split()) l1.add((a,b)) l.append([a,b]) s = [] s = set(s) c=0 for i in range(n): for j in range(i+2,n): a = (l[i][0]+l[j][0])/2 b = (l[i][1]+l[j][1])/2 if (a,b) in l1: c+=1 print(c) ```
instruction
0
58,307
23
116,614
No
output
1
58,307
23
116,615
Provide tags and a correct Python 3 solution for this coding contest problem. Imagine you have an infinite 2D plane with Cartesian coordinate system. Some of the integral points are blocked, and others are not. Two integral points A and B on the plane are 4-connected if and only if: * the Euclidean distance between A and B is one unit and neither A nor B is blocked; * or there is some integral point C, such that A is 4-connected with C, and C is 4-connected with B. Let's assume that the plane doesn't contain blocked points. Consider all the integral points of the plane whose Euclidean distance from the origin is no more than n, we'll name these points special. Chubby Yang wants to get the following property: no special point is 4-connected to some non-special point. To get the property she can pick some integral points of the plane and make them blocked. What is the minimum number of points she needs to pick? Input The first line contains an integer n (0 ≀ n ≀ 4Β·107). Output Print a single integer β€” the minimum number of points that should be blocked. Examples Input 1 Output 4 Input 2 Output 8 Input 3 Output 16
instruction
0
58,364
23
116,728
Tags: math Correct Solution: ``` print(max(1, 4 * int(int(input()) * 2 ** 0.5))) # Made By Mostafa_Khaled ```
output
1
58,364
23
116,729
Provide tags and a correct Python 3 solution for this coding contest problem. Imagine you have an infinite 2D plane with Cartesian coordinate system. Some of the integral points are blocked, and others are not. Two integral points A and B on the plane are 4-connected if and only if: * the Euclidean distance between A and B is one unit and neither A nor B is blocked; * or there is some integral point C, such that A is 4-connected with C, and C is 4-connected with B. Let's assume that the plane doesn't contain blocked points. Consider all the integral points of the plane whose Euclidean distance from the origin is no more than n, we'll name these points special. Chubby Yang wants to get the following property: no special point is 4-connected to some non-special point. To get the property she can pick some integral points of the plane and make them blocked. What is the minimum number of points she needs to pick? Input The first line contains an integer n (0 ≀ n ≀ 4Β·107). Output Print a single integer β€” the minimum number of points that should be blocked. Examples Input 1 Output 4 Input 2 Output 8 Input 3 Output 16
instruction
0
58,365
23
116,730
Tags: math Correct Solution: ``` from math import sqrt n = int(input()) if n == 0: print(1) else: print(4 * int(n * sqrt(2))) ```
output
1
58,365
23
116,731
Provide tags and a correct Python 3 solution for this coding contest problem. Imagine you have an infinite 2D plane with Cartesian coordinate system. Some of the integral points are blocked, and others are not. Two integral points A and B on the plane are 4-connected if and only if: * the Euclidean distance between A and B is one unit and neither A nor B is blocked; * or there is some integral point C, such that A is 4-connected with C, and C is 4-connected with B. Let's assume that the plane doesn't contain blocked points. Consider all the integral points of the plane whose Euclidean distance from the origin is no more than n, we'll name these points special. Chubby Yang wants to get the following property: no special point is 4-connected to some non-special point. To get the property she can pick some integral points of the plane and make them blocked. What is the minimum number of points she needs to pick? Input The first line contains an integer n (0 ≀ n ≀ 4Β·107). Output Print a single integer β€” the minimum number of points that should be blocked. Examples Input 1 Output 4 Input 2 Output 8 Input 3 Output 16
instruction
0
58,366
23
116,732
Tags: math Correct Solution: ``` import math n = int(input()) if n == 0: print(1) else: print(4 * int(n * math.sqrt(2))) ```
output
1
58,366
23
116,733
Provide tags and a correct Python 3 solution for this coding contest problem. Imagine you have an infinite 2D plane with Cartesian coordinate system. Some of the integral points are blocked, and others are not. Two integral points A and B on the plane are 4-connected if and only if: * the Euclidean distance between A and B is one unit and neither A nor B is blocked; * or there is some integral point C, such that A is 4-connected with C, and C is 4-connected with B. Let's assume that the plane doesn't contain blocked points. Consider all the integral points of the plane whose Euclidean distance from the origin is no more than n, we'll name these points special. Chubby Yang wants to get the following property: no special point is 4-connected to some non-special point. To get the property she can pick some integral points of the plane and make them blocked. What is the minimum number of points she needs to pick? Input The first line contains an integer n (0 ≀ n ≀ 4Β·107). Output Print a single integer β€” the minimum number of points that should be blocked. Examples Input 1 Output 4 Input 2 Output 8 Input 3 Output 16
instruction
0
58,367
23
116,734
Tags: math Correct Solution: ``` import math n = int(input()) if n <= 0: print('1') else: x = int(n / math.sqrt(2)) if 2 * x * x + 2 * x + 1 > n * n: print(8 * x) else: print(8 * x + 4) ```
output
1
58,367
23
116,735
Provide tags and a correct Python 3 solution for this coding contest problem. Imagine you have an infinite 2D plane with Cartesian coordinate system. Some of the integral points are blocked, and others are not. Two integral points A and B on the plane are 4-connected if and only if: * the Euclidean distance between A and B is one unit and neither A nor B is blocked; * or there is some integral point C, such that A is 4-connected with C, and C is 4-connected with B. Let's assume that the plane doesn't contain blocked points. Consider all the integral points of the plane whose Euclidean distance from the origin is no more than n, we'll name these points special. Chubby Yang wants to get the following property: no special point is 4-connected to some non-special point. To get the property she can pick some integral points of the plane and make them blocked. What is the minimum number of points she needs to pick? Input The first line contains an integer n (0 ≀ n ≀ 4Β·107). Output Print a single integer β€” the minimum number of points that should be blocked. Examples Input 1 Output 4 Input 2 Output 8 Input 3 Output 16
instruction
0
58,368
23
116,736
Tags: math Correct Solution: ``` n = int(input()) x = 0 y = n count = 0 while y>x: check = (n+x+1)*(n-x-1) if y*y <= check: x+=1 elif (y-1)*(y-1) <= check: x+=1 y-=1 else: y-=1 count+=1 # print(x,y) if n == 0: print(1) else: if x == y: print(count*8) else: print(count*8-4) ```
output
1
58,368
23
116,737
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Imagine you have an infinite 2D plane with Cartesian coordinate system. Some of the integral points are blocked, and others are not. Two integral points A and B on the plane are 4-connected if and only if: * the Euclidean distance between A and B is one unit and neither A nor B is blocked; * or there is some integral point C, such that A is 4-connected with C, and C is 4-connected with B. Let's assume that the plane doesn't contain blocked points. Consider all the integral points of the plane whose Euclidean distance from the origin is no more than n, we'll name these points special. Chubby Yang wants to get the following property: no special point is 4-connected to some non-special point. To get the property she can pick some integral points of the plane and make them blocked. What is the minimum number of points she needs to pick? Input The first line contains an integer n (0 ≀ n ≀ 4Β·107). Output Print a single integer β€” the minimum number of points that should be blocked. Examples Input 1 Output 4 Input 2 Output 8 Input 3 Output 16 Submitted Solution: ``` import math n=int(input()) marked_set = set() for x in range(n+1): max_y = int(math.sqrt(n*n - x*x)) flag=True y = max_y while True: if (x+1)**2 + y**2 > n**2 or (x)**2 + (y+1)**2 > n**2: marked_set.add((x,y)) else: break if y == 0: break else: y-=1 print((len(marked_set)-1)*4) ```
instruction
0
58,369
23
116,738
No
output
1
58,369
23
116,739
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Imagine you have an infinite 2D plane with Cartesian coordinate system. Some of the integral points are blocked, and others are not. Two integral points A and B on the plane are 4-connected if and only if: * the Euclidean distance between A and B is one unit and neither A nor B is blocked; * or there is some integral point C, such that A is 4-connected with C, and C is 4-connected with B. Let's assume that the plane doesn't contain blocked points. Consider all the integral points of the plane whose Euclidean distance from the origin is no more than n, we'll name these points special. Chubby Yang wants to get the following property: no special point is 4-connected to some non-special point. To get the property she can pick some integral points of the plane and make them blocked. What is the minimum number of points she needs to pick? Input The first line contains an integer n (0 ≀ n ≀ 4Β·107). Output Print a single integer β€” the minimum number of points that should be blocked. Examples Input 1 Output 4 Input 2 Output 8 Input 3 Output 16 Submitted Solution: ``` def BinPow(a,n): if n == 1: return a elif n % 2 == 0: return BinPow(a * a, n // 2) else: return a * BinPow(a * a, n // 2) print(BinPow(2,int(input()) + 1)) ```
instruction
0
58,370
23
116,740
No
output
1
58,370
23
116,741
Provide tags and a correct Python 3 solution for this coding contest problem. Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem. A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit. More formally, if a game designer selected cells having coordinates (x1, y1) and (x2, y2), where x1 ≀ x2 and y1 ≀ y2, then all cells having center coordinates (x, y) such that x1 ≀ x ≀ x2 and y1 ≀ y ≀ y2 will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to OX axis, all hexagon centers have integer coordinates and for each integer x there are cells having center with such x coordinate and for each integer y there are cells having center with such y coordinate. It is guaranteed that difference x2 - x1 is divisible by 2. Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map. Help him implement counting of these units before painting. <image> Input The only line of input contains four integers x1, y1, x2, y2 ( - 109 ≀ x1 ≀ x2 ≀ 109, - 109 ≀ y1 ≀ y2 ≀ 109) β€” the coordinates of the centers of two cells. Output Output one integer β€” the number of cells to be filled. Examples Input 1 1 5 5 Output 13
instruction
0
58,453
23
116,906
Tags: math Correct Solution: ``` a,b,c,d=list(map(int,input().split())) if (d-b)%2==0: print(((c-a+1)*(d-b+2))//2-(c-a)//2) else: print(((c-a+1))*((d-b+1)//2)) ```
output
1
58,453
23
116,907
Provide tags and a correct Python 3 solution for this coding contest problem. Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem. A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit. More formally, if a game designer selected cells having coordinates (x1, y1) and (x2, y2), where x1 ≀ x2 and y1 ≀ y2, then all cells having center coordinates (x, y) such that x1 ≀ x ≀ x2 and y1 ≀ y ≀ y2 will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to OX axis, all hexagon centers have integer coordinates and for each integer x there are cells having center with such x coordinate and for each integer y there are cells having center with such y coordinate. It is guaranteed that difference x2 - x1 is divisible by 2. Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map. Help him implement counting of these units before painting. <image> Input The only line of input contains four integers x1, y1, x2, y2 ( - 109 ≀ x1 ≀ x2 ≀ 109, - 109 ≀ y1 ≀ y2 ≀ 109) β€” the coordinates of the centers of two cells. Output Output one integer β€” the number of cells to be filled. Examples Input 1 1 5 5 Output 13
instruction
0
58,454
23
116,908
Tags: math Correct Solution: ``` x1, y1, x2, y2 = [int(x) for x in input().split()] print((y2-y1+1)*(x2-x1)//2+(y2-y1)//2+1) ```
output
1
58,454
23
116,909
Provide tags and a correct Python 3 solution for this coding contest problem. Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem. A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit. More formally, if a game designer selected cells having coordinates (x1, y1) and (x2, y2), where x1 ≀ x2 and y1 ≀ y2, then all cells having center coordinates (x, y) such that x1 ≀ x ≀ x2 and y1 ≀ y ≀ y2 will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to OX axis, all hexagon centers have integer coordinates and for each integer x there are cells having center with such x coordinate and for each integer y there are cells having center with such y coordinate. It is guaranteed that difference x2 - x1 is divisible by 2. Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map. Help him implement counting of these units before painting. <image> Input The only line of input contains four integers x1, y1, x2, y2 ( - 109 ≀ x1 ≀ x2 ≀ 109, - 109 ≀ y1 ≀ y2 ≀ 109) β€” the coordinates of the centers of two cells. Output Output one integer β€” the number of cells to be filled. Examples Input 1 1 5 5 Output 13
instruction
0
58,455
23
116,910
Tags: math Correct Solution: ``` from sys import stdin x1, y1, x2, y2 = map(int, stdin.readline().split()) dx = x2 - x1 dy = y2 - y1 result = ((dx + 1)*(dy + 1)+1)//2 print(result) ```
output
1
58,455
23
116,911
Provide tags and a correct Python 3 solution for this coding contest problem. Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem. A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit. More formally, if a game designer selected cells having coordinates (x1, y1) and (x2, y2), where x1 ≀ x2 and y1 ≀ y2, then all cells having center coordinates (x, y) such that x1 ≀ x ≀ x2 and y1 ≀ y ≀ y2 will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to OX axis, all hexagon centers have integer coordinates and for each integer x there are cells having center with such x coordinate and for each integer y there are cells having center with such y coordinate. It is guaranteed that difference x2 - x1 is divisible by 2. Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map. Help him implement counting of these units before painting. <image> Input The only line of input contains four integers x1, y1, x2, y2 ( - 109 ≀ x1 ≀ x2 ≀ 109, - 109 ≀ y1 ≀ y2 ≀ 109) β€” the coordinates of the centers of two cells. Output Output one integer β€” the number of cells to be filled. Examples Input 1 1 5 5 Output 13
instruction
0
58,456
23
116,912
Tags: math Correct Solution: ``` a, b, c, d = map(int, input().split()) e = (c - a) // 2 + 1 print((2 * e - 1) * ((d - b) // 2 + 1) - (e - 1) * int(not((d - b) % 2))) ```
output
1
58,456
23
116,913
Provide tags and a correct Python 3 solution for this coding contest problem. Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem. A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit. More formally, if a game designer selected cells having coordinates (x1, y1) and (x2, y2), where x1 ≀ x2 and y1 ≀ y2, then all cells having center coordinates (x, y) such that x1 ≀ x ≀ x2 and y1 ≀ y ≀ y2 will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to OX axis, all hexagon centers have integer coordinates and for each integer x there are cells having center with such x coordinate and for each integer y there are cells having center with such y coordinate. It is guaranteed that difference x2 - x1 is divisible by 2. Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map. Help him implement counting of these units before painting. <image> Input The only line of input contains four integers x1, y1, x2, y2 ( - 109 ≀ x1 ≀ x2 ≀ 109, - 109 ≀ y1 ≀ y2 ≀ 109) β€” the coordinates of the centers of two cells. Output Output one integer β€” the number of cells to be filled. Examples Input 1 1 5 5 Output 13
instruction
0
58,457
23
116,914
Tags: math Correct Solution: ``` a = input().split(" ") x1 = int(a[0]) y1 = int(a[1]) x2 = int(a[2]) y2 = int(a[3]) total = 0 ylen = y2 - y1 xlen = x2 - x1 total += (int(xlen / 2) + 1) * (int(ylen/2) + 1) total += int(xlen / 2) * int(ylen / 2) print(int(total)) ```
output
1
58,457
23
116,915
Provide tags and a correct Python 3 solution for this coding contest problem. Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem. A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit. More formally, if a game designer selected cells having coordinates (x1, y1) and (x2, y2), where x1 ≀ x2 and y1 ≀ y2, then all cells having center coordinates (x, y) such that x1 ≀ x ≀ x2 and y1 ≀ y ≀ y2 will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to OX axis, all hexagon centers have integer coordinates and for each integer x there are cells having center with such x coordinate and for each integer y there are cells having center with such y coordinate. It is guaranteed that difference x2 - x1 is divisible by 2. Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map. Help him implement counting of these units before painting. <image> Input The only line of input contains four integers x1, y1, x2, y2 ( - 109 ≀ x1 ≀ x2 ≀ 109, - 109 ≀ y1 ≀ y2 ≀ 109) β€” the coordinates of the centers of two cells. Output Output one integer β€” the number of cells to be filled. Examples Input 1 1 5 5 Output 13
instruction
0
58,458
23
116,916
Tags: math Correct Solution: ``` x1,y1,x2,y2=[int(x) for x in input().split()] a=(y2-y1+1)//2+1 b=a-1 print(((x2-x1+1)//2)*(a+b)+a) ```
output
1
58,458
23
116,917
Provide tags and a correct Python 3 solution for this coding contest problem. Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem. A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit. More formally, if a game designer selected cells having coordinates (x1, y1) and (x2, y2), where x1 ≀ x2 and y1 ≀ y2, then all cells having center coordinates (x, y) such that x1 ≀ x ≀ x2 and y1 ≀ y ≀ y2 will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to OX axis, all hexagon centers have integer coordinates and for each integer x there are cells having center with such x coordinate and for each integer y there are cells having center with such y coordinate. It is guaranteed that difference x2 - x1 is divisible by 2. Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map. Help him implement counting of these units before painting. <image> Input The only line of input contains four integers x1, y1, x2, y2 ( - 109 ≀ x1 ≀ x2 ≀ 109, - 109 ≀ y1 ≀ y2 ≀ 109) β€” the coordinates of the centers of two cells. Output Output one integer β€” the number of cells to be filled. Examples Input 1 1 5 5 Output 13
instruction
0
58,459
23
116,918
Tags: math Correct Solution: ``` x1, y1, x2, y2 = map(int,input().split()) print(((y2 - y1)//2 + 1) * ((x2 - x1)//2 + 1) + ((y2 - y1)//2) * ((x2 - x1)//2)) ```
output
1
58,459
23
116,919
Provide tags and a correct Python 3 solution for this coding contest problem. Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem. A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit. More formally, if a game designer selected cells having coordinates (x1, y1) and (x2, y2), where x1 ≀ x2 and y1 ≀ y2, then all cells having center coordinates (x, y) such that x1 ≀ x ≀ x2 and y1 ≀ y ≀ y2 will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to OX axis, all hexagon centers have integer coordinates and for each integer x there are cells having center with such x coordinate and for each integer y there are cells having center with such y coordinate. It is guaranteed that difference x2 - x1 is divisible by 2. Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map. Help him implement counting of these units before painting. <image> Input The only line of input contains four integers x1, y1, x2, y2 ( - 109 ≀ x1 ≀ x2 ≀ 109, - 109 ≀ y1 ≀ y2 ≀ 109) β€” the coordinates of the centers of two cells. Output Output one integer β€” the number of cells to be filled. Examples Input 1 1 5 5 Output 13
instruction
0
58,460
23
116,920
Tags: math Correct Solution: ``` import math a, b, c, d = map(lambda x: int(x), input().split(' ')) h = 0 w = c - a + 1 h += (d - b + 1) // 2 summ = h * w if((a + b) % 2 == 0): if(d - b) % 2 == 0: summ += w // 2 + w % 2 else: if(d - b) % 2 == 0: summ += w // 2 + w % 2 print(summ) ```
output
1
58,460
23
116,921
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem. A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit. More formally, if a game designer selected cells having coordinates (x1, y1) and (x2, y2), where x1 ≀ x2 and y1 ≀ y2, then all cells having center coordinates (x, y) such that x1 ≀ x ≀ x2 and y1 ≀ y ≀ y2 will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to OX axis, all hexagon centers have integer coordinates and for each integer x there are cells having center with such x coordinate and for each integer y there are cells having center with such y coordinate. It is guaranteed that difference x2 - x1 is divisible by 2. Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map. Help him implement counting of these units before painting. <image> Input The only line of input contains four integers x1, y1, x2, y2 ( - 109 ≀ x1 ≀ x2 ≀ 109, - 109 ≀ y1 ≀ y2 ≀ 109) β€” the coordinates of the centers of two cells. Output Output one integer β€” the number of cells to be filled. Examples Input 1 1 5 5 Output 13 Submitted Solution: ``` x1, y1, x2, y2 = map(int, input().split()) len_y = (abs(y1 - y2) + 1) // 2 + (abs(y1-y2) + 1) % 2 len_x = abs(x1 - x2) + 1 print(len_x * len_y - len_x//2) ```
instruction
0
58,461
23
116,922
Yes
output
1
58,461
23
116,923
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem. A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit. More formally, if a game designer selected cells having coordinates (x1, y1) and (x2, y2), where x1 ≀ x2 and y1 ≀ y2, then all cells having center coordinates (x, y) such that x1 ≀ x ≀ x2 and y1 ≀ y ≀ y2 will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to OX axis, all hexagon centers have integer coordinates and for each integer x there are cells having center with such x coordinate and for each integer y there are cells having center with such y coordinate. It is guaranteed that difference x2 - x1 is divisible by 2. Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map. Help him implement counting of these units before painting. <image> Input The only line of input contains four integers x1, y1, x2, y2 ( - 109 ≀ x1 ≀ x2 ≀ 109, - 109 ≀ y1 ≀ y2 ≀ 109) β€” the coordinates of the centers of two cells. Output Output one integer β€” the number of cells to be filled. Examples Input 1 1 5 5 Output 13 Submitted Solution: ``` x1, y1, x2, y2 = map(int, input().split()) xdif = x2-x1 ydif = y2-y1 print(xdif//2*ydif//2 + (xdif//2+1) * (ydif//2 + 1)) ```
instruction
0
58,462
23
116,924
Yes
output
1
58,462
23
116,925
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem. A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit. More formally, if a game designer selected cells having coordinates (x1, y1) and (x2, y2), where x1 ≀ x2 and y1 ≀ y2, then all cells having center coordinates (x, y) such that x1 ≀ x ≀ x2 and y1 ≀ y ≀ y2 will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to OX axis, all hexagon centers have integer coordinates and for each integer x there are cells having center with such x coordinate and for each integer y there are cells having center with such y coordinate. It is guaranteed that difference x2 - x1 is divisible by 2. Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map. Help him implement counting of these units before painting. <image> Input The only line of input contains four integers x1, y1, x2, y2 ( - 109 ≀ x1 ≀ x2 ≀ 109, - 109 ≀ y1 ≀ y2 ≀ 109) β€” the coordinates of the centers of two cells. Output Output one integer β€” the number of cells to be filled. Examples Input 1 1 5 5 Output 13 Submitted Solution: ``` x1, y1, x2, y2 = list(map(int, input().split(' '))) print(((x2 - x1) // 2 + 1) * ((y2 - y1) // 2 + 1) + ((x2 - x1) // 2) * ((y2 - y1) // 2)) ```
instruction
0
58,463
23
116,926
Yes
output
1
58,463
23
116,927
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem. A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit. More formally, if a game designer selected cells having coordinates (x1, y1) and (x2, y2), where x1 ≀ x2 and y1 ≀ y2, then all cells having center coordinates (x, y) such that x1 ≀ x ≀ x2 and y1 ≀ y ≀ y2 will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to OX axis, all hexagon centers have integer coordinates and for each integer x there are cells having center with such x coordinate and for each integer y there are cells having center with such y coordinate. It is guaranteed that difference x2 - x1 is divisible by 2. Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map. Help him implement counting of these units before painting. <image> Input The only line of input contains four integers x1, y1, x2, y2 ( - 109 ≀ x1 ≀ x2 ≀ 109, - 109 ≀ y1 ≀ y2 ≀ 109) β€” the coordinates of the centers of two cells. Output Output one integer β€” the number of cells to be filled. Examples Input 1 1 5 5 Output 13 Submitted Solution: ``` import math def main(): x1, y1, x2, y2 = map(int, input().split()) y, x = y2-y1, (x2-x1)//2 ans = 0 ans += (1+x)*(y//2 + 1) ans += x * (math.ceil(y/2)) print(ans) main() ```
instruction
0
58,464
23
116,928
Yes
output
1
58,464
23
116,929
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem. A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit. More formally, if a game designer selected cells having coordinates (x1, y1) and (x2, y2), where x1 ≀ x2 and y1 ≀ y2, then all cells having center coordinates (x, y) such that x1 ≀ x ≀ x2 and y1 ≀ y ≀ y2 will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to OX axis, all hexagon centers have integer coordinates and for each integer x there are cells having center with such x coordinate and for each integer y there are cells having center with such y coordinate. It is guaranteed that difference x2 - x1 is divisible by 2. Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map. Help him implement counting of these units before painting. <image> Input The only line of input contains four integers x1, y1, x2, y2 ( - 109 ≀ x1 ≀ x2 ≀ 109, - 109 ≀ y1 ≀ y2 ≀ 109) β€” the coordinates of the centers of two cells. Output Output one integer β€” the number of cells to be filled. Examples Input 1 1 5 5 Output 13 Submitted Solution: ``` x1,y1,x2,y2 = input().split( ) x1=int(x1) y1=int(y1) x2=int(x2) y2=int(y2) x =int(x2 - x1) y =int(y2 - y1) if x % 2 == 0: if y % 2 == 1: n= int(int( x + 1 ) * int(y + 1) / 2) elif x1 % 2 == 0 and y1 % 2 == 0: n= int(int(x * y + x + y) / 2) + 1 elif x1 % 2 == 1 and y1 % 2 == 1 and x * y > 1000000: t=int(x*y+x+y) t1=t%1000/2 t2=t/1000/2 n=int(t2*1000)+int(t1)+1 elif x1 % 2 == 1 and y1 % 2 == 1 and x * y <= 1000000: n= int(int(x * y + x + y) / 2) + 1 else: n= int((x * y + x + y) / 2) else: n = int((x + 1) / 2 * ( y + 1 )) print(n) ```
instruction
0
58,465
23
116,930
No
output
1
58,465
23
116,931
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem. A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit. More formally, if a game designer selected cells having coordinates (x1, y1) and (x2, y2), where x1 ≀ x2 and y1 ≀ y2, then all cells having center coordinates (x, y) such that x1 ≀ x ≀ x2 and y1 ≀ y ≀ y2 will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to OX axis, all hexagon centers have integer coordinates and for each integer x there are cells having center with such x coordinate and for each integer y there are cells having center with such y coordinate. It is guaranteed that difference x2 - x1 is divisible by 2. Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map. Help him implement counting of these units before painting. <image> Input The only line of input contains four integers x1, y1, x2, y2 ( - 109 ≀ x1 ≀ x2 ≀ 109, - 109 ≀ y1 ≀ y2 ≀ 109) β€” the coordinates of the centers of two cells. Output Output one integer β€” the number of cells to be filled. Examples Input 1 1 5 5 Output 13 Submitted Solution: ``` x1,y1,x2,y2=map(int,input().split()) x=x2-x1 y=y2-y1 a=y//2 b=y//2 if y1%2 and y2%2: b+=1 elif (not y1%2) and y2%2: b+=1 a+=1 elif y1%2 and (not y2%2): a+=1 b+=1 else: a+=1 if x%2==0: print(x//2*(a+b)+(b if x1%2 else a)) else: print((x//2+1)*(a+b)) ```
instruction
0
58,466
23
116,932
No
output
1
58,466
23
116,933
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem. A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit. More formally, if a game designer selected cells having coordinates (x1, y1) and (x2, y2), where x1 ≀ x2 and y1 ≀ y2, then all cells having center coordinates (x, y) such that x1 ≀ x ≀ x2 and y1 ≀ y ≀ y2 will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to OX axis, all hexagon centers have integer coordinates and for each integer x there are cells having center with such x coordinate and for each integer y there are cells having center with such y coordinate. It is guaranteed that difference x2 - x1 is divisible by 2. Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map. Help him implement counting of these units before painting. <image> Input The only line of input contains four integers x1, y1, x2, y2 ( - 109 ≀ x1 ≀ x2 ≀ 109, - 109 ≀ y1 ≀ y2 ≀ 109) β€” the coordinates of the centers of two cells. Output Output one integer β€” the number of cells to be filled. Examples Input 1 1 5 5 Output 13 Submitted Solution: ``` import sys import math # sys.stdin = open('input.txt') # sys.stdout = open('output.txt', 'w') def main(): x1, y1, x2, y2 = map(int, input().split()) dx = x2 - x1 dy = y2 - y1 h1 = dx // 2 + 1 h2 = dx // 2 v1 = (y2 - y2 // 2) - (y1 - 1 - (y1 - 1) // 2) v2 = y2 // 2 - (y1 - 1) // 2 if dy % 2 == 1: v2 += 1 if x1 % 2 == 0: print(h1 * v2 + h2 * v1) else: print(h1 * v1 + h2 * v2) main() ```
instruction
0
58,467
23
116,934
No
output
1
58,467
23
116,935
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem. A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit. More formally, if a game designer selected cells having coordinates (x1, y1) and (x2, y2), where x1 ≀ x2 and y1 ≀ y2, then all cells having center coordinates (x, y) such that x1 ≀ x ≀ x2 and y1 ≀ y ≀ y2 will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to OX axis, all hexagon centers have integer coordinates and for each integer x there are cells having center with such x coordinate and for each integer y there are cells having center with such y coordinate. It is guaranteed that difference x2 - x1 is divisible by 2. Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map. Help him implement counting of these units before painting. <image> Input The only line of input contains four integers x1, y1, x2, y2 ( - 109 ≀ x1 ≀ x2 ≀ 109, - 109 ≀ y1 ≀ y2 ≀ 109) β€” the coordinates of the centers of two cells. Output Output one integer β€” the number of cells to be filled. Examples Input 1 1 5 5 Output 13 Submitted Solution: ``` from math import * a=input() a=a.split(" ") x1=int(a[0]) y1=int(a[1]) x2=int(a[2]) y2=int(a[3]) x=x2-x1+1 y=(y2+1-y1+1)/2 total=x*y total-=floor(x/2) print(int(total)) ```
instruction
0
58,468
23
116,936
No
output
1
58,468
23
116,937
Provide a correct Python 3 solution for this coding contest problem. You are given an H Γ— W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process. Constraints * 1 \leq H,W \leq 50 * S_i is a string of length W consisting of `#` and `.`. Input Input is given from Standard Input in the following format: H W S_1 : S_H Output Print the H strings after the process. The i-th line should contain a string T_i of length W, where the j-th character in T_i corresponds to the square at the i-th row from the top and j-th row from the left in the grid (1 \leq i \leq H, 1 \leq j \leq W). Examples Input 3 5 ..... .#.#. ..... Output 11211 1#2#1 11211 Input 3 5 Output Input 6 6 . .#.## .# .#..#. .##.. .#... Output 3 8#7## 5# 4#65#2 5##21 4#310
instruction
0
58,735
23
117,470
"Correct Solution: ``` H, W = [int(i) for i in input().split()] S = ['.' * (W + 2)] for i in range(H): S.append('.' + input() + '.') S.append('.' * (W + 2)) mine = [[0 for _ in range(W)] for _ in range(H)] for j in range(H): for i in range(W): if S[j + 1][i + 1] == '#': mine[j][i] = '#' else: mine[j][i] = sum([s[i:i + 3].count('#') for s in S[j:j + 3]]) for m in mine: print(''.join([str(i) for i in m])) ```
output
1
58,735
23
117,471
Provide a correct Python 3 solution for this coding contest problem. You are given an H Γ— W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process. Constraints * 1 \leq H,W \leq 50 * S_i is a string of length W consisting of `#` and `.`. Input Input is given from Standard Input in the following format: H W S_1 : S_H Output Print the H strings after the process. The i-th line should contain a string T_i of length W, where the j-th character in T_i corresponds to the square at the i-th row from the top and j-th row from the left in the grid (1 \leq i \leq H, 1 \leq j \leq W). Examples Input 3 5 ..... .#.#. ..... Output 11211 1#2#1 11211 Input 3 5 Output Input 6 6 . .#.## .# .#..#. .##.. .#... Output 3 8#7## 5# 4#65#2 5##21 4#310
instruction
0
58,736
23
117,472
"Correct Solution: ``` h,w=map(int,input().split()) m=[list(input()) for _ in range(h)] ans=[[0]*w for _ in range(h)] for i in range(h): for j in range(w): if m[i][j]=='#': ans[i][j]='#' else: for k in range(max(0,i-1),min(h,i+2)): ans[i][j]+=m[k][max(0,j-1):min(w,j+2)].count('#') [print(*l,sep='') for l in ans] ```
output
1
58,736
23
117,473
Provide a correct Python 3 solution for this coding contest problem. You are given an H Γ— W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process. Constraints * 1 \leq H,W \leq 50 * S_i is a string of length W consisting of `#` and `.`. Input Input is given from Standard Input in the following format: H W S_1 : S_H Output Print the H strings after the process. The i-th line should contain a string T_i of length W, where the j-th character in T_i corresponds to the square at the i-th row from the top and j-th row from the left in the grid (1 \leq i \leq H, 1 \leq j \leq W). Examples Input 3 5 ..... .#.#. ..... Output 11211 1#2#1 11211 Input 3 5 Output Input 6 6 . .#.## .# .#..#. .##.. .#... Output 3 8#7## 5# 4#65#2 5##21 4#310
instruction
0
58,737
23
117,474
"Correct Solution: ``` H, W = [int(_) for _ in input().split()] S = ["."*(H+2)] + ["." + input() + "." for i in range(H)] + ["."*(H+2)] for y in range(H): for x in range(W): c = S[y+1][x+1] if c != "#": c = str(sum([S[i][x:x+3].count("#") for i in range(y,y+3)])) print(c, sep="", end="") print() ```
output
1
58,737
23
117,475
Provide a correct Python 3 solution for this coding contest problem. You are given an H Γ— W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process. Constraints * 1 \leq H,W \leq 50 * S_i is a string of length W consisting of `#` and `.`. Input Input is given from Standard Input in the following format: H W S_1 : S_H Output Print the H strings after the process. The i-th line should contain a string T_i of length W, where the j-th character in T_i corresponds to the square at the i-th row from the top and j-th row from the left in the grid (1 \leq i \leq H, 1 \leq j \leq W). Examples Input 3 5 ..... .#.#. ..... Output 11211 1#2#1 11211 Input 3 5 Output Input 6 6 . .#.## .# .#..#. .##.. .#... Output 3 8#7## 5# 4#65#2 5##21 4#310
instruction
0
58,738
23
117,476
"Correct Solution: ``` h,w=map(int, input().split()) w1=['.'*(w+2)] s=w1+['.'+input()+'.' for _ in range(h)]+w1 for i in range(1,h+1): for j in range(1,w+1): if s[i][j]=='.': t=s[i-1][j-1:j+2]+s[i][j-1:j+2]+s[i+1][j-1:j+2] s[i]=s[i][:j]+str(t.count('#'))+s[i][j+1:] print(s[i][1:-1]) ```
output
1
58,738
23
117,477
Provide a correct Python 3 solution for this coding contest problem. You are given an H Γ— W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process. Constraints * 1 \leq H,W \leq 50 * S_i is a string of length W consisting of `#` and `.`. Input Input is given from Standard Input in the following format: H W S_1 : S_H Output Print the H strings after the process. The i-th line should contain a string T_i of length W, where the j-th character in T_i corresponds to the square at the i-th row from the top and j-th row from the left in the grid (1 \leq i \leq H, 1 \leq j \leq W). Examples Input 3 5 ..... .#.#. ..... Output 11211 1#2#1 11211 Input 3 5 Output Input 6 6 . .#.## .# .#..#. .##.. .#... Output 3 8#7## 5# 4#65#2 5##21 4#310
instruction
0
58,739
23
117,478
"Correct Solution: ``` H, W = map(int,input().split()) S = [input() for _ in range(H)] for i in range(H): rs = '' for j in range(W): if(S[i][j] == '#'): rs += '#' else: tmp = 0 for s in S[max(0, i-1): min(H, i+2)]: tmp += s[max(0, j-1): min(W, j+2)].count('#') rs += str(tmp) print(rs) ```
output
1
58,739
23
117,479
Provide a correct Python 3 solution for this coding contest problem. You are given an H Γ— W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process. Constraints * 1 \leq H,W \leq 50 * S_i is a string of length W consisting of `#` and `.`. Input Input is given from Standard Input in the following format: H W S_1 : S_H Output Print the H strings after the process. The i-th line should contain a string T_i of length W, where the j-th character in T_i corresponds to the square at the i-th row from the top and j-th row from the left in the grid (1 \leq i \leq H, 1 \leq j \leq W). Examples Input 3 5 ..... .#.#. ..... Output 11211 1#2#1 11211 Input 3 5 Output Input 6 6 . .#.## .# .#..#. .##.. .#... Output 3 8#7## 5# 4#65#2 5##21 4#310
instruction
0
58,740
23
117,480
"Correct Solution: ``` H,W=map(int,input().split()) M=[input() for x in range(H)] A=[[0 for x in range(W)]for y in range(H)] nx=[-1,0,1] ny=[-1,0,1] for i in range(H): for j in range(W): if M[i][j]=='.': cnt=0 for x in nx: for y in ny: if (0<= i+x <H) and (0<= j+y <W) and M[i+x][j+y]=="#": cnt+=1 A[i][j]=str(cnt) else: A[i][j]="#" for i in range(H): print("".join(A[i])) ```
output
1
58,740
23
117,481
Provide a correct Python 3 solution for this coding contest problem. You are given an H Γ— W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process. Constraints * 1 \leq H,W \leq 50 * S_i is a string of length W consisting of `#` and `.`. Input Input is given from Standard Input in the following format: H W S_1 : S_H Output Print the H strings after the process. The i-th line should contain a string T_i of length W, where the j-th character in T_i corresponds to the square at the i-th row from the top and j-th row from the left in the grid (1 \leq i \leq H, 1 \leq j \leq W). Examples Input 3 5 ..... .#.#. ..... Output 11211 1#2#1 11211 Input 3 5 Output Input 6 6 . .#.## .# .#..#. .##.. .#... Output 3 8#7## 5# 4#65#2 5##21 4#310
instruction
0
58,741
23
117,482
"Correct Solution: ``` a,b=map(int,input().split()) s=[input()for i in range(a)] for i in range(a): for j in range(b): c=0 if s[i][j]==".": p=s[i] s[i]=p[:j]+str(sum([t[max(0,j-1):min(b,j+2)].count("#")for t in s[max(0,i-1):min(a,i+2)]]))+p[j+1:] for i in range(a): print(s[i]) ```
output
1
58,741
23
117,483
Provide a correct Python 3 solution for this coding contest problem. You are given an H Γ— W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process. Constraints * 1 \leq H,W \leq 50 * S_i is a string of length W consisting of `#` and `.`. Input Input is given from Standard Input in the following format: H W S_1 : S_H Output Print the H strings after the process. The i-th line should contain a string T_i of length W, where the j-th character in T_i corresponds to the square at the i-th row from the top and j-th row from the left in the grid (1 \leq i \leq H, 1 \leq j \leq W). Examples Input 3 5 ..... .#.#. ..... Output 11211 1#2#1 11211 Input 3 5 Output Input 6 6 . .#.## .# .#..#. .##.. .#... Output 3 8#7## 5# 4#65#2 5##21 4#310
instruction
0
58,742
23
117,484
"Correct Solution: ``` h,w=map(int,input().split()) s=[input() for _ in range(h)] for i in range(h): ans="" for j in range(w): if(s[i][j]=="#"): ans+="#" else: tmp=0 for k in s[max(0, i-1):min(h, i+2)]: tmp+=k[max(0, j-1):min(w, j+2)].count("#") ans+=str(tmp) print(ans) ```
output
1
58,742
23
117,485
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an H Γ— W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process. Constraints * 1 \leq H,W \leq 50 * S_i is a string of length W consisting of `#` and `.`. Input Input is given from Standard Input in the following format: H W S_1 : S_H Output Print the H strings after the process. The i-th line should contain a string T_i of length W, where the j-th character in T_i corresponds to the square at the i-th row from the top and j-th row from the left in the grid (1 \leq i \leq H, 1 \leq j \leq W). Examples Input 3 5 ..... .#.#. ..... Output 11211 1#2#1 11211 Input 3 5 Output Input 6 6 . .#.## .# .#..#. .##.. .#... Output 3 8#7## 5# 4#65#2 5##21 4#310 Submitted Solution: ``` h, w = map(int, input().split()) s = [input() for _ in range(h)] for i in range(h): for j in range(w): if s[i][j] == ".": sum = 0 for a in range(max(i-1, 0), min(i+2, h)): for b in range(max(j-1, 0), min(j+2, w)): if s[a][b] == "#": sum += 1 print(sum, end="") else: print("#", end="") print() ```
instruction
0
58,743
23
117,486
Yes
output
1
58,743
23
117,487
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an H Γ— W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process. Constraints * 1 \leq H,W \leq 50 * S_i is a string of length W consisting of `#` and `.`. Input Input is given from Standard Input in the following format: H W S_1 : S_H Output Print the H strings after the process. The i-th line should contain a string T_i of length W, where the j-th character in T_i corresponds to the square at the i-th row from the top and j-th row from the left in the grid (1 \leq i \leq H, 1 \leq j \leq W). Examples Input 3 5 ..... .#.#. ..... Output 11211 1#2#1 11211 Input 3 5 Output Input 6 6 . .#.## .# .#..#. .##.. .#... Output 3 8#7## 5# 4#65#2 5##21 4#310 Submitted Solution: ``` H,W = map(int,input().split()) S = [(2+W)*"."]+["."+input()+"." for h in range(H)]+[(2+W)*"."] for h in range(1,1+H): for w in range(1,1+W): if S[h][w]!="#": s = S[h-1][w-1:w+2]+S[h][w-1]+S[h][w+1]+S[h+1][w-1:w+2] S[h]=S[h][:w]+str(s.count("#"))+S[h][w+1:] for h in range(1,1+H): print(S[h][1:1+W]) ```
instruction
0
58,744
23
117,488
Yes
output
1
58,744
23
117,489
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an H Γ— W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process. Constraints * 1 \leq H,W \leq 50 * S_i is a string of length W consisting of `#` and `.`. Input Input is given from Standard Input in the following format: H W S_1 : S_H Output Print the H strings after the process. The i-th line should contain a string T_i of length W, where the j-th character in T_i corresponds to the square at the i-th row from the top and j-th row from the left in the grid (1 \leq i \leq H, 1 \leq j \leq W). Examples Input 3 5 ..... .#.#. ..... Output 11211 1#2#1 11211 Input 3 5 Output Input 6 6 . .#.## .# .#..#. .##.. .#... Output 3 8#7## 5# 4#65#2 5##21 4#310 Submitted Solution: ``` def checkmine(i,j): count=0 for a in range(-1,2): for b in range(-1,2): if 0<=a+i<n and 0<=b+j<m: if field[a+i][b+j]=="#":count+=1 return count n,m=map(int,input().split()) field=[] for i in range(n):field.append(list(input())) for i in range(n): for j in range(m): if field[i][j]==".":field[i][j]=checkmine(i,j) for i in field:print(''.join(map(str,i))) ```
instruction
0
58,745
23
117,490
Yes
output
1
58,745
23
117,491
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an H Γ— W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process. Constraints * 1 \leq H,W \leq 50 * S_i is a string of length W consisting of `#` and `.`. Input Input is given from Standard Input in the following format: H W S_1 : S_H Output Print the H strings after the process. The i-th line should contain a string T_i of length W, where the j-th character in T_i corresponds to the square at the i-th row from the top and j-th row from the left in the grid (1 \leq i \leq H, 1 \leq j \leq W). Examples Input 3 5 ..... .#.#. ..... Output 11211 1#2#1 11211 Input 3 5 Output Input 6 6 . .#.## .# .#..#. .##.. .#... Output 3 8#7## 5# 4#65#2 5##21 4#310 Submitted Solution: ``` h, w = map(int,input().split()) s = [input() for i in range(h)] for i in range(h): l = "" for j in range(w): if s[i][j] == "#": l += "#" else: l += str(sum([t[max(0,j-1):min(w,j+2)].count("#") for t in s[max(0,i-1):min(h,i+2)]])) print(l) ```
instruction
0
58,746
23
117,492
Yes
output
1
58,746
23
117,493
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an H Γ— W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process. Constraints * 1 \leq H,W \leq 50 * S_i is a string of length W consisting of `#` and `.`. Input Input is given from Standard Input in the following format: H W S_1 : S_H Output Print the H strings after the process. The i-th line should contain a string T_i of length W, where the j-th character in T_i corresponds to the square at the i-th row from the top and j-th row from the left in the grid (1 \leq i \leq H, 1 \leq j \leq W). Examples Input 3 5 ..... .#.#. ..... Output 11211 1#2#1 11211 Input 3 5 Output Input 6 6 . .#.## .# .#..#. .##.. .#... Output 3 8#7## 5# 4#65#2 5##21 4#310 Submitted Solution: ``` h, w = map(int, input().split()) s = [list(input()) for _ in range(h)] print(s) dx = [-1, 0, 1] dy = [-1, 0, 1] for i in range(h): for j in range(w): if s[i][j] == '#': for d_x in dx: for d_y in dy: if 0 <= i + d_x < h and 0 <= j + d_y < w: if s[i + d_x][j + d_y] != '#': if s[i + d_x][j + d_y] == '.': s[i + d_x][j + d_y] = 1 else: s[i + d_x][j + d_y] += 1 print(s) ```
instruction
0
58,747
23
117,494
No
output
1
58,747
23
117,495