description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) c = input() a = input() c = [int(x) for x in c] a = [int(x) for x in a] res = -1 nz = 0 na = 0 nc = 0 nb = 0 for is_c, is_a in zip(c, a): if is_c and is_a: nb += 1 elif is_c: nc += 1 elif is_a: na += 1 else: nz += 1 rnb1 = None rna1 = None rnc1 = None rnz...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR NUMBER IF VAR VAR ...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
from sys import stdin n = int(stdin.readline().strip()) s = stdin.readline().strip() s1 = stdin.readline().strip() s2 = [] x00 = 0 x01 = 0 x10 = 0 x11 = 0 for i in range(n): if s[i] == "0" and s1[i] == "0": x00 += 1 elif s[i] == "0" and s1[i] == "1": x01 += 1 elif s[i] == "1" and s1[i] == "...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR NUMBER...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) c = input() a = input() c00 = c01 = c10 = c11 = 0 d00 = [] d01 = [] d10 = [] d11 = [] for i in range(n): if c[i] == "1" and a[i] == "1": c11 += 1 d11.append(i) elif c[i] == "0" and a[i] == "1": c01 += 1 d01.append(i) elif c[i] == "1" and a[i] == "0": ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING VAR NUMBER ...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
import sys n = int(input()) c = [int(x) for x in input()] a = [int(x) for x in input()] by_diff = {i: [] for i in range(3)} diff = [(c[i] + a[i]) for i in range(n)] for i in range(n): by_diff[c[i] + a[i]].append(i + 1) total_sum = sum(a) total_count = [len(by_diff[i]) for i in range(3)] for count2 in range(total_c...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR LIST VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR ...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) c = input() a = input() clowns = [] acr = [] both = [] neither = [] for i in range(n): if c[i] == "1" and a[i] == "1": both.append(i + 1) elif c[i] == "1": clowns.append(i + 1) elif a[i] == "1": acr.append(i + 1) else: neither.append(i + 1) x = len(clowns...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRIN...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
cnt = [0] * 4 ans = [0] * 4 n = int(input()) c = [int(i) for i in input()] an = [int(i) for i in input()] for i in range(n): cnt[(c[i] & 1) << 1 | an[i] & 1] += 1 fl = 1 for d in range(cnt[3] + 1): a = (n >> 1) + d - cnt[1] - cnt[3] if a >= 0 and a <= cnt[0]: bc = cnt[1] + cnt[3] - 2 * d if ...
ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR ...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
import sys input = sys.stdin.readline n = int(input()) c = list(input().rstrip()) a = list(input().rstrip()) f = [[] for i in range(4)] for i in range(n): c[i] = int(c[i]) a[i] = int(a[i]) if c[i] == a[i] == 0: f[0].append(i) elif c[i] == 0 and a[i] == 1: f[1].append(i) elif c[i] ==...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR N...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) a = input() b = input() init = sum(int(c) for c in b) mp = [[] for i in range(3)] for i in range(n): c = int(a[i]) + int(b[i]) mp[c] += [i + 1] need = n // 2 for i in range(len(mp[1]) + 1): for j in range(len(mp[2]) + 1): if i + 2 * j == init and i + j <= need and i + j + len(mp[0])...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR LIST BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VA...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
import sys input = sys.stdin.readline n = int(input()) x = input() y = input() a = [] b = [] c = [] d = [] for i in range(n): if x[i] == "0" and y[i] == "0": a.append(i + 1) elif x[i] == "0" and y[i] == "1": b.append(i + 1) elif x[i] == "1" and y[i] == "0": c.append(i + 1) elif ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR VAR STRING EXPR FUNC_CALL V...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) c = list(map(int, list(input()))) a = list(map(int, list(input()))) p = [0, 0, 0, 0] ind = [[], [], [], []] for i in range(n): if c[i] and a[i]: p[3] += 1 ind[3].append(i) elif c[i]: p[1] += 1 ind[1].append(i) elif a[i]: p[2] += 1 ind[2].appen...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST LIST LIST LIST LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER NUM...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) c = input() a = input() aCnt = 0 bCnt = 0 cCnt = 0 dCnt = 0 for i in range(n): if a[i] == "0" and c[i] == "0": aCnt += 1 if a[i] == "0" and c[i] == "1": cCnt += 1 if a[i] == "1" and c[i] == "0": bCnt += 1 if a[i] == "1" and c[i] == "1": dCnt += 1 isDone =...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR NUMBER I...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) s1 = input() s2 = input() w, x, y, z = 0, 0, 0, 0 W, X, Y, Z = [], [], [], [] for i in range(n): s = s1[i] + s2[i] if s == "00": w += 1 W.append(i) elif s == "11": x += 1 X.append(i) elif s == "10": y += 1 Y.append(i) else: z +...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR VAR LIST LIST LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR STRING VAR NUMBER EXPR...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) c_s = input() a_s = input() clowns = [] acrobats = [] both = [] none = [] for i in range(n): if a_s[i] == "1" and c_s[i] == "1": both.append(i + 1) elif a_s[i] == "1": acrobats.append(i + 1) elif c_s[i] == "1": clowns.append(i + 1) else: none.append(i + 1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRIN...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
from sys import stdin, stdout n = int(stdin.readline()) a = [int(x) for x in stdin.readline().strip()] c = [int(x) for x in stdin.readline().strip()] ind = [[], [], [], []] for i in range(len(a)): ind[2 * a[i] + c[i]].append(i + 1) cnt = [] r = [] for i in range(n // 2 + 1): for j in range(i + 1): if j...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST LIST LIST LIST LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR LIST A...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) s = input() t = input() A = [] B = [] C = [] D = [] a, b, c, d = 0, 0, 0, 0 for i in range(n): f = s[i] + t[i] if f == "00": d += 1 D.append(i + 1) elif f == "01": a += 1 A.append(i + 1) elif f == "11": c += 1 C.append(i + 1) else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR N...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) s1 = input() s2 = input() count1 = 0 count2 = 0 count3 = 0 count4 = 0 l1 = set() l2 = set() l3 = set() l4 = set() for i in range(n): if s1[i] == "1" and s2[i] == "0": count1 += 1 l1.add(i + 1) if s1[i] == "0" and s2[i] == "1": count2 += 1 l2.add(i + 1) if s1[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING ...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
import sys N = int(input()) c_ls = list(input()) a_ls = list(input()) total_both = 0 ls_both = [] total_Aonly = 0 ls_Aonly = [] total_Conly = 0 ls_Conly = [] total_none = 0 ls_none = [] for i in range(N): if c_ls[i] == "1" and a_ls[i] == "1": total_both += 1 ls_both.append(i) elif c_ls[i] == "1...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING V...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
import sys n = int(input()) s = input() s1 = input() a = 0 b = 0 c = 0 d = 0 an = [] for i in range(n): if s[i] == "0" and s1[i] == "0": a += 1 elif s[i] == "1" and s1[i] == "0": b += 1 elif s[i] == "0" and s1[i] == "1": c += 1 else: d += 1 x = 0 y = 0 z = 0 w = 0 t = 0 ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR ...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
k = lambda: map(int, input().split()) l = lambda: list(k()) n = int(input()) pairs = [None for _ in range(n)] cant = acros = clowns = both = 0 l1, l2 = input(), input() g1, g2 = [0, 0, 0, 0], [0, 0, 0, 0] ans = [0] * n for i in range(n): pairs[i] = int(l1[i]), int(l2[i]), i + 1 ans[i] = pairs[i][0] + pairs[i][1...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NONE VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMB...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
import sys n = int(input()) a = input() b = input() pary = [] for i in range(n): pary.append([int(a[i]), int(b[i])]) jj = [] jz = [] zj = [] zz = [] for i in range(n): if pary[i] == [0, 0]: zz.append(i) if pary[i] == [1, 0]: jz.append(i) if pary[i] == [0, 1]: zj.append(i) if...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR LIST NUMBER N...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
def calc(s, n, d): cnts = [len(v) for v in d.values()] half = n // 2 for a in range(0, cnts[0] + 1): for b in range(0, cnts[1] + 1): c = n - 2 * a - b - s d = a + s - half if ( 0 <= c <= cnts[2] and 0 <= d <= cnts[3] ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP NUMBER VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF NUMBER VAR VAR NUMBER NUM...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) c = [int(i) for i in input()] a = [int(i) for i in input()] dzero_index = [] done_index = [] one_zero_index = [] aone_count = 0 find = False for i in range(n): if c[i] == a[i] == 0: dzero_index.append(i + 1) elif c[i] == a[i] == 1: done_index.append(i + 1) else: one_...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) s = input() t = input() na, nb, nc, nd = 0, 0, 0, 0 for i in range(n): if s[i] == "0" and t[i] == "0": na += 1 if s[i] == "0" and t[i] == "1": nb += 1 if s[i] == "1" and t[i] == "0": nc += 1 if s[i] == "1" and t[i] == "1": nd += 1 ans = [] for b in range(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR ...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) s1 = input() s2 = input() first = [] second = [] none = [] both = [] for i in range(n): if s1[i] == "1" and s2[i] == "0": first.append(i + 1) elif s1[i] == "0" and s2[i] == "1": second.append(i + 1) elif s1[i] == "1" and s2[i] == "1": both.append(i + 1) else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER I...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) c = input() a = input() buff = [[] for i in range(4)] for i in range(n): if a[i] == c[i] == "0": buff[0].append(i) elif c[i] == "1" and a[i] == "0": buff[1].append(i) elif c[i] == "0" and a[i] == "1": buff[2].append(i) else: buff[3].append(i) ans = [0] * ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR STRING EXPR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING VAR VAR STRING EXPR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING VAR VAR STRING EXPR FUNC_CA...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) n2 = n // 2 c = input() a = input() only_clown = sum([(1) for i in range(n) if c[i] == "1" and a[i] == "0"]) only_acrobat = sum([(1) for i in range(n) if c[i] == "0" and a[i] == "1"]) both = sum([(1) for i in range(n) if c[i] == "1" and a[i] == "1"]) neither = sum([(1) for i in range(n) if c[i] == "0" ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR STRING VAR VAR STRING ASSIGN VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR STRING VAR VAR STRING ASSIGN VAR FUNC_CALL VAR NUMBER VA...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
maxn = int(5010) a = [(0) for i in range(0, maxn)] b = [(0) for i in range(0, maxn)] n = int(input()) s1 = input() s2 = input() aa, bb, cc, dd = 0, 0, 0, 0 na, nb, nc, nd = 0, 0, 0, 0 for i in range(0, n): a[i] = int(s1[i]) b[i] = int(s2[i]) if a[i] == 0 and b[i] == 0: aa += 1 elif a[i] == 0 and...
ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER FOR...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
x = int(input()) s1 = input() s2 = input() a = [] b = [] c = [] d = [] for i in range(len(s1)): if s1[i] == "0" and s2[i] == "0": a.append(i + 1) elif s1[i] == "1" and s2[i] == "0": b.append(i + 1) elif s1[i] == "0" and s2[i] == "1": c.append(i + 1) else: d.append(i + 1) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR VAR STRING EXPR FUNC_CALL VAR BIN_O...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
import sys DBG = not True n = int(input()) cc = input() aa = input() c = [] a = [] for i in range(n): c.append(1 if cc[i] == "1" else 0) a.append(1 if aa[i] == "1" else 0) e = [0, 0, 0, 0] g = [[], [], [], []] if DBG: print(c) print(a) for i in range(n): if c[i] == 0 and a[i] == 0: e[0] += ...
IMPORT ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR STRING NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN V...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) c = input() a = input() counta = 0 for x in a: x = int(x) if x == 1: counta += 1 c0 = 0 c1 = 0 c2 = 0 for x, y in zip(c, a): x, y = int(x), int(y) if x == 1 and y == 1: c2 += 1 elif x == 1 or y == 1: c1 += 1 else: c0 += 1 p = 0 q = 0 r = 0 for k i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR N...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) // 2 c = map(int, list(input())) a = map(int, list(input())) artists = zip(c, a) both, none, clowns, acrobats = [], [], [], [] for i, artist in enumerate(artists): if sum(artist) == 2: both.append(i + 1) elif sum(artist) == 0: none.append(i + 1) elif artist[0] == 1: ...
ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR LIST LIST LIST LIST FOR VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR ...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) c = input() a = input() an = [(0) for i in range(n)] for i in range(n): if c[i] == "1" and a[i] == "1": an[i] = 3 elif a[i] == "1": an[i] = 1 elif c[i] == "1": an[i] = 2 a1 = [] a2 = [] a3 = [] a4 = [] for i in range(n): if an[i] == 1: a1.append(i) el...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING ASSIGN VAR VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIS...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) s1 = [int(i) for i in input()] s2 = [int(i) for i in input()] a = [[] for i in range(4)] for i in range(n): a[s2[i] * 2 + s1[i]].append(i + 1) def cal(a0, a2): nota0 = len(a[0]) - a0 nota2 = len(a[2]) - a2 nota1 = a0 + a2 - nota0 a1 = len(a[1]) - nota1 a3 = n // 2 - a0 - a1 - ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR N...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) y = list(map(int, list(input()))) a = list(map(int, list(input()))) x = [0, 0, 0, 0] for i in range(n): if y[i] == 0: if a[i] == 0: x[0] += 1 else: x[1] += 1 elif a[i] == 0: x[2] += 1 else: x[3] += 1 ok = False ans = [] for c in range(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER NUMBER VAR NUMBER NUMB...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) clow = input() acro = input() a, b, c, d = 0, 0, 0, 0 for i in range(len(clow)): if clow[i] == "1" and acro[i] == "1": a += 1 elif clow[i] == "1": b += 1 elif acro[i] == "1": c += 1 else: d += 1 x, y, z, t = 0, 0, 0, 0 isAns = False for i in range(d + 1):...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR NUMB...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
n, l, r = list(map(int, input().split())) a = list(map(int, input().split())) p = list(map(int, input().split())) s = set() x = [] for i in range(len(a)): x.append([p[i], i]) x.sort() mx = -1000000000000 for i in range(n): p[x[i][1]] = max(l, mx + a[x[i][1]] + 1) if p[x[i][1]] > r: print("-1") ...
ASSIGN VAR 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VA...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
n, l, r = map(int, input().split()) A = [int(i) for i in input().split()] Cord = [int(i) for i in input().split()] Cinv = [(0) for _ in range(n)] for i in range(n): Cinv[Cord[i] - 1] = i pmin = -(10**18) B = [(0) for _ in range(n)] ans = True for i in range(n): ad = max(l, pmin + A[Cinv[i]] + 1) B[Cinv[i]] ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
n, l, r = map(int, input().split()) a = list(map(int, input().split())) p = list(map(int, input().split())) ans = [0] * n order = [0] * n for i in range(n): order[p[i] - 1] = i cur = -(10**19) for o in order: bi = max(l, cur + 1 + a[o]) if bi > r: print(-1) exit() ans[o] = bi cur = b...
ASSIGN VAR 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 ASSIGN 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 FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBE...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
read = lambda: map(int, input().split()) n, l, r = read() mn = l A = [(-i) for i in list(read())] B = [0] * n C = list(enumerate(list(read()))) C.sort(key=lambda x: x[-1]) C = [i for i, j in C] for i in range(n): B[C[i]] = mn - A[C[i]] mn += 1 d = min(B) B = [(i - (d - l)) for i in B] if r - 1 + l >= n and max(...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR FOR VAR FUNC_C...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
n, l, r = map(int, input().split()) A = list(map(int, input().split())) P = list(map(int, input().split())) s = [0] * n per = 0 for j in range(n): s[P[j] - 1] = j b = [0] * n b[s[0]] = l for j in range(1, n): last = b[s[j - 1]] - A[s[j - 1]] nexs = last + 1 if r - A[s[j]] > last: b[s[j]] = max(n...
ASSIGN VAR 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
n, l, r = map(int, input().split(" ")) a = list(map(int, input().split(" "))) c = list(map(int, input().split(" "))) d = dict(zip(c, range(n))) b = [0] * n ckeys = sorted(d, reverse=True) curr = r curr_diff = r - a[d[ckeys[0]]] b[d[ckeys[0]]] = r for ck in ckeys[1:]: curr_diff -= 1 next_b = a[d[ck]] + curr_diff...
ASSIGN VAR 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VA...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
import sys N, L, R = list(map(int, input().split())) a = list(map(int, input().split())) b = [0] * N c = list(map(int, input().split())) d = [i for i in range(N)] z = [list(t) for t in zip(c, a, b, d)] z = sorted(z) z[0][2] = L last = z[0][2] - z[0][1] for i in range(1, N): z[i][2] = max(last + 1 + z[i][1], L) ...
IMPORT ASSIGN VAR 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 ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
n, l, r = map(int, input().split(" ")) a = list(map(int, input().split(" "))) compressed = list(map(int, input().split(" "))) b = [0] * n lastmod = -1 lol = list(zip(compressed, enumerate(a))) for i, (pos, val) in sorted(lol): if i == 1: b[pos] = l lastmod = pos if i > 1: b[pos] = max(b[...
ASSIGN VAR 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
def binary_search(l, r, k): while l <= r: mid = l + r >> 1 if mid < k: l = mid + 1 else: r = mid - 1 return l def main(): n, l, r = map(int, input().split()) a = list(map(int, input().split())) p = list(map(int, input().split())) x = [(p[i], i + ...
FUNC_DEF WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR V...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
n, l, r = [int(i) for i in input().split()] a = [int(i) for i in input().split()] p = [int(i) for i in input().split()] pos = [] b = [0] * n for i in range(n): pos.append((p[i], i)) pos.sort() b[pos[0][1]] = l c = [0] * n c[pos[0][1]] = l - a[pos[0][1]] cur = c[pos[0][1]] for i in range(1, n): b[pos[i][1]] = cu...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR ...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
from sys import stdin, stdout def ri(): return list(map(int, input().split())) n, l, r = ri() a = list(ri()) p = list(ri()) pi = [i for i in range(n)] pi.sort(key=lambda e: p[e]) b = [(0) for i in range(n)] i = pi[0] b[i] = l cp = b[i] - a[i] for ii in range(1, n): i = pi[ii] if a[i] + cp + 1 >= l: ...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR ...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
n, L, R = map(int, input().split()) a = [*map(int, input().split())] p = sorted((e, i) for i, e in enumerate(map(int, input().split()))) prev = -float("inf") res = [0] * n for _, i in p: l = max(a[i] + prev, L - 1) + 1 if l > R: print(-1) exit() res[i] = l prev = l - a[i] print(*res)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR VAR ASSIGN VAR BIN_OP FUNC...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
n, l, f = map(int, input().split()) a = [int(x) for x in input().split()] c = [int(x) for x in input().split()] b = [] for i in range(n): b.append(a[i] + c[i]) m = max(b) if m > f: diff = m - f for i in range(n): b[i] -= diff else: diff = f - m for i in range(n): b[i] += diff if min(...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
import sys n, l, r = map(int, input().split()) a = [int(i) for i in input().split()] p = [int(i) for i in input().split()] pp = [i for i in range(n)] pp.sort(key=lambda x: p[x] * -1) b = [0] * n b[pp[0]] = r c = [pp[0]] * n c[pp[0]] = b[pp[0]] - a[pp[0]] for j in range(1, n): i = pp[j] b[i] = a[i] + c[pp[j - 1...
IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR NUMBER VAR ...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
n, l, r = map(int, input().split()) a = map(int, input().split()) p = map(int, input().split()) b = list(map(lambda x: sum(x), zip(a, p))) minb = min(b) maxb = max(b) if maxb - minb > r - l: print(-1) else: print(" ".join(str(i - minb + l) for i in b))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR VA...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
R = lambda: map(int, input().split()) n, l, r = R() a, d = list(R()), list(R()) b = [(av + cv) for av, cv in zip(a, d)] mi = min(b) if mi < l: b = [(bv + l - mi) for bv in b] mx = max(b) if mx > r: b = [(bv - (mx - r)) for bv in b] if l <= min(b) <= max(b) <= r: print(" ".join(map(str, b))) else: print(...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL V...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
n, l, r = input().split(" ") n = int(n) l = int(l) r = int(r) at = input().split(" ") pt = input().split(" ") a = [] b = [] p = [] indices = [] for i in range(n): a.append(int(at[i])) p.append(int(pt[i])) b.append(None) indices.append(None) for i in range(n): indices[p[i] - 1] = i flag = True i = 0 ...
ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
n, l, r = map(int, input().split()) a = list(map(int, input().split())) p = list(map(int, input().split())) c = [] for j in range(n): c.append([p[j], j]) c.sort() j = 0 b = [0] * n pre = -float("inf") f = 0 while j < n: i = c[j][1] if l - a[i] >= pre: b[i] = l pre = l - a[i] + 1 else: ...
ASSIGN VAR 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 ASSIGN 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 LIST VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
n, l, r = [int(el) for el in input().split()] a = [int(el) for el in input().split()] p = [int(el) for el in input().split()] b = [(a[i] + p[i]) for i in range(n)] mx = max(b) mn = min(b) if mx <= r: print(" ".join([str(el) for el in b])) else: diff = mx - r if mn - diff >= l: print(" ".join([str(el...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL V...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
n, l, r = map(int, input().split()) a = list(map(int, input().split())) p = list(map(int, input().split())) seg = [0] * n for i in range(n): seg[i] = [l - a[i], r - a[i]] segments = [0] * n for i in range(n): segments[p[i] - 1] = seg[i] c = [0] * n can = True l = -(10**18) for i in range(n): if l >= segment...
ASSIGN VAR 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR LIST BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN ...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
f = lambda: map(int, input().split()) n, l, r = f() b = [(x + y) for x, y in zip(f(), f())] u, v = l - min(b), r - max(b) print(-1 if u > v else " ".join(str(q + u) for q in b))
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL STRING FUNC_CALL VAR BIN_OP VAR VAR VAR V...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
n, l, r = map(int, input().split()) a = list(map(int, input().split())) out = [-1] * n p = list(map(int, input().split())) pp = [(p[i], i) for i in range(n)] pp.sort() curr = -(l + r) for v, i in pp: best = curr + 1 + a[i] if best < l: best = l out[i] = best curr = best - a[i] if max(out) > r: ...
ASSIGN VAR 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 ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR F...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
n, l, r = list(map(int, input().split())) a = list(map(int, input().split())) p = list(map(int, input().split())) order = dict() for i in range(len(p)): order[p[i]] = i curr = -100000000000 b = [-1] * n for i in range(1, n + 1): if i == 1: b[order[i]] = l curr = b[order[i]] - a[order[i]] ...
ASSIGN VAR 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIG...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
from sys import stdin, stdout n, l, r = map(int, stdin.readline().split()) a = list(map(int, stdin.readline().split())) p = list(map(int, stdin.readline().split())) b = p[:] label = 1 diff = max(a) for i in range(n): b[i] += a[i] if min(b) < l: value = min(b) for i in range(n): b[i] += l - value if...
ASSIGN VAR 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR IF FUNC_CALL VAR VAR ...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
n, l, r = map(int, input().split()) a = [int(i) for i in input().split()] p = [int(i) for i in input().split()] b = [(a[i] + p[i]) for i in range(n)] m1 = min(b) m2 = max(b) if r - l + 1 < m2 - m1 + 1: print(-1) exit() if l <= m1 <= m2 <= r: print(*b) exit() if l > m1 and r < m2: print(-1) exit(...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
R = lambda: map(int, input().split()) n, l, r = R() a, d = list(R()), list(R()) b = [l for _ in range(n)] c = [(0) for _ in range(n)] for i in range(n): c[d[i] - 1] = i dif = l - a[c[0]] for x in c[1:]: if b[x] - a[x] <= dif: b[x] = a[x] + dif + 1 dif = b[x] - a[x] if b[x] > r: print("-1...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR BIN_OP VAR V...
Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}. About sequences a and b we know that their elements are in the range ...
n, l, r = map(int, input().split()) read = lambda: map(int, input().split()) a = list(read()) p = list(read()) d = [(a[i], p[i], i) for i in range(n)] d.sort(key=lambda x: x[1]) cur = l - d[0][0] b = [0] * n for i in range(n): ind = d[i][2] b[ind] = a[ind] + cur if b[ind] < l: cur = l - a[ind] ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER NUMBER ASSIG...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
import sys input = sys.stdin.readline t = int(input()) for tests in range(t): n, m = map(int, input().split()) A = [list(map(int, input().split())) for i in range(n)] flag = 1 ANS = [] for i in range(n): if flag == 0 or len(ANS) > 0: break B = list(A[i]) C = list...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER FUNC_CALL VAR...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
t = int(input()) for _ in range(t): n, m = list(map(int, input().strip().split())) swap_pos = None impossible = False arr = [] for _ in range(n): row = list(map(int, input().strip().split())) sort_row = sorted(row) arr.append(row) pos = [] for i in range(m): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NONE ASSIGN VAR NUMBER 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 ASSIGN VAR FUNC_CALL ...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
t = int(input()) while t: n, m = map(int, input().split()) a = list() for i in range(n): a.append(list(map(int, input().split()))) x = list() i = 0 while i < n and not len(x): k = list(a[i]) k.sort() for j in range(m): if a[i][j] != k[j]: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL 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 ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FU...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
t = int(input()) result = [] while t > 0: t -= 1 n, m = map(int, input().split()) a = [] b = [] for i in range(n): col1 = list(map(int, input().split())) col2 = col1.copy() col2.sort() a.append(col1) b.append(col2) s = set() for i in range(n): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST WHILE VAR NUMBER VAR NUMBER 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 ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_C...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
import sys input = sys.stdin.readline def solve(): N, M = list(map(int, input().split())) X = [] for i in range(M): X.append([]) for i in range(N): K = list(map(int, input().split())) for j in range(M): X[j].append(K[j]) flag = 0 ans = set() Y = X.copy(...
IMPORT ASSIGN VAR VAR FUNC_DEF 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 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 VAR VAR VAR AS...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
for inh in range(int(input())): n, m = map(int, input().split()) a, hehe = [], [] for i in range(n): k = list(map(int, input().split())) a.append(k) b = k.copy() b.sort() hehe.append(b) for i in range(n): k = 0 x, y = -1, -1 for j in range(...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR V...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
def dif_col(l): new = l[:] new.sort() distinct = set() for i in range(len(l)): if l[i] != new[i]: distinct.add(i) return distinct def check_changed(l, swap): a, b = swap[0], swap[1] l[a], l[b] = l[b], l[a] for i in range(len(l) - 1): if l[i] > l[i + 1]: ...
FUNC_DEF ASSIGN VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_O...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
def solve(arr): bad = [] for i in range(len(arr)): b = list(arr[i]) b.sort() for j in range(len(b)): if arr[i][j] != b[j]: bad.append(j) if len(bad) > 0: break if len(bad) == 0: print(1, 1) elif len(bad) > 2: print(-...
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF FUNC_CALL VAR VAR NUMBER ...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
def check(grid, u, v): for irow in grid: sirow = list(irow) sirow[u], sirow[v] = sirow[v], sirow[u] for jc in range(1, len(sirow)): if sirow[jc - 1] > sirow[jc]: return False return True def solve(): n, m = map(int, input().split()) grid = [] for...
FUNC_DEF FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
for i in range(int(input())): n, m = map(int, input().split()) d = [] for j in range(n): A = [int(k) for k in input().split()] d.append(A) flag = 0 ans = [] for j in d: b = j.copy() b.sort() a = [] for h in range(m): if b[h] != j[h]: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR A...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
t = int(input()) for i in range(t): n, m = map(int, input().split()) lst = [] for j in range(n): lst1 = list(map(int, input().split())) lst.append(lst1) lst1 = [] e = 0 ind = [] v = len(lst[0]) for j in lst: lst3 = j.copy() lst3.sort() a = [] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
t = int(input()) for _ in range(t): n, m = map(int, input().split()) grid = [] for i in range(n): grid.append([int(x) for x in input().split()]) def solve(grid): x, y = -2, -2 for i in range(n): k = 0 for j in range(1, m): if grid[i][j] < ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR F...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
def sortcheck(ar): for i in range(0, len(ar) - 1): if ar[i] > ar[i + 1]: return False return True t = int(input()) for _ in range(t): n, m = map(int, input().split()) l = [] for _ in range(n): tl = list(map(int, input().split())) l.append(tl) u, v, issorted ...
FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 ...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
for _ in range(int(input())): n, m = map(int, input().split()) arr = [list(map(int, input().split())) for i in range(n)] swap = set() for row in arr: for i, a, b in zip(list(range(m)), row, sorted(row)): if a != b: swap.add(i + 1) if len(swap) > 2: print(-...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 FOR VAR VAR FOR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF ...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
test_cases = int(input()) def in_order(row): for i in range(1, len(row)): if row[i] < row[i - 1]: return False return True def diff_indices(a, b): indices = [] for i in range(len(a)): if a[i] != b[i]: indices.append(i) return indices for test in range(te...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
def solve(arr): n = len(arr) m = len(arr[0]) sorted_arr = [] for row in arr: sorted_arr.append(sorted(row)) badIdx = [] for i in range(n): for j in range(m): if arr[i][j] != sorted_arr[i][j]: badIdx.append(j) if len(badIdx) >= 2: br...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FU...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
for case in range(int(input())): n, m = map(int, input().split()) arr = [list(map(int, input().split())) for _ in range(n)] if m == 1: print(1, 1) else: swap = set() not_possible = False for i in range(n): temp = sorted(arr[i]) for j in range(m): ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN V...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
iT = int(input()) for _ in range(iT): answer = "" iN, iM = map(int, input().split()) lst_temp = [[] for _ in range(iN)] for idx in range(iN): lst_temp[idx] = list(map(int, input().split())) row = 0 idx1 = -1 for j in range(1, iM): for i in range(iN): if lst_temp[i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR F...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
def ss(g, m, n): l = [[0, 0] for _ in range(m)] for i in range(m): t = sorted(g[i]) c = 0 for j in range(n): if t[j] != g[i][j]: if c == 2: return -1 elif c == 0: c += 1 l[i][0] = j ...
FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR IF VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR ASSIGN VAR LIST N...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
for _ in range(int(input())): n, m = map(int, input().split()) a = [] for i in range(n): s = list(map(int, input().split())) a.append(s) res = [] for i in a: res.append(sorted(i)) x, y = -1, -1 ok = True for i in range(n): for j in range(m): if...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR N...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
t = int(input()) for _ in range(t): n, m = map(int, input().split()) arr = [] for i in range(n): l = list(map(int, input().split())) arr.append(l) flag = True indexs = [] for i in range(n): ol = arr[i].copy() sl = arr[i].copy() sl.sort() ti = [] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
t = int(input()) for _ in range(t): n, m = map(int, input().split()) arr = [] arr_sorted = [] for i in range(n): arr.append(list(map(int, input().split()))) arr_sorted.append(sorted(arr[i])) for i in range(n): ind = 0 cnt = 0 flag = 0 for j in range(m)...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VA...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
for u in range(int(input())): n, m = [int(x) for x in input().split()] l = [] for i in range(n): l.append([int(x) for x in input().split()]) temp = [] for i in range(n): temp.append(sorted(l[i])) for i in range(n): if l[i] != temp[i]: break q = [] for ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL V...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
T = int(input()) for _ in range(T): N, M = map(int, input().split()) A = [[int(c) for c in input().split()] for _ in range(N)] swappos = [] for i in range(N): B = sorted(A[i]) for j in range(M): if B[j] != A[i][j]: swappos.append(j) if len(swappos) > 0...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
t = int(input()) for _ in range(t): n, m = map(int, input().split()) rows = [list(map(int, input().split())) for i in range(n)] guess = None for r in range(n): row = rows[r] fixed = sorted(row) indexes = [i for i in range(m) if fixed[i] != row[i]] if len(indexes) > 2: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 NONE FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
R = lambda: [*map(int, input().split())] for _ in [0] * R()[0]: n, m = R() a = [R() for _ in [0] * n] (*b,) = map(sorted, a) i = j = 0 for t in zip(a, b): i, j, *_ = [i for i, x, y in zip(range(m), *t) if x ^ y] or (i, j) for r in a: r[i], r[j] = r[j], r[i] print(*((i + 1, j ...
ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR BIN_OP LIST NUMBER FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
T = int(input()) while T: T -= 1 n, m = map(int, input().split()) ex = [] a = [[0]] * n for i in range(n): a[i] = list(map(int, input().split())) for row in a: rc = row.copy() rc.sort() for i in range(m): if row[i] != rc[i]: ex.append(i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
T = int(input()) for case in range(T): n, m = map(int, input().split()) g = [tuple(map(int, input().split())) for r in range(n)] g = tuple(zip(*g)) r = tuple(sorted(g)) for i in range(1, m): for j in range(n): if r[i][j] < r[i - 1][j]: break else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR N...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
for _ in range(int(input())): n, m = map(int, input().split()) l = [] w = 0 p, o = -1, -1 for i in range(n): t = list(map(int, input().split())) u = t.copy() u.sort() if t == u: w += 1 l.append(t) if w == n: print(1, 1) else: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR VAR VA...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
cases = int(input()) for i in range(cases): good = True r, c = map(int, input().split()) gaps = [] mat = [] for j in range(r): row = list(map(int, input().split())) mat.append(row) for j in range(r): gaps = [] row = mat[j] sortedRow = sorted(row) f...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER 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...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
t = int(input()) while t != 0: r, c = list(map(int, input().split(" "))) arr = [] for i in range(r): r1 = list(map(int, input().split(" "))) arr.append(r1) bad = [] for i in range(0, r): if bad: break k = arr[i].copy() k.sort() for j in ran...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VA...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
t = int(input()) for i in range(t): a, b = input().split() n, m = int(a), int(b) c = [[] * m] * n e = [] flag = 0 ans = 0 tot = 0 for j in range(n): c[j] = input().split() for k in range(m): c[j][k] = int(c[j][k]) for j in range(n): if c[j] == sort...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST BIN_OP LIST VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL F...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
for i in range(int(input())): n, m = list(map(int, input().split())) a = [0] * n b = [0] * n x = 0 y = 0 count = 0 for i in range(n): a[i] = list(map(int, input().split())) b[i] = a[i] b[i] = sorted(b[i]) for i in range(n): for j in range(m): i...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
T = int(input()) for _ in range(T): n, m = map(int, input().split()) matrix = [None] * n for i in range(n): matrix[i] = list(map(int, input().split())) swap1 = -1 swap2 = -1 found = False for i in range(n): for j in range(m - 1): if matrix[i][j] > matrix[i][j + 1]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CA...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
class Solve: def __init__(self): self.n, self.m = map(int, input().strip().split()) self.table = [list(map(int, input().strip().split())) for _ in range(self.n)] def check_table(self): for i in range(self.n): for j in range(1, self.m): if self.table[i][j] < ...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR RETURN NONE FUN...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
import sys input = sys.stdin.readline ints = lambda: list(map(int, input().split())) t = ints()[-1] for _ in range(t): n, m = ints() grid = [ints() for _ in range(n)] problem = set() for row in grid: temp = row[:] temp.sort() for i in range(m): if temp[i] != row[i]: ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
t = int(input()) while t > 0: t -= 1 n, m = map(int, input().split()) a = [] b = [] swap = [0] * m for i in range(n): a += [list(map(int, input().split()))] b += [sorted(a[i])] idx = -1 jdx = -1 k = 0 for i in range(n): for j in range(m): if a[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR LIST FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR LIST FUNC_CALL VAR VAR VAR ASSIGN V...
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$. You ha...
import sys input = sys.stdin.readline for _ in range(int(input())): n, m = list(map(int, input().split())) arr = [] for i in range(n): a = list(map(int, input().split())) arr.append(a) a = [] for i in range(n): b = sorted(arr[i]) for j in range(m): if arr...
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL 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 ASS...