description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Given an array arr[] and an integer K where K is smaller than size of array, the task is to find the K^{th} smallest element in the given array. It is given that all array elements are distinct. Note :- l and r denotes the starting and ending index of the array. Example 1: Input: N = 6 arr[] = 7 10 4 3 20 15 K = 3 Out...
class Solution: def kthSmallest(self, arr, l, r, k): l = arr[0] arr.reverse() r = arr[0] arr.sort() asf = arr[k - 1] return asf
CLASS_DEF FUNC_DEF ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER RETURN VAR
Given an array arr[] and an integer K where K is smaller than size of array, the task is to find the K^{th} smallest element in the given array. It is given that all array elements are distinct. Note :- l and r denotes the starting and ending index of the array. Example 1: Input: N = 6 arr[] = 7 10 4 3 20 15 K = 3 Out...
class Solution: def kthSmallest(self, arr, l, r, k): def count_smaller(mid_el, arr): count_sm = 0 for i in arr: if i < mid_el: count_sm += 1 return count_sm l = min(arr) h = max(arr) ans = 0 while l <=...
CLASS_DEF FUNC_DEF FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER A...
Given an array arr[] and an integer K where K is smaller than size of array, the task is to find the K^{th} smallest element in the given array. It is given that all array elements are distinct. Note :- l and r denotes the starting and ending index of the array. Example 1: Input: N = 6 arr[] = 7 10 4 3 20 15 K = 3 Out...
class Solution: def kthSmallest(self, arr, l, r, k): return self.kthSmallestUtil(arr, l, r, k - 1) def partition(self, arr, low, high): pivot_index = random.randint(low, high) arr[pivot_index], arr[high] = arr[high], arr[pivot_index] i = low for j in range(low, high): ...
CLASS_DEF FUNC_DEF RETURN FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR RETURN VAR FUNC_...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
t = int(input()) for i in range(t): d = {} for i in range(12): a, b, c, p, e = map(str, input().split()) b, p = int(b), int(p) if a not in d: d[a] = [0, 0] if e not in d: d[e] = [0, 0] if b > p: d[a][0] += 3 d[a][1] += b - p...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR LIST NUMBER NUMBER IF VAR VAR ASSIGN VAR VAR LIST NUMBER NUMBER ...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
def tableToppers(scoreBoard): sorted_dict = {} sorted_keys = sorted(scoreBoard, key=scoreBoard.get) for w in sorted_keys: sorted_dict[w] = scoreBoard[w] print(list(sorted_dict)[-1], "", list(sorted_dict)[-2]) def updateTeam(scoreBoard, Name, Goals, Conceded): if Name not in scoreBoard.keys...
FUNC_DEF ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR VAR ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER STRING FUNC_CALL VAR VAR NUMBER FUNC_DEF IF VAR FUNC_CALL VAR ASSIGN VAR LIST IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIG...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
for i in range(int(input())): d = dict() for j in range(12): l = input().split() l.remove("vs.") if l[0] in d: if int(l[1]) > int(l[2]): d[l[0]] = d[l[0]][0] + 3, d[l[0]][1] + int(l[1]) - int(l[2]) elif int(l[1]) < int(l[2]): d[l[0]...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP VAR VAR NUMBER NUMBER NUMBER BIN_OP BIN_OP VAR VAR NUMB...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
t = int(input()) for i in range(t): l = [] for j in range(12): y = input() x = y.split() l.append(x) d = {} for j in range(12): if l[j][0] not in d: d[l[j][0]] = 0 else: continue dg = d.copy() for j in range(12): if int(l[j]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER VAR ASSIGN VAR VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
n = int(input()) for i in range(0, n): d = {} d2 = {} for j in range(0, 12): s = input() s = s.split(" ") if int(s[1]) > int(s[3]): if s[0] in d.keys(): d[s[0]] += 3 else: d[s[0]] = 3 if s[0] in d2.keys(): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBE...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
t = int(input()) for _ in range(t): dic = {} for i in range(12): t1, g1, vs, g2, t2 = input().split() g1, g2 = int(g1), int(g2) if g1 > g2: if t1 not in dic: dic[t1] = [3, g1 - g2] else: dic[t1][0] += 3 dic[t1][1] +=...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR VAR ASSIGN VAR VAR LIST NUMBER BIN_OP VAR VAR VAR VAR NUMBER NUMBER VAR VAR NUMBER BIN_OP ...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
for _ in range(int(input())): di = {} for i in range(12): a = input() arr = a.split(" ") if arr[0] not in di: di[arr[0]] = 0 if arr[-1] not in di: di[arr[-1]] = 0 if int(arr[1]) > int(arr[3]): di[arr[0]] += 3000 elif int(arr[1])...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER IF VAR NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR VAR NUMBER NUMBER...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
n = int(input()) for i in range(n): d = {} gd = {} for i in range(12): ar = list(map(str, input().split(" "))) t1 = ar[0] t2 = ar[4] v1 = int(ar[1]) v2 = int(ar[3]) if v1 > v2: if t1 in d: d[t1] += 3 else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF V...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
n = int(input()) for i in range(0, n): d = {} for j in range(0, 12): s = input() s = s.split(" ") if int(s[1]) > int(s[3]): if s[0] in d.keys(): d[s[0]][0] += 3 d[s[0]][1] += int(s[1]) - int(s[3]) else: d[s[0]] = [3,...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER NUMBER NUMBER VAR VAR NUMBER NUMBER BIN_OP ...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
for _ in range(int(input())): xd = {} for _ in range(12): x, xx, _, yy, y = input().split() if x not in xd: xd[x] = [0, 0] if y not in xd: xd[y] = [0, 0] xx, yy = int(xx), int(yy) if xx > yy: xd[x][0] += 3 xd[x][1] += xx - y...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR LIST NUMBER NUMBER IF VAR VAR ASSIGN VAR VAR LIST NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER NUMBER ...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
t = int(input()) while t: t -= 1 pnts, gldif = {}, {} for i in range(12): ls = list(input().split()) nm1, gl1, vs, gl2, nm2 = ls[0], int(ls[1]), ls[2], int(ls[3]), ls[4] if nm1 not in pnts: if gl1 > gl2: pnts[nm1] = 3 elif gl2 > gl1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR DICT DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER IF ...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
for i in range(int(input())): d = {} for j in range(12): str = input() l = str.split() team1 = l[0] team2 = l[4] x = int(l[1]) y = int(l[3]) t1 = [] t2 = [] if team1 not in d.keys(): d[team1] = [0, 0] if team2 not in d.k...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST IF VAR FUNC_CALL VAR ASSIGN...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
t = int(input()) for _ in range(t): dct = {} for i in range(12): lst = list(input().split()) goal_home_team, goal_away_team = int(lst[1]), int(lst[-2]) home_team, away_team = lst[0], lst[-1] points_home_team, points_away_team = 0, 0 if goal_home_team > goal_away_team: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR NUMBER I...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
t = int(input()) for _ in range(t): di = {} for i in range(12): t1, s1, v, s2, t2 = map(str, input().split()) if t1 not in di: di[t1] = [0, 0] if t2 not in di: di[t2] = [0, 0] s1 = int(s1) s2 = int(s2) if s1 > s2: di[t1][0] += 3...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR LIST NUMBER NUMBER IF VAR VAR ASSIGN VAR VAR LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL V...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
t = int(input()) for i in range(t): names = [] scores = [0] * 4 diff = [0] * 4 for j in range(12): name1, goals1, bb, goals2, name2 = input().split() goals1 = int(goals1) goals2 = int(goals2) if name1 not in names: names.append(name1) if name2 not in n...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL V...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
T = int(input()) for _ in range(T): points = {} for i in range(12): l = input().split(" ") scoreA = int(l[1]) scoreB = int(l[3]) if scoreA > scoreB: pointsA, pointsB = 3, 0 elif scoreA < scoreB: pointsA, pointsB = 0, 3 else: poi...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR N...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
for _ in range(int(input())): d = {} for i in range(12): a, b, c, d1, e = map(str, input().split(" ")) if a not in d: d[a] = [0, 0] if e not in d: d[e] = [0, 0] b = int(b) d1 = int(d1) if b > d1: d[a][0] += 3 elif b < d1...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR VAR ASSIGN VAR VAR LIST NUMBER NUMBER IF VAR VAR ASSIGN VAR VAR LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR I...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
test_cases = int(input()) def pointstable(team1detail, team2detail, table): if team1detail[0] not in table: table.append(team1detail[0]) pointtable[team1detail[0]] = [0, 0] else: pass if team2detail[1] not in table: table.append(team2detail[1]) pointtable[team2detai...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER LIST NUMBER NUMBER IF VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER IF...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
for _ in range(int(input())): d = {} for i in range(12): l = [] l = list(map(str, input().split())) if l[0] not in d: d[l[0]] = [0, 0] if l[-1] not in d: d[l[-1]] = [0, 0] if int(l[1]) > int(l[3]): d[l[0]][0] += 3 elif int(l[1])...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR ASSIGN VAR VAR NUMBER LIST NUMBER NUMBER IF VAR NUMBER VAR ASSIGN VAR VAR NUMBER LIST NUMBER NUMBER IF FUNC_CALL VAR VAR NUM...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
t = int(input()) for _ in range(t): matches = [] pt = {} for i in range(12): t1, s1, vs, s2, t2 = input().split() s1 = int(s1) s2 = int(s2) if t1 not in pt: pt[t1] = [0, 0] if t2 not in pt: pt[t2] = [0, 0] if s1 > s2: pt[t1]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR LIST NUMBER NUMBER IF VAR VAR ASSIGN VAR VAR LIST NUMBER NU...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
t = int(input()) for _ in range(t): n = 12 d = {} for _ in range(n): teamA, teamB = input().split(" vs. ") teamA = teamA.split() teamB = teamB.split() if teamA[0] not in d: d.update({teamA[0]: [0, 0]}) if teamB[1] not in d: d.update({teamB[1]: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER VAR EXPR FUNC_CALL VAR DICT VAR NUMBER LIST NUMBER NUMBER IF VAR NUMBER VAR EXPR FUNC...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
for _ in range(int(input())): a = {} for i in range(12): b, c, d, e = input().replace("vs. ", "").split() if b not in a.keys(): a[b] = 0 if e not in a.keys(): a[e] = 0 c = int(c) d = int(d) if c > d: a[b] += 3000 + c - d ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING STRING IF VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER IF VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
T = int(input()) for _ in range(T): D = {} for i in range(12): a, b, e, d, c = map(str, input().split()) if a in D: if int(b) > int(d): D[a][0] += 3 elif int(b) == int(d): D[a][0] += 1 D[a][1] += int(b) - int(d) elif int...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER NUMBER VAR VAR ...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
t = int(input()) while t > 0: tot = [] x = 12 groups = [] score = [(0) for i in range(4)] gd = [(0) for i in range(4)] while x > 0: a = list(map(str, input().split())) t1 = a[0] s1 = a[1] s1 = int(s1) s2 = a[3] s2 = int(s2) t2 = a[4] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
T = int(input()) for _ in range(T): d = {} initial_score = 0 initial_goal = 0 for i in range(12): scoreline = str(input()) score = scoreline.split() if score[0] not in list(d.keys()): d[score[0]] = [initial_score, initial_goal] if score[4] not in list(d.keys()...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER LIST VAR VAR IF VAR NUMBER FUNC_CALL VAR FUNC_...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
for _ in range(int(input())): teams = {} arr = [[0, 0, ""] for _ in range(4)] z = 0 for i in range(12): team1, team1score, x, team2score, team2 = list(input().split()) team1score = int(team1score) team2score = int(team2score) if team1 not in teams: teams[team1...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST NUMBER NUMBER STRING VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR ...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
n = int(input()) for j in range(n): arr = [] s = [] count = 0 d = {} c = {} j = [] for i in range(12): arr = list(input().split()) s.append(arr) a = int(s[i][1]) b = int(s[i][3]) q = [] u = {} s[i][1] = a s[i][3] = b if ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
t = int(input()) while t: ds = {} for i in range(12): ls = input().split(" ") if ls[0] not in ds: ds[ls[0]] = [int(ls[1]), int(ls[3]), 0] else: ds[ls[0]][0] += int(ls[1]) ds[ls[0]][1] += int(ls[3]) if ls[4] not in ds: ds[ls[4]] = [i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER VAR ASSIGN VAR VAR NUMBER LIST FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER NUMBER VAR VAR NUMBER NUMBER FUNC_CALL VAR VAR NUMBER VAR VAR NUMBER NUMBER FUNC_CALL VAR...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
for _ in range(int(input())): d = {} for i in range(12): a, b = map(str, input().split("vs. ")) a = a.split() b = b.split() if a[0] not in d: d[a[0]] = [0, 0] if b[1] not in d: d[b[1]] = [0, 0] diff_a = int(a[1]) - int(b[0]) d[a[0]]...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER VAR ASSIGN VAR VAR NUMBER LIST NUMBER NUMBER IF VAR NUMBER VAR ASSIGN VAR VAR NUMBER LIST NUMBER ...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
T = int(input()) for _ in range(T): fixtures = [] team_names = [] for j in range(12): fixture = input().split() fixtures.append(fixture) team_names.append(fixture[0]) fixt_dict = dict([(name, 0) for name in set(team_names)]) for team in fixt_dict.keys(): total_diff = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN V...
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. The UEFA Champions League is the most prestigious annual sports competition in the world. In the group stage of this competition, European football clubs are divided into 8 groups; there are four teams in each group...
tcase = int(input()) while tcase > 0: pointdict = {} gddict = {} for q in range(12): match = input().split(" vs. ") score = [] team = [] for i in match: for j in i.split(): if j.isdigit(): score.append(int(j)) el...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR FOR VAR FUNC_CALL VAR IF FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR EXPR FUNC_CALL VAR VAR F...
Chef gets confused between mean and median very often, and as a result, he has developed a dislike of arrays whose mean and median are not equal. Chef has an array A of N elements. He can perform the following operation on it: Pick an index 1 ≤ i ≤ N and increase A_{i} by 1. He would like to obtain an array whose mea...
def check_mean_median(arr, n, x): cost_mean = n * x - sum(arr) if cost_mean < 0: return -1 cost_median = 0 for i in range((n - 1) // 2, n): cost_median += max(0, x - arr[i]) if cost_median > cost_mean: return -1 else: return cost_mean def solve(arr, n): arr....
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR IF VAR VAR RETURN NUMBER RETURN VAR FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR BIN_OP BIN_OP VAR NUMBER ...
Chef gets confused between mean and median very often, and as a result, he has developed a dislike of arrays whose mean and median are not equal. Chef has an array A of N elements. He can perform the following operation on it: Pick an index 1 ≤ i ≤ N and increase A_{i} by 1. He would like to obtain an array whose mea...
def snek(a, n, x): c = n * x - sum(a) if c < 0: return -1 c2 = 0 for i in range((n - 1) // 2, n): c2 += max(0, x - a[i]) if c2 > c: return -1 else: return c t = int(input()) for i in range(t): n = int(input()) a = list(map(int, input().split())) a.so...
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR IF VAR VAR RETURN NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR ...
Chef gets confused between mean and median very often, and as a result, he has developed a dislike of arrays whose mean and median are not equal. Chef has an array A of N elements. He can perform the following operation on it: Pick an index 1 ≤ i ≤ N and increase A_{i} by 1. He would like to obtain an array whose mea...
def check(arr, mean, n): sum = 0 for i in range(len(arr)): sum += arr[i] allowed_operations = n * mean - sum if allowed_operations < 0: return -1 required_operations = 0 for i in range((n - 1) // 2, n): required_operations += max(0, mean - arr[i]) if required_operatio...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR IF VAR VAR RETURN NUMBER RETURN VAR FOR VAR FUNC_CALL VA...
Chef gets confused between mean and median very often, and as a result, he has developed a dislike of arrays whose mean and median are not equal. Chef has an array A of N elements. He can perform the following operation on it: Pick an index 1 ≤ i ≤ N and increase A_{i} by 1. He would like to obtain an array whose mea...
for _ in range(int(input())): n = int(input()) A = list(map(int, input().split())) A.sort() s = sum(A) low = A[(n - 1) // 2] high = 10**9 ans = 10**9 while low <= high: k = (low + high) // 2 mean = k * n - s median = 0 for i in range((n - 1) // 2, n): ...
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 EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER WHILE...
Chef gets confused between mean and median very often, and as a result, he has developed a dislike of arrays whose mean and median are not equal. Chef has an array A of N elements. He can perform the following operation on it: Pick an index 1 ≤ i ≤ N and increase A_{i} by 1. He would like to obtain an array whose mea...
def cal(arr, n, med): ind = n // 2 - 1 if n % 2 == 0 else (n + 1) // 2 - 1 c = 0 for i in range(ind, n): if i == ind: c += med - arr[ind] arr[ind] = med elif arr[i - 1] > arr[i]: c += arr[i - 1] - arr[i] arr[i] = arr[i - 1] tot = sum(arr) ...
FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR VAR BIN...
Chef gets confused between mean and median very often, and as a result, he has developed a dislike of arrays whose mean and median are not equal. Chef has an array A of N elements. He can perform the following operation on it: Pick an index 1 ≤ i ≤ N and increase A_{i} by 1. He would like to obtain an array whose mea...
from sys import stdin input = stdin.readline def check(x): ans = 0 for i in range(middle, n): ans += max(0, x - a[i]) if n * x < s + ans: return -1 return n * x - (s + ans) + ans def answer(): s = sum(a) l, h = a[middle], a[-1] while l <= h: mid = (l + h) // 2 ...
ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR IF BIN_OP VAR VAR BIN_OP VAR VAR RETURN NUMBER RETURN BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_O...
Chef gets confused between mean and median very often, and as a result, he has developed a dislike of arrays whose mean and median are not equal. Chef has an array A of N elements. He can perform the following operation on it: Pick an index 1 ≤ i ≤ N and increase A_{i} by 1. He would like to obtain an array whose mea...
for _ in range(int(input())): n = int(input()) a = [int(x) for x in input().split()] a.sort() mod_in = (n - 1) // 2 l = a[mod_in] - 1 r = 10**9 while r - l > 1: cur = (l + r) // 2 meanop = cur * n - sum(a) medianop = 0 for i in range(mod_in, n): me...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP B...
Chef gets confused between mean and median very often, and as a result, he has developed a dislike of arrays whose mean and median are not equal. Chef has an array A of N elements. He can perform the following operation on it: Pick an index 1 ≤ i ≤ N and increase A_{i} by 1. He would like to obtain an array whose mea...
for _ in range(int(input())): n = int(input()) arr = [int(x) for x in input().split(" ")] arr.sort() s = sum(arr) mean = s / n med = arr[(n - 1) // 2] if med == mean: print(0) continue def check(k): meanop = k * n - s medop = 0 for i in range((n -...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER FUNC_DEF ...
Chef gets confused between mean and median very often, and as a result, he has developed a dislike of arrays whose mean and median are not equal. Chef has an array A of N elements. He can perform the following operation on it: Pick an index 1 ≤ i ≤ N and increase A_{i} by 1. He would like to obtain an array whose mea...
def possible(rmd): rs = n * rmd cs = s for j in range(md, n): cs += max(rmd - a[j], 0) if rs < cs: return False, -1 return True, rs - s for i in range(int(input())): n = int(input()) a = list(map(int, input().split())) s = sum(a) a.sort() ans = float("inf") ...
FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER IF VAR VAR RETURN NUMBER NUMBER RETURN NUMBER BIN_OP 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 FUN...
Chef gets confused between mean and median very often, and as a result, he has developed a dislike of arrays whose mean and median are not equal. Chef has an array A of N elements. He can perform the following operation on it: Pick an index 1 ≤ i ≤ N and increase A_{i} by 1. He would like to obtain an array whose mea...
import sys input = sys.stdin.readline def feasible(arr, tar, total): N = len(arr) meanop = N * tar - total medianop = 0 for i in range((N - 1) // 2, N): medianop += max(0, tar - arr[i]) if meanop >= medianop: return meanop return -1 t = int(input()) for case in range(t): ...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR IF VAR VAR RETURN VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR AS...
Chef gets confused between mean and median very often, and as a result, he has developed a dislike of arrays whose mean and median are not equal. Chef has an array A of N elements. He can perform the following operation on it: Pick an index 1 ≤ i ≤ N and increase A_{i} by 1. He would like to obtain an array whose mea...
import sys int1 = lambda x: int(x) - 1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for...
IMPORT ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING VAR ASSIGN VAR FUNC_CALL VAR VAR STRING STRING VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN...
Chef gets confused between mean and median very often, and as a result, he has developed a dislike of arrays whose mean and median are not equal. Chef has an array A of N elements. He can perform the following operation on it: Pick an index 1 ≤ i ≤ N and increase A_{i} by 1. He would like to obtain an array whose mea...
def findMedian(A): return A[(len(A) - 1) // 2] def isX(A, X): summ = 0 for i in range(len(A)): if i < (len(A) - 1) // 2: summ += A[i] else: summ += max(X, A[i]) return summ <= len(A) * X for t in range(int(input())): N = int(input()) A = list(map(int, ...
FUNC_DEF RETURN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR BIN_OP FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR AS...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
n = int(input()) a = list(map(int, input().split())) q = int(input()) qu = list() an = [-1] * n m = 0 for i in range(q): qu.append(tuple(map(int, input().split()))) for i in range(q): k = qu[q - i - 1] if k[0] == 2: m = max(m, k[1]) elif an[k[1] - 1] == -1: an[k[1] - 1] = max(m, k[2]) fo...
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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL V...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
import sys input = sys.stdin.buffer.readline n = int(input()) a = list(map(int, input().split())) answers = [-1] * n last_all_update = [-1, 0] updates = [[1, i + 1, a[i]] for i in range(n)] q = int(input()) for i in range(1, q + 1): updates.append(list(map(int, input().split()))) curr_mx = 0 for i in range(len(upd...
IMPORT ASSIGN 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 BIN_OP LIST NUMBER VAR ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST NUMBER BIN_OP VAR NUMBER VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL ...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
from sys import stdin, stdout class Stree: def __init__(self, f, n, default, init_data): self.ln = 2 ** (n - 1).bit_length() self.data = [default] * (self.ln * 2) self.f = f for i, d in init_data: self.data[self.ln + i] = d for j in range(self.ln - 1, -1, -1): ...
CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP NUMBER FUNC_CALL BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FOR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER F...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
citizensCount, citizens, requestsCount = ( int(input()), [*map(int, input().split())], int(input()), ) operations = [] for _ in range(requestsCount): type, *cmd = map(int, input().split()) operations.append((type, cmd)) wagesChanges = [(-1) for _ in range(citizensCount)] secondTypeMax = -1 for type,...
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FU...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
import sys input = sys.stdin.readline def construct(array, cur_pos, tree, start, end): if start == end: tree[cur_pos] = array[start] else: mid = (start + end) // 2 tree[cur_pos] = max( construct(array, 2 * cur_pos + 1, tree, start, mid), construct(array, 2 * cu...
IMPORT ASSIGN VAR VAR FUNC_DEF IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR VAR FUNC_CALL VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER VAR RETURN VAR VAR FUNC_DEF IF VAR VAR VAR VAR RETUR...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
import sys n = int(input()) a = [int(i) for i in input().split(" ")] lasts = [0] * n q = int(input()) mins = [] trs = [] for i in range(0, q): tr = [int(i) for i in sys.stdin.readline().rstrip().split(" ")] if tr[0] == 1: a[tr[1] - 1] = tr[2] lasts[tr[1] - 1] = i trs.append(tr) ct = 0 for i...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRIN...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
from sys import stdin input = stdin.readline n = int(input()) money = list(map(int, input().split(" "))) m = int(input()) tmp = 0 up = [(0) for i in range(m)] last = [(0) for i in range(n)] for i in range(m): req = list(map(int, input().split(" "))) if req[0] == 2: up[i] = req[1] else: mone...
ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
from sys import stdin input = stdin.readline n = int(input()) a = [int(i) for i in input().split()] q = int(input()) payoff = [0] * q a_receipt = [0] * n for _ in range(q): pay = [int(i) for i in input().split()] if pay[0] == 1: a[pay[1] - 1] = pay[2] a_receipt[pay[1] - 1] = _ else: ...
ASSIGN 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 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 FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER NUMBE...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
from sys import stdin, stdout for _ in range(1): n = int(stdin.readline()) last = [0] * n a = list(map(int, stdin.readline().split())) update = [] qq = int(stdin.readline()) for q in range(qq): pair = list(map(int, stdin.readline().split())) if pair[0] == 2: update +...
FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR 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 LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF ...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
[n] = [int(w) for w in input().split()] a = [int(w) for w in input().split()] [q] = [int(w) for w in input().split()] o = [(x, 0) for x in a] s = [(0) for t in range(q + 1)] for t in range(1, q + 1): c, *xs = [int(w) for w in input().split()] if c == 1: p, x = xs o[p - 1] = x, t else: ...
ASSIGN LIST VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN LIST VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN V...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
from sys import stdin as cin from sys import stdout as cout get = cin.readline end = cout.flush def put(x): cout.write(str(x)) input = cout.readline n = int(get()) ar = list(map(int, get().split())) q = int(get()) p = [] for i in range(q): x = tuple(map(int, get().split())) p.append(x) mod = [0] * n cu...
ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN 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 FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
import sys n = int(sys.stdin.readline()) data = [int(i) for i in sys.stdin.readline().split()] q = int(sys.stdin.readline()) welfare = [0] * (q + 1) tw = [] changes = [(0, 0)] + [(0, a) for a in data] for i in range(1, q + 1): qu = [int(i) for i in sys.stdin.readline().split()] if qu[0] == 1: changes[q...
IMPORT 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 FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER NUMBER NUMBER VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR ...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
n = int(input()) array = list(map(int, input().split())) q = int(input()) d = {i: (0) for i in range(n)} stack = [] for i in range(q): req = list(map(int, input().split())) if req[0] == 2: stack.append((req[1], i)) else: p = req[1] - 1 d[p] = i array[p] = req[2] ans_i = [-1] ...
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 FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER NUMBER E...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
import sys input = sys.stdin.readline n = int(input()) for _ in range(1): arr = list(map(int, input().split())) q = int(input()) ql = [] for iq in range(q): ql += [list(map(int, input().split()))] useful = [] maxi = 0 for i in range(q - 1, -1, -1): if ql[i][0] == 2: ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR VAR LIST FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST A...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
import sys input = sys.stdin.readline n = int(input()) l = list(map(int, input().split())) lUpd = [0] * n q = int(input()) payoff = [-1] * q for query in range(q): qnext = list(map(int, input().split())) if qnext[0] == 1: p = qnext[1] - 1 x = qnext[2] l[p] = x lUpd[p] = query ...
IMPORT ASSIGN 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 BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_C...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
from sys import stdin input = stdin.readline n = int(input()) a = list(map(int, input().split())) input() t = [True] * n x = 0 for inn in stdin.readlines()[::-1]: l = list(map(int, inn.split())) i = l[1] - 1 if len(l) == 3 and t[i]: a[i] = max(l[2], x) t[i] = False elif len(l) == 2: ...
ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER IF FUN...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
n = int(input()) a = [int(X) for X in input().split()] vis = [0] * n c = 0 tt = [] for j in range(int(input())): s = input().split() if s[0] == "1": p, x = map(int, s[1:]) a[p - 1] = x vis[p - 1] = c else: tt.append(int(s[1])) c += 1 for j in range(len(tt) - 2, -1, -1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER STRING ASSIGN VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
from sys import stdin, stdout N = int(input()) arr = [int(x) for x in stdin.readline().split()] Q = int(input()) logg = [0] * Q t = [0] * Q account = [0] * Q m = [0] * Q valid = [1] * Q for i in range(Q): a = [int(x) for x in stdin.readline().split()] if a[0] == 1: account[i] = a[1] t[i] = 1 ...
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 FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CA...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
def main(): n = int(input()) money = list(map(int, input().split())) last_change = [-1] * n dp = [] q = int(input()) second = [] for i in range(q): query = list(map(int, input().split())) if query[0] == 1: dp.append(-1) p, x = query[1], query[2] ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR 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 LIST ASSIGN VAR FUNC_CALL VAR 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 IF VAR ...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
import sys read = sys.stdin.readline n = int(read()) balance = list(map(int, read().split(" "))) n_operations = int(read()) minis = [] next_mini = 0 changed_before = [0] * (len(balance) + 1) for n_op in range(n_operations): operation = list(map(int, read().split(" "))) if operation[0] == 1: x = operati...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
R = lambda: map(int, input().split()) n = int(input()) a = *zip([1] * n, range(1, n + 1), R()), *([*R()] for _ in [0] * int(input())) r = [-1] * n m = 0 for t, p, *x in a[::-1]: if t > 1: m = max(m, p) elif r[p - 1] < 0: r[p - 1] = max(x[0], m) print(*r)
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP LIST NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR LIST FUNC_CALL VAR VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR V...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
n = int(input()) arr = list(map(int, input().rstrip().split())) q = int(input()) events = [] for i in range(q): a = list(map(int, input().rstrip().split())) events.append(a) changes = {} for i in range(q): if events[i][0] == 1: if events[i][1] not in changes.keys(): changes.update({event...
ASSIGN VAR FUNC_CALL VAR 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
import sys input = sys.stdin.readline class SegmentTree: def __init__(self, n): self.size = 1 while self.size < n: self.size *= 2 self.node = [0] * (2 * self.size - 1) def update(self, i, val): i += self.size - 1 self.node[i] = val while i > 0: ...
IMPORT ASSIGN VAR VAR CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER FUNC_DEF VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
R = lambda: map(int, input().split()) n = int(input()) a = list(R()) q = int(input()) p = [] ax = [-1] * n for _ in range(q): p.append(list(R())) temp = 0 for i in range(q - 1, -1, -1): if p[i][0] == 2: temp = max(temp, p[i][1]) elif ax[p[i][1] - 1] == -1: ax[p[i][1] - 1] = max(temp, p[i][2]...
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 FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR F...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
N = int(input()) List = [int(x) for x in input().split()] query = [] q = int(input()) for i in range(q): x = [int(x) for x in input().split()] query.append(x) second = [-1] * q if query[q - 1][0] == 2: second[q - 1] = query[q - 1][1] for i in range(q - 2, -1, -1): if query[i][0] == 2: second[i] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR IF VAR BIN_OP VAR NUMBER NUMB...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
n = int(input()) lis = list(map(int, input().split())) lis = [[0, i] for i in lis] k = int(input()) li = [] m = 0 for i in range(k): li.append(list(map(int, input().split()))) for i in range(k): if len(li[k - i - 1]) == 2: m = max(li[k - i - 1][1], m) elif lis[li[k - i - 1][1] - 1][0] == 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR V...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
n = int(input()) l = [int(i) for i in input().split()] q = int(input()) t = [-1] * n upd = [0] * q for i in range(q): k = [int(x) for x in input().split()] if k[0] == 1: l[k[1] - 1] = k[2] t[k[1] - 1] = i else: upd[i] = k[1] for i in range(q - 2, -1, -1): upd[i] = max(upd[i], upd...
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 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 FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER NUMBER ASSIGN VAR BI...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
from sys import stdin, stdout n = int(stdin.readline()) a = [int(i) for i in stdin.readline().rstrip().split()] marked = [False] * n q = int(stdin.readline()) op = [] for i in range(q): op.append([int(i) for i in stdin.readline().rstrip().split()]) op.reverse() max_so_far = 0 for o in op: if o[0] == 1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR 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 FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIG...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
import sys input = sys.stdin.readline n = int(input()) a = list(map(int, input().split())) qq = int(input()) queries = [list(map(int, input().split())) for _ in range(qq)] queries.reverse() ans = [-1] * n payoff = 0 for q in queries: if q[0] == 1: if ans[q[1] - 1] == -1: ans[q[1] - 1] = max(pay...
IMPORT ASSIGN 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR ...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
import sys in_file = sys.stdin n = int(in_file.readline().strip()) A = list(map(int, in_file.readline().strip().split())) q = int(in_file.readline().strip()) flood = [] last = [(0) for a in A] for i in range(q): t = list(map(int, in_file.readline().strip().split())) if t[0] == 1: A[t[1] - 1] = t[2] ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL 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 FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FU...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
n = int(input()) a = list(map(int, input().split())) m = int(input()) o = [list(map(int, input().split())) for _ in range(m)] b = [0] * m x = 0 for i in range(m - 1, -1, -1): if o[i][0] == 2: x = max(x, o[i][1]) b[i] = x for i in range(n): a[i] = max(a[i], b[0]) for i in range(m): if o[i][0] == ...
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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR N...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
n = int(input()) balance = list(map(int, input().split())) q = int(input()) log = [list(map(int, input().split())) for i in range(q)] ind_of_last_operation = [None] * n max_pay = 0 ind_of_max_payment = None payments = [] payments_id = [] for i in range(q): if log[i][0] == 1: ind_of_last_operation[log[i][1] ...
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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR NUMBER ASSIGN VAR NONE ASSIGN VAR LIST ASSI...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
import sys input = sys.stdin.readline for nt in range(1): n = int(input()) l = list(map(int, input().split())) q = int(input()) last = {} maxx = [0] * q t2 = [] for i in range(q): temp = list(map(int, input().split())) if temp[0] == 1: last[temp[1]] = temp[2], i ...
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL 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 FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CA...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
import sys input = sys.stdin.readline n = int(input()) li = list(map(int, input().split())) check = [-1] * n maxx = 0 for i in [input().split() for i in range(int(input()))][::-1]: if i[0] == "2": maxx = max(maxx, int(i[1])) elif check[int(i[1]) - 1] == -1: check[int(i[1]) - 1] = max(int(i[2]),...
IMPORT ASSIGN 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 BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
import sys in_file = sys.stdin n = int(in_file.readline().strip()) a = list(map(int, in_file.readline().strip().split())) q = int(in_file.readline().strip()) ls = [list(map(int, in_file.readline().strip().split())) for _ in range(q)] mxs = [-1] * q mxs[-1] = ls[-1][1] if ls[-1][0] == 2 else -1 for i in range(q - 2, -1...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST N...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
iYdqL = int iYdqt = input iYdqI = list iYdqK = map iYdqp = range iYdqb = len iYdqc = reversed iYdqx = max iYdqr = print n = iYdqL(iYdqt()) a = iYdqI(iYdqK(iYdqL, iYdqt().split())) q = iYdqL(iYdqt()) s = [(0) for i in iYdqp(iYdqb(a))] f = [(0) for i in iYdqp(q)] for i in iYdqp(q): r = iYdqI(iYdqK(iYdqL, iYdqt().spli...
ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN 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 FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
import sys input = sys.stdin.buffer.readline def solution(): n = int(input()) l = list(map(int, input().split())) m = -1 a = [-1] * n q = [] for _ in range(int(input())): t = list(map(int, input().split())) q.append(t) for t in q[::-1]: if t[0] == 1 and a[t[1] - 1]...
IMPORT ASSIGN VAR VAR FUNC_DEF 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 BIN_OP LIST NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VA...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
import sys input = sys.stdin.readline I = lambda: list(map(int, input().split())) (n,) = I() l = I() (q,) = I() ar = [-1] * n tm = 0 qr = [] for i in range(q): qr.append(I()) for i in range(q - 1, -1, -1): r = qr[i] if r[0] == 1: if ar[r[1] - 1] == -1: ar[r[1] - 1] = max(r[2], tm) e...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP ...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
n = int(input()) a = list(map(int, input().split())) q = int(input()) changes = [0] * q for i in range(q): changes[-i - 1] = tuple(map(int, input().split())) final = [-1] * n curr = 0 for guy in changes: if guy[0] == 1: if final[guy[1] - 1] == -1: final[guy[1] - 1] = max(guy[2], curr) el...
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 FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER ...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
import sys input = sys.stdin.readline prnt = sys.stdout.write n = int(input()) a = list(map(int, input().split())) q = int(input()) ls = [] last = [-1] * n for i in range(q): x = list(map(int, input().split())) ls.append(x) if x[0] == 1: last[x[1] - 1] = i mxsf = [-1] * (q + 1) for i in range(q - 1...
IMPORT ASSIGN VAR VAR ASSIGN 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 FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
n = int(input().strip()) a = list(map(int, input().split())) q = int(input().strip()) queries = [] last_balance = [-1] * n last_balance_id = [-1] * n for i in range(q): query = list(map(int, input().split())) queries.append(query) if query[0] == 1: p = query[1] - 1 last_balance[p] = query[2]...
ASSIGN VAR FUNC_CALL 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 FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FU...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
n = int(input()) a = list(map(int, input().split())) q = int(input()) last = [(0) for i in range(n + 1)] ubah = [(0) for i in range(q + 1)] for i in range(1, q + 1): k = input().split() if k[0] == "1": p = int(k[1]) x = int(k[2]) a[p - 1] = x last[p - 1] = i else: x =...
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 FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
import sys input = sys.stdin.readline n = int(input()) a = list(map(int, input().split())) q = int(input()) a2 = [-1] * len(a) arr = [None] * q pay = [-1] * q for i in range(q): b = input().split() if len(b) == 2: pay[i] = int(b[1]) else: arr[i] = int(b[1]) a2[arr[i] - 1] = int(b[2]...
IMPORT ASSIGN 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 FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FU...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
n = int(input()) a = [[int(q), 0] for q in input().split()] k = int(input()) was, changes = 0, [] for _ in range(k): s = list(map(int, input().split())) if s[0] == 1: a[s[1] - 1] = [s[2], was] else: changes.append(s[1]) was += 1 max1 = [-1] for q in range(len(changes) - 1, -1, -1): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUM...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
n = int(input()) init = [-1] + [int(x) for x in input().split()] Q = [tuple(map(int, input().split())) for q in range(int(input()))] p = [-1] * (n + 1) qmax = 0 for i in range(1, len(Q) + 1): q1 = Q[-i] if q1[0] == 2: qmax = max(qmax, q1[1]) elif p[q1[1]] == -1: p[q1[1]] = max(qmax, q1[2]) f...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR 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 FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMB...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
import sys n = int(sys.stdin.readline()) a = list(map(int, sys.stdin.readline().split())) q = int(sys.stdin.readline()) qu = [tuple(map(int, sys.stdin.readline().split())) for _ in range(q)] an = [-1] * n m = 0 for i in range(q): query = qu[q - i - 1] if query[0] == 2: m = max(m, query[1]) elif an[...
IMPORT 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR A...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
from sys import stdin inp = stdin.readline n = int(inp()) a = list(map(int, inp().split())) q = int(inp()) cur_max = 0 max_after_query = [0] * q queries = [] for i in range(q): op = list(map(int, inp().split())) queries.append(op) for i in range(q - 1, -1, -1): if queries[i][0] == 2 and cur_max < queries[i...
ASSIGN 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 FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
INF = 10**12 n = int(input()) a = [int(item) for item in input().split()] min_recipt = [INF] * n q = int(input()) max_payoff = 0 query = [] for i in range(q): query.append([int(item) for item in input().split()]) ans = [-1] * n for que in query[::-1]: if que[0] == 1: if ans[que[1] - 1] != -1: ...
ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL V...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
n = int(input()) a = list(map(int, input().split())) q = int(input()) r1 = [-1] * q r2 = [-1] * q for i in range(q): ne = list(map(int, input().split())) if ne[0] == 1: p = ne[1] - 1 t = ne[2] r1[i] = [p, t] else: r2[i] = ne[1] b = -1 for i in range(q - 1, -1, -1): b = ma...
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 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
import sys input = sys.stdin.readline n = int(input()) A = list(map(int, input().split())) q = int(input()) query = [(list(map(int, input().split())) + [i]) for i in range(q)] q1 = [] q2 = [0] * q for qu in query: if qu[0] == 1: q1.append(qu[1:]) else: q2[qu[-1]] = qu[1] MAXQ = [0] * q MAXQ[q -...
IMPORT ASSIGN 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 FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VA...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
import sys sys.setrecursionlimit(10**5 + 1) inf = int(10**20) max_val = inf min_val = -inf RW = lambda: sys.stdin.readline().strip() RI = lambda: int(RW()) RMI = lambda: [int(x) for x in sys.stdin.readline().strip().split()] RWI = lambda: [x for x in sys.stdin.readline().strip().split()] nb = RI() have = RMI() nb_ops ...
IMPORT EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL FUN...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
n = int(input()) a = list(map(int, input().split())) last_updated = [(0) for _ in range(n)] q = int(input()) pay_days = [(0) for _ in range(q)] for i in range(q): qu = list(map(int, input().split())) if qu[0] == 1: _, p, x = qu a[p - 1] = x last_updated[p - 1] = i else: _, x ...
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 VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
n = int(input()) money = list(map(int, input().split())) q = int(input()) tranzactions = list(list(map(int, input().split())) for _ in range(q)) result = [-1] * n temp = -1 for i in range(q - 1, -1, -1): if tranzactions[i][0] == 1: if result[tranzactions[i][1] - 1] == -1: result[tranzactions[i][...
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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VA...
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have. Sometimes the g...
import sys class DWelfareState: def solve(self): n = int(input()) a = [int(_) for _ in input().split()] q = int(input()) queries = [] v = [[-1, a[i]] for i in range(n)] x_max = [-float("inf")] * (q + 1) for qi in range(q): query = [int(_) for _ ...
IMPORT CLASS_DEF FUNC_DEF 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 FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST NUMBER VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST FUNC_CALL VAR STRING BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR AS...