description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) exams = [] sum_exam = 0 for j in range(n): a, b = map(int, input().split()) exams.append((a, b)) sum_exam += a if sum_exam == n * avg: print(0) else: sum = 0 exams = sorted(exams, key=lambda x: x[1]) remaining = n * avg - sum_exam i = 0 while i <...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR IF VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER A...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n = list(map(int, input().split())) r = n[1] e = 0 l = [] d = n[2] * n[0] for i in range(n[0]): l += [list(map(int, input().split()))] l.sort(key=lambda x: x[1]) f = [i[0] for i in l] c = sum(f) if c < d: for i in l: if i[0] < r and c + r - i[0] < d: e += (r - i[0]) * i[1] c += r...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER VAR LIST FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR VAR...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) exams, need, ans = [], avg * n, 0 for x in range(n): a, b = map(int, input().split()) exams.append([b, a]) need -= a exams.sort() i = 0 while need > 0 and i < n: ans += exams[i][0] * min(r - exams[i][1], need) need -= min(r - exams[i][1], need) i += 1 print(...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR LIST BIN_OP VAR VAR NUMBER 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 VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR VAR BIN_OP VAR VAR NUMBER FU...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) v_avg = 0 t = [[(0) for x in range(2)] for x in range(n)] for i in range(0, n): t[i][1], t[i][0] = map(int, input().split()) v_avg += t[i][1] s = 0 t.sort() m = 0 while v_avg < avg * n: if v_avg + r - t[m][1] < avg * n: s += t[m][0] * (r - t[m][1]) v_avg...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR ASSIGN V...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
[n, r, avg] = list(map(int, input().split())) points = n * avg mark_sheet = [] for i in range(n): mark_sheet.append(list(map(int, input().split()))) mark_sheet.sort(key=lambda x: x[1]) total_points = 0 for i in range(n): total_points += mark_sheet[i][0] ans = 0 current_paper = 0 while points > total_points: ...
ASSIGN LIST VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR 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 VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSI...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, a = map(int, input().split()) l, e, b = [], 0, 0 for i in [1] * n: q, w = map(int, input().split()) l += [[w, r - q]] e += q l.sort() k = n * a - e if n * a > e else 0 for i in l: p = i[0] * min(i[1], k) b += p k -= i[1] if k <= 0: break print(b)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR LIST NUMBER NUMBER FOR VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR LIST LIST VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR NUMBER FOR VAR VA...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
num_exams, max_grade, average_grade = map(int, input().split()) required_points = average_grade * num_exams num_essays_to_do = 0 exams = [tuple(map(int, input().split())) for _ in range(num_exams)] exams.sort(key=lambda exam: exam[1]) for exam in exams: required_points -= exam[0] if required_points > 0: for exa...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER 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 FOR VAR VAR VAR VAR NUMBER IF VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
from sys import stdin stdin.readline def mp(): return list(map(int, stdin.readline().strip().split())) def it(): return int(stdin.readline().strip()) n, r, avg = mp() v = [] k = res = 0 for _ in range(n): a, b = mp() v += [[a, b]] k += a v.sort(key=lambda x: x[1]) ans = k d = avg * n - ans i ...
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 VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR LIST LIST VAR VAR VAR VAR EXPR FUNC_CALL VAR ...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) rs = avg * n s = 0 al = [] for _ in range(n): x, y = map(int, input().split()) s += x if x != r: al.append([x, y]) al.sort(key=lambda x: x[1]) re = rs - s ans = 0 i = 0 while re > 0: if r - al[i][0] > re: ans += al[i][1] * re re = 0 else:...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VA...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
def main(): n, r, avg = map(int, input().split(" ")) x = [] points = 0 essays = 0 for i in range(n): a, b = map(int, input().split(" ")) if a < r: x.append([a, b]) points += a x = sorted(x, key=lambda i: i[1]) i = 0 while points < int(avg * n): ...
FUNC_DEF ASSIGN VAR VAR 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 ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) arr = [] s = 0 for i in range(n): a, b = map(int, input().split()) arr.append((b, r - a)) s += a arr.sort() i, res = 0, 0 while s < n * avg: if n * avg - s <= arr[i][1]: res += (n * avg - s) * arr[i][0] s = n * avg else: s += arr[i][1] ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER WHILE VAR BIN_OP VAR VAR IF BIN_OP BIN_OP VAR VA...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) avg *= n a = [0] * n b = [0] * n mas = [[0, 0]] * n summ = 0 for i in range(n): a[i], b[i] = map(int, input().split()) summ += a[i] mas[i] = [b[i], a[i] - r] mas.sort() for i in range(n): mas[i][1] *= -1 i = 0 cnt = 0 while i < n and summ < avg: cnt += min(mas[i...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST LIST NUMBER NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR L...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
def Sort(sub_li): sub_li.sort(key=lambda x: x[1]) return sub_li o = input().rstrip().split(" ") req = int(o[0]) * int(o[2]) total = 0 l = [] for i in range(0, int(o[0])): p = input().rstrip().split(" ") D = [] D.append(int(p[0])) D.append(int(p[1])) l.append(D) total += int(p[0]) if to...
FUNC_DEF EXPR FUNC_CALL VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
from sys import stdin n, r, avg = map(int, input().split()) def sumy(x): s = 0 for i in x: s += i[0] return s exams = [list(map(int, input().split())) for i in range(n)] s = sumy(exams) exams.sort(key=lambda x: x[1], reverse=True) exe = 0 while s / n < avg: a, b = exams.pop() if (s + r ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR VAR NUMBER RETURN 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 EXPR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR ...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
import sys def get_ints(): return map(int, sys.stdin.readline().strip().split()) n, r, avg = map(int, input().split()) a = [] b = [] for i in range(n): ai, bi = get_ints() a.append(ai) b.append(bi) if sum(a) >= n * avg: print(0) sys.exit() req = [] for i in range(n): req.append([b[i], r ...
IMPORT FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL ...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = list(map(int, input().split())) ls = [] for i in range(n): ls.append(list(map(int, input().split()))) ls.sort(key=lambda x: x[1]) req_points = avg * n - sum([i[0] for i in ls]) if req_points <= 0: print("0") else: essays = 0 j = 0 while req_points > 0: i = ls[j] points_he...
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) d = [] s = 0 ans = 0 for i in range(n): a, b = map(int, input().split()) d.append([b, a]) s += a d.sort() f = n * avg - s g = f for i in range(len(d)): if f > 0: c = r - d[i][1] ans += min(c * d[i][0], g * d[i][0]) f -= 1 g -= min(c, ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER 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 VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = [int(i) for i in input().split()] a = [0] * n b = [([0] * 2) for i in range(n)] for j in range(n): a[j], b[j][0] = [int(i) for i in input().split()] b[j][1] = j b.sort() mid = -1 sum1 = sum(a) res = 0 hod = 0 sumOLD = 0 if sum1 / n < avg: while mid < avg: sumOLD = sum1 sum1 += mi...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMB...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
from sys import stdin input = stdin.readline n, r, avg = map(int, input().split()) prosjek = avg * n popis = [] sad = 0 for i in range(n): a, b = map(int, input().split()) popis.append([b, a]) sad += a popis = sorted(popis) treba = 0 e = 0 while sad < prosjek: smanji = prosjek - sad if smanji > r -...
ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER 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 VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUM...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
s = input() n, r, gpa = s.split() n = int(n) r = int(r) gpa = int(gpa) z = [] sum0 = 0 avg = 0.0 for x in range(0, n): a = list(map(int, input().split())) z.append(a) sum0 += z[x][0] r0 = gpa * n flag = False if sum0 >= r0: print(0) else: ans = 0 z.sort(key=lambda y: y[1]) i = 0 while su...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
from sys import stdin, stdout n, r, arg = map(int, stdin.readline().split()) a = [] sum = 0 for _ in range(n): x, y = map(int, stdin.readline().split()) a.append([y, x]) sum += x a.sort() sum = n * arg - sum essasy = 0 for element in a: if sum <= 0: print(essasy) exit() if r != elem...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER 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 VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER EX...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, maxMark, avg = map(int, input().split()) a = [tuple(map(int, input().split())) for _ in range(n)] avg *= n s = 0 for mark, _ in a: s += mark need = max(avg - s, 0) a.sort(key=lambda x: x[1]) ret = 0 for mark, essays in a: if need == 0: break take = min(need, maxMark - mark) ret += take * essa...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR IF VAR NU...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = [int(X) for X in input().split()] pairs = [[int(X) for X in input().split()] for i in range(n)] req = avg * n - sum([x[0] for x in pairs]) pairs = sorted(pairs, key=lambda x: x[1]) n_essay = 0 for x in pairs: if req <= 0: break pts = min(r - x[0], req) n_essay += pts * x[1] req -= pt...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR B...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
IL = lambda: list(map(int, input().split())) IS = lambda: input().split() I = lambda: int(input()) S = lambda: input() n, grMax, grAvg = IL() grReq = grAvg * n exams = [IL() for i in range(n)] emap = {} for exam in exams: if exam[1] not in emap: emap[exam[1]] = 0 emap[exam[1]] += grMax - exam[0] imprs =...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR VAR IF VAR NUMBER VAR AS...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, max_mark, avg = list(map(int, input().split())) a, b = [], [] for i in range(n): ai, bi = list(map(int, input().split())) a.append(ai) b.append(bi) exams = dict(enumerate(zip(a, b))) marks_needed = round((avg - sum(a) / len(a)) * n) num_essays = 0 if marks_needed > 0: for exam in sorted(exams.values(...
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
import sys input = sys.stdin.readline n, r, avg = map(int, input().split()) d = [] s = 0 f = avg * n for i in range(n): a, b = map(int, input().split()) d.append([b, a]) s += a ans = 0 if s < f: d.sort() t = f - s while t: for i in d: k = min(r - i[1], t) ans += ...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR 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 VAR VAR ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR ASSIGN...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, req = map(int, input().split()) exams = [] avg = 0 req *= n essays = 0 for i in range(n): a, b = map(int, input().split()) exams.append((a, b)) avg += a exams.sort(key=lambda x: x[1]) if req > avg: for exam in exams: if exam[0] < r: essays += exam[1] * min(r - exam[0], req - av...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER IF VAR VAR FOR VAR VAR IF VAR NUMBER VAR VAR BIN_OP...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) l = [] top = 0 for i in range(n): a, b = map(int, input().split()) top += a l.append((a, b)) ne = avg * n l.sort(key=lambda x: x[1]) res = 0 for i in l: a, b = i inc = r - a t = inc * b if top + inc < ne: res += t top += inc elif top ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR VAR AS...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, a = map(int, input().split()) l = [] s = 0 for _ in range(n): x, y = map(int, input().split()) s += x l.append([y, x]) l.sort() ans = 0 total = n * a i = 0 while s < total: temp = min(total - s, r - l[i][1]) ans += l[i][0] * temp s += temp i += 1 print(ans)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN ...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, mx, avg = map(int, input().split()) total = 0 l = [] for i in range(n): x, y = map(int, input().split()) total += x l.append((y, mx - x)) l.sort() count = 0 i = 0 diff = avg * n - total while diff > 0: k = min(l[i][1], diff) count += l[i][0] * k diff -= k i += 1 print(count)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR WHIL...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
from sys import stdin def main(): n, r, avg = list(map(int, stdin.readline().strip().split())) aa, bb = [], [] for _ in range(n): a, b = list(map(int, stdin.readline().strip().split())) aa.append(a) bb.append(b) now = sum(aa) ineed = n * avg if now >= ineed: ret...
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP V...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) p = [[0, 0] for i in range(n)] for i in range(n): p[i][0], p[i][1] = map(int, input().split()) s = sum(p[i][0] for i in range(0, n)) if s >= n * avg: print(0) else: t = n * avg - s y = 0 x = 0 p = sorted(p, key=lambda x: x[1]) for i in range(0, n): ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR VAR EXPR FUNC_C...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) l = [] s = 0 for i in range(n): a, b = map(int, input().split()) s = s + a l.append((r - a, b)) if s / n >= avg: print(0) else: q = avg * n s = q - s ans = 0 l = sorted(l, key=lambda x: x[1]) for i in l: if i[0] <= s: s = s - ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSI...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) a = [] b = [] c = [] for i in range(n): num1, num2 = map(int, input().split()) a.append(num1) b.append(num2) c.append((num1, num2)) want = avg * n have = sum(a) diff = want - have left = diff cnt = 0 if diff <= 0: print(0) else: c.sort(key=lambda x: x[1]) ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST 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 EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) a = [] for i in range(n): c = list(map(int, input().split())) a.append([c[0], c[1]]) s = 0 ans = 0 for i in range(n): s += a[i][0] a.sort(key=lambda x: x[1]) i = 0 while s / n < avg: if a[i][0] < r: k = min(r - a[i][0], n * avg - s) s += k an...
ASSIGN VAR 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 LIST VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
from sys import stdin n, r, avg = map(int, next(stdin).split()) ab = [] ab_min = [] summ = 0 for e in range(n): a, b = map(int, next(stdin).split()) ab.append([a, b]) if a < r: ab_min.append([a, b]) summ += a mean = summ / n def compare_refs(x): return x[1] refs = 0 ab_min = sorted(ab_m...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR IF VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR FUNC_DEF ...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) sm = avg * n sn = 0 scors = [] for _ in range(n): a, b = map(int, input().split()) sn += a scors.append([a, b]) ans = 0 scors.sort(key=lambda x: x[1]) ind = 0 while sn < sm: a, b = scors[ind] ind += 1 t = min(r - a, sm - sn) sn += t ans += b * t prin...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR ...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
def solve(): n, r, avg = [int(x) for x in input().split(" ")] total = 0 lst = [] for i in range(n): mark, essay = [int(x) for x in input().split(" ")] total += int(mark) if mark != r: lst.append((int(mark), int(essay))) if total / n >= avg: print(0) el...
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR E...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
stat = [] n, r, avg = map(int, input().split(" ")) for i in range(n): a, b = map(int, input().split(" ")) stat.append([a, b, r - a]) req = n * avg curr = sum([i[0] for i in stat]) need = req - curr stat.sort(key=lambda x: x[1]) curr = 0 tot = 0 while need > 0: if stat[curr][2] <= need: tot += stat[c...
ASSIGN VAR LIST ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR LIST VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR VAR EXP...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = list(map(int, input().split())) a = [] sum = int(round(avg * n)) sum1 = 0 res = 0 for i in range(n): x, y = list(map(int, input().split())) a.append([y, x]) sum1 += x a.sort() i = 0 while sum > sum1: if sum - sum1 > r - a[i][1]: sum1 += r - a[i][1] res += (r - a[i][1]) * a[i]...
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR 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 LIST VAR VAR VAR VAR EX...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = [int(x) for x in input().split()] ls = [] for i in range(n): ls.append([int(x) for x in input().split()]) ls.sort(key=lambda x: x[1]) s = sum([x[0] for x in ls]) ans = 0 if s >= avg * n: print(0) else: for i in range(n): if avg * n - s <= r - ls[i][0]: ans += (avg * n - s) * ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER IF VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR ...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
def input_split(f): return map(f, input().split()) def main(): n, r, avg = input_split(int) ex = [] sum_a = 0 for i in range(n): ai, bi = input_split(int) sum_a += ai ex.append([bi, ai]) ex.sort() le = avg * n - sum_a res = 0 i = 0 while le > 0: ...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VA...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
l = [int(i) for i in input().split()] n = l[0] r = l[1] a = l[2] e = [None] * n i = 0 goal = a * n s = 0 while i < n: e[i] = [int(x) for x in input().split()] s += e[i][0] i += 1 e.sort(key=lambda y: y[1]) deficit = goal - s essays = 0 i = 0 while deficit > 0: while e[i][0] == r: i += 1 if d...
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBE...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
from sys import stdin def bsearch(li, v): l, r = 0, len(li) while l < r: m = l + (r - l) // 2 if li[m] < v: l = m + 1 else: r = m return l def solve(tc): n, r, avg = map(int, stdin.readline().split()) li = [] for _ in range(n): a, b = m...
FUNC_DEF ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR 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...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
import sys n, m, avg = list(map(int, sys.stdin.readline().rstrip().lstrip().split())) arr = [] x = 0 for i in range(n): u, v = list(map(int, sys.stdin.readline().rstrip().lstrip().split())) arr.append([v, u]) x += u arr.sort() req = avg * n if x >= req: sys.stdout.write("0" + "\n") else: req = req ...
IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN V...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
def main(): n, r, avg = map(int, input().strip().split()) cur_sum = 0 exams = list() for i in range(n): a, b = map(int, input().strip().split()) cur_sum += a if a < r: exams.append((a, b)) if cur_sum / n >= avg: print(0) return def ts(el): ...
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN FUN...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) a = [] cur = 0 for i in range(n): a.append(list(map(int, input().split()))) a[i][0], a[i][1] = a[i][1], a[i][0] cur += a[i][1] a.sort() ans = 0 for i in range(n): if cur < avg * n: ans += a[i][0] * min(n * avg - cur, r - a[i][1]) cur += min(n * avg -...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER F...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) t = n * avg e = [] for i in range(n): a, b = map(int, input().split()) t -= a if a != r: e.append((a, b)) e.sort(key=lambda x: x[1]) s = 0 for a, b in e: if t <= 0: break c = min(t, r - a) t -= c s += c * b print(s)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR IF VAR NUMBER ASSIGN VAR...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, t, av = map(int, input().split()) p = [] sum = 0 for i in range(n): a, b = map(int, input().split()) p.append((b, a)) sum += a p.sort() col = n * av col = col - sum sum = 0 for i in range(len(p)): if col == 0: print(max(sum, 0)) break if col > t - p[i][1]: col -= t - p[i][...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL ...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) arr = [] for i in range(n): arr.append(list(map(int, input().split()))) sum = 0 for i in arr: sum += i[0] req = n * avg - sum if req <= 0: print(0) else: ans = [] for i in range(n): if arr[i][0] >= r: pass else: ans.append...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR ...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
import sys input = sys.stdin.readline def inInt(): return int(input()) def inStr(): return input().strip("\n") def inIList(): return list(map(int, input().split())) def inSList(): return input().split() def bsearch(nums, target): N = len(nums or []) l = 0 r = N - 1 while l <= ...
IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR LIST ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) l = [[*map(int, input().split())] for i in range(n)] l.sort(key=lambda x: x[1]) total = 0 for i in range(n): total += l[i][0] i = 0 ans = 0 if total // n >= avg: print(0) exit() while total // n < avg: x = r - l[i][0] if (x + total) // n < avg: total += ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EX...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) A = [] curr_sum = 0 for _ in range(n): a, b = map(int, input().split()) A.append((a, b)) curr_sum += a needed_points = avg * n - curr_sum if needed_points <= 0: print(0) else: A.sort(key=lambda t: t[1]) ans = 0 for i in range(n): a, b = A[i] ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
a, b = [], [] m = [] n, r, ag = map(int, input().split()) for i in range(n): x, y = map(int, input().split()) a.append(x) b.append([y, r - x]) s = ag * n - sum(a) b = sorted(b) count = 0 for i in range(n): if s > 0: count += b[i][0] * min(s, b[i][1]) s -= min(s, b[i][1]) print(count)
ASSIGN VAR VAR LIST LIST ASSIGN VAR LIST ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CA...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = [int(i) for i in input().split()] ls = [] aver = 0 cost = 0 for i in range(n): x, y = [int(i) for i in input().split()] ls.append((x, y)) aver += x a = aver // n if a >= avg: print(0) else: br = 1 ls.sort(key=lambda item: item[1]) for tup in ls: exam = tup[0] poin...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER 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 VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) current_avg = 0 grades = [] for _ in range(n): a, b = map(int, input().split()) grades.append([b, a]) current_avg += a avg *= n if avg > current_avg: grades.sort() ans = 0 i = 0 while avg > current_avg: if grades[i][1] >= r: i += 1 continue a...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER 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 VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR NUM...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) a = [] total = 0 for _ in range(n): a.append(list(map(int, input().split()))) total += a[-1][0] a = sorted(a, key=lambda x: x[1]) i = 0 ans = 0 while total < avg * n: tmp = min(avg * n - total, r - a[i][0]) ans += tmp * a[i][1] total += tmp i += 1 print(ans)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR VAR A...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
def sum_i(a): sum_j = 0 for i in range(len(a)): sum_j = sum_j + a[i][1] return sum_j n, m, r = map(int, input().split()) a = [] for i in range(n): v, c = map(int, input().split()) a.append([c, v]) a.sort() s = 0 h = r * n sum_ = sum_i(a) if sum_ >= h: print("0") else: for i in rang...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR 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_CAL...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) needed = n * avg current = 0 ammo = [] for i in range(n): a, b = map(int, input().split()) current += a if a < r: ammo.append([b, r - a]) needed -= current written = 0 if needed > 0: ammo.sort() while needed > 0: x = ammo[0][1] if needed ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, a = map(int, input().split()) l = [[*map(int, input().split())] for i in range(n)] sum = 0 w = 0 z = 0 for i in range(n): sum += l[i][0] l[i][0], l[i][1] = l[i][1], l[i][0] l.sort() if sum >= a * n: print(0) else: i = 0 k = a * n - sum while k > 0: if l[i][1] < r: z = m...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CAL...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
import sys input = sys.stdin.readline n, r, avg = map(int, input().split()) f = [] u = 0 for j in range(n): a, b = map(int, input().split()) u += a f.append([b, a]) f.sort() if u / n >= avg: print(0) else: req = avg * n - u ans = 0 for j in range(n): if f[j][1] < r: got ...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BI...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
first = input().split() n = int(first[0]) r = int(first[1]) avg = int(first[2]) marks = {} total = 0 essays = [] for i in range(n): inp = input().split() inp[0] = int(inp[0]) inp[1] = int(inp[1]) total += inp[0] essays.append(inp[1]) if inp[1] in marks: marks[inp[1]].append(inp[0]) e...
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 VAR NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FUNC_...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = list(map(int, input().split())) a = [] cur = 0 for i in range(n): t1, t2 = list(map(int, input().split())) cur += t1 a.append((t2, t1)) a = sorted(a) ans = 0 avg = avg * n for i in range(n): if cur >= avg: break need = avg - cur temp = min(need, r - a[i][1]) cur += temp ...
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR FOR VA...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
import sys input = sys.stdin.readline read_tuple = lambda _type: map(_type, input().split(" ")) def solve(): n, r, avg = read_tuple(int) data = [] for _ in range(n): a_i, b_i = read_tuple(int) data.append((a_i, b_i)) needed = avg * n current = sum(a_i for a_i, _ in data) data_...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) array = [] s = 0 for index in range(0, n): array.append(list(map(int, input().split()))) s += array[index][0] array.sort(key=lambda x: x[1]) index = 0 answer = 0 while s // n < avg: if s + r - array[index][0] >= avg * n: answer += array[index][1] * (avg * n - s)...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF BIN_...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, req_avg = map(int, input().split()) avgs = [] for _ in range(n): a, b = map(int, input().split()) avgs.append((a, b)) required = n * req_avg - sum(x[0] for x in avgs) if required <= 0: print(0) exit() avgs.sort(key=lambda x: x[1]) total = 0 for curr, cost in avgs: if required <= 0: bre...
ASSIGN VAR 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 ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR EXPR FUN...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
import sys lines = sys.stdin.readlines() n, r, avg = list(map(int, lines[0].split())) pair = [] for l in lines[1:]: pair.append(list(map(int, l.split()))) pair.sort(key=lambda x: x[1]) cur_sum = sum([i[0] for i in pair]) req_sum = avg * n ans = 0 for v in pair: if cur_sum >= req_sum: break inc = mi...
IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBE...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) sum_of_marks = 0 sum_required = n * avg a = n * [0] ans = 0 for i in range(n): x = list(map(int, input().split())) a[i] = x sum_of_marks += x[0] a.sort(key=lambda x: x[1]) if sum_of_marks >= sum_required: print(0) else: while sum_of_marks < sum_required: ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER IF VAR...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
inp = input().split() n = int(inp[0]) r = int(inp[1]) avg = int(inp[2]) arr = [] for i in range(0, n): inp = input().split() ai = int(inp[0]) bi = int(inp[1]) arr.append((bi, ai)) arr = sorted(arr) total = 0 for i in range(0, n): total += arr[i][1] curavg = total / n if curavg >= avg: print(0) e...
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 VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VA...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
read = lambda: map(int, input().split()) n, r, avg = read() p = [tuple(read()) for i in range(n)] p.sort(key=lambda x: x[1]) avg *= n cur = sum(a for a, b in p) ans = 0 for a, b in p: if cur >= avg: break if avg - cur < r - a: ans += (avg - cur) * b cur = avg else: ans += (r ...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR IF VAR VAR IF BIN_OP VAR VAR BIN_OP VAR VAR VAR BIN_OP BIN_O...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
def second(elem): return elem[1] n, r, avg = (int(i) for i in input().split()) l = [] s = 0 for i in range(n): a, b = (int(i) for i in input().split()) s += a if a != r: l.append((a, b)) l.sort(key=second) diff = n * avg - s c = 0 i = 0 while diff > 0: k = min(diff, r - l[i][0]) c += k...
FUNC_DEF RETURN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR A...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = list(map(int, input().split(" "))) L = [] for i in range(n): x = list(map(int, input().split(" "))) L.append(x) L.sort(key=lambda x: x[1]) s = 0 for i in L: s += i[0] need = avg * n - s if need <= 0: ans = 0 else: ans = 0 start = 0 while need > 0: a = L[start][0] ...
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = list(map(int, input().split())) pass_point = avg * n current_point = 0 a = [] for _ in range(n): point, essay = list(map(int, input().split())) a.append([essay, point]) current_point += point a.sort() ans = 0 for i in range(n): point = a[i][1] essay = a[i][0] if current_point + r - p...
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER 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 LIST VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUN...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
def solve(n, r, avg, grades, tot): if tot >= avg * n: return 0 p = avg * n - tot ans = 0 i = 0 while p > 0: if p < r - grades[i][1]: ans += grades[i][0] * p p = 0 else: p -= r - grades[i][1] ans += grades[i][0] * (r - grades[i][...
FUNC_DEF IF VAR BIN_OP VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR BIN_OP VAR VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR NUMBER VAR BIN_OP VAR VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR NUMBER VAR NUMBER RETURN VAR ...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) s = 0 a = [] for i in range(n): z = input().split() a.append([int(z[1]), int(z[0])]) s += a[-1][1] a.sort() b = avg * n - s ans = 0 for x in a: if b <= 0: break tmp = min(r - x[1], b) ans += tmp * x[0] b -= tmp print(ans)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST 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 VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR N...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) a = [list(reversed(list(map(int, input().split())))) for i in range(n)] a.sort() cur = 0 req = avg * n for i in range(n): cur += a[i][1] i = 0 ans = 0 while i < n and cur < req: d = min(req - cur, r - a[i][1]) ans += min(req - cur, r - a[i][1]) * a[i][0] i += 1 ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBE...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) arr = [] ss = 0 temp = [] for i in range(n): a, b = map(int, input().split()) arr.append([a, b]) ss += a if a < r: temp.append([a, b]) aa = avg * n - ss temp = sorted(temp, key=lambda item: item[1]) ans = 0 for i in range(len(temp)): if aa <= 0: ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER 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 VAR VAR IF VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
import sys n, r, avg = list(map(int, input().split())) L = [] tot = 0 for i in range(n): L.append(list(map(int, input().split()))) L[i][0], L[i][1] = L[i][1], L[i][0] tot += L[i][1] L[i][1] = r - L[i][1] req = avg * n L.sort() ind = 0 ans = 0 while ind < n and req > tot: diff = req - tot if L[i...
IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR NU...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
def sort_by_second(n): return n[1] n, r, avg = map(int, input().split()) marks = [] s = 0 for i in range(n): a, b = map(int, input().split()) marks.append([a, b]) s += marks[i][0] to_collect = avg * n - s collected = 0 answer = 0 marks.sort(key=sort_by_second) i = 0 while collected < to_collect: a...
FUNC_DEF RETURN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER 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 VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VA...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
from sys import stdin def main(): n, r, avg = map(int, stdin.readline().split()) g = [] cr = 0 for _ in range(n): ta, tb = map(int, stdin.readline().split()) cr += ta g.append((ta, tb)) target = max(avg * n - cr, 0) ans = 0 g.sort(key=lambda x: x[1]) for i in ra...
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
class P: def __init__(self, score, count_ref): self.score = score self.count_ref = count_ref n, r, avg = map(int, input().split()) needed_score = n * avg current_score = 0 a = [] for _ in range(n): score, count_ref = map(int, input().split()) current_score += score a.append(P(score, c...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) scores, essays = [], [] for _ in range(n): a, b = map(int, input().split()) scores.append(a) essays.append(b) now = sum(scores) ineed = n * avg essay_cnt = 0 while now < ineed: pref = sorted(range(n), key=essays.__getitem__) for i in pref: a, b = scores[...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CA...
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
n, r, avg = map(int, input().split()) t = 0 s = 0 l_s = list() for _ in range(n): a, b = map(int, input().split()) s += a l_s.append([a, b]) l_s.sort(key=lambda x: x[1]) i = 0 while s / n < avg: t += min(r - l_s[i][0], n * avg - s) * l_s[i][1] s += min(r - l_s[i][0], n * avg - s) i += 1 print(t)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR VA...
Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler! However, there is no reason for disappointment, as Valery has found another ruler, its length is l centimeters. The ruler already has n marks, with which he can make measure...
R = lambda: map(int, input().split()) n, l, x, y = R() arr = set(R()) x_good, y_good = False, False for m in arr: if m + x in arr or m - x in arr: x_good = True break for m in arr: if m + y in arr or m - y in arr: y_good = True break if x_good and y_good: print(0) return ...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR IF BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC...
Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler! However, there is no reason for disappointment, as Valery has found another ruler, its length is l centimeters. The ruler already has n marks, with which he can make measure...
def rl(T=str): return list(map(T, input().split())) def ok(a, d, x): for v in a: if v + x in d: return True return False def try_one(a, d, x, y): def can_place(v): if a[0] <= v <= a[-1]: if (v + x in d or v - x in d) and (v + y in d or v - y in d): ...
FUNC_DEF VAR RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR VAR IF BIN_OP VAR VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF FUNC_DEF IF VAR NUMBER VAR VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR RETURN NUMBER RETURN NUMBER FOR VAR VAR FOR VAR...
Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler! However, there is no reason for disappointment, as Valery has found another ruler, its length is l centimeters. The ruler already has n marks, with which he can make measure...
__author__ = "zabidon" n, l, x, y = map(int, input().split()) data = set(map(int, input().split())) old_x = any(i + x in data for i in data) old_y = any(i + y in data for i in data) if old_x and old_y: print(0) elif old_x: print(1) print(y) elif old_y: print(1) print(x) else: found = False f...
ASSIGN VAR STRING ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR EXPR FUNC_CALL VAR NUM...
Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler! However, there is no reason for disappointment, as Valery has found another ruler, its length is l centimeters. The ruler already has n marks, with which he can make measure...
import sys def main(): import sys tokens = [int(i) for i in sys.stdin.read().split()] tokens.reverse() n, l, x, y = [tokens.pop() for i in range(4)] marks = set(tokens) flag_x = flag_y = False index = -1 for i in marks: if i + x in marks: flag_x = True ...
IMPORT FUNC_DEF IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR IF BIN_OP VAR VAR VAR A...
Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler! However, there is no reason for disappointment, as Valery has found another ruler, its length is l centimeters. The ruler already has n marks, with which he can make measure...
n, l, x, y = list(map(int, input().split())) a = set(map(int, input().split())) boy = False girl = False one = False where = -1 for i in a: if i + x in a: boy = True if i + y in a: girl = True if i - x > 0 and i - x + y in a: one = True where = i - x if i + x < l and i + ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR NUMBER IF BIN_OP ...
Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler! However, there is no reason for disappointment, as Valery has found another ruler, its length is l centimeters. The ruler already has n marks, with which he can make measure...
def main(): n, l, x, y = list(map(int, input().split())) arr = set(map(int, input().split())) first = False second = False for i in arr: if i + x in arr: first = True if i + y in arr: second = True if first and not second: print(1) print(y)...
FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER ...
Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler! However, there is no reason for disappointment, as Valery has found another ruler, its length is l centimeters. The ruler already has n marks, with which he can make measure...
n, l, x, y = map(int, input().split()) s = set(map(int, input().split())) def f(d): return any(i + d in s for i in s) def g(): for i in s: if i + x + y in s: return i + x return 0 def h(): for i in s: if i + y - x in s: if i - x >= 0: return ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR FUNC_DEF FOR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR RETURN BIN_OP VAR VAR RETURN NUMBER FUNC_DEF FOR VAR VAR IF BIN_OP BIN_OP VAR...
Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler! However, there is no reason for disappointment, as Valery has found another ruler, its length is l centimeters. The ruler already has n marks, with which he can make measure...
a = input().split(" ") b = input().split(" ") n = int(a[1]) x = int(a[2]) y = int(a[3]) xcan = False ycan = False xycan = False xymoar = False cool = 0 cool2 = 0 s = set() for element in b: s.add(int(element)) for c in s: if c + x in s: xcan = True if c + y in s: ycan = True if c + x + y...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL...
Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler! However, there is no reason for disappointment, as Valery has found another ruler, its length is l centimeters. The ruler already has n marks, with which he can make measure...
n, l, x, y = list(map(int, input().split(" "))) li = list(map(int, input().split(" ", n)[:n])) li.sort() dic = {} a1, a2 = 0, 0 ans = 2 x1 = x y1 = y xi = -1 yi = -1 for i in li: dic[i] = 1 for i in range(n): if li[i] - x >= 0: if li[i] - x in dic: a1 = 1 xi = i if li[i] + x ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR ...
Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler! However, there is no reason for disappointment, as Valery has found another ruler, its length is l centimeters. The ruler already has n marks, with which he can make measure...
n, l, x, y = map(int, input().split()) def f(t, q): i = j = 0 while j < n: d = t[j] - t[i] if d < q: j += 1 elif d > q: i += 1 else: return 0 return q def g(t): q = x + y i = j = 0 while j < n: d = t[j] - t[i] ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER RETURN NUMBER RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF...
Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler! However, there is no reason for disappointment, as Valery has found another ruler, its length is l centimeters. The ruler already has n marks, with which he can make measure...
n, l, x, y = list(map(int, input().split())) v = list(map(int, input().split())) s = set(v) cx = 0 for i in range(n): if v[i] + x in s: cx = 1 break cy = 0 for i in range(n): if v[i] + y in s: cy = 1 break count = 0 ans = [] if cx == 0: count += 1 ans.append(x) if cy == 0...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR...
Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler! However, there is no reason for disappointment, as Valery has found another ruler, its length is l centimeters. The ruler already has n marks, with which he can make measure...
def solve(n, l, x, y, a): s = set() fx, fy, fxy, fyx = False, False, False, False vxy = -1 vyx_min, vyx_max = -1, -1 for v in a: if v - x in s: fx = True if v - y in s: fy = True if v - (x + y) in s: fxy = True vxy = v i...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR IF BIN_OP VAR BIN_OP VAR VAR V...
Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler! However, there is no reason for disappointment, as Valery has found another ruler, its length is l centimeters. The ruler already has n marks, with which he can make measure...
n, l, x, y = map(int, input().split()) a = list(map(int, input().split())) i = 0 j = 1 tot = 0 can_measure_a = False while j < n: if a[j] - a[i] == x: can_measure_a = True break elif a[j] - a[i] > x: i += 1 else: j += 1 i = 0 j = 1 can_measure_b = False while j < n: if a[...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER AS...
Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler! However, there is no reason for disappointment, as Valery has found another ruler, its length is l centimeters. The ruler already has n marks, with which he can make measure...
import sys first = sys.stdin.readline().split(" ") n = int(first[0]) l = int(first[1]) x = int(first[2]) y = int(first[3]) second = sys.stdin.readline().split(" ") have_dict = {} need_dict_x = {} need_dict_y = {} for val in second: have_dict[val] = 1 val = int(val) need_dict_x[str(val - x)] = 1 need_di...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR NUMBER ASS...
Bandits appeared in the city! One of them is trying to catch as many citizens as he can. The city consists of $n$ squares connected by $n-1$ roads in such a way that it is possible to reach any square from any other square. The square number $1$ is the main square. After Sunday walk all the roads were changed to one-...
n = int(input()) parents = [0] + [(x - 1) for x in list(map(int, input().split()))] citizens = list(map(int, input().split())) size = [1] * n for i in parents: size[i] = 0 for i in range(n - 1, 0, -1): citizens[parents[i]] += citizens[i] size[parents[i]] += size[i] ans = 0 for i in range(n): ans = max(a...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBE...
Bandits appeared in the city! One of them is trying to catch as many citizens as he can. The city consists of $n$ squares connected by $n-1$ roads in such a way that it is possible to reach any square from any other square. The square number $1$ is the main square. After Sunday walk all the roads were changed to one-...
import sys input = sys.stdin.readline n = int(input()) P = [1] + list(map(int, input().split())) A = list(map(int, input().split())) for i in range(n): P[i] -= 1 Y = [1] * n for i in range(n): Y[P[i]] = 0 for i in range(n - 1, 0, -1): Y[P[i]] += Y[i] S = [a for a in A] for i in range(n - 1, 0, -1): S[P...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIG...
Bandits appeared in the city! One of them is trying to catch as many citizens as he can. The city consists of $n$ squares connected by $n-1$ roads in such a way that it is possible to reach any square from any other square. The square number $1$ is the main square. After Sunday walk all the roads were changed to one-...
n = int(input()) deg = [(0) for _ in range(n)] p = list(map(int, input().split())) for i in range(n - 1): p[i] -= 1 deg[p[i]] += 1 a = list(map(int, input().split())) sz = [(0 if deg[i] else 1) for i in range(n)] ans = 0 for i in range(n - 1, 0, -1): sz[p[i - 1]] += sz[i] a[p[i - 1]] += a[i] ans = m...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER ...