description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = map(int, input().split()) friends = [tuple(map(int, input().split())) for i in range(n)] friends = sorted(friends, key=lambda f: f[0]) sums = [] curr = 0 for i in range(n): curr += friends[i][1] sums.append(curr) res = 0 for i in range(n): low = i high = n - 1 curr = friends[i][0] while l...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_C...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, m = [int(i) for i in input().split(" ")] cost = [] f_factor = [] for i in range(n): s = input().split(" ") cost.append(int(s[0])) f_factor.append(int(s[1])) sorted_map = sorted(zip(cost, f_factor)) cost = [x for x, y in sorted_map] f_factor = [y for x, y in sorted_map] maxans = 0 cumSum = [f_factor[0]] f...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VA...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
import itertools def read_data(): n, d = map(int, input().split()) MSs = [] for i in range(n): m, s = map(int, input().split()) MSs.append((m, s)) return n, d, MSs def solve(n, d, MSs): if n == 1: return MSs[0][1] MSs.sort() Ms = [m for m, s in MSs] Ss = [s fo...
IMPORT FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR RETURN VAR VAR VAR FUNC_DEF IF VAR NUMBER RETURN VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN V...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
def sf(a): return -a[0] inp = input().split() n = int(inp[0]) d = int(inp[1]) arr = [] for i in range(0, n): dat = [int(x) for x in input().split()] arr.append(dat) arr.sort(key=sf) l = r = 0 summ = arr[0][1] ans = arr[0][1] while r < n - 1: if arr[l][0] - arr[r + 1][0] < d: summ += arr[r + 1]...
FUNC_DEF RETURN VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR V...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, k = map(int, input().split()) l = [] for i in range(n): l.append(list(map(int, input().split()))) l.sort() su = l[0][1] ma = 0 first, last = 0, 1 while first < n and last < n: if l[last][0] - l[first][0] >= k: if su > ma: ma = su su -= l[first][1] first += 1 else: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR VAR VAR IF BIN_OP VAR VAR NUMBER VAR ...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
from sys import stdin stdin.readline def mp(): return list(map(int, stdin.readline().strip().split())) def it(): return int(stdin.readline().strip()) n, d = mp() v = [] for _ in range(n): v += [mp()] v.sort() ans = v[0][1] ma = 0 f, l = 0, 1 while f < n and l < n: if abs(v[l][0] - v[f][0]) >= d: ...
EXPR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR VAR LIST FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = list(map(int, input().split())) persons = [] for i in range(n): m, s = list(map(int, input().split())) persons.append((m, s)) persons.sort() max_s = 0 cur_s = persons[0][1] good_persons = [persons[0]] for i in range(1, n): if abs(good_persons[0][0] - persons[i][0]) < d: good_persons.append(pe...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CAL...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
firstLine = input().split(" ") noOfFriends = int(firstLine[0]) diff = int(firstLine[1]) friends = [] for index in range(noOfFriends): desc = input().split(" ") friends.append((int(desc[0]), int(desc[1]))) friends.sort() left = 0 right = 1 maxFriendship = friends[0][1] friendship = friends[0][1] while right <= n...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBE...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = list(map(int, input().split())) friends = [] max_friendship = 0 tmp_index = 0 tmp_friendship = 0 for k in range(n): m, s = list(map(int, input().split())) friends.append({"m": m, "s": s}) friends = sorted(friends, key=lambda x: x["m"]) k = 0 while k < n: if abs(friends[tmp_index]["m"] - friends[k]["m...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR DICT STRING STRING VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR STR...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
def key_sort(x): return x[0] v = [] n, d = input().split() n = int(n) d = int(d) for i in range(n): x = input().split() v.append([int(x[0]), int(x[1])]) v.sort(key=key_sort) i = j = s = m = 0 while i < n and j < n: if v[j][0] - v[i][0] >= d: s -= v[i][1] i += 1 else: s += v...
FUNC_DEF RETURN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = map(int, input().split()) mat = [] for i in range(n): m, s = map(int, input().split()) mat.append([m, s]) mat.sort(key=lambda x: x[0]) dp = [0] * (n + 1) for i in range(1, n + 1): dp[i] = dp[i - 1] + mat[i - 1][1] ans = mat[0][1] i = 0 j = 0 while i < n and j < n: if mat[j][0] - mat[i][0] < d: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL 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 LIST VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN ...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = map(int, input().split()) v = sorted([list(map(int, input().split())) for i in range(n)], key=lambda x: x[0]) sum = v[0][1] sol = v[0][1] b = 0 for i in range(1, n): while v[i][0] >= d + v[b][0]: sum -= v[b][1] b += 1 sum += v[i][1] sol = max(sum, sol) print(sol)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL 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 VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR WHILE VAR VAR NUMBER BIN_OP VAR VAR VAR ...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
class MaximumFriendshipWithinMoneyRangeProblem: def __init__(self): self.numFriends, self.moneyRange, self.friends = self.getInput() self.solution = self.computeMaximumFriendshipWithinMoneyRange() def getInput(self): numFriends, moneyDistance = map(int, input().split()) friends...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN VAR VAR VAR FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIG...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
def main(): n, d = map(int, input().split()) l = sorted(tuple(map(int, input().split())) for _ in range(n)) lo, res = l[0][0], [] i = j = ss = 0 while True: for j in range(j, n): hi, s = l[j] if hi - lo >= d: res.append(ss) break ...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL 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 VAR VAR NUMBER NUMBER LIST ASSIGN VAR VAR VAR NUMBER WHILE NUMBER FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR IF BIN_OP VAR VAR VAR...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = input().split() n, d = int(n), int(d) l = [] for _ in range(n): x = input().split() l.append((int(x[0]), int(x[1]))) def key(pair): return pair[0] l.sort(key=key) i = 0 j = 0 sum = 0 max = 0 while i < n and j < n: if l[j][0] - l[i][0] >= d: sum -= l[i][1] i -= -1 else: ...
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBE...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
first_line = input().split() n = int(first_line[0]) d = int(first_line[1]) friends = [[0, 0] for i in range(n)] for i in range(n): a_friend = input().split() friends[i][0] = int(a_friend[0]) friends[i][1] = int(a_friend[1]) friends = sorted(friends) left = 0 right = 0 result = 0 addition = 0 while left < n ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = map(int, input().split()) lis1 = [] for i in range(n): m, f = map(int, input().split()) lis1.append([m, f]) lis1.sort() ans = [] for i in range(1, len(lis1)): lis1[i][1] += lis1[i - 1][1] for i in range(len(lis1)): lo, hi = i + 1, len(lis1) - 1 idx = i while lo <= hi: mid = lo + (...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL 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 LIST VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER FOR VA...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
entrada = list(map(int, input().split(" "))) lista = [] friendship = 0 p = 1 for i in range(entrada[0]): temp = list(map(int, input().split())) lista.append((temp[0], temp[1])) lista.sort() lista2 = [0] for i in range(1, entrada[0] + 1): lista2.append(lista2[i - 1] + lista[i - 1][1]) for i in range(entrada[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUN...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = map(int, input().split()) t = [] for i in range(n): x, y = map(int, input().split()) t += [(x, y)] t = sorted(t, key=lambda colonnes: colonnes[0]) i = 0 j = 1 q, r = t[0] vTemp = r rTemp = r qtemp = q v = vTemp while j < n: x, y = t[j] if x >= q + d: vTemp -= rTemp i += 1 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR LIST VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
from sys import stdin def solve(people, d): ls = sorted(people, key=lambda p: p[0]) ans = ls[0][1] acc = 0 last = -1 for idx, (m, s) in enumerate(ls): while last >= 0 and idx - last > 0 and m - ls[last][0] >= d: acc -= ls[last][1] last += 1 acc += s ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR WHILE VAR NUMBER BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER VAR VAR IF VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUN...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
def binarySearch(aList, target, low, high): while low <= high: mid = (low + high) // 2 if aList[mid][0] > target: high = mid - 1 else: low = mid + 1 return low - 1 nd = input().split() nd = [int(i) for i in nd] data = [] for i in range(nd[0]): line = input()...
FUNC_DEF WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL ...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = map(int, input().split()) a = [] for i in range(n): x, y = map(int, input().split()) a += [(x, y)] a.sort(key=lambda x: x[0]) i = 0 j = 0 ans = -1 res = 0 for i in range(n): ans = max(ans, a[i][1]) i = 0 while j < n: sm = a[i][0] while j < n and a[j][0] - sm < d: res += a[j][1] ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CAL...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
def sol(a, n, d): i, j, ans, tmpans = 0, 0, 0, 0 while j < n: if a[j][0] - a[i][0] < d: tmpans += a[j][1] j += 1 else: ans = max(ans, tmpans) while a[j][0] - a[i][0] >= d: tmpans -= a[i][1] i += 1 ans = max(ans, ...
FUNC_DEF ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER WHILE VAR VAR IF BIN_OP VAR VAR NUMBER VAR VAR NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR WHILE BIN_OP VAR VAR NUMBER VAR VAR NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUN...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, poorAmount = list(map(int, input().split(" "))) everythingList = [] moneyList = [] friendshipFactorList = [] for _ in range(n): money, friendshipFactor = list(map(int, input().split(" "))) everythingList.append((money, friendshipFactor)) everythingList.sort(key=lambda x: x[0]) i = 0 j = 0 endingSequence = Fa...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMB...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
def solve(): n, d = map(int, input().split()) friends = [list(map(int, input().split())) for _ in range(n)] friends = sorted(friends, key=lambda f: f[0]) friendship = 0 max_friendship = friendship i = 0 for j in range(n): friendship += friends[j][1] while friends[j][0] - frie...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER WHILE BIN_OP VAR VAR NUMBER V...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = map(int, input().split(" ")) sum1 = 0 maximum = -1 a = [] arr = [] arr.append(0) for x in range(n): a.append(list(map(int, input().split(" ")))) a.sort() for x in range(n): sum1 += a[x][1] arr.append(sum1) y = 0 for x in range(n): while y < n and a[y][0] - a[x][0] < d: y += 1 maximum ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR VAR V...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
line = input().split() n = int(line[0]) d = int(line[1]) friends = list() for i in range(n): line = input().split() friends.append([int(line[0]), int(line[1])]) friends.sort() sum = friends[0][1] sum_max = sum baza = friends[0][0] i = 1 j = 0 while i < len(friends) and j < len(friends): if friends[i][0] - f...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIG...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
from sys import stdin stdin.readline def mp(): return list(map(int, stdin.readline().strip().split())) def it(): return int(stdin.readline().strip()) v = [] n, d = mp() for i in range(n): a, b = mp() v += [[a, b]] v.sort() ma = 0 ans = v[0][1] i, j = 0, 1 while i < n and j < n: if abs(v[j][0]...
EXPR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR LIST LIST VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR N...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
def solve(inp, d): inp = sorted(inp, key=lambda x: x[0]) p1 = 0 p2 = 0 n = len(inp) maxfnd = 0 max1 = maxfnd while p2 < n: if inp[p2][0] - inp[p1][0] < d: maxfnd += inp[p2][1] p2 += 1 else: maxfnd -= inp[p1][1] p1 += 1 m...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR IF BIN_OP VAR VAR NUMBER VAR VAR NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR ...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = [int(i) for i in input().split(" ")] friends = [[int(i) for i in input().split(" ")] for _ in range(n)] friends.sort(key=lambda x: x[0]) first = 0 last = 0 max_friendship = 0 friendship = 0 while last < n: while first <= last and friends[last][0] - friends[first][0] >= d: friendship -= friends[first]...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR WHILE VAR VAR BIN_OP VAR VAR NUMBER VAR VAR NUMBER...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = map(int, input().split()) info = [] for cases in range(n): a, b = map(int, input().split()) info.append([]) info[cases].append(a) info[cases].append(b) info = sorted(info) l = 0 r = 0 maxn = -1 sum = info[0][1] while r < n: if info[r][0] - info[l][0] < d and maxn < sum: maxn = sum ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL 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 LIST EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASS...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = map(int, input().split()) line = list() for i in range(n): line.append(list(map(int, input().split()))) line.sort(key=lambda a: a[0]) refer = list() note = line[0][0] flag_a = flag_b = False flag_v = 0 for i in range(n - 1): if flag_a: if flag_v - line[i][0] >= d: continue els...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, k = [int(i) for i in input().split()] arr = [] for i in range(n): s = [int(i) for i in input().split()] arr.append(s) lst = [] arr.sort() v = arr[0][1] j = 1 for i in range(len(arr)): if j == n: break while abs(arr[i][0] - arr[j][0]) < k: v += arr[j][1] j += 1 if j > n...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR WHIL...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = map(int, input().split()) al = [list(map(int, input().split())) for _ in range(n)] al.sort() res = al[0][1] t = al[0][1] idx = 0 for i in range(1, n): if al[i][0] - al[idx][0] < d: t += al[i][1] else: while al[i][0] - al[idx][0] >= d: t -= al[idx][1] idx += 1 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR NUMBER VAR VAR NUMBER VAR VA...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = tuple(map(int, input().split())) m, s = [0] * n, [0] * n ms = [0] * n for i in range(n): m[i], s[i] = tuple(map(int, input().split())) ms[i] = m[i], s[i] suffix = [0] * n postfix = [0] * n alsum = sum(s) ms.sort() for i in range(1, n): postfix[i] = postfix[i - 1] + ms[i - 1][1] for i in range(n - 2, ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP ...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
num_friends, poor = [int(i) for i in input().split()] party = [] for x in range(num_friends): temp_array = [0, 0] temp_array[0], temp_array[1] = [int(y) for y in input().split()] party.append(temp_array) party.sort() answer = party[0][1] if len(party) == 1: print(answer) exit() y = 0 temp_answer = 0...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CAL...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
def get_max_friendship_factor(friends, min_money_dif): friends.sort() max_friendship_factor = 0 right = 0 friendship_factor = 0 for left in range(0, len(friends)): while ( right < len(friends) and abs(friends[left][0] - friends[right][0]) < min_money_dif ): ...
FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR WHILE VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR VAR NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = map(int, input().split()) money = [] dic = {} for _ in range(n): m, s = map(int, input().split()) money.append(m) if m in dic: dic[m].append(s) else: dic[m] = [s] money.sort() f = [] money1 = sorted(list(set(money))) for i in money1: for j in dic[i]: f.append(j) money ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR LIST VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUN...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
debug = lambda *args: args def search(lo, hi, frds, t): while lo < hi: mid = lo + int((hi - lo + 1) / 2) if frds[mid][0] <= t: lo = mid else: hi = mid - 1 return lo n, d = [int(x) for x in input().split(" ")] frds = [] z = {} for i in range(n): p = [int(x)...
ASSIGN VAR VAR FUNC_DEF WHILE VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF VAR VAR NUMBER VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = map(int, input().split()) a = [tuple(map(int, input().split())) for i in range(n)] a.sort(reverse=True) sums = [0] * n sums[0] = a[0][1] for i in range(1, n): sums[i] = sums[i - 1] + a[i][1] maxsum = 0 r = 0 for l in range(n): if r < l: r = l while r < n and -a[r][0] + a[l][0] < d: r ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER V...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
a = [] n, d = [int(x) for x in input().split()] for i in range(n): x, y = [int(x) for x in input().split()] a.append((x, y)) a = sorted(a) b = [0] for i in range(n): b.append(a[i][1] + b[i]) max = 0 for i in range(n): left = i right = n while right - left > 1: medium = (left + right) // ...
ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR VAR AS...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = input().strip().split() n = int(n) d = int(d) a = [[] for i in range(n)] for i in range(n): t1, t2 = input().strip().split() a[i].append(int(t1)) a[i].append(int(t2)) a.sort() i = 0 j = 0 s = 0 ans = 0 while i < n: if a[j][0] - a[i][0] < d: if j < n - 1: s += a[j][1] ...
ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
import sys def binsearch(friends, start, end, d): low = start mid = 0 high = end cost = 0 flag = 0 while low <= high: mid = (low + high) // 2 if friends[mid][0] - friends[start][0] >= d: high = mid - 1 elif mid == end or friends[mid + 1][0] - friends[start][...
IMPORT FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBE...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, m = tuple(int(x) for x in input().split()) v = [] for i in range(n): i = input() v.append(tuple(int(x) for x in i.split())) v.sort(reverse=True) maxi = val = v[0][1] i = j = 0 for j in range(1, len(v)): val += v[j][1] while abs(v[j][0] - v[i][0]) >= m: val -= v[i][1] i += 1 if val...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, diff = map(int, input().split()) a = sorted([tuple(map(int, input().split())) for _ in range(n)]) left = right = 0 ret = 0 s = 0 while right < n: while right < n and a[right][0] - a[left][0] < diff: s += a[right][1] right += 1 ret = max(ret, s) if right == n: break s += a[righ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL 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 VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR WHILE VAR VAR BIN_OP VAR VAR NUMBER VAR VAR NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER ASS...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = map(int, input().split()) friends = [list(map(int, input().split())) for _ in range(n)] friends.sort() s = [friends[0][1]] for i in range(1, n): s.append(s[i - 1] + friends[i][1]) mx = 0 for i in range(n): low = i + 1 high = n while low < high: mid = low + (high - low) // 2 if fri...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = [int(i) for i in input().split()] frendo = [[0, 0]] for i in range(n): xs = [int(x) for x in input().split()][:2] frendo.append(xs) def cmp(xs): return xs[0] frendo.sort(key=cmp) j = 0 suma = rez = 0 diff = 0 for i in range(1, n + 1): suma += frendo[i][1] frendo[i][1] = suma for i in rang...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_DEF RETURN VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = (int(x) for x in input().split()) ms = [] for _ in range(n): ms.append(tuple(int(x) for x in input().split())) ms.sort() ans = 0 start, end, ssum = 0, 0, 0 while end < n: end += 1 ssum += ms[end - 1][1] while start < end and ms[end - 1][0] >= ms[start][0] + d: ssum -= ms[start][1] ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER WHILE VAR VAR VAR NUMBER VAR VAR BIN_OP VAR NUMBER NUMBER WHI...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = [int(x) for x in input().split()] ms = [] for i in range(n): msi = [int(x) for x in input().split()] ms.append(msi) ms = sorted(ms) l, u = 0, 0 for i in range(n): if ms[i][0] - ms[0][0] >= d: u = i - 1 break if ms[n - 1][0] - ms[0][0] < d: u = n - 1 psum = [ms[0][1]] * n for i in ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER NUMBER VAR ASSIGN...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
from sys import stdin n, k = map(int, stdin.readline().rstrip().split(" ")) li = [0] * n for i in range(n): li[i] = list(map(int, stdin.readline().rstrip().split(" "))) li.sort() start = end = j = 0 t = 0 ma = 0 for i in range(0, n): t += li[i][1] end = i while li[end][0] - li[start][0] >= k: t...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
firstLineInput = input() firstLineInput = firstLineInput.split(" ") repetition = int(firstLineInput[0]) dick = int(firstLineInput[1]) friendship = [] i = 0 while i != repetition: friendInput = input() friendInput = friendInput.split(" ") friendship.append([int(friendInput[0]), int(friendInput[1])]) i +=...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR LIST FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER E...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
def answer(n, d, A): A.sort(key=lambda x: x[0]) pre = [0] * (n + 1) for i in range(1, n + 1): pre[i] = pre[i - 1] + A[i - 1][1] l = 0 r = 0 maxi = 0 while r >= l and r < n: if A[r][0] - A[l][0] < d: r += 1 else: maxi = max(maxi, pre[r] - pre[l]...
FUNC_DEF EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF BIN_OP VAR VAR NUMBER VAR VAR NUMB...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = [int(i) for i in input().split()] l = [] c = {} for i in range(n): m, s = [int(i) for i in input().split()] if not l: l.append(m) c[m] = s continue for j in range(len(l)): flag = False if m + d <= l[j] or m - d >= l[j]: pass else: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR VAR VAR VAR BIN_OP ...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = [int(x) for x in input().rstrip().split(" ")] friends = [] for i in range(n): friends.append([int(x) for x in input().rstrip().split(" ")]) friends.sort(key=lambda x: x[0]) s_max = friends[0][1] i_begin = 0 i_end = 1 s_curr = s_max while i_end < n: d_max = friends[i_begin][0] + d while i_end < n and ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING 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 STRING EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VA...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
def getInts(): return [int(s) for s in input().split()] def getInt(): return int(input()) def getStrs(): return [s for s in input().split()] def getStr(): return input() def listStr(): return list(input()) def solve(): N, D = getInts() friends = [] prefix_sums = [] curr_sum...
FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR ...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
scan = lambda: map(int, input().split()) n, d = scan() arr = [] for i in range(n): m, r = scan() arr.append([m, r]) arr.sort() p1, p2 = 0, 1 tmp = arr[0][1] ans = tmp while p1 < n: while p2 < n and arr[p2][0] - arr[p1][0] < d: tmp += arr[p2][1] p2 += 1 ans = max(tmp, ans) tmp -= arr[...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR WHILE VAR VAR WHILE VAR VAR BIN_OP VAR VAR ...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
import time n, d = (int(i) for i in input().split()) ms = {} for i in range(n): m, s = (int(i) for i in input().split()) if m in ms.keys(): ms[m] += s else: ms[m] = s start = time.time() l = sorted(ms.keys()) ans = 0 j = 0 while j < len(l) and l[j] - l[0] < d: ans += ms[l[j]] j += 1...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMB...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
def merge(arr, l, m, r): n1 = m - l + 1 n2 = r - m L = [0] * n1 R = [0] * n2 for i in range(n1): L[i] = arr[l + i] for j in range(n2): R[j] = arr[m + 1 + j] i = 0 j = 0 k = l while i < n1 and j < n2: if L[i][0] >= R[j][0]: arr[k] = R[j] ...
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR 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 BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN ...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
l = input() l = l.split() n = int(l[0]) d = int(l[1]) lst = [] for i in range(n): l = input() l = l.split() lst.append((int(l[0]), int(l[1]))) lst.sort(key=lambda x: x[0]) sum, maxim, start, fin = 0, 0, 0, 0 while fin < n: while fin < n and lst[fin][0] - lst[start][0] + 1 <= d: sum += lst[fin][1...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN ...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
def ans(f, n, d): if n == 1: return f[0][1] ans = f[0][1] tmp_ans = f[0][1] i = 0 j = 1 while j < n: if i == j: tmp_ans = f[j][1] j += 1 if tmp_ans > ans: ans = tmp_ans elif abs(f[i][0] - f[j][0]) < d: tmp_an...
FUNC_DEF IF VAR NUMBER RETURN VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR VAR NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER IF...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
import sys n, d = map(int, input().split()) a = [] for i in range(n): x = list(map(int, sys.stdin.readline().split())) a.append(x) a.sort() i = 0 mx = 0 x = a[i][0] s = a[i][1] j = 1 while j != n: if a[j][0] - x < d: s += a[j][1] mx = max(s, mx) j += 1 else: mx = max(s, ...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = map(int, input().split()) friends = [] for i in range(n): m, s = map(int, input().split()) friends.append([m, s]) max_f = 0 friends.sort(key=lambda x: x[0]) i = 0 j = 0 f = 0 while i < n: while j < n: diff = friends[j][0] - friends[i][0] if diff < d: f += friends[j][1] ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL 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 LIST VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR WHILE VAR VAR AS...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, k = map(int, input().split()) f, v = [], [] d = {} for _ in range(n): a, b = map(int, input().split()) if a in d: temp = d[a] temp.append(b) else: d[a] = [b] for i in sorted(d): v.extend([i] * len(d[i])) f.extend(sorted(d[i])) start, end = 0, 1 m = max(f) pre, temp = [], 0...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR LIST VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP LIST VAR F...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = map(int, input().split(" ")) mymap = dict() v = [] t = [] for i in range(n): p, q = map(int, input().split(" ")) if mymap.get(p, -1) == -1: v.append(p) t.append(int(0)) mymap[p] = q + mymap.get(p, int(0)) v.sort() sum = 0 en = int(0) for i in range(len(v)): if i != 0: t[i]...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR ...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, k = map(int, input().split()) l = [list(map(int, input().split())) for i in range(n)] l.sort(key=lambda x: x[0]) val = l[0][0] i = 0 j = i + 1 ans = 0 temp = l[i][1] while j < n and l[j][0] - l[i][0] < k: temp += l[j][1] j += 1 ans = max(ans, temp) while j < n: if j < n and i < n and l[j][0] - l[i][0] < ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER WHILE VAR VAR BIN_OP VAR...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = [int(x) for x in input().split()] prieteni = [] for i in range(n): pr = [int(x) for x in input().split()] prieteni += [pr] prieteni.sort(key=lambda x: x[0]) l = 0 r = 0 final = prieteni[l][1] max = 0 while r < n: if l == r: final = prieteni[l][1] r += 1 if r == n: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR LIST VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR ASSIGN VAR V...
Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend t...
n, d = map(int, input().split()) counter = 0 maximum = 0 total = 0 list = sorted([list(map(int, input().split())) for x in range(n)]) for i in range(n): while counter < n and list[counter][0] - list[i][0] < d: total += list[counter][1] counter += 1 maximum = max(maximum, total) total -= list...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR BIN_OP VAR VAR NUMBER VAR VAR NUMBER VAR VAR VAR VAR NUMBER VAR NU...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
import sys input = sys.stdin.readline n, I = [int(item) for item in input().split()] a = [int(item) for item in input().split()] bits = I * 8 bps = bits // n drange = 2**bps - 1 a.sort() a_comp = [] itr = 0 for i, item in enumerate(a): if i == 0: prev = item a_comp.append(itr) continue ...
IMPORT ASSIGN 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 BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
from sys import stdin input = stdin.readline n, I = map(int, input().split()) a = sorted(list(map(int, input().split()))) key = [] k = min(I * 8 // n, 20) K = min(2**k, n) last = -1 for i in range(n): if a[i] == last: key[-1] += 1 else: key.append(1) last = a[i] now = 0 best = 0 for i i...
ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
n, m = map(int, input().split()) arr = list(map(int, input().split())) arr.sort() limit = 2 ** (8 * m // n) cnt = limit - len(set(arr)) ls = [0] if cnt >= 0: print(0) else: ma = 0 for i in range(1, n): if arr[i] != arr[i - 1]: ls.append(i) for i in range(len(ls) - limit): ma ...
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 EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
import sys n, I = map(int, sys.stdin.readline().split()) s = list(map(int, sys.stdin.readline().split())) k = I * 8 // n s.sort() c = [0] for i in range(1, n): if s[i] != s[i - 1]: c.append(i) k = 2**k maxn = -1 for i in range(0, len(c) - k): maxn = max(maxn, c[i + k] - c[i]) if maxn == -1: print(0...
IMPORT 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 BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP ...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
n, _i = map(int, input().split()) _i = _i * 8 // n a = [int(_) for _ in input().split()] a.sort() p = 1 while _i > 0 and p <= 10000000.0: p <<= 1 _i -= 1 x = 1 c = 1 v = 0 for i in range(1, n): if a[i] != a[i - 1]: c += 1 if c > p: while a[v] == a[v + 1] and v < n - 1: v += 1...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUM...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
R = lambda: map(int, input().split()) n, I = R() a = sorted(R()) b = [0] + [(i + 1) for i in range(n - 1) if a[i] < a[i + 1]] + [n] print(n - max((y - x for x, y in zip(b, b[1 << 8 * I // n :])), default=n))
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER LIST VAR EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FU...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
n, i = list(map(int, input().split())) k = 2 ** (8 * i // n) if 8 * i // n < 20 else n a = [int(x) for x in input().split()] a.sort() freq = [1] for i in range(1, len(a)): if a[i - 1] == a[i]: freq[-1] += 1 else: freq.append(1) window = sum(freq[:k]) ans = window for i in range(k, len(freq)): ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR NUMBER BIN_OP NUMBER BIN_OP BIN_OP NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR BI...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
n, I = map(int, input().split()) a = list(map(int, input().split())) b = I * 8 // n c = 2**b a.sort() d = {} for i in range(n): if a[i] in d: a[i] = d[a[i]] else: d[a[i]] = len(d) a[i] = d[a[i]] l, r = 0, 0 ans = n while l < len(a): while r < len(a) and a[r] - a[l] + 1 <= c: ...
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 BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR FUNC_...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
from itertools import groupby def mp3(n, I, a): k = int(I * 8 / n) d = 1 << k c = [len(list(group)) for key, group in groupby(sorted(a))] chgs = sum(c[d:]) ans = chgs for i in range(0, len(c) - d): chgs += c[i] chgs -= c[i + d] ans = min(ans, chgs) return ans def ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR ASSI...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
n, m = map(int, input().split()) a = list(map(int, input().split())) m *= 8 m = m // n m = 2**m d = {} for i in a: try: d[i] += 1 except: d[i] = 1 a.sort() val = [0] mx = 0 for i in range(1, n): if a[i - 1] != a[i]: val.append(i) diff = len(val) - m if len(val) <= m: print(0) els...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR DICT FOR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR V...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
n, p = map(int, input().split()) x = list(map(int, input().split())) x.sort() t = 2 ** (8 * p // n) last = None y = [] for c in x: if last is None or last != c: last = c y.append(1) else: y[-1] += 1 best = 0 now = 0 le = len(y) for i in range(le): now += y[i] if i >= t: n...
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 EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR NONE ASSIGN VAR LIST FOR VAR VAR IF VAR NONE VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR NUMBER VAR NUMBER NUMBER ...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
dic = {} num = 0 a = [0] sum1 = [0] sum2 = [0] def getID(x): global dic, num if dic.get(x, -1) == -1: num += 1 dic[x] = num return dic[x] def quickM(d): ans = 1 base = 2 while d > 0: if d & 1: ans *= base base *= base d >>= 1 return ans...
ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER FUNC_DEF IF FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER VAR VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN ...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
from sys import stdin, stdout input = stdin.readline a = list(map(int, input().split())) b = list(map(int, input().split())) b.sort() m = 2 ** (a[1] * 8 // len(b)) g = [0] for i in range(1, a[0]): if b[i - 1] != b[i]: g.append(i) if len(g) <= m: print(0) else: print(a[0] - max(g[i + m] - g[i] for i...
ASSIGN VAR 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 EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR BIN_OP ...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
n, bs = map(int, input().split()) a = list(map(int, input().split())) k = bs * 8 // n k = min(k, 30) kd = 2**k d = {} for i in a: if i not in d: d[i] = 0 d[i] += 1 cm = 0 a = sorted(set(a)) for i in a: ncm = cm + d[i] d[i] = cm cm = ncm la = len(a) ans = n for l in range(la): r = l + kd ...
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 BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR DICT FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMB...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
n, I = [int(x) for x in input().split()] d = pow(2, 8 * I // n) a = [int(x) for x in input().split()] a.sort() val = [0] m = 0 for i in range(1, n): if a[i - 1] != a[i]: val.append(i) diff = len(val) - d if len(val) <= d: print("0") else: for i in range(diff): m = max(val[i + d] - val[i], m)...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL ...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
n, I = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() k = 2 ** (I * 8 // n) b = [0] * len(set(a)) be = a[0] i = 0 t = 0 ma = 0 if k > len(b): print(0) else: for x in a: if x != be: t += b[i] if i - k >= 0: t -= b[i - k] ma...
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 EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN ...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
import sys n, I = map(int, input().split()) a = list(map(int, input().split())) b = a b.sort() c = [] d = [] for i in range(n): if i == 0: c.append(b[i]) d.append(1) elif b[i] != b[i - 1]: c.append(b[i]) d.append(1) else: d[len(d) - 1] += 1 K = len(c) if K <= 2 ** (I...
IMPORT 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 VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMB...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
def solve(): n, i = map(int, input().split()) ns = sorted([*map(int, input().split())]) k = 1 << i * 8 // n lis = [] for i in range(n - 1): if ns[i] != ns[i + 1]: lis.append(i + 1) lis.append(n) print( 0 if len(lis) <= k else n - max(lis[i + k] - l...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EX...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
n, m = map(int, input().split()) a = sorted([int(i) for i in input().split()]) k = 1 << m * 8 // n l, r = 0, 1 ans = n cnt = k - 1 while r < n: if a[r - 1] == a[r] or cnt > 0: if a[r - 1] != a[r]: cnt -= 1 r += 1 else: ans = min(ans, n - r + l) l += 1 if a[l] ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER IF VAR ...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
n, I = map(int, input().split()) a = list(map(int, input().split())) diff = len(set(a)) k = 8 * I // n K = 2**k if diff < K: print(0) else: a.sort() ind = 0 curr = -1 changes = [] for i in range(n): if a[ind] != curr: changes.append(ind) curr = a[ind] ...
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 ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP NUMBER VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
from itertools import groupby as gb N, I = map(int, input().split()) A = list(map(int, input().split())) A = sorted(A) l = [] G = gb(A) for k, v in G: l.append(len(list(v))) k = 100 while True: if N * k > 8 * I: k -= 1 else: break K = 2**k NN = len(l) if NN <= K: print(0) exit() sm ...
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 VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE NUMBER IF BIN_OP VAR VAR BIN_OP...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
n, I = [int(i) for i in input().split()] a = sorted([int(i) for i in input().split()]) b = [] c_one_b = I * 8 // n k = 2**c_one_b c = 1 for i in range(n - 1): if a[i] != a[i + 1]: b.append(c) c = 0 c += 1 b.append(c) s = 0 maxx = 0 ln = len(b) for j in range(min(k, ln)): s += b[j] maxx = s f...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CA...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
import sys from itertools import accumulate as acc input = sys.stdin.readline n, m = map(int, input().split()) m = m * 8 // n mx = 2**m a = list(map(int, input().split())) c, d = {}, [] for i in a: if i not in c: c[i] = 1 d.append(i) else: c[i] += 1 d.sort() d = [c[i] for i in d] d = li...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR DICT LIST FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMB...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
N, I = map(int, input().split()) A = sorted([int(a) for a in input().split()]) B = [] j = 0 for i in range(N): if i == 0 or A[i] == A[i - 1]: B.append(j) else: j += 1 B.append(j) def calc(k): K = 1 << k i = 0 j = 0 ma = 0 while j < N: if B[j] - B[i] <= K - 1...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR BIN_OP NUMB...
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers. If there are exactly $K$ distinct values in the array, then we need $k = \lcei...
def answer(n, x, A): k = 2 ** (x * 8 // n) A.sort() l = 0 r = 0 d = set() maxi = 0 while r < n: if len(d) < k: d.add(A[r]) r += 1 elif len(d) == k: if A[r] in d: r += 1 else: t = A[l] ...
FUNC_DEF ASSIGN VAR BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR VA...
Monocarp wants to watch $n$ videos. Each video is only one minute long, but its size may be arbitrary. The $i$-th video has the size $a_i$ megabytes. All videos are published on the Internet. A video should be downloaded before it can be watched. Monocarp has poor Internet connection β€” it takes exactly $1$ minute to do...
n, m = map(int, input().split()) a = list(map(int, input().split())) a.sort() res = 0 for e in a: res += e l = 0 r = n - 1 while l < r: if a[l] + a[r] <= m: l += 1 r -= 1 else: r -= 1 res += 1 res += 1 print(res)
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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR ...
Monocarp wants to watch $n$ videos. Each video is only one minute long, but its size may be arbitrary. The $i$-th video has the size $a_i$ megabytes. All videos are published on the Internet. A video should be downloaded before it can be watched. Monocarp has poor Internet connection β€” it takes exactly $1$ minute to do...
def binarysearch(array, element): if len(array) == 1: if array[0] >= element: return 0 else: return 1 elif array[len(array) // 2] >= element: return binarysearch(array[0 : len(array) // 2], element) else: return len(array) // 2 + binarysearch(array[len...
FUNC_DEF IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR RETURN NUMBER RETURN NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR RETURN FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER VAR RETURN BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_DEF ASSIGN VAR VAR NU...
Monocarp wants to watch $n$ videos. Each video is only one minute long, but its size may be arbitrary. The $i$-th video has the size $a_i$ megabytes. All videos are published on the Internet. A video should be downloaded before it can be watched. Monocarp has poor Internet connection β€” it takes exactly $1$ minute to do...
n, m = input().split() m = int(m) p = list(input().split()) for i in range(len(p)): p[i] = int(p[i]) p.sort() l = 0 h = len(p) - 1 s = 0 while l <= h: if l != h: if p[h] + p[l] <= m: s += p[h] + p[l] h -= 1 l += 1 else: s += p[h] + 1 h ...
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR IF ...
Monocarp wants to watch $n$ videos. Each video is only one minute long, but its size may be arbitrary. The $i$-th video has the size $a_i$ megabytes. All videos are published on the Internet. A video should be downloaded before it can be watched. Monocarp has poor Internet connection β€” it takes exactly $1$ minute to do...
n, m = [int(num) for num in input().split()] arr = [int(num) for num in input().split()] arr.sort() aa = 0 i = 0 j = n - 1 while i < j: if arr[i] + arr[j] > m: j -= 1 aa += 1 else: i += 1 j -= 1 ans = sum(arr) + 1 + aa print(ans)
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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_...
Monocarp wants to watch $n$ videos. Each video is only one minute long, but its size may be arbitrary. The $i$-th video has the size $a_i$ megabytes. All videos are published on the Internet. A video should be downloaded before it can be watched. Monocarp has poor Internet connection β€” it takes exactly $1$ minute to do...
n, m = map(int, input().split()) sizes = list(map(int, input().split())) sizes = sorted(sizes) up_index = n - 1 down_index = 0 spent_time = 0 used_m = 0 while up_index >= down_index: if used_m + sizes[up_index] > m: spent_time += 1 spent_time += sizes[up_index] used_m = sizes[up_index] up_index ...
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 VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR VAR VAR VAR NUMBER VAR VAR VAR ASSIGN VAR VAR VAR VA...
Monocarp wants to watch $n$ videos. Each video is only one minute long, but its size may be arbitrary. The $i$-th video has the size $a_i$ megabytes. All videos are published on the Internet. A video should be downloaded before it can be watched. Monocarp has poor Internet connection β€” it takes exactly $1$ minute to do...
n, k = map(int, input().split()) l = list(map(int, input().split())) l.sort() i = 0 j = n - 1 answer = sum(l) while j > i: if l[i] + l[j] > k: answer += 1 j -= 1 else: i += 1 j -= 1 print(answer + 1)
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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CAL...
In an attempt to escape the Mischievous Mess Makers' antics, Farmer John has abandoned his farm and is traveling to the other side of Bovinia. During the journey, he and his k cows have decided to stay at the luxurious Grand Moo-dapest Hotel. The hotel consists of n rooms located in a row, some of which are occupied. ...
res = 1000000000.0 def next(i): i += 1 while i < N and S[i] == "1": i += 1 return i N, K = map(int, input().split()) S = input() l = next(-1) m = l r = l for j in range(K): r = next(r) while r < N: while max(m - l, r - m) > max(next(m) - l, r - next(m)): m = next(m) res = min...
ASSIGN VAR NUMBER FUNC_DEF VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR WHILE FUNC_CALL VA...
In an attempt to escape the Mischievous Mess Makers' antics, Farmer John has abandoned his farm and is traveling to the other side of Bovinia. During the journey, he and his k cows have decided to stay at the luxurious Grand Moo-dapest Hotel. The hotel consists of n rooms located in a row, some of which are occupied. ...
def main(): n, k = list(map(int, input().split())) cowLocations = input() whereIsCow = [] for i in range(len(cowLocations)): if cowLocations[i] == "0": whereIsCow.append(i) i = 0 j = k fJohn = 0 wic = len(whereIsCow) smallest = 1000000 while i < wic and j < wi...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VA...