Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = input()
c = [0]*N
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        c[i] = 1
for i in range(Q):
    l,r = map(int,input().split())
    ans = c[l-1:r-1]
    print(ans.count(1))

Fixed submission:
N,Q = map(int,input().split())
S = input()
c = []
count = 0
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        count += 1
    c.append(count)
for i in range(Q):
    l,r = map(int,input().split())
    if l == 1:
        print(c[r-2]-0)
    else:
        print(c[r-2]-c[l-2])

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())
    c = 0
    for j in range(l-1,r-1):
        if S[j] == "A" and S[j+1] == "C":
            c += 1
    print(c)

Fixed submission:
N,Q = map(int,input().split())
S = input()
c = []
count = 0
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        count += 1
    c.append(count)
for i in range(Q):
    l,r = map(int,input().split())
    if l == 1:
        print(c[r-2]-0)
    else:
        print(c[r-2]-c[l-2])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = list(input())
for i in range(Q):
    l,r = map(int,input().split())
    c = 0
    for j in range(l-1,r-1):
        if S[j] == "A" and S[j+1] == "C":
            c += 1
    print(c)

Fixed submission:
N,Q = map(int,input().split())
S = input()
c = []
count = 0
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        count += 1
    c.append(count)
for i in range(Q):
    l,r = map(int,input().split())
    if l == 1:
        print(c[r-2]-0)
    else:
        print(c[r-2]-c[l-2])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = list(input())
for i in range(Q):
    l,r = map(int,input().split())
    s = S[l-1:r]
    c = 0
    for j in range(len(s)-1):
        if s[j] == "A" and s[j+1] == "C":
            c += 1
    print(c)

Fixed submission:
N,Q = map(int,input().split())
S = input()
c = []
count = 0
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        count += 1
    c.append(count)
for i in range(Q):
    l,r = map(int,input().split())
    if l == 1:
        print(c[r-2]-0)
    else:
        print(c[r-2]-c[l-2])

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

Fixed submission:
N,Q = map(int,input().split())
S = input()
c = []
count = 0
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        count += 1
    c.append(count)
for i in range(Q):
    l,r = map(int,input().split())
    if l == 1:
        print(c[r-2]-0)
    else:
        print(c[r-2]-c[l-2])
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
py = [list(map(int,input().split())) for i in range(M)]
P = [[] for i in range(N)]
for p,y in py:
    P[p-1].append(y)
for i in P:
    i.sort()
for p,y in py:
    c = str(P[p-1].index(y) + 1)
    p = str(p)
    ans = "0" * (6-len(p)) + p + "0" *(6-len(c)) + c
    print(ans)

Fixed submission:
N,M = map(int,input().split())
py = [list(map(int,input().split()))+[i] for i in range(M)]
py.sort()
P = py[0][0]
c = 0
ans = []
for p,y,i in py:
    if p == P:
        c += 1
    else:
        P = p
        c = 1
    ansc = str(c)
    ansp = str(p)
    anser = "0" * (6-len(ansp)) + ansp + "0" *(6-len(ansc)) + ansc
    ans.append([i,anser])
ans.sort()
for i,anser in ans:
    print(anser)
Buggy python submission (verdict: Runtime Error):
n = int(input())
v = list(map(int,input().split()))
v0 = v[0:n-1:2]
v1 = v[1:n:2]
from collections import Counter
V0 = Counter(v0)
V1 = Counter(v1)
if V0.most_common()[0][0] != V1.most_common()[0][0]:
    a = V0.most_common()[0][1]
    b = V1.most_common()[0][1]
else:
    if V0.most_common()[0][1] > V1.most_common()[0][1]:
        if len(V1) > 1:
            a = V0.most_common()[0][1]
            b = V1.most_common()[1][1]
        else:
            a = V0.most_common()[0][1]
            b = 0
    elif V0.most_common()[0][1] < V1.most_common()[0][1]:
        if len(V0) > 1:
            a = V1.most_common()[0][1]
            b = V0.most_common()[1][1]
        else:
            a = 0
            b = V1.most_common()[0][1]
    else:
        if len(V0) == 1 and len(V1) == 1:
            a = 0
            b = V0.most_common()[1][1]
        elif len(V0) == 1:
            a = V0.most_common()[0][1]
            b = V1.most_common()[1][1]
        elif len(V1) == 1:
            a = V0.most_common()[1][1]
            b = V1.most_common()[0][1]
        else:
            a = V0.most_common()[0][1]
            b = max(V0.most_common()[1][1],V1.most_common()[1][1])
print(n-a-b)

Fixed submission:
n = int(input())
v = list(map(int,input().split()))
v0 = v[0:n-1:2]
v1 = v[1:n:2]
from collections import Counter
V0 = Counter(v0)
V1 = Counter(v1)
if V0.most_common()[0][0] != V1.most_common()[0][0]:
    a = V0.most_common()[0][1]
    b = V1.most_common()[0][1]
else:
    if V0.most_common()[0][1] > V1.most_common()[0][1]:
        if len(V1) > 1:
            a = V0.most_common()[0][1]
            b = V1.most_common()[1][1]
        else:
            a = V0.most_common()[0][1]
            b = 0
    elif V0.most_common()[0][1] < V1.most_common()[0][1]:
        if len(V0) > 1:
            a = V1.most_common()[0][1]
            b = V0.most_common()[1][1]
        else:
            a = 0
            b = V1.most_common()[0][1]
    else:
        if len(V0) == 1 and len(V1) == 1:
            a = 0
            b = V0.most_common()[0][1]
        elif len(V0) == 1:
            a = V0.most_common()[0][1]
            b = V1.most_common()[1][1]
        elif len(V1) == 1:
            a = V0.most_common()[1][1]
            b = V1.most_common()[0][1]
        else:
            a = V0.most_common()[0][1]
            b = max(V0.most_common()[1][1],V1.most_common()[1][1])
print(n-a-b)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
x = list(map(int,input().split()))
xp = [i for i in x if i >= 0]
xn = [i for i in x if i < 0]
xn.reverse()
lp = len(xp)
ln = len(xn)
pc = min(K,lp)
pp = xp[pc-1]
if K>lp:
    nc = K-lp
    np = -xn[nc-1]
else:
    nc = 0
    np = 0
ans = pp + np + min(pp,np)
for i in range(pc-1):
    if nc == ln:
        break
    pp = xp[pc-i-2]
    np = -xn[nc]
    nc += 1
    ans = min(ans,pp + np + min(pp,np))
print(ans)

Fixed submission:
N,K = map(int,input().split())
x = list(map(int,input().split()))
xp = [i for i in x if i >= 0]
xn = [i for i in x if i < 0]
xn.reverse()
lp = len(xp)
ln = len(xn)
if lp == 0:
    print(-xn[K-1])
    exit()
if ln == 0:
    print(xp[K-1])
    exit()
pc = min(K,lp)
pp = xp[pc-1]
if K>lp:
    nc = K-lp
    np = -xn[nc-1]
else:
    nc = 0
    np = 0
ans = pp + np + min(pp,np)
for i in range(pc-1):
    if nc == ln:
        break
    pp = xp[pc-i-2]
    np = -xn[nc]
    nc += 1
    ans = min(ans,pp + np + min(pp,np))
print(ans)

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
x = list(map(int,input().split()))
xp = [i for i in x if i >= 0]
xn = [i for i in x if i < 0]
xn.reverse()
lp = len(xp)
ln = len(xn)
pc = min(K,lp)
pp = xp[pc-1]
if K>lp:
    nc = K-lp
    np = -xn[nc-1]
else:
    nc = 0
    np = 0
ans = pp + np + min(pp,np)
for i in range(pc):
    if nc == ln:
        break
    pp = xp[pc-i-2]
    np = -xn[nc]
    nc += 1
    ans = min(ans,pp + np + min(pp,np))
print(ans)

