Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))

import math
from functools import reduce

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

print (gcd_list(A))


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

import fractions
from functools import reduce

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

print (gcd_list(A))
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
d = b-a

def h(x:int):
    if x == 1:
        return 1
    else:
        return h(x-1)+x

print (h(d)-b)


Fixed submission:
import sys
sys.setrecursionlimit(10 ** 9)

a,b = map(int,input().split())
d = b-a

def h(x:int):
    if x == 1:
        return 1
    else:
        return h(x-1)+x

print (h(d)-b)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
lx = len(x)
lxi = (lx-1)//2
for v in x:
    z = y.copy()
    z.remove(v)
    print (z[lxi])


Fixed submission:
n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
lidx = n//2
sidx = lidx-1
for v in x:
    if v <= y[sidx]:
        print (y[lidx])
    else:
        print (y[sidx])
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k = map(int,input().split())
for i in range(a,b+1):
    if i < a+k or b-k < i:
        print (i)


Fixed submission:
a,b,k = map(int,input().split())
l = []
for i in range(a,min(a+k,b)):
    print (i)
    l.append(i)

for i in range(max(a,b-k+1),b+1):
    if not i in l:
        print (i)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = sorted(list(map(int,input().split())))
c = 0
for i in (set(A)):
    tmp = A.count(i)
    if tmp < i:
        c += tmp
    else:
        c += tmp - i
print (c)


Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int,input().split()))
c = Counter(A)
ans = 0
for k,v in c.items():
    if v < k:
        ans += v
    else:
        ans += v-k
print (ans)
Buggy python submission (verdict: Runtime Error):
print (input().count(1)

Fixed submission:
print (input().count('1'))
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
l = []
for _ in range(m):
    a,b = map(int,input().split())
    l.append([a,b])

# 1から行ける島を列挙する
a = []
for x in l:
    if x[0] == 1:
        a.append(x[1])

# 1から行ける島からNからいける島があったらOK
for y in a:
    for z in l:
        if z[0] == y and z[1] == n:
            print ("POSSIBLE")
            exit ()
print ("IMPOSSIBLE")


Fixed submission:
n,m = map(int,input().split())
l = []
for _ in range(m):
    a,b = map(int,input().split())
    l.append([a,b])

a = []
b = []
for x in l:
    if x[0] == 1:
        a.append(x[1])
    if x[1] == n:
        b.append(x[0])

if set(a) & set(b):
    print ("POSSIBLE")
else:
    print ("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
total = sum(a)
ans = float('inf')
x = 0
for i in range(N-1):
    x += a[i]
    ans = min(abs(total-2*x),ans)
print (ans)


Fixed submission:
a,b = map(int,input().split())
print ("Possible") if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0 else print ("Impossible")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,input().split()))
total = sum(a)
ans = float('inf')
for i in range(1,N):
    ans = min(abs(total-2*sum(a[:i])),ans)
print (ans)


Fixed submission:
N = int(input())
a = list(map(int,input().split()))
total = sum(a)
ans = float('inf')
x = 0
for i in range(N-1):
    x += a[i]
    ans = min(abs(total-2*x),ans)
print (ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,input().split()))
ans = float('inf')
for i in range(1,N):
    x = abs(sum(a[:i])-sum(a[i:]))
    if x < ans:
        ans = x
print (ans)


Fixed submission:
N = int(input())
a = list(map(int,input().split()))
total = sum(a)
ans = float('inf')
x = 0
for i in range(N-1):
    x += a[i]
    ans = min(abs(total-2*x),ans)
print (ans)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
print (a+b) if a+b >= 24 print (a+b-24)


Fixed submission:
a,b = map(int,input().split())
print (a+b) if a+b < 24 else print (a+b-24)
Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
for _ in range(w):
    s = input()
    print (s)
    print (s)

Fixed submission:
h,w = map(int,input().split())
pic = []
for _ in range(h):
    pic.append(input())
for line in pic:
    print (line)
    print (line)
Buggy python submission (verdict: Runtime Error):
[a, b] = read().split().map(int)
print(a + b if b % a == 0 else b - a)


Fixed submission:
[a, b] = map(int, input().split())
print(a + b if b % a == 0 else b - a)
Buggy python submission (verdict: Runtime Error):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

N = int(input())

table = [0] * (N+5)

for i in range(1, N+2):
    for j in range(i, N+2, i):
        table[j] += 1
ans = 0
for i in range(N):
    ans += table[i]

print(ans)

Fixed submission:
N = int(input())

table = [0] * (N+5)

for i in range(1, N+3):
    for j in range(i, N+2, i):
        table[j] += 1
ans = 0
for i in range(N):
    ans += table[i]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
X, K, D = map(int, input().split())

if X == 0:
    print(0 if K % 2 == 0 else D)
elif X < 0:

    while X < 0 and K > 0:
        X += D
        K -= 1

    if K == 0:
        print(abs(X))
        exit()
    print(abs(X) if K % 2 == 0 else abs(X-D))
else:
    while X > 0 and K > 0:
        X -= D
        K -= 1

    if K == 0:
        print(abs(X))
        exit()
    print(abs(X) if K % 2 == 0 else abs(X+D))


Fixed submission:
X, K, D = map(int, input().split())

if X == 0:
    print(0 if K % 2 == 0 else D)
elif X < 0:

    div = abs(X) // D
    tmp = X + D*div

    if div >= K:
        print(abs(X + D*K))
    elif div < K:
        K -= div
        print(abs(tmp) if K % 2 == 0 else abs(tmp+D))    

else:

    div = abs(X) // D
    tmp = X - D*div

    if div >= K:
        print(abs(X - D*K))
    elif div < K:
        K -= div
        print(abs(tmp) if K % 2 == 0 else abs(tmp-D))
Buggy python submission (verdict: Time Limit Exceeded):
R,C,K = map(int, input().split())

maze = [[0 for _ in range(C)] for _ in range(R)]
dp = [[[0 for _ in range(C+1)] for _ in range(R+1)] for _ in range(4)]
for i in range(K):
    r,c,v = map(int, input().split())
    r -=1
    c -= 1
    maze[r][c] = v

for i in range(R):
    for j in range(C):
        
        for k in range(2, -1, -1):
            dp[k+1][i][j] = max(dp[k+1][i][j], dp[k][i][j] + maze[i][j])

        for k in range(4):
            dp[0][i+1][j] = max(dp[0][i+1][j], dp[k][i][j])
            dp[k][i][j+1] = max(dp[k][i][j+1], dp[k][i][j])  

ans = 0

for k in range(4):
    ans = max(ans, dp[k][R-1][C-1])       

print(ans)

Fixed submission:
R,C,K = map(int, input().split())

d = [[0 for _ in range(C+1)] for _ in range(R+1)]
dp = [[[0 for _ in range(C+1)] for _ in range(R+1)] for _ in range(4)]

for i in range(K):
    r, c, v = map(int, input().split())
    d[r-1][c-1] = v
for i in range(R):
    for j in range(C):
        # kが大きい方からやらないとダメ。01ナップサックと同じ考え方。書き換えられた値を見ないように。
        for k in range(2, -1, -1):
            # 拾う遷移。d[i][j]を取るかどうかという判定
            dp[k+1][i][j] = max(dp[k+1][i][j], dp[k][i][j] + d[i][j])
        for k in range(4):
            dp[0][i+1][j] = max(dp[0][i+1][j], dp[k][i][j])
            dp[k][i][j+1] = max(dp[k][i][j+1], dp[k][i][j])
ans = 0

for k in range(4):
    ans = max(ans, dp[k][R-1][C-1])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
R,C,K = map(int, input().split())

d = [[0 for _ in range(C+1)] for _ in range(R+1)]
dp = [[[0 for _ in range(4)] for _ in range(C+1)] for _ in range(R+1)]

for i in range(K):
    r, c, v = map(int, input().split())
    d[r-1][c-1] = v
