description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
t = int(input()) for j in range(t): n, k = map(int, input().split()) a = input().split() b = input().split() a = [int(i) for i in a] b = [int(i) for i in b] sumn = 0 temp = 0 for i in range(len(a)): sumn += a[i] * b[i] temp2 = sumn for i in range(len(b)): if a[i] ...
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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL 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 FOR VAR FUNC_CALL ...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
def interaction(a, b): sum = 0 for i in range(len(a)): sum += a[i] * b[i] return sum t = int(input()) while t: t -= 1 n, k = map(int, input().split()) a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] l = [abs(x) for x in b] if b[l.index(max(l))] >...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR RETURN VAR 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 FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CAL...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
from sys import stdin input = stdin.readline t = int(input()) for _ in range(t): n, k = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) orig = 0 for i in range(n): orig += A[i] * B[i] a = max(B) b = min(B) c = max(abs(a), abs(b))...
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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR B...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
t = int(input()) for t in range(t): n, k = [int(i) for i in input().split()] a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] print(sum(x * y for x, y in zip(a, b)) + k * max(map(abs, b)))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
Test = int(input()) while Test != 0: maxi = 0 N, K = map(int, input().split()) A = [] B = [] A = input().split() B = input().split() for j in range(N): A[j] = int(A[j]) B[j] = int(B[j]) if maxi < abs(B[j]): maxi = abs(B[j]) loc = j prod = 0...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
for _ in range(int(input())): maxx = -100005 summ = 0 n, k = map(int, input().split()) arr = list(map(int, input().split())) brr = list(map(int, input().split())) for i in range(n): if maxx < abs(brr[i]): maxx = abs(brr[i]) index = i for i in range(n): ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL ...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) l1 = [int(x) for x in input().split()] l2 = [int(x) for x in input().split()] a, b = [], [] ans = [] mx = 0 for i in range(n): if mx < abs(l2[i]): mx = abs(l2[i]) ans = [l1[i], l2[i], i] ...
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 ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
for _ in range(int(input())): n, k = list(map(int, input().split(" "))) a = list(map(int, input().split(" "))) b = list(map(int, input().split(" "))) data = [] sum_data = sum(x * y for x, y in zip(a, b)) for i in range(n): data.append(sum_data + k * b[i]) data.append(sum_data - k...
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 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 LIST ASSIGN VAR FUNC_CALL VAR BIN...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) a = list(map(int, input().lstrip().split())) b = list(map(int, input().lstrip().split())) total = 0 for i in range(n): total += a[i] * b[i] maxi = total for i in range(n): val1 = maxi val2 = maxi ...
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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
t = int(input()) while t > 0: n, k = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) max = 0 m = 0 for i in range(0, n): e = b[i] if e < 0: e = e * -1 if max < e: m = i max = e if b[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSI...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
for _ in range(int(input())): N, K = list(map(int, input().split())) a = list(map(int, input().split())) b = list(map(int, input().split())) sum1 = sum(list(n1 * n2 for n1, n2 in zip(a, b))) max_b = max(b) min_b = min(b) if -min_b > max_b: sum1 = sum1 - K * min_b else: su...
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 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 BIN_OP VAR VAR VAR VAR FUN...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
t = int(input()) for tc in range(t): n, k = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) mx = -99999999 for i in b: mx = max(mx, abs(i)) ii = 0 for i in range(n): ii = ii + a[i] * b[i] ii = ii + mx * k print(ii)
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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
t = int(input()) while t > 0: n, k = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = 0 for i in range(0, n): c += a[i] * b[i] mx = b[0] for i in range(1, n): mx = max(mx, abs(b[i])) c += k * mx print(c) t -= 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR VAR VAR...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
for _ in range(int(input())): n, k = map(int, input().split()) a, b = list(map(int, input().split())), list(map(int, input().split())) res = 0 for i in range(n): res += a[i] * b[i] m = 0 for i in range(n): if abs(b[i]) > m: m = abs(b[i]) pos = i res = ...
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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMB...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
t = int(input()) for i in range(t): length, operations = map(int, input().split()) arr = [] total = 0 arr1 = list(map(int, input().split())) arr2 = list(map(int, input().split())) for j in range(length): arr.append([arr1[j], arr2[j]]) total += arr1[j] * arr2[j] arr.sort(key=l...
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 NUMBER 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 FOR VAR FUNC_CALL VAR VAR EXPR...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
t = int(input()) for i in range(t): n, k = list(map(int, input().split())) a = list(map(int, input().split())) b = list(map(int, input().split())) mb = b[0], 0 for i in range(len(b)): if abs(b[i]) > abs(mb[0]): mb = b[i], i if mb[0] >= 0: a[mb[1]] += k else: ...
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 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 NUMBER NUMBER FOR VAR FUNC_CALL VAR...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
for t in range(int(input())): ans = 0 n, k = map(int, input().split()) arrA = list(map(int, input().split())) arrB = list(map(int, input().split())) for i in range(len(arrA)): ans += arrA[i] * arrB[i] if arrB[i] < 0: arrB[i] *= -1 print(ans + k * max(arrB))
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VA...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
T = int(input()) while T > 0: N, K = map(int, input().split()) A = [int(n) for n in input().split()] B = [int(n) for n in input().split()] result = 0 inter = 0 for i in range(N): result += A[i] * B[i] inter = result for i in range(N): if A[i] >= 0 and B[i] >= 0 or A[i] < ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSI...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
for _ in range(int(input())): n, k = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) f = max(b) r = min(b) sum = 0 for i in range(n): sum += a[i] * b[i] b[i] = abs(b[i]) sum += k * max(b) print(sum)
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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
def soln(n, k, a, b): res = 0 orig = 0 maxm = 0 for i in range(n): res += a[i] * b[i] res += k * max(abs(max(b)), abs(min(b))) return res for _ in range(int(input())): n, k = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CA...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
for _ in range(int(input())): n, k = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) M = 0 ans = 0 for i in range(n): ans += A[i] * B[i] if B[i] < 0: B[i] *= -1 if B[i] > M: M = B[i] ans += k * ...
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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VA...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
tc = int(input()) for _ in range(tc): n, k = map(int, input().split(" ")) list_A = list(map(int, input().split(" "))) list_B = list(map(int, input().split(" "))) mx = 0 sumall = 0 for i in range(n): c = list_A[i] * list_B[i] sumall += c if list_B[i] > 0: d = l...
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 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 NUMBER ASSIGN VAR NUMBER FOR VAR...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
q = int(input()) for i in range(0, q): temp = list(map(int, input().split(" ", 2)[:2])) n = temp[0] k = temp[1] listA = list(map(int, input().split(" ", n)[:n])) listB = list(map(int, input().split(" ", n)[:n])) sum1 = 0 for j in range(0, n): sum1 = sum1 + listA[j] * listB[j] max...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
t = int(input()) for _ in range(t): n, k = [int(x) for x in input().split()] a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] for i in range(n): if a[i] <= 0 and b[i] <= 0: a[i], b[i] = -a[i], -b[i] x = 0 for i in range(n): if abs(b[i]) > ab...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR VA...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
t = int(input()) for i in range(0, t): n, k = map(int, input().split()) res = 0 a = list(map(int, input().split())) b = list(map(int, input().split())) B = [] for j in range(0, n): res = res + a[j] * b[j] B.append(abs(b[j])) res = res + k * abs(b[B.index(max(B))]) print(r...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER 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 N...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
n = int(input()) for i in range(n): p = input() n, k = p.split() n, k = int(n), int(k) a = input() b = input() la = [int(s) for s in a.strip().split(" ")] lb = [int(s) for s in b.strip().split(" ")] maxb = 0 mai = -1 ms = 1 for i in range(n): temp = abs(lb[i]) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUN...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] x = 0 m = 0 sum = 0 for i in range(n): r = a[i] * b[i] sum = sum + r p = (a[i] + 1) * b[i] q = (a[i] - 1) * b[i] ...
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 ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSI...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) mb, mbi = 0, 0 for i in range(n): if b[i] < 0: if mb < -1 * b[i]: mb = -1 * b[i] mbi = i elif mb < ...
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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VA...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
def solution(a, b, k): s = sum(x * y for x, y in zip(a, b)) maxi = s + 0 for i in range(len(b)): if s + k * b[i] > maxi: maxi = s + k * b[i] if s - k * b[i] > maxi: maxi = s - k * b[i] return maxi T = int(input()) for t in range(T): N, K = map(int, input().s...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR VAR IF BIN_OP VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR VAR RETURN VAR ASSIG...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
t = int(input()) for i in range(t): n, k = input().split(" ") n = int(n) k = int(k) a = input().split(" ") b = input().split(" ") maxi = 0 ind = 0 for z in range(n): val = int(b[z]) if abs(val) > maxi: maxi = abs(val) ind = z s = int(va...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING 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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIG...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
t = int(input()) for i in range(t): a = [] b = [] n, k = map(int, input().split()) a = list(map(int, input().strip().split()))[:n] b = list(map(int, input().strip().split()))[:n] max = abs(b[0]) ind = 0 sum = 0 for j in range(n): if abs(b[j]) > max: max = abs(b[j]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST 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 FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR VAR ASSI...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
for t in range(int(input())): n, k = map(int, input().split()) a = sorted( (bi, ai) for ai, bi in zip(map(int, input().split()), map(int, input().split())) ) v = sum(bi * ai for bi, ai in a) if a[-1][0] > 0 and a[-1][0] >= -a[0][0]: v += k * a[-1][0] elif a[0][0] < 0: v +...
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 VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR IF VAR NUMBER NUMBER N...
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N. You want to maximize the value of interaction of the arrays. You are allowed to make ...
for i in range(int(input())): n, k = list(map(int, input().split())) x = list(map(int, input().split())) y = list(map(int, input().split())) s = 0 for j in range(n): s = s + x[j] * y[j] a = s + max(y) * k b = s + min(y) * -k print(max(a, b))
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 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 NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR...
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
t = int(input()) for i in range(t): n = int(input()) l = list(map(int, input().split())) s = {0} c = 0 p = 0 for i in l: p ^= i if p in s: c += 1 p = i s = {i} else: s.add(p) print(c)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR ...
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
T = int(input()) for _ in range(T): st = set([]) st.add(0) flag = 0 N = int(input()) arr = list(map(int, input().split())) xor1 = 0 marker = 5000 c = 0 bool = True marker = flag for i in range(N): flag += 1 xor1 ^= arr[i] marker -= flag * 2 if ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR LIST EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASS...
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
t = int(input()) for i in range(t): n = int(input()) arr = list(map(int, input().split())) d = {} res = 0 d[0] = 1 curr = 0 for i in range(len(arr)): curr = curr ^ arr[i] if curr in d: res += 1 d = {} curr = 0 d[curr] = 0 print(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF...
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
T = int(input()) for i in range(T): N = int(input()) A = list(map(int, input().split())) ans, xor = 0, 0 xorSums = set([0]) for i in A: if xor ^ i in xorSums: ans += 1 xor = 0 xorSums = set([0]) else: xor = xor ^ i xorSums.a...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR LIST NUMBER FOR VAR VAR IF BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL...
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) s = set() s.add(0) x = 0 ans = 0 for i in range(n): x = x ^ a[i] if x in s: ans += 1 x = a[i] s = set() s.add(x) else: s.add(...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR VAR NUMBER...
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
import sys from itertools import islice for s in islice(sys.stdin, 2, None, 2): r = t = 0 a = {0} for x in s.split(): t ^= int(x) if t in a: r += 1 t = 0 a = {0} a.add(t) print(r)
IMPORT FOR VAR FUNC_CALL VAR VAR NUMBER NONE NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) count = 0 iop = 0 st = set() st.add(0) for i in range(n): iop ^= a[i] if list(st).count(iop) >= 1: st = set() count += 1 st.add(0) iop = 0 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF FUNC_CALL FUNC_CALL VAR VAR VAR NUMB...
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
for i in range(int(input())): n = int(input()) l = list(map(int, input().split())) k, t = 0, 0 m = {} m[0] = 1 for j in l: t ^= j if t in m and m[t] == 1: k += 1 m.clear() m[t] = 1 print(k)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER NUMBER FOR VAR VAR VAR VAR IF VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR NUM...
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) count = 0 xor = 0 set1 = set() set1.add(0) for i in arr: xor = xor ^ i if xor in set1: count += 1 xor = 0 set1.clear() set1.add(xor) print(coun...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER...
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
def solve(n, arr): lookup = {0} curr = 0 res = 0 for num in arr: curr ^= num if num == 0 or curr in lookup: lookup = {0} curr = 0 res += 1 continue lookup.add(curr) return res for _ in range(int(input())): n = int(input())...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR IF VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FU...
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) s = set([0]) ans = 0 count = 0 for i in range(n): count = count ^ a[i] if count in s: ans += 1 s = set([0]) count = 0 s.add(count) print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR LIST NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR VAR NUMBE...
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) occs = set() occs.add(0) res = xorofone = 0 for i in range(n): xorofone ^= arr[i] if xorofone in occs: occs.clear() res += 1 occs.add(0) xorofone =...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CA...
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
for i in range(int(input())): n = int(input()) a = list(map(int, input().split())) x = 0 dic = {} c = 0 for i in range(n): x = x ^ a[i] if x in dic or a[i] == 0 or x == 0: c += 1 dic = {} x = 0 else: dic[x] = 1 print(c)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN V...
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
t = int(input()) def fn(arr): l = len(arr) stack = [] operations = 0 for i in range(l): if arr[i] == 0: operations += 1 stack = [] elif arr[i] in stack: operations += 1 stack = [] else: for j in range(len(stack)): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR LIST IF VAR VAR VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR...
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
import sys input = sys.stdin.readline for _ in range(int(input())): n = int(input()) l = list(map(int, input().split())) s = {0} x, ans = 0, 0 for i in range(n): x = x ^ l[i] if x in s: ans += 1 s = {l[i]} x = l[i] else: s.add(...
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR VA...
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) for i in range(1, n): arr[i] ^= arr[i - 1] s = {0} res = 0 for e in arr: if e in s: res += 1 s = {e} else: s.add(e) print(res)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL V...
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
t = int(input()) for _ in range(t): n = int(input()) a = [int(x) for x in input().split()] xor = 0 set_ = set() set_ = {xor} count = 0 for i in range(0, n): xor = a[i] ^ xor if xor in set_: xor = 0 count += 1 set_.clear() set_.a...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VA...
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
def haxorzro(A, lstart, r): xor = 0 for l in range(r, lstart - 1, -1): xor ^= A[l] if not xor: return True else: return False def minops(A, N): lstart = 0 ops = 0 while True: for r in range(lstart, N): if haxorzro(A, lstart, r): ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER VAR VAR VAR IF VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FU...
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
for _ in range(int(input())): size = int(input()) array = list(map(int, input().split())) maps = set() ans = 0 xors = 0 for i in array: xors ^= i if xors == 0 or xors in maps: ans = ans + 1 maps = set() xors = 0 else: maps.a...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR IF VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN ...
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
def Solution(n, a): count = 0 temp = {0} p = 0 for i in range(n): p = p ^ a[i] if p not in temp: temp.add(p) else: count += 1 temp = {p} return count test = int(input()) for t in range(test): n = int(input()) a = tuple(map(int, in...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR F...
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
def ans(arr): k = {0} current = 0 c = 0 for y in arr: xored = current ^ y if xored in k: c += 1 k = {y} current = y else: current = xored k.add(xored) return c test_cases = int(input()) while test_cases != 0: d...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VA...
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
t = int(input()) for s in range(t): a = int(input()) arr = [int(i) for i in input().split()] s = set() s.add(0) x = 0 ans = 0 for i in arr: x = x ^ i if x in s: ans += 1 s.clear() s.add(x) print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CA...
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
for _ in range(int(input())): xrs = set([0]) n = int(input()) a = [int(i) for i in input().split()] prv = 0 ct = 0 for i in range(n): xr = prv ^ a[i] if xr in xrs: ct += 1 xrs = set([xr]) else: xrs.add(xr) prv = xr print(ct)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR LIST NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VA...
An array A of size N is called *good* if the following conditions hold: For every pair (l, r) (1 ≤ l ≤ r ≤ N), A_{l} \oplus A_{l+1} \oplus ... \oplus A_{r} \ne 0. (where \oplus denotes the [bitwise XOR operation].) JJ has an array A of size N. He wants to convert the array to a good array. To do so he can perform the ...
t = int(input()) while t > 0: t = t - 1 n = int(input()) arr = list(map(int, input().split())) ans = 0 x = 0 s = set() s.add(0) for i in range(n): x = x ^ arr[i] if x in s: s = set() ans += 1 s.add(0) x = 0 s.add(x) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_O...
Given a string num representing the digits of a very large integer and an integer k. You are allowed to swap any two adjacent digits of the integer at most k times. Return the minimum integer you can obtain also as a string.   Example 1: Input: num = "4321", k = 4 Output: "1342" Explanation: The steps to obtain the mi...
class Solution: def minInteger(self, num: str, k: int) -> str: rest = num move = 0 s = "" for dig in range(10): count = 0 digC = str(dig) for i, c in enumerate(rest): if c == digC: if k < move + i - count: ...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR STRING VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN ...
Given a string num representing the digits of a very large integer and an integer k. You are allowed to swap any two adjacent digits of the integer at most k times. Return the minimum integer you can obtain also as a string.   Example 1: Input: num = "4321", k = 4 Output: "1342" Explanation: The steps to obtain the mi...
class Solution: def minInteger(self, num: str, k: int) -> str: if k <= 0: return num for i in range(10): ind = num.find(str(i)) if 0 <= ind <= k: return str(num[ind]) + self.minInteger( num[0:ind] + num[ind + 1 :], k - ind ...
CLASS_DEF FUNC_DEF VAR VAR IF VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF NUMBER VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR RETURN VAR VAR
Given a string num representing the digits of a very large integer and an integer k. You are allowed to swap any two adjacent digits of the integer at most k times. Return the minimum integer you can obtain also as a string.   Example 1: Input: num = "4321", k = 4 Output: "1342" Explanation: The steps to obtain the mi...
class Solution: def minInteger(self, num: str, k: int) -> str: n = len(num) if k >= (n - 1) * n // 2: return "".join(sorted(num)) ans = [] while k and num: for d in "0123456789": i = num.find(d) if 0 <= i <= k: ...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER RETURN FUNC_CALL STRING FUNC_CALL VAR VAR ASSIGN VAR LIST WHILE VAR VAR FOR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR IF NUMBER VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR R...
Given a string num representing the digits of a very large integer and an integer k. You are allowed to swap any two adjacent digits of the integer at most k times. Return the minimum integer you can obtain also as a string.   Example 1: Input: num = "4321", k = 4 Output: "1342" Explanation: The steps to obtain the mi...
class Solution: def minInteger(self, num: str, k: int) -> str: min_num = "".join(sorted(list(num))) i = 0 to_find = 0 while num != min_num and k > 0 and i < len(num): index = num.find(str(to_find), i) while index != -1: if index - i <= k: ...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR WHILE VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR ...
Given a string num representing the digits of a very large integer and an integer k. You are allowed to swap any two adjacent digits of the integer at most k times. Return the minimum integer you can obtain also as a string.   Example 1: Input: num = "4321", k = 4 Output: "1342" Explanation: The steps to obtain the mi...
class Solution: def minInteger(self, num: str, k: int) -> str: n = len(num) if k <= 0: return num if k > n * (n - 1) // 2: return "".join(sorted(list(num))) for i in range(10): idx = num.find(str(i)) if idx >= 0 and idx <= k: ...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN VAR IF VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER RETURN FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR RETURN BIN_OP VAR VAR FUNC_CALL VAR BIN...
Given a string num representing the digits of a very large integer and an integer k. You are allowed to swap any two adjacent digits of the integer at most k times. Return the minimum integer you can obtain also as a string.   Example 1: Input: num = "4321", k = 4 Output: "1342" Explanation: The steps to obtain the mi...
class Solution: def minInteger(self, num: str, k: int) -> str: D = 10 ans = num for d in range(D): i = num.find(str(d)) if i < 0: continue cost = i if cost > k: continue if i == 0: re...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR IF VAR VAR IF VAR NUMBER RETURN BIN_OP VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR RETURN BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER BI...
Let's call an array consisting of n integer numbers a_1, a_2, ..., a_{n}, beautiful if it has the following property: consider all pairs of numbers x, y (x ≠ y), such that number x occurs in the array a and number y occurs in the array a; for each pair x, y must exist some position j (1 ≤ j < n), such that at least...
n, m = map(int, input().split()) q = [0] * m w = [0] * m for i in range(m): q[i], w[i] = [int(x) for x in input().split()] w.sort(reverse=True) s = 0 v = 0 for i in range(m): i = i + 1 if i % 2 == 1: v = i * (i - 1) // 2 + 1 else: v = i * i // 2 i = i - 1 if v > n: break ...
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 VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR B...
Let's call an array consisting of n integer numbers a_1, a_2, ..., a_{n}, beautiful if it has the following property: consider all pairs of numbers x, y (x ≠ y), such that number x occurs in the array a and number y occurs in the array a; for each pair x, y must exist some position j (1 ≤ j < n), such that at least...
def Fun(n): if n % 2: return n * (n - 1) // 2 + 1 return n * n // 2 n, m = list(map(int, input().split())) q = [0] * m w = [0] * m for i in range(m): q[i], w[i] = [int(x) for x in input().split()] w.sort(reverse=True) s = 0 v = 0 for i in range(m): if Fun(i + 1) > n: break s += w[i...
FUNC_DEF IF BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER NUMBER RETURN BIN_OP BIN_OP VAR VAR NUMBER 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 FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FU...
Let's call an array consisting of n integer numbers a_1, a_2, ..., a_{n}, beautiful if it has the following property: consider all pairs of numbers x, y (x ≠ y), such that number x occurs in the array a and number y occurs in the array a; for each pair x, y must exist some position j (1 ≤ j < n), such that at least...
def readdata(): global n, m, w, q n, m = [int(x) for x in input().split()] q = [0] * m w = [0] * m for i in range(m): q[i], w[i] = [int(x) for x in input().split()] def podg(): global summ w.sort(reverse=True) summ = [w[0]] * m for i in range(1, m): summ[i] = summ[i...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR 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 VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST VAR NUMBER VAR FOR VAR FUNC_C...
Let's call an array consisting of n integer numbers a_1, a_2, ..., a_{n}, beautiful if it has the following property: consider all pairs of numbers x, y (x ≠ y), such that number x occurs in the array a and number y occurs in the array a; for each pair x, y must exist some position j (1 ≤ j < n), such that at least...
import itertools def f(n): return n * (n - 1) / 2 + 1 if n % 2 else n * (n - 1) / 2 + n / 2 n, m = list(map(int, input().split())) table = sorted([int(input().split()[1]) for _ in range(m)], reverse=True) ans = 1 while f(ans) <= n: ans += 1 ans -= 1 print(list(itertools.accumulate(table))[min(ans - 1, m - 1...
IMPORT FUNC_DEF RETURN BIN_OP VAR NUMBER BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR NUMBER VAR FUNC_CALL...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
s = input() t = input() a = [(int(x) - 1) for x in input().split()] def ok(n): bad = set(a[:n]) it = (a for i, a in enumerate(s) if i not in bad) return all(c in it for c in t) low = 0 high = len(s) while low < high: mid = (high + low + 1) // 2 if ok(mid): low = mid else: hig...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
def canFind(ss, t, arr, mid): s = ss.copy() for i in range(mid): s[arr[i] - 1] = "#" k = 0 for i in range(len(t)): flag = False for j in range(k, len(s)): if t[i] == s[j]: flag = True k = j + 1 break if not flag:...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR RETURN NUMBER RETURN NUMBER...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
def isSubSequence(str1, str2, m, n): j = 0 i = 0 while j < m and i < n: if str1[j] == str2[i]: j = j + 1 i = i + 1 return j == m t = list(input()) p = input() a = list(map(int, input().split())) def check(x): count = 0 y = t.copy() for i in range(x): y...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASS...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
def main(): t = input() p = input() n = len(t) pos = list(map(lambda x: int(x) - 1, input().split())) def f(ind): was = [(0) for _ in range(n)] for i in range(ind + 1): was[pos[i]] = 1 pattern_pos = 0 for i, ch in enumerate(t): if was[i] == 0 ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR ...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
def check(i): k = 0 for c, n in zip(s, ns): if n <= i: continue if s2[k] == c: k += 1 if k == len(s2): return True return False s = input() s2 = input() ns = [(i + 1, int(x)) for i, x in enumerate(input().split())] ns.sort(key=lambda x: x...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUM...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
def can(m): u = sorted(a[:m]) inp = 0 inu = 0 for i in range(len(t)): if inu < len(u) and i == u[inu] - 1: inu += 1 elif t[i] == p[inp]: inp += 1 if inp == len(p): return True return False t = input() p = input() a = list(map(int,...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN ...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
def solution(a, b, c): def check(x): temp = list(a) for i in range(x): temp[c[i] - 1] = "$" j = 0 for i in range(len(temp)): if temp[i] == b[j]: j += 1 if j == len(b): return True return False low = 0 ...
FUNC_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIG...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
t = input() p = input() a = list(map(int, input().split())) for i in range(len(a)): a[i] -= 1 step = 0 mark = [0] * len(t) def check(index): global step step += 1 for j in range(index + 1): mark[a[j]] = step temp_index = 0 for j in range(len(t)): if mark[j] == step: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FUNC_DEF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
t = input().strip() p = input().strip() A = list(map(int, input().strip().split())) def fn(c): s = set(A[:c]) st = [] for i in range(len(t)): if (i + 1 in s) == False: st.append(t[i]) p1 = 0 p2 = 0 while p1 != len(st) and p2 != len(p): if st[p1] == p[p2]: ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBE...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
t = input() p = input() a = list(map(int, input().split())) def can(s, p): i = 0 for ch in s: if ch == p[i]: i += 1 if i == len(p): return True return False def binary_search(l, r): while l < r - 1: s = list(t) mid = (l + r) // 2 ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP B...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
import sys def removeat(string, indexes): return [c for i, c in enumerate(string) if i not in indexes] def contains(string, what): if not len(what): return True if not len(string): return False checked = 0 for c in string: if what[checked] == c: checked += 1 ...
IMPORT FUNC_DEF RETURN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_DEF IF FUNC_CALL VAR VAR RETURN NUMBER IF FUNC_CALL VAR VAR RETURN NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_C...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
import sys def debug(x, table): for name, val in table.items(): if x is val: print("DEBUG:{} -> {}".format(name, val), file=sys.stderr) return None def solve(): t = input() p = input() A = [(int(i) - 1) for i in input().split()] ans = nibutan(t, p, A) print(an...
IMPORT FUNC_DEF FOR VAR VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR VAR VAR RETURN NONE FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN V...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
def possible(t, p, a, n): s = "" check = [True] * len(t) for i in range(n): check[a[i]] = False for i in range(len(check)): if check[i]: s += t[i] m = len(s) lp = len(p) c = 0 for i in range(m): if s[i] == p[c]: c += 1 if c == lp: ...
FUNC_DEF ASSIGN VAR STRING ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBE...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
a = input() b = input() c = [(int(i) - 1) for i in input().split()] l = 0 r = len(a) while r - l > 1: m = l + (r - l) // 2 d = list(a) j = 0 for i in range(m): d[c[i]] = "" for i in range(len(a)): if d[i] == b[j]: j += 1 if j == len(b): l = m ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
b = input() s = input() i = [(int(x) - 1) for x in input().split()] def viable(x): ind = 0 ok = [0] * len(b) for j in range(0, x): ok[i[j]] = 1 for j in range(0, len(b)): if s[ind] == b[j] and ok[j] != 1: ind += 1 if ind == len(s): break if i...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR VAR...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
def subset(S, s): i = 0 j = 0 while i < len(S) and j < len(s): if S[i] == s[j]: i += 1 j += 1 else: i += 1 if j == len(s): return True return False n = input() a = input() arr = [(int(x) - 1) for x in input().split()] new = [] l = 0 r = l...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
def check(tt, p): i, j = 0, 0 while i < len(t): if tt[i] == p[j]: j += 1 i += 1 if j == len(p): break if j == len(p): return 1 else: return 0 t = list(input()) p = list(input()) n = len(t) a = list(map(int, input().split())) l, r, ans = 0...
FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUN...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
s = input() t = input() arr = list(map(int, input().split())) l = 0 r = len(arr) - len(t) while l <= r: mid = (l + r) // 2 var = [0] * len(arr) for i in range(mid): var[arr[i] - 1] = 1 f = 0 for i in range(len(s)): if var[i]: continue if f == len(t): b...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASS...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
import sys input = sys.stdin.readline t = input().rstrip() p = input().rstrip() a = list(map(int, input().split())) l = 0 r = len(a) while r - l > 1: mid = (r + l) // 2 s = set(a[:mid]) j = 0 for i in range(len(t)): if j < len(p) and t[i] == p[j] and i + 1 not in s: j += 1 if j ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NU...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
def mi(): return map(int, input().split()) s = list(input()) t = input() a = list(map(int, input().split())) def isSubSequence(str1, str2, m, n): j = 0 i = 0 while j < m and i < n: if str1[j] == str2[i]: j = j + 1 i = i + 1 return j == m l = len(a) high = l low = 0 ...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_O...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
s1 = input() s2 = input() rs = list(map(int, input().split())) def is_in(big, little): i, j = 0, 0 matched = 0 while i < len(big) and j < len(little): if big[i] == little[j]: matched += 1 i += 1 j += 1 else: i += 1 if matched < len(little...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NU...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
def findPossible(str1, str2): str1length = len(str1) str2length = len(str2) str1Flag = 0 str2Flag = 0 for x in range(0, str1length): if str1[x] == str2[str2Flag]: str2Flag += 1 if str2Flag == str2length: return True return False def delChr(oldStr, permut...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR VAR VAR NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUM...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
def pred(s1, s2, arr, mid): n = len(s1) m = len(s2) marked = [(0) for x in range(n)] for i in range(mid + 1): marked[arr[i] - 1] = 1 i = 0 j = 0 while i < n and j < m: if not marked[i] and s1[i] == s2[j]: j += 1 i += 1 return j != m s1 = input() s2 =...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER RETURN VAR VAR ASSIGN VAR ...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
import sys Ri = lambda: [int(x) for x in sys.stdin.readline().split()] ri = lambda: sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [([c] * b) for i in range(a)] def list3d(a, b, c, d): return [[([d] * c) for j in range(b)] for i in range(a)] ...
IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUN...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
def is_obtained(p, t, K): i = 0 for ch in p: i = t.find(ch, i) + 1 if i == 0: return False while i in K: i = t.find(ch, i) + 1 if i == 0: return False return True I = input t, p, A = I(), I(), list(map(int, I().split())) L, R = 0,...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER RETURN NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
def binary_search(lis, l, r, txt, txt2): if r >= l: mid = l + (r - l) // 2 templis = lis[0 : mid + 1] if is_sub(txt, txt2, templis): return binary_search(lis, mid + 1, r, txt1, txt2) else: return binary_search(lis, l, mid - 1, txt1, txt2) else: ret...
FUNC_DEF IF VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR VAR RETURN BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER RETURN ...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
t = input() p = input() block = [(int(i) - 1) for i in input().split()] ind = {} for i in range(len(block)): ind[block[i]] = i def is_part_and_parcel(s1, s2, mid): n = len(s2) m = len(s1) i = 0 c = 0 j = 0 while i < n and j < m: if ind[j] < mid: j += 1 conti...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
def isValid(t, t1, l, mid): temp = [] for i in range(len(l)): temp.append(t[i]) for i in range(mid): temp[l[i] - 1] = " " m = len(t1) n = len(temp) i = 0 j = 0 while j < m and i < n: if temp[i] == t1[j]: j = j + 1 i = i + 1 if j == m: ...
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBE...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
t = input() p = input() a = list(map(int, input().split())) n = len(a) low = 0 high = n - 1 last = 0 while low <= high: mid = (high + low) // 2 i = 0 j = 0 usable = [False] * n for ai in a[mid:]: usable[ai - 1] = True while i < n and j < len(p): if usable[i] and t[i] == p[j]: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP L...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
from sys import stdin, stdout def ri(): return map(int, input().split()) def subset(S, s): i = 0 j = 0 while i < len(S) and j < len(s): if S[i] == s[j]: i += 1 j += 1 else: i += 1 if j == len(s): return True return False t = list(...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VA...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
import sys def bits(n: int): return list(bin(n)).count("1") def main(test_case=False): n = int(input()) if test_case else 1 for _ in range(n): test() def flush(): sys.stdout.flush() def parr(arr): print(*arr, sep=" ") def gcd(a, b): while b: if b % a == 0: b...
IMPORT FUNC_DEF VAR RETURN FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR VAR STRING FUNC_DEF NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR VAR STRING FUNC_DEF WHILE VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR VAR ASSIGN ...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
def binaryFind(): c = [0] * lenp maxlen = 0 for i in range(0, mid): c[a[i] - 1] = 1 for i in range(0, lenp): if c[i] == 0: if p[i] == t[maxlen]: maxlen += 1 if maxlen == lent: return True return False p = input() t = input() a = list(...
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ...
p = input() t = input() arr = [(int(i) - 1) for i in input().split(" ")] def check(mid): l = list(p) for i in range(mid + 1): l[arr[i]] = " " found = 0 i = 0 while found < len(t) and i < len(arr): if l[i] is t[found]: found += 1 i += 1 return found == len(t)...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF...