Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
x = input()
ans = len(x)


def do(i, j):
    global ans
    if x[i] == 'S' and x[j] == 'T':
        ans -= 2
        if i > 0 and j < len(x) - 1:
            do(i-1, j+1)
    if j - i == 1 and j < len(x) - 1:
        do(i+1, j+1)


do(0, 1)
print(ans)


Fixed submission:
X = input()

count = 0
count_s = 0
i = 0
while i < len(X):
    if i < len(X) - 1 and X[i] == 'S' and X[i+1] == 'T':
        count += 1
        i += 1
    elif X[i] == 'S':
        count_s += 1
    elif X[i] == 'T' and count_s > 0:
        count_s -= 1
        count += 1
    else:
        count_s = 0
    i += 1

count = min(count, 10 ** 10000)
print(len(X) - count * 2)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))

current = 1
path = [1]

while K > 0:
    if A[current - 1] in path:
        loop = path[path.index(A[current - 1]):]
        path += [loop[(K-1) % len(loop)]]
        break

    path += [A[current - 1]]
    current = A[current - 1]
    K -= 1

print(path[-1])


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

current = 1
path = [1]
already = [False] * len(A)

while K > 0:
    if already[current - 1]:
        loop = path[path.index(A[current - 1]):]
        current = loop[(K - 1) % len(loop)]
        break

    path += [A[current - 1]]
    already[current - 1] = True
    current = A[current - 1]
    K -= 1

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

AB = []

for i in range(M):
    AB += [list(map(int, input().split()))]

good = 0

for i in range(N):
    ng = False

    for a, b in AB:
        if i + 1 == a and H[i] <= H[b - 1]:
            ng = True
            break
        if i + 1 == b and H[i] <= H[a - 1]:
            ng = True
            break

    if not ng:
        good += 1

print(good)


Fixed submission:
N, M = map(int, input().split())
H = list(map(int, input().split()))
good = [True] * N

for i in range(M):
    a, b = map(int, input().split())
    a = a - 1
    b = b - 1
    if not H[a] > H[b]:
        good[a] = False
    if not H[a] < H[b]:
        good[b] = False

print(sum([1 if good[i] else 0 for i in range(N)]))
Buggy python submission (verdict: Runtime Error):
K = input()
A, B = map(int, input().split())

result = False
for i in range(A, B + 1):
    if (i % K) == 0:
        result = True
print("OK" if result else "NG")

Fixed submission:
K = int(input())
A, B = map(int, input().split())

result = False
for i in range(A, B + 1):
    if (i % K) == 0:
        result = True
print("OK" if result else "NG")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from sympy import *

x, y, z = symbols('x y z')
N, price = list(map(int, input().split()))

if N * 10000 < price or N * 1000 > price:
    li = map(str, [-1] * 3)
else:
    temp = 10000 * N
    x, y = 0, 0

    for i in range(N):
        if x < 0:
            break;
        if temp == price:
            break;
        elif temp > price:
            y += 1
            temp -= 9000
        else:
            x += 1
            y -= 1
            temp += 4000
    li = map(str, [N - x - y, x, y]) if y >= 0 else map(str, [-1] * 3)

print(" ".join(li))


Fixed submission:
# -*- coding: utf-8 -*-
N, price = list(map(int, input().split()))

li = map(str, [-1] * 3)

if N * 10000 >= price and N * 1000 <= price:
    x = price // 10000
    for i in range(x + 1):
        y = (price - i * 10000) // 5000
        for j in range(y + 1):
            if N >= i + j and price == i * 10000 + j * 5000 + (N - i - j) * 1000:
                li = map(str, [i, j, N - i - j])

print(" ".join(li))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
n = int(input())
sta = []

for i in range(n - 1):
    c, s, f = map(int, input().split())
    sta += [dict(c = c, s = s, f = f)]

for i in range(n):
    time = 0
    while i < n - 1:
        n_time = sta[i]['s']
        while time > n_time:
            n_time += sta[i]['f']
        time = n_time + sta[i]['c']
        i += 1
    print(str(time))

Fixed submission:
# -*- coding: utf-8 -*-
import math

n = int(input())
sta = []

for i in range(n - 1):
    c, s, f = map(int, input().split())
    sta += [dict(c = c, s = s, f = f)]

for i in range(n):
    time = 0
    while i < n - 1:
        x = math.ceil((time - sta[i]['s']) / sta[i]['f']) if time > sta[i]['s'] else 0
        time = sta[i]['s'] + sta[i]['f'] * x + sta[i]['c']
        i += 1
    print(str(time))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
n = int(input())

stations = []

for i in range(n - 1):
    c, s, f = map(int, input().split())
    stations += [dict(c = c, s = s, f = f)]

for i in range(n - 1):
    time = stations[i]['s'] + stations[i]['c']
    i += 1
    while i < n - 1:
        n_time = stations[i]['s']
        while time > n_time:
            n_time += stations[i]['f']
        time = n_time + stations[i]['c']
        i += 1
    print(str(time))
print(str(0))


Fixed submission:
# -*- coding: utf-8 -*-
import math

n = int(input())
sta = []

for i in range(n - 1):
    c, s, f = map(int, input().split())
    sta += [dict(c = c, s = s, f = f)]

for i in range(n):
    time = 0
    while i < n - 1:
        x = math.ceil((time - sta[i]['s']) / sta[i]['f']) if time > sta[i]['s'] else 0
        time = sta[i]['s'] + sta[i]['f'] * x + sta[i]['c']
        i += 1
    print(str(time))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n = int(input())

alist = list(map(int, input().split()))
result = 0

for i in set(alist):
    if alist.count(i) > i:
        result += alist.count(i) - i
    elif alist.count(i) < i:
        result += alist.count(i)
print(result)


Fixed submission:
from collections import Counter

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

count = 0
for key, value in B.items():
    count += value - key if value >= key else value

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]

l = [0]*n

for i in range(n):
    for j in range(i+1,n):
        if abs(i-j) == a[i]+a[j]:
            l[i] += 1

print(sum(l))

Fixed submission:
from collections import defaultdict
n = int(input())
a = [0] + [int(x) for x in input().split()]

d1 = defaultdict(int)
d2 = defaultdict(int)

for i in range(1,n+1):
    d1[i-a[i]] += 1
    d2[i+a[i]] += 1

ans = 0

for k in d1.keys():
    ans += d1[k]*d2[k]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]

l = [0]*n

for i in range(n):
    for j in range(i+1,n):
        if abs(i-j) == a[i]+a[j]:
            l[i] += 1

print(sum(l))

Fixed submission:
from collections import defaultdict
n = int(input())
a = [0] + [int(x) for x in input().split()]

d1 = defaultdict(int)
d2 = defaultdict(int)

for i in range(1,n+1):
    d1[i-a[i]] += 1
    d2[i+a[i]] += 1

ans = 0

for k in d1.keys():
    ans += d1[k]*d2[k]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,n = [int(x) for x in input().split()]

ans = 0

