description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
u = [int(i) for i in input().split()]
cnt = [(0) for i in range(10)]
ans = 0
for i in range(n):
cnt[u[i] - 1] += 1
cm = max(cnt)
c0 = cnt.count(0)
gen = cm - 1
if cnt.count(gen) == 10 - c0 - 1:
ans = i + 1
else:
temp = []
for x in cnt:
if x !=... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF FUNC_CALL V... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | import sys
n = int(input())
nums = list(map(int, input().split()))
eleCount = {}
possibleMax = 1
for i in range(n):
if nums[i] in eleCount.keys():
eleCount[nums[i]] += 1
if len(eleCount.keys()) == 1:
possibleMax = i + 1
else:
x = list(eleCount.values())
x... | IMPORT 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL V... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | def equal(a):
l = len(a)
for i in range(1, l):
if a[i - 1] != a[i]:
return 0
return 1
def equal1(a):
b = a[:]
if b[0] <= b[1]:
try:
posi1 = b.index(b[0] + 1)
b[posi1] = b[0]
return equal(b)
except ValueError:
retur... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR NUMBER RETURN FUNC_CALL VAR VAR VAR RETURN NUMBER ASSIGN VAR NUMBER BI... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
a = list(map(int, input().split()))
def ok(pos):
freq = list(filter(lambda x: x, count[pos]))
if len(freq) == 1:
return True
s = set(freq)
if len(s) == 1:
return freq[0] == 1
if len(s) > 2:
return False
_min, _max = sorted(s)
return (
_max -... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN VAR NUMBER NUMBER IF FUNC_CALL VAR VAR NUMBER RE... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
a = list(map(int, input().split()))
gg = [0] * 15
ans = 1
for i in range(n):
gg[a[i]] += 1
cnt1 = 0
s = set([])
for j in gg:
if not j:
continue
if j == 1:
cnt1 += 1
else:
s.add(j)
mkc = []
for j in s:
mkc.append... | 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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR LIST FOR VAR VAR IF VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | import sys
n = int(sys.stdin.readline().strip())
u = sys.stdin.readline().split()
for i in range(len(u)):
u[i] = int(u[i])
freq = [0] * 100005
freq_num = [0] * 100005
ans = 1
for i in range(1, len(u) + 1):
freq[u[i - 1]] += 1
freq_num[freq[u[i - 1]]] += 1
if not i == n and freq_num[freq[u[i - 1]]] * fr... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | NUMS = [(0) for i in range(10)]
def check(nums):
maxi = max(nums)
category = nums.count(maxi)
if category == 1:
oneof = 0
for n in nums:
if n == maxi:
continue
if n == 0:
continue
if oneof != 0 and (n != oneof or n != maxi... | ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR IF VAR NUMBER IF VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER RETURN NUMBER ASSIGN VAR VAR RETURN NUMBER IF VAR NUMBER IF FUNC_CALL VAR NUMBER NUMBER RETURN NU... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
A = list(map(int, input().split()))
f = [0] * int(100000.0 + 1)
cnt = [0] * int(100000.0 + 1)
mx = 0
max_idx = 0
valid = False
for i in range(1, len(A) + 1):
a = A[i - 1]
cnt[f[a]] -= 1
f[a] += 1
cnt[f[a]] += 1
mx = max(mx, f[a])
if cnt[1] == i:
valid = True
elif cnt... | 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 FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER B... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input().strip())
numbers = tuple(map(int, input().strip().split()))
occ = [(0) for i in range(100001)]
places = []
d = {}
for k in range(0, len(numbers)):
occ[numbers[k]] += 1
if occ[numbers[k]] - 1 in d.keys():
if d[occ[numbers[k]] - 1] == 1:
d.pop(occ[numbers[k]] - 1)
else:... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR NUMBER FUNC_CALL VAR IF VAR BIN... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
a = [(int(x) - 1) for x in input().split()]
counts = [0] * 10
for ind, i in enumerate(a):
counts[i] += 1
k = sorted([i for i in counts if i])
if (
len(k) == 1
or k[0] == k[-2]
and k[-1] - k[-2] == 1
or k[0] == 1
and k[1] == k[-1]
):
best =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER NUMBER V... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
a = list(map(int, input().split()))
dic = {a[0]: 1}
su = 1
kq = 1
for i in range(1, n):
if dic.get(a[i], 0) == 0:
dic.update({a[i]: 1})
else:
dic[a[i]] += 1
su += 1
cach = len(list(dic.keys()))
c = 0
c_ = 0
for z in list(dic.keys()):
if cach == 1:
... | 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 VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR DICT VAR VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER ASS... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | def get_num():
return int(input())
def print_arr(arr: list):
for val in arr:
print(val)
def read_num_list():
num_str = input()
return [int(v) for v in num_str.split(" ")]
def read_nums(k):
lst = []
for _ in range(k):
lst.append(get_num())
return lst
n = get_num()
colo... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
a = list(map(int, input().split()))
b = [(0) for i in range(10)]
pos = 1
for i in range(n):
b[a[i] - 1] += 1
c = []
for j in range(10):
if b[j] > 0:
c.append(b[j])
c.sort()
if (
c[len(c) - 1] == i + 1
or c[len(c) - 1] == c[len(c) - 2] + 1
... | 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 VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | counts = {}
rcount = {}
input()
m = 0
for i, x in enumerate(map(int, input().split())):
if x in counts:
rcount[counts[x]].remove(x)
if not rcount[counts[x]]:
del rcount[counts[x]]
counts[x] += 1
if counts[x] not in rcount:
rcount[counts[x]] = set()
rco... | ASSIGN VAR DICT ASSIGN VAR DICT EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR NUMBE... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | d = {}
n = int(input())
x = c = z = m = p = 0
y = 1
a = list(map(int, input().split()))
for i in range(n):
d[a[i]] = k = d.get(a[i], 0) + 1
if k == 1:
z += y
m += 1
p += 1
elif k == 2:
p -= 1
if k == y + 1:
if c == 0:
z = y * m - i
c = 1
... | ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER IF VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER IF VAR NUM... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
u = input().split()
d = {}
for i in set(u):
d[i] = u.count(i)
for i in range(1, n + 1):
l = list(set(dict.values(d)))
if len(l) == 2:
warn = 0
warning = 0
for j in d:
if d[j] == max(l):
warning += 1
elif d[j] == min(l):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
u = list(map(int, input().split()))
nu = 100000
cl = [0] * nu
cl[u[0] - 1] += 1
md = 1
mcl = 1
cmcl = 1
clcl = 0
cocl = 1
czcl = nu - 1
for i in range(1, n):
cc = u[i] - 1
cl[cc] += 1
if cl[cc] == 1:
czcl -= 1
cocl += 1
if cl[cc] == 2:
cocl -= 1
if cl[cc] == ... | 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 BIN_OP LIST NUMBER VAR VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
p = input().rstrip().split(" ")
l = [0] * 10
for i in range(0, len(p)):
l[int(p[i]) - 1] += 1
T = list(set(l))
T.sort(key=int, reverse=True)
if 0 in T:
if len(T) == 2:
if T[0] == 1:
q = i
elif l.count(T[0]) == 1:
q = i
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER IF NUMBER VAR IF FUNC_CAL... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
colors = list(map(int, input().split()))
cnt = [(0) for _ in range(100001)]
vals = dict()
ind = 1
for i in range(n):
el = colors[i]
if cnt[el] != 0:
vals[cnt[el]] -= 1
if vals[cnt[el]] == 0:
del vals[cnt[el]]
cnt[el] += 1
if cnt[el] in vals:
vals[cnt[... | 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 VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR NUMBER VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER VAR VAR VAR VAR VAR NUMB... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
b = {}
c = {}
d = []
for i in range(n):
b[a[i]] = b.get(a[i], 0) + 1
c[b[a[i]]] = c.get(b[a[i]], 0) + 1
if c[b[a[i]]] * b[a[i]] == i + 1:
if i + 2 <= n:
d.append(i + 2)
if c[b[a[i]]] * b[a[i]]... | 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 ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR VAR ... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
u = list(map(int, input().split()))
cnts = [(0) for _ in range(11)]
b = 1
for i in range(n):
cnts[u[i]] += 1
nz = 11 - cnts.count(0)
j = i + 1
if nz == 1:
b = j
continue
if j % nz == 1:
c = j // nz
if cnts.count(c) + 1 == nz:
b = j
... | 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 VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR IF B... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
arr = list(map(int, input().split()))
fr = {}
nmbr = {}
days = 0
M = 0
for i in range(1, n + 1):
fr[arr[i - 1]] = fr.get(arr[i - 1], 0)
nmbr[fr[arr[i - 1]]] = nmbr.get(fr[arr[i - 1]], 0) - 1
fr[arr[i - 1]] = fr.get(arr[i - 1], 0) + 1
nmbr[fr[arr[i - 1]]] = nmbr.get(fr[arr[i - 1]], 0) + ... | 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 ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR BIN_... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
a = [int(x) for x in input().split()]
arr = [0] * 100001
freqs = [0] * 100001
freqs[0] = n
minf, maxf = 0, 0
for ind, i in enumerate(a):
arr[i] += 1
freqs[arr[i]] += 1
freqs[arr[i] - 1] -= 1
if not freqs[arr[i] - 1] and minf == arr[i] - 1:
minf += 1
maxf = max(maxf, arr[i])
... | 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 NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER NUMBER IF... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
arr = list(map(int, input().split()))
count = [0] * 10
ans = 1
for i in range(n):
count[arr[i] - 1] += 1
cp_count = list.copy(count)
cp_count.sort()
r = 0
for j in range(1, 10):
if cp_count[j] != cp_count[j - 1]:
r += 1
if r == 0 and cp_count[0] == 1:
... | 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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBE... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
u = [int(x) for x in input().split()]
colors = [(0) for _ in range(10)]
streak = 1
def check1(d):
c = [d[i] for i in range(10)]
a = max(c)
f1 = False
for i in range(10):
if c[i] == 1:
c[i] = 0
f1 = True
break
if not f1:
return Fa... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR N... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | from sys import setcheckinterval, setrecursionlimit, stdin
setcheckinterval(1000)
setrecursionlimit(10**6)
iin = lambda: int(stdin.readline())
lin = lambda: list(map(int, stdin.readline().split()))
n = iin()
a = lin()
a = [(i - 1) for i in a]
sol = [[(0) for i in range(10)] for i in range(n)]
for i in range(n):
so... | EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER 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 ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR ... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | def Maximum_Streak(a):
counts = [0] * 11
for index, v in enumerate(a):
counts[v] += 1
k = sorted([i for i in counts if i])
if (
len(k) == 1
or k[0] == k[-2]
and k[-1] - k[-2] == 1
or k[0] == 1
and k[1] == k[-1]
):
... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR RETURN BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL V... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
l = list(map(int, input().split()))
res = 0
c = [0] * 10
for j in range(n):
c[l[j] - 1] += 1
lo = [i for i in c if i]
lo.sort()
if (
len(lo) == 1
or lo[0] == lo[-2]
and lo[-1] - 1 == lo[-2]
or lo[1] == lo[-1]
and lo[0] == 1
):
res = j
... | 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 BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER BIN_... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | import sys
allnums = (int(x) for x in sys.stdin.readlines()[1].split())
maxx = 0
counts = [(0) for i in range(0, 10)]
def isok():
global counts
nonzeroes = [c for c in counts if c != 0]
if len(nonzeroes) == 1:
return True
if any(x == 1 for x in nonzeroes):
s = sum(nonzeroes)
n... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER IF FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
u = [int(x) for x in input().split()]
cnt = {}
for x in u:
cnt[x] = cnt.get(x, 0) + 1
cnt2 = {}
for v in cnt.values():
cnt2[v] = cnt2.get(v, 0) + 1
k = len(u)
while True:
if len(cnt2) == 1:
if list(cnt2.values())[0] == 1 or list(cnt2.keys())[0] == 1:
print(k)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR 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 DICT FOR VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE NUMBER IF FUNC_... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
lis = [0] + list(map(int, input().split()))
a = [0] * 100004
b = [0] * 100004
ans = 1
for i in range(1, n + 1):
a[lis[i]] += 1
b[a[lis[i]]] += 1
if a[lis[i]] * b[a[lis[i]]] == i and i != n:
ans = i + 1
elif a[lis[i]] * b[a[lis[i]]] == i - 1:
ans = i
print(ans) | 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 BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER IF BIN_OP VAR ... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
u = list(map(int, input().split()))
cnt = [0] * 10
x = 0
for k in range(n):
i = u[k]
cnt[i - 1] += 1
f = 1
ch = 0
f1 = 0
oc = 0
cnt1 = sorted(cnt)
for p in range(len(cnt1)):
j = cnt1[p]
if not j:
continue
if j == 1:
q = p +... | 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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FU... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
temp = list(map(int, input().split()))
x = 0
hold = [0] * 20
hold[temp[0]] = 1
for j in range(1, n):
hold[temp[j]] = hold[temp[j]] + 1
anmol = set(hold)
if len(anmol) == 2:
anmol = sorted(anmol)
t = anmol[1] + anmol[0]
if 1 in anmol:
x = j
elif ho... | 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 BIN_OP LIST NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NU... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
ui = list(map(int, input().split()))
ar = [0] * 100001
ar2 = [0] * 100001
maxi = 1
mini = 1
ans = 1
for i in range(n):
if ar[ui[i]] == 0:
ar[ui[i]] = 1
mini = 1
ar2[1] += 1
else:
ar2[ar[ui[i]]] -= 1
if ar2[ar[ui[i]]] == 0 and mini == ar[ui[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 BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR N... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | from sys import stdin, stdout
n = int(stdin.readline())
arr = list(map(int, stdin.readline().strip().split(" ")))
farr = [(0) for i in range(10**5 + 2)]
carr = [(0) for i in range(n + 1)]
colorseen = [(0) for i in range(10**5 + 2)]
seentillnow = 0
ansind = -1
for i in range(len(arr)):
if colorseen[arr[i]] == 0:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER A... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | d1, d2 = {}, {}
n = int(input())
s = list(map(int, ("0 " + input()).split()))
r = 1
for i in range(1, n + 1):
d1[s[i]] = d1.get(s[i], 0) + 1
d2[d1[s[i]]] = d2.get(d1[s[i]], 0) + 1
if d2[d1[s[i]]] * d1[s[i]] == i and i != n:
r = i + 1
if d2[d1[s[i]]] * d1[s[i]] == i - 1:
r = i
print(r) | ASSIGN VAR VAR DICT DICT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL BIN_OP STRING FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR ... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | import sys
def is_party_time(d):
for item in d.keys():
sub_d = d.copy()
sub_d[item] -= 1
if sub_d[item] == 0:
del sub_d[item]
if len(set(sub_d.values())) <= 1:
return True
return False
def cat_party_house(n, a):
result = None
d = dict()
for... | IMPORT FUNC_DEF FOR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR NUMBER VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NONE ASSIGN VAR FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NONE ASSIGN VAR VAR NUMBER VAR VAR ... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
a = map(int, input().split())
c = {}
d = 0
for i, x in enumerate(a):
c[x] = c.get(x, 0) + 1
if len(c) > 1:
if 1 in c.values():
x = len(c) - 1
if x and 0 == i % x:
y = i / x
if max(c.values()) == y:
d = max(d, i ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER IF FUNC_CALL VAR VAR NUMBER IF NUMBER FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR NUMBER B... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
arr = list(map(int, input().split()))
lis = [0] * 10
ans = 0
for j in range(n):
lis[arr[j] - 1] += 1
num = []
for i in range(10):
if lis[i] > 0:
num.append(lis[i])
a = max(num)
if a == 1:
ans = max(ans, sum(num))
elif len(num) == 1:
ans = max(... | 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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
mark = [(0) for _ in range(11)]
a = list(map(int, input().split()))
minus = 0
for v in a:
mark[v] += 1
for v in a[::-1]:
temp = []
done = []
for value in mark:
if value != 0:
temp.append(value)
temp.sort()
if temp.count(1) == 1 and (len(set(temp)) == 1 or len... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR NUMBER FOR VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF FUNC... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | def gns():
return [int(x) for x in input().split()]
def gn():
return int(input())
n = gn()
ns = gns()
cl = {}
nn = {}
ans = -1
i = 0
for c in ns:
i += 1
if i == 2:
xxxx = 0
if c in cl:
cl[c] += 1
else:
cl[c] = 1
t = cl[c]
if t in nn:
nn[t] += 1
els... | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR ... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | N = int(input())
A = [int(a) for a in input().split()]
C = [0] * 101010
ma = 0
macnt = 0
poscnt = 0
cntofone = 0
ans = 0
for i in range(N):
C[A[i]] += 1
if C[A[i]] > ma:
ma = C[A[i]]
macnt = 1
elif ma == C[A[i]]:
macnt += 1
if C[A[i]] == 1:
poscnt += 1
cntofone +=... | 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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | m = [0] * 100001
t = dict()
n = int(input())
(*l,) = map(int, input().split())
minI = 1
maxI = 1
x = 0
for i in range(n):
if m[l[i]] != 0:
t[m[l[i]]].remove(l[i])
if len(t[m[l[i]]]) == 0:
t.pop(m[l[i]])
m[l[i]] += 1
if t.get(m[l[i]]) == None:
t[m[l[i]]] = {l[i]}
else:... | ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR IF FUNC_CALL VAR VAR VAR ... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
a = [int(s) for s in input().split()]
b = []
c = []
x = 1
for i in range(n):
if a[i] not in b:
b.append(a[i])
c.append(1)
else:
for j in range(len(b)):
if b[j] == a[i]:
c[j] += 1
count = 0
k = 0
lenb = len(b)
if lenb > 5 and ((... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER ASSIGN... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
L = [int(i) for i in input().split()]
D = {}
def check(D):
G = list(D.values())
G = list(reversed(sorted(G)))
f = len(G) - 1
if f == 0:
return 1
elif G[0] == G[1] + 1 == G[f] + 1:
return 1
elif G[0] == G[f - 1] and G[f] == 1:
return 1
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER BIN_OP VAR NUMBER ... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
a = list(map(int, input().split()))
dic = {i: (0) for i in range(1, 11)}
maxIndex = 0
for i in range(n):
dic[a[i]] += 1
flag = False
occurence = set(dic.values()).difference({0})
if len(occurence) > 2:
continue
occurence = list(occurence)
occurence.sort()
if (
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR NU... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
a = [int(i) for i in input().split()]
b = []
for i in range(11):
b.append(0)
m = 0
b[a[0]] = 1
for i in range(1, n):
b[a[i]] += 1
c = set(b)
if len(c) == 2:
c = sorted(c)
t = c[0] + c[1]
if 1 in c:
m = i
elif b.count(t) == 1:
m = i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMB... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
nums = list(map(int, input().split()))
cnt = [0] * (10**5 + 10)
f = [0] * (10**5 + 10)
ans = 1
mx = 1
for i in range(1, n + 1):
if cnt[f[nums[i - 1]]] != 0:
cnt[f[nums[i - 1]]] -= 1
f[nums[i - 1]] += 1
cnt[f[nums[i - 1]]] += 1
mx = max(mx, f[nums[i - 1]])
ok = False
if c... | 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 BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER I... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | def checkEqual(array):
while 0 in array:
array.remove(0)
return len(list(set(array))) == 1 or len(array) == 0
def check(dic):
v = dic.values()
v = list(v)
while 0 in v:
v.remove(0)
v = sorted(v)
if len(v) > 1:
for i in range(len(v)):
arr = [(v[k] if k !=... | FUNC_DEF WHILE NUMBER VAR EXPR FUNC_CALL VAR NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE NUMBER VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VA... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | from sys import stdin
def main():
n = int(stdin.readline())
ar = list(map(int, stdin.readline().split()))
c = [0] * (10**5 + 1)
f = [0] * (10**5 + 1)
ans = 1
c[ar[0]] += 1
f[c[ar[0]]] += 1
df = 1
dn = 1
for i in range(1, n):
curr = ar[i]
if c[curr] > 0:
... | 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 BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER VAR VAR NUMBER NUMBER VAR VAR VAR NUMBER NUMBER ASSIGN VA... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
arr = [int(x) for x in input().split()]
counts = [0] * 100000
count_to_color = {}
mx = 0
for i in range(n):
color = arr[i] - 1
if counts[color] > 0:
count_to_color[counts[color]].remove(color)
if not count_to_color[counts[color]]:
del count_to_color[counts[color]]
... | 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 NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASS... |
This problem is same as the next one, but has smaller constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the $n$ days since the day Shiro moved to the... | n = int(input())
otv = 1
a = list(map(int, input().split()))
kol = dict()
for i in range(n):
o = a[i]
if o not in kol:
kol[o] = 1
else:
kol[o] += 1
sv = set(kol.values())
if sv == {1} or len(set(kol.keys())) == 1:
otv = i + 1
elif len(sv) == 2 and min(sv) == 1 and list(ko... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER FUNC_CALL VAR FUNC_CALL V... |
Given an undirected connected graph of n vertices and list of m edges in a graph and for each pair of vertices that are connected by an edge.
There are two edges between them, one curved edge and one straight edge i.e. the tuple (x, y, w1, w2) means that between vertices x and y, there is a straight edge with weight w... | class Solution:
def dijkstra(self, u, b, n, adj):
unused = []
dis = [float("inf")] * (n + 1)
dis[u] = 0
unused.append((0, u))
heapify(unused)
while unused:
x, v = heappop(unused)
if x > dis[v]:
continue
for edge in ... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST FUNC_CALL VAR STRING BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR FOR VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF BIN_OP VAR VAR VAR VAR VAR ... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | import sys
input = sys.stdin.readline
n, q = map(int, input().split())
a = list(map(int, input().split()))
query = [int(input()) for i in range(q)]
max_a = max(a)
for i in range(n):
if a[i] == max_a:
max_ind = i
break
ans = [0] * (n + 1)
tmp_max = -1
if max_ind == 0:
i = -1
else:
b = []
... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBE... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | from sys import setcheckinterval, stdin
setcheckinterval(1000)
iin = lambda: int(stdin.readline())
lin = lambda: list(map(int, stdin.readline().split()))
n, q = lin()
a = lin()
if q == 0:
exit()
Q = [iin() for i in range(q)]
sq = set(Q)
mx = max(Q)
d = dict()
ch = 1
for i in range(min(mx, n + 1)):
if ch == n:
... | EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | n, q = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
mx = max(a)
ans = []
idx = a.index(mx)
bk = []
if idx == 0:
pass
else:
cur = max(a[0], a[1])
ans.append([a[0], a[1]])
bk.append(min(a[0], a[1]))
for i in range(2, idx + 1):
ans.append([cur, a[i]])
bk.appen... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR LIST VAR NUMBER VAR NUMBER EXPR ... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | M = 10**9 + 7
R = lambda: map(int, input().split())
n, q = R()
L = list(R())
ma = max(L)
ind = L.index(ma)
res = [[L[0], L[1]]]
p = max(L[0], L[1])
A = [min(L[0], L[1])]
for i in range(2, n):
res.append([p, L[i]])
if p < L[i]:
A.append(p)
p = L[i]
else:
A.append(L[i])
for i in range(... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST LIST VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIG... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | n, q = map(int, input().split())
ai = list(map(int, input().split()))
ar = []
ar3 = []
num = 1
nummm = max(ai)
if ai[0] != nummm:
num2 = ai[0]
for i in range(1, n):
ar3 += [[num2, ai[i]]]
if ai[i] == nummm:
ar += [num2]
num = i + 1
break
if ai[i] > num... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR LIST LIST VAR VAR VAR IF VAR VAR VAR VAR... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | a = [int(i) for i in input().split(" ")]
b = [int(i) for i in input().split(" ")]
c = []
maxnum = max(b)
index = 0
for i in range(a[0]):
c.append([b[0], b[1]])
if b[0] < b[1]:
small = b.pop(0)
else:
small = b.pop(1)
b.insert(a[0] - 1, small)
if b[0] == maxnum:
index = i + 1
... | ASSIGN 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 ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR LIST VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR ... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | nq = input().split()
n = int(nq[0])
q = int(nq[1])
arr = list(map(int, input().split()))
arr_q = []
for _ in range(q):
arr_q.append(int(input()))
largest1 = max(arr)
new_arr = []
for i in arr:
new_arr.append(i)
for i in range(n - 1):
if new_arr[i] > new_arr[i + 1]:
new_arr[i : i + 2] = [new_arr[i + ... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR ... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | n, q = map(int, input().split())
a = list(map(int, input().split()))
l = [a[0]]
for i in range(n - 1):
A, B = l[i], a[i + 1]
if A < B:
A, B = B, A
l.append(A)
a.append(B)
for i in range(q):
m = int(input())
if m <= n:
print(l[m - 1], a[m])
else:
print(l[-1], a[n + (m ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR ... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | n, q = map(int, input().split())
ls = list(map(int, input().split()))
M = [ls[0]]
for i in ls[1:]:
M.append(max(M[-1], i))
ans = []
for i in range(n - 1):
ans.append((M[i], ls[i + 1]))
for i in range(n - 1):
ans.append((M[-1], min(ans[i][0], ans[i][1])))
for i in range(q):
m = int(input())
try:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER FOR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMB... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | n, q = map(int, input().split())
a = [int(x) for x in input().split()]
mx = max(a)
d = {}
i = 0
while a[i] != mx:
x, y = a[i], a[i + 1]
a.append(min(x, y))
a[i + 1] = max(x, y)
i += 1
d[i] = x, y
la = len(a)
for qi in range(q):
mj = int(input())
if mj <= i:
print(d[mj][0], d[mj][1])
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR NUMBER WHILE VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL ... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | import sys
n, q = list(map(int, input().split()))
a = list(map(int, input().split()))
mx1 = max(a)
a1 = []
dp = {}
for i in range(q):
a1.append(int(input()))
if a1 == []:
mx = 0
else:
mx = max(a1)
count = 0
while 1:
count += 1
val1 = a[0]
val2 = a[1]
if val1 == mx1:
break
if val... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR LIST ASSIGN VAR NUMBER ASSIGN VAR ... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | n, q = map(int, input().split())
dek = list(map(int, input().split()))
b = [0] * (n - 1)
c = [0] * (n - 1)
l = 0
r = 1
for i in range(1, n):
b[i - 1] = dek[l]
c[i - 1] = dek[r]
if dek[l] >= dek[r]:
r += 1
else:
l = r
r += 1
if r == n:
r = 0
for i in range(q):
m = ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VA... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | arr = input()
N, Q = [int(x) for x in arr.split(" ")]
arr = input()
arr = [int(x) for x in arr.split(" ")]
ans = {}
maxi = max(arr)
A = arr[0]
B = arr[1]
idx = 0
for i in range(1, N):
B = arr[i]
C = min(A, B)
ans[i] = [A, B, C]
A = max(A, B)
if A == maxi:
idx = i
break
check = [0] * ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | n, x = map(int, input().split())
m = list(map(int, input().split()))
ind = 0
for i in range(n):
if m[ind] < m[i]:
ind = i
z = m[ind]
r = m[0]
ans = []
l = []
for i in range(ind):
ans.append([r, m[i + 1]])
l.append(min(m[i + 1], r))
if r < m[i + 1]:
r = m[i + 1]
for i in range(ind + 1, n)... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | n, q = map(int, input().split())
a = list(map(int, input().split()))
MAX = max(a)
max_idx = a.index(MAX)
pulled = [[-1, -1]]
for i in range(max_idx):
pulled.append([a[i], a[i + 1]])
a[i], a[i + 1] = (a[i + 1], a[i]) if a[i] > a[i + 1] else (a[i], a[i + 1])
k = max_idx
l = []
for i in range(k + 1, len(a)):
l... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR BIN_... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | def func(a, n, maxa, index):
first = a[0]
ans = []
arr = []
for i in range(1, index + 1):
second = a[i]
ans.append([first, second])
if first > second:
arr.append(second)
else:
arr.append(first)
first = second
if index == n - 1:
... | FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR IF VAR BIN_OP VAR NUMBER RETURN LIST VAR VAR RETURN LIST VAR BIN_OP VAR BIN_OP VAR NUMB... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | n, m = map(int, input().split())
arr = list(map(int, input().split()))
fr = [0] * n
br = [0] * n
cyc = [0] * (n - 1)
maxind = 0
for i in range(n):
if arr[i] > arr[maxind]:
maxind = i
pick = arr[0]
last = -1
for i in range(n):
if i >= maxind:
fr[i] = arr[maxind]
if i != n - 1:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR AS... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | n, k = map(int, input().split())
a = list(map(int, input().split()))
mx = max(a)
ind = a.index(mx)
f = 0
s = 1
ans = [[] for i in range(ind)]
for i in range(ind):
ans[i].append(a[f])
ans[i].append(a[s])
if a[f] >= a[s]:
a.append(a[s])
s += 1
else:
a.append(a[f])
f = s
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FU... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | [n, q] = list(map(int, input().split()))
a = list(map(int, input().split()))
qry = [(0) for i in range(q)]
for i in range(q):
qry[i] = int(input())
ans = [[-1, -1]]
m = max(a)
idx = a.index(m)
t1 = a[0]
for i in range(idx):
ans.append([t1, a[i + 1]])
a.append(min(t1, a[i + 1]))
t1 = max(a[i + 1], t1)
fo... | ASSIGN LIST 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 VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSI... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | n, q = map(int, input().strip().split())
d = list(map(int, input().strip().split()))
if q:
m = -1
m_i = -1
m_p = []
for i in range(n):
if d[i] > m:
m = d[i]
m_i = i
m_p.append(m)
new_d = []
new_d[m_i + 1 :] = d[m_i + 1 :]
for i in range(m_i):
i... | ASSIGN 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASS... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | n, q = map(int, input().split())
a = list(map(int, input().split()))
b = [-1] * (3 * n)
s = 0
d = []
e = n - 1
if q == 0:
exit()
c = [[a[0], a[1]]]
for i in range(n):
b[i] = a[i]
m = max(a)
while b[s] != m:
if b[s] > b[s + 1]:
b[s + 1], b[e + 1] = b[s], b[s + 1]
s += 1
e += 1
els... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST LIST VAR NUMBER VAR NUMBER FOR VAR F... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | n, q = map(int, input().split())
l = list(map(int, input().split()))
m = max(l)
tab = [0] * 2 * n
for i in range(n):
tab[i] = l[i]
odp = [[0, 0]] * n
pocz = 0
kon = n - 1
for j in range(n):
A = tab[pocz]
B = tab[pocz + 1]
odp[j] = [A, B]
pocz += 1
kon += 1
tab[pocz] = max(A, B)
tab[kon] ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST LIST NUMBER NUMBER VAR ASSIGN VAR NUMBER ASSIGN... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | from sys import stdin, stdout
n, q = map(int, stdin.readline().split())
arr = [int(el) for el in stdin.readline().split()]
query = []
for i in range(q):
query.append(int(stdin.readline()))
last = []
mx = max(arr)
left = 0
right = 1
count = 1
initial = {}
while arr[left] != mx:
initial[count] = [arr[left], arr[... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT WH... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | n, t = map(int, input().split())
a = list(map(int, input().split()))
b, c = [], []
u = a[0]
for v in a[1:]:
b.append(u)
if v > u:
u, v = v, u
c.append(v)
for _ in range(t):
x = int(input())
if x < n:
print(b[x - 1], a[x])
else:
print(u, c[(x - 1) % (n - 1)]) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST ASSIGN VAR VAR NUMBER FOR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | n, q = list(map(int, input().split()))
arr = list(map(int, input().split()))
maxi = max(arr[0], arr[1])
reste = [min(arr[0], arr[1])]
hist_maxi = [maxi]
for i in range(2, n):
if arr[i] > maxi:
reste.append(maxi)
maxi = arr[i]
else:
reste.append(arr[i])
hist_maxi.append(maxi)
for qi i... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR LIST FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR LIST VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR EXPR FUNC_CALL ... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | import sys
IS_LOCAL = False
def readMultiple(f):
return f(map(int, input().split()))
def main():
n, q = 5, 10
xs = [2, 3, 1, 4, 5]
qs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
if not IS_LOCAL:
n, q = readMultiple(tuple)
xs = readMultiple(list)
qs = []
for _ in range(q):
... | IMPORT ASSIGN VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER IF VAR ASSIGN VAR VAR FUNC_CALL VAR VAR ASSIGN V... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | o = input().rstrip().split(" ")
p = input().rstrip().split(" ")
C = list(p)
C.sort(key=int, reverse=True)
t = int(C[0])
l = []
q = []
w = []
S = []
D = []
i = 0
while i < len(p) - 1:
if int(p[i]) != t:
l.append(int(p[i]))
q.append(int(p[i + 1]))
if int(p[i]) > int(p[i + 1]):
p.ap... | ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_C... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | x, y = map(int, input().split())
arr = list(map(int, input().split()))
arr1 = []
arr2 = []
if y == 0:
print("")
exit()
for i in range(0, y):
arr1.append(int(input()))
maxi = max(arr)
i = 1
while 1:
if arr[0] == maxi:
break
a = arr[0]
b = arr[1]
if a > b:
del arr[1]
ar... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | n, e = map(int, input().split())
d = list(map(int, input().split()))
ind = d.index(max(d))
maxs = d[ind]
q = []
while True:
if d[0] > d[1]:
q.append((d[0], d[1]))
r = d.pop(1)
d.append(r)
else:
q.append((d[0], d[1]))
t = d.pop(0)
d.append(t)
if d[0] == maxs:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR LIST WHILE NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER EXPR FU... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | def main():
n, q = map(int, input().split())
arr = list(map(int, input().split()))
dp = []
max_val = max(arr)
while arr[0] != max_val:
dp.append((arr[0], arr[1]))
if arr[1] >= arr[0]:
arr.append(arr.pop(0))
else:
arr.append(arr.pop(1))
for i in ran... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL ... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | n_q = list(map(int, input().split(" ")))
arr = list(map(int, input().split(" ")))
arr_ind = [i for i in range(n_q[0])]
max_val, max_ind = -1000, -1
for i in range(n_q[0]):
if arr[i] > max_val:
max_val = arr[i]
max_ind = i
pull = []
for i in range(max_ind + 1):
pull.append([arr[0], arr[1]])
i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST F... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | str1 = input().split()
n = int(str1[0])
q = int(str1[1])
str2 = input().split()
arr = []
for num in str2:
arr.append(int(num))
dict = {}
q_list = []
max_num = max(arr)
max_index = arr.index(max_num)
for i in range(q):
mj = int(input())
if mj <= max_index:
dict[mj] = ""
q_list.append(mj)
for i in... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR V... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | def op(arr, num):
for i in range(0, num - 1):
if arr[0] > arr[1]:
z = arr.pop(1)
arr.append(z)
else:
z = arr.pop(0)
arr.append(z)
print(arr[0], arr[1])
def opmod(arr, num):
count = 0
while arr[0] != num:
if arr[0] > arr[1]:
... | FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR FUNC... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | import sys
n, q = map(int, sys.stdin.readline().split())
a = list(map(int, sys.stdin.readline().split()))
d = {}
d[0] = a[0]
b = []
b.append(0)
for i in range(1, n):
d[i] = max(d[i - 1], a[i])
b.append(min(d[i - 1], a[i]))
b[0] = d[n - 1]
for _ in range(q):
m = int(sys.stdin.readline())
if m > n - 1:
... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | n, q = [int(x) for x in input().split(" ")]
a = [int(x) for x in input().split(" ")]
C = a[0]
resp = []
before = []
maxn = a[0]
pos = 0
for i in range(1, n):
if a[i] > maxn:
maxn = a[i]
pos = i
for i in range(pos + 1, n):
resp.append(a[i])
for i in range(1, pos + 1):
A = C
B = a[i]
b... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | a, b = map(int, input().split())
A = list(map(int, input().split()))
A.append(-1)
B = []
Z = []
AN = []
x, y = A[0], A[1]
for i in range(a - 1):
Z.append((x, y))
if x > y:
B.append(y)
y = A[i + 2]
else:
B.append(x)
x, y = y, A[i + 2]
for i in range(b):
w = int(input())
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR VAR EXPR FU... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | n, queries = list(map(int, input().split()))
l = list(map(int, input().split()))
if queries == 0:
exit()
maxval = max(l)
pairs = []
count = 0
f = l[0]
secix = 1
while f != maxval:
count += 1
f = l[0]
s = l[secix]
pairs.append([f, s])
f, s = max(f, s), min(f, s)
l[0] = f
l.append(s)
s... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | n, q = input().split()
if q == "0":
exit(0)
l = list(map(int, input().split()))
m = max(l)
f = []
while 1:
if l[0] == m:
break
a = l[0]
b = l[1]
f.append([a, b])
if a > b:
del l[1]
l.append(b)
else:
del l[0]
l.append(a)
for i in range(int(q)):
m = ... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST WHILE NUMBER IF VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR IF VAR VAR VAR NUMBER ... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | import sys
n, q = [int(i) for i in sys.stdin.readline().split()]
data = [int(i) for i in sys.stdin.readline().split()]
mx = max(data)
ans = [(-1, -1)]
while data[0] != mx:
ans.append((data[0], data[1]))
if data[0] > data[1]:
data.append(data.pop(1))
else:
data.append(data.pop(0))
cnt = len(... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER WHILE VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER EXPR FUNC... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | import sys
n, q = list(map(int, sys.stdin.readline().strip().split()))
a = list(map(int, sys.stdin.readline().strip().split()))
m = [0] * q
M = max(a)
i = 0
x = a[0]
L = []
L1 = []
L2 = []
while x != M:
L1.append(x)
L2.append(a[i + 1])
i = i + 1
if x < a[i]:
L.append(x)
x = a[i]
els... | IMPORT ASSIGN VAR VAR FUNC_CALL 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 ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST WHIL... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | t = list(map(int, input().split()))
n, q = t[0], t[1]
a = list(map(int, input().split()))
list_m = []
A, B = 0, 0
for i in range(q):
l = len(list_m)
m = int(input())
t = int(m / (n - 1)) - 1
if t < 0:
t = 0
m = m - t * (n - 1)
if m <= l:
A, B = list_m[m - 1][0], list_m[m - 1][1]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | n, q = map(int, input().split())
l = list(map(int, input().split()))
l0 = l[:]
q_array = []
M = -float("inf")
a_array = []
back_array = []
chain = []
for i in range(n):
if l[i] >= M:
q_array.append(i)
a_array.append(M)
back_array += chain
back_array.append(M)
chain = []
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VA... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | from sys import stdin, stdout
input = stdin.readline
n, q = map(int, input().split())
a = list(map(int, input().split()))
b = max(a)
c = a.index(b)
d = []
for i in range(c):
d.append([a[0], a[1]])
if a[0] > a[1]:
x = a.pop(1)
a.append(x)
else:
x = a.pop(0)
a.append(x)
y = a[... | ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | n, q = map(int, input().split())
arr = list(map(int, input().split()))
ret = []
maxItem = 0
for item in arr:
maxItem = max(maxItem, item)
for _ in range(n):
ret.append([arr[0], arr[1]])
arr[0], arr[1] = min(arr[0], arr[1]), max(arr[0], arr[1])
z = arr.pop(0)
arr.append(z)
if arr[0] == maxItem:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER FUNC_CALL VAR VA... |
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A >... | class Dek:
def __init__(self, n):
self.items = []
self.len = n - 1
def op(self):
a = self.items[0]
b = self.items[1]
self.items.remove(a)
if a > b:
self.items[0] = a
self.items.append(b)
else:
self.items.append(a)
... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR NUMBER VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ... |
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t... | for _ in range(0, int(input())):
a = input().strip().replace("=", "")
m = 0
temp = 0
for i in a:
if i == ">":
temp += 1
else:
temp = 0
m = max(m, temp)
temp = 0
for i in a:
if i == "<":
temp += 1
else:
temp =... | FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR NUMBER ASSIGN ... |
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t... | x = int(input())
for _ in range(x):
n = input()
lol = []
for i in n:
if i != "=":
lol.append(i)
n = "".join(lol)
l = 0
if len(n) > 0:
l += 1
c = 1
for i in range(1, len(n)):
if n[i] == n[i - 1]:
c += 1
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.