Fixed submission:
N,K = map(int,input().split())
x = list(map(int,input().split()))
xp = [i for i in x if i >= 0]
xn = [i for i in x if i < 0]
xn.reverse()
lp = len(xp)
ln = len(xn)
if lp == 0:
    print(-xn[K-1])
    exit()
if ln == 0:
    print(xp[K-1])
    exit()
pc = min(K,lp)
pp = xp[pc-1]
if K>lp:
    nc = K-lp
    np = -xn[nc-1]
else:
    nc = 0
    np = 0
ans = pp + np + min(pp,np)
for i in range(pc-1):
    if nc == ln:
        break
    pp = xp[pc-i-2]
    np = -xn[nc]
    nc += 1
    ans = min(ans,pp + np + min(pp,np))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
    A[i] = A[i]-i-1
A.sort()
import bisect
z = bisect.bisect_left(A,0)
ans = sum(A[z:])-sum(A[:z])
if z > N-z:
    b = -1
    while z>N-z:
        ans += N - 2*z
        b -= 1
        z = bisect.bisect_right(A,b)
elif N > 2*bisect.bisect_left(A,1):
    z = bisect.bisect_left(A,1)
    b = 1
    while N-z>z:
        ans += 2*z - N
        b += 1
        z = bisect.bisect_left(A,2)
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
    A[i] = A[i]-i-1
A.sort()
import bisect
z = bisect.bisect_left(A,0)
ans = sum(A[z:])-sum(A[:z])
if z > N-z:
    p = 0
    while z>N-z:
        b = A[z-1]
        ans += (N - 2*z) * (p-b)
        p = b
        z = bisect.bisect_left(A,b)
elif N > 2*bisect.bisect_right(A,0):
    z = bisect.bisect_right(A,0)
    p = 0
    while N-z>z:
        b = A[z]
        ans += (2*z - N) * (b-p)
        p = b
        z = bisect.bisect_right(A,b)
print(ans)
Buggy python submission (verdict: Runtime Error):
 = int(input())
A = list(map(int,input().split()))
j = abs(A[0]) + abs(A[N-1])
for i in range(N-1):
    j += abs(A[i]-A[i+1])
for i in range(N):
    if i == 0:
        ans = j-abs(A[0])-abs(A[0]-A[1])+abs(A[1])
    elif i == N-1:
        ans = j-abs(A[N-2]-A[N-1])-abs(A[N-1])+abs(A[N-2])
    else:
        ans = j - abs(A[i]-A[i-1]) - abs(A[i]-A[i+1]) + abs(A[i-1]-A[i+1])
    print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
j = abs(A[0]) + abs(A[N-1])
for i in range(N-1):
    j += abs(A[i]-A[i+1])
for i in range(N):
    if i == 0:
        ans = j-abs(A[0])-abs(A[0]-A[1])+abs(A[1])
    elif i == N-1:
        ans = j-abs(A[N-2]-A[N-1])-abs(A[N-1])+abs(A[N-2])
    else:
        ans = j - abs(A[i]-A[i-1]) - abs(A[i]-A[i+1]) + abs(A[i-1]-A[i+1])
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
ans = 0
import bisect
for i in A:
    a = bisect.bisect_right(B,i)
    for j in range(a,N):
        b = bisect.bisect_right(C,B[j])
        ans += N-b
print(ans)

Fixed submission:
N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
ans = 0
import bisect
b = []
for i in B:
    x = bisect.bisect_right(C,i)
    b.append(N-x)
y = sum(b)
c = [y]
for i in range(1,N):
    y -= b[i-1]
    c.append(y)
c.append(0)
for i in A:
    a = bisect.bisect_right(B,i)
    ans += c[a]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = []
for i in range(N):
    A = input()
    if A in ans:
        ans.remove(A)
    else:
        ans.append(A)
print(len(ans))

Fixed submission:
N = int(input())
ans = {}
for i in range(N):
    A = input()
    if  A in ans:
        ans[A] += 1
    else:
        ans[A] = 1
c = 0
for i in ans:
    if ans[i] % 2 == 1:
        c += 1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
import collections
a = collections.Counter(A)
b = []
for i in range(len(a)):
    if a.most_common()[i][1] >= 2:
        b.append(a.most_common()[i])
    else:
        break
b.sort()
if len(b) >= 1 and b[-1][1] >= 4:
    print(b[-1][0] ** 2)
elif len(b) >= 2:
    print(b[-1][0] * b[-2][0])
else:
    print(0)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
import collections
a = collections.Counter(A)
b = []
for i, j in a.items():
    if j >= 2:
        b.append([i,j])
b.sort(reverse=True)
if len(b) >= 1 and b[0][1] >= 4:
    print(b[0][0] ** 2)
elif len(b) >= 2:
    print(b[0][0] * b[1][0])
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
import collections
a = collections.Counter(A)
b = []
for i in range(len(a)):
    if a.most_common()[i][1] >= 2:
        b.append(a.most_common()[i])
    else:
        break
b.sort(reverse=True)
if len(b) >= 1 and b[0][1] >= 4:
    print(b[0][0] ** 2)
elif len(b) >= 2:
    print(b[0][0] * b[1][0])
else:
    print(0)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
import collections
a = collections.Counter(A)
b = []
for i, j in a.items():
    if j >= 2:
        b.append([i,j])
b.sort(reverse=True)
if len(b) >= 1 and b[0][1] >= 4:
    print(b[0][0] ** 2)
elif len(b) >= 2:
    print(b[0][0] * b[1][0])
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
f = [[] for i in range(N)]
for i in range(N-1):
    a,b,c = map(int,input().split())
    f[a-1].append([b-1,c])
    f[b-1].append([a-1,c])
from collections import deque
d = deque()
s = [-1]*N
Q,K = map(int,input().split())
for i in range(N):
    t = [-1]*N
    d.append(i)
    t[i] = 0
    if i == K-1:
        Flag = False
        z = d.clear()
    else:
        Flag = True
    while Flag:
        z = d.popleft()
        for j,c in f[z]:
            if t[j] == -1:
                t[j] = c+t[z]
                d.append(j)
            if j == K-1:
                Flag = False
                d.clear()
                break
    s[i] = t[K-1]
for i in range(Q):
    x,y = map(int,input().split())
    print(s[x-1]+s[y-1])

Fixed submission:
N = int(input())
f = [[] for i in range(N)]
for i in range(N-1):
    a,b,c = map(int,input().split())
    f[a-1].append([b-1,c])
    f[b-1].append([a-1,c])
from collections import deque
d = deque()
s = [-1]*N
Q,K = map(int,input().split())
d.append(K-1)
s[K-1] = 0
while len(d) > 0:
    z = d.popleft()
    for i,j in f[z]:
        if s[i] == -1:
            s[i] = j+s[z]
            d.append(i)
for i in range(Q):
    x,y = map(int,input().split())
    print(s[x-1]+s[y-1])
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
ans = []
for i in range(N):
    a,b = map(int,input().split())
    for j in range(b):
        ans.append(a)
ans.sort()
print(ans[K-1])

Fixed submission:
N,K = map(int,input().split())
ans = []
for i in range(N):
    ab = list(map(int,input().split()))
    ans.append(ab)
ans.sort()
l = 0
for i in range(N):
    l += ans[i][1]
    if l >= K:
        s = i
        break
print(ans[s][0])
Buggy python submission (verdict: Runtime Error):
x = y = S//3 + 1
z = S - x - y
if z < y:
    x = z
    z = y
while 0 <= x <= y and 0 <= y <= K and y <= z <= K:
    while 0 <= x and z <= K:
        if x == y == z:
            ans += 1
        elif x == y or y == z:
            ans += 3
        else:
            ans += 6
        x -= 1
        z += 1
    y += 1
    x = y
    z = S - x - y
    if z < y:
        x = z
        z = y
print(ans)

