description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
import sys input = sys.stdin.readline I = lambda: list(map(int, input().split())) n, m = I() a = [I() for i in range(n)] b = [I() for i in range(n)] x = [[] for i in range(n + m - 1)] y = [[] for i in range(n + m - 1)] for i in range(n): for j in range(m): x[i + j].append(a[i][j]) y[i + j].append(b...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP BIN_...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) ma = [[] for i in range(n + m)] mb = [[] for i in range(n + m)] w = [] for i in range(n): w = list(map(int, input().split())) for j in range(m): ma[i + j].append(w[j]) w = [] for i in range(n): w = list(map(int, input().split())) for j in range(m): mb[i +...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR ...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) mat1 = [] mat2 = [] for i in range(n): mat1.append(list(map(int, input().split()))) for i in range(n): mat2.append(list(map(int, input().split()))) i = 0 temp1 = [] temp2 = [] while i < m: k = i j = 0 while k >= 0 and j < n: temp1.append(mat1[j][k]) t...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR ...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) def check(a, b, x, y): i = 0 j = 0 while x + i < n and y - j >= 0: if a[x + i][y - j] == b[x][y]: a[x][y], a[x + i][y - j] = a[x + i][y - j], a[x][y] return True i += 1 j += 1 return False a = [] for i in range(n): ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR BIN_OP VAR VAR NUMBER IF VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR VAR RETURN NUMBER VAR NUMBE...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
num = [int(x) for x in input().split(" ")] n, m = num[0], num[1] table1 = list() table2 = list() for i in range(n): num = [int(x) for x in input().split(" ")] table1.append(num) test = table1 max_col = len(test) max_row = len(test[0]) cols = [[] for i in range(max_col)] rows = [[] for i in range(max_row)] fdiag...
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR F...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
N, M = map(int, input().split()) A = [list(map(int, input().split())) for i in range(N)] B = [list(map(int, input().split())) for i in range(N)] ans = "YES" for i in range(N): t1 = sorted([A[i - j][j] for j in range(min(N, M)) if i - j >= 0]) t2 = sorted([B[i - j][j] for j in range(min(N, M)) if i - j >= 0]) ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR V...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
r, c = list(map(int, input().split())) f = [None] * (r + c - 1) l = [None] * (r + c - 1) for i in range(0, r + c - 1): f[i] = [] l[i] = [] for i in range(0, r): ip = list(map(int, input().split())) for j in range(0, c): f[i + j].append(ip[j]) for i in range(0, r): ip = list(map(int, input()....
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NONE BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR LIST ASSIGN VAR VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSI...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = list(map(int, input().split())) A = [] B = [] for i in range(n): A.append(list(map(int, input().split()))) for i in range(n): B.append(list(map(int, input().split()))) dA = [] dB = [] for d in range(m): for i in range(d, -1, -1): if d - i >= n: break dA.append(A[d - i][i])...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) m1 = [] m2 = [] for i in range(n): m1.append([int(j) for j in input().split()]) for i in range(n): m2.append([int(j) for j in input().split()]) d1 = [[] for i in range(n + m - 1)] d2 = [[] for i in range(n + m - 1)] for i in range(n): for j in range(m): d1[i + j].app...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP BIN_OP V...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) ar = [0] * 2 diag = [0] * 2 for i in range(2): ar[i] = [[int(t) for t in input().split()] for j in range(n)] diag[i] = [{} for j in range(n + m - 1)] for num in range(2): for i in range(n): for j in range(m): cur = ar[num][i][j] it = diag[num]...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR DICT VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FU...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = list(map(int, input().split())) a = [] for i in range(n): a.append(list(map(int, input().split()))) b = [] for i in range(n): b.append(list(map(int, input().split()))) ok = "YES" for i in range(m - 1 + n - 1 + 1): d = dict() for x in range(min(i + 1, m)): if i - x < n: if a[i ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRI...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(n)] B = [list(map(int, input().split())) for _ in range(n)] ans = True for dig in range(n): i = dig j = 0 d1 = dict() d2 = dict() while i >= 0 and j < m: d1[A[i][j]] = d1.get(A[i][j], 0) + 1 d2[B[i][...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN V...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = list(map(int, input().split())) a, b = [], [] for _ in range(n): aux = [int(x) for x in input().split()] a.append(aux) for _ in range(n): aux = [int(x) for x in input().split()] b.append(aux) def diagonalOrder(a, b): for line in range(1, n + m): start_col = max(0, line - n) ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FUNC_DEF FOR...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) data_1 = [] data_2 = [] fl = True diagonal_1 = [[] for i in range(n + m - 1)] diagonal_2 = [[] for i in range(n + m - 1)] for i in range(n): data_3 = list(map(int, input().split())) data_1.append(data_3) for i in range(n): data_3 = list(map(int, input().split())) data_2....
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CAL...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
from sys import stdin, stdout n, m = map(int, stdin.readline().split()) mata = [None] * n matb = [None] * n for i in range(n): mata[i] = list(map(int, stdin.readline().split())) for i in range(n): matb[i] = list(map(int, stdin.readline().split())) la = [None] * (n + m - 1) lb = [None] * (n + m - 1) for i in ra...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR BIN_OP LIST NONE VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIG...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) a = [[int(x) for x in input().split()] for _ in range(n)] b = [[int(x) for x in input().split()] for _ in range(n)] transa = [[] for _ in range(n + m)] transb = [[] for _ in range(n + m)] for i in range(n): for j in range(m): transa[i + j].append(a[i][j]) transb[i + ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR VAR FOR VAR...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
sizeI, sizeJ = map(int, input().split()) have = [list(map(int, input().split())) for _ in range(sizeI)] need = [list(map(int, input().split())) for _ in range(sizeI)] def solve(): for k in range(sizeI + sizeJ - 1): haveDict, needDict = {}, {} for j in range(k + 1): i = k - j ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR DICT DICT ...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) a = [] b = [] for i in range(n): c = list(map(int, input().split())) a.append(c) for i in range(n): c = list(map(int, input().split())) b.append(c) for i in range(n): for j in range(m): if a[i][j] == b[i][j]: continue else: k =...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) a = [[] for _ in range(n + m)] b = [[] for _ in range(n + m)] for i in range(n): for j, x in enumerate(input().split()): a[i + j].append(x) for i in range(n): for j, x in enumerate(input().split()): b[i + j].append(x) for i in range(n + m): a[i].sort() b[...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
def main(): n, m = (int(x) for x in input().split(" ")) a = [] b = [] for _ in range(n): a.append([int(x) for x in input().split(" ")]) for _ in range(n): b.append([int(x) for x in input().split(" ")]) for s in range(n + m - 1): ma = {} for j in range(max(s - n + ...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CA...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
MOD = 10**9 + 7 I = lambda: list(map(int, input().split())) n, m = I() a = [[] for i in range(n + m - 1)] b = [[] for i in range(n + m - 1)] for i in range(n): l = I() for j in range(m): a[i + j].append(l[j]) for i in range(n): l = I() for j in range(m): b[i + j].append(l[j]) ans = "YES"...
ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR F...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = 0, 0 a, b = [], [] def get_diags(a): diags = [] for c in range(len(a[0])): x, y = 0, c diags.append([]) while x < n and y >= 0: diags[-1].append(a[x][y]) x += 1 y -= 1 for r in range(len(a)): x, y = r, m - 1 diags.append([]...
ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR LIST LIST FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR EXPR FUNC_CALL VAR LIST WHILE VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) a = [] b = [] lol = 0 la = [[] for i in range(n * m)] lb = [[] for i in range(n * m)] for i in range(n): a.append(list(map(int, input().split()))) for i in range(n): b.append(list(map(int, input().split()))) for i in range(n): for j in range(m): la[i + j].append(a[i]...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_C...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().strip().split()) matrix1 = [] matrix2 = [] ans = "YES" for _ in range(n): matrix1.append(list(map(int, input().strip().split()))) for _ in range(n): matrix2.append(list(map(int, input().strip().split()))) for idx_sum in range(n + m - 1): line1 = [] line2 = [] for raw_id in ra...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n_m = input().split(" ") n = int(n_m[0]) m = int(n_m[1]) A = [] for i in range(n): t = input().split(" ") A.append(t) B = [] for i in range(n): t = input().split(" ") B.append(t) for i in range(m + n - 1): text_1 = [] text_2 = [] for j in range(i + 1): if i - j < n and j < m: ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL ...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
import sys input = sys.stdin.readline n, m = map(int, input().split()) grid1 = [list(input().split()) for _ in range(n)] grid2 = [list(input().split()) for _ in range(n)] for i in range(n + m - 1): s1, s2 = [], [] for j in range(n): x, y = j, i - j if 0 <= x < n and 0 <= y < m: s1.a...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR V...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().strip().split()) def inrange(x, y): return x >= 0 and y >= 0 and x < n and y < m a = [] b = [] for _ in range(n): a.append(list(map(int, input().split()))) for _ in range(n): b.append(list(map(int, input().split()))) s = True for i in range(n + m - 1): ii = i j = 0 aa...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN VAR NUMBER VAR NUMBER VAR VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CA...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) mat1 = [0] * n mat2 = [0] * n for i in range(n): mat1[i] = input().split() for i in range(n): mat2[i] = input().split() ans = "YES" for i in range(n + m - 1): if i < min(n - 1, m - 1): lst1 = [0] * (i + 1) lst2 = [0] * (i + 1) for j, k in enumerate(ra...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUM...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) m1, m2 = [list(map(int, input().split())) for _ in range(n)], [ list(map(int, input().split())) for _ in range(n) ] for i in range(n): x, y = 0, i d = {} while y >= 0 and x < m: d[m1[y][x]] = d[m1[y][x]] + 1 if m1[y][x] in d else 1 d[m2[y][x]] = d[m2[y][x...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR ASSIGN VAR DICT WHILE VAR NUMBER VAR VAR...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = list(map(int, input().split())) a = [] b = [] for i in range(n): a.append(list(map(int, input().split()))) for i in range(n): b.append(list(map(int, input().split()))) a1 = [[] for i in range(n + m - 1)] for i in range(n): j = 0 k = i while k >= 0 and j < m: a1[i].append(a[k][j]) ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
def diagonal(a): global n, m max_col = n max_row = m fdiag = [[] for i in range(max_col + max_row - 1)] for y in range(max_col): for x in range(max_row): fdiag[x + y].append(a[y][x]) return fdiag n, m = map(int, input().split()) a = [] b = [] for i in range(n): temp = l...
FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VA...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
gi = lambda: list(map(int, input().strip().split())) n, m = gi() A = [gi() for e in range(n)] B = [gi() for e in range(n)] for k in range(m): a = sorted([A[j][k - j] for j in range(min(n, k + 1))]) b = sorted([B[j][k - j] for j in range(min(n, k + 1))]) if a != b: print("NO") exit() for k in...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) a = [] for i in range(n): a.append(list(map(int, input().split()))) b = [] for i in range(n): b.append(list(map(int, input().split()))) diasA = [[] for i in range(m + n)] diasB = [[] for i in range(m + n)] for i in range(n): for j in range(m): diasA[i + j].append(a[i...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = list(map(int, input().split())) a = [0] * n b = [0] * n ok = 1 for i in range(n): a[i] = list(map(int, input().split())) for i in range(n): b[i] = list(map(int, input().split())) for i in range(m): tmp1 = [] tmp2 = [] deph = 0 it = i while deph < n and it >= 0: tmp1.append(a[d...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL V...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
import sys n, m = map(int, input().split()) A = [] for i in range(0, n): A.append(input().split()) B = [] for i in range(0, n): B.append(input().split()) for i in range(1, n + m): x, y = min(i - 1, n - 1), max(i - n, 0) a, b = [], [] while x >= 0 and y < m: a.append(A[x][y]) b.appen...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR ASSIGN VAR VAR FUNC_CALL VAR...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = [int(item) for item in input().split()] a = [[] for _ in range(n)] b = [[] for _ in range(n)] for i in range(n): a[i] = [int(item) for item in input().split()] for i in range(n): b[i] = [int(item) for item in input().split()] ok = True for i in range(n): for l in range(m): if a[i][l] == b[i][...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VA...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
from sys import * n, m = map(int, stdin.readline().split()) a = [] for i in range(n): x = list(map(int, stdin.readline().split())) a.append(x) b = [] for i in range(n): x = list(map(int, stdin.readline().split())) b.append(x) c1 = [] for i in range(n + m): c1.append([]) c2 = [] for i in range(n + m...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = list(map(int, input().split())) a = [] for i in range(n): a.append(list(map(int, input().split()))) b = [] flag = True for i in range(n): b.append(list(map(int, input().split()))) for i in range(m + n - 1): cur = [] curb = [] for l in range(i + 1): try: cur.append(a[i - l]...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL V...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
import sys def rint(): return map(int, sys.stdin.readline().split()) n, m = rint() a = [[] for j in range(n)] b = [[] for j in range(n)] for i in range(n): a[i] = list(rint()) for i in range(n): b[i] = list(rint()) for s in range(n + m - 1): adict = dict() bdict = dict() for r in range(s + 1...
IMPORT FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().strip().split()) arr = [] for i in range(n): a = list(map(int, input().strip().split())) arr.append(a) brr = [] for i in range(n): a = list(map(int, input().strip().split())) brr.append(a) flag = 0 j = 0 for i in range(n): a = [] b = [] p = i q = 0 while p >= ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_C...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) a_sets = {} b_sets = {} for i in range(n): ll = map(int, input().split()) for j, x in enumerate(ll): a_sets.setdefault(i + j, []).append(x) for i in range(n): ll = map(int, input().split()) for j, x in enumerate(ll): b_sets.setdefault(i + j, []).append(x)...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL FUNC_CALL VAR BIN_OP VAR VAR LIST VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
from sys import stdin, stdout def inp(): return int(stdin.readline()) def minp(): return map(int, stdin.readline().rstrip().split()) def linp(): return list(minp()) def main(): n, m = minp() a = [] b = [] for i in range(n): l = linp() a.append(l) for i in range(n)...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VA...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) a = [] b = [] d = dict() td = dict() for i in range(n): a.append(list(map(int, input().split()))) for i in range(n): b.append(list(map(int, input().split()))) for i in range(n): for j in range(m): idx = i + j try: d[idx].append(a[i][j]) ex...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUN...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) a = [[i for i in map(int, input().split())] for i in range(n)] b = [[i for i in map(int, input().split())] for i in range(n)] ans = 1 op = 1 for j in range(m): da = {} db = {} i = 0 while j >= 0 and i < n: da[a[i][j]] = da.get(a[i][j], 0) + 1 db[b[i][j]] ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT ASS...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) A = [] B = [] for a in range(n): A.append(list(map(int, input().split()))) for _ in range(n): B.append(list(map(int, input().split()))) for c in range(n + m): rinda = 0 if c < m else c - m kolona = c if c < m else m - 1 Ad = [] Bd = [] while kolona >= 0 and r...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP ...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
import sys sys.setrecursionlimit(10**5 + 1) inf = int(10**20) max_val = inf min_val = -inf RW = lambda: sys.stdin.readline().strip() RI = lambda: int(RW()) RMI = lambda: [int(x) for x in sys.stdin.readline().strip().split()] RWI = lambda: [x for x in sys.stdin.readline().strip().split()] nb_rows, nb_cols = RMI() mat_A...
IMPORT EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL FUN...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().strip().split()) A = [] B = [] for _ in range(n): a = list(map(int, input().strip().split())) A.append(a) for _ in range(n): b = list(map(int, input().strip().split())) B.append(b) flag = True for i in range(n - 1): if i == 0: if A[0][0] != B[0][0]: flag =...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_C...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
cnt = lambda s, x: s.count(x) ii = lambda: int(input()) si = lambda: input() f = lambda: map(int, input().split()) dgl = lambda: list(map(int, input())) il = lambda: list(map(int, input().split())) n, m = f() m1, m2 = [], [] lm1, lm2 = [[] for _ in range(n + m)], [[] for _ in range(n + m)] for _ in range(n): m1.app...
ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR LIST L...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) pa = [{} for _ in range(n + m - 1)] pb = [{} for _ in range(n + m - 1)] for i in range(n): tmp = list(map(int, input().split())) for j in range(m): if tmp[j] in pa[i + j]: pa[i + j][tmp[j]] += 1 else: pa[i + j][tmp[j]] = 1 for i in range(n...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR DICT VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = [int(s) for s in input().split()] a = [] b = [] c = [] ans = 0 c = [] d = [] for i in range(n): a.append([int(s) for s in input().split()]) for i in range(n): b.append([int(s) for s in input().split()]) for i in range(0, n + m - 1): c.append([]) d.append([]) for i in range(n): for j in range(...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUN...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) a = [] b = [] for i in range(n): a1 = [int(x) for x in input().split()] a.append(a1) for i in range(n): a1 = [int(x) for x in input().split()] b.append(a1) ad = [[] for x in range(n * m)] bd = [[] for x in range(n * m)] for i in range(n): for j in range(m): a...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = [int(i) for i in input().split()] a = [[] for i in range(n + m + 1)] b = [[] for i in range(n + m + 1)] s = [] st = [] for i in range(n): p = [int(i) for i in input().split()] s.append(p) for i in range(n): p = [int(i) for i in input().split()] st.append(p) for i in range(n): for j in range(m...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = [int(x) for x in input().split(" ")] ROW = n COL = m data = [] def diagonalOrder(matrix): d = [] for line in range(1, ROW + COL): start_col = max(0, line - ROW) count = min(line, COL - start_col, ROW) row = [] for j in range(0, count): row.append(matrix[min(R...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMB...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = list(map(int, input().split())) A = [list(map(int, input().split())) for i in range(n)] B = [list(map(int, input().split())) for i in range(n)] C = [ sorted([A[j][i - j] for j in range(i + 1) if 0 <= j < n and i - j < m]) for i in range(n + m - 1) ] D = [ sorted([B[j][i - j] for j in range(i + 1) if ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR BIN_O...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
def ria(): return [int(i) for i in input().split()] h, w = ria() mt1 = [] mt2 = [] for y in range(h): mt1.append(ria()) for y in range(h): mt2.append(ria()) for x in range(w): st1 = [] st2 = [] y = 0 while w > x >= 0 and h > y >= 0: st1.append(mt1[y][x]) st2.append(mt2[y][x...
FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER WHI...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
def e(x, y, d): while y >= 0 and x < m: d[p[y][x]] = d[p[y][x]] + 1 if p[y][x] in d else 1 d[q[y][x]], x, y = d[q[y][x]] - 1 if q[y][x] in d else -1, x + 1, y - 1 for k in d: if d[k] != 0: print("NO") raise SystemExit() n, m = map(int, input().split()) p, q = [l...
FUNC_DEF WHILE VAR NUMBER VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER FOR VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR STRING FUNC_CALL VAR ASSIGN VAR VAR FUNC_...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) l1 = [] l2 = [] for i in range(n): ka = list(map(int, input().split())) l1.append(ka) for i in range(n): ka = list(map(int, input().split())) l2.append(ka) ba = [] ha = [] for i in range(n): for j in range(m): ha.append(l1[i][j]) ba.append(l2[i][j]) i...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
A = [] B = [] [N, M] = [int(x) for x in input().split()] for i in range(N): A.append([int(x) for x in input().split()]) for i in range(N): B.append([int(x) for x in input().split()]) a_t = [[] for x in range(1010)] b_t = [[] for x in range(1010)] for n in range(N): for m in range(M): a_t[n + m].appe...
ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
[n, m] = input().split(" ") n = int(n) m = int(m) matrixA = [] matrixB = [] for i in range(n): matrixA.append(list(map(int, input().split(" ")))) for i in range(n): matrixB.append(list(map(int, input().split(" ")))) def buildDiagonals(matrix): r = [None] * (n + m - 1) for i in range(m): for j ...
ASSIGN LIST VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VA...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) mat1 = [[(0) for i in range(m)] for j in range(n)] mat2 = [[(0) for i in range(m)] for j in range(n)] for i in range(n): mat1[i] = list(map(int, input().split())) for i in range(n): mat2[i] = list(map(int, input().split())) l1 = [dict() for i in range(n + m - 1)] l2 = [dict() fo...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR F...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
def main(): n, m = map(int, input().split()) a = [[] for i in range(n)] b = [[] for i in range(n)] aDicts = [dict() for i in range(n + m - 1)] bDicts = [dict() for i in range(n + m - 1)] for i in range(n): a[i] = list(map(int, input().split())) for i in range(n): b[i] = list(...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN V...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) lst = [] lst2 = [] for c in range(n): lst.append(list(map(int, input().split()))) for c in range(n): lst2.append(list(map(int, input().split()))) for c in range(n): for r in range(len(lst[c])): p = 0 if lst[c][r] != lst2[c][r]: a = c b...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FOR...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
import sys n, m = tuple(map(int, input().split(" "))) A = [] for i in range(n): A.append(list(map(int, input().split(" ")))) B = [] for i in range(n): B.append(list(map(int, input().split(" ")))) if A[0][0] != B[0][0] or A[-1][-1] != B[-1][-1]: print("NO") sys.exit(0) for i in range(n): for j in ra...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CAL...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) A = dict() B = dict() for i in range(n): a = list(map(int, input().split())) for j in range(m): if i + j in A: if a[j] in A[i + j]: A[i + j][a[j]] += 1 else: A[i + j][a[j]] = 1 else: A[i + j] = {...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR IF VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER ASSIGN V...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
import sys n, m = list(map(int, input().split())) m1 = [list(map(int, input().split())) for i in range(n)] m2 = [list(map(int, input().split())) for i in range(n)] for j in range(m + n - 1): x1 = {} x2 = {} for i in range(j + 1): if j - i < n and i < m: x1[m1[j - i][i]] = 0 ...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR DI...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, k = map(int, input().split()) a = [[] * k] * n for i in range(n): a[i] = list(map(int, input().split())) b = [[] * k] * n for i in range(n): b[i] = list(map(int, input().split())) flag = True tempa = [] tempb = [] for i in range(n + k): tempa.clear() tempb.clear() if flag == False: break ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST BIN_OP LIST VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST BIN_OP LIST VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CA...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) a = [[] for i in range(n)] b = [[] for i in range(n)] va = [[] for i in range(n + m)] vb = [[] for i in range(n + m)] for i in range(n): a[i] = list(map(int, input().split())) for j in range(m): va[i + j].append(a[i][j]) for i in range(n): b[i] = list(map(int, input(...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_C...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) arr = {} j = 0 for i in range(n): s = list(map(int, input().split())) for k in range(m): y = i + k x = s[k] ky = str(x) + "a" + str(y) if ky in arr: arr[ky] += 1 else: arr[ky] = 1 j = 0 flag = 1 for i in range(n): ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR STRING FUNC_CALL VAR V...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
size = [int(number) for number in input().split()] matrixa = [] for i in range(size[0]): matrixa.append([int(number) for number in input().split()]) matrixb = [] for i in range(size[0]): matrixb.append([int(number) for number in input().split()]) def checkDiagonal(cords): if cords[0] > 0 and cords[1] < si...
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER NUMBER VAR N...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
import sys input = sys.stdin.readline MOD = 1000000007 MOD2 = 998244353 ii = lambda: int(input().strip("\n")) si = lambda: input().strip("\n") dgl = lambda: list(map(int, input().strip("\n"))) f = lambda: map(int, input().strip("\n").split()) il = lambda: list(map(int, input().strip("\n").split())) ls = lambda: list(i...
IMPORT ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) M1 = [list(map(int, input().split())) for i in range(n)] M2 = [list(map(int, input().split())) for i in range(n)] h = [0] * n for i in range(n): M1[i].extend(h) for i in range(n): M2[i].extend(h) fl = 0 for i in range(1, m + n - 1): s1 = dict() s2 = dict() x = i ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VA...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
def collect_tr(mat, n, m, i, j): tr = [] while i >= 0 and j < m: tr.append(mat[i][j]) i -= 1 j += 1 return tr def main(): n, m = map(int, input().split(" ")) mat1 = [list(map(int, input().split(" "))) for _ in range(n)] mat2 = [list(map(int, input().split(" "))) for _ i...
FUNC_DEF ASSIGN VAR LIST WHILE VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VA...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) i = 0 k = [] while i < n: s = list(map(int, input().split())) i += 1 k += [s] i = 0 x = [] while i < n: g = [] j = 0 p = i while p > -1 and j > -1 and p < n and j < m: g += [k[p][j]] j += 1 p -= 1 g.sort() x += [g] i += 1 i...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR LIST VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER VAR NUMBER...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) a = [list(map(int, input().split())) for i in range(n)] b = [list(map(int, input().split())) for i in range(n)] a1 = [[] for i in range(n + m + 100)] b1 = [[] for i in range(n + m + 100)] for i in range(n): for j in range(m): a1[i + j].append(a[i][j]) b1[i + j].appen...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR LIST VAR FU...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
tokens = input().split() rows = int(tokens[0]) columns = int(tokens[1]) A = [] B = [] for i in range(rows): tokens = input().split() tokens = [int(w) for w in tokens] A.append(tokens) for i in range(rows): tokens = input().split() tokens = [int(w) for w in tokens] B.append(tokens) status = True ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = [int(x) for x in input().split()] A = [] B = [] for _ in range(n): A.append([int(x) for x in input().split()]) for _ in range(n): B.append([int(x) for x in input().split()]) AD = [] BD = [] for s in range(2, m + n + 1): at = [] bt = [] for r in range(1, n + 1): c = s - r if 1 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split(" ")) ma = [] mb = [] for i in range(n): li = list(map(int, input().split(" ", m)[:m])) ma.append(li) for i in range(n): li = list(map(int, input().split(" ", m)[:m])) mb.append(li) lia = [] lib = [] i, j = 0, 0 kl = 0 ad = 0 for l in range(n + m - 1): li = [] while...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) a = [] b = [] test = [] test_ = [] for i in range(n + m): test.append([0]) test_.append([0]) for i in range(n): cache = list(map(int, input().split())) a.append(cache) for i in range(n): cache = list(map(int, input().split())) b.append(cache) for i in range(n): ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR LIST NUMBER EXPR FUNC_CALL VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FU...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = list(map(int, input().split())) a = [] for i in range(n): a.append(list(map(int, input().split()))) b = [] for i in range(n): b.append(list(map(int, input().split()))) for i in range(m + n - 1): d1 = {} d2 = {} for j in range(n): l = j r = i - j if l >= 0 and l < n and...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CA...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) A = [] B = [] for i in range(n): A.append([int(x) for x in input().split()]) for i in range(n): B.append([int(x) for x in input().split()]) flag = 0 for i in range(n + m - 1): a = [] b = [] if i < m: r, c = 0, i else: r, c = i - m + 1, m - 1 w...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BI...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
the_string = input() rows, coloumns = the_string.split() row = int(rows) coloumn = int(coloumns) biggestdiag = min(row, coloumn) A = [] B = [] for i in range(row): string = input() string = string.split() A.append(string) for i in range(row): string = input() string = string.split() B.append(str...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CA...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = [int(x) for x in input().split()] A = [[int(x) for x in input().split()] for _ in range(n)] B = [[int(x) for x in input().split()] for _ in range(n)] def valid(i, j): return i >= 0 and j >= 0 and i < n and j < m can = True for i in range(n): i1, j1 = i, 0 a = [] b = [] while valid(i1, j1)...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN VAR NUMBER VAR NUMBER VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASS...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split(" ")) a = [] b = [] for i in range(n): a.append(list(map(int, input().split(" ")))) for i in range(n): b.append(list(map(int, input().split(" ")))) for i in range(n): j = i k = 0 c = [] d = [] while j >= 0 and k < m: c.append(a[j][k]) d.append(b[...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR ...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
from sys import stdin n, m = map(int, stdin.readline().strip().split()) mt1 = [] for i in range(n): mt1.append(list(map(int, stdin.readline().strip().split()))) mt2 = [] for i in range(n): mt2.append(list(map(int, stdin.readline().strip().split()))) t = True for i in range(n): x = i y = 0 s = [] ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) diag_A = [] diag_B = [] for i in range(n + m): diag_A.append([]) diag_B.append([]) A = [] for i in range(n): row = input().split() A.append(row) B = [] for i in range(n): row = input().split() B.append(row) for row in range(n): for col in range(m): di...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR LIST EXPR FUNC_CALL VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSI...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
R = lambda: map(int, input().split()) n, m = R() def f(): a = [()] * (n + m) for i in range(n): for x in R(): a[i] += (x,) i += 1 return [*map(sorted, a)] print("YNEOS"[f() != f() :: 2])
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP LIST BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER RETURN LIST FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING FUNC_CALL VAR FUNC_CALL VAR NUMBER
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
EMPTY = 0 WHITE = 1 BLACK = 8 BOARDWIDTH = 7 BOARDHEIGHT = 6 def isWinner(board, tile): for x in range(BOARDWIDTH - 3): for y in range(3, BOARDHEIGHT): if ( board[x][y] == tile and board[x + 1][y - 1] == tile and board[x + 2][y - 2] == tile ...
ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER V...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) n, m = mi() a = [li() for i in range(n)] b = [li() for i in range(n)] p = [[] for i in range(n + m)] q = [[] for i in range(n + m)] for i in range(n): for j in range(m): p[i + j].append(a[i][j]) q[i + j].append(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR LIST V...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
import sys def equal(arr, arr_1): for i in range(len(arr)): if arr[i] != arr_1[i]: return False return True n, m = [int(s) for s in input().split()] array = [] array_2 = [] for i in range(n): array.append([int(s) for s in input().split()]) for i in range(n): array_2.append([int(s...
IMPORT FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FU...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) ans = "YES" M = [list(map(int, input().split())) for j in range(n)] M2 = [list(map(int, input().split())) for j in range(n)] for hehe in range(1, n + m): start_m = max(0, hehe - n) count = min(hehe, m - start_m, n) dic1, dic2 = {}, {} for j in range(0, count): if...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VA...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = [int(x) for x in input().split()] A = [] B = [] for i in range(n): a = [int(x) for x in input().split()] A.append(a) for i in range(n): a = [int(x) for x in input().split()] B.append(a) a_list = [] for i in range(n): a = [] j = 0 a.append(A[i][j]) while 1: if i - 1 >= 0 an...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
R = lambda: map(int, input().split()) n, m = R() def f(): a = [[] for _ in [0] * (n + m)] for i in range(n): j = 0 for x in R(): a[i + j] += (x,) j += 1 return a print("YNEOS"[any(sorted(x) != sorted(y) for x, y in zip(f(), f())) :: 2])
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST VAR BIN_OP LIST NUMBER BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR EXPR FUNC_CALL VAR STRING FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_C...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) A = [[] for i in range(n)] B = [[] for i in range(n)] for i in range(n): a = list(map(int, input().split())) A[i] = a for i in range(n): a = list(map(int, input().split())) B[i] = a A1 = [[] for i in range(n + m - 1)] B1 = [[] for i in range(n + m - 1)] for k in range(n ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_C...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
a = [] n, m = map(int, input().split()) for i in range(n): a.append(input().split()) b = [] for i in range(n): b.append(input().split()) for k in range(m): i = k j = 0 c = [] d = [] while i >= 0 and j <= n - 1: c.append(a[j][i]) d.append(b[j][i]) i = i - 1 j =...
ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WH...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m, *_ = list(map(int, input().split())) b1 = [] for i in range(n): b1.append(input().split()) b2 = [] for i in range(n): b2.append(input().split()) def works(n, m, b1, b2): for diag in range(n + m - 1): l1 = [] l2 = [] for col in range(diag + 1): point = [col, diag -...
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR LIST...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
a, b = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(a)] B = [list(map(int, input().split())) for _ in range(a)] for i in range(a): A[i] += [0] * (b + a) B[i] += [0] * (b + a) for i in range(a - 1): a1 = {} b1 = {} for j in range(i + 1): a1[A[j][i - j]] = a1.g...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP LIST NUMBER BIN_OP VAR VAR VAR VAR BIN_OP LI...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) A = [] B = [] for i in range(n): A.append(list(map(int, input().split()))) for i in range(n): B.append(list(map(int, input().split()))) lenkey = n - 1 + (m - 1) + 1 checkA = [] checkB = [] for i in range(lenkey): checkA.append([]) checkB.append([]) for i in range(n): ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().split()) A = [] B = [] flag = 1 for i in range(n): A.append(list(map(int, input().split()))) for i in range(n): B.append(list(map(int, input().split()))) for i in range(n + m - 1): j = 0 Alist = [] Blist = [] while i >= 0: try: Alist.append(A[i][j]) ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUN...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
inp = lambda: map(int, input().split()) def ans(): global n, m a = [[] for _ in [0] * (n + m)] for i in range(n): for j in inp(): a[i].append(j) i += 1 return [*map(sorted, a)] n, m = inp() if ans() != ans(): print("NO") else: print("YES")
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST VAR BIN_OP LIST NUMBER BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER RETURN LIST FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR IF FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR STRIN...
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matrix $A$ unlimited number of times: take any square square submatrix...
n, m = map(int, input().strip().split()) def transpose(matrix): to_return = [[] for i in range(m)] for i in range(m): for j in range(n): to_return[i].append(matrix[j][i]) return to_return A, B = [], [] for i in range(n): A.append([int(i) for i in input().strip().split()]) for i i...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR RETURN VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_C...