Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
suma = a[0]
suma2 = sum(a)
for i in range(N-2):
    if 2*suma + a[i+1] -suma2 >= 0:
        break
    suma += a[i+1]
print(min(abs(2*suma+a[i] - suma2),abs(2*suma - suma2)))

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
suma = sum(a)
ans = abs(suma - a[0])
sumb = a[0]
if N == 2:
    print(abs(a[0]-a[1]))
else:
    for i in range(1,N-1):
        sumb += a[i]
        ans = min(ans,abs(suma - 2*sumb))
    print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
suma = a[0]
suma2 = sum(a)
for i in range(1,N-1):
    if 2*suma + a[i] -suma2 >= 0:
        break
    suma += a[i]
print(min(abs(2*suma+a[i] - suma2),abs(2*suma - suma2)))

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
suma = sum(a)
ans = abs(suma - a[0])
sumb = a[0]
if N == 2:
    print(abs(a[0]-a[1]))
else:
    for i in range(1,N-1):
        sumb += a[i]
        ans = min(ans,abs(suma - 2*sumb))
    print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
if n == 1:
    print(a[0])
else:
    print(*a[::-2],*a[n%2::2])

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
if n == 1:
    print(a[0])
else:
    print(*a[::-2],end = ' ')
    print(*a[n%2::2])

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
print(*a[::-2],*a[n%2::2])

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
if n == 1:
    print(a[0])
else:
    print(*a[::-2],end = ' ')
    print(*a[n%2::2])

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
if n == 1:
    print(a[0])
else:
    print(*a[::-2],*a[::2])


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
if n == 1:
    print(a[0])
else:
    print(*a[::-2],end = ' ')
    print(*a[n%2::2])

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
print(*a[::-2],*a[::2])


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
if n == 1:
    print(a[0])
else:
    print(*a[::-2],end = ' ')
    print(*a[n%2::2])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(n):
    b.append(a[i])
    b = b[::-1]
print(*b)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
if n == 1:
    print(a[0])
