Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def city_saver(a, b):
    monster = 0
    for i in range(len(b)):
        monster += min(a[i], b[i])
        if(a[i]<b[i]):
            monster += min(b[i]-a[i], a[i+1])
            a[i+1] -= min(b[i]-a[i], a[i+1])
    return monster

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    print(city_saver(a, b))

if __name__ == "__main__":
    try:
    main()


Fixed submission:
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def city_saver(a, b):
    monster = 0
    for i in range(len(b)):
        monster += min(a[i], b[i])
        if(a[i]<b[i]):
            monster += min(b[i]-a[i], a[i+1])
            a[i+1] -= min(b[i]-a[i], a[i+1])
    return monster

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    print(city_saver(a, b))

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def city_saver(a, b):
    monster = 0
    for i in range(len(b)):
        monster += min(a[i], b[i])
        if(a[i]<b[i]):
            monster += min(b[i]-a[i], a[i+1])
            a[i+1] -= min(b[i]-a[i], a[i+1])
    return monster

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    city_saver(a, b)

if __name__ == "__main__":
    try:
    main()


Fixed submission:
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def city_saver(a, b):
    monster = 0
    for i in range(len(b)):
        monster += min(a[i], b[i])
        if(a[i]<b[i]):
            monster += min(b[i]-a[i], a[i+1])
            a[i+1] -= min(b[i]-a[i], a[i+1])
    return monster

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    print(city_saver(a, b))

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def city_saver(a, b):
    monster = 0
    for i in range(len(b)):
        monster += min(a[i], b[i])
        if(a[i]<b[i]):
            monster += min(b[i]-a[i], a[i+1])
            a[i+1] -= min(b[i]-a[i], a[i+1])
    return monster

def main():
    n = int(input())
    a = map(int, input().split())
    b = map(int, input().split())

if __name__ == "__main__":
    try:
    main()


Fixed submission:
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def city_saver(a, b):
    monster = 0
    for i in range(len(b)):
        monster += min(a[i], b[i])
        if(a[i]<b[i]):
            monster += min(b[i]-a[i], a[i+1])
            a[i+1] -= min(b[i]-a[i], a[i+1])
    return monster

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    print(city_saver(a, b))

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
if S == "Sunny": return "Cloudy"
if S == "Cloudy": return "Rainy"
if S == "Rainy": return "Sunny"

Fixed submission:
S = input()
if S == "Sunny": print("Cloudy")
if S == "Cloudy": print("Rainy")
if S == "Rainy": print("Sunny")

Buggy python submission (verdict: Runtime Error):
cur = input()
if cur == "Sunny":
  print("Cloudy")
else if cur == "Rainy":
  print("Sunny")
else:
  print("Rainy")

Fixed submission:
l = ["Sunny", "Cloudy", "Rainy", 'Sunny']
print(l[l.index(input()) + 1])

Buggy python submission (verdict: Runtime Error):
import sys

def main():
    N = sys.stdin.readline()
    w = ['Sunny', 'Cloudy', 'Rainy']
    i = w.index(N)
    print(w[(i+1)%3])

if __name__=='__main__':
    main()

Fixed submission:
import sys

def main():
    N = sys.stdin.readline().rstrip()
    w = ['Sunny', 'Cloudy', 'Rainy']
    i = w.index(N)
    print(w[(i+1)%3])

if __name__=='__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys

def main():
    N = sys.stdin.readline()
    w = ['Sunny', 'Cloudy', 'Rainy']
    i = w.index(N)
    print(w[(i+1)%3])

if __name__=='__main__':
    main()

Fixed submission:
import sys

def main():
    N = sys.stdin.readline().rstrip()
    w = ['Sunny', 'Cloudy', 'Rainy']
    i = w.index(N)
    print(w[(i+1)%3])

if __name__=='__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys

def main():
    N = sys.stdin.readline()
    w = ['Sunny', 'Cloudy', 'Rainy']
    i = w.index(N)
    print(w[(i+1)%3])

if __name__=='__main__':
    main()

Fixed submission:
import sys

def main():
    N = sys.stdin.readline().rstrip()
    w = ['Sunny', 'Cloudy', 'Rainy']
    i = w.index(N)
    print(w[(i+1)%3])

if __name__=='__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys

def main():
    N = sys.stdin.readline()
    w = ['Sunny', 'Cloudy', 'Rainy', 'Sunny']
    i = w.index(N)
    print(w[i+1])

if __name__=='__main__':
    main()

Fixed submission:
import sys

def main():
    N = sys.stdin.readline().rstrip()
    w = ['Sunny', 'Cloudy', 'Rainy']
    i = w.index(N)
    print(w[(i+1)%3])

if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys, bisect

def main():
    _,M,*A = map(int, open(0).read().split())

    A.sort()
    i = M
    while i > 0:
        a = int(A.pop() / 2)
        i-=1
        while a >= A[-1] and i > 0:
            a = int(a / 2)
            i-=1
        bisect.insort_left(A,a)

    print(sum(A))

if __name__=='__main__':
    main()

Fixed submission:
import sys
from heapq import heappush, heappop

def main():
    _,M,*A = map(int, open(0).read().split())

    A = [-x for x in A] # reverse max to min
    A.sort()

    for _ in range(M):
        a = int(heappop(A) / 2)
        heappush(A, a)
    print(-sum(A))

if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys, bisect

def main():
    _,M,*A = map(int, open(0).read().split())

    A.sort()
    for _ in range(M):
        a = int(A.pop() / 2)
        bisect.insort_left(A,a)

    print(sum(A))

if __name__=='__main__':
    main()

Fixed submission:
import sys
from heapq import heappush, heappop

def main():
    _,M,*A = map(int, open(0).read().split())

    A = [-x for x in A] # reverse max to min
    A.sort()

    for _ in range(M):
        a = int(heappop(A) / 2)
        heappush(A, a)
    print(-sum(A))

if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys, bisect

def main():
    N,M,*A = map(int, open(0).read().split())

    A.sort()
    for _ in range(M):
        a = int(A.pop() / 2)
        bisect.insort_left(A,a)

    print(sum(A))

if __name__=='__main__':
    main()

Fixed submission:
import sys
from heapq import heappush, heappop

def main():
    _,M,*A = map(int, open(0).read().split())

    A = [-x for x in A] # reverse max to min
    A.sort()

    for _ in range(M):
        a = int(heappop(A) / 2)
        heappush(A, a)
    print(-sum(A))

if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys, bisect

def main():
    _,M,*A = map(int, open(0).read().split())

    A.sort()
    for _ in range(M):
        a = int(A.pop() / 2)
        bisect.insort_left(A,a)

    print(sum(A))

if __name__=='__main__':
    main()

Fixed submission:
import sys

def main():
    _,S = open(0).read().split()
    s1 = S[:int(len(S)*3/4)+1]

    maxLen = 0
    lenS1 = len(s1)
    for i in range(lenS1):
        for j in range(i+1+maxLen,lenS1):
            # print(s1[i:j], S[j:], j,i)
            if len(s1[i:j]) > len(S[j:]):
                break
            if s1[i:j] in S[j:]:
                maxLen = j-i
            else:
                break

    print(maxLen)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def main():
    _,S = open(0).read().split()
    s1 = S[:int(len(S)*3/4)+1]

    maxLen = 0
    lenS1 = len(s1)
    for i in range(lenS1):
        for j in range(i+1+maxLen,lenS1):
            # print(s1[i:j], S[j:], j,i)
            if s1[i:j] in S[j:] and j-i+1 > maxLen:
                maxLen = j-i

    print(maxLen)

if __name__ == '__main__':
    main()

Fixed submission:
import sys

def main():
    _,S = open(0).read().split()
    s1 = S[:int(len(S)*3/4)+1]

    maxLen = 0
    lenS1 = len(s1)
    for i in range(lenS1):
        for j in range(i+1+maxLen,lenS1):
            # print(s1[i:j], S[j:], j,i)
            if len(s1[i:j]) > len(S[j:]):
                break
            if s1[i:j] in S[j:]:
                maxLen = j-i
            else:
                break

    print(maxLen)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def encode(s):
    alp = [0]*26
    for c in s:
        alp[ord(c)-97] += 1
    return tuple(alp)

def main():
    N = int(sys.stdin.readline())
    S = [encode(x.rstrip()) for x in sys.stdin.readlines()]

    dic = {}
    for i, s in enumerate(S):
        if s not in dic:
            dic[s] = {i:0}
        else:
            for x in dic[s].keys():
                dic[s][x]+=1
            dic[s][i]=0

    count = 0
    for i, s in enumerate(S):
        count += dic[s][i]

    print(count)

if __name__=='__main__':
    main()

Fixed submission:
import sys

def main():
    N = int(sys.stdin.readline())
    S = [tuple(sorted(x.rstrip())) for x in sys.stdin.readlines()]

    dic = {}
    for i, s in enumerate(S):
        if s not in dic:
            dic[s] = {i:1}
        else:
            dic[s][i] = len(dic[s])+1

    count = 0
    for i, s in enumerate(S):
        count += len(dic[s]) - dic[s][i]

    print(count)

if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def encode(s):
    alp = [0]*26
    for c in s:
        alp[ord(c)-97] += 1
    return tuple(alp)

def main():
    N = int(sys.stdin.readline())
    S = [encode(x.rstrip()) for x in sys.stdin.readlines()]

    dic = {}
    for i, s in enumerate(S):
        if s not in dic:
            dic[s] = [i]
        else:
            dic[s].append(i)

    count = 0
    for i, s in enumerate(S):
        count += len([x for x in dic[s] if x > i])

    print(count)

if __name__=='__main__':
    main()

Fixed submission:
import sys

def main():
    N = int(sys.stdin.readline())
    S = [tuple(sorted(x.rstrip())) for x in sys.stdin.readlines()]

    dic = {}
    for i, s in enumerate(S):
        if s not in dic:
            dic[s] = {i:1}
        else:
            dic[s][i] = len(dic[s])+1

    count = 0
    for i, s in enumerate(S):
        count += len(dic[s]) - dic[s][i]

    print(count)

if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import Counter

def encode(s):
    alp = [0]*26
    for c in s:
        alp[ord(c)-97] += 1
    return tuple(alp)

def main():
    N = int(sys.stdin.readline())
    S = [encode(x.rstrip()) for x in sys.stdin.readlines()]

    dic = {}
    for i, s in enumerate(S):
        if s not in dic:
            dic[s] = [i]
        else:
            dic[s].append(i)

    count = 0
    for i, s in enumerate(S):
        count += len([x for x in dic[s] if x > i])

    print(count)

if __name__=='__main__':
    main()

Fixed submission:
import sys

def main():
    N = int(sys.stdin.readline())
    S = [tuple(sorted(x.rstrip())) for x in sys.stdin.readlines()]

    dic = {}
    for i, s in enumerate(S):
        if s not in dic:
            dic[s] = {i:1}
        else:
            dic[s][i] = len(dic[s])+1

    count = 0
    for i, s in enumerate(S):
        count += len(dic[s]) - dic[s][i]

    print(count)

if __name__=='__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def L(l,i,last):
    l[i-1] += last[i]
    l[i] -= last[i]
    last[i] = l[i]
    last[i-1] = l[i-1]

def R(l,i,last):
    l[i+1] += last[i]
    l[i] -= last[i]
    last[i] = l[i]


def main():
    S = input()

    maxLR = 0
    tmpLR = 0
    last = ''
    funcS = []
    for s in S:
        if s == last:
            tmpLR += 1
        else:
            maxLR = max(maxLR, tmpLR)
            tmpLR = 1
            last = s

        if s == 'R':
            funcS.append(R)
        else:
            funcS.append(L)
    
    maxLR = max(maxLR, tmpLR)
    
    loop = maxLR if maxLR % 2 == 0 else maxLR -1
    
    lenS = len(S)
    ch = [1]*lenS
    lastch = [1]*lenS
    for i in range(loop):
        for j in range(lenS):
            if ch[j] == 0:
                continue
            funcS[j](ch,j,lastch)
            # print(i,j, ch)

    print(*ch)

if __name__=='__main__':
    main()

Fixed submission:
import sys
import math

def main():
    S = input()
    lenS = len(S)
    ch = [0]*lenS

    tmpLR = 0
    last = ''
    for i, s in enumerate(S):
        if s == last:
            tmpLR += 1
        else:
            if last == 'R':
                ch[i-1] = tmpLR
            elif last == 'L':
                ch[i-tmpLR] = tmpLR

            tmpLR = 1
            last = s
    
    ch[-tmpLR] = tmpLR

    for i,c in enumerate(ch):
        if c == 0 or S[i] == 'L':
            continue
        if S[i] == 'R':
            rch = c
            lch = ch[i+1]
            rleft = math.ceil(rch/2)
            lleft = math.ceil(lch/2)
            ch[i] = rleft + lch - lleft
            ch[i+1] = lleft + rch - rleft

    print(*ch)

if __name__=='__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def main():
    _ = int(input())
    A = list(map(int, sys.stdin.readlines()))
    
    arr = [A[0]]
    for a in A[1:]:
        if a <= arr[-1]:
            arr.append(a)
        else:
            for i in range(len(arr)):
                if a > arr[i]:
                    arr[i] = a
                    break
    print(len(arr))
    
if __name__=='__main__':
    main()

Fixed submission:
import sys
import bisect
from collections import deque

def main():
    _ = int(input())
    A = list(map(int, sys.stdin.readlines()))
    
    arr = deque()
    arr.append(A[0])
    for a in A[1:]:
        if a <= arr[0]:
            arr.appendleft(a)
        else:
            insert_index = bisect.bisect_left(arr, a)
            update = max(0, insert_index-1)
            arr[update] = a
    print(len(arr))
    
if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def main():
    _ = int(input())
    A = list(map(int, sys.stdin.readlines()))
    
    arr = [A[0]]
    for a in A[1:]:
        for i in range(len(arr)):
            if a > arr[i]:
                arr[i] = a
                break
        else:
            arr.append(a)
    print(len(arr))
    
if __name__=='__main__':
    main()

Fixed submission:
import sys
import bisect
from collections import deque

def main():
    _ = int(input())
    A = list(map(int, sys.stdin.readlines()))
    
    arr = deque()
    arr.append(A[0])
    for a in A[1:]:
        if a <= arr[0]:
            arr.appendleft(a)
        else:
            insert_index = bisect.bisect_left(arr, a)
            update = max(0, insert_index-1)
            arr[update] = a
    print(len(arr))
    
if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def main():
    N = int(input())
    A = list(map(int, sys.stdin.readlines()))
    
    arr = [A[0]]
    for a in A[1:]:
        for i in range(len(arr)):
            if a > arr[i]:
                arr[i] = a
                break
        else:
            arr.append(a)
        arr.sort(reverse=True)
    print(len(arr))
    
if __name__=='__main__':
    main()

Fixed submission:
import sys
import bisect
from collections import deque

def main():
    _ = int(input())
    A = list(map(int, sys.stdin.readlines()))
    
    arr = deque()
    arr.append(A[0])
    for a in A[1:]:
        if a <= arr[0]:
            arr.appendleft(a)
        else:
            insert_index = bisect.bisect_left(arr, a)
            update = max(0, insert_index-1)
            arr[update] = a
    print(len(arr))
    
if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys

def main():
    n = int(input())
    w = [tuple(map(int,input().split())) for x in range(n)]
    w.sort(key=lambda x: x[0])

    pqs = {}
    for i in range(n):
        for j in range(i+1,n):
            x = w[j][0] - w[i][0]
            y = w[j][1] - w[i][1]
            if (x,y) not in pqs:
                pqs[(x,y)] = 1
            else:
                pqs[(x,y)] += 1

    print(n - max(pqs.values()))

if __name__=='__main__':
    main()

Fixed submission:
import sys

def main():
    n = int(input())

    if n <= 2:
        print(1)
        sys.exit()

    w = [tuple(map(int,input().split())) for x in range(n)]
    w.sort()

    pqs = {}
    for i in range(n-1):
        for j in range(i+1,n):
            xy = (w[j][0] - w[i][0], w[j][1] - w[i][1])
            if xy not in pqs:
                pqs[xy] = 1
            else:
                pqs[xy] += 1
    print(n - max(pqs.values()))

if __name__=='__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys

def main():
    n = int(input())
    w = [tuple(map(int,input().split())) for x in range(n)]

    pqs = {}
    for i in range(n):
        for j in range(i+1,n):
            x = abs(w[i][0] - w[j][0])
            y = abs(w[i][1] - w[j][1])
            if (x,y) not in pqs:
                pqs[(x,y)] = 1
            else:
                pqs[(x,y)] += 1

    print(n - max(pqs.values()))

if __name__=='__main__':
    main()

Fixed submission:
import sys

def main():
    n = int(input())

    if n <= 2:
        print(1)
        sys.exit()

    w = [tuple(map(int,input().split())) for x in range(n)]
    w.sort()

    pqs = {}
    for i in range(n-1):
        for j in range(i+1,n):
            xy = (w[j][0] - w[i][0], w[j][1] - w[i][1])
            if xy not in pqs:
                pqs[xy] = 1
            else:
                pqs[xy] += 1
    print(n - max(pqs.values()))

if __name__=='__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

def main():
    n,m = [int(x) for x in stdin.readline().rstrip().split()]
    l,r = [int(x) for x in stdin.readline().rstrip().split()]
    ans = set(range(l,r+1))

    for i in range(m-1):
        l,r = [int(x) for x in stdin.readline().rstrip().split()]
        cards = set(range(l,r+1))
        ans = ans & cards

    print(len(ans))
    
if __name__=='__main__':
    main()

Fixed submission:
from sys import stdin

def main():
    n,m = [int(x) for x in stdin.readline().rstrip().split()]

    _l = 0
    _r = n

    for i in range(m):
        l,r = [int(x) for x in stdin.readline().rstrip().split()]
        _l = max(l, _l)
        _r = min(r, _r)

    if _r - _l < 0:
        print(0)
    else:
        print(_r - _l + 1)
    
if __name__=='__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

from sys import stdin
    
def calc(n, s):
    s2 = [ c == '#' for c in s]
    total = sum(s2)
    ans =[2*sum(s2[:i])+n-i-total for i in range(n+1)]
    return min(ans)

def main():
    n = int(stdin.readline().rstrip())
    s = stdin.readline().rstrip()
    ans = calc(n, s)
    print(ans)
    
if __name__=='__main__':
    main()

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

from sys import stdin
    
def calc(n, s):
    s2 = [ c == '#' for c in s]
    total = sum(s2)
    _min = min(total, n-total)
    tr = 0
    for i,c in enumerate(s2):
        if c:
            tr += 1
        op = 2*tr+n-(i+1)-total
        if op < _min:
            _min = op

    return _min

def main():
    n = int(stdin.readline().rstrip())
    s = stdin.readline().rstrip()
    ans = calc(n, s)
    print(ans)
    
if __name__=='__main__':
    main()

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

from sys import stdin
    
def calc(n, s):
    b = '#'
    w = '.'
    last = ''

    s2 = [ c == '#' for c in s]
    ans =[sum(s2[:i])+n-i-sum(s2[i:]) for i in range(n+1)]
    return min(ans)

def main():
    n = int(stdin.readline().rstrip())
    s = stdin.readline().rstrip()
    ans = calc(n, s)
    print(ans)
    
if __name__=='__main__':
    main()

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

from sys import stdin
    
def calc(n, s):
    s2 = [ c == '#' for c in s]
    total = sum(s2)
    _min = min(total, n-total)
    tr = 0
    for i,c in enumerate(s2):
        if c:
            tr += 1
        op = 2*tr+n-(i+1)-total
        if op < _min:
            _min = op

    return _min

def main():
    n = int(stdin.readline().rstrip())
    s = stdin.readline().rstrip()
    ans = calc(n, s)
    print(ans)
    
if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

from sys import stdin

def load():
    n = int(stdin.readline())
    s = stdin.readline()
    q = int(stdin.readline())
    k = [int(x) for x in stdin.readline().split()]
    
    return (s, k)

def calc(s, ks):
    dmcmap = dmc(s)
    ans = [sum(dmcmap[:k]) for k in ks]
    print(*ans, sep='\n', flush=True)

def dmc(src):
    ret = [0 for _ in range(len(src))]

    dmap = [i for i, x in enumerate(src) if x == 'D']
    mmap = [i for i, x in enumerate(src) if x == 'M']
    cmap = [i for i, x in enumerate(src) if x == 'C']

    for d in dmap:
        for m in filter(lambda x: x > d, mmap):
            for c in filter(lambda x: x > m, cmap):
                ret[c-d] += 1
    return ret

stdin = open('data.txt')
s, ks = load()
calc(s,ks)

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

import numpy as np
from sys import stdin

def load():
    n = stdin.readline()
    data = [int(x) for x in stdin.readline().split()]
    return (n,data)

def calc(n, data):
    d = np.asarray(data)
    m = d.mean()
    diff = np.abs(d - m)
    return diff.argmin()

n, data = load()
print(calc(n, data))

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

from sys import stdin
from functools import reduce

def load():
    n = int(stdin.readline())
    s = stdin.readline()
    q = int(stdin.readline())
    k = [int(x) for x in stdin.readline().split()]
    
    return (s, k)

def calc(s, ks):
    dmcmap = dmc(s, max(ks))
    for k in ks:
        print(sum(dmcmap[:k]))

def dmc(src, kmax):
    ret = [0 for _ in range(kmax)]

    for ind in range(len(src)):
        if src[ind] == 'D':
            for inm in range(ind+1, len(src)):
                if src[inm] == 'M':
                    for inc in range(inm+1, len(src)):
                        if src[inc] == 'C':
                            ret[inc-ind] += 1
    return ret

s, ks = load()
calc(s,ks)

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

import numpy as np
from sys import stdin

def load():
    n = stdin.readline()
    data = [int(x) for x in stdin.readline().split()]
    return (n,data)

def calc(n, data):
    d = np.asarray(data)
    m = d.mean()
    diff = np.abs(d - m)
    return diff.argmin()

n, data = load()
print(calc(n, data))
Buggy python submission (verdict: Runtime Error):
n = int(input())


print((n - 1) * n // 2))

Fixed submission:
n = int(input())


print((n - 1) * n // 2)