for x in range(1,n+1):
    if ans > ((a*x//b)-(x//b)*a):
        break
    else:
        ans = max(ans, (a*x//b)-(x//b)*a)

print(ans)

Fixed submission:
a,b,n = [int(x) for x in input().split()]


x = min(n,b-1)
print((a*x//b)-(x//b)*a)
Buggy python submission (verdict: Time Limit Exceeded):
n,x,y = [int(x) for x in input().split()]

for k in range(1, n):
    ans = 0
    for i in range(1,n):
        for j in range(i+1, n+1):
            if min(abs(j-i), abs(x-i)+1+abs(j-y), abs(y-i)+1+abs(j-x)) == k:
                ans += 1
    print(ans)

Fixed submission:
n,x,y = [int(x) for x in input().split()]
d = {x: 0 for x in range(1, n)}
for i in range(1,n):
    for j in range(i+1, n+1):
        d[min(abs(j-i), abs(x-i)+1+abs(j-y), abs(y-i)+1+abs(j-x))] += 1
for v in d.values():
    print(v)
Buggy python submission (verdict: Runtime Error):
A,B,M = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = []
for _ in range(M):
    tmp = [int(x) for x in input().split()]
    c.append(tmp)

ans = min(a)+min(b)
for i in range(M):
    ans = min((a[i-1]+b[i-1]-c[i][2]),ans)

print(ans)

Fixed submission:
A,B,M = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = []
for _ in range(M):
    tmp = [int(x) for x in input().split()]
    c.append(tmp)

ans = min(a)+min(b)
for x in c:
    ans = min((a[x[0]-1]+b[x[1]-1]-x[2]),ans)

print(ans)
Buggy python submission (verdict: Runtime Error):
n,a,b = [int(x) for x in input().split()]

s = "b" * a + "r" * b

ans = (n // (a+b)) * a
ama = n % (a+b)

if a <= ama:
    print(ans + s[:ama].count("b"))
else:
    print(ans + ama)

Fixed submission:
n,a,b = [int(x) for x in input().split()]

ans = (n // (a+b)) * a
ama = n % (a+b)

if a <= ama:
    print(ans + a)
else:
    print(ans + ama)

Buggy python submission (verdict: Runtime Error):
n,a,b = [int(x) for x in input().split()]

s = "b" * a + "r" * b

ans = (n // (a+b)) * a
ama = n % (a+b)

print(ans + s[:ama].count("b"))

Fixed submission:
n,a,b = [int(x) for x in input().split()]

ans = (n // (a+b)) * a
ama = n % (a+b)

if a <= ama:
    print(ans + a)
else:
    print(ans + ama)
Buggy python submission (verdict: Runtime Error):
n,a,b = [int(x) for x in input().split()]

INF = (10**9 + 7)

def f(n):
    if n == 1:
        return 1
    return (f(n-1) * 2) + 1

if n == 2:
    print(0)
else:
    ans = f(n) - f(a) - f(b)
    print(ans % INF)

Fixed submission:
n,a,b = [int(x) for x in input().split()]

INF = (10**9 + 7)

def c(n,r,p):
    r = min(r,n-r)
    numer = 1
    denom = 1
    for i in range(1,r+1):
        numer = numer * (n+1-i) % p
        denom = denom * i % p
    return numer * pow(denom,p-2,p) % p

ans = pow(2,n,INF) - 1 - c(n,a,INF) - c(n,b,INF)

while ans < 0:
    ans += INF
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c = map(int, input().split())

for i in range(c):
    if a >= 1:
        a -= 1
    elif b >= 1:
        b -= 1

print(a, b)

Fixed submission:
a, b, c = map(int, input().split())

if a >= c:
    a = a - c
else:
    c = c - a
    a = 0
    b = b - c
    if b < 0:
        b = 0

print(a, b)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
l = [int(x) for x in input().split()]

ans = 0
for v in itertools.combinations(l, 3):
    if v[0] < v[1] + v[2] and v[1] < v[0]+v[2] and v[2] < v[0]+v[1]:
        ans += 1

print(ans)

Fixed submission:
from bisect import bisect_left
n = int(input())
l = [int(x) for x in input().split()]
l.sort()
x = 0

for i in range(n):
    for j in range(i+1, n):
        a = l[i] + l[j]
        x += max(bisect_left(l,a) - j - 1, 0)
print(x)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

ans = [a.index(x)+1 for x in range(1, n+1)]

print(*ans)

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

l = [[] for x in range(n)]
for i, num in enumerate(a):
    l[num-1] = (int(i) + 1)

print(*l)

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

ans = [str(a.index(x)+1) for x in range(1, n+1)]

print(" ".join(ans))

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

l = [[] for x in range(n)]
for i, num in enumerate(a):
    l[num-1] = (int(i) + 1)

print(*l)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]

ans = [str(a.index(x)+1) for x in range(1, n+1)]

print(" ".join(ans))

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

l = [[] for x in range(n)]
for i, num in enumerate(a):
    l[num-1] = (int(i) + 1)

print(*l)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]

ans = [str(a.index(x)+1) for x in range(1, n+1)]

print(" ".join(ans))

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

l = [[] for x in range(n)]
for i, num in enumerate(a):
    l[num-1] = (int(i) + 1)

print(*l)
Buggy python submission (verdict: Time Limit Exceeded):
a,b = [int(x) for x in input().split()]

def f(a,b):
    l = []
    for i in range(1,min(a,b)+1):
        if a % i == 0 and b % i == 0:
            l.append(i)
    return l

def sosu(n):
    ret = True
    for i in range(2,int((n**0.5)+1)):
        if n % i == 0:
            ret = False
            break
    return ret

l = f(a,b)
ans = 0
for x in l:
    if sosu(x):
        ans += 1

print(ans)

Fixed submission:
a,b = [int(x) for x in input().split()]

def gcd(a,b):
    while b:
        a,b = b, a%b
    return a

d = gcd(a,b)
pf = {}
for i in range(2, int(d**0.5)+1):
    while d%i == 0:
        pf[i] = pf.get(i,0)+1
        d//=i
if d>1:
    pf[d] = 1
P = list(pf.keys())
print(len(P)+1)

Buggy python submission (verdict: Time Limit Exceeded):
a,b = [int(x) for x in input().split()]

def f(a,b):
    l = []
    for i in range(1,min(a,b)+1):
        if a % i == 0 and b % i == 0:
            l.append(i)
    return l

def sosu(n):
    ret = True
    for i in range(2,int((n**0.5)+1)):
        if n % i == 0:
            ret = False
            break
    return ret

l = f(a,b)
ans = 0
for x in l:
    if sosu(x):
        ans += 1

print(ans)

Fixed submission:
a,b = [int(x) for x in input().split()]

def gcd(a,b):
    while b:
        a,b = b, a%b
    return a

d = gcd(a,b)
pf = {}
for i in range(2, int(d**0.5)+1):
    while d%i == 0:
        pf[i] = pf.get(i,0)+1
        d//=i
if d>1:
    pf[d] = 1
P = list(pf.keys())
print(len(P)+1)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

for _ in range(m):
    a.sort()
    a[-1] = int(a[-1] / 2)

print(sum(a))

Fixed submission:
import heapq
n,m = [int(x) for x in input().split()]
a = [int(x)*(-1) for x in input().split()]

heapq.heapify(a)

for _ in range(m):
    tmp_min = heapq.heappop(a)
    heapq.heappush(a, (-1)* (-tmp_min//2))

print(-sum(a))
Buggy python submission (verdict: Runtime Error):
n = int(input())

ans = 0

l = list(range(1,n))
l.insert(0, n)

for i,x in enumerate(l):
    ans += x % (i+1)

print(ans)

Fixed submission:
n = int(input())

print(n * (n-1) // 2)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
n = int(input())
s = ["".join(sorted(list(input()))) for _ in range(n)]
ans = 0
for v in combinations(s, 2):
    if v[0] == v[1]:
        ans += 1

print(ans)

Fixed submission:
n = int(input())
s = []
for _ in range(n):
    s.append(input())


cnt = 0
tmpdic = {}
for i in s:
    tmp = "".join(sorted(i))
    if tmp in tmpdic.keys():
        cnt += tmpdic[tmp]
        tmpdic[tmp] += 1
    else:
        tmpdic[tmp] = 1


print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
n = int(input())
s = [sorted(list(input())) for _ in range(n)]
ans = 0
for v in combinations(s, 2):
    if v[0] == v[1]:
        ans += 1

print(ans)

Fixed submission:
n = int(input())
s = []
for _ in range(n):
    s.append(input())


cnt = 0
tmpdic = {}
for i in s:
    tmp = "".join(sorted(i))
    if tmp in tmpdic.keys():
        cnt += tmpdic[tmp]
        tmpdic[tmp] += 1
    else:
        tmpdic[tmp] = 1


print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for _ in range(n):
    s.append(input())

sorted_s = ["".join(sorted(x)) for x in s]

cnt = 0
for i in range(n):
    cnt += sorted_s[i+1:].count(sorted_s[i])

print(cnt)

Fixed submission:
n = int(input())
s = []
for _ in range(n):
    s.append(input())


cnt = 0
tmpdic = {}
for i in s:
    tmp = "".join(sorted(i))
    if tmp in tmpdic.keys():
        cnt += tmpdic[tmp]
        tmpdic[tmp] += 1
    else:
        tmpdic[tmp] = 1


print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

for i in range(n):
    print(max(a[:i] + a[i+1:]))

Fixed submission:
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

sorted_a = sorted(a)
first = sorted_a[-1]
second = sorted_a[-2]
first_place = a.index(first)
for i in range(n):
    if first == second:
        print(first)
    else:
        if i == first_place:
            print(second)
        else:
            print(first)
Buggy python submission (verdict: Time Limit Exceeded):
l, r = [int(x) for x in input().split()]

ans = 2200
for i in range(l, r):
    if i % 2019 == 0:
        pass
    else:
        for j in range(i+1, r+1):
            if i == j:
                continue
            elif j % 2019 == 0:
                continue
            else:
                tmpans = (i * j) % 2019
            ans = min(ans, tmpans)


print(ans)

Fixed submission:
l, r = [int(x) for x in input().split()]

ans = 2200
for i in range(l, r):
    if i % 2019 == 0:
        ans = 0
        break
    else:
        for j in range(i+1, r+1):
            if i == j:
                continue
            elif j % 2019 == 0:
                ans = 0
                break
            else:
                tmpans = (i * j) % 2019
            ans = min(ans, tmpans)


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
l, r = [int(x) for x in input().split()]

ans = 2200
for i in range(l, r):
    if i % 2019 == 0:
        pass
    else:
        for j in range(l+1, r+1):
            if i == j:
                continue
            elif j % 2019 == 0:
                continue
            else:
                tmpans = (i * j) % 2019
            ans = min(ans, tmpans)


print(ans)

Fixed submission:
l, r = [int(x) for x in input().split()]

ans = 2200
for i in range(l, r):
    if i % 2019 == 0:
        ans = 0
        break
    else:
        for j in range(i+1, r+1):
            if i == j:
                continue
            elif j % 2019 == 0:
                ans = 0
                break
            else:
                tmpans = (i * j) % 2019
            ans = min(ans, tmpans)


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
l, r = [int(x) for x in input().split()]

ans = 2200
for i in range(l, r):
    for j in range(l+1, r+1):
        if i == j:
            continue
        else:
            tmpans = (i * j) % 2019
        ans = min(ans, tmpans)

print(ans)

Fixed submission:
l, r = [int(x) for x in input().split()]

ans = 2200
for i in range(l, r):
    if i % 2019 == 0:
        ans = 0
        break
    else:
        for j in range(i+1, r+1):
            if i == j:
                continue
            elif j % 2019 == 0:
                ans = 0
                break
            else:
                tmpans = (i * j) % 2019
            ans = min(ans, tmpans)


print(ans)
Buggy python submission (verdict: Runtime Error):
w,h,x,y = [int(x) for x in input().split()]

if w % x == 0 and h % y == 0:
    print((w*h)/2, 1)
else:
    print((w*h)/2, 0)

Fixed submission:
X, H, x, y = [int(x) for x in input().split()]

if 2 * x == X and 2 * y == H:
    print((X * H) / 2, 1)
else:
    print((X * H) / 2, 0)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = [int(x) for x in input().split()]
a = [int(input()) for _ in range(m)]

dp = [0]*(n+1)
dp[0] = 1

for i in range(1, n+1):
    dp[i] = (dp[i-1] + dp[i-2]) % (10**9+7)
    if i in a:
        dp[i] = 0

print(dp[n])

Fixed submission:
n, m = [int(x) for x in input().split()]
a = set([int(input()) for _ in range(m)])

dp = [0]*(n+1)
dp[0] = 1

for i in range(1, n+1):
    dp[i] = (dp[i-1] + dp[i-2]) % (10**9+7)
    if i in a:
        dp[i] = 0

print(dp[n])

Buggy python submission (verdict: Time Limit Exceeded):
n, m = [int(x) for x in input().split()]
a = []
for _ in range(m):
    a.append(int(input()))

mod = 1000000007

dp = [0]*(n+1)
dp[0] = 1

for i in range(1, n+1):
    dp[i] = (dp[i-1] + dp[i-2]) % mod
    if i in a:
        dp[i] = 0

print(dp[n])

Fixed submission:
n, m = [int(x) for x in input().split()]
a = set([int(input()) for _ in range(m)])

dp = [0]*(n+1)
dp[0] = 1

for i in range(1, n+1):
    dp[i] = (dp[i-1] + dp[i-2]) % (10**9+7)
    if i in a:
        dp[i] = 0

print(dp[n])

Buggy python submission (verdict: Time Limit Exceeded):
n, m = [int(x) for x in input().split()]
a = []
for _ in range(m):
    a.append(int(input()))

mod = 1000000007

dp = [0]*(n+1)
dp[0] = 1

for i in range(1, n+1):
    dp[i] = (dp[i-1] + dp[i-2]) % mod
    if i in a:
        dp[i] = 0

print(dp[n])

Fixed submission:
n, m = [int(x) for x in input().split()]
a = set([int(input()) for _ in range(m)])

dp = [0]*(n+1)
dp[0] = 1

for i in range(1, n+1):
    dp[i] = (dp[i-1] + dp[i-2]) % (10**9+7)
    if i in a:
        dp[i] = 0

print(dp[n])
Buggy python submission (verdict: Time Limit Exceeded):
n, m = [int(x) for x in input().split()]
lst = []
for _ in range(m):
    l, r = [int(x) for x in input().split()]
    lst.append(set(range(l, r+1)))

uni = lst[0].intersection(*lst[1:])
print(len(uni))

Fixed submission:
n, m = [int(x) for x in input().split()]
l_lst = []
r_lst = []
for _ in range(m):
    l, r = [int(x) for x in input().split()]
    l_lst.append(l)
    r_lst.append(r)

l_max = max(l_lst)
r_min = min(r_lst)

if l_max <= r_min:
    num = r_min - l_max + 1
else:
    num = 0
print(num)
Buggy python submission (verdict: Runtime Error):
n, k = [int(x) for x in input().split()]
s = input()

s[k-1] = s[k-1].lower()

print(s)

Fixed submission:
n, k = [int(x) for x in input().split()]
s = list(input())

s[k-1] = s[k-1].lower()

print(*s ,sep="")
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n = [int(x) for x in input().split()]

ans = 0

for x in range(n//r + 1):
    for y in range(n // g + 1):
        if (n - (r * x + g * y)) % b == 0 and (n - (r*x + g*y)) >= 0:
            ans += 1
print(ans)

Fixed submission:
r,g,b,n = [int(x) for x in input().split()]

ans = 0

for x in range(n//r + 1):
    for y in range(n // g + 1):
        if (n - (r * x + g * y)) % b == 0 and (n - (r*x + g*y)) >= 0:
            ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
import itertools
from functools import reduce

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

n = int(input())
a = [int(x) for x in input().split()]

tmp = 0
for v in itertools.permutations(a, len(a)-1):
    tmp = max(gcd(*v), tmp)

print(tmp)

Fixed submission:
import fractions
import itertools
from functools import reduce

n = int(input())
a = [int(x) for x in input().split()]

l = [0]*(n+1)
r = [0]*(n+1)

for i in range(n):
    l[i+1] = fractions.gcd(l[i], a[i])
    r[n-i-1]= fractions.gcd(r[n-i], a[n-i-1])

ans = 0
for i in range(n):
    ans = max(fractions.gcd(l[i], r[i+1]), ans)

print(ans)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
lst = [a,b,c,d,e]

lst2 = []

for x in lst:
    amari = x % 10
    if amari == 0:
        pass
    else:
        lst2.append(10 - amari)

lst2.remove(max(lst2))
print(sum(lst)+sum(lst2))

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
lst = [a,b,c,d,e]

lst2 = []

for x in lst:
    amari = x % 10
    if amari == 0:
        pass
    else:
        lst2.append(10 - amari)

if not lst2:
    pass
else:
    lst2.remove(max(lst2))
print(sum(lst)+sum(lst2))