Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))


# 最小値更新して越えてたらアウト
resultCount = 0
minNum = P[0]
for i in range(N):
    isMitasu = True
    if i != 0:
        if P[i] > minNum:
            isMitasu = False
        else:
            for j in range(i):
                if P[i] > P[j]:
                    isMitasu = False
                    # 最小値更新
                    if P[i] < minNum:
                        minNum = P[i]
                    break
    if isMitasu:
        resultCount += 1
print(resultCount)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))


# 最小値更新して越えてたらアウト
resultCount = 0
minNum = P[0]
for i in range(N):
    isMitasu = True
    if i != 0:
        if P[i] > minNum:
            isMitasu = False
        else:
            # 最小値更新
            minNum = P[i]
    if isMitasu:
        resultCount += 1
print(resultCount)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))

resultCount = 0
NGNum = float('inf')
for i in range(N):
    isMitasu = True
    # 計算量削減のため、既に駄目だと分かっている数の場合計算しない
    if P[i] < NGNum:
        for j in range(i):
            if P[i] > P[j]:
                isMitasu = False
                # 計算量削減のため、駄目だった数を控える
                if P[i] < NGNum:
                    NGNum = P[i]
                break
    else:
        isMitasu = False
    if isMitasu:
        resultCount += 1
print(resultCount)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))


# 最小値更新して越えてたらアウト
resultCount = 0
minNum = P[0]
for i in range(N):
    isMitasu = True
    if i != 0:
        if P[i] > minNum:
            isMitasu = False
        else:
            # 最小値更新
            minNum = P[i]
    if isMitasu:
        resultCount += 1
print(resultCount)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))

resultCount = 0
for i in range(N):
    isMitasu = True
    for j in range(i):
        if P[i] > P[j]:
            isMitasu = False
            break
    if isMitasu:
        resultCount += 1
print(resultCount)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))


# 最小値更新して越えてたらアウト
resultCount = 0
minNum = P[0]
for i in range(N):
    isMitasu = True
    if i != 0:
        if P[i] > minNum:
            isMitasu = False
        else:
            # 最小値更新
            minNum = P[i]
    if isMitasu:
        resultCount += 1
print(resultCount)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))

resultCount = 0
for i in range(N):
    isMitasu = True
    for j in range(i):
        if P[i] > P[j]:
            isMitasu = False
    if isMitasu:
        resultCount += 1
print(resultCount)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))


# 最小値更新して越えてたらアウト
resultCount = 0
minNum = P[0]
for i in range(N):
    isMitasu = True
    if i != 0:
        if P[i] > minNum:
            isMitasu = False
        else:
            # 最小値更新
            minNum = P[i]
    if isMitasu:
        resultCount += 1
print(resultCount)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = [int(i) for i in input().split()]

for i in range(K):
    if A > 0:
        A = A - 1
    elif B > 0:
        B = B - 1
    else:
        break

print('{} {}'.format(A,B))

Fixed submission:
A, B, K = [int(i) for i in input().split()]

if K > A:
    K = K - A
    A = 0
    if K >= B:
        B = 0
    else:
        B = B - K
else:
    A = A - K

print('{} {}'.format(A,B))
Buggy python submission (verdict: Runtime Error):
import math

A, B = [int(i) for i in input().split()]

result = (A * B) // math.gcd(A, B)
print(result)

Fixed submission:
import fractions 

A, B = [int(i) for i in input().split()]

result = A * B // fractions.gcd(A, B)
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
#300
N = int(input())
S = [input() for _ in range(N)]
L = [0 for _ in range(N)]
L1 = ["" for _ in range(N)]
S.sort()
k = 0


for i in range(N):
    if i == 0:
        L[k] = 1 
        L1[k] = S[i]
    else:
        if S[i-1] == S[i]:
            L[k] = L[k] + 1
        else:
            L[k+1] = 1
            L1[k+1] = S[i]
            k += 1

for i in range(N):
    if L[i] == max(L):
        print(L1[i])

Fixed submission:
#300
N = int(input())
S = [input() for _ in range(N)]
L = [0 for _ in range(N)]
L1 = ["" for _ in range(N)]
S.sort()
k = 0


for i in range(N):
    if i == 0:
        L[k] = 1 
        L1[k] = S[i]
    else:
        if S[i-1] == S[i]:
            L[k] = L[k] + 1
        else:
            L[k+1] = 1
            L1[k+1] = S[i]
            k += 1

m = max(L)
for i in range(N):
    if L[i] == m:
        print(L1[i])

Buggy python submission (verdict: Time Limit Exceeded):
#300
N = int(input())
S = [input() for _ in range(N)]
L = []
L1 = []
S.sort()


for i in range(N):
    if i == 0:
        L.append(1)
        L1.append(S[i])
    else:
        if S[i-1] == S[i]:
            L[len(L)-1] = L[len(L)-1] + 1
        else:
            L.append(1)
            L1.append(S[i])

for i in range(len(L)):
    if L[i] == max(L):
        print(L1[i])

Fixed submission:
#300
N = int(input())
S = [input() for _ in range(N)]
L = [0 for _ in range(N)]
L1 = ["" for _ in range(N)]
S.sort()
k = 0


for i in range(N):
    if i == 0:
        L[k] = 1 
        L1[k] = S[i]
    else:
        if S[i-1] == S[i]:
            L[k] = L[k] + 1
        else:
            L[k+1] = 1
            L1[k+1] = S[i]
            k += 1

m = max(L)
for i in range(N):
    if L[i] == m:
        print(L1[i])

Buggy python submission (verdict: Time Limit Exceeded):
#300
N = int(input())
S = [input() for _ in range(N)]
L = []
S.sort()
Set = set(S)
SetL = list(Set)
SetL.sort()

for i in range(N):
    if i == 0:
        L.append(1)
    else:
        if S[i-1] == S[i]:
            L[len(L)-1] = L[len(L)-1] + 1
        else:
            L.append(1)

for i in range(len(L)):
    if L[i] == max(L):
        print(SetL[i])

Fixed submission:
#300
N = int(input())
S = [input() for _ in range(N)]
L = [0 for _ in range(N)]
L1 = ["" for _ in range(N)]
S.sort()
k = 0


for i in range(N):
    if i == 0:
        L[k] = 1 
        L1[k] = S[i]
    else:
        if S[i-1] == S[i]:
            L[k] = L[k] + 1
        else:
            L[k+1] = 1
            L1[k+1] = S[i]
            k += 1

m = max(L)
for i in range(N):
    if L[i] == m:
        print(L1[i])
Buggy python submission (verdict: Time Limit Exceeded):
#400
N,K = map(int,input().split())
p = list(map(int,input().split()))
q = [0 for _ in range(N)]

for i in range(N):
    q[i] = (1+p[i])/2

Smax = sum(q[0:K])
for i in range(N-K):
    if sum(q[i+1:K+i+1]) > Smax:
        Smax = sum(q[i+1:K+i+1])

print(Smax)

Fixed submission:
#400
N,K = map(int,input().split())
p = list(map(int,input().split()))
q = [0 for _ in range(N)]

for i in range(N):
    q[i] = (1+p[i])/2

S = sum(q[0:K])
Smax = S
for i in range(N-K):
    S = S - q[i] + q[K+i]
    if S > Smax:
        Smax = S

print(Smax)
Buggy python submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

N = int(input())
A = list(map(int,input().split()))
LCM = 0
S = 0

for i in range(N):
    if i == 0:
        LCM = A[0]
    else:
        LCM = lcm(LCM,A[i])

for j in range(N):
    S = S + (LCM // A[j])

S = S % (10**9 + 7)
print(S)

Fixed submission:
#500
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

N = int(input())
A = list(map(int,input().split()))
LCM = 0
S = 0

for i in range(N):
    if i == 0:
        LCM = A[0]
    else:
        LCM = lcm(LCM,A[i])

for j in range(N):
    S = S + (LCM // A[j])

S = S % (10**9 + 7)
print(S)
Buggy python submission (verdict: Runtime Error):
S,T = map(input().split())
U = ""
U = U + T + S
print(U)

Fixed submission:
S,T = input().split()
U = ""
U = U + T + S
print(U)

Buggy python submission (verdict: Runtime Error):
S,T = map(input().split())
U = T + S
print(U)

Fixed submission:
S,T = input().split()
U = ""
U = U + T + S
print(U)
Buggy python submission (verdict: Runtime Error):
#Partition
import math
N,M = map(int,input().split())
n = 1
rootM = int(math.sqrt(M))
for i in range(rootM+1):
    if M % (i+1) == 0 and N*(i+1) <= M:
        n = i+1
if N == 1:
    n = M
print(n)

Fixed submission:
#Programming Education
N = int(input())
if N == 1:
    print("Hello World")
else:
    A = int(input())
    B = int(input())
    print(A+B)
Buggy python submission (verdict: Time Limit Exceeded):
#Partition
N,M = map(int,input().split())
n = 1
for i in range(M):
    if M % (i+1) == 0 and N*(i+1) <= M:
        n = i+1
print(n)

Fixed submission:
#Partition
import math
N,M = map(int,input().split())
n = 1
rootM = int(math.sqrt(M))+1
for i in range(rootM):
    if M % (i+1) == 0 and N*(i+1) <= M:
        if N*(M/(i+1)) <= M and n <= (M/(i+1)):
            n = M/(i+1)
        elif n <= i+1:
            n = i+1
        else:
            continue
print(int(n))
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
n = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i + 100*j + 50*k = X:
        n += 1
print(n)


Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
n = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i + 100*j + 50*k == X:
        n += 1
print(n)

Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
n = 0
for i in range(A):
  for j in range(B):
    for k in range(C):
      if 500*i + 100*j + 50*k = X:
        n += 1
print(n)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
n = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i + 100*j + 50*k == X:
        n += 1
print(n)
Buggy python submission (verdict: Runtime Error):
#Rating Goal
R, G = map(int, input().split())
T = R + 2 * (G - R)
print(T)

Fixed submission:
#Rating Goal
R = int(input())
G = int(input())
T = R + 2 * (G - R)
print(T)

Buggy python submission (verdict: Runtime Error):
#Rating Goal
R, G = map(int, input().split())
T = R + 2 * (G - R)
print (T)

Fixed submission:
#Rating Goal
R = int(input())
G = int(input())
T = R + 2 * (G - R)
print(T)
Buggy python submission (verdict: Runtime Error):
#Can you get AC?
S = input()
p = 0
for i in range(n-1):
    if S[i:i+2] == "AC":
        print("Yes")
        p = p + 1
        break
    else:
        continue
if p == 0:
    print("No")

Fixed submission:
#Can you get AC?
S = input()
n = len(S)
p = 0
for i in range(n-1):
    if S[i:i+2] == "AC":
        print("Yes")
        p = p + 1
        break
    else:
        continue
if p == 0:
    print("No")

Buggy python submission (verdict: Runtime Error):
#Can you get AC?
S = input()
p = 0
for i in range(n-1):
    if S[i:i+2] == "AC":
        print("Yes")
        p = p + 1
        break
    else:
        continue
if p == 0:
    print("No")

Fixed submission:
#Can you get AC?
S = input()
n = len(S)
p = 0
for i in range(n-1):
    if S[i:i+2] == "AC":
        print("Yes")
        p = p + 1
        break
    else:
        continue
if p == 0:
    print("No")
Buggy python submission (verdict: Runtime Error):
#Multiple Clocks
import math
N = int(input())
T = int(input())
for i in range (N-1):
    t = int(input())
    T = t*T // math.gcd(t,T)
print(T)

Fixed submission:
#Multiple Clocks
import fractions
N = int(input())
T = int(input())
for i in range (N-1):
    t = int(input())
    T = t*T // fractions.gcd(t,T)
print(T)
Buggy python submission (verdict: Runtime Error):
#Expired?
X, A, B = map(int, input().split())
Count = -A+B
if Count <= 0:
    print("delicious")
elif Cunt <= X:
    print("safe")
else:
    print("dangerous")

Fixed submission:
#Expired?
X, A, B = map(int, input().split())
Count = -A+B
if Count <= 0:
    print("delicious")
elif Count <= X:
    print("safe")
else:
    print("dangerous")
Buggy python submission (verdict: Time Limit Exceeded):
#Trained?
N = int(input())
a = [int(input()) for _ in range(N)]
judge2 = 0
judgeloop = 0
now = 1
tugi = a[0]
rireki = []
n = 1

if tugi == 2:
    judge2 += 1

while judge2 == 0 and judgeloop == 0:
    n += 1
    rireki.append(now)
    now = tugi
    tugi = a[tugi-1]
    if tugi in rireki:
        judgeloop += 1
    elif tugi == 2:
        judge2 += 1

if judgeloop == 1:
    print(-1)
elif judge2 == 1:
    print(n)

Fixed submission:
#Trained?
N = int(input())
a = [int(input()) for _ in range(N)]

now = 1
L = [0]*N
for i in range(N):
    L[i] = now
    now = a[now-1]

judge = 1
for i in range(N):
    if L[i] == 2:
        print(i)
        judge = 0
        break
    else:
        pass

if judge == 1:
    print(-1)
Buggy python submission (verdict: Runtime Error):
#Colorful Leaderboard
N = int(input())
a = list(map(int, input().split()))
L = [0 for i in range(9)]
for i in range(N):
    L[a[i]//400] = L[a[i]//400] + 1
n = 0
for i in range(8):
    if L[i] > 0:
        n = n + 1
nmin = n
nmax = n + L[8]
if nmax > 9:
    nmax = 9
print(str(nmin)+" "+str(nmax))

Fixed submission:
#Colorful Leaderboard
N = int(input())
a = list(map(int, input().split()))
L = [0 for i in range(8)]
s = 0
for i in range(N):
    if a[i] < 3200:
        L[a[i]//400] = L[a[i]//400] + 1
    else:
        s = s + 1
n = 0
for i in range(8):
    if L[i] > 0:
        n = n + 1
nmin = n
nmax = n + s
if nmin == 0:
    nmin = 1
print(str(nmin)+" "+str(nmax))
Buggy python submission (verdict: Runtime Error):
#Big Array
N, K = map(int, input().split())
a = [0]*N
b = [0]*N
R = [0]*(10**5)
ans = 0
for i in range(N):
    a[i], b[i] = map(int, input().split())
for i in range(N):
    R[a[i]] = R[a[i]] + b[i]
j = 0
while K > 0:
    K = K - R[j]
    ans = ans + 1
    j = j + 1
print(ans-1)

Fixed submission:
#Big Array
N, K = map(int, input().split())
a = [0]*(N)
b = [0]*(N)
R = [0]*(10**5+1)
ans = 0
for i in range(N):
    a[i], b[i] = map(int, input().split())
for i in range(N):
    R[a[i]] = R[a[i]] + b[i]
j = 0
while K > 0:
    K = K - R[j]
    ans = ans + 1
    j = j + 1
print(ans-1)

Buggy python submission (verdict: Time Limit Exceeded):
#Big Array
N, K = map(int, input().split())
a = [0]*N
b = [0]*N
R = []
for i in range(N):
    a[i], b[i] = map(int, input().split())
for i in range(N):
    for j in range(b[i]):
        R.append(a[i])
R.sort()
print(R[K-1])

Fixed submission:
#Big Array
N, K = map(int, input().split())
a = [0]*(N)
b = [0]*(N)
R = [0]*(10**5+1)
ans = 0
for i in range(N):
    a[i], b[i] = map(int, input().split())
for i in range(N):
    R[a[i]] = R[a[i]] + b[i]
j = 0
while K > 0:
    K = K - R[j]
    ans = ans + 1
    j = j + 1
print(ans-1)
Buggy python submission (verdict: Runtime Error):
#∵∴∵
O = input()
E = input()
S = ""
for i in range(len(E)):
    S = S + O[i]
    S = S + E[i]
if len(E) < len(O):
    S = S + S[len(O)]
print(S)

Fixed submission:
#∵∴∵
O = input()
E = input()
S = ""
for i in range(len(E)):
    S = S + O[i]
    S = S + E[i]
if len(E) < len(O):
    S = S + O[len(O)-1]
print(S)
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int,input().split())
x = list(map(int,input().split()))

d = []
for i in range(n-1):
  d.append(x[i+1]-x[i])

f = 0
for i in range(n-1):
  if d[i]*a <= b:
    f += d*a
  else:
    f += b
    
print(f)

Fixed submission:
n, a, b = map(int,input().split())
x = list(map(int,input().split()))

d = []
for i in range(n-1):
  d.append(x[i+1]-x[i])

f = 0
for i in range(n-1):
  if d[i]*a <= b:
    f += d[i]*a
  else:
    f += b
    
print(f)
Buggy python submission (verdict: Runtime Error):
#Iroha Loves Strings (ABC Edition)
N, L = map(int, input().split())
S = []
for _ in range(N):
    S.append(input())
sort = sorted(S)
R = ""
for i in range(0,N):
    R = R + sort[i]
print(R)

Fixed submission:
A,B,C = map(int,input().split())
S = A+B+C
if S == 17:
    S = S - max(A, B, C)
    if S == 10:
        S = S - min(A, B, C)
        if S == 5:
            print("YES")
        else:
            pass
    else:
        pass
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
#Iroha Loves Strings (ABC Edition)
N, L = map(int, input().split())
S = []
for _ in range(N):
    S.append(input())
R = []
K = ""
R.append(S[0])
for i in range(1, N):
    for j in range (0, i):
        if S[i] < R[j]:
            R.insert(j,S[i])
        if S[i] >= R[i-1]:
            R.append(S[i])
for i in range(0,N):
    K = K + R[i]
print(K)

Fixed submission:
A,B,C = map(int,input().split())
S = A+B+C
if S == 17:
    S = S - max(A, B, C)
    if S == 10:
        S = S - min(A, B, C)
        if S == 5:
            print("YES")
        else:
            pass
    else:
        pass
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
a=int(input())
b=list(map(int,input().split()))
d=[]
d.append(0)
for i in range(a):
	d.append(b[i])
for i in range(1,a+1):
	sumx=0
	if(i==a):
		e=d[:i]
	else:
		e=d[:i]+d[i+1:]
	for j in range(1,len(e)):
		sumx+=abs(e[j]-e[j-1])
	sumx+=abs(e[-1]-0)
	print(sumx)

Fixed submission:
a=int(input())
b=list(map(int,input().split()))
d=[]
d.append(0)
d=d+b
sumx=0
for i in range(1,a+1):
	sumx+=abs(d[i]-d[i-1])
for i in range(1,a):
	sumx1=sumx-abs(d[i]-d[i-1])-abs(d[i+1]-d[i])+abs(d[i+1]-d[i-1])
	sumx1+=abs(d[-1]-0)
	print(sumx1)
sumx1=sumx-abs(d[-1]-d[-2])+abs(d[-2]-0)
print(sumx1)
Buggy python submission (verdict: Runtime Error):
S, T = input().split()
A, B = map(int, input().split())
U = input()

if U == S:
    A -= 1
else:
    B -= 1

print(f"{A} {B}")


Fixed submission:
S, T = input().split()
A, B = map(int, input().split())
U = input()

if U == S:
    A -= 1
else:
    B -= 1

print(A, B)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

N = int(input())
S = [sorted(input()) for _ in range(N)]

print(sum(1 if s1 == s2 else 0 for s1, s2 in combinations(S, 2)))


Fixed submission:
from collections import Counter

N = int(input())
S = ["".join(sorted(list(input()))) for _ in range(N)]

cnt = Counter(S)
print(sum(v*(v-1)//2 for v in cnt.values()))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

if N == 2:
    print("\n".join(map(str, A[::-1])))
else:
    for i in range(N):
        if i == N - 1:
            print(max(A[:-1]))
        else:
            print(max(A[:i] + A[i+1:]))


Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]

if N == 2:
    print("\n".join(map(str, A[::-1])))
else:
    a = sorted(A)
    maxv1 = a[-1]
    maxi1 = A.index(maxv1)
    maxv2 = a[-2]

    for i in range(N):
        if i == maxi1:
            print(maxv2)        
        else:
            print(maxv1)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for _ in range(N)]

if N == 2:
    print("\n".join(map(str, A[::-1])))
else:
    for i in range(N):
        if i == N - 1:
            print(max(A[:-1]))
        else:
            print(max(*A[:i], *A[i+1:]))

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]

if N == 2:
    print("\n".join(map(str, A[::-1])))
else:
    a = sorted(A)
    maxv1 = a[-1]
    maxi1 = A.index(maxv1)
    maxv2 = a[-2]

    for i in range(N):
        if i == maxi1:
            print(maxv2)        
        else:
            print(maxv1)
Buggy python submission (verdict: Runtime Error):
_, m = map(int, input().split())

mi, mx = map(int, input().split())
for i in range(m-1):
    l, r = map(int, input().split())
    if mi < l <= mx:
        mi = l
    if mi <= r < mx:
        mx = r
    if mx < l or r < mi:
        flag = True
        break

if flag:
    print(0)
else:
    print(mx - mi + 1)

Fixed submission:
_, m = map(int, input().split())

mi, mx = map(int, input().split())
flag = False
for i in range(m-1):
    l, r = map(int, input().split())
    if mi < l <= mx:
        mi = l
    if mi <= r < mx:
        mx = r
    if mx < l or r < mi:
        flag = True
        break

if flag:
    print(0)
else:
    print(mx - mi + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())

l, r = map(int, input().split())
gate = set(range(l, r+1))
for i in range(m-1):
    l, r = map(int, input().split())
    gate = set(range(l, r+1)) & gate

print(len(gate))

Fixed submission:
_, m = map(int, input().split())

mi, mx = map(int, input().split())
flag = False
for i in range(m-1):
    l, r = map(int, input().split())
    if mi < l <= mx:
        mi = l
    if mi <= r < mx:
        mx = r
    if mx < l or r < mi:
        flag = True
        break

if flag:
    print(0)
else:
    print(mx - mi + 1)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))

for i in range(m):
    b, c = map(int, input().split())
    a = sorted(a + [c] * b, reverse=True)[:n]

print(sum(a))

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

bc = [tuple(map(int, input().split())) for _ in range(m)]
a.sort()
bc.sort(key=lambda x:x[1], reverse=True)

idx = 0
res = 0
flag = False
for b,c in bc:
    for _ in range(b):
        if idx < n and a[idx] < c:
            res += c
            idx += 1
        else:
            flag = True
    if flag:
        break

if idx < n:
    res += sum(a[idx:])

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
from functools import reduce

N = int(input())
A = list(map(int, input().split()))


def gcd_list(lst):
    return reduce(gcd, lst)


ans = 0
for i in range(N):
    ans = max(ans, gcd_list(A[:i] + A[i+1:]))
print(ans)


Fixed submission:
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))


def gcd2(x, y):
    if not x:
        return y
    if not y:
        return x
    return gcd(x, y)


L, R = [0] * (N+1), [0] * (N+1)
for i in range(1, N+1):
    L[i] = gcd2(L[i-1], A[i-1])
    R[N-i] = gcd2(R[N-i+1], A[N-i])

ans = 0
for i in range(N):
    ans = max(ans, gcd2(L[i], R[i+1]))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
LR = [list(map(int, input().split())) for _ in range(Q)]

