Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
import heapq

sys.setrecursionlimit(10 ** 6)

n = int(input())
a, b = [], []
used = [False] * (n + 1)
used[n] = True
for i in range(n):
    a_i, b_i = map(int, input().split())
    heapq.heappush(a, (-a_i, -b_i, i))
    heapq.heappush(b, (-b_i, -a_i, i))

flag = True
ans = 0
for _ in range(n):
    i, j = n, n
    while used[i]:
        a_i, b_i, i = heapq.heappop(a)
    while used[j]:
        b_j, a_j, j = heapq.heappop(b)
    if abs(a_i - a_j) > abs(b_i - b_j):
        if flag:
            ans -= a_i
        else:
            ans += b_i
        used[i] = True
        heapq.heappush(b, (b_j, a_j, j))
    else:
        if flag:
            ans -= a_j
        else:
            ans += b_j
        used[j] = True
        heapq.heappush(b, (b_i, a_i, i))
    flag = not flag
print(ans)

Fixed submission:
n = int(input())
happy, a, b = [], [], []
for i in range(n):
    happy.append(tuple(map(int, input().split())))
happy.sort(key=lambda x: x[0] + x[1], reverse=True)
ans = 0
for i, (a, b) in enumerate(happy):
    if i % 2 == 0:
        ans += a
    else:
        ans -= b
print(ans)

Buggy python submission (verdict: Runtime Error):
import heapq

n = int(input())
a, b = [], []
used = [False] * (n + 1)
used[n] = True
for i in range(n):
    a_i, b_i = map(int, input().split())
    heapq.heappush(a, (-a_i, -b_i, i))
    heapq.heappush(b, (-b_i, -a_i, i))

flag = True
ans = 0
for _ in range(n):
    i, j = n, n
    while used[i]:
        a_i, b_i, i = heapq.heappop(a)
    while used[j]:
        b_j, a_j, j = heapq.heappop(b)
    if abs(a_i - a_j) > abs(b_i - b_j):
        if flag:
            ans -= a_i
        else:
            ans += b_i
        used[i] = True
        heapq.heappush(b, (b_j, a_j, j))
    else:
        if flag:
            ans -= a_j
        else:
            ans += b_j
        used[j] = True
        heapq.heappush(b, (b_i, a_i, i))
    flag = not flag
print(ans)

Fixed submission:
n = int(input())
happy, a, b = [], [], []
for i in range(n):
    happy.append(tuple(map(int, input().split())))
happy.sort(key=lambda x: x[0] + x[1], reverse=True)
ans = 0
for i, (a, b) in enumerate(happy):
    if i % 2 == 0:
        ans += a
    else:
        ans -= b
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
graph = [tuple(map(int, input().split())) for _ in range(m)]

def shortest_path(s):
    MIN = -1 * 10 ** 12
    d = [MIN] * (n + 1)
    d[s] = 0
    update = True
    cnt = 1
    tmp = MIN
    while update:
        update = False
        for a, b, c in graph:
            if d[a] != MIN and d[b] < d[a] + c:
                d[b] = d[a] + c
                update = True
        if cnt == m: tmp = d[n]
        if update and cnt == 2 * m and d[n] > tmp: return 'inf'
        cnt += 1
    return d[n]

print(shortest_path(1))

Fixed submission:
n, m = map(int, input().split())
graph = [tuple(map(int, input().split())) for _ in range(m)]

def shortest_path(s):
    MIN = -1 * 10 ** 12
    d = [MIN] * (n + 1)
    d[s] = 0
    update = True
    cnt = 1
    tmp = MIN
    while update:
        update = False
        for a, b, c in graph:
            if d[a] != MIN and d[b] < d[a] + c:
                d[b] = d[a] + c
                update = True
        if cnt == m: tmp = d[n]
        if update and cnt == 2 * m and d[n] > tmp: return 'inf'
        if cnt == 2 * m: update = False
        cnt += 1
    return d[n]

print(shortest_path(1))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
graph = [tuple(map(int, input().split())) for _ in range(m)]

def shortest_path(s):
    MIN = -1 * 10 ** 12
    d = [MIN] * (n + 1)
    d[s] = 0
    update = True
    cnt = 1
    tmp = MIN
    while update:
        update = False
        for a, b, c in graph:
            if d[a] != MIN and d[b] < d[a] + c:
                d[b] = d[a] + c
                update = True
        if cnt == m: tmp = d[n]
        if update and cnt == 2 * m and d[n] > tmp: return 'inf'
        cnt += 1
    return d[n]

print(shortest_path(1))

Fixed submission:
n, m = map(int, input().split())
graph = [tuple(map(int, input().split())) for _ in range(m)]

def shortest_path(s):
    MIN = -1 * 10 ** 12
    d = [MIN] * (n + 1)
    d[s] = 0
    update = True
    cnt = 1
    tmp = MIN
    while update:
        update = False
        for a, b, c in graph:
            if d[a] != MIN and d[b] < d[a] + c:
                d[b] = d[a] + c
                update = True
        if cnt == m: tmp = d[n]
        if update and cnt == 2 * m and d[n] > tmp: return 'inf'
        if cnt == 2 * m: update = False
        cnt += 1
    return d[n]

print(shortest_path(1))
Buggy python submission (verdict: Time Limit Exceeded):
n, l, t = map(int, input().split())
ants = [tuple(map(int, input().split())) for _ in range(n)]
place = []
clock = []
anticlock = []
for i, (x, w) in enumerate(ants):
    if w == 1:
        place.append((x + t) % l)
        clock.append((i, x))
    else:
        place.append((x - t) % l)
        anticlock.append((i, x))

def dist(x, y):
    if x < y: return y - x
    else: return y - x + l