else:
    print(*a[::-2],end = ' ')
    print(*a[n%2::2])
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
num = [0 for i in range(9)]
for i in range(N):
    num[a[i]//400] += 1

if num[-1] == 0:
    num = [i for i in num if i != 0]
    print(len(num),len(num))
else:
    n = num.pop(-1)
    num2 = [i for i in num if i != 0]
    print(len(num2),min(8,len(num2)+n))
    

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
num = [0 for i in range(9)]
for i in range(N):
    if a[i] < 3200:
        num[a[i]//400] += 1
    else:
        num[-1] += 1

if num[-1] == 0:
    num = [i for i in num if i != 0]
    print(len(num),len(num))
else:

    n = num.pop(-1)

    num2 = [i for i in num if i != 0]
    print(max(1,len(num2)),len(num2)+n)
Buggy python submission (verdict: Runtime Error):
n = int(input())
array = []
for i in range(1,n+1):
    for j in range(1,n//i+1):
        array.append(abs(i-j) + n - i*j)
print(min(array))

Fixed submission:
N,K = map(int,input().split())
num = 0
dicta = {}
for i in range(N):
    a,b = map(int,input().split())
    if a not in dicta:
        dicta[a] = b
    else:
        dicta[a] += b

dicts = sorted(dicta.items(), key = lambda x:x[0])
for i,v in dicts:
    num += v
    if num >= K:
        print(i)
        break
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
N,W = map(int,input().split())
w = [[] for i in range(4)]
w1,v1 = map(int,input().split())
w[0].append(v1)
for i in range(N-1):
    wi,vi = map(int,input().split())
    w[wi-w1].append(vi)
num = []
for i in range(4):
    w[i].sort(reverse= 1)
    w[i] = [0]+list(accumulate(w[i]))
    num.append(len(w[i]))
ans = 0
for n1 in range(num[0]+1):
    for n2 in range(num[1]+1):
        for n3 in range(num[2]+1):
            for n4 in range(num[3]+1):
                wc = w1*(n1+n2+n3+n4) + n2 + 2*n3 + 3*n4
                if wc <= W:
                    vc = w[0][n1]+w[1][n2]+w[2][n3]+w[3][n4]
                    ans = max(ans,vc)
print(ans)

Fixed submission:
N,W = map(int,input().split())
w = [[] for i in range(4)]
w1,v1 = map(int,input().split())
w[0].append(v1)
for i in range(N-1):
    wi,vi = map(int,input().split())
    w[wi-w1].append(vi)
num = []
for i in range(4):
    w[i].sort(reverse= 1)
    num.append(len(w[i]))
ans = 0
for n1 in range(num[0]+1):
    for n2 in range(num[1]+1):
        for n3 in range(num[2]+1):
            for n4 in range(num[3]+1):
                wc = w1*(n1+n2+n3+n4) + n2 + 2*n3 + 3*n4
                if wc <= W:
                    vc = sum(w[0][:n1])+sum(w[1][:n2])+sum(w[2][:n3])+sum(w[3][:n4])
                    ans = max(ans,vc)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
count2 = 0
for i in range(N-1,-1,-1):
    count = B[i]*((A[i]-1)//B[i] + 1) - A[i]
    count2 += count
    for j in range(i+1):
        A[j] += count
print(count2)


Fixed submission:
N = int(input())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
count2 = 0
for i in range(N-1,-1,-1):
    count = B[i]*((A[i]+count2-1)//B[i] + 1) - A[i]-count2
    count2 += count
print(count2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
count2 = 0
for i in range(N-1,-1,-1):
    count = B[i]*((A[i]-1)//B[i] + 1) - A[i]
    count2 += count
    for j in range(i+1):
        A[j] += count
print(count2)


Fixed submission:
N = int(input())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
count2 = 0
for i in range(N-1,-1,-1):
    count = B[i]*((A[i]+count2-1)//B[i] + 1) - A[i]-count2
    count2 += count
print(count2)
Buggy python submission (verdict: Runtime Error):
n= int(input())
s= input()
suma=[0]
for i in range(n):
  if s[i] == 'I':
    suma.append(s[i]+1)
  else:
    suma.append(s[i]-1)
print(max(suma))

Fixed submission:
n= int(input())
s= input()
suma=[0]
for i in range(n):
  if s[i] == 'I':
    suma.append(suma[i]+1)
  else:
    suma.append(suma[i]-1)
print(max(suma))
Buggy python submission (verdict: Runtime Error):
N = int(input())
#N,M = map(int,input().split())
#A = list(map(int,input().split()))
#A = [list(map(int,input().split())) for i in range(N)]
def prime_dict(n):
    a = {}
    if n%2 == 0:
        a[2] = 1
        n//=2
    while n%2 == 0:
        a[2] += 1
        n //= 2
    f = 3
    while f*f <= n:
        if n%f == 0:
            if f not in a:
                a[f] == 1
            else:
                a[f] += 1
        else:
            f += 2
    if n!= 1:
        a[n] = 1
    return a
ans = 1
mod = 10**9+7
prime2 = {}
for i in range(2,N+1):
    prime = prime_dict(i)
    for k,v in prime.items():
        if k not in prime2:
            prime2[k] = v
        else:
            prime2[k] += v
for i in prime2.values():
    ans = (ans*(i+1))%mod
print(ans)


Fixed submission:
N = int(input())
#N,M = map(int,input().split())
#A = list(map(int,input().split()))
#A = [list(map(int,input().split())) for i in range(N)]
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
ans = 1
mod = 10**9+7
prime = primes(N)
for i in prime:
    isum = 0
    for n in range(2,N+1):
        while n%i == 0:
            isum += 1
            n //= i
    ans = (ans*(isum+1))%mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,x = map(int,input().split())
flag = False
for i in range(a,b+1):
    if i%x == 0:
        first = i
        flag = True
        break
if flag:
    print((b-i)//x+1)
else:
    print(0)

Fixed submission:
a,b,x = map(int,input().split())
if a == 0:
    print(b//x+1)
else:
    print(b//x - (a-1)//x)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,x = map(int,input().split())
flag = False
for i in range(a,b+1):
    if i%x == 0:
        first = i
        flag = True
        break
if flag:
    print((b-i)//x+1)
else:
    print(0)

Fixed submission:
a,b,x = map(int,input().split())
if a == 0:
    print(b//x+1)
else:
    print(b//x - (a-1)//x)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
while True:
    if S == S.replace('ST',''):
        break
    else:
        S = S.replace('ST','')
print(len(S))

Fixed submission:
S = input()
tcount = 0
scount = 0
for i in S:
    if i == 'T':
        if scount > 0:
            scount -= 1
        else:
            tcount += 1
    else:
        scount += 1
print(tcount + scount)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

c = 0
for i in range(N):
    for j in range(N):
        if i < j:
            if A[i] == j+1 and A[j] == i+1:
                c += 1
print(c)
    

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

c = 0
for i in range(N):
    if A[A[i]-1] == i+1:
        c += 1
print(int(c//2))

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

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

c = 0
for i in range(N):
    if A[A[i]-1] == i+1:
        c += 1
print(int(c//2))
Buggy python submission (verdict: Time Limit Exceeded):
H,W,N = map(int,input().split())
ans = [0 for i in range(10)]
ab = []
for i in range(N):
    a,b =map(int,input().split())
    a -= 1
    b -=1
    ab.append([a,b])
ab.sort()
start = set()
h1 = [-2,-2,-2,-1,-1,-1,0,0,0]
w1 = [-2,-1,0,-2,-1,0,-2,-1,0]
for a,b in ab:
    for i in range(9):
        if 0<= a+h1[i]<= H-3 and 0<= b+w1[i]<=W-3:
            start.add((a+h1[i],b+w1[i]))
h2 = [2,2,2,1,1,1,0,0,0]
w2 = [2,1,0,2,1,0,2,1,0]
for a,b in start:
    count = 0
    for i in range(9):
        if [a+h2[i],b+w2[i]] in ab:
            count += 1
    if count:
        ans[count] += 1
ans[0] = (H-2)*(W-2) - sum(ans)
for i in ans:
    print(i)

Fixed submission:
from collections import Counter
H,W,N = map(int,input().split())
ab = []
corner = []
countlist = [0 for i in range(10)]
for i in range(N):
    a,b = map(int,input().split())
    for h in range(-2,1):
        for w in range(-2,1):
            if 1 <= a+h <= H-2 and 1 <= b+w <= W-2:
                corner.append((a+h,b+w))
cc = Counter(corner)
clist = list(cc.values())
clistc = Counter(clist)
for k,v in clistc.items():
    countlist[k] += v
countlist[0] = (H-2)*(W-2) - sum(countlist)
for i in countlist:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
D = list(map(int,input().split()))
num = {0,1,2,3,4,5,6,7,8,9}
Ds = set(D)
diff = num^Ds
ans = N
while True:
    strN = str(N)
    flag = False
    for i in strN:
        if int(i) not in diff:
            flag = True
    if flag:
        ans += 1
    else:
        break
print(ans)

Fixed submission:
N,K = map(int,input().split())
D = input().split()
num = set([str(i) for i in range(10)])
Ds = set(D)
diff = num^Ds
ans = N
while True:
    strN = set(list(str(ans)))
    if strN - diff:
        ans += 1
    else:
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
import bisect
N,K = map(int,input().split())
D = list(map(int,input().split()))
num = {0,1,2,3,4,5,6,7,8,9}
Ds = set(D)
diff = num^Ds
if 0 in diff:
    diff.remove(0)
    lenn = len(str(N))
    print(str(min(diff)) + '0'*(lenn-1))
else:
    lenn = len(str(N))
    diff = list(diff)
    diff.sort()
    strN = str(N)
    for i in range(lenn):
        intN = int(strN[i])
        ind = bisect.bisect_left(diff,intN)
        print(diff[ind],end='')


Fixed submission:
N,K = map(int,input().split())
D = input().split()
num = set([str(i) for i in range(10)])
Ds = set(D)
diff = num^Ds
ans = N
while True:
    strN = set(list(str(ans)))
    if strN - diff:
        ans += 1
    else:
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
H,W,A,B = map(int,input().split())
mod = 10**9+7
def comb(a,b,p):
    if a<0 or b<0 or a<b: return 0
    if a==0 or b==0: return 1
    fa = 1
    fb = 1
    fab = 1
    for i in range(1,a+1):
        fa = (fa*i)%p
    for i in range(1,b+1):
        fb = (fb*i)%p
    for i in range(1,a-b+1):
        fab = (fab*i)%p
    return (fa*power2(fb,p-2,p)*power2(fab,p-2,p))%p
def power2(a,b,p):
    if b == 0:
        return 1
    if b%2 == 0:
        d = power2(a,b//2,p)
        return (d*d)%p
    return (a*power2(a,b-1,p))%p
ans = 0
for w in range(B,W):
    ans = (ans+ (comb(H-A+w-1,w,mod)*comb(A+W-w-2,A-1,mod))%mod)%mod
print(ans)

Fixed submission:
H,W,A,B = map(int,input().split())
mod = 10**9+7
x1 = [1 for i in range(H+W)]
xi = [1 for i in range(H+W)]
num = 1
def power2(a,b,p):
    if b == 0:
        return 1
    if b%2 == 0:
        d = power2(a,b//2,p)
        return (d*d)%p
    return (a*power2(a,b-1,p))%p
for i in range(1,H+W):
    num = (num*i)%mod
    x1[i] = num
for i in range(1,H+W):
    x2 = power2(x1[i],mod-2,mod)
    xi[i] = x2
def comb(a,b,p):
    return (x1[a]*xi[b]*xi[a-b])%p
ans = 0
for w in range(B,W):
    ans = (ans+ (comb(H-A+w-1,w,mod)*comb(A+W-w-2,A-1,mod))%mod)%mod
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B, C,K=map(int,input().split())
if K<= A:
    prin(K)
elif K<=A+B:
    print(A)
else:
    print(2*A+B-K)  

Fixed submission:
A,B, C,K=map(int,input().split())
if K<= A:
    print(K)
elif K<=A+B:
    print(A)
else:
    print(2*A+B-K)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
a = []
b = []
ans = 0
for i in range(N):
    a.append(i+1+A[i])
    b.append(i+1-A[i])
for i in a:
    ans += b.count(i)
print(ans)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
a = []
b = []
ans = 0
for i in range(N):
    a.append(i+1+A[i])
    b.append(i+1-A[i])
b = Counter(b)
for i in a:
    ans += b[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
cnt = 0
for i in range(N):
    for u in range(i,N):
        if u-i == A[i]+A[u]:
            cnt += 1
        else:
            pass
print(cnt)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
a = []
b = []
ans = 0
for i in range(N):
    a.append(i+1+A[i])
    b.append(i+1-A[i])
b = Counter(b)
for i in a:
    ans += b[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
N ,M ,Q = map(int,input().split())
l = [list(map(int,input().split())) for i in range(Q)]
ans=[]
score = 0
for i1 in range(1,M+1):
    for i2 in range(i1,M+1):
        for i3 in range(i2,M+1):
            for i4 in range(i3,M+1):
                for i5 in range(i4,M+1):
                    for i6 in range(i5,M+1):
                        for i7 in range(i6,M+1):
                            for i8 in range(i7,M+1):
                                for i9 in range(i8,M+1):
                                    for i10 in range(i9,M+1):
                                        A = [i1,i2,i3,i4,i5,i6,i7,i8,i9,i10]
                                        for a, b, c, d in l:
                                            if A[b+1] - A[a+1] == c:
                                                score += d
                                            else:
                                                pass
                                        ans.append(score)
                                        score = 0
print(max(ans))

Fixed submission:
N ,M ,Q = map(int,input().split())
l = [list(map(int,input().split())) for i in range(Q)]
ans=[]
score = 0
for i1 in range(1,M+1):
    for i2 in range(i1,M+1):
        for i3 in range(i2,M+1):
            for i4 in range(i3,M+1):
                for i5 in range(i4,M+1):
                    for i6 in range(i5,M+1):
                        for i7 in range(i6,M+1):
                            for i8 in range(i7,M+1):
                                for i9 in range(i8,M+1):
                                    for i10 in range(i9,M+1):
                                        A = [i1,i2,i3,i4,i5,i6,i7,i8,i9,i10]
                                        for a, b, c, d in l:
                                            if A[b-1] - A[a-1] == c:
                                                score += d
                                            else:
                                                pass
                                        ans.append(score)
                                        score = 0
print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import math
A ,B ,N = map(int,input().split())
l = 0
t = A/B
for x in range(1,N+1):
    if math.floor(t * x)-A*math.floor(x/B) > l:
        l=math.floor(t * x)-A*math.floor(x/B)
print(l)

Fixed submission:
A , B , N = map(int,input().split())
x = min(B-1,N)
print((A*x)//B)

Buggy python submission (verdict: Time Limit Exceeded):
import math
A ,B ,N = map(int,input().split())
l = []
for x in range(1,N+1):
    l.append(math.floor(A*x/B)-A*math.floor(x/B))
print(max(l))

Fixed submission:
A , B , N = map(int,input().split())
x = min(B-1,N)
print((A*x)//B)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
for i in range(N):
    x = a.count(i+1)
    print(x)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
s = [0] *N
for u in range(N-1):
    s[a[u]-1] += 1
for i in range(N):
    print(s[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
for i in range(N):
    x = a.count(i+1)
    print(x)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
s = [0] *N
for u in range(N-1):
    s[a[u]-1] += 1
for i in range(N):
    print(s[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
for i in range(N):
    x = a.count(i+1)
    print(x)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
s = [0] *N
for u in range(N-1):
    s[a[u]-1] += 1
for i in range(N):
    print(s[i])
Buggy python submission (verdict: Time Limit Exceeded):
import math
K = int(input())
sum = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            sum+=math.gcd(math.gcd(a,b),c)
print(sum)

Fixed submission:
import math
k = int(input())
 
ans = 0
for i in range(1, k+1):
  for j in range(1, k+1):
    tmp = math.gcd(i,j)
    for l in range(1, k+1):
      ans += math.gcd(tmp, l)
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
K = int(input())
sum = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans+=math.gcd(math.gcd(a,b),c)
print(sum(list))


Fixed submission:
import math
k = int(input())
 
ans = 0
for i in range(1, k+1):
  for j in range(1, k+1):
    tmp = math.gcd(i,j)
    for l in range(1, k+1):
      ans += math.gcd(tmp, l)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
K = int(input())
list = []
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
           x = math.gcd(math.gcd(a,b),c)
           list.append(x)
print(sum(list))

Fixed submission:
import math
k = int(input())
 
ans = 0
for i in range(1, k+1):
  for j in range(1, k+1):
    tmp = math.gcd(i,j)
    for l in range(1, k+1):
      ans += math.gcd(tmp, l)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
K = int(input())
list = []
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
           x = math.gcd(a,b)
           y = math.gcd(x,c)
           list.append(y)
print(sum(list))

Fixed submission:
import math
k = int(input())
 
ans = 0
for i in range(1, k+1):
  for j in range(1, k+1):
    tmp = math.gcd(i,j)
    for l in range(1, k+1):
      ans += math.gcd(tmp, l)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
K = int(input())
sum = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
           x = math.gcd(a,b)
           y = math.gcd(x,c)
           sum +=y
print(sum)

Fixed submission:
import math
k = int(input())
 
ans = 0
for i in range(1, k+1):
  for j in range(1, k+1):
    tmp = math.gcd(i,j)
    for l in range(1, k+1):
      ans += math.gcd(tmp, l)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
cnt = 0
for i in range(N):
    for j in range(i,N):
        if S[i] != S[j]:
            for k in range(j,N):
                if (S[i] != S[k]) and (S[j] != S[k]) and (j != (i+k)/2):
                    cnt +=1
                else:
                    pass
        else:
            pass
print(cnt)

Fixed submission:
N = int(input())
S = input()
R = S.count("R")
G = S.count("G")
B = S.count("B")
cnt = 0
for i in range(N):
    for j in range(i+1,N):
        if j*2-i < N:
            if (S[i] != S[j]) and (S[i] !=S[(j*2)-i]) and (S[j] != S[(j*2)-i]):
                cnt += 1
            else:
                pass
        else:
            pass
print(R*G*B - cnt)
Buggy python submission (verdict: Runtime Error):
K, N = map(int,input().split())
a = list(map(int,input().split()))
x = [a[0]-a[-1]+K]
for i in range(1,N):
    x.append(a[i]-a[i-1])
print(x)
print(K-max(x))

Fixed submission:
import math
N, K = map(int, input().split())
N = N%K
while True:
    if abs(N-K) < N:
        N = abs(N-K)
    else:
        print(N)
        break

Buggy python submission (verdict: Time Limit Exceeded):
import math
N, K = map(int, input().split())
while True:
    if abs(N-K) < N:
        N = abs(N-K)
    else:
        print(N)
        break

Fixed submission:
import math
N, K = map(int, input().split())
N = N%K
while True:
    if abs(N-K) < N:
        N = abs(N-K)
    else:
        print(N)
        break
Buggy python submission (verdict: Runtime Error):
X ,Y ,A ,B ,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)
p = p[:X]
q = q[:Y]
p.extend(q)
p.extend(r)
p. sort(reverse = True)
p = p[:A+B]
print(sum(p))

Fixed submission:
S = input()
if S[2] ==S[3] and S[4] == S[5]:
    print("Yes")
else :
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import math
N ,X ,Y = map(int,input().split())
x = [0] * (N-1)
for i in range(1,N+1):
    for u in range(i+1,N+1):
        y =[abs(u - i), abs(X - i) + 1 + abs(u - Y ), abs(Y - i) + 1 + abs(u - X)]
        x[min(y)-1] += 1
for h in x:
    print(h)

Fixed submission:
import math
N ,X ,Y = map(int,input().split())
x = [0] * (N-1)
for i in range(1,N+1):
    for u in range(i+1,N+1):
        y =[abs(u - i), abs(X - i) + 1 + abs(u - Y ), abs(Y - i) + 1 + abs(u - X)]
        x[min(y)-1] += 1
for h in x:
    print(h)