Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
l = [0]
r = [0]
c = 0
for i in range(len(S)):
    if S[i] == '<':
        c += 1
    else:
        c = 0
    l.append(c)
c = 0
for i in range(len(S)-1,-1,-1):
    if S[i] == '>':
        c += 1
    else:
        c = 0
    r.insert(0, c)
print(sum([max(l[i],r[i]) for i in range(len(S)+1)]))


Fixed submission:
S = input()
l = [0] * (len(S)+1)
r = [0] * (len(S)+1)
for i in range(len(S)):
    if S[i] == '<':
        l[i+1] = l[i] + 1
for i in range(len(S)-1,-1,-1):
    if S[i] == '>':
        r[i] = r[i+1] + 1
print(sum([max(l[i],r[i]) for i in range(len(S)+1)]))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split()))
ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if L[i]<L[j]+L[k] and L[j]<L[k]+L[i] and L[k]<L[i]+L[j]:
                ans += 1
print(ans)


Fixed submission:
def is_ok1(a,b,c):
    return L[b] < L[c] + L[a]
def is_ok2(a,b,c):
    return L[c] < L[a] + L[b]
def meguru_bisect(ng, ok, is_ok, a, b):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(a, b, mid):
            ok = mid
        else:
            ng = mid
    return ok
N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for a in range(N):
    for b in range(a+1, N):
        ans += max(0, meguru_bisect(N, b, is_ok2, a, b)-meguru_bisect(b, N, is_ok1, a, b)+1)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter
N = int(input())
A = list(map(int, input().split()))
# a= []
# for i in range(N):
#     a.append((i+1, A[i]))
#     a.sort(key=itemgetter(1))
# print(' '.join([str(i[0]) for i in a]))
a = []
for i in range(N):
    for j in range(N):
        if i+1 == A[j]:
            a.append(str(j+1))
print(' '.join(a))


Fixed submission:
from operator import itemgetter
N = int(input())
A = list(map(int, input().split()))
# a= []
# for i in range(N):
#     a.append((i+1, A[i]))
#     a.sort(key=itemgetter(1))
# print(' '.join([str(i[0]) for i in a]))
a = [0] * N
for i in range(N):
    a[ A[i] -1 ] = str(i + 1)
print(' '.join(a))

Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter
N = int(input())
A = list(map(int, input().split()))
a= []
for i in range(N):
    a.append((i+1, A[i]))
    a.sort(key=itemgetter(1))
print(' '.join([str(i[0]) for i in a]))


Fixed submission:
from operator import itemgetter
N = int(input())
A = list(map(int, input().split()))
# a= []
# for i in range(N):
#     a.append((i+1, A[i]))
#     a.sort(key=itemgetter(1))
# print(' '.join([str(i[0]) for i in a]))
a = [0] * N
for i in range(N):
    a[ A[i] -1 ] = str(i + 1)
print(' '.join(a))
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
t = S.count('AC')
L = []
R = []
for i in range(N):
    L.append(S[:i].count('AC'))
    R.append(S[i:].count('AC'))
for i in range(Q):
    l, r = map(int, input().split())
    print(t-L[l]-R[r-1])


Fixed submission:
N, Q = map(int, input().split())
S = input()
t = S.count('AC')
L = [0]
R = [0]
for i in range(N-1):
    L.append(L[i]+1 if S[i:i+2] == 'AC' else L[i])
    R.append(R[i]+1 if S[N-i-2:N-i] == 'AC' else R[i])