swap = []
for i, x in clock:
    for j, y in anticlock:
        tmp = t * 2
        d = dist(x, y)
        if tmp > d:
            tmp -= d
            swap.append((d, i, j))
            for c in range(1, tmp // l):
                swap.append((d + c * l, i, j))

swap.sort(reverse=True)
for d, i, j in swap:
    place[i], place[j] = place[j], place[i]
for p in place:
    print(p)

Fixed submission:
n, l, t = map(int, input().split())
ants = [tuple(map(int, input().split())) for _ in range(n)]

def dist(x, y, sign_0):
    if sign_0 == -1:
        x, y = y, x
    if x < y: return y - x
    else: return y - x + l

place = []
for i, (x, w) in enumerate(ants):
    sign = 1 if w == 1 else -1
    place.append((x + t * sign) % l)
    if i == 0:
        num = 0
        x_0 = x
        sign_0 = sign
    elif sign_0 * sign == -1:
        length = 2 * t
        d = dist(x_0, x, sign_0)
        if length > d or (length == d and sign_0 == -1):
            num = (num + sign_0) % n
            length -= d
            num = (num + (length // l) * sign_0) % n
            if length % l == 0 and sign_0 == 1:
                num = (num - 1) % n
    else: continue

place.sort()
i_0 = (place.index((x_0 + t * sign_0) % l) - num) % n
place.count((x_0 + t * sign_0) % l)

for i in range(i_0, n + i_0):
    i = i % n
    print(place[i])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
remain = [0 for i in range(max(a) + 1)]
for ai in a:
    remain[ai] += 1
res = 0
for i in range(1, max(a) + 1):
    if remain[i] == 1:
        res += 1
    if remain[i]:
        for j in range(i * 2, max(a) + 1, i):
            remain[j] = 0
print(res)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
remain = [0 for i in range(max(a) + 1)]
for ai in a:
    remain[ai] += 1
res = 0
max_a = max(a)
for i in range(1, max_a + 1):
    if remain[i] == 1:
        res += 1
    if remain[i]:
        for j in range(i * 2, max_a + 1, i):
            remain[j] = 0
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
s = []
for i in range(0, n - k + 1):
    v = [(1 + p[j])/2 for j in range(i, i + k)]
    s.append(sum(v))
print(max(s))


Fixed submission:
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
q = [(1 + p[0]) / 2]
for i in range(1, n):
    q.append(q[i - 1] + ((1 + p[i]) / 2))
s = [q[k - 1]]
for i in range(k, n):
    s.append(q[i] - q[i - k])
print(max(s))
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def my_round(val, digit=0):
    p = 10 ** digit
    return (val * p * 2 + 1) // 2 / p


n, m = list(map(int, input().split()))
a_pr = [i // 2 for i in list(map(int, input().split()))]
lcm_ = lcm_list(a_pr)
res, div2 = 0, None
for ai in a_pr:
    cnt = 0
    while a % 2 == 0:
        a //= 2
        cnt += 1
    if div2 is None:
        div2 = cnt
    elif cnt != div2:
        print(0)
        exit()

print(int(my_round(m // lcm_ / 2)))


Fixed submission:
import fractions
import math
n, m = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))
a = [int(i/2) for i in a]
num_gcd = a[0]
for i in range(1, n):
    num_gcd = num_gcd * a[i] // fractions.gcd(num_gcd, a[i])
flag = False
c = 0
p = a[0]
while True:
    if p % 2 != 0:
        break
    p /= 2
    c += 1
for i in range(1, n):
    if a[i] % (2 ** c) == 0 and (a[i] // (2 ** c)) % 2 != 0:
        pass
    else:
        flag = True
if flag:
    print(0)
else:
    print(math.ceil((m // num_gcd) / 2))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
c = 0
c_dict = {}
l = []
for i in range(n):
    s_listed = sorted(list(input()))
    s = ''.join(s_listed)
    if s in l:
        if s in c_dict.keys():
            c_dict[s] += 1
        else:
            c_dict[s] = 1
    l.append(s)
for i in c_dict.values():
    if i == 1:
        c += 1
    else:
        c += i * (i + 1) / 2
print(int(c))


Fixed submission:
n = int(input())
c = 0
c_dict = {}
l = []
for i in range(n):
    s_listed = sorted(list(input()))
    s = ''.join(s_listed)
    if s in c_dict.keys():
        c_dict[s] += 1
        c += c_dict[s] - 1
    else:
        c_dict[s] = 1
print(int(c))
Buggy python submission (verdict: Runtime Error):
import math
a, b, c, d = list(map(int, input().split()))


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


def search(n, i, j):
    l = lcm(i, j)
    return n - int(n / i) - int(n / j) + int(n / l)


print(search(b, c, d) - search(a - 1, c, d))


Fixed submission:
import fractions
a, b, c, d = list(map(int, input().split()))


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


def search(n, i, j):
    l = lcm(i, j)
    return n - n // i - n // j + n // l


print(search(b, c, d) - search(a - 1, c, d))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = list(map(int, input().split()))
a = []
for _ in range(m):
    a.append(int(input()))
cur = 0
dp = [0 for _ in range(n + 1)]
flags = [0 for _ in range(n + 1)]
for i in range(n + 1):
    if i in a:
        flags[i] = 1
dp[0], dp[1] = 1, 1
if flags[1]:
    dp[1] = 0
for i in range(2, n + 1):
    if flags[i]:
        continue
    dp[i] = dp[i - 1] + dp[i - 2]
    dp[i] %= (10 ** 9 + 7)
print(dp[n])


Fixed submission:
n, m = list(map(int, input().split()))
a = []
for i in range(m):
    a.append(int(input()))
a = set(a)
dp = [0 for _ in range(n+1)]
dp[0] = 1
if 1 in a:
    dp[1] = 0
else:
    dp[1] = 1
for i in range(2, n+1):
    if not(i in a):
        dp[i] = dp[i - 2] + dp[i - 1]
print(dp[n] % 1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = list(map(int, input().split()))
a = []
for _ in range(m):
    a.append(int(input()))
cur = 0
dp = [0 for _ in range(n + 1)]
flags = [0 for _ in range(n + 1)]
for i in range(n + 1):
    if i in a:
        flags[i] = 1
dp[0], dp[1] = 1, 1
if 1 in a:
    dp[1] = 0
for i in range(2, n + 1):
    if flags[i]:
        continue
    dp[i] = (dp[i - 1] + dp[i - 2]) % (10 ** 9 + 7)
print(dp[n])


Fixed submission:
n, m = list(map(int, input().split()))
a = []
for i in range(m):
    a.append(int(input()))
a = set(a)
dp = [0 for _ in range(n+1)]
dp[0] = 1
if 1 in a:
    dp[1] = 0
else:
    dp[1] = 1
for i in range(2, n+1):
    if not(i in a):
        dp[i] = dp[i - 2] + dp[i - 1]
print(dp[n] % 1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = list(map(int, input().split()))
a = []
for _ in range(m):
    a.append(int(input()))
cur = 0
dp = [0 for _ in range(n + 1)]
dp[0], dp[1] = 1, 1
if 1 in a:
    dp[1] = 0
for i in range(2, n + 1):
    if i in a:
        continue
    dp[i] = (dp[i - 1] + dp[i - 2]) % (10 ** 9 + 7)
print(dp[n])


Fixed submission:
n, m = list(map(int, input().split()))
a = []
for i in range(m):
    a.append(int(input()))
a = set(a)
dp = [0 for _ in range(n+1)]
dp[0] = 1
if 1 in a:
    dp[1] = 0
else:
    dp[1] = 1
for i in range(2, n+1):
    if not(i in a):
        dp[i] = dp[i - 2] + dp[i - 1]
print(dp[n] % 1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = list(map(int, input().split()))
a = []
for i in range(m):
    a.append(int(input()))
dp = [0 for _ in range(n+1)]
dp[0] = 1
if 1 in a:
    dp[1] = 0
else:
    dp[1] = 1
for i in range(2, n+1):
    if i in a:
        dp[i] = 0
    else:
        dp[i] = dp[i - 2] + dp[i - 1]
print(dp[n] % 1000000007)


Fixed submission:
n, m = list(map(int, input().split()))
a = []
for i in range(m):
    a.append(int(input()))
a = set(a)
dp = [0 for _ in range(n+1)]
dp[0] = 1
if 1 in a:
    dp[1] = 0
else:
    dp[1] = 1
for i in range(2, n+1):
    if not(i in a):
        dp[i] = dp[i - 2] + dp[i - 1]
print(dp[n] % 1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter
import heapq
n, m = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))
heap_a = [i for i in a]
heapq.heapify(heap_a)
b = []
c = []
for i in range(m):
    bi, ci = list(map(int, input().split()))
    b.append(bi)
    c.append(ci)

bc = zip(b, c)
bc = sorted(bc, key=itemgetter(1))
b, c = zip(*bc)

for i in range(m):
    for j in range(b[i]):
        min_a = heapq.heappop(heap_a)
        if min_a < c[i]:
            heapq.heappush(heap_a, c[i])
        else:
            heapq.heappush(heap_a, min_a)
            break
print(sum(heap_a))


Fixed submission:
from operator import itemgetter
import heapq
n, m = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))
heap_a = [i for i in a]
heapq.heapify(heap_a)
b = []
c = []
for i in range(m):
    bi, ci = list(map(int, input().split()))
    b.append(bi)
    c.append(ci)

bc = zip(b, c)
bc = sorted(bc, key=itemgetter(1), reverse=True)
b, c = zip(*bc)

flag = False

for i in range(m):
    if flag:
        break
    for j in range(b[i]):
        min_a = heapq.heappop(heap_a)
        if min_a < c[i]:
            heapq.heappush(heap_a, c[i])
        else:
            heapq.heappush(heap_a, min_a)
            flag = True
            break
print(sum(heap_a))

Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter
import heapq
n, m = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))
heap_a = [-i for i in a]
heapq.heapify(heap_a)
b = []
c = []
for i in range(m):
    bi, ci = list(map(int, input().split()))
    b.append(bi)
    c.append(ci)
    for j in range(bi):
        heapq.heappush(heap_a, -ci)

s = 0

for i in range(n):
    s += -1 * heapq.heappop(heap_a)

print(s)


Fixed submission:
from operator import itemgetter
import heapq
n, m = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))
heap_a = [i for i in a]
heapq.heapify(heap_a)
b = []
c = []
for i in range(m):
    bi, ci = list(map(int, input().split()))
    b.append(bi)
    c.append(ci)

bc = zip(b, c)
bc = sorted(bc, key=itemgetter(1), reverse=True)
b, c = zip(*bc)

flag = False

for i in range(m):
    if flag:
        break
    for j in range(b[i]):
        min_a = heapq.heappop(heap_a)
        if min_a < c[i]:
            heapq.heappush(heap_a, c[i])
        else:
            heapq.heappush(heap_a, min_a)
            flag = True
            break
print(sum(heap_a))
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
import fractions
n = int(input())
a = list(map(int, input().split()))


def R(r):
    r_list = [a[i] for i in range(n) if i >= r]
    if r_list == []:
        return reduce(fractions.gcd, [a[i] for i in range(n) if i != n - 1])
    else:
        return reduce(fractions.gcd, r_list)


def L(l):
    l_list = [a[i] for i in range(n) if i <= l]
    if l_list == []:
        return reduce(fractions.gcd, [a[i] for i in range(n) if i != 0])
    else:
        return reduce(fractions.gcd, l_list)


def M(m):
    return fractions.gcd(L(m-1), R(m + 1))


t = []
for j in range(n):
    t.append(M(j))
print(max(t))


Fixed submission:
from functools import reduce
import fractions
n = int(input())
a = list(map(int, input().split()))
L = [0] * (n + 1)
R = [0] * (n + 1)
for i in range(n-1):
    L[i + 1] = fractions.gcd(L[i], a[i])
    R[n - i - 1] = fractions.gcd(R[n - i], a[n - i - 1])

rl = [0] * n
for i in range(n):
    rl[i] = fractions.gcd(L[i], R[i + 1])
print(max(rl))
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if b - a <= k and c - b <= k and d - c <= k and e - d <= k and c - a <= k and d - a <= k and e - a <= k and d - b <= k and e - b <= k and e - c <= k:
    print("Yay!
")
else:
    print(": (")


Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if b - a <= k and c - a <= k and d - a <= k and e - a <= k and c-b <= k and d-b <= k and e-b <= k and d-c <= k and e-c <= k and e - d <= k:
    print("Yay!")
else:
    print(":(")
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
li = [a, b, c, d, e]
li_2 = []
d = 10
count = 0
adr = 0
for i in li:
    li_2.append(i % 10)
for i in li_2:
    if i < d and i != 0:
        d = i
        ans = adr
    adr += 1
if d == 10:
    d = 0
for i in range(5):
    if i != ans and li_2[i] != 0:
        count += (li[i] - li_2[i] + 10)
    elif i != ans and li_2[i] == 0:
        count += li[i]
count += li[ans]
print(count)


Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
li = [a, b, c, d, e]
li_2 = []
d = 10
count = 0
adr = 0
for i in li:
    li_2.append(i % 10)
for i in li_2:
    if i < d and i != 0:
        d = i
        ans = adr
    adr += 1
if d == 10:
    d = 0
    ans = 0
for i in range(5):
    if i != ans and li_2[i] != 0:
        count += (li[i] - li_2[i] + 10)
    elif i != ans and li_2[i] == 0:
        count += li[i]
count += li[ans]
print(count)
Buggy python submission (verdict: Runtime Error):
s = list(input())
renzoku = 0
renli = []
for i in s:
    if i == "A" or i == "T" or i == "C" or i == "G":
        renzoku += 1
        renli.append(renzoku)
    else:
        renzoku = 0
print(max(renli))

Fixed submission:
s = list(input())
renzoku = 0
count = 0
hu_renzoku = 0
renli = []
for i in s:
    count += 1
    if i == "A" or i == "T" or i == "C" or i == "G":
        renzoku += 1
        renli.append(renzoku)
    else:
        renzoku = 0
        hu_renzoku += 1
if count == hu_renzoku:
    print(0)
else:
    print(max(renli))
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if b % a == 0:
  print(a + b)
else:
  print(b-a)

Fixed submission:
x = input().split()
a = int(x[0])
b = int(x[1])
if b % a == 0:
  print(a + b)
else:
  print(b-a)
Buggy python submission (verdict: Runtime Error):
x1 = input().split()
N = int(x1[0])
M = int(x1[1])
S = []
A = []
K = []
F = []
for i in range(M):
    S.append(0)
for i in range(N):
    K.append(0)
for i in range(N):
    A.append(input().split())
    K[i] = int(A[i][0])
    for j in range(K[i]):
        F.append(int(A[i][j]))
    for j in F:
        S[j] += 1
ans = 0
for i in range(M):
    if S[i] == N:
        ans += 1
print(ans)


Fixed submission:
x1 = input().split()
N = int(x1[0])
M = int(x1[1])
S = []
A = []
K = []
F = []
for i in range(M):
    S.append(0)
for i in range(N):
    K.append(0)
for i in range(N):
    A.append(input().split())
    K[i] = int(A[i][0])
    for j in range(K[i]):
        F.append(int(A[i][j+1]))
    for j in F:
        S[j - 1] += 1
    F = []
ans = 0
for i in range(M):
    if S[i] == N:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
n = int(input())
a_li = list(map(int, input().split()))


def gcd(*numbers):
    return reduce(math.gcd, numbers)


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


print(gcd_list(a_li))


Fixed submission:
import fractions
from functools import reduce
n = int(input())
a_li = list(map(int, input().split()))


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


print(gcd_list(a_li))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
A = input().split()
A = [int(i) for i in A]
A.sort()
A.reverse()
while True:
    A[0] = A[0] % A[1]
    A.sort()
    A.reverse()
    if A[1] == 0:
        break
print(A[0])


Fixed submission:
import fractions
from functools import reduce
n = int(input())
a_li = list(map(int, input().split()))


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


print(gcd_list(a_li))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
A = input().split()
A = [int(i) for i in A]
A.sort()
A.reverse()
while True:
    A[0] = A[0] - A[1]
    A.sort()
    A.reverse()
    if A[1] == 0:
        break
print(A[0])


Fixed submission:
import fractions
from functools import reduce
n = int(input())
a_li = list(map(int, input().split()))


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


print(gcd_list(a_li))
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    h_li = list(map(int, input().split()))
    i = 0
    count = 0
    f = 0
    discount = max(h_li)
    while True:
        if h_li[i] >= discount:
            count += 1
            h_li[i] -= 1
            while i < len(h_li) - 1:
                if h_li[i + 1] >= discount:
                    i += 1
                    h_li[i] -= 1
                else:
                    i += 1
                    break
        if i == len(h_li) - 1:
            i = 0
            discount -= 1
            if max(h_li) == 0:
                f = 1
        else:
            i += 1
        if f == 1:
            break
    print(count)
if __name__ == '__main__':
    main()

Fixed submission:
n = int(input())
h_li = list(map(int, input().split()))
count = 0
for i in range(100):
    f = 0
    for j in range(n):
        if h_li[j] >= i + 1:
            if f == 0:
                count += 1
                f = 1
        else:
            f = 0
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    h_li = list(map(int, input().split()))
    i = 0
    count = 0
    f = 0
    discount = max(h_li)
    while True:
        if h_li[i] >= discount:
            count += 1
            h_li[i] -= 1
            while i < len(h_li) - 1:
                if h_li[i + 1] >= discount:
                    i += 1
                    h_li[i] -= 1
                else:
                    break
        if i == len(h_li) - 1:
            i = 0
            discount -= 1
            if max(h_li) == 0:
                f = 1
        else:
            i += 1
        if f == 1:
            break
    print(count)


if __name__ == '__main__':
    main()


Fixed submission:
n = int(input())
h_li = list(map(int, input().split()))
count = 0
for i in range(100):
    f = 0
    for j in range(n):
        if h_li[j] >= i + 1:
            if f == 0:
                count += 1
                f = 1
        else:
            f = 0
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
h_li = list(map(int, input().split()))
i = 0
count = 0
f = 0
discount = max(h_li)
while True:
    if h_li[i] >= discount:
        count += 1
        h_li[i] -= 1
        while i < len(h_li) - 1:
            if h_li[i + 1] >= discount:
                i += 1
                h_li[i] -= 1
            else:
                break
    if i == len(h_li) - 1:
        i = 0
        discount -= 1
        if max(h_li) == 0:
            f = 1
    else:
        i += 1
    if f == 1:
        break
print(count)


Fixed submission:
n = int(input())
h_li = list(map(int, input().split()))
count = 0
for i in range(100):
    f = 0
    for j in range(n):
        if h_li[j] >= i + 1:
            if f == 0:
                count += 1
                f = 1
        else:
            f = 0
print(count)