Fixed submission:
K,S = map(int,input().split())
x = y = S//3
z = S - x - y
if z < y:
    x = z
    z = y
ans = 0
while 0 <= x <= y and 0<= y <=K and z <= K:
    while 0 <= x and z <= K:
        if x == y == z:
            ans += 1
        elif x == y or y == z:
            ans += 3
        else:
            ans += 6
        x -= 1
        z += 1
    y -= 1
    x = y
    z = S - x - y
    if z < y:
        x = z
        z = y
x = y = S//3 + 1
z = S - x - y
if z < y:
    x = z
    z = y
while 0 <= x <= y and 0 <= y <= K and y <= z <= K:
    while 0 <= x and z <= K:
        if x == y == z:
            ans += 1
        elif x == y or y == z:
            ans += 3
        else:
            ans += 6
        x -= 1
        z += 1
    y += 1
    x = y
    z = S - x - y
    if z < y:
        x = z
        z = y
print(ans)
Buggy python submission (verdict: Runtime Error):
x,y = map(int,input().split())
ax = abs(x)
ay = abs(y)
if ax == ay and x != y:
    a = 1
elif x > y and 0 < y:
    a = ax - ay + 2
elif x > y and y = 0:
    a = ax - ay + 1
elif x > y and 0 > y:
    if ay > ax and x >= 0:
        a = ay - ax + 1
    elif ay > ax and x < 0:
        a = ay - ax + 2
    elif ax > ay:
        a = ax - ay + 1
elif y > x and x < 0 and ay > ax:
    a = ay - ax + 1
elif y > x and x < 0 and y > 0 and ax > ay:
    a = ax - ay + 1
else:
    a = y-x
print(a)

Fixed submission:
x,y = map(int,input().split())
ax = abs(x)
ay = abs(y)
if ax == ay and x != y:
    a = 1
elif x > y and 0 < y:
    a = ax - ay + 2
elif x > y and y == 0:
    a = ax - ay + 1
elif x > y and 0 > y:
    if ay > ax and x >= 0:
        a = ay - ax + 1
    elif ay > ax and x < 0:
        a = ay - ax + 2
    elif ax > ay:
        a = ax - ay + 1
elif y > x and x < 0 and ay > ax:
    a = ay - ax + 1
elif y > x and x < 0 and y > 0 and ax > ay:
    a = ax - ay + 1
else:
    a = y-x
print(a)

Buggy python submission (verdict: Runtime Error):
x,y = map(int,input().split())
ax = abs(x)
ay = abs(y)
if x > y and 0 < y:
    x = -x
    a = y - x + 1
    if  ay > ax and x >= 0:
        a = ay - x + 

elif x > y and 0 >= y:
    if ay > ax and x >= 0:
        a = ay - x + 1
    elif ay > ax and x < 0:
        a = ay + x + 2
    else:
        a = 1
elif y > x and x < 0:
    if ay > ax:
        a = ay - ax + 1
else:
    a = y-x
print(a)

Fixed submission:
x,y = map(int,input().split())
ax = abs(x)
ay = abs(y)
if ax == ay and x != y:
    a = 1
elif x > y and 0 < y:
    a = ax - ay + 2
elif x > y and y == 0:
    a = ax - ay + 1
elif x > y and 0 > y:
    if ay > ax and x >= 0:
        a = ay - ax + 1
    elif ay > ax and x < 0:
        a = ay - ax + 2
    elif ax > ay:
        a = ax - ay + 1
elif y > x and x < 0 and ay > ax:
    a = ay - ax + 1
elif y > x and x < 0 and y > 0 and ax > ay:
    a = ax - ay + 1
else:
    a = y-x
print(a)
Buggy python submission (verdict: Runtime Error):
S = input()
i = 0
while i <= len(S)-5:
    if S[i:i+5] == "dream":
        i += 5
        if S[i:i+2] == "er" and S[i:i+5] != "erase":
            i += 2
    elif S[i:i+5] == "erase":
        i += 5
        if S[i] == "r":
            i += 1
    else:
        break
