description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
This problem is actually a subproblem of problem G from the same contest.
There are $n$ candies in a candy box. The type of the $i$-th candy is $a_i$ ($1 \le a_i \le n$).
You have to prepare a gift using some of these candies with the following restriction: the numbers of candies of each type presented in a gift shou... | for _ in range(int(input())):
n = int(input())
lis = [0] * (n + 2)
li = [*map(int, input().split())]
for i in li:
lis[i] += 1
lis.sort(reverse=True)
k = lis[0]
s = k
i = 1
while k > 0:
k = min(lis[i], k - 1)
s += k
i += 1
print(s) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ... |
This problem is actually a subproblem of problem G from the same contest.
There are $n$ candies in a candy box. The type of the $i$-th candy is $a_i$ ($1 \le a_i \le n$).
You have to prepare a gift using some of these candies with the following restriction: the numbers of candies of each type presented in a gift shou... | import sys
t = int(input())
for _ in range(t):
n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
d = {}
for i in a:
d[i] = d.get(i, 0) + 1
b = sorted(list(d.values()))
ans = b[-1]
ans1 = b[-1]
for i in range(len(b) - 2, -1, -1):
ans1 = min(an... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN ... |
This problem is actually a subproblem of problem G from the same contest.
There are $n$ candies in a candy box. The type of the $i$-th candy is $a_i$ ($1 \le a_i \le n$).
You have to prepare a gift using some of these candies with the following restriction: the numbers of candies of each type presented in a gift shou... | for i in range(int(input())):
mmm = {}
n = int(input())
for a in map(int, input().split()):
if a not in mmm:
mmm[a] = 1
else:
mmm[a] += 1
s = 0
items = sorted(mmm.items(), key=lambda x: -x[1])
_max = 99999999999999999999999
for i in items:
if _... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER ASSIG... |
This problem is actually a subproblem of problem G from the same contest.
There are $n$ candies in a candy box. The type of the $i$-th candy is $a_i$ ($1 \le a_i \le n$).
You have to prepare a gift using some of these candies with the following restriction: the numbers of candies of each type presented in a gift shou... | q = int(input())
for _ in range(q):
freq = {}
n = int(input())
arr = [int(i) for i in input().strip().split(" ")]
for i in arr:
if freq.get(i) == None:
freq[i] = 1
else:
freq[i] += 1
k = sorted(list(freq.values()), reverse=True)
m = 90000000000000
ans ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING FOR VAR VAR IF FUNC_CALL VAR VAR NONE ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VA... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | for T in range(int(input())):
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
P = 0
RQ = A[0] * N - sum(A)
AV = 0
MK = 0
if RQ > 0:
for i in range(1, N):
RQ -= (N - i) * (A[i - 1] - A[i])
AV += A[i - 1]
MK += 1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | for i in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
if len(set(a)) == 1:
print("0")
else:
add = sum(a)
a.sort()
big = 0
ans = n
while True:
big += a.pop()
ans -= 1
if add - big >= a[-1] * a... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE NUMBER VA... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | tc = int(input())
for TC in range(tc):
n = int(input())
l = list(map(int, input().split()))
l.sort()
dup = [0]
for i in range(1, n):
dup.append(dup[i - 1] + (l[i] - l[i - 1]) * i)
prev = 0
ans = 0
if dup[-1] == 0:
ans = 0
else:
prev = l[-1]
ans += 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR VAR ... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | for i in range(int(input())):
n = int(input())
a = [int(x) for x in input().split()]
a.sort()
ps = []
ss = []
s = 0
for i in a:
s += i
ps.append(s)
s1 = 0
for i in a[::-1]:
s1 += i
ss.append(s1)
ss = ss[::-1]
r = set(a)
if len(r) == 1:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VA... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | for _ in range(int(input())):
initial_pop = int(input())
coins = [int(num) for num in input().split()]
coins.sort()
coins_sum = sum(coins)
for current_pop in range(initial_pop, 0, -1):
coins_current = coins[current_pop - 1]
if coins_current == coins[0] or coins_current <= coins_sum /... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR BIN_OP VAR VAR EXPR FUNC_CALL V... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | for _ in range(int(input())):
n = int(input())
l = sorted(list(map(int, input().split())), reverse=True)
if l[0] == l[n - 1]:
print(0)
else:
b, a = sum(l), 0
for i in range(n):
a += l[i]
b -= l[i]
if l[i + 1] * (n - 1 - i) <= b + a:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | m = int(input())
r = [0] * m
for i in range(m):
n = int(input())
a = list(map(int, input().split()))
a.sort()
b = [0] * n
for j in range(1, n):
b[j] = (a[j] - a[j - 1]) * j + b[j - 1]
t = 0
j = n - 1
while t < b[j]:
t = t + a[j]
j = j - 1
r[i] = n - 1 - j
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP BIN_OP ... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
rs = lambda: input()
def solve():
n = ri()
a = rl()
s = sum(a)
a.sort(reverse=True)
ans = 0
for i in range(n):
if s >= a[i] * (n - i):
ans = i
break
return ans
def main():
for _ in ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR VAR BIN_OP VA... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | def check(l, s, n):
if l[n - 1] * n == s:
return True
return False
for _ in range(int(input())):
n = int(input())
l = [int(i) for i in input().split()]
l.sort()
s = sum(l)
ss = 0
for i in range(n):
if check(l, s, n - i):
print(i)
break
if... | FUNC_DEF IF BIN_OP VAR BIN_OP VAR NUMBER VAR VAR RETURN NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF FU... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | import sys
input = sys.stdin.readline
M = int(1000000000.0) + 7
def solve():
n = int(input())
a = sorted(map(int, input().split()))
pre = [0] * n
for i in range(1, n):
pre[i] = pre[i - 1] + a[i - 1]
sm = 0
for i in range(n - 1, -1, -1):
if i * a[i] <= sm + pre[i]:
... | IMPORT ASSIGN VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSI... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | ans = []
for _ in range(int(input())):
N = int(input())
A = sorted([int(x) for x in input().split()], reverse=True)
sm = sum(A)
for i in range(N):
if A[i] * (N - i) <= sm:
break
ans.append(i)
print(*ans, sep="\n") | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | def solve():
n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[0] == a[n - 1]:
return 0
presum = [a[0]]
for i in range(1, n):
presum.append(a[i] + presum[i - 1])
c = 0
dons = 0
while True:
c += 1
dons += a.pop()
presum.pop()
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR NUMBER VAR BIN_OP VAR NUMBER RETURN NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER AS... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | for _ in range(int(input())):
n = int(input())
a = [int(i) for i in input().strip().split()]
a.sort()
if a[0] == a[-1]:
print(0)
else:
b = []
b.append(0)
for i in range(1, n - 1):
b.append((a[i] - a[i - 1]) * i + b[i - 1])
sum = a[n - 1]
fo... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR ... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | t = int(input())
for _ in range(t):
n = int(input())
a = [int(x) for x in input().split()]
a.sort()
prefix = [a[0]]
for index in range(1, n):
prefix.append(a[index] + prefix[-1])
ans = 0
added = 0
for index in range(n - 1, 0, -1):
val = a[index]
total = prefix[ind... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | a = int(input())
for i in range(a):
N = int(input())
A = list(map(int, input().split()))
A.sort()
q = sum(A)
x = 1
p = 0
if A.count(A[0]) == N:
x = 0
else:
for j in range(N - 1, 0, -1):
p += A[j]
if p >= A[j - 1] * j - (q - p):
brea... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CA... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | t = int(input())
for test in range(t):
N = int(input())
A = list(map(int, input().split()))
total = sum(A)
A.sort(reverse=True)
for i in range(N):
if total >= A[i] * (N - i):
print(i)
break | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | t = int(input())
for _ in range(t):
n = int(input())
a = sorted(list(map(int, input().split())))
sum_, b, bsum = 0, [0] * n, [0] * n
bsum[-1] = a[-1]
for i in range(n):
sum_ += a[i]
b[i] = (i + 1) * a[i] - sum_
for i in range(n - 2, -1, -1):
bsum[i] = bsum[i + 1] + a[i]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR ... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | for _ in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)[::-1]
if 1 == len(set(l)):
print(0)
else:
mid = n // 2
le = 0
ri = n
while mid != le and mid != ri:
if sum(l[:mid]) >= (n - mid) * l[mid] - sum(l[mid:n... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VA... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | for i in range(int(input())):
n = int(input())
k = list(map(int, input().split()))
k1 = list(k)
k1.sort(reverse=True)
sk = 0
for j in k1:
sk += j
sk2 = sk
if k1[0] == k1[-1]:
print(0)
continue
b = k1[0]
for j in range(0, n - 1):
b += k1[j + 1]
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIG... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | for _ in range(int(input())):
n = int(input())
lst = sorted(list(map(int, input().split())))
total = 0
for l in lst:
total += l
ans = 0
for c in range(n):
if total / (n - c) >= lst[n - c - 1]:
ans = c
break
print(ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | t = int(input())
for _ in range(t):
n = int(input())
lst = list(map(int, input().split()))
lst.sort(reverse=True)
reqd, ans, avail = 0, 0, 0
for i in range(n):
reqd += lst[0] - lst[i]
if reqd == 0:
ans = 0
else:
for i in range(1, n):
avail += lst[i - 1]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR VAR IF VAR NUMBER ASSIGN VAR NU... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | T = int(input())
while T > 0:
n = input()
a = [int(x) for x in input().split()]
t = 1
suma = 0
a = sorted(a)
for i in a:
suma += i
suma -= a[-1]
if a[0] == a[-1]:
print(0)
else:
while (len(a) - 1) * a[-2] - suma > a[-1]:
suma -= a[-2]
s... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER WHILE BIN_OP BIN_OP BIN_OP FUNC... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | t = int(input())
for i in range(t):
l = int(input())
arr = list(map(int, input().split()))
if l == 1:
print(0)
else:
arr.sort()
prev = [(0) for i in range(l)]
prev[l - 1] = 0
for i in range(l - 2, -1, -1):
prev[i] = arr[i + 1] + prev[i + 1]
tot... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_C... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | t = int(input())
while t:
t -= 1
n = int(input())
if n == 1 or n == 0:
coins = input()
print(0)
continue
coins = [int(i) for i in input().split()]
coins.sort(reverse=True)
if coins[0] == coins[n - 1]:
print(0)
continue
if n == 2:
print(1)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | t = int(input())
for i in range(t):
n = int(input())
a = list(map(int, input().split()))
c = False
count = 0
k = 0
a.sort()
if a[0] == a[-1]:
print(0)
else:
b = [0] * (n + 1)
for i in range(0, n):
b[i + 1] = b[i] + a[i]
while c == False:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NU... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
rs = lambda: input()
def solve():
N = ri()
A = rl()
ans = N - 1
s = sum(A)
A.sort()
if A[0] == A[N - 1]:
return 0
cur = 0
for i in range(N):
cur += A[i]
x = s - cur
if x >= A[i] * (i ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF VAR NUMBER VAR BIN_OP VAR NUMBER RETURN NUMBER ASS... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | t = int(input())
for i in range(t):
l = int(input())
arr = list(map(int, input().split()))
if l == 1:
print(0)
else:
arr.sort()
s = sum(arr)
target = 0
for i in range(l - 1, -1, -1):
temp = (i + 1) * arr[i] - s
if target >= temp:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUM... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | t = int(input())
for i in range(t):
n = int(input())
l = list(map(int, input().split()))
s = sum(l)
l.sort(reverse=True)
if l[0] == l[-1]:
print("0")
else:
for i in range(0, n - 1):
if l[i + 1] * (n - 1 - i) - s <= 0:
print(i + 1)
break | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUM... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | def main():
T = int(input())
for i in range(T):
ans = 0
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
need = 0
avail = a[0]
if a[0] == a[-1]:
print("0")
continue
if a[0] != a[-1] and n == 2:
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VA... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | t = int(input())
while t > 0:
n = int(input())
a = [int(i) for i in input().split()]
if len(set(a)) == 1:
print("0")
else:
add = sum(a)
a.sort()
ans = n
while True:
a.pop()
ans -= 1
if add >= a[-1] * ans:
print(n... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR WHILE NUMBER EXPR FUNC_CALL VAR VAR N... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | for M in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
arr.sort(reverse=True)
s = sum(arr)
if max(arr) == min(arr):
print(0)
continue
for i in range(n - 1):
if s >= (n - 1 - i) * arr[i + 1]:
print(i + 1)
break | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF V... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | t = int(input())
for _ in range(t):
N = int(input())
A = [int(x) for x in input().split(" ")]
if A.count(max(A)) == len(A):
print(0)
continue
sm = sum(A)
A.sort()
curr, ans = 0, N
for i in range(N):
curr += A[i]
x = sm - curr
if x >= A[i] * (i + 1) - c... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | T = int(input())
for t in range(T):
n = int(input())
arr = [int(_) for _ in input().split()]
arr.sort(reverse=True)
prefix = [arr[0]]
for i in range(1, n):
prefix.append(prefix[i - 1] + arr[i])
suffix = [(0) for i in range(n)]
suffix[-1] = arr[-1]
for i in range(n - 2, -1, -1):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | def fun(n, a):
a.sort(reverse=True)
if a[0] == a[n - 1]:
return 0
i = 1
s = sum(a)
x = 0
while i < n:
s -= a[i - 1]
r = a[i] * (n - i) - s
x += a[i - 1]
if x >= r:
return i
i += 1
for _ in range(int(input())):
n = int(input())
... | FUNC_DEF EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR RETURN VAR VAR NUMBER FOR VAR FUNC_CALL V... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | t = int(input())
for _ in range(t):
n = int(input())
arr = list(map(int, input().split()))
if n == 1:
print(0)
continue
narr = arr.copy()
narr.sort(reverse=True)
pref_sum = 0
suf_sum = [(0) for i in range(n)]
cs = 0
for i in range(n - 1, -1, -1):
cs += narr[i]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
a.sort()
summ = sum(a)
for i in range(n - 1, -1, -1):
if a[i] * (i + 1) <= summ:
print(n - (i + 1))
break | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | import sys
input = sys.stdin.readline
def solve():
for i in range(int(input())):
n = int(input())
lst = list(map(int, input().split()))
sm = sum(lst)
lst.sort()
if lst[n - 1] == lst[0]:
print(0)
else:
curr = 0
ans = n
... | IMPORT ASSIGN VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIG... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | def qsort(inlist):
if inlist == []:
return []
else:
pivot = inlist[0]
lesser = qsort([x for x in inlist[1:] if x < pivot])
greater = qsort([x for x in inlist[1:] if x >= pivot])
return lesser + [pivot] + greater
for t in range(int(input())):
n = int(input())
s =... | FUNC_DEF IF VAR LIST RETURN LIST ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR VAR RETURN BIN_OP BIN_OP VAR LIST VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR F... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
a.sort()
if len(a) == 1:
print(0)
continue
s = sum(a)
c = 0
ans = -1
for i in range(0, n):
c += a[i]
if a[i] * (i + 1) - c <= s - c:
ans = i
print(n - ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUN... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | T = int(input())
for i in range(T):
n = int(input())
li = list(map(int, input().split()))
li.sort(reverse=True)
total_sum = sum(li)
b_sum = 0
c_sum = total_sum
flag = 0
for j in range(1, n):
if li[j - 1] != li[j]:
flag = 1
break
if flag == 0:
p... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | for _ in range(int(input())):
n = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
diff = x = c = 0
for i in range(n):
diff += arr[-1] - arr[i]
for i in range(n - 1, 0, -1):
if x >= diff:
break
diff -= (arr[i] - arr[i - 1]) * i
x += arr[... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR BIN_... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | a = int(input())
for i in range(a):
c = int(input())
b = list(map(int, input().split()))
b.sort()
b.reverse()
if len(set(b)) == 1:
print("0")
else:
j = sum(b)
k = len(b)
l = 0
for i in range(len(b)):
j -= b[i]
k -= 1
l +... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUN... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | for _ in range(int(input())):
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
if A[0] == A[-1]:
print(0)
continue
total = sum(A)
for i, a in enumerate(A[:-1]):
if A[i + 1] == A[-1]:
print(i + 1)
break
if total / (N... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP VAR NUM... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | def checker(arr, k):
t = sum(arr[0:k])
i = k
req = 0
target = arr[i]
while i < len(arr):
req += target - arr[i]
i += 1
if req <= t:
return 1
else:
return 0
def ans(arr):
start = 0
end = len(arr)
temp = sorted(arr, reverse=True)
c = 0
whil... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VA... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | for _ in range(int(input())):
n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
s = sum(a)
for i in range(n):
if a[i] * (n - i) <= s:
print(i)
break | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | T = int(input())
Coins = list()
Res = list()
for i in range(T):
N = int(input())
Coins = input().split(" ")
A = list()
n = 0
while n < N:
A = list()
A.append(int(Coins[n]))
n = n + 1
Coins = [int(j) for j in Coins]
Coins.sort()
SumOfCoins = sum(Coins)
n = N
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR A... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | t = int(input())
for _ in range(t):
n = int(input())
arr = sorted(list(map(int, input().split())), reverse=True)
x = sum(arr)
ans = 0
d = 0
for i in range(n):
if arr[i] * (n - i) > x + d:
ans += 1
d += arr[i]
x -= arr[i]
else:
break... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR BIN_OP VAR VAR BIN_... |
There is a town with N people and initially, the i^{th} person has A_{i} coins. However, some people of the town decide to become *monks*. If the i^{th} person becomes a monk, then:
He leaves the town thereby reducing the number of people in the town by 1.
He distributes X (0 ≤ X ≤ A_{i}) coins to the remaining people ... | try:
T = int(input())
for k in range(T):
N = int(input())
A = list(map(int, input().split(" ")))
A.sort()
sum = 0
for j in range(N):
sum += A[j]
if A[0] == A[N - 1]:
print(0)
continue
ans = N
C = 0
for i ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIG... |
A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex $v$ (different from root) is the previous to $v$ vertex on the shortest path from the root to the vertex $v$. Children of the vertex $v$ are all vertices for which $v$ is the parent.
You are given a r... | class Node:
def __init__(self, data):
self.data = data
self.next = None
self.prev = None
class doubly_linked_list:
def __init__(self):
self.head = None
def push(self, NewVal):
NewNode = Node(NewVal)
NewNode.next = self.head
if self.head is not Non... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NONE ASSIGN VAR NONE CLASS_DEF FUNC_DEF ASSIGN VAR NONE FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR IF VAR NONE ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF IF VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR ASSIGN VAR NONE ASS... |
A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex $v$ (different from root) is the previous to $v$ vertex on the shortest path from the root to the vertex $v$. Children of the vertex $v$ are all vertices for which $v$ is the parent.
You are given a r... | def calcula_t():
n_vertices = int(input())
grau = [0] * n_vertices
lista_p = list(map(int, input().split()))
for p in lista_p:
grau[p - 1] += 1
a = [1]
for i in range(n_vertices):
if grau[i] > 0:
a.append(grau[i])
a.sort(reverse=True)
inicio = len(a)
fim =... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR... |
A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex $v$ (different from root) is the previous to $v$ vertex on the shortest path from the root to the vertex $v$. Children of the vertex $v$ are all vertices for which $v$ is the parent.
You are given a r... | class Tree:
def __init__(self, n, p):
self.groups = [1]
self.time = 0
self.n = n
p.sort()
s = p[0]
k = 0
for t in p:
if t == s:
k += 1
else:
self.groups.append(k)
s = t
k ... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF VAR VAR F... |
A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex $v$ (different from root) is the previous to $v$ vertex on the shortest path from the root to the vertex $v$. Children of the vertex $v$ are all vertices for which $v$ is the parent.
You are given a r... | for _ in [0] * int(input()):
n = int(input())
a = list(map(int, input().split()))
c = [0] * n + [1]
for i in a:
c[i - 1] += 1
c = sorted(c, reverse=True)
ans = sum(i > 0 for i in c)
for i, j in enumerate(c):
if j > 0:
c[i] = i + j - ans
c = sorted([i for i in ... | FOR VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER VAR LIST NUMBER FOR VAR VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ... |
A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex $v$ (different from root) is the previous to $v$ vertex on the shortest path from the root to the vertex $v$. Children of the vertex $v$ are all vertices for which $v$ is the parent.
You are given a r... | for i in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
d = {}
for j in l:
d[j] = 0
for j in l:
d[j] += 1
l1 = []
for j in d:
l1.append(d[j])
l1.append(1)
l1.sort()
x = len(l1)
t = 0
for j in range(x):
t += 1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR F... |
A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex $v$ (different from root) is the previous to $v$ vertex on the shortest path from the root to the vertex $v$. Children of the vertex $v$ are all vertices for which $v$ is the parent.
You are given a r... | for _ in range(int(input())):
n = int(input())
arr = [(0) for i in range(n + 1)]
arr[0] = 1
for i in list(map(int, input().split())):
arr[i] += 1
arr.sort()
arr = [i for i in arr if i != 0]
n = len(arr)
ans = n
arr2 = [(arr[i] - i - 1) for i in range(n) if arr[i] - i - 1 > 0]... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL... |
A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex $v$ (different from root) is the previous to $v$ vertex on the shortest path from the root to the vertex $v$. Children of the vertex $v$ are all vertices for which $v$ is the parent.
You are given a r... | for _ in range(int(input())):
n = int(input())
a = [0] + list(map(int, input().split()))
branch = {}
for i in a:
branch[i] = branch.get(i, 0) + 1
res = sorted(branch.values())[::-1]
cnt = 0
j = len(res)
for i in range(len(res)):
res[i] -= j
j -= 1
cnt += 1... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL 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 DICT FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER... |
A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex $v$ (different from root) is the previous to $v$ vertex on the shortest path from the root to the vertex $v$. Children of the vertex $v$ are all vertices for which $v$ is the parent.
You are given a r... | import time
for _ in range(int(input())):
n = int(input())
a = [0] * (n + 1)
a[0] = 1
for i in list(map(int, input().split())):
a[i] += 1
try:
a = [x for x in a if x > 0]
a.sort(reverse=True)
ans = len(a)
for i in range(len(a)):
a[i] -= len(a) - i... | IMPORT FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR F... |
A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex $v$ (different from root) is the previous to $v$ vertex on the shortest path from the root to the vertex $v$. Children of the vertex $v$ are all vertices for which $v$ is the parent.
You are given a r... | t = int(input())
rr = ""
for _t in range(t):
n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
new_arr = []
nlist = []
prev = None
for a in arr:
if a == prev or not nlist:
nlist.append(a)
else:
new_arr.append(nlist)
n... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NONE FOR VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR... |
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him.
After a while the cashier has a lunch break and t... | n = int(input())
arr = []
for i in range(n):
a, b = list(map(str, input().split()))
b = int(b)
arr.append([b, a])
arr.sort()
ans = []
for i in arr:
if i[0] > len(ans):
print(-1)
exit()
ans.insert(i[0], (i[1], n))
n -= 1
for i in ans:
print(i[0], i[1]) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EX... |
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him.
After a while the cashier has a lunch break and t... | import sys
n = int(input())
person = []
for i in range(n):
person.append(input().split())
person.sort(key=lambda x: int(x[1]))
high = 10**9
low = 1
cntHigh = 0
for i in range(n):
dif = int(person[i][1]) - cntHigh
for j in range(i - 1, -1, -1):
if dif == 0:
break
if person[j][2] ... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR ... |
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him.
After a while the cashier has a lunch break and t... | n = int(input())
arr = [input().split() for _ in range(n)]
arr = [[int(arr[i][1]), arr[i][0]] for i in range(n)]
arr.sort()
res = []
for i in range(n):
res.append(i - arr[i][0])
if res[i] < 0:
print(-1)
exit()
for j in range(i):
if res[j] >= res[i]:
res[j] += 1
for i in r... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FUNC_CALL VAR VAR VAR NUMBER VAR VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR... |
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him.
After a while the cashier has a lunch break and t... | ans, pr = list(), list()
for _ in range(int(input())):
a, b = input().split()
ans.append([int(b), a])
ans.sort()
v = len(ans)
for x in ans:
if x[0] > len(pr):
print(-1)
break
pr.insert(x[0], (x[1], v))
v -= 1
else:
for _ in pr:
print(_[0], _[1]) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR N... |
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him.
After a while the cashier has a lunch break and t... | n = int(input())
a = sorted(
[
list(
map(lambda x: x if x[0] >= "a" and x[0] <= "z" else int(x), input().split())
)[::-1]
for i in range(n)
]
)
fl = 1
ans = []
for i in range(len(a)):
v, name = a[i]
if i == 0:
if v > 0:
fl = 0
break
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER STRING VAR NUMBER STRING VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR IF VAR NUMBER IF VAR... |
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him.
After a while the cashier has a lunch break and t... | def solve(arr, n):
arr.sort()
names = [x[1] for x in arr]
counts = [x[0] for x in arr]
segments = []
curr_count = counts[0]
curr_len = 0
L = 0
for i in range(n):
if counts[i] == curr_count:
curr_len += 1
else:
segments.append((L, i - 1))
... | FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR VAR ASSIGN VAR VAR NUMBER VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CAL... |
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him.
After a while the cashier has a lunch break and t... | n = int(input())
a = []
for _ in range(n):
name, num = input().split()
a.append([name, int(num)])
a = sorted(a, key=lambda x: x[1])
h = []
def solve(a):
h = []
for name, num in a:
if num > len(h):
return False, -1
if num == 0:
if len(h) == 0:
h.a... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR LIST FUNC_DEF ASSIGN VAR LIST FOR VAR VAR VAR IF VAR FUNC_CALL VAR VAR RETURN NUMBER NUMBER IF VAR NUMB... |
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him.
After a while the cashier has a lunch break and t... | n = int(input())
def func(s):
name, a = s.split()
return [int(a), name]
arr = [func(input()) for i in range(n)]
arr.sort()
flag = True
for i in range(n):
if i < arr[i][0]:
flag = False
break
if flag:
h = [0] * n
for i in range(n // 2):
hi = h[i] = 20000 * (i + 1 - arr[i][... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR RETURN LIST FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR ... |
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him.
After a while the cashier has a lunch break and t... | def question3():
people = int(input())
front_more_height = []
for i in range(people):
name, front = input().split()
front = int(front)
front_more_height.append([name, front])
front_more_height.sort(key=lambda x: x[1])
max1 = people**2
n = people
ans = []
for i in ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUM... |
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him.
After a while the cashier has a lunch break and t... | n = int(input())
a = []
for i in range(n):
s, c = input().split()
a.append((s, int(c)))
a.sort(key=lambda x: x[1])
ans = []
for i in range(n):
if len(ans) < a[i][1]:
print(-1)
exit(0)
ans.insert(a[i][1], (a[i][0], n - i))
for s, a in ans:
print(s, a) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER... |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
c1 = collections.Counter(s1)
c2 = collections.Counter(s2)
t1, t2 = 0, 0
f1, f2 = 1, 1
for i in range(26):
z = chr(97 + i)
t1 += c1[z] - c2[z]
if t1 < 0:
f... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR VAR BIN_OP VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER VAR BIN_OP VAR VAR VAR VAR IF VAR NUMBER ASSIG... |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
s1 = list(s1)
s2 = list(s2)
s1.sort(reverse=True)
s2.sort(reverse=True)
match = all(x >= y for x, y in zip(s1, s2))
if match:
return True
s1.sort()
s2.sort()
matc... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR RETURN NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VA... |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
s1 = sorted(s1)
s2 = sorted(s2)
def check(s1, s2):
c = 0
n = len(s1)
for i in range(n):
if s1[i] >= s2[i]:
c = c + 1
return c == n
... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR VAR RETURN FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
s1sorted = "".join(sorted(s1))
s2sorted = "".join(sorted(s2))
res1 = True
res2 = True
for i in range(len(s1)):
if ord(s1sorted[i]) > ord(s2sorted[i]):
res1 = False
for i ... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR... |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
l1 = list(s1)
l2 = list(s2)
l1.sort()
l2.sort()
count = 0
count1 = 0
for i in range(len(l1)):
if l1[i] >= l2[i]:
count += 1
if count == len(l1):
... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR V... |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
t1, t2 = sorted(list(s1)), sorted(list(s2))
for i in range(len(t1)):
if t1[i] <= t2[i]:
continue
else:
break
else:
return True
for i in range(len(... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR RETURN NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER VAR |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
l1 = [char for char in s1]
l1.sort()
l2 = [char for char in s2]
l2.sort()
strlen = len(s1)
flag = 0
for i in range(strlen):
if l1[i] >= l2[i]:
continue
... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER VAR |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
s1 = sorted(s1)
s2 = sorted(s2)
indices = [i for i, (a, b) in enumerate(zip(s1, s2)) if a != b]
comparisons = [(s1[i] > s2[i]) for i in indices]
return all(comparisons) or not any(comparisons) | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
l1 = list()
l2 = list()
n = len(s1)
for i in range(0, n):
l1.append(s1[i : i + 1])
l1.sort()
for i in range(0, n):
l2.append(s2[i : i + 1])
l2.sort()
indicato... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER AS... |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
s1_arr = [ord(x) for x in s1]
s2_arr = [ord(x) for x in s2]
s1_arr.sort()
s2_arr.sort()
s1_counter = 0
s2_counter = 0
for i in range(len(s1_arr)):
if s1_arr[i] > s2_arr[i]:
... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ... |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
s1 = sorted(s1)
s2 = sorted(s2)
s1_bigger = False
s2_bigger = False
for i in range(len(s1)):
if s1_bigger and s1[i] < s2[i]:
return False
if s2_bigger and s1[i] > s2[... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR RETURN NUMBER IF VAR VAR VAR VAR VAR RETURN NUMBER IF VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR NUMBER RETURN NUMB... |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
s1 = list(s1)
s2 = list(s2)
s1.sort()
s2.sort()
s1token = True
for i in range(len(s1)):
if s1[i] > s2[i]:
s1token = False
break
if s1token == True... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR V... |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
s1 = sorted(s1, reverse=True)
s2 = sorted(s2, reverse=True)
resultA = []
resultB = []
for ch1, ch2 in zip(s1, s2):
if ch1 >= ch2:
resultA.append(1)
else:
... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR NUMBER F... |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
s1 = sorted(list(s1))
s2 = sorted(list(s2))
i = 0
while s1[i] <= s2[i]:
if i == len(s1) - 1:
return True
i += 1
i = 0
while s2[i] <= s1[i]:
if i =... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER RETURN NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER RETURN NUMBER VAR NUMBER... |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
s1 = sorted([c for c in s1])
s2 = sorted([c for c in s2])
return all(char1 <= char2 for char1, char2 in zip(s1, s2)) or all(
char1 >= char2 for char1, char2 in zip(s1, s2)
) | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def check(self, d1, d2):
for x, y in zip(d1, d2):
if x <= y:
continue
return False
return True
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
d1 = sorted(s1)
d2 = sorted(s2)
return self.check(d1, d2) | self.c... | CLASS_DEF FUNC_DEF FOR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
ss1 = sorted(s1)
ss2 = sorted(s2)
f = True
r = True
for x, y in zip(ss1, ss2):
f = f and x >= y
r = r and x <= y
return f or r | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR RETURN VAR VAR VAR |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
return all(ch1 <= ch2 for ch1, ch2 in zip(sorted(s1), sorted(s2))) or all(
ch1 <= ch2 for ch1, ch2 in zip(sorted(s2), sorted(s1))
) | CLASS_DEF FUNC_DEF VAR VAR RETURN FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
s1 = sorted(s1)
s2 = sorted(s2)
count1 = 0
count2 = 0
for i in range(len(s1)):
if s1[i] <= s2[i]:
count1 += 1
if s1[i] >= s2[i]:
count2 += 1
i... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER VAR |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
s1 = "".join(sorted(s1))
s2 = "".join(sorted(s2))
cnt1 = 0
cnt2 = 0
for i in range(len(s1)):
if s1[i] >= s2[i]:
cnt1 += 1
if s2[i] >= s1[i]:
cnt2 += 1... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_CALL VAR VAR VAR FUNC_... |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
comparisons = [(a >= b) for a, b in zip(sorted(s1), sorted(s2))]
all_true = all(comparisons)
if not all_true:
comparisons = [(a <= b) for a, b in zip(sorted(s1), sorted(s2))]
all_true = all(comparis... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR RETURN VAR VAR |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
s1 = sorted(s1)
s2 = sorted(s2)
left = True
determined = False
for i, c in enumerate(s1):
if c > s2[i]:
if not left and determined:
return False
... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR IF VAR VAR RETURN NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR IF VAR VAR RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER RETURN NUMBER VAR |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
ans1 = [(a <= b) for a, b in zip(sorted(s1), sorted(s2))]
ans2 = [(a >= b) for a, b in zip(sorted(s1), sorted(s2))]
if len(set(ans1)) == 1 or len(set(ans2)) == 1:
return True
return False | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER RETURN NUMBER RETURN NUMBER VAR |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
def helper(d1, d2):
s = 0
for c in "abcdefghijklmnopqrstuvwxyz":
s += d1[c] - d2[c]
if s < 0:
return False
return True
c1 = collections.Coun... | CLASS_DEF FUNC_DEF VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR STRING VAR BIN_OP VAR VAR VAR VAR IF VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
s1list = list(s1)
s2list = list(s2)
s1list.sort()
s2list.sort()
count1 = 0
count2 = 0
for i in range(len(s1)):
count1 += int(s1list[i] >= s2list[i])
for i in range(len(s1... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR RETURN BIN_OP... |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
s1 = sorted(s1)
s2 = sorted(s2)
a1 = [(s1[i] >= s2[i]) for i in range(len(s1))]
a2 = [(s1[i] <= s2[i]) for i in range(len(s1))]
return False not in a1 or False not in a2 | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR RETURN NUMBER VAR NUMBER VAR VAR |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
s1 = sorted(s1)
s2 = sorted(s2)
ans1 = True
ans2 = True
for i in range(len(s1)):
if s1[i] < s2[i]:
ans1 = False
if s2[i] < s1[i]:
ans2 = False
... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR NUMBER RETURN VAR VAR VAR |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
s1 = sorted(s1)
s2 = sorted(s2)
size_t = len(s1)
for idx in range(size_t):
if s1[idx] == s2[idx]:
continue
elif s1[idx] < s2[idx]:
ans = set(map(lambda x, y: ... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR IF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER RETU... |
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
Input: s1 = "ab... | class Solution:
def checkIfCanBreak(self, s1: str, s2: str) -> bool:
arr1 = list(s1)
arr2 = list(s2)
arr1.sort()
arr2.sort()
n = len(arr1)
flag = True
flag1 = True
for i in range(n):
if arr1[i] < arr2[i]:
flag1 = False
... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.