Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np


DEBUG = True
dprint = print if DEBUG else lambda *x : x

H, N = [int(str) for str in input().strip().split()]
AB = [[int(str) for str in input().strip().split()] for _ in range(N)]

dp = [0]
for h in range(1, H + 1):
    a, b = min(AB, key=lambda i: i[1] + dp[max(0, h - i[0])])
    dp.append(b + dp[max(0, h - a)])    
print(dp[-1])

Fixed submission:
H, N = [int(str) for str in input().strip().split()]
AB = [[int(str) for str in input().strip().split()] for _ in range(N)]

dp = [0]
for h in range(1, H + 1):
    a, b = min(AB, key=lambda i: i[1] + dp[max(0, h - i[0])])
    dp.append(b + dp[max(0, h - a)])    
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import numpy as np


DEBUG = True
dprint = print if DEBUG else lambda *x : x

H, N = [int(str) for str in input().strip().split()]
AB = [[int(str) for str in input().strip().split()] for _ in range(N)]

dp = [0]
for h in range(1, H + 1):
    dp.append(min([i[1] + dp[max(0, h - i[0])] for i in AB]))
    
print(dp[-1])

Fixed submission:
H, N = [int(str) for str in input().strip().split()]
AB = [[int(str) for str in input().strip().split()] for _ in range(N)]

dp = [0]
for h in range(1, H + 1):
    a, b = min(AB, key=lambda i: i[1] + dp[max(0, h - i[0])])
    dp.append(b + dp[max(0, h - a)])    
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import numpy as np


DEBUG = True
dprint = print if DEBUG else lambda *x : x

H, N = [int(str) for str in input().strip().split()]
AB = [[int(str) for str in input().strip().split()] for _ in range(N)]

cosp = [i[0] / i[1] for i in AB]

bestshot = AB[cosp.index(max(cosp))]
rem = H % bestshot[0]

dp = [0]
for h in range(1, H + 1):
    dp.append(min([i[1] + dp[max(0, h - i[0])] for i in AB if AB[0]]))
    
print(dp[-1])

Fixed submission:
H, N = [int(str) for str in input().strip().split()]
AB = [[int(str) for str in input().strip().split()] for _ in range(N)]

dp = [0]
for h in range(1, H + 1):
    a, b = min(AB, key=lambda i: i[1] + dp[max(0, h - i[0])])
    dp.append(b + dp[max(0, h - a)])    
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(str) for str in input().split()]

[print(a, end=' ') for a in [A.index(i) + 1 for i in range(1, N + 1)]]

Fixed submission:
import numpy as np


N = int(input())
A = np.array([int(str) for str in input().split()])
[print(i + 1, end=' ') for i in np.argsort(A)]

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(str) for str in input().split()]

[print(a, end=' ') for a in [A.index(i) + 1 for i in range(1, N + 1)]]

Fixed submission:
import numpy as np


N = int(input())
A = np.array([int(str) for str in input().split()])
[print(i + 1, end=' ') for i in np.argsort(A)]
Buggy python submission (verdict: Time Limit Exceeded):
N, M = [int(str) for str in input().strip().split()]

for i in range(N, M + 1):
    if M % i == 0:
        print(M // i)
        exit()

print(1)


Fixed submission:
#!/usr/bin/env python3
N, M = [int(str) for str in input().strip().split()]

divs = []
for i in range(1, int(M**0.5) + 1):
    if M % i == 0:
        divs.append(i)
        if i**2 != M:
            divs.append(M // i)

divs.sort(reverse=True)

for div in divs:
    if M // div >= N:
        print(div)
        exit()

Buggy python submission (verdict: Time Limit Exceeded):
N, M = [int(str) for str in input().strip().split()]

for i in range(N, M + 1):
    if M % i == 0:
        print(M // i)
        exit()

print(1)

Fixed submission:
#!/usr/bin/env python3
N, M = [int(str) for str in input().strip().split()]

divs = []
for i in range(1, int(M**0.5) + 1):
    if M % i == 0:
        divs.append(i)
        if i**2 != M:
            divs.append(M // i)

divs.sort(reverse=True)

for div in divs:
    if M // div >= N:
        print(div)
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
S = input().strip()
T = input().strip()

for i in range(len(S)):
    S = S.translate(str.maketrans({S[i]: T[i], T[i]: S[i]}))

print('Yes' if S == T else 'No')

Fixed submission:
S = input().strip()
T = input().strip()

s_dict = {}
for i in range(len(S)):
    if not S[i] in s_dict:
        s_dict[S[i]] = T[i]

    elif s_dict[S[i]] != T[i]:
        print('No')
        exit()

t_dict = {}
for i in range(len(T)):
    if not T[i] in t_dict:
        t_dict[T[i]] = S[i]

    elif t_dict[T[i]] != S[i]:
        print('No')
        exit()

print('Yes')

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input().strip())
T = list(input().strip())

for i in range(len(S)):
    s_idx = [j for j, c in enumerate(S) if c == S[i]]
    t_idx = [j for j, c in enumerate(T) if c == T[i]]

    if s_idx != t_idx:
        print('No')
        exit()

print('Yes')

Fixed submission:
S = input().strip()
T = input().strip()

s_dict = {}
for i in range(len(S)):
    if not S[i] in s_dict:
        s_dict[S[i]] = T[i]

    elif s_dict[S[i]] != T[i]:
        print('No')
        exit()

t_dict = {}
for i in range(len(T)):
    if not T[i] in t_dict:
        t_dict[T[i]] = S[i]

    elif t_dict[T[i]] != S[i]:
        print('No')
        exit()

print('Yes')
Buggy python submission (verdict: Runtime Error):
H, W = [int(str) for str in input().strip().split()]
A = [[int(str) for str in input().strip().split()] for _ in range(H)]

N = 0
actions = []
for i in range(H):
    jd = 1 - (i % 2) * 2
    js = list(range(W))[::jd]
    for j in js:
        if A[i][j] % 2:
            if j == js[-1]:
                if i != H - 1:
                    ti, tj = i + 1, j
            
            else:
                ti, tj = i, j + jd

            A[ti][tj] += 1
            actions.append([i + 1, j + 1, ti + 1, tj + 1])
            N += 1

print(N)
for action in actions:
    [print(a, end=' ') for a in action]
    print('')

Fixed submission:
H, W = [int(str) for str in input().strip().split()]
A = [[int(str) for str in input().strip().split()] for _ in range(H)]

N = 0
actions = []
for i in range(H):
    jd = 1 - (i % 2) * 2
    js = list(range(W))[::jd]
    for j in js:
        if A[i][j] % 2 and A[i][j] != 0:
            if j == js[-1]:
                if i != H - 1:
                    ti, tj = i + 1, j
                else:
                    break
            
            else:
                ti, tj = i, j + jd

            A[ti][tj] += 1
            actions.append('{0} {1} {2} {3}'.format(i + 1, j + 1, ti + 1, tj + 1))
            N += 1

print(N)
[print(action) for action in actions]
Buggy python submission (verdict: Runtime Error):
S = input().strip()
K = int(input().strip())

i = 0
while S[i] == '1':
    i += 1

print(S[i] if K > i else 1)

Fixed submission:
S = input().strip()
K = int(input().strip())

i = 0
while S[i] == '1' and i < len(S) - 1:
    i += 1

print(S[i] if K > i else 1)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = [int(str) for str in input().strip().split()]
A = [int(str) for str in input().strip().split()]

sums = [0]
for i in range(N):
    sums.append(sums[-1] + A[i])
    if sums[i] > M:
        sums[i] -= M

ans = 0
for l in range(N):
    for r in range(l + 1, N + 1):
        if (sums[r] - sums[l]) % M == 0:
            ans += 1

print(ans)

Fixed submission:
N, M = [int(str) for str in input().strip().split()]
A = [int(str) for str in input().strip().split()]

ssum = 0
B = {}
for i in range(N):
    ssum += A[i]
    key = ssum % M
    B[key] = B.get(key, 0) + 1

print(B.get(0, 0) + sum([i * (i - 1) for i in B.values()]) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = [int(str) for str in input().strip().split()]
A = [int(str) for str in input().strip().split()]

sums = [0]
for i in range(N):
    sums.append(sums[-1] + A[i])

ans = 0
for l in range(N):
    for r in range(l + 1, N + 1):
        if (sums[r] - sums[l]) % M == 0:
            ans += 1

print(ans)

Fixed submission:
N, M = [int(str) for str in input().strip().split()]
A = [int(str) for str in input().strip().split()]

ssum = 0
B = {}
for i in range(N):
    ssum += A[i]
    key = ssum % M
    B[key] = B.get(key, 0) + 1

print(B.get(0, 0) + sum([i * (i - 1) for i in B.values()]) // 2)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N, M = [int(str) for str in input().strip().split()]
cakes = np.array([[int(str) for str in input().strip().split()] for i in range(N)])

def calc_score(choised_cakes):
    return sum([abs(sum(para)) for para in choised_cakes.T])

score_list = []
for i in range(3):
    sorted_cakes = cakes[np.argsort(cakes[:, i])]
    for j in range(min(100, N - M)):
        score_list.append(calc_score(sorted_cakes[j : M + j, :]))
        score_list.append(calc_score(sorted_cakes[::-1][j : M + j, :]))

print(max(score_list))

Fixed submission:
import numpy as np
N, M = [int(str) for str in input().strip().split()]
cakes = np.array([[int(str) for str in input().strip().split()] for i in range(N)])

def calc_score(choised_cakes):
    return sum([abs(sum(para)) for para in choised_cakes.T])

signs_list = [[i, j, k] for i in (-1, 1) for j in (-1, 1) for k in (-1, 1)]

score_list = []
for signs in signs_list:
    sscores = np.dot(cakes, np.array(signs).T)
    sort_index = np.argsort(sscores)[::-1]
    sorted_cakes = cakes[sort_index]
    score_list.append(sum(np.dot(sorted_cakes[:M], np.array(signs).T)))

print(max(score_list))
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

input = sys.stdin.readline


def main():
    X, N = list(map(int, input().split(" ")))
    if N==0:
        print(X)
        exit(0)
    arr = list(map(int, input().split(" ")))
    if X not in arr:
        print(X)

    arr.sort()
    for i in range(len(arr)):
        if arr[i] >= X:
            diff = 1
            while True:
                if X - diff not in arr:
                    print(X-diff)
                    exit(0)
                if X + diff not in arr:
                    print(X+diff)
                    exit(0)
                diff +=1


if __name__ == '__main__':
    main()


Fixed submission:
import sys

input = sys.stdin.readline


def main():
    X, N = list(map(int, input().split(" ")))
    if N == 0:
        print(X)
        exit(0)
    arr = list(map(int, input().split(" ")))
    if X not in arr:
        print(X)
        exit(0)

    arr.sort()
    for i in range(len(arr)):
        if arr[i] >= X:
            diff = 1
            while True:
                if X - diff not in arr:
                    print(X - diff)
                    exit(0)
                if X + diff not in arr:
                    print(X + diff)
                    exit(0)
                diff += 1


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
A =list(map(int, input().split(" ")))

ret = 1
for a in A:
    ret *= a

if len(str(ret)) >= 19 and ret != 10**18:
    print(-1)
else:
    print(ret)


Fixed submission:
import numpy as np
N = int(input())
A =list(map(int, input().split(" ")))

if 0 in A:
    print(0)
    exit(0)
    
ret = 1
for a in A:
    ret *= a
    if len(str(ret)) >= 19 and ret != 10 ** 18:
        print(-1)
        exit(0)
    

if len(str(ret)) >= 19 and ret != 10**18:
    print(-1)
else:
    print(ret)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A =list(map(np.float128, input().split(" ")))
ret = np.prod(A)
ret = int(ret)

if len(str(ret)) >= 19 and ret != 10**18:
    print(-1)
else:
    print(ret)


Fixed submission:
import numpy as np
N = int(input())
A =list(map(int, input().split(" ")))

if 0 in A:
    print(0)
    exit(0)
    
ret = 1
for a in A:
    ret *= a
    if len(str(ret)) >= 19 and ret != 10 ** 18:
        print(-1)
        exit(0)
    

if len(str(ret)) >= 19 and ret != 10**18:
    print(-1)
else:
    print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
import os
from collections import defaultdict
N = int(input())
A = list(map(int, input().split(" ")))

pow2 = defaultdict(int)

ret = 0
lim = []
for i in range(N+1):
    pow2[i] = 2**i


for i in range(N+1):
    if i == 0:
        r = 2**i - A[i]
    else:
        r = 2*lim[i-1] - A[i]
    if r < 0:
        print(-1)
        exit(0)
    lim.append(r)

for d in reversed(range(N+1)):
    if A[d] > pow2[d]:
        print(-1)
        exit(0)
    if d == N:
        n = min(A[d], pow2[d])
    else:
        n = min(A[d] + min(n, lim[d]), pow2[d])
    ret +=n

print(ret)

Fixed submission:
import os
from collections import defaultdict

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

pow2 = defaultdict(int)

ret = 0
lim = [0] * (N + 1)
# for i in range(N + 1):
#     pow2[i] = 2 ** i

for i in range(N + 1):
    if i == 0:
        r = 1 - A[i]
    else:
        r = 2 * lim[i - 1] - A[i]
    if r < 0:
        print(-1)
        exit(0)
    lim[i] = r

for d in reversed(range(N + 1)):
    # if A[d] > pow2[d]:
    #     print(-1)
    #     exit(0)
    if d == N:
        #n = min(A[d], pow2[d])
        n = A[d]
    else:
        #n = min(A[d] + min(n, lim[d]), pow2[d])
        n = A[d] + min(n, lim[d])
    ret += n

print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
import os
N = int(input())
A = list(map(int, input().split(" ")))

ret = 0
lim = [0] * (N+1)
for i in range(len(lim)):
    if i == 0:
        lim[i] = 2**i - A[i]
    else:
        lim[i] = 2*lim[i-1] - A[i]
    if lim[i] < 0:
        print(-1)
        exit(0)

for d in reversed(range(N+1)):
    if A[d] > 2**d:
        print(-1)
        exit(0)
    if d == N:
        n = min(A[d], 2**d)
    else:
        n = min(A[d] + min(n, lim[d]), 2**d)
    ret +=n
# ret = 0
# for d in range(N+1):
#     if d == 0:
#         n = 2**d - A[d]
#     else:
#         n = 2*n - A[d]
#
#     if n<=0:
#         print(-1)
#         exit(0)
#     ret += n


print(ret)

Fixed submission:
import os
from collections import defaultdict

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

pow2 = defaultdict(int)

ret = 0
lim = [0] * (N + 1)
# for i in range(N + 1):
#     pow2[i] = 2 ** i

for i in range(N + 1):
    if i == 0:
        r = 1 - A[i]
    else:
        r = 2 * lim[i - 1] - A[i]
    if r < 0:
        print(-1)
        exit(0)
    lim[i] = r

for d in reversed(range(N + 1)):
    # if A[d] > pow2[d]:
    #     print(-1)
    #     exit(0)
    if d == N:
        #n = min(A[d], pow2[d])
        n = A[d]
    else:
        #n = min(A[d] + min(n, lim[d]), pow2[d])
        n = A[d] + min(n, lim[d])
    ret += n

print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
import math
A, B, N = list(map(int, input().split(" ")))

def tgt(A,B,d):
    return math.floor(A * d / B) - A * math.floor(d/B)

if N >= B-1:
    d_max = B-1
else: # N< B-1
    d_max = N

ret = 0
for d in range (d_max+1):
    tmp = tgt(A,B,d)
    if ret <= tmp:
        ret = tmp

print(ret)





Fixed submission:
import math
A, B, N = list(map(int, input().split(" ")))

def tgt(A,B,d):
    return math.floor(A * d / B)

if N >= B-1:
    d_max = B-1
else: # N< B-1
    d_max = N

ret = tgt(A,B,d_max)

print(ret)
Buggy python submission (verdict: Runtime Error):
s = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".split(', ')
k = int(input())
print(int(s[k]))


Fixed submission:
s = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'.split(', ')
k = int(input())
print(int(s[k-1]))

Buggy python submission (verdict: Runtime Error):
s = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".split(', ')
k = int(input())
print(s[k])

Fixed submission:
s = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'.split(', ')
k = int(input())
print(int(s[k-1]))
Buggy python submission (verdict: Runtime Error):
a,b=map(float,input().split())
b=b.replace(".","")
print(int(a*b/100))

Fixed submission:
a,b=input().split()
a=int(a)
b=int(b.replace(".",""))
print(a*b//100)

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(int(a*b))

Fixed submission:
a,b=input().split()
a=int(a)
b=int(b.replace(".",""))
print(a*b//100)
Buggy python submission (verdict: Runtime Error):
N=int(input())
count=0
pn=[2]
for L in range(3,N):
    chk=True
    for L2 in pn:
        if L%L2==0:chk=False
    if chk==True:pn.append(L)
ph=[1]*len(pn)
i=0
while N!=1:
    if N%(pn[i]**ph[i])==0:
        count+=1
        N//=(pn[i]**ph[i])
        ph[i]+=1
    else:i+=1
print(count)

Fixed submission:
from collections import Counter
def factorization(n):
    a=[]
    for i in range(2,int(n**.5)+1):
        while n%i==0:
            n//=i
            a.append(i)
    if n!=1:
        a.append(n)
    return a
n=int(input())
A=factorization(n)
B=Counter(A)
count=0
for key,value in B.items():
    for i in range(1,value+1):
        if n%(key**i)==0:
            count+=1
            n//=(key**i)
        else:break
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
while True:
    if N%K==0:
        print(0)
        break
    elif N<K:
        if N<K/2:
            print(N)
            break
        else:
            print(K-N)
            break
    else:
        N=abs(N-K)

Fixed submission:
N,K=map(int,input().split())
while True:
    if N%K==0:
        print(0)
        break
    elif N<K:
        if N<K/2:
            print(N)
            break
        else:
            print(K-N)
            break
    else:
        N=N%K
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from math import factorial
N=int(input())
A=list(map(int,input().split()))
B=Counter(A)
count=0
def combination(x,y):
    return factorial(x) // (factorial(x - y) * factorial(y))
for key,b in B.items():
    if b>=2:
        count+=combination(b,2)
for a in A:
    ans=count
    if B[a]==2:
        ans-=1
    elif B[a]>=3:
        ans+=combination(B[a]-1,2)-combination(B[a],2)
    print(ans)


Fixed submission:
from collections import Counter
from math import factorial
N=int(input())
A=list(map(int,input().split()))
B=Counter(A)
count=0
def combination(x,y):
    return factorial(x) // (factorial(x - y) * factorial(y))
for key,b in B.items():
    if b>=2:
        count+=combination(b,2)
for a in A:
    ans=count
    ans-=B[a]-1
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from math import factorial
N=int(input())
A=list(map(int,input().split()))
B=Counter(A)
for a in A:
    count=0
    for key,b in B.items():
        if b >= 2 and a!=key:
            count += factorial(b) // (factorial(b - 2) * factorial(2))
        elif b>=3 and a==key:
            b-=1
            count += factorial(b) // (factorial(b - 2) * factorial(2))
    print(count)


Fixed submission:
from collections import Counter
from math import factorial
N=int(input())
A=list(map(int,input().split()))
B=Counter(A)
count=0
def combination(x,y):
    return factorial(x) // (factorial(x - y) * factorial(y))
for key,b in B.items():
    if b>=2:
        count+=combination(b,2)
for a in A:
    ans=count
    ans-=B[a]-1
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from math import factorial
N=int(input())
A=list(map(int,input().split()))
for i in range(N):
    B=Counter(A[:i]+A[i+1:])
    count=0
    for b in B.values():
        if b >= 2:
            count+=factorial(b)//(factorial(b-2)*factorial(2))
    print(count)


Fixed submission:
from collections import Counter
from math import factorial
N=int(input())
A=list(map(int,input().split()))
B=Counter(A)
count=0
def combination(x,y):
    return factorial(x) // (factorial(x - y) * factorial(y))
for key,b in B.items():
    if b>=2:
        count+=combination(b,2)
for a in A:
    ans=count
    ans-=B[a]-1
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from math import factorial
N=int(input())
A=list(map(int,input().split()))
for i in range(N):
    B=Counter(A[:i]+A[i+1:])
    count=0
    for b in B.values():
        if b >= 2:
            count+=factorial(b)//(factorial(b-2)*factorial(2))
    print(count)


Fixed submission:
from collections import Counter
from math import factorial
N=int(input())
A=list(map(int,input().split()))
B=Counter(A)
count=0
def combination(x,y):
    return factorial(x) // (factorial(x - y) * factorial(y))
for key,b in B.items():
    if b>=2:
        count+=combination(b,2)
for a in A:
    ans=count
    ans-=B[a]-1
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
P=list(map(int,input().split()))
maximum=0
num=0
for i in range(K-1,N):
    if maximum<sum(P[i-(K-1):i+1]):
        maximum=sum(P[i-(K-1):i+1])
        num=i
print(sum([1+(p-1)*0.5 for p in P[num-(K-1):num+1]]))


Fixed submission:
N,K=map(int,input().split())
P=list(map(int,input().split()))
total=sum(P[:K])
maximum=sum(P[:K])
num=0
for i in range(N-K):
    m=total-P[i]+P[i+K]
    if m>=maximum:
        num=i+1
        maximum=m
    total=m
print(sum([1+(p-1)*0.5 for p in P[num:num+K]]))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
P=list(map(int,input().split()))
count=0
for i in range(N):
    if P[i]==min(P[:i+1]):
        count+=1
print(count)


Fixed submission:
N=int(input())
P=list(map(int,input().split()))
count=0
minimum=max(P)
for i in range(N):
    if P[i]<=minimum:
        count+=1
        minimum=P[i]
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
P=list(map(int,input().split()))
count=0
for i in range(N):
    if P[i]==min(P[:i+1]):
        count+=1
print(count)


Fixed submission:
N=int(input())
P=list(map(int,input().split()))
count=0
minimum=max(P)
for i in range(N):
    if P[i]<=minimum:
        count+=1
        minimum=P[i]
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=sorted(list(map(int,input().split())))
cnt=0
for i in range(N-1):
    l=A[i]
    for j in range(i+1,N):
        m=A[j]
        for a in A[:i]:
            if a<l+m and l<a+m and m<a+l:
                cnt+=1
print(cnt)

Fixed submission:
from bisect import bisect_left
N=int(input())
A=sorted(list(map(int,input().split())))
cnt=0
for i in range(N-1):
    for j in range(i+1,N):
        a=bisect_left(A,A[i]+A[j])
        if j<a:
            cnt+=a-j-1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
N=int(input())
A=list(map(int,input().split()))
cnt=0
for a in combinations(A,3):
    l=a[0]
    m=a[1]
    n=a[2]
    if l<m+n and m<l+n and n<l+m:
        cnt+=1
print(cnt)

Fixed submission:
from bisect import bisect_left
N=int(input())
A=sorted(list(map(int,input().split())))
cnt=0
for i in range(N-1):
    for j in range(i+1,N):
        a=bisect_left(A,A[i]+A[j])
        if j<a:
            cnt+=a-j-1
print(cnt)
Buggy python submission (verdict: Runtime Error):
S=input()
K=int(input())
flag=False
if S[0]==S[-1]:
    flag=True
cnt=1
A=[]
for i in range(1,len(S)):
    if S[i-1]==S[i]:
        cnt+=1
    else:
        A.append(cnt)
        cnt=1
if cnt>=2:
    A.append(cnt)
ans=0
for a in A:
    ans+=a//2
if flag:
    ans=(ans*K)+((A[0]+A[-1])//2-(A[0]//2+A[-1]//2))*(K-1)
    print(ans)
else:
    ans*=K
    print(ans)

Fixed submission:
t=input()
s=list(t)
k=int(input())
if s==[s[0]]*len(s):
  print((len(s)*k)//2)
  exit()
b=[1]
for i in range(1,len(s)):
  if s[i-1]==s[i]:b[-1]+=1
  else:b.append(1)
ans=0
for i in b:ans+=i//2*k
if t[0]==t[-1] and (b[0]+b[-1])%2==0:ans+=k-1
print(ans)