if i != len(S):
    print("NO")
else:
    print("YES")

Fixed submission:
S = input()
i = 0
n = len(S)
while i <= n-5:
    if S[i:i+5] == "dream":
        i += 5
        if S[i:i+2] == "er" and S[i:i+5] != "erase":
            i += 2
    elif S[i:i+5] == "erase":
        i += 5
        if S[i:i+1] == "r":
            i += 1
    else:
        break
if i != len(S):
    print("NO")
else:
    print("YES")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    m = 10**9 + 7
    B =[a%m for a in A]
    ans = 0
    for i in range(N-1):
        for j in range(i+1,N):
            # ans += (A[i]*A[j])%(10**9+7)
            ans += (A[i]*A[j])
    print(ans%m)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    W = [0]*N
    W[0] = A[0]
    for i in range(1,N):
        W[i] += W[i-1] + A[i]
    ans = 0
    for i in range(N-1):
        ans += A[i]*(W[N-1] - W[i])
    print(ans%(10**9+7))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    m = 10**9 + 7
    B =[a%m for a in A]
    ans = 0
    for i in range(N-1):
        for j in range(i+1,N):
            # print(B[i],B[j])
            # ans += (A[i]*A[j])%(10**9+7)
            ans += A[i]%m * A[j]%m
    print(ans%m)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    W = [0]*N
    W[0] = A[0]
    for i in range(1,N):
        W[i] += W[i-1] + A[i]
    ans = 0
    for i in range(N-1):
        ans += A[i]*(W[N-1] - W[i])
    print(ans%(10**9+7))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def main():
    S = input().rstrip()
    CNT = 0
    ans = 0
    for c in S:
        if c == 'R':
            CNT += 1
        else:
            ans = max(ans,CNT)
            CNT = 0
    print(ans)


if __name__ == '__main__':
    main)

Fixed submission:
import sys
input = sys.stdin.readline
def main():
    S = input().rstrip()
    CNT = 0
    ans = 0
    for c in S:
        if c == 'R':
            CNT += 1
        else:
            ans = max(ans,CNT)
            CNT = 0

    ans = max(ans,CNT)
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    tmp = 1
    for i in range(K):
        tmp *= A[i]

    for i in range(K,N):
        n = tmp * A[i] / A[i-K]
        if n > tmp:
            print('Yes')
        else:
            print('No')
        tmp = n

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    # tmp = 1
    # for i in range(K):
    #     tmp *= A[i]
    # print(tmp)

    for i in range(K,N):
        # n = tmp * A[i] / A[i-K]
        n = A[i]/A[i-K]
        if n > 1:
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    tmp = 1
    for i in range(K):
        tmp *= A[i]

    for i in range(K,N):
        n = tmp * A[i] / A[i-K]
        if n > tmp:
            print('Yes')
        else:
            print('No')
        tmp = n

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    # tmp = 1
    # for i in range(K):
    #     tmp *= A[i]
    # print(tmp)

    for i in range(K,N):
        # n = tmp * A[i] / A[i-K]
        n = A[i]/A[i-K]
        if n > 1:
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    tmp = 1
    for i in range(K):
        tmp *= A[i]

    for i in range(K,N):
        n = tmp * A[i] / A[i-K]
        if n > tmp:
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    # tmp = 1
    # for i in range(K):
    #     tmp *= A[i]
    # print(tmp)

    for i in range(K,N):
        # n = tmp * A[i] / A[i-K]
        n = A[i]/A[i-K]
        if n > 1:
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    M = [0]*(N+1)
    for i in range(1,N+1):
        for j in range(i, N+1, i):
            M[j] += 1
    ans = 0
    for i in range(1, N+1):
        ans += i * M[i]
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    M = [0]*(N+1)
    for i in range(1,N+1):
        for j in range(i, N+1, i):
            M[j] += 1
    ans = 0
    for i in range(1, N+1):
        ans += i * M[i]
    print(ans)

if __name__ == '__main__':
    main()