R.reverse()
for i in range(Q):
    l, r = map(int, input().split())
    print(t-L[l-1]-R[r-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
for i in range(Q):
    l, r = map(int, input().split())
    print(S[l-1:r].count('AC'))


Fixed submission:
N, Q = map(int, input().split())
S = input()
t = S.count('AC')
L = [0]
R = [0]
for i in range(N-1):
    L.append(L[i]+1 if S[i:i+2] == 'AC' else L[i])
    R.append(R[i]+1 if S[N-i-2:N-i] == 'AC' else R[i])
R.reverse()
for i in range(Q):
    l, r = map(int, input().split())
    print(t-L[l-1]-R[r-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
c = [0] * 26
for s in S:
    c[ord(s)-ord('a')] = (c[ord(s)-ord('a')] + 1) % (10**9+7)
import itertools
import operator
from functools import reduce
ans = 0
for j in range(1, 27):
    for i in itertools.combinations(c, j):
        ans += reduce(operator.mul,i) % (10**9+7)
print(ans)


Fixed submission:
import operator
import functools
N = int(input())
S = input()
c = [1] * 26
for s in S:
    c[ord(s)-ord('a')] += 1
print((functools.reduce(operator.mul,c)-1) % (10**9+7))
Buggy python submission (verdict: Runtime Error):
import math
N,P=map(int,input().split())
i=math.ceil(P**(1/N))
while 1:
    if P%(i**N)==0:print(i);exit()
    i-=1


Fixed submission:
import math
def factrization_prime(number):
    factor = {}
    div = 2
    s = math.sqrt(number)
    while div < s:
        div_cnt = 0
        while number % div == 0:
            div_cnt += 1
            number //= div
        if div_cnt != 0:
            factor[div] = div_cnt
        div += 1
    if number > 1:
        factor[number] = 1
    return factor
N, P = map(int, input().split())
d = factrization_prime(P)
a = 1
for p in d:
    a *= p**(d[p]//N)
print(a)

Buggy python submission (verdict: Runtime Error):
N,P=map(int,input().split())
i=1
while i**N<=P:
    if P%i**N==0:a=i
    i+=1
print(a)


Fixed submission:
import math
def factrization_prime(number):
    factor = {}
    div = 2
    s = math.sqrt(number)
    while div < s:
        div_cnt = 0
        while number % div == 0:
            div_cnt += 1
            number //= div
        if div_cnt != 0:
            factor[div] = div_cnt
        div += 1
    if number > 1:
        factor[number] = 1
    return factor
N, P = map(int, input().split())
d = factrization_prime(P)
a = 1
for p in d:
    a *= p**(d[p]//N)
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
S = list(map(str,input()))
i = 0
ans = 0
while i < len(S)-1:
    if S[i] + S[i+1]=='BW':
        ans += 1
        S[i]='W'
        S[i+1]='B'
        if i>0:
            i -= 1
    else:
        i += 1
print(ans)


Fixed submission:
S = input()
n = S.count('W')
print(sum([i for i in range(len(S)) if S[i]=='W']) - n*(n-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort()
ans = max(h)
for i in range(N-K+1):
    if max(h[i:i+K])-min(h[i:i+K]) < ans:
        ans = max(h[i:i+K])-min(h[i:i+K])
print(ans)


Fixed submission:
N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort()
ans = max(h)
for i in range(N-K+1):
    if h[i+K-1]-h[i] < ans:
        ans = h[i+K-1]-h[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
def g(n,r):return f[n]//f[n-r]//f[r]
n,*a=map(int,open(0).read().split())
m=max(a)
f=[1]*-~m
for i in range(m):f[i+1]=f[i]*-~i
o=min(a)
for A in a:
 if g(m,A)>g(m,o):o=A
print(m,o)


Fixed submission:
n,*a=map(int,open(0).read().split())
m=max(a)
b=m//2
o=min(a)
for A in a:
 if abs(A-b)<abs(o-b):o=A
print(m,o)

Buggy python submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
m=max(a)
f=[1]*-~m
for i in range(m):f[i+1]=f[i]*-~i
def g(n,r):return f[n]//f[n-r]//f[r]
o=min(a)
for A in a:
 if g(m,A)>g(m,o):o=A
print(m,o)


Fixed submission:
n,*a=map(int,open(0).read().split())
m=max(a)
b=m//2
o=min(a)
for A in a:
 if abs(A-b)<abs(o-b):o=A
print(m,o)
Buggy python submission (verdict: Runtime Error):
import re
S,T=open(0)
S=S.replace('?','.')
s=len(S)
t=len(T)
B='z'*s
c=0
for i in range(s-t+1):
 if re.search(S[i:i+t],T):A=min(A,(S[:i]+T+S[i+t:]).replace('.','a'));c=1
print(A if c else 'UNRESTORABLE')


Fixed submission:
import re
S,T=open(0)
S=S.replace('?','.')
T=T[:-1]
s=len(S)
t=len(T)
for i in range(s-t,-1,-1):
 if re.match(S[i:i+t],T):print((S[:i]+T+S[i+t:]).replace('.','a'));exit()
print('UNRESTORABLE')
Buggy python submission (verdict: Time Limit Exceeded):
import math
N=int(input())
for i in range(math.ceil(N**0.5),N+1):
 if N%i==0:print(len(str(i)));break


Fixed submission:
N=int(input())
print(min(len(str(N//i))for i in range(1,int(N**.5)+1)if N%i<1))
Buggy python submission (verdict: Runtime Error):
def is_ok(m, n):
    return m*(m+1)//2>=n
def meguru_bisect(ng, ok, n):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid, n):
            ok = mid
        else:
            ng = mid
    return ok
def f(n):
    if n>0:
        m = meguru_bisect(0,10**7, n)
        print(m)
        f(n-m)
N = int(input())
f(N)


Fixed submission:
import sys
sys.setrecursionlimit(10**7)
def is_ok(m, n):
    return m*(m+1)//2>=n
def meguru_bisect(ng, ok, n):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid, n):
            ok = mid
        else:
            ng = mid
    return ok
def f(n):
    if n>0:
        m = meguru_bisect(0,10**7, n)
        print(m)
        f(n-m)
N = int(input())
f(N)

Buggy python submission (verdict: Runtime Error):
def is_ok(n):
    global N
    return n*(n+1)//2>=N
def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok
N = int(input())
n = meguru_bisect(0,10**7)
s = list(range(1, n+1))
d = n-2
while sum(s) != N:
    s.pop(d)
    d -= 1
for i in s:
    print(i)


Fixed submission:
import sys
sys.setrecursionlimit(10**7)
def is_ok(m, n):
    return m*(m+1)//2>=n
def meguru_bisect(ng, ok, n):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid, n):
            ok = mid
        else:
            ng = mid
    return ok
def f(n):
    if n>0:
        m = meguru_bisect(0,10**7, n)
        print(m)
        f(n-m)
N = int(input())
f(N)

Buggy python submission (verdict: Time Limit Exceeded):
def is_ok(n):
    global N
    return n*(n+1)//2>=N
def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok
N = int(input())
n = meguru_bisect(0,10**7)
s = list(range(1, n+1))
import itertools
for i in itertools.product([0,1], repeat=n):
    a = [s[j-1] for j in s if i[j-1]]
    if sum(a) == N:
        for k in a:
            print(k)
        exit()


Fixed submission:
import sys
sys.setrecursionlimit(10**7)
def is_ok(m, n):
    return m*(m+1)//2>=n
def meguru_bisect(ng, ok, n):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid, n):
            ok = mid
        else:
            ng = mid
    return ok
def f(n):
    if n>0:
        m = meguru_bisect(0,10**7, n)
        print(m)
        f(n-m)
N = int(input())
f(N)
Buggy python submission (verdict: Runtime Error):
import sys
amount = int(input())

if amount < 3:
    print(0)
    sys.exit()

coins = [x for x in range(3,amount+1)]

lst = [amount+1 for x in range(amount+1)]

lst[0] = 1
lst[1] = 0
lst[2] = 0
lst[3] = 1
lst[4] = 1
lst[5] = 1



for i in range(6,amount+1):
    counter = 0
    for coin in coins:
        change = i - coin

        if change >= 0:
            counter += lst[change]
    lst[i] = counter

print(lst[-1] % (10**9 + 7))

Fixed submission:
import sys
amount = int(input())

lst1 = [3,4,5]
if amount in lst1:
    print(1)
    sys.exit()
elif amount < 6:
    print(0)
    sys.exit()

coins = [x for x in range(3,amount+1)]

lst = [amount+1 for x in range(amount+1)]

lst[0] = 1
lst[1] = 0
lst[2] = 0
lst[3] = 1
lst[4] = 1
lst[5] = 1


for i in range(6,amount+1):
    counter = 0
    for coin in coins:
        change = i - coin

        if change >= 0:
            counter += lst[change]
    lst[i] = counter

print(lst[-1] % (10**9 + 7))

Buggy python submission (verdict: Runtime Error):

amount = int(input())

coins = [x for x in range(3,amount+1)]

lst = [amount+1 for x in range(amount+1)]

lst[0] = 1
lst[1] = 0
lst[2] = 0
lst[3] = 1
lst[4] = 1
lst[5] = 1


for i in range(6,amount+1):
    counter = 0
    for coin in coins:
        change = i - coin

        if change >= 0:
            counter += lst[change]
    lst[i] = counter

print(lst[-1] % (10**9 + 7))




Fixed submission:
import sys
amount = int(input())

lst1 = [3,4,5]
if amount in lst1:
    print(1)
    sys.exit()
elif amount < 6:
    print(0)
    sys.exit()

coins = [x for x in range(3,amount+1)]

lst = [amount+1 for x in range(amount+1)]

lst[0] = 1
lst[1] = 0
lst[2] = 0
lst[3] = 1
lst[4] = 1
lst[5] = 1


for i in range(6,amount+1):
    counter = 0
    for coin in coins:
        change = i - coin

        if change >= 0:
            counter += lst[change]
    lst[i] = counter

print(lst[-1] % (10**9 + 7))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N = int(input())

xlist = input().split(" ")
ylist = []

for num in xlist:
    ylist.append(int(num))


    """
pairs = itertools.combinations(ylist, 2)
answer = 0
for pair in pairs:
    answer += pair[0] * pair[1]

print(answer % (10**9 +7 ))"""


def findProductSum(A, n):
    product = 0
    for i in range(n):
        for j in range(i + 1, n):
            product = product + A[i] * A[j]
    return product


print(findProductSum(ylist,N ) %  (10**9 +7 ))


Fixed submission:


N = int(input())
A = list((input().split(" ")))

values = []
for i in range(N):
    values.append(int(A[i]))


suffixSumArray = values.copy()



for i in range(N-2,-1,-1):
    suffixSumArray[i] = suffixSumArray[i+1] + suffixSumArray[i]



sum = 0
for i in range(N-1):
    sum += (values[i] * suffixSumArray[i+1])

print(sum % (10 ** 9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N = input()

xlist = input().split(" ")
ylist = []
for num in xlist:
    ylist.append(int(num))
pairs = itertools.combinations(ylist, 2)
answer = 0
for pair in pairs:
    answer += pair[0] * pair[1]

print(answer % (10**9 +7 ))

Fixed submission:


N = int(input())
A = list((input().split(" ")))

values = []
for i in range(N):
    values.append(int(A[i]))


suffixSumArray = values.copy()



for i in range(N-2,-1,-1):
    suffixSumArray[i] = suffixSumArray[i+1] + suffixSumArray[i]



sum = 0
for i in range(N-1):
    sum += (values[i] * suffixSumArray[i+1])

print(sum % (10 ** 9 + 7))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]


t = dict()

for i in range(1, n + 1):
    t[i] = set()


for a, b in ab:
    t[a].add(b)
    t[b].add(a)


def dfs(graph, start):
    visited = set()
    stack = [start]

    while stack:
        vertex = stack.pop()
        if vertex not in visited:
            visited.add(vertex)

            stack.extend(graph[vertex] - visited)
    return visited

length = 0

for i in range(1, n+1):
    ans = dfs(t, i)
    if len(ans) > length:
        length = len(ans)

print(length)


Fixed submission:
from collections import deque

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]


t = dict()

for i in range(1, n + 1):
    t[i] = set()


for a, b in ab:
    t[a].add(b)
    t[b].add(a)


def dfs(graph, start):
    visited = set()
    stack = [start]

    while stack:
        vertex = stack.pop()
        if vertex not in visited:
            visited.add(vertex)

            stack.extend(graph[vertex] - visited)
    return visited

seen = set()
length = 0
for i in range(1, n+1):
    if i not in seen:
        ans = dfs(t, i)
        for num in ans:
            seen.add(num)

        if len(ans) > length:
            length = len(ans)

print(length)
Buggy python submission (verdict: Runtime Error):
max = 0
for letter in S:
    if letter == "R":
        max += 1
    if letter == "S":
        break 
print(max)

Fixed submission:
S = input()

l = len(S)
count = 0

for i in range(l):
    if "R" not in S:
        break
    cur_count = 1

    for j in range(i+1,l):
        if S[i] == "S":
            break
        if (S[i] != S[j]):
            break
        cur_count += 1
    if cur_count > count:
        count = cur_count

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    factors = [1]*(n+1)
    ans = 1
    for i in range(2, n+1):
        for j in range(i, n+1, i):
            factors[j] += 1
        ans += (factors[i]*i)
    return ans

if __name__ == '__main__':
    n = int(input())
    print(solve())
    

Fixed submission:
def solve():
    ans = 0
    for x in range(1, n + 1):
        y = int(n / x)
        ans += y * (y + 1) * x // 2
    return ans

if __name__ == '__main__':
    n = int(input())
    print(solve())
Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    for i in range(len(arr)):
        if arr[i] == b:
            arr[i] = c
    return sum(arr)

if __name__ == '__main__':
    n = int(input())
    arr = list(map(int, input().split()))
    q = int(input())
    for i in range(q):
        b, c, = map(int, input().split())
        print(solve())

Fixed submission:
if __name__ == '__main__':
    n = int(input())
    arr = list(map(int, input().split()))
    d = {}
    for i in range(len(arr)):
        if arr[i] in d:
            d[arr[i]] += 1
        else:
            d[arr[i]] = 1
    sums = sum(arr)
    q = int(input())
    for i in range(q):
        b, c = map(int, input().split())
        if b in d:
            sums -= (b * d[b])
            sums += (c * d[b])
        if c not in d and b in d:
            d[c] = d[b]
        elif b in d:
            d[c] += d[b]
        if b in d:
            d[b] = 0
        print(sums)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
arr = list(map(int, input().split()))

dp = [0]*(10**6+1)

for i in arr:
    for j in range(i, len(dp), i):
        if j in arr:
            dp[j] += 1
print(dp.count(1))

Fixed submission:
n = int(input())
arr = list(map(int, input().split()))

dp = [0]*(10**6+1)

for i in sorted(arr):
    dp[i] += 1
    if dp[i] == 1:
        for j in range(2*i, len(dp), i):
            dp[j] += 2
print(dp.count(1))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
arr = list(map(int, input().split()))
count = 0
for i in range(n):
    good = 0
    for j in range(n):
        if j != i and arr[i] % arr[j] == 0:
            break
        elif j != i:
            good += 1
    if good == n-1:
        count += 1
print(count)

Fixed submission:
n = int(input())
arr = list(map(int, input().split()))

dp = [0]*(10**6+1)

for i in sorted(arr):
    dp[i] += 1
    if dp[i] == 1:
        for j in range(2*i, len(dp), i):
            dp[j] += 2
print(dp.count(1))
Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':
    n = int(input())
    arr = list(map(int, input().split()))
    product = arr[0]
    if 0 in arr:
        product = 0
    else:
        for i in range(1, n):
            product *= arr[i]
            if product > (10**18):
                product = -1
                break
    print(product)

Fixed submission:
if __name__ == '__main__':
    a, b = map(int, input().split())
    print(a*b)
Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
    n = int(input())
    arr = list(map(int, input().split()))
    product = arr[0]
    for i in range(1, n):
        product *= arr[i]
    if product > (10**18):
        product = -1
    print(product)

Fixed submission:
if __name__ == '__main__':
    n = int(input())
    arr = list(map(int, input().split()))
    product = arr[0]
    if 0 in arr:
        product = 0
    else:
        for i in range(1, n):
            product *= arr[i]
            if product > (10**18):
                product = -1
                break
    print(product)
Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    matrix = [[0]*(w+1) for _ in range(n)]
    for i in range(n):
        for j in range(1, w+1):
            if i >= 1 and j-dp[i][0] >= 0:
                matrix[i][j] = max(matrix[i-1][j], dp[i][1]+matrix[i-1][j-dp[i][0]])
            elif i < 1 and j-dp[i][0] >= 0:
                matrix[i][j] = dp[i][1]
            else:
                matrix[i][j] = matrix[i-1][j]
    return matrix[n-1][w]


if __name__ == '__main__':
    n, w = map(int, input().split())
    dp = []
    for i in range(n):
        dp.append(list(map(int,input().split())))
    print(solve())

Fixed submission:
import numpy as np

n, W = map(int, input().split())
dp = np.array([[0]*(W+1)]*(n+1))
for i in range(1, n+1):
    w, v = map(int, input().split())
    dp[i] = dp[i-1]
    dp[i][w:W+1] = np.maximum(dp[i-1][w:W+1], dp[i-1][:W+1-w]+v)
print(dp[n][W])
Buggy python submission (verdict: Runtime Error):
#from collections import Counter
N=int(input())
"""F=list(list(map(int,input().split())) for i in range(N))
P=list(list(map(int,input().split())) for i in range(N))"""
F=[int(input().replace(' ',''),2)for _ in[0]*N]
P=[list(map(int,input().split()))for _ in[0]*N]
ans=-(1<<40)
for bit in range(1,1<<10):
    tmp = 0
    for i in range(N):
        c=0
        for j in range(10):
            if bit&(1<<j) and F[i][j]:
                c+=1
        tmp+=P[i][c]
    ans = max(ans,tmp)
print(ans)

Fixed submission:
#from collections import Counter
N=int(input())
F=list(list(map(int,input().split())) for i in range(N))
P=list(list(map(int,input().split())) for i in range(N))
ans=-(1<<40)
for bit in range(1,1<<10):
    tmp = 0
    for i in range(N):
        c=0
        for j in range(10):
            if bit&(1<<j) and F[i][j]:
                c+=1
        tmp+=P[i][c]
    ans = max(ans,tmp)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())


def lc():
    l0, l1 = 2, 1
    while 1:
        yield l0 + l1
        l0, l1 = l1, l0 + l1


for i, n in enumerate(lc()):
    if i == N - 2:
        print(n)
        break


Fixed submission:
N = int(input())


def lc():
    l0, l1 = 2, 1
    while 1:
        yield l0 + l1
        l0, l1 = l1, l0 + l1


if N > 1:
    for i, n in enumerate(lc()):
        if i == N - 2:
            print(n)
            break
else:
    print(1)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())


def rk():
    l0, l1 = 2, 1
    while 1:
        yield l0 + l1
        l0, l1 = l1, l0 + l1


for i, n in enumerate(rk()):
    if i == N - 2:
        print(n)


Fixed submission:
N = int(input())


def lc():
    l0, l1 = 2, 1
    while 1:
        yield l0 + l1
        l0, l1 = l1, l0 + l1


if N > 1:
    for i, n in enumerate(lc()):
        if i == N - 2:
            print(n)
            break
else:
    print(1)
Buggy python submission (verdict: Runtime Error):
A = input()
op = ["+", "-"]
for bit in range(1 << 3):
    ans = A[0]
    for i in range(3):
        ans += op[bit & (1 << i)]+A[i+1]
    if eval(ans) == 7:
        print(ans+"=7")
        break


Fixed submission:
A = input()
for bit in range(1 << 4):
    ans = int(A[0])
    res = [A[0]]
    for i in range(3):
        if bit & (1 << i):
            ans += int(A[i + 1])
            res.append("+")
            res.append(A[i+1])
        else:
            ans -= int(A[i + 1])
            res.append("-")
            res.append(A[i+1])
    if ans == 7:
        for i in range(7):
            print(res[i], end='')
        print("=7")
        break

Buggy python submission (verdict: Runtime Error):
A = input()
op = ["+", "-"]
for bit in range(1 << 4):
    ans = A[0]
    for i in range(3):
        ans += op[bit & (1 << i)]+A[i+1]
    if eval(ans) == 7:
        print(ans+"=7")
        break


Fixed submission:
A = input()
for bit in range(1 << 4):
    ans = int(A[0])
    res = [A[0]]
    for i in range(3):
        if bit & (1 << i):
            ans += int(A[i + 1])
            res.append("+")
            res.append(A[i+1])
        else:
            ans -= int(A[i + 1])
            res.append("-")
            res.append(A[i+1])
    if ans == 7:
        for i in range(7):
            print(res[i], end='')
        print("=7")
        break