for i in range(R):
    for j in range(C):
        # kが大きい方からやらないとダメ。01ナップサックと同じ考え方。書き換えられた値を見ないように。
        for k in range(2, -1, -1):
            # 拾う遷移。d[i][j]を取るかどうかという判定
            dp[i][j][k+1] = max(dp[i][j][k+1], dp[i][j][k] + d[i][j])
        for k in range(4):
            dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k])
            dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k])
ans = 0

for k in range(4):
    ans = max(ans, dp[R-1][C-1][k])
print(ans)    

Fixed submission:
R,C,K = map(int, input().split())

d = [[0 for _ in range(C+1)] for _ in range(R+1)]
dp = [[[0 for _ in range(C+1)] for _ in range(R+1)] for _ in range(4)]

for i in range(K):
    r, c, v = map(int, input().split())
    d[r-1][c-1] = v
for i in range(R):
    for j in range(C):
        # kが大きい方からやらないとダメ。01ナップサックと同じ考え方。書き換えられた値を見ないように。
        for k in range(2, -1, -1):
            # 拾う遷移。d[i][j]を取るかどうかという判定
            dp[k+1][i][j] = max(dp[k+1][i][j], dp[k][i][j] + d[i][j])
        for k in range(4):
            dp[0][i+1][j] = max(dp[0][i+1][j], dp[k][i][j])
            dp[k][i][j+1] = max(dp[k][i][j+1], dp[k][i][j])
ans = 0

for k in range(4):
    ans = max(ans, dp[k][R-1][C-1])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = lambda: sys.stdin.readline().rstrip()

K = int(input())

if K % 2 == 0:
    print(-1)
    exit()

tmp = 7
i = 1

while True:
    if tmp % K == 0:
        print(i)
        exit()
    tmp = tmp * 10 + 7
    i += 1   

Fixed submission:
K = int(input())

seen = set()

extra = 7 % K
i = 1

while extra not in seen:

    if extra == 0:
        print(i)
        exit()
    
    seen.add(extra)
    extra = (extra * 10 + 7) % K
    i += 1

print(-1)
Buggy python submission (verdict: Runtime Error):
import sys
input = lambda: sys.stdin.readline().rstrip()

N = int(input())
A = list(map(int, input().split()))
A = [0] + A

ans = 0
for i in range(1, len(A)+1):
    if i % 2 == 1 and A[i] % 2 == 1:
        ans += 1
print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A = [0] + A

ans = 0
for i in range(1, len(A)):
    if i % 2 == 1 and A[i] % 2 == 1:
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = lambda: sys.stdin.readline().rstrip()

N, M, K = map(int, input().split())

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

total = 0

stack = [(0, 0, 0, 0, 0)]
res = 0
flg = 0
while stack:
    av, ai, bv, bi, ans = stack.pop()
    if av + bv > K:
        res = max(res, ans-1)
        flg = 1
        continue
    if ai <= len(A) - 1:
        stack.append((av+A[ai], ai+1, bv, bi, ans+1))
        # print((av+A[ai], ai+1, bv, bi, ans+1))
    if bi <= len(B) - 1:
        stack.append((av, ai, bv+B[bi], bi+1, ans+1))
        # print((av+A[ai], ai+1, bv, bi, ans+1))

if flg:
    print(res)
else:
    print(ans)    


Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip()

N, M, K = map(int, input().split())

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

a = [0] + A
b = [0] + B

for i in range(len(a)-1):
    a[i+1] += a[i]

for i in range(len(b)-1):
    b[i+1] += b[i]

ans = 0
j = M

for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = lambda: sys.stdin.readline().rstrip()

N = int(input())

div = [0] * (N+1)

for i in range(1, N+1):
    for j in range(i, N+1, i):
        div[j] += 1

ans = 0
for i in range(1, N+1):
    ans += i * div[i]
print(ans)    


Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip()

N = int(input())

ans = 0
for i in range(1, N+1):
    ans += N//i * (2*i + (N//i-1)*i) // 2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = lambda: sys.stdin.readline().rstrip()

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

ans = 1
for num in A:
    ans *= num

print(ans if ans <= 10 ** 18 else -1)

Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip()

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

if 0 in A:
    print(0)
    exit()
    
upto = 10 ** 18
ans = 1
for num in A:
    ans *= num
    if ans > upto:
        print("-1")
        exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
input = lambda: sys.stdin.readline().rstrip()

N, K = map(int, input().split())

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


visited = set()
visited.add(1)
lst = [1, ]

now = 1
for i in range(K):
    now = A[now-1]
    if now in visited:
        last = K - i
        loop_point = now
        break
    visited.add(now)
    lst.append(now)

for i in range(len(lst)):
    if lst[i] == loop_point:
        inter = i
        loop = lst[i:]
        flg = 1

if not flg:
    print(lst[-1])
    exit()        

last = (last-1) % len(loop)
print(loop[last])

Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip()

N, K = map(int, input().split())

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


visited = set()
visited.add(1)
lst = [1, ]

now = 1
flg = 0
for i in range(K):
    now = A[now-1]
    if now in visited:
        last = K - i
        loop_point = now
        flg = 1
        break
    visited.add(now)
    lst.append(now)
if not flg:
    print(lst[-1])
    exit()    

for i in range(len(lst)):
    if lst[i] == loop_point:
        inter = i
        loop = lst[i:]

last = (last-1) % len(loop)
print(loop[last])
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = list(map(int, input().split()))

ans = 0

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

ans = sum(num_array[0:K])    
for i in range(1, N-K+1):
    temp = sum(num_array[i:i+K])
    if temp > ans:
        ans = sum(num_array[i:i+K])

print(ans)

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

ans = 0

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

ans = sum(num_array[0:K])
temp = ans
for i in range(1, N-K+1):
    j = i+K-1
    temp = temp - num_array[i-1] + num_array[j]
    if temp > ans:
        ans = temp

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

def lcm_base(x, y):
    mod = 10**9 + 7
    return (x * y) // fractions.gcd(x, y) 

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

N = int(input())

mod = 10**9 + 7

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

num = lcm_list(A)

ans = 0
for i in range(N):
    ans += num // A[i]
    ans %= mod
print(ans)  

Fixed submission:
def gcd(a, b):
    while b!= 0:
        a,b = b, a%b
    return a
def lcm(a,b):
    return a*b //(gcd(a, b))

N = int(input())
A = list(map(int, input().split()))
a_lcm = A[0]

mod = 10 ** 9 + 7

for i in range(1,N):
    a_lcm = lcm(a_lcm, A[i])

ans = 0
for i in range(N):
    ans += a_lcm*pow(A[i], mod-2, mod)
print(ans%mod)

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

def lcm_base(x, y):
    mod = 10**9 + 7
    return (x * y) // fractions.gcd(x, y) 

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

N = int(input())

mod = 10**9 + 7

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

num = lcm_list(A)

ans = 0
for i in range(N):
    ans += num // A[i]
    ans %= mod
print(ans)  

Fixed submission:
def gcd(a, b):
    while b!= 0:
        a,b = b, a%b
    return a
def lcm(a,b):
    return a*b //(gcd(a, b))

N = int(input())
A = list(map(int, input().split()))
a_lcm = A[0]

mod = 10 ** 9 + 7

for i in range(1,N):
    a_lcm = lcm(a_lcm, A[i])

ans = 0
for i in range(N):
    ans += a_lcm*pow(A[i], mod-2, mod)
print(ans%mod)
Buggy python submission (verdict: Runtime Error):
N, K, S = map(int, input().split())

N = [1] * N

if S % 2 == 0:
    for i in range(K+1):
        N[i] = S // 2
else:
    for i in range(K):
        N[i] = S

print(*N)

Fixed submission:
N, K, S = map(int, input().split())

if S != 10 **9:
    N = [S+1] * N    
else:
    N = [1] * N

for i in range(K):
        N[i] = S

print(*N)

Buggy python submission (verdict: Runtime Error):
N, K, S = map(int, input().split())

array = [0] * N
if S % 2 == 0:
    for i in range(K+1):
        array[i] = S//2
    print(*array)
else:
    for i in range(0, K, 2):
        array[i] = (S-1) //2
        array[i+1] = (S+1)  // 2
    print(*array)

Fixed submission:
N, K, S = map(int, input().split())

if S != 10 **9:
    N = [S+1] * N    
else:
    N = [1] * N

for i in range(K):
        N[i] = S

print(*N)

Buggy python submission (verdict: Runtime Error):
N, K, S = map(int, input().split())

array = [0] * N
if S % 2 == 0:
    for i in range(K+1):
        array[i] = S//2
    print(*array)
else:
    for i in range(0, K+1, 2):
        array[i] = (S-1) //2
        array[i+1] = (S+1)  // 2
    print(*array)

Fixed submission:
N, K, S = map(int, input().split())

if S != 10 **9:
    N = [S+1] * N    
else:
    N = [1] * N

for i in range(K):
        N[i] = S

print(*N)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

p = []
S = []

for i in range(M):
    p1, s1 = input().split()

    p.append(int(p1))
    S.append(s1)
AC = 0
WA = 0
list = []

for i in range(M):
    if S[i] == "AC" and p[i] not in list:
        AC += 1
        list.append(p[i])
        for j in range(i):
            if p[j] == p[i]:
                WA += 1
print(AC, WA)

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

ac = [0] * N
wa = [0] * N

for i in range(M):
    p,s = input().split()
    p = int(p)
    p -= 1
    if ac[p]:
        continue
    if s == 'AC': 
        ac[p] = 1
    else:
        wa[p] += 1
AC = sum(ac)
WA = 0
for i in range(N):
    if ac[i]:
        WA += wa[i]
print(AC, WA)

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

p = []
S = []

for i in range(M):
    p1, s1 = input().split()

    p.append(int(p1))
    S.append(s1)
AC = 0
WA = 0
list = []

for i in range(M):
    if S[i] == "AC" and p[i] not in list:
        AC += 1
        list.append(p[i])
        for j in range(i):
            if p[j] == p[i]:
                WA += 1
print(AC, WA)

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

ac = [0] * N
wa = [0] * N

for i in range(M):
    p,s = input().split()
    p = int(p)
    p -= 1
    if ac[p]:
        continue
    if s == 'AC': 
        ac[p] = 1
    else:
        wa[p] += 1
AC = sum(ac)
WA = 0
for i in range(N):
    if ac[i]:
        WA += wa[i]
print(AC, WA)
Buggy python submission (verdict: Runtime Error):
import fractions
from functools import reduce

N, M = map(int, input().split())

a = list(map(int, input().split()))

a_set = list(set(a))

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

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

lcm = lcm_list(a_set)

sum = lcm / 2
ans = 0
while sum <= M:
    if sum > M:
        break
    sum += lcm
    ans += 1
print(ans)

Fixed submission:
import fractions
from functools import reduce

N, M = map(int, input().split())
a = list(map(int, input().split()))

def f(x):
    res = 0
    while x % 2 == 0:
        x //= 2
        res += 1
    return res  

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

for i in range(len(a)):
    if a[i] % 2 == 1:
        print(0)
        exit()
    a[i] //= 2

t = f(a[0])
for i in range(len(a)):
    if f(a[i]) != t:
        print(0)
        exit()
    a[i] >>= t #a[i] //= 2 ** t
M >>= t

l = 1
for i in range(N):
    l = lcm(l, a[i])
    if l > M:
        print(0)
        exit()

M //= l
ans = (M+1) // 2
print(ans)

Buggy python submission (verdict: Runtime Error):
import fractions
from functools import reduce

N, M = map(int, input().split())

a = list(map(int, input().split()))

a_set = list(set(a))

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

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

lcm = lcm_list(a_set)

sum = lcm / 2
ans = 0
while sum <= M:
    if sum > M:
        break
    sum += lcm
    ans += 1
print(ans)

Fixed submission:
import fractions
from functools import reduce

