description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | t = int(input())
for i in range(t):
s = str(input())
t = str(input())
x = len(s)
y = len(t)
count1 = [0] * 26
count2 = [0] * 26
z = 0
matrix1 = [[] for j in range(26)]
for j in range(x):
count1[ord(s[j]) - 97] += 1
matrix1[ord(s[j]) - 97].append(j + 1)
for j in ra... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST VAR FUNC_CA... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | def bsearch(a, x):
l = 0
r = len(a)
while l < r:
mid = (l + r) // 2
if a[mid] > x:
r = mid
else:
l = mid + 1
return l
for _ in range(int(input())):
s = input()
t = input()
Map = {}
for i in range(len(s)):
if s[i] not in Map:
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FU... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | test = int(input())
for _ in range(test):
s = input()
t = input()
i1, i2 = 0, 0
s1, s2 = set(s), set(t)
if len(s2 - s1) > 0:
print(-1)
continue
dics = [(0) for i in range(len(s))]
sst = sorted(list(s))
main = {i: (0) for i in sst}
for i in range(len(s) - 1, -1, -1):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | for _ in range(int(input())):
s = list(map(lambda c: ord(c) - 97, input()))
n = len(s)
t = list(map(lambda c: ord(c) - 97, input()))
if len(set(t) - set(s)) > 0:
print(-1)
continue
next_c = [-1] * 26
dp = [([-1] * 26) for _ in range(n)]
for i in range(n - 1, -1, -1):
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR IF FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER EXPR... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | import sys
def minp():
return sys.stdin.readline().strip()
def mint():
return int(minp())
def mints():
return map(int, minp().split())
def solve():
s = minp()
t = minp()
n = len(s)
m = len(t)
h = [None] * n
hh = [None] * 26
hh[ord(s[-1]) - ord("a")] = n - 1
h[-1] = hh... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR BIN_OP LIST... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | def getRow(c):
return ord(c) - 97
for t in range(int(input())):
s = input()
t = input()
inf = len(s)
grid = [([inf] * len(s)) for _ in range(26)]
grid[getRow(s[-1])][-1] = len(s) - 1
for col in reversed(range(len(s) - 1)):
for row in range(26):
grid[row][col] = grid[row... | FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER BIN_OP FUNC_CALL VAR VAR NUMBE... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | import sys
inf = float("inf")
input = lambda: sys.stdin.readline().rstrip("\r\n")
q = int(input())
for _ in range(q):
s = input()
t = input()
n = len(s)
loc = [[inf for __ in range(26)] for _ in range(n + 1)]
s2 = []
t2 = []
for c in s:
s2.append(ord(c) - ord("a"))
for c in t:
... | IMPORT ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASS... |
You are given two strings $s$ and $t$ consisting of lowercase Latin letters. Also you have a string $z$ which is initially empty. You want string $z$ to be equal to string $t$. You can perform the following operation to achieve this: append any subsequence of $s$ at the end of string $z$. A subsequence is a sequence th... | def bin_poisk(q, arr):
l = 0
r = len(arr)
while r - l > 1:
x = (l + r) // 2
if arr[x] <= q:
l = x
else:
r = x
if arr[-1] <= q:
return -1
if arr[l] <= q:
if r == len(arr):
return arr[-1]
return arr[r]
return arr[l... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR RETURN NUMBER IF VAR VAR VAR IF VAR FUNC_CALL VAR VAR RETURN VAR NUMBER RETURN VAR VAR RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_C... |
Some time ago Lesha found an entertaining string $s$ consisting of lowercase English letters. Lesha immediately developed an unique algorithm for this string and shared it with you. The algorithm is as follows.
Lesha chooses an arbitrary (possibly zero) number of pairs on positions $(i, i + 1)$ in such a way that the ... | s = input()
cs = [""]
ans = []
last = [""]
poped = False
for c in s[::-1]:
if not poped and c == cs[-1] and c > last[-2]:
cs.pop()
if not cs or c != cs[-1]:
last.pop()
poped = True
else:
poped = False
if c != cs[-1]:
last.append(c)
cs.appen... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST STRING ASSIGN VAR LIST ASSIGN VAR LIST STRING ASSIGN VAR NUMBER FOR VAR VAR NUMBER IF VAR VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR... |
Some time ago Lesha found an entertaining string $s$ consisting of lowercase English letters. Lesha immediately developed an unique algorithm for this string and shared it with you. The algorithm is as follows.
Lesha chooses an arbitrary (possibly zero) number of pairs on positions $(i, i + 1)$ in such a way that the ... | def main(s):
if len(s) == 0:
return []
if len(s) == 1:
return [[s], [1]]
s = s[::-1]
sres = [s[0]]
nres = [1]
if s[0] == s[1]:
sres.append("")
nres.append(0)
else:
sres.append(s[1] + s[0])
nres.append(2)
for i in range(2, len(s)):
s... | FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN LIST IF FUNC_CALL VAR VAR NUMBER RETURN LIST LIST VAR LIST NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST VAR NUMBER ASSIGN VAR LIST NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CAL... |
Some time ago Lesha found an entertaining string $s$ consisting of lowercase English letters. Lesha immediately developed an unique algorithm for this string and shared it with you. The algorithm is as follows.
Lesha chooses an arbitrary (possibly zero) number of pairs on positions $(i, i + 1)$ in such a way that the ... | import sys
z = sys.stdin.readline
s = z().strip()
l = len(s)
b = [" "]
o = []
m = [" "]
for i in range(l):
c = s[-1 - i]
if c == b[-1]:
if c > m[-1].lower() or c == m[-1].lower() and c > m[-2].lower():
b.pop()
if b[-1].lower() != m[-1].lower():
m.pop()
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST STRING ASSIGN VAR LIST ASSIGN VAR LIST STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP NUMBER VAR IF VAR VAR NUMBER IF VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VA... |
Some time ago Lesha found an entertaining string $s$ consisting of lowercase English letters. Lesha immediately developed an unique algorithm for this string and shared it with you. The algorithm is as follows.
Lesha chooses an arbitrary (possibly zero) number of pairs on positions $(i, i + 1)$ in such a way that the ... | s = input()
n = len(s)
res = ["", s[-1]]
l = [1]
flag = True
last = [""]
for i in range(n - 2, -1, -1):
tmp = res[-1]
if flag and s[i] == tmp[0] and s[i] > last[-1]:
res.append(res[-2])
l.append(l[-1] - 1)
flag = False
if l[-1] > 0 and res[-1][0] != s[i]:
last.pop()
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST STRING VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR VAR VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VA... |
Some time ago Lesha found an entertaining string $s$ consisting of lowercase English letters. Lesha immediately developed an unique algorithm for this string and shared it with you. The algorithm is as follows.
Lesha chooses an arbitrary (possibly zero) number of pairs on positions $(i, i + 1)$ in such a way that the ... | import sys
s = input().strip()
N = len(s)
if len(s) == 1:
print(1, s[0])
return
X = [s[-1], s[-2] + s[-1] if s[-2] != s[-1] else ""]
Y = [1, 2 if s[-2] != s[-1] else 0]
for i in range(N - 3, -1, -1):
c = s[i]
k1 = c + X[-1]
ng = Y[-1] + 1
if ng > 10:
k1 = k1[:5] + "..." + k1[-2:]
if... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER RETURN ASSIGN VAR LIST VAR NUMBER VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER STRING ASSIGN VAR LIST NUMBER VAR NUMBER VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR ... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | t = int(input())
for tt in range(0, t):
n = int(input())
p = list(map(int, input().split()))
d = [0] * n
for i in range(1, n):
if p[i] <= p[i - 1]:
d[0] -= p[i - 1] - p[i]
d[i] += p[i - 1] - p[i]
for i in range(1, n):
d[i] += d[i - 1]
st = 1
for i in r... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER VA... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | from itertools import accumulate
def read_ints():
return map(int, input().split())
t_n = int(input())
for i_t in range(t_n):
n = int(input())
a = list(read_ints())
min_from_left = list(accumulate(a, min))
min_from_right = list(accumulate(a[::-1], min))[::-1]
deltas = [(x2 - x1) for x1, x2 in... | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR ... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | import sys
from sys import stdin
tt = int(stdin.readline())
for loop in range(tt):
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
r = a[0]
l = 0
for i in range(n):
if r + l < a[i]:
l = a[i] - r
elif r + l > a[i]:
r = a[i] - l
if r ... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF BIN_OP VAR VAR VA... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | t = int(input())
while t:
n = int(input())
v = list(map(int, input().split()))
a = [(0) for i in range(n)]
b = [(0) for i in range(n)]
a[0] = v[0]
flag = True
for i in range(1, n):
a[i] = min(a[i - 1], v[i] - b[i - 1])
b[i] = v[i] - a[i]
if b[i] < b[i - 1] or a[i] < 0... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIG... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | t = int(input())
for _ in range(t):
n = int(input())
a = [int(x) for x in input().split()]
s = p = a[0]
for i in range(1, n):
if a[i] < p:
s -= p - a[i]
p = a[i]
if s < 0:
print("NO")
else:
print("YES") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXP... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
b = [0] * (n - 1)
for i in range(n - 1):
b[i] = a[i + 1] - a[i]
mi = 10000000
c = [0] * (n + 1)
for i in range(n - 1):
if b[i] < 0:
c[i + 1] += b[i]
c[0] -= b[i]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VA... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
a += [a[-1], a[0]]
min_a = a[0]
min_i = 0
for i in range(n):
if a[i] < min_a:
min_i = i
min_a = a[i]
need = 0
for i in range(n):
if i == min_i:
bre... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR LIST VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR ASS... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
ans = "YES"
left_min = [(0) for _ in range(n)]
left_min[0] = a[0]
for i in range(1, n):
left_min[i] = min(left_min[i - 1], a[i])
for i in range(0, n - 1):
if i > 0:
left_min[i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR ... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | from sys import stdin, stdout
t = int(stdin.readline())
for _ in range(t):
n = int(stdin.readline())
arr = list(map(int, stdin.readline().split()))
minl = arr[0]
maxl = 0
for i in range(1, n):
curr = arr[i]
arr[i] = min(arr[i - 1], arr[i] - maxl)
maxl = max(maxl, curr - arr[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
d = [(a[i] if i == 0 else a[i] - a[i - 1]) for i in range(n)]
if abs(sum(x for x in d if x < 0)) <= d[0]:
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR NU... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | def solve():
n = int(input())
a = list(map(int, input().split()))
a = [0] + a
print(
"YES"
if sum([max(0, a[i - 1] - a[i]) for i in range(1, n + 1)]) <= a[1]
else "NO"
)
def main():
t = 1
t = int(input())
for _ in range(t):
solve()
main() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER STRING STRING FUNC_DEF ASS... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | for _ in range(0, int(input())):
n = int(input())
arr = [int(x) for x in input().split()]
lst = arr[0]
bad = False
arr[0] = 0
for i in range(1, n):
dec = min(lst, arr[i] - arr[i - 1])
lst = dec
arr[i] -= dec
if dec < 0:
bad = True
print("NO" if bad... | FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASS... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | a = int(input())
for i in range(a):
s = int(input())
z = list(map(int, input().split()))
dec = []
inc = []
dec.append(z[0])
inc.append(0)
flag = 0
for i in range(1, len(z)):
if z[i] == z[i - 1]:
dec.append(dec[-1])
inc.append(inc[-1])
if z[i] > z[i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR ... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | T = int(input())
for _ in range(T):
n = int(input())
a = list(map(int, input().split()))
cur, maxn, flag, res = 0, 0, 0, 1
for i in range(1, n):
if flag == 0 and a[i] > a[i - 1]:
maxn = a[i - 1]
cur = a[i] - maxn
flag = 1
elif flag == 1 and a[i] >= cur... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | import sys
input = sys.stdin.readline
def inp():
return int(input())
def inlt():
return list(map(int, input().split()))
def insr():
s = input()
return list(s[: len(s) - 1])
def invr():
return map(int, input().split())
n = inp()
b = [0] * 100000
c = [0] * 100000
for j in range(n):
t = ... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN V... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
a = [0] * n
a[0] = arr[0]
b = [0] * n
fl = True
for i in range(1, n):
aMust = min(a[i - 1], arr[i] - b[i - 1])
bMust = arr[i] - aMust
a[i] = aMust
b[i] = bMust
if aMus... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n = int(input())
l = list(map(int, input().split()))
curr = 0
for i in range(n - 1):
diff = l[i + 1] - l[i]
l[i] -= curr
if diff > 0:
curr += diff
l[n - 1] -= curr
if min(l) >= 0:
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR IF VAR NU... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | t = int(input())
for _ in range(t):
n = int(input())
arr = list(map(int, input().split()))
if n == 1 or n == 2:
print("Yes")
else:
arr = [10**18] + arr + [10**18]
imos = [0] * (n + 2)
for i in range(1, n + 1):
if arr[i] > arr[i - 1]:
d = arr[i]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP LIST BIN_OP NUMBER NUMBER VAR LIST BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | def read_generator():
while True:
tokens = input().split(" ")
for t in tokens:
yield t
reader = read_generator()
def readword():
return next(reader)
def readint():
return int(next(reader))
def readfloat():
return float(next(reader))
def readline():
return input(... | FUNC_DEF WHILE NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR VAR EXPR VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_C... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | for _ in range(int(input())):
n = int(input())
flag = True
ar = list(map(int, input().split()))
su = 0
for i in range(n - 1):
if ar[i] >= ar[i + 1]:
su += ar[i] - ar[i + 1]
if su <= ar[0]:
print("YES")
else:
print("NO") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR NUM... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | import sys
readline = sys.stdin.readline
T = int(readline())
INF = 10**9 + 7
Ans = [None] * T
for qu in range(T):
N = int(readline())
A = list(map(int, readline().split()))
res = INF
rem = 0
for i in range(N):
res = max(0, min(res, A[i] - rem))
A[i] -= res
rem = A[i]
Ans... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NONE VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CAL... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
if n == 1:
print("YES")
continue
d = [a[0]] + [(a[i] - a[i - 1]) for i in range(1, n)] + [-a[n - 1]]
need_plus = 0
for i in range(1, len(d) - 1):
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP LIST VAR NUMBER BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
for i in range(n - 1, 0, -1):
a[i] -= a[i - 1]
minus = 0
for i in range(1, n):
if a[i] < 0:
minus -= a[i]
if a[0] - minus >= 0:
print("YES... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR ... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | for _ in range(int(input())):
n = int(input())
x = 10**9
y = 0
for a in map(int, input().split()):
if a < x + y:
x = a - y
if x < 0:
print("NO")
break
else:
y = a - x
else:
print("YES") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VA... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | def process(A):
a0 = A[0]
b0 = 0
n = len(A)
for i in range(n):
X = A[i]
if 0 <= X - b0 <= a0:
b1 = b0
a1 = X - b0
elif X - a0 >= b0:
a1 = a0
b1 = X - a0
else:
return "NO"
a0, b0 = a1, b1
return "YES"
... | FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF NUMBER BIN_OP VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN STRING ASSIGN VAR VAR VAR VAR RETURN STRING ASSIGN VAR FU... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | N = int(input())
for _ in range(N):
n = int(input())
l = list(map(int, input().split()))
des_num = 0
for i in range(len(l) - 1):
if l[i + 1] - des_num < 0:
print("NO")
break
if l[i] < l[i + 1]:
des_num += l[i + 1] - l[i]
else:
print("YES") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR V... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | for s in [*open(0)][2::2]:
x, *l = map(int, s.split())
a = y = 0
for i in l:
x = min(x, i - y)
y = max(y, i - x)
a |= x < 0
print("YNEOS"[a::2]) | FOR VAR LIST FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | import sys
input = sys.stdin.buffer.readline
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
rs = lambda: input().decode().rstrip("\n\r")
wrt = sys.stdout.write
pr = lambda *args, end="\n": wrt(" ".join([str(x) for x in args]) + end)
xrange = lambda args: reversed(range(args))
cdiv = lambda x, y... | 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 FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR STRING FUNC_CALL VAR BIN_OP FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | I = lambda: map(int, input().split(" "))
for _ in range(int(input())):
n = int(input())
arr = [*I()]
s = 0
for i in range(n - 1):
s = s + max(0, arr[i] - arr[i + 1])
if s <= arr[0]:
print("YES")
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF ... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | import sys
sys.setrecursionlimit(10**5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II():
return int(sys.stdin.buffer.readline())
def MI():
return map(int, sys.stdin.buffer.readline().split())
def LI():
return list(map(int, sys.stdin.buffer.readline().split()))
def LLI(rows_... | IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
i = 1
l = 0
g = a[0]
while i < n and a[i] <= a[i - 1]:
g = min(g, a[i])
i += 1
l = i - 1
i = n - 2
h = a[-1]
while i >= 0 and a[i + 1] >= a[i]:
h = min(h, a[i])
i -=... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER WHILE VAR VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | t = int(input())
for _ in range(t):
n = int(input())
arr = list(map(int, input().split()))
diff = [0] * n
diff[0] = arr[0]
sum = 0
for i in range(1, n):
diff[i] = arr[i] - arr[i - 1]
if diff[i] < 0:
sum -= diff[i]
if sum > diff[0]:
print("NO")
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR B... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | import sys
input = sys.stdin.readline
def main():
n = int(input())
alst = list(map(int, input().split()))
up = alst[0]
down = 0
for a in alst[1:]:
if up + down == a:
continue
elif up + down < a:
down = a - up
else:
up = a - down
... | IMPORT ASSIGN VAR VAR 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 VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR NUMBER IF BIN_OP VAR VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER EXP... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
x = 0
flag = 1
for i in range(1, n):
x = max(x, a[i] - a[i - 1])
a[i] -= x
if a[i] < 0:
flag = 0
print("NO")
bre... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | import sys
input = sys.stdin.readline
a = int(input())
for i in range(a):
b = int(input())
c = list(map(int, input().split()))
d = [c[0]]
e = [0]
for j in range(1, b):
d.append(min(d[j - 1], c[j] - e[j - 1]))
e.append(c[j] - d[j])
def abc(d, e):
for j in range(1, b):
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP ... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
left, flag = a[0], False
for i in range(n - 1):
if a[i] > a[i + 1]:
left -= a[i] - a[i + 1]
if left < 0:
flag = True
break
left = min(left, a[i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | import sys
input = sys.stdin.readline
def possible(a):
if len(a) == 0:
return "YES"
if a[0] < 0:
return "NO"
if len(a) == 1:
return "YES"
if a[0] > a[1]:
return possible(a[1:])
if a[-1] > a[-2]:
return possible(a[:-1])
return possible([(x - a[1] + a[0])... | IMPORT ASSIGN VAR VAR FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN STRING IF VAR NUMBER NUMBER RETURN STRING IF FUNC_CALL VAR VAR NUMBER RETURN STRING IF VAR NUMBER VAR NUMBER RETURN FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR NUMBER RETURN FUNC_CALL VAR VAR NUMBER RETURN FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NU... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | import sys
input = sys.stdin.buffer.readline
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
rs = lambda: input().decode().rstrip("\n\r")
wrt = sys.stdout.write
pr = lambda *args, end="\n": wrt(" ".join([str(x) for x in args]) + end)
xrange = lambda args: reversed(range(args))
cdiv = lambda x, y... | 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 FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR STRING FUNC_CALL VAR BIN_OP FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | inf = 10**9
def solve():
l = inf
r = -1
for a in aa:
l = min(a, l, a - r)
r = a - l
if l < 0 or r < 0:
return "NO"
return "YES"
for _ in range(int(input())):
n = int(input())
aa = list(map(int, input().split()))
print(solve()) | ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER RETURN STRING RETURN STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CA... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | mod = 10**9 + 7
INF = float("inf")
def getlist():
return list(map(int, input().split()))
def main():
T = int(input())
for _ in range(T):
N = int(input())
A = getlist()
B = [0] * N
leftminus = [None] * N
B[0] = 0
leftminus[0] = A[0]
jud = 1
... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VA... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
if a[0] - sum(-min(a[i] - a[i - 1], 0) for i in range(1, n)) >= 0:
print("YES")
else:
print("NO") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | import sys
input = sys.stdin.readline
(T,) = map(int, input().split())
for _ in range(T):
(N,) = map(int, input().split())
X = list(map(int, input().split()))
f = 0
ks = -1
si = -1
i = 0
for b, x in zip(X[:], X[1:]):
if not f and b >= x:
X[i] = 0
i += 1
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR V... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | tests = int(input())
for test in range(tests):
n = int(input())
a = list(map(int, input().split()))
l = [0] * n
r = [0] * n
for i in range(n):
if i > 0 and a[i] > a[i - 1]:
l[i] = a[i] - a[i - 1]
if i < n - 1 and a[i] > a[i + 1]:
r[i] = a[i] - a[i + 1]
rr ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR ... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
aa = 0
bb = a[0]
for i in range(1, n):
if a[i] <= a[i - 1]:
bb -= a[i - 1] - a[i]
else:
aa += a[i] - a[i - 1]
ok = True
ok &= bb >= 0
ok &= aa <= a[-1]
print("YE... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR VA... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | import sys
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c for j in range(b)] for i in range(a)]
def list3d(a, b, c, d):
return [[[d for k in range(c)] for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [
[[[e for l in range(d)] for k... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF NUMBER... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | for _ in range(int(input())):
n = int(input())
a = [*map(int, input().split())]
ans = sum(max(a[i] - a[i + 1], 0) for i in range(n - 1))
print("YES" if ans <= a[0] else "NO") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER STRING STRING |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | total = int(input())
for _ in range(total):
size = int(input())
arr = [int(c) for c in input().split()]
preOperationCount = arr[0]
rightOperationCount = 0
for val in arr:
if val < rightOperationCount:
print("NO")
break
else:
rightOperationCount = m... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR V... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split(" ")))
d = [0] * n
d[0] = a[0]
can = True
for i in range(1, n):
d[i] = a[i] - a[i - 1]
if d[i] < 0:
d[0] += d[i]
d[i] = 0
if d[0] < 0:
can = Fa... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR VA... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | from sys import stdin
input = stdin.readline
t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
b = a.copy()
x = 0
for i in range(n - 2, -1, -1):
if a[i] > b[i + 1]:
x += a[i] - b[i + 1]
a[i] -= x
if a[0] >= 0:
print("YES... | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR ... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | from sys import stdin
t = int(stdin.readline())
for case in range(t):
n = int(stdin.readline())
a = [int(x) for x in stdin.readline().split()]
left = [a[0]]
right = [a[-1]]
for x in range(1, n):
left.append(min(left[-1], a[x]))
right.append(min(right[-1], a[-x - 1]))
right = rig... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR F... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | rep = int(input())
for i in range(rep):
n = int(input())
a = input()
answer = "YES"
if n > 2:
a = a.split(" ")
f = int(a[0])
b = 0
c = int(a[1])
for i in range(2, n):
if int(a[i]) >= c - f + b and int(a[i]) >= b:
if b < c - f + b:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF F... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | t = int(input())
def solve(n, arr):
cur = arr[0]
transformed = [0]
for i in range(1, n):
transformed.append(max(transformed[i - 1], arr[i] - cur))
cur = min(cur, arr[i] - transformed[i])
cur = arr[-1]
for i in range(n - 1, -1, -1):
if arr[i] < transformed[i]:
re... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | import sys
def input():
return sys.stdin.readline().rstrip()
def slv():
n = int(input())
a = list(map(int, input().split()))
l, r = 0, 1 << 128
def greedy_update(l, r, S):
y = min(S - l, r)
x = S - y
return x, y
for v in a:
new_l, new_r = greedy_update(l, r,... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR 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 VAR NUMBER BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN VAR VAR FOR VAR VAR ASSIGN VA... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n = int(input())
A = map(int, input().split())
l, r = 10000000000, 0
possible = True
for a in A:
if a < r:
possible = False
break
a -= r
l = min(l, a)
r += a - l
if ... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR BIN_OP V... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | for i in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
if n <= 2:
print("YES")
else:
for j in range(1, n):
if a[j] > a[j - 1]:
break
rrr = 0
x = a[j - 1]
for jj in range(j, n - 1):
if a[jj + 1] < ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER FOR VAR... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | n = int(input())
answer = []
for i in range(n):
k = int(input())
list = input().split()
for j in range(k):
list[j] = int(list[j])
result = True
leftIndex = 0
leftPoints = list[0]
rightPoints = 0
rightMaxPoints = 0
for j in range(1, k - 1):
if list[j] < rightPoints:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR ... |
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decrement by one $k$ of the last elements of the array.
For example, if $n=5$ an... | t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
l = 0
r = n - 1
maxi = 10**8
for i in range(n):
if a[l] <= maxi:
maxi = a[l]
l += 1
else:
break
lmax = maxi
maxi = 10**8
for i in range(n):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR VAR NUMBER... |
Jeff got 2n real numbers a_1, a_2, ..., a_2n as a birthday present. The boy hates non-integer numbers, so he decided to slightly "adjust" the numbers he's got. Namely, Jeff consecutively executes n operations, each of them goes as follows: choose indexes i and j (i ≠ j) that haven't been chosen yet; round element a_{... | n, t = int(input()), [int(i[-3:]) for i in input().split()]
k, s = t.count(0), sum(t)
c = s // 1000 + int(s % 1000 > 500)
a, b = max(0, n - k), min(2 * n - k, n)
if a <= c <= b:
s = abs(c * 1000 - s)
else:
s = min(abs(a * 1000 - s), abs(b * 1000 - s))
print(str(s // 1000) + "." + str(s % 1000).zfill(3)) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR VAR V... |
Jeff got 2n real numbers a_1, a_2, ..., a_2n as a birthday present. The boy hates non-integer numbers, so he decided to slightly "adjust" the numbers he's got. Namely, Jeff consecutively executes n operations, each of them goes as follows: choose indexes i and j (i ≠ j) that haven't been chosen yet; round element a_{... | N = int(input())
n = N
A = list(map(float, input().strip().split(" ")))
z = 0
for i in range(len(A)):
A[i] = round(A[i], 3) - int(A[i])
if A[i] == 0:
z += 1
ANS = sum(A)
ans = 10**10
for j in range(n - z, n + 1):
ans = min(ans, abs(ANS - j))
print("%.3f" % ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL V... |
Jeff got 2n real numbers a_1, a_2, ..., a_2n as a birthday present. The boy hates non-integer numbers, so he decided to slightly "adjust" the numbers he's got. Namely, Jeff consecutively executes n operations, each of them goes as follows: choose indexes i and j (i ≠ j) that haven't been chosen yet; round element a_{... | from sys import *
s1 = stdin.readline().strip()
n = int(s1)
s1 = stdin.readline().strip()
a = list(map(float, s1.split()))
b = []
for i in range(2 * n):
if int(a[i]) != a[i]:
b.append(round(1000 * (a[i] - int(a[i]))))
m = len(b)
r = 0
for i in range(m):
r = r + b[i]
if m <= n:
if r >= 1000 * m:
... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR VAR FUNC_CALL VAR... |
Jeff got 2n real numbers a_1, a_2, ..., a_2n as a birthday present. The boy hates non-integer numbers, so he decided to slightly "adjust" the numbers he's got. Namely, Jeff consecutively executes n operations, each of them goes as follows: choose indexes i and j (i ≠ j) that haven't been chosen yet; round element a_{... | n = int(input())
arr = list(map(float, input().split()))
arr = sorted([(x - int(x)) for x in arr if x - int(x) != 0])
o = 2 * n - len(arr)
arr_sum = sum(arr)
res = int(2000000000.0)
for i in range(n + 1):
if i + o >= n:
res = min(res, abs(i - arr_sum))
print("%.3f" % res) | 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 BIN_OP VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER F... |
Jeff got 2n real numbers a_1, a_2, ..., a_2n as a birthday present. The boy hates non-integer numbers, so he decided to slightly "adjust" the numbers he's got. Namely, Jeff consecutively executes n operations, each of them goes as follows: choose indexes i and j (i ≠ j) that haven't been chosen yet; round element a_{... | k = 0
ans = 0
n = int(input())
a = input().split()
for i in range(2 * n):
s = float(a[i])
if s != int(s):
k += 1
ans += int(s) + 1 - s
if ans - int(ans) > 0.5:
p = int(ans) + 1
else:
p = int(ans)
if p > n:
p = n
if p + n >= k:
print("%.3f" % abs(ans - p))
else:
print("%.3f" %... | ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR FUNC_CALL VAR VAR VAR NUMBER VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR IF BIN_OP VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_... |
Jeff got 2n real numbers a_1, a_2, ..., a_2n as a birthday present. The boy hates non-integer numbers, so he decided to slightly "adjust" the numbers he's got. Namely, Jeff consecutively executes n operations, each of them goes as follows: choose indexes i and j (i ≠ j) that haven't been chosen yet; round element a_{... | n = int(input())
As = list(map(float, input().split()))
B = list(x - int(x) for x in As if x - int(x) > 0.0)
l = len(B)
if l == 0:
print("{:.3f}".format(0))
exit(0)
S = sum(x for x in B)
ll = l if l % 2 == 0 else l + 1
ans = 10000000000.0
for i in range(max(0, l - n), (n if l > n else l) + 1):
ans = min(ans... | 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 BIN_OP VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING NUMBER EXPR FUNC_CALL VAR NUMBER ASSI... |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | n = int(input())
s = input().strip("\n")
cur = s[0]
l = 1
for i in range(1, n):
if s[i] != cur:
l += 1
cur = s[i]
print(min(l + 2, n)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | n = int(input())
t = [int(i) for i in input()]
ch = 0
sm = 0
for i in range(n - 1):
if t[i] == t[i + 1]:
sm += 1
else:
ch += 1
print(ch + min(sm, 2) + 1) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR NUMBER NUMBER |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | n = int(input())
s = input()
def solve(n, s):
if n <= 3:
return n
cum = 0
p = "2"
count = 0
for i, v in enumerate(s):
if v != p:
cum += 1
else:
count += 1
p = v
if count == 0:
return cum
elif count == 1:
return cum + 1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER RETURN VAR IF VAR NUMBER RETURN BIN_OP VAR NUMBER RETURN BIN_OP VAR NUMBER E... |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | n = int(input())
s = input()
repeat = 0
count = 0
for i in range(len(s) - 1):
if s[i] == s[i + 1]:
repeat += 1
else:
count += 1
count += 1
if repeat == 1:
count += 1
if repeat >= 2:
count += 2
print(count) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | import sys
def solve(n, x):
ant = x[0]
cont = 1
maximo = 1
maxi = 1
dos = 0
for i in range(1, n):
if ant != x[i]:
cont += 1
ant = x[i]
if maximo >= 2:
dos += 1
maximo = 1
else:
maximo += 1
maxi ... | IMPORT FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NU... |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | n = int(input())
s = input()
k = 0
i = 0
r = int(s[0])
while i < n:
if int(s[i]) == r:
r = 1 - r
k += 1
i += 1
print(min(k + 2, n)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER WHILE VAR VAR IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | n = int(input())
s = input()
res = 1
for i in range(1, n):
if s[i] != s[i - 1]:
res += 1
print(min(res + 2, n)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | n = map(int, input())
s = input()
l = []
cnt = 1
for i in range(1, len(s)):
if s[i] != s[i - 1]:
l.append(cnt)
cnt = 1
else:
cnt += 1
l.append(cnt)
result = len(l)
max_pair = 0
max_count = 0
for i in range(len(l)):
if l[i] == 2:
max_pair += 1
max_count = max(max_count, l[... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBE... |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | n = int(input())
s = input()
c = 1
seg = []
for i in range(1, n):
if s[i] == s[i - 1]:
c += 1
else:
seg.append(c)
c = 1
seg.append(c)
f = 0
for i in range(len(seg)):
if seg[i] >= 3:
f = max(f, 2)
if seg[0] == 1 and seg[len(seg) - 1] == 2 or seg[0] == 2 and seg[len(seg) - 1] =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIG... |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | from sys import stdin
def get_count(c):
count = 0
flag = False
i = 1
while i < n + 2:
if arr[i] == arr[i - 1] and arr[i] == c:
if i == n + 1 or i == n:
flag = True
count += 1
i += 2
continue
i += 1
return count, flag
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL V... |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | n, s, ans = int(input()), list(input()), 1
flag = 0
for i in range(1, n):
if s[i] == s[i - 1]:
s[i] = str(int(s[i]) ^ 1)
flag = 1
elif flag:
break
last = s[0]
for i in s[1:]:
if i != last:
last = i
ans += 1
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR ASSIGN VAR VAR NUMBER FOR VAR VAR NUMBER IF VAR VAR ASSIGN VAR V... |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | def max_score(s):
a = 0
p = None
for c in s:
if c != p:
a += 1
p = c
return a + min(len(s) - a, 2)
n = int(input())
s = input()
print(max_score(s)) | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NONE FOR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR RETURN BIN_OP VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | n = int(input())
a = input()
p = [1] * 4
for i in range(1, n):
for j in range(2, -1, -1):
p[j + 1] = max(p[j + 1], p[j] + (a[i - 1] == a[i]))
p[j] += a[i - 1] != a[i]
print(max(p[0:3])) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR... |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | __author__ = "Utena"
n = input()
s = input()
t = []
def alt(a):
b = ""
b += a[0]
for i in a[1 : len(a)]:
if i != b[-1]:
b += i
return b
m = len(alt(s))
judge = 0
for i in range(len(s) - 1):
if s[i + 1] == s[i]:
judge = 1
if i < len(s) - 2:
for j in... | ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF ASSIGN VAR STRING VAR VAR NUMBER FOR VAR VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VA... |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | n = int(input())
ch = str(input())
if n == 1:
print(1)
else:
B = [(0) for _ in range(n)]
B[0] = 1
c = ch[0]
for k in range(1, n):
if ch[k] == c:
B[k] = B[k - 1]
else:
B[k] = B[k - 1] + 1
c = ch[k]
T = [(0) for _ in range(n)]
F = [(0) for _ ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_... |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | n = int(input())
s = input()
k1, k2, k1l, k2l = 0, 0, "0", "1"
for i in s:
if k1l != i:
k1 += 1
k1l = i
if k2l != i:
k2 += 1
k2l = i
print(min(len(s), max(k1, k2) + 2)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER STRING STRING FOR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | n = int(input())
s = input()
mem = s[0]
streak = 1
amount = 0
res = 0
score = 1
for l in range(1, n):
if s[l] == mem:
streak += 1
else:
mem = s[l]
streak = 1
score += 1
if streak > 2:
res = 2
elif streak == 2:
amount += 1
if amount > 1:
res = 2... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBE... |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | n = int(input())
s = list(input())
lis = [0] * n
bb = []
p = s[0]
lis[0] = 1
kk = 0
for i in range(1, len(s)):
if s[i] != p:
lis[i] = 1
p = s[i]
for i in range(1, len(s)):
if s[i] == s[i - 1]:
kk += 1
else:
bb.append(kk)
kk = 0
bb.append(kk)
ans = c = 0
if max(bb) > 1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR NU... |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | import sys
n = int(sys.stdin.readline())
s = sys.stdin.readline()
s = list(s)
a = []
k = 1
for i in range(n):
if i == n - 1:
a.append(k)
break
if s[i] == s[i + 1]:
k += 1
else:
a.append(k)
k = 1
add_amount = 0
count = 0
for i in range(n - 1):
if s[i] == s[i + 1]:... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VA... |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | n = int(input().strip())
s = input().strip()
segs = []
start = 0
i = 1
while i <= n:
if i == n or s[i] != s[start]:
segs.append(i - start)
start = i
i = start + 1
else:
i += 1
res = len(segs)
segs.sort()
if segs[-1] >= 3:
res += 2
elif len(segs) >= 2 and segs[-1] >= 2 and seg... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF VAR... |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | import sys
__author__ = "MoonBall"
T = 1
def process():
input()
s = input()
if len(s) == 1:
print(1)
return
b = []
for x in s:
if not b or b[-1][0] != x:
b.append((x, 1))
else:
b[-1] = b[-1][0], b[-1][1] + 1
ans = len(b)
c2 = 0
c... | IMPORT ASSIGN VAR STRING ASSIGN VAR NUMBER FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR LIST FOR VAR VAR IF VAR VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN V... |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | N = int(input())
s = input()
count1 = []
x = s[0]
i = 1
count = 1
while i < N:
if s[i] == s[i - 1]:
count += 1
else:
count1.append(count)
count = 1
i += 1
count1.append(count)
if any(i > 2 for i in count1):
print(len(count1) + 2)
elif count1.count(2) > 1:
print(len(count1) + ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR VAR EXPR FUNC_CAL... |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | from sys import stdin
length = int(stdin.readline().rstrip())
scores = stdin.readline().rstrip()
doubles_found = 0
score = 1
for i in range(length - 1):
if scores[i] != scores[i + 1]:
score += 1
elif doubles_found < 2:
score += 1
doubles_found += 1
print(score) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | n = int(input())
s = input()
dl = 1
now = s[0]
k = 0
for i in range(1, n):
if now != s[i]:
now = s[i]
dl += 1
for i in range(n - 1):
if s[i] == s[i + 1] == "0" or s[i] == s[i + 1] == "1":
k += 1
if k >= 2:
print(dl + 2)
elif k == 1:
print(dl + 1)
else:
print(dl) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR ASSIGN VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER STRING VAR VAR VAR BIN_OP VAR NUMBER STRING VAR... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.