message
stringlengths
2
19.9k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
322
108k
cluster
float64
15
15
__index_level_0__
int64
644
217k
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Memory is performing a walk on the two-dimensional plane, starting at the origin. He is given a string s with his directions for motion: * An 'L' indicates he should move one unit left. * ...
instruction
0
35,626
15
71,252
No
output
1
35,626
15
71,253
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Memory is performing a walk on the two-dimensional plane, starting at the origin. He is given a string s with his directions for motion: * An 'L' indicates he should move one unit left. * ...
instruction
0
35,627
15
71,254
No
output
1
35,627
15
71,255
Provide tags and a correct Python 3 solution for this coding contest problem. Vanya decided to walk in the field of size n Γ— n cells. The field contains m apple trees, the i-th apple tree is at the cell with coordinates (xi, yi). Vanya moves towards vector (dx, dy). That means that if Vanya is now at the cell (x, y), ...
instruction
0
36,488
15
72,976
Tags: math Correct Solution: ``` def gcd(a, b): if b == 0: return a, 1, 0 else: d, x, y = gcd(b, a % b) return d, y, x - y * (a // b) n,m,dx,dy = map(int,input().split()) c = [0]*1000000 d, x, y = gcd(-n, dx) mu = dy * y % n for i in range(m): a, b = map(int,input().split()) ...
output
1
36,488
15
72,977
Provide tags and a correct Python 3 solution for this coding contest problem. Vanya decided to walk in the field of size n Γ— n cells. The field contains m apple trees, the i-th apple tree is at the cell with coordinates (xi, yi). Vanya moves towards vector (dx, dy). That means that if Vanya is now at the cell (x, y), ...
instruction
0
36,489
15
72,978
Tags: math Correct Solution: ``` from sys import stdin def egcd(a, b): x = v = 0 y = u = 1 while a: q, r = divmod(b, a) a, b, x, y, u, v = r, a, u, v, x - u * q, y - v * q return x, y, b def main(): n, m, dx, dy = map(int, stdin.readline().strip().split()) step = egcd(dx, n)[...
output
1
36,489
15
72,979
Provide tags and a correct Python 3 solution for this coding contest problem. Vanya decided to walk in the field of size n Γ— n cells. The field contains m apple trees, the i-th apple tree is at the cell with coordinates (xi, yi). Vanya moves towards vector (dx, dy). That means that if Vanya is now at the cell (x, y), ...
instruction
0
36,490
15
72,980
Tags: math Correct Solution: ``` n, m, dx, dy = map(int, input().split()) zero = [0] * n x, y = 0, 0 for i in range(n): zero[x] = y x = (x + dx) % n y = (y + dy) % n cnt = [0] * n for _ in range(m): x, y = map(int, input().split()) cnt[(y - zero[x]) % n] += 1 max_val = max(cnt) max_pos = cnt.inde...
output
1
36,490
15
72,981
Provide tags and a correct Python 3 solution for this coding contest problem. Vanya decided to walk in the field of size n Γ— n cells. The field contains m apple trees, the i-th apple tree is at the cell with coordinates (xi, yi). Vanya moves towards vector (dx, dy). That means that if Vanya is now at the cell (x, y), ...
instruction
0
36,491
15
72,982
Tags: math Correct Solution: ``` import math import itertools def euclid_algorithm(a, b): t1, t2 = abs(a), abs(b) #saving equalities: #t1 == x1 * a + y1 * b, #t2 == x2 * a + y2 * b. x1, y1, x2, y2 = int(math.copysign(1, a)), 0, 0, int(math.copysign(1, b)) if t1 < t2: t1, t2 = t2, t1 ...
output
1
36,491
15
72,983
Provide tags and a correct Python 3 solution for this coding contest problem. Vanya decided to walk in the field of size n Γ— n cells. The field contains m apple trees, the i-th apple tree is at the cell with coordinates (xi, yi). Vanya moves towards vector (dx, dy). That means that if Vanya is now at the cell (x, y), ...
instruction
0
36,492
15
72,984
Tags: math Correct Solution: ``` n, m, dx, dy = map(int, input().split()) y = [k * dy % n for k in range(n)] k = [0] * n for i in range(n): k[y[i]] = i trees = [0] * n for i in range(m): x, y = map(int, input().split()) trees[(x - k[y] * dx) % n] += 1 max = 0 best_x = 0 for i in range(n): if trees[i] > ...
output
1
36,492
15
72,985
Provide tags and a correct Python 3 solution for this coding contest problem. Vanya decided to walk in the field of size n Γ— n cells. The field contains m apple trees, the i-th apple tree is at the cell with coordinates (xi, yi). Vanya moves towards vector (dx, dy). That means that if Vanya is now at the cell (x, y), ...
instruction
0
36,493
15
72,986
Tags: math Correct Solution: ``` n, m, dx, dy = map(int, input().split()) rel = [0] * n x, y = 0, 0 for i in range(n): rel[x] = y x = (x + dx) % n y = (y + dy) % n cnt = [0] * n for _ in range(m): x, y = map(int, input().split()) cnt[(y - rel[x]) % n] += 1 max_val = max(cnt) max_pos = cnt.index(m...
output
1
36,493
15
72,987
Provide tags and a correct Python 3 solution for this coding contest problem. Vanya decided to walk in the field of size n Γ— n cells. The field contains m apple trees, the i-th apple tree is at the cell with coordinates (xi, yi). Vanya moves towards vector (dx, dy). That means that if Vanya is now at the cell (x, y), ...
instruction
0
36,494
15
72,988
Tags: math Correct Solution: ``` def gcdex(a, b): if a == 0: return b, 0, 1 g, x, y = gcdex(b % a, a) x, y = y - (b // a) * x, x return g, x, y s = input() #s = "5 5 2 3" n, m, dx, dy = map(int, s.split()) step = dy * n + dx #ss = ("0 0", "1 2", "1 3", "2 4", "3 1") ans = {} for i ...
output
1
36,494
15
72,989
Provide tags and a correct Python 3 solution for this coding contest problem. Vanya decided to walk in the field of size n Γ— n cells. The field contains m apple trees, the i-th apple tree is at the cell with coordinates (xi, yi). Vanya moves towards vector (dx, dy). That means that if Vanya is now at the cell (x, y), ...
instruction
0
36,495
15
72,990
Tags: math Correct Solution: ``` n,m,dx,dy = map(int,input().split()) x=y=0 a=[0]*n c=[0]*n for i in range(1,n): x = (x+dx)%n y = (y+dy)%n a[x]=y for i in range(m): x,y = map(int,input().split()) index = (y-a[x]+n)%n; c[index] += 1 ans = 0 for i in range(n): if c[i] > c[ans]: ans = i print(0, ans) ```
output
1
36,495
15
72,991
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vanya decided to walk in the field of size n Γ— n cells. The field contains m apple trees, the i-th apple tree is at the cell with coordinates (xi, yi). Vanya moves towards vector (dx, dy). That ...
instruction
0
36,496
15
72,992
Yes
output
1
36,496
15
72,993
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vanya decided to walk in the field of size n Γ— n cells. The field contains m apple trees, the i-th apple tree is at the cell with coordinates (xi, yi). Vanya moves towards vector (dx, dy). That ...
instruction
0
36,497
15
72,994
Yes
output
1
36,497
15
72,995
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vanya decided to walk in the field of size n Γ— n cells. The field contains m apple trees, the i-th apple tree is at the cell with coordinates (xi, yi). Vanya moves towards vector (dx, dy). That ...
instruction
0
36,498
15
72,996
Yes
output
1
36,498
15
72,997
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vanya decided to walk in the field of size n Γ— n cells. The field contains m apple trees, the i-th apple tree is at the cell with coordinates (xi, yi). Vanya moves towards vector (dx, dy). That ...
instruction
0
36,499
15
72,998
No
output
1
36,499
15
72,999
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vanya decided to walk in the field of size n Γ— n cells. The field contains m apple trees, the i-th apple tree is at the cell with coordinates (xi, yi). Vanya moves towards vector (dx, dy). That ...
instruction
0
36,500
15
73,000
No
output
1
36,500
15
73,001
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vanya decided to walk in the field of size n Γ— n cells. The field contains m apple trees, the i-th apple tree is at the cell with coordinates (xi, yi). Vanya moves towards vector (dx, dy). That ...
instruction
0
36,501
15
73,002
No
output
1
36,501
15
73,003
Provide tags and a correct Python 3 solution for this coding contest problem. Little C loves number Β«3Β» very much. He loves all things about it. Now he is playing a game on a chessboard of size n Γ— m. The cell in the x-th row and in the y-th column is called (x,y). Initially, The chessboard is empty. Each time, he pl...
instruction
0
36,864
15
73,728
Tags: brute force, constructive algorithms, flows, graph matchings Correct Solution: ``` N,M = map(int,input().split()) l = [0,1,2,3,2,1] res = float('inf') for (n,m) in ((N,M),(M,N)): if l[n%6]==0: print(n*m) exit() elif l[n%6]==1: tmp = l[m%6] res = min(res,tmp) elif l[n%...
output
1
36,864
15
73,729
Provide tags and a correct Python 3 solution for this coding contest problem. Little C loves number Β«3Β» very much. He loves all things about it. Now he is playing a game on a chessboard of size n Γ— m. The cell in the x-th row and in the y-th column is called (x,y). Initially, The chessboard is empty. Each time, he pl...
instruction
0
36,865
15
73,730
Tags: brute force, constructive algorithms, flows, graph matchings Correct Solution: ``` n, m = map(int, input().split()) if n > m: n, m = m, n if n == 1: ans = (m//6)*6+2*max(m%6-3, 0) print(ans) elif n == 2: if m == 2: print(0) elif m == 3: print(4) elif m == 7: prin...
output
1
36,865
15
73,731
Provide tags and a correct Python 3 solution for this coding contest problem. Little C loves number Β«3Β» very much. He loves all things about it. Now he is playing a game on a chessboard of size n Γ— m. The cell in the x-th row and in the y-th column is called (x,y). Initially, The chessboard is empty. Each time, he pl...
instruction
0
36,866
15
73,732
Tags: brute force, constructive algorithms, flows, graph matchings Correct Solution: ``` n,m=map(int,input().split(" ")) if n==1 or m==1: print((((n*m)//6)*6)+((n*m)%6>3)*((((n*m)%6)%3)*2)) elif n*m<6: print(0) elif n*m==6: print(4) elif n*m==14: print(12) # elif (n==2 and m%2==1) or (m==2 and...
output
1
36,866
15
73,733
Provide tags and a correct Python 3 solution for this coding contest problem. Little C loves number Β«3Β» very much. He loves all things about it. Now he is playing a game on a chessboard of size n Γ— m. The cell in the x-th row and in the y-th column is called (x,y). Initially, The chessboard is empty. Each time, he pl...
instruction
0
36,867
15
73,734
Tags: brute force, constructive algorithms, flows, graph matchings Correct Solution: ``` import math from decimal import * getcontext().prec = 30 n,m=map(int,input().split()) ans=0 if n<m: n,m=m,n if n<3 and m<3: ans=0 elif m==1: ans+=(n//6)*6 n%=6 if n>3: ans+=(n-3)*2 elif n%4==0 or m%4==0 ...
output
1
36,867
15
73,735
Provide tags and a correct Python 3 solution for this coding contest problem. Little C loves number Β«3Β» very much. He loves all things about it. Now he is playing a game on a chessboard of size n Γ— m. The cell in the x-th row and in the y-th column is called (x,y). Initially, The chessboard is empty. Each time, he pl...
instruction
0
36,868
15
73,736
Tags: brute force, constructive algorithms, flows, graph matchings Correct Solution: ``` class Solution(object): def run(self): n, m = [int(x) for x in input().split()] if n > m: n, m = m, n res = (n * m) // 2 if n == 1 and (m + 1) % 6 // 3: res -= 1 e...
output
1
36,868
15
73,737
Provide tags and a correct Python 3 solution for this coding contest problem. Little C loves number Β«3Β» very much. He loves all things about it. Now he is playing a game on a chessboard of size n Γ— m. The cell in the x-th row and in the y-th column is called (x,y). Initially, The chessboard is empty. Each time, he pl...
instruction
0
36,869
15
73,738
Tags: brute force, constructive algorithms, flows, graph matchings Correct Solution: ``` n,m=map(int,input().strip().split()) f=min(n,m) f1=max(n,m) def s(g): if (g%6==1 or g%6==5): return 1 if (g%6==2 or g%6==4): return 2 if (g%6==0): return 0 if (g%6==3): return 3 if (f...
output
1
36,869
15
73,739
Provide tags and a correct Python 3 solution for this coding contest problem. Little C loves number Β«3Β» very much. He loves all things about it. Now he is playing a game on a chessboard of size n Γ— m. The cell in the x-th row and in the y-th column is called (x,y). Initially, The chessboard is empty. Each time, he pl...
instruction
0
36,870
15
73,740
Tags: brute force, constructive algorithms, flows, graph matchings Correct Solution: ``` n,m=map(int, input().split()) q=min(n,m) w=max(n,m) if ((q==1) and (w<=3)) or (q==2==w): print ('0') elif (q==1) and (w==4): print ('2') elif (q==1) and (w==5): print ('4') elif (q==1) and (w==6): print ('6') elif (...
output
1
36,870
15
73,741
Provide tags and a correct Python 3 solution for this coding contest problem. Little C loves number Β«3Β» very much. He loves all things about it. Now he is playing a game on a chessboard of size n Γ— m. The cell in the x-th row and in the y-th column is called (x,y). Initially, The chessboard is empty. Each time, he pl...
instruction
0
36,871
15
73,742
Tags: brute force, constructive algorithms, flows, graph matchings Correct Solution: ``` n, m = map(int, input().split()) if n >= 4 and m >= 4: print(n * m - (n * m % 2)) else: if min(n, m) == 1: if max(n, m) % 6 == 5: print(max(n, m) // 6 * 6 + 4) elif max(n, m) % 6 == 4: ...
output
1
36,871
15
73,743
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little C loves number Β«3Β» very much. He loves all things about it. Now he is playing a game on a chessboard of size n Γ— m. The cell in the x-th row and in the y-th column is called (x,y). Initi...
instruction
0
36,872
15
73,744
Yes
output
1
36,872
15
73,745
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little C loves number Β«3Β» very much. He loves all things about it. Now he is playing a game on a chessboard of size n Γ— m. The cell in the x-th row and in the y-th column is called (x,y). Initi...
instruction
0
36,873
15
73,746
Yes
output
1
36,873
15
73,747
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little C loves number Β«3Β» very much. He loves all things about it. Now he is playing a game on a chessboard of size n Γ— m. The cell in the x-th row and in the y-th column is called (x,y). Initi...
instruction
0
36,874
15
73,748
Yes
output
1
36,874
15
73,749
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little C loves number Β«3Β» very much. He loves all things about it. Now he is playing a game on a chessboard of size n Γ— m. The cell in the x-th row and in the y-th column is called (x,y). Initi...
instruction
0
36,875
15
73,750
No
output
1
36,875
15
73,751
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little C loves number Β«3Β» very much. He loves all things about it. Now he is playing a game on a chessboard of size n Γ— m. The cell in the x-th row and in the y-th column is called (x,y). Initi...
instruction
0
36,876
15
73,752
No
output
1
36,876
15
73,753
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little C loves number Β«3Β» very much. He loves all things about it. Now he is playing a game on a chessboard of size n Γ— m. The cell in the x-th row and in the y-th column is called (x,y). Initi...
instruction
0
36,877
15
73,754
No
output
1
36,877
15
73,755
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little C loves number Β«3Β» very much. He loves all things about it. Now he is playing a game on a chessboard of size n Γ— m. The cell in the x-th row and in the y-th column is called (x,y). Initi...
instruction
0
36,878
15
73,756
No
output
1
36,878
15
73,757
Provide tags and a correct Python 3 solution for this coding contest problem. In this problem at each moment you have a set of intervals. You can move from interval (a, b) from our set to interval (c, d) from our set if and only if c < a < d or c < b < d. Also there is a path from interval I1 from our set to interval ...
instruction
0
37,148
15
74,296
Tags: dfs and similar, graphs Correct Solution: ``` path = [] n = int(input()) for it in range(0, n): data = list(map(int, input().split(' '))) if data[0] == 1: path.append(data[1:]) else: vis = [False] * (len(path) + 1) que = [data[1] - 1] while len(que): p = que[0] del que[0] for i, v ...
output
1
37,148
15
74,297
Provide tags and a correct Python 3 solution for this coding contest problem. In this problem at each moment you have a set of intervals. You can move from interval (a, b) from our set to interval (c, d) from our set if and only if c < a < d or c < b < d. Also there is a path from interval I1 from our set to interval ...
instruction
0
37,149
15
74,298
Tags: dfs and similar, graphs Correct Solution: ``` def main(): intervals = [] condensed = [] index = 0 n = int(input()) for i in range(n): query, start, end = [int(k) for k in input().split(" ")] if query == 1: intervals.append((index, start, end)) index += 1 ...
output
1
37,149
15
74,299
Provide tags and a correct Python 3 solution for this coding contest problem. In this problem at each moment you have a set of intervals. You can move from interval (a, b) from our set to interval (c, d) from our set if and only if c < a < d or c < b < d. Also there is a path from interval I1 from our set to interval ...
instruction
0
37,150
15
74,300
Tags: dfs and similar, graphs Correct Solution: ``` n=int(input()) s=[] ans=[] def bfs(x,y,ans): n=x while 1: for i in s: if i not in vis and (i[0]<n[0]<i[1] or i[0]<n[1]<i[1]): stack.append(i) if i==y:ans.append('YES');return ans if len(stack)==0:ans....
output
1
37,150
15
74,301
Provide tags and a correct Python 3 solution for this coding contest problem. In this problem at each moment you have a set of intervals. You can move from interval (a, b) from our set to interval (c, d) from our set if and only if c < a < d or c < b < d. Also there is a path from interval I1 from our set to interval ...
instruction
0
37,151
15
74,302
Tags: dfs and similar, graphs Correct Solution: ``` def DFS(v,b,visited): visited.add(v) global count,matrix,ok if v==b: ok = True return for i in range(count): if matrix[v][i]==1 and v!=i and i not in visited: DFS(i,b,visited) n = int(input()) matrix = [[0]*111 f...
output
1
37,151
15
74,303
Provide tags and a correct Python 3 solution for this coding contest problem. In this problem at each moment you have a set of intervals. You can move from interval (a, b) from our set to interval (c, d) from our set if and only if c < a < d or c < b < d. Also there is a path from interval I1 from our set to interval ...
instruction
0
37,152
15
74,304
Tags: dfs and similar, graphs Correct Solution: ``` from sys import stdin input = stdin.readline n = int(input()) r = [(0, 0)] for _ in range(n): q, x, y = [int(x) for x in input().split()] if q == 1: r.append((x, y)) else: stack = [] stack.append(x) visited = [False]*len(r...
output
1
37,152
15
74,305
Provide tags and a correct Python 3 solution for this coding contest problem. In this problem at each moment you have a set of intervals. You can move from interval (a, b) from our set to interval (c, d) from our set if and only if c < a < d or c < b < d. Also there is a path from interval I1 from our set to interval ...
instruction
0
37,153
15
74,306
Tags: dfs and similar, graphs Correct Solution: ``` #!/usr/bin/env python3 import sys num_queries = 0 visited = [] first = [] last = [] def dfs(start, end): if start == end: return True for i in range(0, num_queries): if visited[i] == 0: if first[start] > first[i] and first[start] ...
output
1
37,153
15
74,307
Provide tags and a correct Python 3 solution for this coding contest problem. Many computer strategy games require building cities, recruiting army, conquering tribes, collecting resources. Sometimes it leads to interesting problems. Let's suppose that your task is to build a square city. The world map uses the Cart...
instruction
0
37,197
15
74,394
Tags: brute force, greedy Correct Solution: ``` def main(): n = int(input()) mines = [] minx, miny, maxx, maxy = 1e9, 11e9, -1e9, -1e9 for _ in range(n): x, y = map(int, input().split()) minx = min(minx, x) maxx = max(maxx, x) miny = min(miny, y) maxy = max(maxy,...
output
1
37,197
15
74,395
Provide tags and a correct Python 3 solution for this coding contest problem. Many computer strategy games require building cities, recruiting army, conquering tribes, collecting resources. Sometimes it leads to interesting problems. Let's suppose that your task is to build a square city. The world map uses the Cart...
instruction
0
37,198
15
74,396
Tags: brute force, greedy Correct Solution: ``` # -*- coding: utf-8 -*- # @Date : 2019-05-29 17:08:10 # @Author : raj lath (oorja.halt@gmail.com) # @Link : link # @Version : 1.0.0 import sys sys.setrecursionlimit(10**5+1) inf = int(10 ** 20) max_val = inf min_val = -inf RW = lambda : sys.stdin.readlin...
output
1
37,198
15
74,397
Provide tags and a correct Python 3 solution for this coding contest problem. Many computer strategy games require building cities, recruiting army, conquering tribes, collecting resources. Sometimes it leads to interesting problems. Let's suppose that your task is to build a square city. The world map uses the Cart...
instruction
0
37,199
15
74,398
Tags: brute force, greedy Correct Solution: ``` a=int(input()) x,y=map(int,input().split()) minx=x maxx=x miny=y maxy=y for i in range(a-1): x,y=map(int,input().split()) minx=min(minx,x) maxx=max(maxx,x) miny=min(miny,y) maxy=max(maxy,y) print(max(maxx-minx,maxy-miny)**2) ```
output
1
37,199
15
74,399
Provide tags and a correct Python 3 solution for this coding contest problem. Many computer strategy games require building cities, recruiting army, conquering tribes, collecting resources. Sometimes it leads to interesting problems. Let's suppose that your task is to build a square city. The world map uses the Cart...
instruction
0
37,200
15
74,400
Tags: brute force, greedy Correct Solution: ``` n = int(input()) x, y = [], [] for j in range(n): xj, yj = [int(j) for j in input().split()] x.append(xj) y.append(yj) x_min = x[0] y_min = y[0] x_max = x[0] y_max = y[0] for j in range(1, n): x_min = min(x_min, x[j]) y_min = min(y_min, y[j]) x_max...
output
1
37,200
15
74,401
Provide tags and a correct Python 3 solution for this coding contest problem. Many computer strategy games require building cities, recruiting army, conquering tribes, collecting resources. Sometimes it leads to interesting problems. Let's suppose that your task is to build a square city. The world map uses the Cart...
instruction
0
37,201
15
74,402
Tags: brute force, greedy Correct Solution: ``` n=int(input()) l,r,u,d=10**10,-10**10,10**10,-10**10 for i in range(n): a,b=map(int,input().split()) l=min(a,l) r=max(a,r) u=min(u,b) d=max(d,b) print(max((d-u),(r-l))**2) ```
output
1
37,201
15
74,403
Provide tags and a correct Python 3 solution for this coding contest problem. Many computer strategy games require building cities, recruiting army, conquering tribes, collecting resources. Sometimes it leads to interesting problems. Let's suppose that your task is to build a square city. The world map uses the Cart...
instruction
0
37,202
15
74,404
Tags: brute force, greedy Correct Solution: ``` n = int(input()) p = [] s = [] for i in range(n): x, y = map(int, input().split()) p.append(x) s.append(y) p.sort() s.sort() p = p[-1] - p[0] s = s[-1] - s[0] print(max(p, s) ** 2) ```
output
1
37,202
15
74,405
Provide tags and a correct Python 3 solution for this coding contest problem. Many computer strategy games require building cities, recruiting army, conquering tribes, collecting resources. Sometimes it leads to interesting problems. Let's suppose that your task is to build a square city. The world map uses the Cart...
instruction
0
37,203
15
74,406
Tags: brute force, greedy Correct Solution: ``` def STR(): return list(input()) def INT(): return int(input()) def MAP(): return map(int, input().split()) def MAP2():return map(float,input().split()) def LIST(): return list(map(int, input().split())) def STRING(): return input() import string import sys from heapq imp...
output
1
37,203
15
74,407
Provide tags and a correct Python 3 solution for this coding contest problem. Many computer strategy games require building cities, recruiting army, conquering tribes, collecting resources. Sometimes it leads to interesting problems. Let's suppose that your task is to build a square city. The world map uses the Cart...
instruction
0
37,204
15
74,408
Tags: brute force, greedy Correct Solution: ``` #!/usr/bin/env python3 # -*- coding: utf-8 -*- from copy import copy n=int(input()) ox=[] oy=[] xmax=-10000000000000000000 xmin=10**10 ymax=-1000000000000000000 ymin=10**10 for i in range(n): x,y=map(int,input().split()) if x>xmax: xmax=copy(x) if x<xm...
output
1
37,204
15
74,409
Provide tags and a correct Python 3 solution for this coding contest problem. Two bears are playing tic-tac-toe via mail. It's boring for them to play usual tic-tac-toe game, so they are a playing modified version of this game. Here are its rules. The game is played on the following field. <image> Players are makin...
instruction
0
37,427
15
74,854
Tags: implementation Correct Solution: ``` a1 = input() a2 = input() a3 = input() f=input() b4 = input() b5 = input() b6 = input() g=input() c7 = input() c8 = input() c9 = input() x,y=list(map(int,input().split())) g=x % 3 h=y % 3 if g == 1: if h == 1: if '.' in a1[0:3] or '.' in a2[0:3] or '.' in a3[0:3]: ...
output
1
37,427
15
74,855
Provide tags and a correct Python 3 solution for this coding contest problem. Two bears are playing tic-tac-toe via mail. It's boring for them to play usual tic-tac-toe game, so they are a playing modified version of this game. Here are its rules. The game is played on the following field. <image> Players are makin...
instruction
0
37,428
15
74,856
Tags: implementation Correct Solution: ``` R=input g=[list(R()) for _ in range(11)] r,c=map(int,R().split()) r,c=(r-1)%3*4,(c-1)%3*4 f,d='.!' for i in range(9): s,e=g[r+i//3],c+i%3 if s[e]<'o': s[e]=f=d for v in g:print(''.join(v).replace(f,d)) ```
output
1
37,428
15
74,857
Provide tags and a correct Python 3 solution for this coding contest problem. Two bears are playing tic-tac-toe via mail. It's boring for them to play usual tic-tac-toe game, so they are a playing modified version of this game. Here are its rules. The game is played on the following field. <image> Players are makin...
instruction
0
37,429
15
74,858
Tags: implementation Correct Solution: ``` a = [""]*11 for i in range(11): a[i]=list(input()) x,y = map(int, input().split()) k=0 x1=(x-1)%3 y1=(y-1)%3 if y1==0: y2=2 if y1==1: y2=6 y1=4 if y1==2: y2=10 y1=8 if x1==0: x2=2 if x1==1: x2=6 x1=4 if x1==2: x1=8 x2=10 for i in ran...
output
1
37,429
15
74,859
Provide tags and a correct Python 3 solution for this coding contest problem. Two bears are playing tic-tac-toe via mail. It's boring for them to play usual tic-tac-toe game, so they are a playing modified version of this game. Here are its rules. The game is played on the following field. <image> Players are makin...
instruction
0
37,430
15
74,860
Tags: implementation Correct Solution: ``` import collections, math local = False if local: file = open("inputt.txt", "r") def inp(): if local: return file.readline().rstrip() else: return input().rstrip() def ints(): return [int(_) for _ in inp().split()] fromTos = [(0,2), (3,5), (...
output
1
37,430
15
74,861
Provide tags and a correct Python 3 solution for this coding contest problem. Two bears are playing tic-tac-toe via mail. It's boring for them to play usual tic-tac-toe game, so they are a playing modified version of this game. Here are its rules. The game is played on the following field. <image> Players are makin...
instruction
0
37,431
15
74,862
Tags: implementation Correct Solution: ``` l=[input() for _ in range(11)] x,y=map(int, input().split()) x-=1 x+=x//3 y-=1 y+=y//3 a,b=x%4*4,y%4*4 f=1 for i in range(a,a+3): r=l[i][b:b+3].replace('.','!') if r!=l[i][b:b+3]: l[i]=l[i][:b]+r+l[i][b+3:] f=0 if f: for i in range(11): l[i]...
output
1
37,431
15
74,863