cnt = [0] * (N)
for i in range(N-1):
    if S[i:i+2] == "AC":
        cnt[i] += 1

for l, r in LR:
    print(sum(cnt[l-1:r]) - cnt[r-1])


Fixed submission:
N, Q = map(int, input().split())
S = input()
LR = [list(map(int, input().split())) for _ in range(Q)]

cnt, acc = [0] * N, 0
for i in range(1, N):
    if S[i-1:i+1] == "AC":
        acc += 1
    cnt[i] = acc

for l, r in LR:
    print(cnt[r-1] - cnt[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
LR = [list(map(int, input().split())) for _ in range(Q)]

for l, r in LR:
    print(S[l-1:r].count("AC"))

Fixed submission:
N, Q = map(int, input().split())
S = input()
LR = [list(map(int, input().split())) for _ in range(Q)]

cnt, acc = [0] * N, 0
for i in range(1, N):
    if S[i-1:i+1] == "AC":
        acc += 1
    cnt[i] = acc

for l, r in LR:
    print(cnt[r-1] - cnt[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split())) + [float("inf")] * (K-1)

dp = [0] * N + [float("inf")] * K
for i in range(N-1)[::-1]:
    temp = float("inf")
    for k in range(1, K+1):
        temp = min(temp, abs(h[i+k] - h[i]) + dp[i+k])
    dp[i] = temp

print(dp[0])


Fixed submission:
N, K = map(int, input().split())
h = list(map(int, input().split())) + [float("inf")] * (K-1)

dp = [0] * N + [float("inf")] * K
for i in range(N-1)[::-1]:
    temp = float("inf")
    for k in range(1, K+1):
        temp = min(temp, abs(h[i+k] - h[i]) + dp[i+k])
    dp[i] = temp

print(dp[0])