N, M = map(int, input().split())
a = list(map(int, input().split()))

def f(x):
    res = 0
    while x % 2 == 0:
        x //= 2
        res += 1
    return res  

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

for i in range(len(a)):
    if a[i] % 2 == 1:
        print(0)
        exit()
    a[i] //= 2

t = f(a[0])
for i in range(len(a)):
    if f(a[i]) != t:
        print(0)
        exit()
    a[i] >>= t #a[i] //= 2 ** t
M >>= t

l = 1
for i in range(N):
    l = lcm(l, a[i])
    if l > M:
        print(0)
        exit()

M //= l
ans = (M+1) // 2
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

N,K = map(int, input().split())
R,S,P = map(int, input().split())
T = input()

index = defaultdict(list)

for i, t in enumerate(T):
    index[t].append(i)


len_r = len(index['r'])
len_s = len(index['s'])
len_p = len(index['p'])

tmp = 0
flag = True
for i in index['r']:    
    if tmp % K == 0 and flag == True:
        len_r -= 1
        flag = False
        tmp = i
        continue
    if tmp % K == 0 and flag == False:    
        flag = True
        tmp = i
        continue
    tmp += i -tmp

tmp = 0
flag = True
for j in index['s']:    
    if tmp % K == 0 and flag == True:
        len_s -= 1
        flag = False
        tmp = js
        continue
    if tmp % K == 0 and flag == False:    
        flag = True
        tmp = j
        continue
    tmp += j - tmp

tmp = 0
flag = True
for k in index['p']:    
    if tmp % K == 0 and flag == True:
        len_p -= 1
        flag = False
        tmp = k
        continue
    if tmp % K == 0 and flag == False:    
        flag = True
        tmp = k
        continue
    tmp += k-tmp

ans = P * len_r + R * len_s + S * len_p
print(ans)

Fixed submission:
N,K = map(int, input().split())
R,S,P = map(int, input().split())
T = input()

ans = ""
score = 0

for i, t in enumerate(T):
    if t == 'r':
        if i >= K and "p" == ans[-K]:
            ans += " "
        else:
            ans += 'p'
            score += P    

    elif t == 's':
        if i >= K and "r" == ans[-K]:
            ans += " "
        else:
            ans += 'r'
            score += R 
    else:
        if i >= K and 's' == ans[-K]:
            ans += " "
        else:
            ans += 's'
            score += S
print(score)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = list(map(int, input().split()))

ans = 0
for i in range(N-1):
    tmp = 0
    for j in range(i, N-1):
        if H[j] >= H[j+1]:
            tmp += 1
        else: 
            break
    ans = max(ans, tmp)
print(ans)    

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

ans = 0
cnt = 0

for i in range(N-1):
    if H[i] >= H[i+1]:
        cnt += 1
    else:
        if ans < cnt:
            ans = cnt
        cnt = 0    
if ans < cnt:
    ans = cnt
print(ans)

Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int N;

int main() {
  cin >> N;
  int H[N];
  for (int i = 0; i < N; i++) cin >> H[i];

  int ans = 0;

  for (int i = 0; i < N-1; i++) {
    int tmp = 0;
    for (int j = i; j < N-1;) {
      if (H[j] >= H[j+1]) tmp++;
      else break;
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}

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

ans = 0
cnt = 0

for i in range(N-1):
    if H[i] >= H[i+1]:
        cnt += 1
    else:
        if ans < cnt:
            ans = cnt
        cnt = 0    
if ans < cnt:
    ans = cnt
print(ans)

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

ans = 0
for i in range(N-1):
    tmp = 0
    for j in range(i, N-1):
        if H[j] >= H[j+1]:
            tmp += 1
        else: 
            break    
    ans = max(ans, tmp)
print(ans)

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

ans = 0
cnt = 0

for i in range(N-1):
    if H[i] >= H[i+1]:
        cnt += 1
    else:
        if ans < cnt:
            ans = cnt
        cnt = 0    
if ans < cnt:
    ans = cnt
print(ans)