description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.
The city consists of $n$ squares connected by $n-1$ roads in such a way that it is possible to reach any square from any other square. The square number $1$ is the main square.
After Sunday walk all the roads were changed to one-... | n = int(input())
p = [0, 0] + list(map(int, input().split()))
a = [0] + list(map(int, input().split()))
g = [[] for _ in range(n + 1)]
slots = [0] * (n + 1)
cap = [0] * (n + 1)
leaves = [0] * (n + 1)
for u in range(n, 0, -1):
g[p[u]].append(u)
if not g[u]:
cap[u] = a[u]
leaves[u] = 1
con... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER AS... |
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.
The city consists of $n$ squares connected by $n-1$ roads in such a way that it is possible to reach any square from any other square. The square number $1$ is the main square.
After Sunday walk all the roads were changed to one-... | n = int(input())
p = list(map(int, input().split()))
a = list(map(int, input().split()))
tree = {}
for i, pp in enumerate(p, start=2):
tree.setdefault(pp, []).append(i)
cache = {}
for s in range(n, 0, -1):
children = tree.get(s, [])
if len(children) == 0:
cache[s] = a[s - 1], a[s - 1], 1
con... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL FUNC_CALL VAR VAR LIST VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR NUMBER NUM... |
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.
The city consists of $n$ squares connected by $n-1$ roads in such a way that it is possible to reach any square from any other square. The square number $1$ is the main square.
After Sunday walk all the roads were changed to one-... | import sys
sys.setrecursionlimit(10**5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II():
return int(sys.stdin.buffer.readline())
def MI():
return map(int, sys.stdin.buffer.readline().split())
def LI():
return list(map(int, sys.stdin.buffer.readline().split()))
def LI1():
... | IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC... |
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.
The city consists of $n$ squares connected by $n-1$ roads in such a way that it is possible to reach any square from any other square. The square number $1$ is the main square.
After Sunday walk all the roads were changed to one-... | n = int(input())
g = [[] for i in range(n + 1)]
p = list(map(int, input().split()))
for i in range(n - 1):
a = i + 2
b = p[i]
g[a].append(b)
g[b].append(a)
dp = [0] + list(map(int, input().split()))
count = [0] * (n + 1)
maxi = [0] * (n + 1)
for i in range(2, n + 1):
if len(g[i]) == 1:
count... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LI... |
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.
The city consists of $n$ squares connected by $n-1$ roads in such a way that it is possible to reach any square from any other square. The square number $1$ is the main square.
After Sunday walk all the roads were changed to one-... | import sys
input = sys.stdin.readline
n = int(input())
p = list(map(int, input().split()))
p.insert(0, 0)
for i in range(1, n):
p[i] -= 1
a = list(map(int, input().split()))
data = [0] * n
for i in range(n):
data[i] = [0, a[i], True]
i = n - 1
biggest = 0
while i > 0:
prev = p[i]
if data[i][2]:
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FU... |
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.
The city consists of $n$ squares connected by $n-1$ roads in such a way that it is possible to reach any square from any other square. The square number $1$ is the main square.
After Sunday walk all the roads were changed to one-... | n = int(input())
P = [-1] + list(map(lambda x: int(x) - 1, input().split()))
A = list(map(int, input().split()))
ans = 0
C = [[] for i in range(n)]
for i in range(1, n):
C[P[i]] += [i]
que = [0]
B = [0] * n
for i in range(n):
if not C[i]:
B[i] = 1
while que:
q = que.pop()
if C[q]:
que +=... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR... |
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.
The city consists of $n$ squares connected by $n-1$ roads in such a way that it is possible to reach any square from any other square. The square number $1$ is the main square.
After Sunday walk all the roads were changed to one-... | from itertools import repeat
from sys import stdin
def main():
n = int(stdin.readline())
p = list(map(int, stdin.readline().split(), repeat(10, n - 1)))
a = list(map(int, stdin.readline().split(), repeat(10, n)))
l = [1] * n
b = [0] * n
ans = 0
for i in range(n - 1, -1, -1):
b[i] +... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN... |
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.
The city consists of $n$ squares connected by $n-1$ roads in such a way that it is possible to reach any square from any other square. The square number $1$ is the main square.
After Sunday walk all the roads were changed to one-... | n = int(input())
a = [int(x) for x in input().split()]
g = [0] * n
for i in range(n - 1):
if type(g[a[i] - 1]) == int:
g[a[i] - 1] = []
g[a[i] - 1].append(i + 1)
a = [int(x) for x in input().split()]
b = [0] * n
now = [0] * n
for i in range(n - 1, -1, -1):
if g[i] == 0:
b[i] = 1
now[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR NUMBER LIST EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN... |
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.
The city consists of $n$ squares connected by $n-1$ roads in such a way that it is possible to reach any square from any other square. The square number $1$ is the main square.
After Sunday walk all the roads were changed to one-... | n = int(input())
P = list(map(int, input().split()))
A = list(map(int, input().split()))
g = [[] for _ in range(n)]
P = [(p - 1) for p in P]
parent = [-1] * n
for i, p in enumerate(P):
g[p].append(i + 1)
parent[i + 1] = p
s = []
s.append(0)
order = []
while s:
v = s.pop()
order.append(v)
for u in g[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR FUNC_CALL VAR VAR EXPR FUN... |
Treeland consists of $n$ cities and $n-1$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right — the country's topology is an undirected tree.
There are some private road companies in Treeland. The government decided to sell roads ... | def strelizia():
oh_pie = 0
kaguya = 0
owe_pie = [(0, 0, 0)]
while kaguya <= oh_pie:
o_pie = oh_pie
while kaguya <= o_pie:
x = owe_pie[kaguya][0]
p = owe_pie[kaguya][1]
c = 1
l = len(stamen[x])
if l > virm:
for t... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER WHILE VAR VAR ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR FOR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VA... |
Treeland consists of $n$ cities and $n-1$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right — the country's topology is an undirected tree.
There are some private road companies in Treeland. The government decided to sell roads ... | def set_color(edge, colors, color):
colors[edge] = color
colors[edge[1], edge[0]] = color
def set_node_color(node, parent, parent_color, index, bad_nodes, colors):
color = 1
for child_node in (child for child in index[node] if child != parent):
if color == parent_color:
color += 1
... | FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR VAR NUMBER VAR NUMBER VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR VAR VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR FUNC_DEF ASSIGN VAR VAR NONE VAR VAR ASSIGN VAR VAR FUNC_C... |
Treeland consists of $n$ cities and $n-1$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right — the country's topology is an undirected tree.
There are some private road companies in Treeland. The government decided to sell roads ... | import sys
zz = 1
sys.setrecursionlimit(10**5)
if zz:
input = sys.stdin.readline
else:
sys.stdin = open("input.txt", "r")
sys.stdout = open("all.txt", "w")
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]
def fori(n):
return [fi() for i in range(n)]
def inc(d, c, x=1):
d[c] = d[c] + x if c in d else x
... | IMPORT ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER IF VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF NU... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | t = int(input())
for _ in range(t):
n = int(input())
playList = []
for index in range(n):
band, songLen = map(int, input().split())
playList.append([band, songLen])
playList.sort(reverse=False)
smallestSongs = []
total = 0
for index in range(n):
if index == 0 or playL... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 LIST VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | t = int(input())
for _ in range(t):
hash = {}
n = int(input())
rem = []
for i in range(n):
a, b = map(int, input().split())
if a in hash:
if hash[a] > b:
rem.append(hash[a])
hash[a] = b
else:
rem.append(b)
el... | 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 LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | t = int(input())
for _ in range(t):
songs = []
n = int(input())
for _ in range(n):
b, l = map(int, input().split())
songs.append((b, l))
songs.sort()
total = 0
js = []
for i in range(n):
if i == 0 or songs[i - 1][0] < songs[i][0]:
js.append(songs[i][1])
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR NUMB... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | for _ in range(int(input())):
n = int(input())
band = {}
for i in range(n):
b, l = map(int, input().split())
if b in band:
band[b].append(l)
else:
band[b] = [l]
out = 0
arr = []
k = len(band)
for i in band:
band[i].sort()
arr.ap... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR LIST VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FOR VAR... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | def maxBandLength(bands, n):
bands.sort(key=lambda x: x[1])
list2 = []
len_set = set()
count = 0
for item in bands:
if item[0] not in len_set:
len_set.add(item[0])
count += len(len_set) * item[1]
else:
list2.append(item[1])
for length in list2:... | FUNC_DEF EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER FOR VAR VAR VAR BIN_OP VAR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL V... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | for T in range(int(input())):
N = int(input())
dic = {}
no_band = 0
for i in range(N):
B, L = map(int, input().split())
try:
if L < dic[B][0]:
dic[B].insert(0, L)
else:
dic[B].append(L)
except KeyError:
no_band +... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR L... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | for _ in range(int(input())):
n = int(input())
arr = []
for i in range(n):
a, b = map(int, input().split())
arr.append([b, a])
arr.sort()
total = 0
j = 1
ans = 0
su = {}
for i in arr:
if i[1] not in su:
su[i[1]] = 1
ans += i[0] * j
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 LIST VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR VAR... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | for _ in range(int(input())):
n = int(input())
l = [0] * n
b = [0] * n
q = []
for i in range(n):
q.append(list(map(int, input().split())))
q = sorted(q, key=lambda x: x[1])
prod = 0
count = 0
dict = {}
t = 0
for i in q:
if i[0] not in dict.keys():
... | 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 VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | t = int(input())
while t:
songs = []
res = 0
n = int(input())
unique_bands = {}
for _ in range(n):
b_l = [int(i) for i in input().split()]
songs.append({"band": b_l[0], "length": b_l[1], "visited": 0})
songs = sorted(songs, key=lambda k: k["length"])
for song in range(len(son... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR DICT STRING STRING STRING VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | for _ in range(int(input())):
n = int(input())
arr = []
for i in range(n):
a, b = map(int, input().split())
arr.append((b, a))
arr.sort()
band = set()
play_last = []
res = 0
for l, b in arr:
if b not in band:
band.add(b)
res += l * len(band... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR VAR IF VAR VAR ... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | for _ in range(int(input())):
n = int(input())
s = set()
ls = list()
arr = list()
for i in range(n):
b, l = map(int, input().split())
ls.append([l, b])
ans = Count = 0
ls.sort()
for i in range(n):
if ls[i][1] not in s:
Count += 1
ans += Cou... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR ... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | for _ in range(int(input())):
ls = []
s = set()
ans = 0
temp = []
cnt = 0
for i in range(int(input())):
b, l = list(map(int, input().split()))
ls.append([l, b])
ls.sort()
for i in range(len(ls)):
if ls[i][1] not in s:
s.add(ls[i][1])
cnt +=... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR FOR V... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | for _ in range(int(input())):
n = int(input())
nl = []
for i in range(n):
nl.append([int(x) for x in input().split()])
nl.sort(key=lambda x: x[1])
ans = 0
vis = [False] * len(nl)
bp = {}
bb = 0
for i in range(n):
if nl[i][0] not in bp:
bp[nl[i][0]] = True
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR N... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | for _ in range(int(input())):
n = int(input())
s = []
dp = {}
cnt = 0
sweetness = 0
visited = [False] * n
for _ in range(n):
s.append([int(x) for x in input().split()])
s.sort(key=lambda x: x[1])
for i in range(n):
if s[i][0] not in dp:
dp[s[i][0]] = True
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER FOR VAR ... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | T = int(input())
for z in range(T):
N = int(input())
dct = {}
min_dct = {}
for i in range(N):
band, song = map(int, input().split())
if band in dct:
if song < min_dct[band]:
dct[band].append(min_dct[band])
min_dct[band] = song
else:... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR VA... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | for _ in range(int(input())):
num_songs = int(input())
songs_list = []
for i in range(num_songs):
songs_list.append(tuple(map(int, input().split())))
songs_list.sort(key=lambda x: x[1])
played_list = [False] * num_songs
previously_palyed = {}
sweetness = 0
for i in range(len(song... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CAL... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | from sys import *
for _ in range(int(stdin.readline())):
n = int(stdin.readline())
l = []
d = set()
ans = 0
new = []
for _ in range(n):
a, b = map(int, stdin.readline().split())
l.append([b, a])
l.sort()
for j in l:
if j[1] not in d:
d.add(j[1])
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR 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 EXPR FUNC_CALL VAR FOR VAR VAR IF VAR NUM... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | T = int(input())
for _ in range(T):
N = int(input())
songs = []
for _ in range(N):
songs.append(list(map(int, input().split())))
sweetness = 0
played = set()
play_later = []
songs.sort(key=lambda x: x[1])
for i in songs:
if i[0] not in played:
played.add(i[0])... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR NUMBER FOR VAR VA... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | for T in range(int(input())):
n = int(input())
a = []
b = []
d = {}
ind = {}
visited = [(True) for x in range(n)]
for i in range(n):
x, y = map(int, input().split())
a.append(x)
b.append(y)
if x not in d:
d[x] = []
d[x].append(y)
if... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VA... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | tc = int(input())
for _ in range(tc):
n = int(input())
mp = {}
for i in range(n):
b, l = map(int, input().split())
if b in mp:
mp[b].append(l)
else:
mp[b] = [l]
lst = []
for b in mp.values():
b.sort()
lst.append(b[0])
bands = len(ls... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR LIST VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR EXPR FUNC_CALL VA... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | for _ in range(int(input())):
a = int(input())
yu = []
pussy = set()
count = 0
ans = 0
temp = 0
for _ in range(a):
yu.append(list(map(int, input().split())))
ty = sorted(yu, key=lambda x: x[1])
for i in ty:
if i[0] not in pussy:
pussy.add(i[0])
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NU... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | t = int(input())
for i in range(0, t):
n = int(input())
li = []
for j in range(0, n):
b, l = map(int, input().split())
li.append([l, b])
li.sort()
m = {}
total = 0
cn = 1
ans = 0
for x in li:
if x[1] not in m:
m[x[1]] = 1
ans = ans + x[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER ... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | def solve(arr):
bands = {}
for b, l in arr:
if b not in bands:
bands[b] = l
bands[b] = min(l, bands[b])
t = sum(l * i for i, l in enumerate(sorted(bands.values()), 1))
for b, l in arr:
if l == bands[b]:
bands[b] = -1
continue
t += l * l... | FUNC_DEF ASSIGN VAR DICT FOR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FOR VAR VAR VAR IF VAR VAR VAR ASSIGN VAR VAR NUMBER VAR BIN_OP VAR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF FOR V... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | def sweet(sweet, n):
n_keys = 0
first_m = []
for k, v in sweet.items():
sweet[k] = sorted(v, reverse=True)
n_keys += 1
first_m.append(sweet[k][-1])
sweet[k].pop()
first_m = sorted(first_m)
total = 0
for i in range(n_keys):
total += (i + 1) * first_m[i]
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR BIN_OP ... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | def calc_sweetness(l, sweetness):
length = 0
songs.append(l[0][1])
for i in range(len(l) - 1):
if l[i][0] < l[i + 1][0]:
songs.append(l[i + 1][1])
else:
length = length + l[i + 1][1]
songs.sort()
for i in range(1, len(songs) + 1):
sweetness = sweetness... | FUNC_DEF ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP F... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | for _ in range(int(input())):
n = int(input())
songs = []
counted = {}
bands_done = 0
for _ in range(n):
songs.append(tuple(map(int, input().split())))
songs.sort(key=lambda x: x[1])
ans = 0
left_length = 0
while len(songs) > 0:
current = songs.pop(0)
if curre... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT 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 EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE FUNC_CAL... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | T = int(input())
for i in range(T):
N = int(input())
BL = []
for j in range(N):
BL.append(list(map(int, input().split())))
BL = sorted(BL)
BL_new = [0] * len(BL)
BL_new[0] = BL[0]
count1 = 0
count2 = 0
for k in range(len(BL) - 1):
if BL[k][0] == BL[k + 1][0]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR ... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | for _ in range(int(input())):
n = int(input())
b = []
l = []
for i in range(n):
bi, li = map(int, input().split())
b.append(bi)
l.append(li)
d = dict()
e = dict()
arr = []
count = 0
sm = 0
for i in range(n):
if b[i] in d:
cur = d[b[i]]
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSI... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | from sys import stdin
data = stdin.readlines()
d = 0
T = int(data[d])
d += 1
for t in range(T):
pairs = {}
rem = 0
N = int(data[d])
d += 1
length = 0
for n in range(N):
b, l = map(int, data[d].split(" "))
d += 1
if b not in pairs:
pairs[b] = l
len... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR STRING VAR NUMBER IF VAR VAR ASSIG... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | from itertools import permutations as p
t = int(input())
for _ in range(t):
n = int(input())
l1 = []
l2 = []
for i in range(n):
a, b = map(int, input().split())
l1.append([b, a])
l2.append([a, b])
d = {}
for i in l1:
try:
d[i[0]].append(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 LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR DICT FOR VAR VAR EXPR FUNC... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | from sys import stdin
tc = int(stdin.readline())
for i in range(tc):
n = int(stdin.readline())
list1 = []
for j in range(n):
b, l = map(int, stdin.readline().split())
list1.append((l, b))
list1.sort()
distinct = set()
total = 0
to_add = []
for each in list1:
if e... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR ... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | for _ in range(int(input())):
n = int(input())
l = []
for i in range(n):
bi, li = map(int, input().split())
l.append((bi, li))
l.sort()
d = dict()
co = 0
cb = 0
ms = []
for i, j in l:
try:
d[i]
co += j
except KeyError:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR V... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | for _ in range(int(input().strip())):
n = int(input().strip())
lst = []
for idx in range(n):
lst.append(list(map(int, input().strip().split())))
lst.sort()
distinct_song_dict = {}
first_songs = []
for song in lst:
band_no, song_length = song[0], song[1]
if band_no not... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL 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 FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR VAR VAR NU... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | try:
for _ in range(int(input())):
N = int(input())
cell = {}
variables = []
space = []
score = 0
variable = 0
for __ in range(N):
a, b = map(int, input().split())
if a not in cell:
cell[a] = b
elif cell[a] >... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST 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 VAR VAR ASSIGN VAR VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | a = int(input())
for _ in range(a):
aa = int(input())
kk = []
table = {}
for i in range(aa):
bb = list(map(int, input().split()))
kk.append((bb[0], bb[1]))
kk = sorted(kk, key=lambda x: x[1])
count = 0
l = 0
j = 0
for i in kk:
if i[0] not in table:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT 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 NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | from sys import stdin
t = int(stdin.readline())
for i in range(t):
n = int(stdin.readline())
count = 0
uniq = set()
final = []
sum1 = 0
list1 = []
for j in range(n):
b, l = list(map(int, stdin.readline().split()))
list1.append((b, l))
list1.sort(key=lambda x: x[1])
f... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | t = int(input())
for i in range(t):
n = int(input())
l = [list(map(int, input().split())) for j in range(n)]
l = sorted(l, key=lambda x: x[1])
k = set()
f = 0
prev = 0
sweetness = 0
for i in l:
if i[0] in k:
continue
sweetness += (f + 1) * i[1]
k.add(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 VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR ... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | t = int(input())
for _ in range(t):
n = int(input())
l = {}
ld = 0
for i in range(n):
x, y = map(int, input().split())
if x not in l:
l[x] = y
elif l.get(x) > y:
ld += l.get(x)
l[x] = y
else:
ld += y
sorted_l = sorted(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 DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | for _ in range(int(input())):
n = int(input())
songs = []
for _ in range(n):
songs.append(tuple(map(int, input().split())))
songs.sort(key=lambda x: x[1])
d = dict()
unique = []
common = []
for i, j in songs:
if i not in d:
d[i] = 1
unique.append((... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR VAR IF VAR VAR ... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | import time
start = time.time()
t = int(input())
for i in range(t):
n = int(input())
a = []
a1 = {}
sum1 = 0
lt = 0
for j in range(n):
b, l = map(int, input().split())
a.append([l, b])
a.sort()
c = 0
for k in a:
if k[1] in a1:
lt += k[0]
e... | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR E... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | t = int(input())
for T in range(t):
n = int(input())
val = []
s = set()
for i in range(n):
val.append([int(x) for x in input().split()][::-1])
val.sort()
c = 0
c1 = 0
ans = 0
for i in range(n):
if val[i][1] not in s:
s.add(val[i][1])
c += 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 LIST ASSIGN VAR FUNC_CALL VAR 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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR ... |
The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going t... | t = int(input())
for _ in range(t):
n = int(input())
arr = []
for i in range(n):
b, l = [int(x) for x in input().strip().split()]
arr.append((b, l))
arr = sorted(arr, key=lambda x: x[1])
band = {}
for i in range(n):
band[arr[i][0]] = 0
k = 0
uniqueval = 0
repe... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VA... |
Alina has discovered a weird language, which contains only $4$ words: ${A}$, ${B}$, ${AB}$, ${BA}$. It also turned out that there are no spaces in this language: a sentence is written by just concatenating its words into a single string.
Alina has found one such sentence $s$ and she is curious: is it possible that it ... | for _ in range(int(input())):
a, b, ab, ba = map(int, input().split())
s = input()
if s.count("A") != a + ab + ba:
print("NO")
continue
stack = [[1, s[0]]]
for i in range(1, len(s)):
if stack[-1][1] != s[i]:
x = stack.pop()
stack.append([x[0] + 1, s[i]... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST LIST NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER NUMB... |
Alina has discovered a weird language, which contains only $4$ words: ${A}$, ${B}$, ${AB}$, ${BA}$. It also turned out that there are no spaces in this language: a sentence is written by just concatenating its words into a single string.
Alina has found one such sentence $s$ and she is curious: is it possible that it ... | import sys
def solve():
inp = sys.stdin.readline
a, b, c, d = map(int, inp().split())
s = inp()
if s.count("A") != a + c + d or s.count("B") != b + c + d:
print("NO")
return
cc = {"A": [], "B": []}
f = 0
e = 0
for i in range(1, len(s) - 1):
if s[i] == s[i - 1]:
... | IMPORT FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING BIN_OP BIN_OP VAR VAR VAR FUNC_CALL VAR STRING BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR DICT STRING STRING LIST LIST ASSIGN VAR NUMBER ASSIGN VAR ... |
Alina has discovered a weird language, which contains only $4$ words: ${A}$, ${B}$, ${AB}$, ${BA}$. It also turned out that there are no spaces in this language: a sentence is written by just concatenating its words into a single string.
Alina has found one such sentence $s$ and she is curious: is it possible that it ... | def solve():
a, b, ab, ba = list(map(int, input().split()))
s = input().strip()
a_n = s.count("A")
b_n = s.count("B")
if a + ab + ba != a_n:
return False
elif b + ab + ba != b_n:
return False
abab_lens = []
baba_lens = []
ab_or_ba_count = 0
prev_symbol = None
... | FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF BIN_OP BIN_OP VAR VAR VAR VAR RETURN NUMBER IF BIN_OP BIN_OP VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN ... |
Alina has discovered a weird language, which contains only $4$ words: ${A}$, ${B}$, ${AB}$, ${BA}$. It also turned out that there are no spaces in this language: a sentence is written by just concatenating its words into a single string.
Alina has found one such sentence $s$ and she is curious: is it possible that it ... | tc = int(input())
for _ in range(tc):
a, b, c, d = list(map(int, input().split()))
s = input()
if s.count("A") != a + c + d:
print("NO")
continue
x = "X"
k = 0
z = []
for i in s:
if i == x:
z.append((k, x))
k = 1
else:
x = i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR VAR ... |
Alina has discovered a weird language, which contains only $4$ words: ${A}$, ${B}$, ${AB}$, ${BA}$. It also turned out that there are no spaces in this language: a sentence is written by just concatenating its words into a single string.
Alina has found one such sentence $s$ and she is curious: is it possible that it ... | import sys
input = sys.stdin.readline
def solve():
a, b, c, d = map(int, input().split())
s = input().strip()
n = len(s)
cnt = 0
for i in range(n):
if s[i] == "A":
cnt += 1
if cnt != a + c + d:
return "NO"
prev = -1
cnt = 0
r = []
for i in range(n):... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR BIN_OP BIN_OP VAR VAR VAR RETURN STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSI... |
Alina has discovered a weird language, which contains only $4$ words: ${A}$, ${B}$, ${AB}$, ${BA}$. It also turned out that there are no spaces in this language: a sentence is written by just concatenating its words into a single string.
Alina has found one such sentence $s$ and she is curious: is it possible that it ... | def solve():
cnt_a, cnt_b, cnt_ab, cnt_ba = map(int, input().strip().split())
s = input()
if s.count("A") != cnt_a + cnt_ba + cnt_ab:
print("NO")
return
stk = [[1, s[0]]]
for i in range(1, len(s)):
if i == 0:
continue
c = s[i]
if c != stk[-1][1]:
... | FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR LIST LIST NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR VAR IF VAR VA... |
Alina has discovered a weird language, which contains only $4$ words: ${A}$, ${B}$, ${AB}$, ${BA}$. It also turned out that there are no spaces in this language: a sentence is written by just concatenating its words into a single string.
Alina has found one such sentence $s$ and she is curious: is it possible that it ... | I = input
for _ in range(int(I())):
a, b, c, d = map(int, I().split())
s = I()
if s.count("A") != a + c + d:
print("NO")
continue
i, n, segs = 0, len(s), []
while i < n:
j = i
while i + 1 < n and s[i + 1] != s[i]:
i += 1
segs.append((i - j + 1, s[i... | ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR NUMBER FUNC_CALL VAR VAR LIST WHILE VAR VAR ASSIGN VAR VAR WHILE BIN_O... |
Alina has discovered a weird language, which contains only $4$ words: ${A}$, ${B}$, ${AB}$, ${BA}$. It also turned out that there are no spaces in this language: a sentence is written by just concatenating its words into a single string.
Alina has found one such sentence $s$ and she is curious: is it possible that it ... | t = int(input())
pp = 0
for _ in range(t):
a, b, c, d = [int(i) for i in input().split()]
s = input()
if s.count("A") != a + c + d or s.count("B") != b + c + d:
print("NO")
continue
l = len(s)
ult = "X"
k = 0
z = []
for i in range(l):
if s[i] == ult:
z... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING BIN_OP BIN_OP VAR VAR VAR FUNC_CALL VAR STRING BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for _ in range(int(input())):
n, k, x = map(int, input().split())
clear = [0]
clear.extend(sorted(list(map(int, input().split()))))
count = 0
while n - 1 >= 0:
if clear[n] + clear[n - 1] > x and k != 0:
count += x
k -= 1
n -= 2
else:
co... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR ... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for i in range(int(input())):
n, k, x = map(int, input().split())
a = [int(j) for j in input().split()]
a.sort(reverse=True)
ans, j = 0, 0
while j < len(a):
if j + 1 < len(a) and a[j] + a[j + 1] >= x and k > 0:
ans += x
j += 2
k -= 1
else:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR ... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for _ in range(int(input())):
n, k, x = map(int, input().split())
d = dict()
l = [int(i) for i in input().split()]
l = sorted(l)
ans = 0
while len(l) > 1:
f = 0
if len(l) > 1 and l[-1] + l[-2] > x and k:
ans += x
f = 1
l = l[:-2]
k ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER BIN... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | def solveF(N, K, X, A):
A.sort()
index = 0
single_remove = len(A) - 2 * K
cost = 0
while index < single_remove:
cost += A[index]
index += 1
if (len(A) - index) % 2:
cost += A[index]
index += 1
while index <= N - 2 and A[index] + A[index + 1] < X:
cost ... | FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR NUMBER IF BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER WHILE VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR VAR VAR BIN_... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | t = int(input())
for _ in range(t):
n, k, x = map(int, input().split())
a = list(map(int, input().split()))
j = n - 1
a.sort()
j = n - 1
ans = 0
for i in range(k):
q = a[j] + a[j - 1]
if q < x:
break
else:
ans += x
j -= 2
while ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for _ in range(int(input())):
n, k, x = map(int, input().split())
arr = sorted(list(map(int, input().split())))
s = 0
for i in range(n):
if i == n - 2 * k:
break
s += arr[i]
else:
i += 1
print(sum([min(x, arr[i] + arr[i + 1]) for i in range(i, n, 2)]) + s) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR BIN_OP NUMBER VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | t = int(input())
for i in range(t):
n, k, x = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
ans = 0
while k and len(a) > 1 and a[-1] + a[-2] > x:
ans += x
k -= 1
a.pop(-1)
a.pop(-1)
ans += sum(a)
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR VAR VAR VAR ... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for _ in range(int(input())):
n, k, x = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
i = len(arr) - 1
j = len(arr) - 2
cost = 0
if k == 0:
print(sum(arr))
else:
while k > 0:
if arr[i] + arr[j] > x:
cost += x
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR ... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for _ in range(int(input())):
n, k, x = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
l.reverse()
i, j = 0, 1
cs, ans = sum(l), sum(l)
while k > 0:
p = l[i] + l[i + 1]
cs -= p
if j * x + cs < ans:
ans = j * x + cs
i += 2
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR WHILE VAR NUMBER ASSIGN ... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for _ in range(int(input())):
n, k, x = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
cost = 0
length = n
while length:
if length >= 2 and arr[-1] + arr[-2] >= x and k > 0:
length -= 2
cost += x
arr = arr[0 : len(arr) - 2]
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR IF VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR VAR ASS... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for _ in range(int(input())):
n, k, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
cost = 0
i = n - 1
while k > 0 and i > 0:
if a[i] + a[i - 1] >= x:
k -= 1
cost += x
else:
break
i -= 2
for j in range(0, ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR ... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | import sys
for _ in range(int(sys.stdin.readline())):
n, k, x = map(int, sys.stdin.readline().split())
l = list(map(int, sys.stdin.readline().split()))
new = sorted(l, reverse=True)
ans = 0
f = 0
if n % 2:
f = 1
n -= 1
for i in range(0, n, 2):
if k == 0:
... | IMPORT FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | t = int(input())
for _ in range(t):
n, k, x = list(map(int, input().split()))
arr = list(map(int, input().split()))
ans = 0
a = sorted(arr)
ind = len(a) - 1
while k > 0 and len(a) > 1:
m = len(a)
sum1 = a[m - 1] + a[m - 2]
if x <= sum1:
a.pop(m - 1)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER FUNC_C... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | t = int(input())
for _ in range(t):
n, k, x = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
l.sort(reverse=True)
i, s = 0, 0
while i < n - 1 and k != 0:
if l[i] > x:
s += x
k -= 1
i += 2
elif l[i] + l[i + 1] > x:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR VAR VAR NUMBER VAR N... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | t = int(input())
for _ in range(t):
n, k, x = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
s = 0
sss = 0
for i in range(0, 2 * k, 2):
sss += l[i] + l[i + 1]
if l[i] + l[i + 1] > x:
s += x
else:
sss -= l[i] + l[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR NUMBER VAR BIN_OP ... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for i in range(int(input())):
n, k, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=1)
i = 0
ans = 0
while i + 1 < n and a[i] + a[i + 1] > x and k > 0:
ans += x
i += 2
k -= 1
if k == 0:
break
if i == n:
prin... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER ... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for _ in range(int(input())):
n, k, x = map(int, input().strip().split())
l = list(map(int, input().strip().split()))
if k == 0:
print(sum(l))
continue
l.sort()
ll = l[-2 * k :]
total = sum(l[: -2 * k])
for i in range(0, len(ll) - 1, 2):
if ll[i] + ll[i + 1] < x:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CAL... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | def solution(arr, k, x):
if k == 0:
return sum(arr)
min_cost = 0
for i in range(k):
if len(arr) < 2:
return sum(arr) + min_cost
S = arr[-1]
arr.pop()
S += arr[-1]
arr.pop()
if S < x:
return min_cost + S + sum(arr)
min_co... | FUNC_DEF IF VAR NUMBER RETURN FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR IF VAR VAR RETURN BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR VAR RETURN BIN_OP VAR FUNC_... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for _ in range(int(input())):
n, k, x = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
cost = sum(arr[: n - 2 * k])
arr = arr[n - 2 * k :]
for i in range(k):
cost += min(arr[2 * i] + arr[2 * i + 1], x)
print(cost) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | def solve():
n, k, x = [int(i) for i in input().split(" ")]
arr = [int(i) for i in input().split(" ")]
arr.sort(reverse=True)
sol = 0
for i in range(0, n, 2):
if k <= 0:
ind = i
break
if arr[i] + arr[i + 1] > x:
sol += x
k -= 1
... | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR NUMBER... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for _ in range(int(input())):
n, k, x = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
s = 0
for i in range(n):
if i == n - 2 * k:
break
s += arr[i]
else:
i += 1
pairDel = 0
for i in range(i, n, 2):
if arr[i] + arr[i... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR BIN_OP NUMBER VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FO... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | t = int(input())
for _ in range(t):
n, k, x = map(int, input().split())
l = list(map(int, input().split()))
if k == 0:
print(sum(l))
continue
l = sorted(l, reverse=True)
ans = 0
i = 0
while i < len(l) - 1 and k > 0:
if l[i] + l[i + 1] > x:
ans += x
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHIL... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | t = int(input())
for _ in range(t):
n, k, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
cost = 0
i = 0
while k > 0 and len(a) > 1:
i = len(a)
if a[i - 1] + a[i - 2] >= x:
cost += x
a.pop(-1)
a.pop(-1)
k ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR I... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for _ in range(int(input())):
n, k, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
flag = 1
i = 0
ans = 0
while i < n:
if i + 1 < n and k > 0 and flag:
if a[i] + a[i + 1] > x:
ans += x
i += 2
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER VAR VAR NUMBER VAR IF BIN_O... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | t = int(input())
for _ in range(t):
N, K, X = [int(x) for x in input().split()]
sequence = [int(x) for x in input().split()]
sequence.sort()
cost = sum(sequence[0 : N - 2 * K])
if K > 0:
for i in range(N - 2 * K, N, 2):
total = sequence[i] + sequence[i + 1]
cost += mi... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR BIN_OP NUMBER VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR BI... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | import sys
def yn(val):
re = ["Yes", "No"]
return re[val]
def Ajay():
aj = chr(65) + chr(74) + chr(64) + chr(165)
return aj
def main():
a, b, c = map(int, sys.stdin.readline().split())
arr = list(map(int, input().split()))
if b == 0:
return sum(arr)
arr.sort(reverse=True)
... | IMPORT FUNC_DEF ASSIGN VAR LIST STRING STRING RETURN VAR VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL ... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for _ in range(int(input())):
n, k, x = list(map(int, input().split()))
l = list(map(int, input().split()))
l.sort()
cost = 0
a = len(l)
d = a - 2 * k
i = 0
while i < a:
if i < d:
cost += l[i]
i += 1
elif l[i] + l[i + 1] < x:
cost += l[... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER WHIL... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | def prog_name():
n, k, const = map(int, input().split())
l = list(map(int, input().split()))
if k == 0:
print(sum(l))
else:
l.sort()
cost = 0
l.reverse()
ind = 0
while k > 0:
k -= 1
cost += min(l[ind] + l[ind + 1], const)
... | FUNC_DEF 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 IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR V... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for _ in range(int(input())):
n, k, x = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort(reverse=True)
change = 0
remove = 0
for i in range(0, n, 2):
if k > 0:
if arr[i] + arr[i + 1] > x:
change += x
remove += arr[i] + a... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR NUMBER IF BIN_OP VAR VAR VAR BIN_... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | def solve(array, k, sub):
array.sort()
cost = 0
index = len(array) - 1
while index >= 0:
if k > 0 and index > 0 and sub <= array[index] + array[index - 1]:
cost += sub
index -= 2
k -= 1
else:
cost += sum(array[: index + 1])
brea... | FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR AS... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for _ in range(int(input())):
N, K, X = map(int, input().split())
A = list(map(int, input().split()))
cost = 0
done = 1
A.sort()
while len(A) > 2 * K:
cost += A[0]
A.pop(0)
if K == 0:
print(cost)
else:
while A:
if A[0] + A[1] < X:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR WHILE FUNC_CALL VAR VAR BIN_OP NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF V... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | T = int(input())
for t in range(T):
n, k, x = [int(i) for i in str(input()).split()]
arr = [int(i) for i in str(input()).split()]
arr = sorted(arr, reverse=True)
final = 0
idx = 0
while True:
if arr[idx] + arr[idx + 1] > x and k > 0:
final += x
k -= 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF BIN_OP VAR VAR VA... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | T = int(input())
for t in range(T):
n, k, x = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
pair = 0
ts = 0
s = 0
i = n - 1
while pair < k and i >= 0:
if arr[i] + arr[i - 1] >= x:
s += x
pair += 1
i -= 2
els... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR NUMBER ... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | t = int(input())
for i in range(t):
n, k, x = map(int, input().split())
lis = list(map(int, input().split()))
lis.sort(reverse=True)
j = 0
sumi = 0
while j < n:
if k == 0:
break
if j + 1 < n:
temp = lis[j] + lis[j + 1]
if temp > x:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR B... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for _ in range(int(input())):
n, k, x = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
cost = 0
while k > 0 and len(arr) > 1:
sumc = arr[-1] + arr[-2]
if sumc >= x:
arr.pop(-1)
arr.pop(-1)
cost += x
k -= 1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CA... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | t = int(input())
for _ in range(t):
n, k, x = map(int, input().split())
arr = list(map(int, input().split()))
sum = 0
arr.sort(reverse=True)
pos = -1
for j in range(0, n - 1, 2):
if k == 0:
break
s = arr[j] + arr[j + 1]
sum += min(s, x)
k -= 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER IF VAR NUMB... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | def mincost(k, l):
n = k[0]
t = k[1]
x = k[2]
cost = 0
l = sorted(l)
c = 0
i = n - 1
while c == 0 and i >= 1:
if l[i] + l[i - 1] >= x and t != 0:
cost += x
t = t - 1
i = i - 2
else:
c += 1
if i == -1:
return cost... | FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VA... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for _ in range(int(input())):
n, k, x = map(int, input().split())
l = sorted(list(map(int, input().split())), reverse=True)
cost = i = 0
while True:
if i == len(l) - 1:
cost += l[i]
break
elif i >= len(l):
break
elif l[i] + l[i + 1] > x and k >... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 NUMBER ASSIGN VAR VAR NUMBER WHILE NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR VAR IF VAR FUNC_CALL VAR VAR IF BIN_OP ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.