description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating ch...
read = lambda: map(int, input().split()) n = int(input()) inf = 10**9 cur = inf a = [tuple(read()) for i in range(n)] dif = 0 def fail(): print("Impossible") exit() flag = True Min = -inf for i in range(n): c, d = a[i] if d == 2: flag = False if d == 2 and cur >= 1900: cur = 1899...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FUNC_DEF EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CA...
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating ch...
ans = 0 check1 = -9999999999 check2 = 9999999999 for i in range(int(input())): a, b = map(int, input().split()) if b == 1: if check2 < 1900: print("Impossible") exit() check1 = max(check1, 1900) + a check2 += a else: if check1 >= 1900: prin...
ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VA...
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating ch...
n = int(input()) for i in range(n): change, division = input().split() change = int(change) division = int(division) if i == 0: if division == 1: maxx = 10**15 minn = 1900 else: maxx = 1899 minn = -(10**10) if division == 1: if ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER IF VAR NUMBER IF VAR NUMBER EX...
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating ch...
def main(): n = int(input()) mn = -int(2000000000.0) mx = int(2000000000.0) impossible = False for i in range(n): c, d = [int(_) for _ in input().split()] if d == 1 and mx < 1900 or d == 2 and mn > 1899: impossible = True break if d == 1: m...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR...
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating ch...
n = int(input()) minr = -1000000000000000000 maxr = 1000000000000000000 for i in range(n): c, div = [int(x) for x in input().split()] if div == 1: if minr < 1900: minr = 1900 elif maxr >= 1900: maxr = 1899 minr += c maxr += c if minr > maxr: print("Impossible") elif m...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR 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 IF VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CAL...
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating ch...
q = int(input()) q -= 1 a, s = map(int, input().split()) if s == 1: z = 1900 x = 9000000000 else: z = -9000000000 x = 1899 z += a x += a for j in range(0, q): a, s = map(int, input().split()) if s == 1: z = max(1900, z) else: x = min(1899, x) z += a x += a if x < z: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN ...
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating ch...
n = int(input()) mx = 10**9 mn = -mx p = 0 for i in range(n): c, d = [int(i) for i in input().split()] if d == 1: mn = max(mn, 1900 - p) else: mx = min(mx, 1899 - p) p += c if mx == 10**9: print("Infinity") elif mx >= mn: print(mx + p) else: print("Impossible")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP NUMBER VAR VAR VAR IF VAR BIN_OP...
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating ch...
n = int(input()) c, d = map(int, input().split()) min_ = 0 max_ = 0 flag = True if d == 1: min_ = 1900 max_ = float("+Inf") else: min_ = float("-Inf") max_ = 1899 for i in range(n - 1): c1, d = map(int, input().split()) if d == 1: min_ = max(min_ + c, 1900) max_ += c else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR F...
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating ch...
from sys import * n = int(stdin.readline()) INF = 100000000000000000000000 MAX = 2 * INF MIN = -MAX possible = True for _ in range(n): c, d = stdin.readline().split(" ") c = int(c) d = int(d) if d is 1: MIN = max(MIN, 1900) if d is 2: MAX = min(MAX, 1899) if MIN > MAX: p...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER ASSIGN ...
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating ch...
def main(): try: while True: n = int(input()) c = [0] * n d = [0] * n has_2 = False for i in range(n): c[i], d[i] = map(int, input().split()) if d[i] == 2: has_2 = True if not has_2: ...
FUNC_DEF WHILE NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST 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 IF VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR BI...
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating ch...
n = int(input()) C = [] D = [] for i in range(n): c, d = list(map(int, input().strip().split())) C.append(c) D.append(d) flag = True if max(D) == min(D) and max(D) == 1: print("Infinity") else: if max(D) == min(D) and max(D) == 2: flag = False a = [] b = [] if D[0] == 1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL...
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating ch...
n = int(input()) mx = 5 * 10**9 mn = -(10**9) flag = True for i in range(n): c, d = map(int, input().split()) if d == 1: mn = max(mn, 1900) else: mx = min(mx, 1899) if mn > mx: flag = False mn += c mx += c if not flag: print("Impossible") elif mx > 10**9: print("I...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR ASSIG...
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating ch...
s, t = -(10**8), 10**8 for i in range(int(input())): c, d = map(int, input().split()) if d == 1: s = max(s, 1900) else: t = min(t, 1899) if s > t: print("Impossible") exit() s, t = s + c, t + c print("Infinity" if t > 5 * 10**7 else t)
ASSIGN VAR VAR BIN_OP NUMBER NUMBER BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR VAR...
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating ch...
n = int(input()) s = 10**10 x = s K = 1900 p = [] for i in range(n): c, d = map(int, input().split()) p.append([c, d]) if x >= K and d == 2: s -= x - (K - 1) x = K - 1 elif x < K and d == 1: s += K - x x = K x += c x = s ok = True for i in range(n): c, d = p[i] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN 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 EXPR FUNC_CALL VAR LIST VAR VAR IF VAR VAR VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER I...
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating ch...
n = int(input()) r = [0] * n d = [0] * n for i in range(n): r[i], d[i] = map(int, input().split()) s = 0 a, b = float("infinity"), -float("infinity") for i in range(n): if d[i] == 1: a = min(a, s) else: b = max(b, s) s += r[i] ans = 1899 - b if ans >= float("infinity"): print("Infini...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASS...
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating ch...
n = int(input()) cdi = [[0, 0]] + [list(map(int, input().split())) for i in range(n)] for i in range(1, n + 1): cdi[i][0] += cdi[i - 1][0] cdi[i - 1][1] = cdi[i][1] cdi[-1][1] = 3 maxi = -(10**9) mini = 10**9 for i in range(n): if cdi[i][1] == 1: mini = min(mini, cdi[i][0]) else: maxi = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST LIST NUMBER NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER N...
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating ch...
n = int(input()) A = [0] * n per = 0 ans1 = float("infinity") ans2 = -float("infinity") for j in range(n): per1, per2 = map(int, input().split()) if per2 == 1: if ans1 < 1900: per = 1 break else: ans2 = max(ans2, 1900) ans1 += per1 ans2...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ...
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating ch...
import sys n = int(input()) change, m = 0, 0 s, t = -pow(10, 8), pow(10, 8) ar = [] rat, div = [], [] for i in range(n): c, d = map(int, input().split(" ")) div.append(d) ar.append(c) if d == 1: s = max(s, 1900) else: t = min(t, 1899) if s > t: print("Impossible") ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR NUMBER NUMBER FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR V...
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating ch...
k = 9**9 t = [0, k, k] for i in range(int(input())): c, d = map(int, input().split()) d = 3 - 2 * d t[d] = min(t[d], t[0] * d) t[0] += c s, a, b = t print("Infinity" if b == k else "Impossible" if a != k and a + b < 1 else 1899 + s + b)
ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST NUMBER VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER VAR ASSIGN VAR VAR VAR VAR EXPR FUNC_...
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating ch...
n = int(input()) events = [] for line in range(n): c, d = map(int, input().split()) events.append((c, d)) if events[0][1] == 1: lb = 1900 ub = float("inf") else: lb = float("-inf") ub = 1899 def normalise_into(div): global lb, ub if div == 1 and lb < 1900: lb = 1900 if div ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FUNC_DEF IF VAR NUMBER VAR ...
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating ch...
n = int(input()) I = lambda: map(int, input().split()) t1 = 0 t2 = 0 j = 0 for _ in range(n): x, y = I() if y == 1: if t1 == 0: mi = j else: mi = min(mi, j) t1 += 1 else: if t2 == 0: ma = j else: ma = max(ma, j) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR ASS...
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating ch...
import sys sys.setrecursionlimit(5000000) def read(type=int): return type(input()) def read_arr(type=int): return [type(token) for token in input().split()] def abs(num): return num if num > 0 else -num inf = 10**9 c = 1899 u, l = inf, -inf diff = 0 n = read() A = [] for i in range(n): r, d = r...
IMPORT EXPR FUNC_CALL VAR NUMBER FUNC_DEF VAR RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF VAR RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN VAR NUMBER VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VA...
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating ch...
def check(rating): r = rating for i in l: if rating <= 1899 and i[1] == 1: return "1" if rating >= 1900 and i[1] == 2: return "2" rating += i[0] nl.append(rating) return "1" n = int(input()) seen = set() l = [] for i in range(n): c, d = map(int, inpu...
FUNC_DEF ASSIGN VAR VAR FOR VAR VAR IF VAR NUMBER VAR NUMBER NUMBER RETURN STRING IF VAR NUMBER VAR NUMBER NUMBER RETURN STRING VAR VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR F...
Numbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows: * F(k, n) = 0, for integer n, 1 ≤ n < k; * F(k, k) = 1; * F(k, n) = F(k, n - 1) + F(k, n - 2) + ... + F(k, n - k), for integer n, n > k. Note that we determine the k-bonacci numbers, F(k, n), on...
[s, k] = [int(x) for x in input().split()] numbers = [1] numbers.append(1) last = 1 index = 1 while last <= s: l_index = index - k if l_index >= 0: last = last * 2 - numbers[l_index] else: last *= 2 if last <= s: numbers.append(last) index += 1 numbers.reverse() numbers.appen...
ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL ...
Numbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows: * F(k, n) = 0, for integer n, 1 ≤ n < k; * F(k, k) = 1; * F(k, n) = F(k, n - 1) + F(k, n - 2) + ... + F(k, n - k), for integer n, n > k. Note that we determine the k-bonacci numbers, F(k, n), on...
s, k = list(map(int, input().split(" "))) a = [0, 1, 1] while a[-1] < s: if len(a) < k: a.append(sum(a)) else: t = 0 for i in range(k): t += a[-i - 1] a.append(t) if s == a[-1]: print(2) print(0, a[-1]) else: use = [] for i in range(len(a)): if...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST NUMBER NUMBER NUMBER WHILE VAR NUMBER VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_C...
Numbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows: * F(k, n) = 0, for integer n, 1 ≤ n < k; * F(k, k) = 1; * F(k, n) = F(k, n - 1) + F(k, n - 2) + ... + F(k, n - k), for integer n, n > k. Note that we determine the k-bonacci numbers, F(k, n), on...
s, k = map(int, input().split()) fib = [0, 1] for i in range(80): g = 0 for x in range(k): if len(fib) - x - 1 < 0: break g += fib[len(fib) - x - 1] fib.append(g) ans = [] for x in reversed(fib): if x <= s: s -= x ans.append(x) print(len(ans)) print(" ".join(s...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL...
Numbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows: * F(k, n) = 0, for integer n, 1 ≤ n < k; * F(k, k) = 1; * F(k, n) = F(k, n - 1) + F(k, n - 2) + ... + F(k, n - k), for integer n, n > k. Note that we determine the k-bonacci numbers, F(k, n), on...
s, k = [int(i) for i in input().split()] a = [-1, 0, 1, 1] i = 3 while a[i] <= pow(10, 9): i += 1 a.append(0) if i <= k: for j in range(1, i): a[i] += a[j] else: for j in range(i - k, i): a[i] += a[j] b = [] for j in range(i, 0, -1): if a[j] <= s: b.ap...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR FUNC_CALL VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR A...
Numbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows: * F(k, n) = 0, for integer n, 1 ≤ n < k; * F(k, k) = 1; * F(k, n) = F(k, n - 1) + F(k, n - 2) + ... + F(k, n - k), for integer n, n > k. Note that we determine the k-bonacci numbers, F(k, n), on...
s, k = map(int, input().split()) f = [0] f.append(1) while True: cur = sum(f[-k:]) if cur > s: break f.append(cur) f = list(set(f)) f.sort() ans = [] i = len(f) - 1 while s and i > 0: if f[i] <= s: s -= f[i] ans.append(f[i]) i -= 1 print(len(ans) + 1) print(*(ans + [0]))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER EXPR FUNC_CALL VAR NUMBER WHILE NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR...
Numbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows: * F(k, n) = 0, for integer n, 1 ≤ n < k; * F(k, k) = 1; * F(k, n) = F(k, n - 1) + F(k, n - 2) + ... + F(k, n - k), for integer n, n > k. Note that we determine the k-bonacci numbers, F(k, n), on...
s, k = map(int, input().split()) a, b = [0, 1], [] while a[-1] < s: a.append(sum(a[-k:])) for i in reversed(a): if i <= s: b.append(i) s -= i print(len(b)) print(" ".join(map(str, b)))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST NUMBER NUMBER LIST WHILE VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR
Numbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows: * F(k, n) = 0, for integer n, 1 ≤ n < k; * F(k, k) = 1; * F(k, n) = F(k, n - 1) + F(k, n - 2) + ... + F(k, n - k), for integer n, n > k. Note that we determine the k-bonacci numbers, F(k, n), on...
def genkbon(s, k): if k < 50: i = 0 res = [0] while res[i] <= s: if i < k: res.append(0) elif i == k: res.append(1) elif i == k + 1: res.append(1) else: res.append(2 * res[i] - res...
FUNC_DEF IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER WHILE VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR VAR VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER RETURN VAR IF VAR NUMBER...
Numbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows: * F(k, n) = 0, for integer n, 1 ≤ n < k; * F(k, k) = 1; * F(k, n) = F(k, n - 1) + F(k, n - 2) + ... + F(k, n - k), for integer n, n > k. Note that we determine the k-bonacci numbers, F(k, n), on...
s, k = list(map(int, input().split())) a = [1] i = 0 while s > a[-1]: if i == 0: a.append(1) else: a.append(2 * a[-1] - int(a[-k - 1] if i >= k else 0)) i += 1 b = [] s0 = s while s > 0: l, r = -1, i + 1 while r - l > 1: m = (l + r) // 2 if a[m] >= s: r = ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER WHILE VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR WHI...
Numbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows: * F(k, n) = 0, for integer n, 1 ≤ n < k; * F(k, k) = 1; * F(k, n) = F(k, n - 1) + F(k, n - 2) + ... + F(k, n - k), for integer n, n > k. Note that we determine the k-bonacci numbers, F(k, n), on...
x, y = map(int, input().split()) dp = [] dp.append(0) dp.append(1) n = 2 while 1: sm = 0 for k in range(n - 1, n - y - 1, -1): if k == 0: break sm += dp[k] if sm > x: break dp.append(sm) n += 1 dp.reverse() res = [] n = 0 while n < len(dp) and x >= 0: if x >= ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF VAR NUMBER VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER...
Numbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows: * F(k, n) = 0, for integer n, 1 ≤ n < k; * F(k, k) = 1; * F(k, n) = F(k, n - 1) + F(k, n - 2) + ... + F(k, n - k), for integer n, n > k. Note that we determine the k-bonacci numbers, F(k, n), on...
s, k = map(int, input().split()) f = [1] while f[-1] < s: x = 0 for i in range(max(0, len(f) - k), len(f)): x += f[i] f.append(x) result = [0] pos = len(f) - 1 while s != 0: while f[pos] > s: pos -= 1 result.append(f[pos]) s -= f[pos] print(len(result)) print(" ".join(map(str, re...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER WHILE VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR ...
Numbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows: * F(k, n) = 0, for integer n, 1 ≤ n < k; * F(k, k) = 1; * F(k, n) = F(k, n - 1) + F(k, n - 2) + ... + F(k, n - k), for integer n, n > k. Note that we determine the k-bonacci numbers, F(k, n), on...
def power(a, b): if b == 0: return 1 elif b % 2 == 0: a_1 = a * a return pow(a_1, b // 2) return a * pow(a, b - 1) def k_fib(s, k): result = [0] if k >= 40: fibs = [power(2, i) for i in range(40)] else: fibs = [0] * (k - 1) + [1] while fibs[len(f...
FUNC_DEF IF VAR NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR LIST NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP ...
Numbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows: * F(k, n) = 0, for integer n, 1 ≤ n < k; * F(k, k) = 1; * F(k, n) = F(k, n - 1) + F(k, n - 2) + ... + F(k, n - k), for integer n, n > k. Note that we determine the k-bonacci numbers, F(k, n), on...
def s(): [s, k] = list(map(int, input().split())) d = [0] d.append(1) t = 0 r = [] while t < s: t = sum(d[-min(k, len(d)) :]) d.append(t) for i in reversed(d): if i <= s: s -= i r.append(i) if i == 0: break print...
FUNC_DEF ASSIGN LIST VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR ...
Numbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows: * F(k, n) = 0, for integer n, 1 ≤ n < k; * F(k, k) = 1; * F(k, n) = F(k, n - 1) + F(k, n - 2) + ... + F(k, n - k), for integer n, n > k. Note that we determine the k-bonacci numbers, F(k, n), on...
s, k = map(int, input().split()) if k >= 32: k_bon = [0] for i in range(33): k_bon.append(2**i) else: k_bon = [0] * (k - 1) k_bon.append(1) i = k + 1 c = 0 while len(k_bon) <= 100: next = sum(k_bon[c:i]) k_bon.append(next) i += 1 c += 1 k_bon = set(k_b...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER ASSIGN V...
Numbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows: * F(k, n) = 0, for integer n, 1 ≤ n < k; * F(k, k) = 1; * F(k, n) = F(k, n - 1) + F(k, n - 2) + ... + F(k, n - k), for integer n, n > k. Note that we determine the k-bonacci numbers, F(k, n), on...
import sys input = sys.stdin.readline def sep(): return map(int, input().split()) def main(): s, k = sep() a = [0, 1] ans = [] while a[-1] < s: a.append(sum(a[-k:])) a.reverse() for i in a: if i <= s: ans.append(i) s -= i print(len(ans)) p...
IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST WHILE VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FU...
Numbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows: * F(k, n) = 0, for integer n, 1 ≤ n < k; * F(k, k) = 1; * F(k, n) = F(k, n - 1) + F(k, n - 2) + ... + F(k, n - k), for integer n, n > k. Note that we determine the k-bonacci numbers, F(k, n), on...
s, k = map(int, input().split()) F = [0, 1] b = set() while True: f = sum(F[-k:]) if f > s: break F.append(f) for i in reversed(F): if i <= s: b.add(i) s -= i print(len(b)) print(" ".join(map(str, b)))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR WHILE NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC...
Numbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows: * F(k, n) = 0, for integer n, 1 ≤ n < k; * F(k, k) = 1; * F(k, n) = F(k, n - 1) + F(k, n - 2) + ... + F(k, n - k), for integer n, n > k. Note that we determine the k-bonacci numbers, F(k, n), on...
s, k = map(int, input().split()) p, t, l = [0], [0, 1, 1], 2 while t[l] < s: t.append((t[l] << 1) - (0 if l < k else t[l - k])) l += 1 t.reverse() for i in t: if i > s: continue p.append(i) s -= i if s == 0: break print(len(p)) print(" ".join(map(str, p)))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR LIST NUMBER LIST NUMBER NUMBER NUMBER NUMBER WHILE VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER E...
Numbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows: * F(k, n) = 0, for integer n, 1 ≤ n < k; * F(k, k) = 1; * F(k, n) = F(k, n - 1) + F(k, n - 2) + ... + F(k, n - k), for integer n, n > k. Note that we determine the k-bonacci numbers, F(k, n), on...
s, k = map(int, input().split()) arr = [0, 1] k1 = 1 visited = [] mini = 0 while arr[-1] < s: arr.append(sum(arr[-k:])) while s > 0: for i in arr: if i <= s: mini = i else: break s -= mini visited.append(mini) if len(visited) == 1: visited.append(0) print(len(...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR WHILE VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR ...
Numbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows: * F(k, n) = 0, for integer n, 1 ≤ n < k; * F(k, k) = 1; * F(k, n) = F(k, n - 1) + F(k, n - 2) + ... + F(k, n - k), for integer n, n > k. Note that we determine the k-bonacci numbers, F(k, n), on...
import sys input = sys.stdin.readline s, k = map(int, input().split()) ans = [] if k >= 60: f = [0, 1] x = 1 for i in range(60): f.append(x) x += x for i in range(60)[::-1]: if s >= f[i]: ans.append(f[i]) s -= f[i] if s == 0: b...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST IF VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR IF 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_...
def main(): n, r, avg = map(int, input().split()) exams = [] total = 0 for i in range(n): a, b = map(int, input().split()) exams.append((a, b)) total += a if total / n >= avg: print(0) return exams = sorted(exams, key=lambda x: x[1]) ans = 0 for i ...
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 EXPR FUNC_CALL VAR VAR VAR VAR VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASS...
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(" ")) grade = [] sumIp = 0 for i in range(n): grade.append([int(item) for item in input().split(" ")]) sumIp += grade[i][0] grade.sort(key=takeSecond) i = 0 aimSum = avg * n essays = 0 points = 0 while sumIp < aimSum ...
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER 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_...
__author__ = "PrimuS" n, r, a = (int(x) for x in input().split()) marks = [[0, 0]] * n s = 0 for i in range(n): ss = input() marks[i] = [int(x) for x in ss.split()] s += marks[i][0] if s / n >= a: print(0) else: x = a * n - s def ccmp(b): return b[1] marks.sort(key=ccmp) i = 0 ...
ASSIGN VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST LIST NUMBER NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC_CALL 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, avg = map(int, input().split()) x = [] s = 0 for i in range(n): a, b = map(int, input().split()) s += a x.append((a, b)) rem = avg * n - s x.sort(key=lambda i: i[1]) i = 0 count = 0 while rem > 0: if x[i][0] < r: v = min(rem, r - x[i][0]) count += v * x[i][1] rem -= v 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 VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER 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_...
n, r, avg = map(int, input().split()) lst = [] c = 0 for i in range(n): lst.append(list(map(int, input().split()))) def aver(li): s = sum(x for x, y in li) return s / len(lst) if aver(lst) < avg: lst = sorted(lst, key=lambda x: x[1]) x = avg * len(lst) - sum(k for k, p in lst) for f, s in ls...
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 FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR RETURN BIN_OP VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR 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()) arr, s = [], 0 for i in range(n): arr.append(list(map(int, input().split()))) s += arr[-1][0] arr = sorted(arr, key=lambda x: x[1]) res = 0 for i in range(n): if min(n * avg - s, r - arr[i][0]) > 0: res += min(n * avg - s, r - arr[i][0]) * arr[i][1] s +=...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST 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 FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR BIN_OP 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_...
line = input().split(" ") n = int(line[0]) r = int(line[1]) avg = int(line[2]) class Exam: def __init__(self, a, b): self.a = a self.b = b def __repr__(self): return repr((self.a, self.b)) i = 0 s = 0 lst = [] while i < n: line = input().split(" ") a = int(line[0]) b = ...
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 CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR ASSIGN VAR 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()) goal = n * avg essay = 0 V = [] for i in range(n): a, b = map(int, input().split()) goal -= a V.append([b, a]) V.sort() goal = [0, goal][goal > 0] for j in V: if not goal: break else: m = min(r - j[1], goal) essay += j[0] * m goal...
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 EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER VAR VAR NUMBER FOR VAR VAR 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_...
n, r, a = [int(x) for x in input().split()] exams = [] grades = 0 essays = 0 for i in range(n): grade, essay = [int(x) for x in input().split()] grades += grade exams.append([grade, essay]) if grades >= n * a: print(0) else: exams.sort(key=lambda x: x[1]) needs = n * a - grades while needs >...
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 VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR IF VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR 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()) ab = [0] * n for i in range(n): a, b = map(int, input().split()) ab[i] = b, a ab.sort() summ = avg * n summ1 = 0 res = 0 for i in range(n): summ1 += ab[i][1] for i in range(n): dif = summ - summ1 now = r - ab[i][1] if dif <= 0: break if now >= di...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR 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 = list(map(int, input().split())) notas = [list(map(int, input().split()))[::-1] for x in range(n)] notas.sort() i = 0 soma = [sum(i) for i in zip(*notas)][1] essays = 0 while soma < avg * n and i < n: dif = r - notas[i][1] precisa = avg * n - soma if dif > precisa: dif = precisa if di...
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR VAR VAR VAR ASS...
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 = sorted([list(map(int, input().split())) for i in range(n)], key=lambda x: x[1]) goal = avg * n current = sum([exam[0] for exam in exams]) essays = 0 if current < goal: for exam in exams: a, b = exam points = r - a if current + points <= goal: ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER IF VAR VAR FOR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR 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_...
def exponent_mod(n, p, prime_const=1000000000 + 7): res = 1 if n == 0: return 0 while p > 0: if p % 2 == 1: res = res * n % prime_const p //= 2 n = n * n % prime_const return res def find_min_essays(n, r, avg, essays): times = 0 count = 0 s = 0 ...
FUNC_DEF BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER IF VAR NUMBER RETURN NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR 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_...
import time n, r, avg = (int(i) for i in input().split()) exams = [] ref = 0 for i in range(n): a, b = (int(i) for i in input().split()) exams.append([r - a, b]) start = time.time() add = (avg - r) * n + sum(i[0] for i in exams) if add > 0: exams = sorted(exams, key=lambda x: x[::-1]) ref = 0 for i...
IMPORT 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 EXPR FUNC_CALL VAR LIST BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR FUNC_CALL VAR 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, a = map(int, input().split()) ab = [] for i in range(n): ab.append(list(map(int, input().split()))) def f(v): return v[1] ab.sort(key=f) a *= n for i in ab: a -= i[0] if a <= 0: print(0) else: i = 0 ct = 0 while a != 0: if r - ab[i][0] <= a: ct += (r - ab[i][0])...
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 FUNC_DEF RETURN VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR FOR VAR VAR VAR VAR NUMBER IF VAR NUMBER 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()) exam = [] need_score = n * avg ret = 0 for _ in range(n): a, b = map(int, input().split()) need_score -= a if a == r: continue else: exam.append([b, r - a]) exam.sort(key=lambda x: x[0]) for e in exam: if need_score <= 0: break cnt = ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER 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 EXPR FUNC_CALL VAR VAR NUMBER FOR VAR VAR IF 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()) lst = [[0, 0]] * n score = 0 for x in range(n): lst[x] = list(map(int, input().split())) score += lst[x][0] lst.sort(key=lambda x: x[1]) scoreRequird = n * avg - score essays = 0 i = 0 while scoreRequird > 0 and i < len(lst): if lst[i][0] < r: increment = min(r ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST LIST NUMBER NUMBER VAR 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 VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER 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_...
import sys def read(line): return [int(c) for c in line.strip().split()] def main(): test = sys.stdin.readlines() n, r, avg = read(test[0]) grades = [read(test[i]) for i in range(1, n + 1)] grades.sort(key=lambda x: x[1]) cur_sum = sum(g[0] for g in grades) required_sum = avg * len(grade...
IMPORT FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR 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()) s = 0 l = [] for i in range(n): a, b = map(int, input().split()) l.append([b, a]) s += a l.sort() z = s yo = n * avg - z if yo <= 0: print(0) exit() ans = 0 for i in range(n): b, a = l[i] if r - a > yo: ans += yo * b yo = 0 break ...
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 EXPR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL 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 f(): n, r, t = map(int, input().split()) t, p = t * n, {} s = k = 0 for i in range(n): a, b = map(int, input().split()) s += a if a == r: continue p[b] = p.get(b, 0) + r - a if s < t: for b in sorted(p.keys()): d = p[b] ...
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR VAR DICT ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR IF VAR VAR 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_...
inp = [int(x) for x in input().split()] n = inp[0] r = inp[1] avg = inp[2] exams = [[int(x) for x in input().split()] for x in range(n)] exams.sort(key=lambda x: x[1]) examsSum = 0 for x in exams: examsSum += x[0] missingPoints = avg * n - examsSum assigments = 0 i = 0 while missingPoints > 0: if r == exams[i][...
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 FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR 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 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_...
n, r, avg = map(int, input().split()) arr = [] summ = 0 for i in range(n): a, b = map(int, input().split()) summ += a arr.append([a, b]) need = n * avg - summ if need == 0: print(0) else: ans1 = 0 arr = sorted(arr, key=lambda x: x[1]) for i in range(n): if arr[i][0] < r and need > 0:...
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 ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER 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, avg = map(int, input().split()) l = [] s = 0 for i in range(n): k = [] a, b = map(int, input().split()) s += a k.append(b) k.append(a) l.append(k) lp = avg * n - s l.sort() i = 0 nes = 0 while lp > 0: slp = r - l[i][1] mi = min(lp, slp) nes += mi * l[i][0] lp -= mi 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 LIST ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR EXPR 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_...
t = input().split() n = int(t[0]) r = int(t[1]) avg = int(t[2]) a = [] for i in range(n): a.append(input().split()) t = int(a[i][0]) a[i][0] = int(a[i][1]) a[i][1] = t a = sorted(a) ref = 0 new = 0 for i in range(n): new += a[i][1] new /= n i = 0 while new < avg and i < n: x = min(r - a[i][1], r...
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 VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER 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_...
import sys n, r, avg = map(int, sys.stdin.readline().split()) arr = [] for i in range(n): x, y = map(int, sys.stdin.readline().split()) arr.append([y, x]) s = 0 for i in range(n): s += arr[i][1] if s >= avg * n: print(0) else: grades_needed = avg * n - s arr.sort() ans = 0 i = 0 whi...
IMPORT 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF VAR BIN_OP VAR VAR EXPR FUNC_CALL 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, p = map(int, input().split()) t = [] for i in range(n): t.append(list(map(int, input().split()))) def func(n): return n[1] t = sorted(t, key=func) s = 0 e = 0 for i in range(len(t)): s += t[i][0] for i in t: if s >= p * n: break if i[0] < r: if s + r - i[0] < p * n: ...
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 FUNC_DEF RETURN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR 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_...
line = input().split() n, r, avg = int(line[0]), int(line[1]), int(line[2]) exams = [] total, to_add, points = avg * n, avg * n, 0 for i in range(n): ex = input().split() exams.append((int(ex[0]), int(ex[1]))) exams = sorted(exams, key=lambda t: t[1]) for exam in exams: to_add -= exam[0] if to_add > 0: ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR ...
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()) m = [] for i in range(n): g = list(map(int, input().split())) m.append(g) total = avg * n marks = 0 for i in range(n): marks += m[i][0] req = total - marks if req <= 0: print(0) else: b = [] for i in range(n): b.append(m[i][1]) a = [0] * (max(b) ...
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 VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF 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 = [tuple(map(int, input().split())) for _ in range(n)] arr.sort(key=lambda x: x[1]) diff = n * avg - sum([x[0] for x in arr]) c = 0 if diff > 0: for i in range(n): x = min(diff, r - arr[i][0]) c += x * arr[i][1] diff -= x if diff == 0: ...
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 EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL 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_...
n, r, avg = map(int, input().split()) total = 0 exams = [] for i in range(n): score, cost = map(int, input().split()) total += score exams.append((cost, score)) need = n * avg - total result = 0 exams.sort() for cost, score in exams: if need <= 0: break x = min(need, r - score) result +=...
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 VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR FOR VAR VAR VAR IF VAR NUMBER ASS...
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, mi = map(int, input().split()) l = [] t = 0 k = 0 for i in range(n): a, b = map(int, input().split()) if r - a > 0: l.append([b, r - a]) t = t + a if r - a <= 0: t = t + a V = mi * n - t l = sorted(l) for x in l: if V > 0: k = k + min(V, x[1]) * x[0] V = V -...
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 IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER ASSIG...
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_...
ab = [] total_a = 0 points = 0 n, r, avg = [int(_) for _ in input().split()] for _ in range(n): a, b = [int(_) for _ in input().split()] ab.append((a, b)) total_a = total_a + a avg_a = total_a // n if avg <= avg_a: print(0) exit(0) else: points = avg * n - total_a ab = sorted(ab, key=lambda x: x...
ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR EXPR FUNC_CALL 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_...
def solve(n, r, avg, grades): grades.sort(key=lambda x: (x[1], x[0])) vanyas = sum(a for a, b in grades) remaining = avg * n - vanyas written = 0 for a, b in grades: if remaining <= 0: break else: win = int(min(r - a, remaining)) written += b * win...
FUNC_DEF EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR RETURN VAR NUMBER VAR NUMBER FUNC_DEF ASSIGN VAR VAR VAR 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 = list(map(int, input().rstrip().split())) sub = [] mark = 0 for i in range(n): x, y = list(map(int, input().rstrip().split())) sub.append([x, y]) mark += x marks = avg * n sub.sort(key=lambda x: x[1]) i = 0 ans = 0 while mark < marks: x = min(marks - mark, r - sub[i][0]) mark += x ans...
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR 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 VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR 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()) t = avg * n l = [] num = 0 ans = 0 for i in range(n): a, b = map(int, input().split()) num += a l.append((b, r - a)) l = sorted(l) i = 0 while num < t: left = t - num tmp = min(left, l[i][1]) ans += tmp * l[i][0] num += tmp i += 1 print(ans)
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 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 BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN 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_...
def main(): n, r, avg = map(int, input().split()) need = avg * n d = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x: x[1]) cur = sum(x[0] for x in d) ret = 0 left = need - cur if left <= 0: return 0 for x in d: can = min(r - x[0], left) r...
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER RETURN 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_...
import sys sys.setrecursionlimit(10**8) try: FILE_POINTER = open("input.inpt") input = FILE_POINTER.readline except: FILE_POINTER = None input = sys.stdin.readline n, r, av = list(map(int, input().strip().split())) grades = [] curr = 0 for i in range(n): grades.append(list(map(int, input().strip()....
IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR NONE ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL 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...
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_...
array = list(map(int, input().rstrip().split())) n = array[0] r = array[1] avg = array[2] minmmarks = n * avg marks = 0 List = [] for i in range(n): ab = list(map(int, input().rstrip().split())) marks += ab[0] ab.reverse() List += [ab] if marks >= minmmarks: print(0) else: required = minmmarks -...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR 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_...
n, r, avg = map(int, input().split()) avg *= n a = [0] * 1000001 b = [0] * 1000001 av = 0 for i in range(n): c, d = map(int, input().split()) av += c a[d] += c b[d] += 1 es = 0 for i in range(1000001): if av < avg and b[i] > 0: es += min(b[i] * r - a[i], avg - av) * i av += min(b[i] ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL 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_...
def main(): n, r, a = map(int, input().split()) a *= n tab = [] for x in range(n): ga, b = map(int, input().split()) tab.append((ga, b)) a -= ga if a <= 0: print(0) return tab.sort(key=lambda x: x[1]) inc = 0 for x in range(n): if a - (r - ...
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR 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 VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER 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_...
from sys import stdin, stdout class Grade: a, b = 0, 0 def __lt__(self, other): return self.b < other.b n, r, avg = map(int, stdin.readline().split()) grade, add, cnt = [Grade() for i in range(n)], 0, 0 for i in range(n): grade[i].a, grade[i].b = map(int, stdin.readline().split()) add += gr...
CLASS_DEF ASSIGN VAR VAR NUMBER NUMBER FUNC_DEF RETURN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIG...
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 = [int(x) for x in input().split()] m = [[int(x) for x in input().split()] for _ in range(n)] m.sort(key=lambda x: x[1]) s = n * a l = sum(m[i][0] for i in range(n)) c = 0 for j in range(n): if l + r - m[j][0] < s: c += (r - m[j][0]) * m[j][1] l += r - m[j][0] else: c += max(s - ...
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 EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP 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_...
import sys input = sys.stdin.readline def multi_input(): return map(int, input().split()) def array_print(arr): print(" ".join(map(str, arr))) total = ans = 0 marks = [] n, r, avg = multi_input() req_total = n * avg for i in range(n): a, b = multi_input() total += a marks.append([a, b]) marks...
IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR 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 = list(map(int, input().split())) score = [] total = 0 for i in range(n): a, b = list(map(int, input().split())) score.append((b, a)) total += a need_point = max(0, avg * n - total) score.sort() ans = 0 for b, a in score: if need_point == 0: break if a < r: ans += b * min(r...
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 EXPR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL 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, avg = map(int, input().split()) l = [] grade = 0 for i in range(n): a, b = map(int, input().split()) l.append([b, a]) grade += a reqd = n * avg - grade if reqd < 1: print(0) exit() l.sort() i = 0 ans = 0 while reqd > 0: if reqd > r - l[i][1]: ans += l[i][0] * (r - l[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 LIST 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 EXPR 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()) avg *= n l = [] s = 0 for i in range(n): a, b = map(int, input().split()) s += a l.append((b, a)) l = sorted(l) req = 0 i = 0 while i < n and s < avg: take = min(r - l[i][1], avg - s) s += take req += take * l[i][0] i += 1 print(req)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR 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 VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR ASSIGN VAR 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_...
__author__ = "Rakshak.R.Hegde" n, r, avg = map(int, input().split()) ab = [] d = n * avg for i in range(n): a, b = map(int, input().split()) d -= a ab.append((b, a)) ab.sort() cost = 0 for t in ab: if d <= 0: break if t[1] < r: m = min(d, r - t[1]) cost += m * t[0] d ...
ASSIGN VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR 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 VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER IF VAR NUMBER 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()) lst = [] ans = 0 s = n * avg for i in range(n): x = input().split() lst.append([int(x[1]), int(x[0])]) s -= int(x[0]) lst.sort() for j in lst: if s <= 0: break tem = min(s, r - j[1]) ans += tem * j[0] s -= tem print(ans)
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 FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FOR VAR VAR IF 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, a = map(int, input().split(" ")) s = 0 arr = [] for _ in range(n): u, v = map(int, input().split(" ")) if u < r: arr.append([u, v]) s = s + u x = n * a - s if x <= 0: ans = 0 else: ans = 0 arr.sort(key=lambda x: x[1]) for item in arr: if r - item[0] < x: ans...
ASSIGN VAR VAR VAR FUNC_CALL 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 FUNC_CALL FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR NUMBER 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_...
__author__ = "Ekaterina" n, r, avg = (int(m) for m in input().split()) exams = [] for i in range(n): input_i = [int(m) for m in input().split()] exams.append([input_i[1], input_i[0]]) exams.sort() current_sum = exams[0][1] works_to_do = 0 for x in range(1, n): current_sum += exams[x][1] needed_points = avg ...
ASSIGN VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL 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_...
n, r, avg = map(int, input().split()) a = [] for i in range(n): p, q = map(int, input().split()) a.append((q, p)) def sortFirst(val): return val[0] a.sort(key=sortFirst) jog = 0 for i in range(n): jog += a[i][1] k = n * avg - jog if k <= 0: print(0) else: ans = 0 x = 0 for i in range...
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 FUNC_DEF RETURN VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP 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_...
N, R, avg = map(int, input().split()) q = [] ttla = 0 for i in range(N): a, b = map(int, input().split()) ttla += a q.append((b, R - a)) rest = N * avg - ttla q.sort() ans = 0 for cost, times in q: if rest <= 0: break if rest < times: ans += cost * rest rest = 0 else: ...
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 BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR 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_...
def mergesort(arr, sup): if len(arr) > 1: mid = len(arr) // 2 left = arr[:mid] right = arr[mid:] leftsup = sup[:mid] rightsup = sup[mid:] mergesort(left, leftsup) mergesort(right, rightsup) i = j = k = 0 while i < len(left) and j < len(right): ...
FUNC_DEF IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN 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 = [int(i) for i in input().split()] li = [] for i in range(n): tmp = [int(i) for i in input().split()] li.append([tmp[1], tmp[0]]) li.sort(reverse=True) dis = avg * n - sum([i[1] for i in li]) ans = 0 while dis > 0: exam = li.pop() if dis <= r - exam[1]: ans += exam[0] * dis di...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR 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 = [int(x) for x in input().split()] l = [] for i in range(n): l.append([int(x) for x in input().split()][::-1]) l.sort() need = avg * n have = sum(x[1] for x in l) ans = 0 for a, b in l: ans += max(min(need - have, r - b), 0) * a have += max(min(need - have, r - b), 0) print(ans)
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 NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR BIN_OP 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_...
sm = 0 n, r, avg = map(int, input().split()) marks = [] for i in range(n): a, b = map(int, input().split()) marks.append([a, b]) sm += a req = avg * n - sm cost = 0 if req <= 0: print(0) exit() marks.sort(key=lambda x: x[1]) for i in range(n): if marks[i][0] >= r: continue if req == ...
ASSIGN VAR NUMBER 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 VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR 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()) arr = [] k = 0 for i in range(n): a, b = map(int, input().split()) arr.append([a, b]) diff = avg * n - sum(i[0] for i in arr) if diff <= 0: print(k) else: arr = sorted(arr, key=lambda x: x[1]) for i in arr: if diff == 0: break else: ...
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 ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR IF VAR NUMBER EXPR FUNC_CALL 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 def In(): return map(int, sys.stdin.readline().split()) def exams(): n, r, avg = In() req = n * avg tol = 0 l = [] for _ in range(n): new, m = In() l.append([new, m]) tol += new if tol > req: return 0 l.sort(key=lambda x: x[1]) ans = 0 ...
IMPORT FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR 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 EXPR FUNC_CALL VAR LIST VAR VAR VAR VAR IF VAR VAR RETURN NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASS...
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()) cost_mark = [] for _ in range(n): mark, cost = map(int, input().split()) cost_mark += [[cost, mark]] cost_mark = sorted(cost_mark) current_sum = sum([x[1] for x in cost_mark]) needed_sum = max(n * avg - current_sum, 0) needed_essays = 0 for cost, mark in cost_mark: if n...
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 VAR LIST LIST VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN ...