Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#解説参照
n,m=map(int, input().split())
e=[[] for _ in range(n+1)]
for _ in range(m):
    ai,bi=map(int, input().split())
    e[ai].append(bi);e[bi].append(ai)

from collections import deque

pth=deque([1,e[1][0]])
used=[0]*(n+1)
used[1]=1;used[e[1][0]]=1

for _ in range((n+m)*2):
    r=pth[-1]
    for v in e[r]:
        if not used[v]:
            pth.append(v)
            used[v]=1
            break
    l=pth[0]
    for v in e[l]:
        if not used[v]:
            pth.appendleft(v)
            used[v]=1
            break
print(len(pth))
print(*pth)



Fixed submission:
n,m=map(int, input().split())
e=[[] for _ in range(n+1)]
for _ in range(m):
    ai,bi=map(int, input().split())
    e[ai].append(bi);e[bi].append(ai)

from collections import deque

pth=deque([1,e[1][0]])
used=[0]*(n+1)
used[1]=1;used[e[1][0]]=1

for _ in range(n*2):
    r=pth[-1]
    for v in e[r]:
        if not used[v]:
            pth.append(v)
            used[v]=1
            break
    l=pth[0]
    for v in e[l]:
        if not used[v]:
            pth.appendleft(v)
            used[v]=1
            break
print(len(pth))
print(*pth)
Buggy python submission (verdict: Runtime Error):
import sys
n = int(input())
s = input()

L = ["SS","SW","WS","WW"]
l= len(s)
##0,1に置き換えたりしない
##条件分岐注意する
##ずらす必要はない、Lが固定するのはindexで-2,-1
for t in L:
  　tmp = t###
    for i in range(l):
        if (s[i]=="x") ^ (tmp[-1] == "W"):
            if tmp[-2]=="S":
                tmp+= "W"
            else:
                tmp += "S"
            
        else:
            tmp += tmp[-2]
    if tmp[:2]==tmp[-2:]:
        print(tmp)
        sys.exit()
print(-1)
    


Fixed submission:
#お手上げ、挙動追えない
import sys
n = int(input())
s = input()

L = ["SS","SW","WS","WW"]
l= len(s)
##0,1に置き換えたりしない
##条件分岐注意する
##ずらす必要はない?Lが固定するのはindexで-1,0?
for t in L:
    tmp = t###
    for i in range(l):
        if (s[i]=="x") ^ (tmp[-1] == "W"):
            if tmp[-2]=="S":
                tmp+= "W"
            else:
                tmp += "S"
            
        else:
            tmp += tmp[-2]
    if tmp[:2]==tmp[-2:]:
        print(tmp[1:-1])###
        sys.exit()
print(-1)
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
a = []
b = []
for i in range(n):
    ai = input()
    a.append(ai)
for i in range(m):
    bi = input()
    b.append(bi)
flag = True    
for i in range(n-m+1):
    flag = True
    for k in range(n-m+1):
        for j in range(i,i+m+1):
        
            if a[j][k:k+m]!=b[j-i]:
                flag = False
                break
        if flag:
            break
    if flag:
        break
#print(i,k,flag)        
print("Yes" if flag else "No")


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

flag = False  
for i in range(n-m+1):
    #flag = True
    for k in range(n-m+1):
        flag=True#ここ
        for j in range(i,i+m):
            #if i==k==3:
            #    print(a[j][k:k+m],b[j-i],a[j][k:k+m]==b[j-i],flag)
            if a[j][k:k+m]!=b[j-i]:
                flag = False
                break
        if flag:
            break
    if flag:
        break
#print(i,k,flag)        
print("Yes" if flag else "No")
Buggy python submission (verdict: Runtime Error):
#editorial参照
n=int(input())
a=list(map(int, input().split()))
sa= sum(a)
if sa%(n*(n+1)//2):
    print("NO")
    exit()
k=sa//(n*(n-1)//2)
b=[a[i]-a[i-1] -k for i in range(n)]

for i in range(n):
    if b[i]%n or b[i]>0:
        print("NO")
        exit()
print("YES")

Fixed submission:
#modN等差数列が必要...根本的に違う
n=int(input())
a=list(map(int, input().split()))
sa= sum(a)
if sa%(n*(n+1)//2):
    print("NO")
    exit()
k=sa//(n*(n+1)//2)###+
b=[a[i]-a[i-1] -k for i in range(n)]

for i in range(n):
    if b[i]%n or b[i]>0:
        print("NO")
        exit()
print("YES")
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split( ))
p= [i for i in range(n)]+[n+j for j in range(m)]
rk = [0]*(n+m)
def rt(a):
    if a==p[a]:
        return a
    p[a] = rt(p[a])
    return p[a]
def uni(a,b):
    ra = rt(a);rb=rt(b)
    if ra==rb:
        return
    if rk[ra]>rk[rb]:
        p[rb] = ra
    else:
        if rk[ra]==rk[rb]:
            p[ra] = rb
            rk[ra]+=1
        else:
            p[ra]=rb 
    return

kl = {}
for i in range(n):
    ki,*li, = map(int, input().split( ))
    kl[i] = li
for ki in kl:
    for j in range(len(kl[ki])):
        kl[ki][j]-=1

for ki in kl:
    for lij in kl[ki]:
        uni(ki,lij+n)
for i in range(n):
    rt(i)
if len(set(p[:n]))==1:
    print("YES")
else:
    print("NO")

Fixed submission:
n,m = map(int, input().split( ))
p= [i for i in range(n)]+[n+j for j in range(m)]
rk = [0]*(n+m)
def rt(a):
    if a==p[a]:
        return a
    p[a] = rt(p[a])
    return p[a]
def uni(a,b):
    ra = rt(a);rb=rt(b)
    if ra==rb:
        return
    if rk[ra]>rk[rb]:
        p[rb] = ra
    else:
        if rk[ra]==rk[rb]:
            p[ra] = rb
            rk[rb]+=1
        else:
            p[ra]=rb 
    return

kl = {}
for i in range(n):
    ki,*li, = map(int, input().split( ))
    kl[i] = li
for ki in kl:
    for j in range(len(kl[ki])):
        kl[ki][j]-=1

for ki in kl:
    for lij in kl[ki]:
        uni(ki,lij+n)
for i in range(n):
    rt(i)
if len(set(p[:n]))==1:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
n, a = map(int,input().split( ))

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

for i in range(n):
    x[i] -= a
mx = max(x)*n+1

dp = [[0 for i in range(3*mx)] for j in range(n)]
dp[0][0] += 1
dp[0][x[0]] += 1

for i in range(1,n) :
    for j in range(-mx,mx):
        dp[i][j] += dp[i-1][j-x[i]]
        dp[i][j] += dp[i-1][j]
    #print(*dp[i])
print(dp[n-1][0]-1)


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

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

for i in range(n):
    x[i] -= a

mx = 0
for i in range(n):
    mx += abs(x[i])
mx +=1

dp = [[0 for i in range(3*mx)] for j in range(n)]
dp[0][0] += 1
dp[0][x[0]] += 1

for i in range(1,n) :
    for j in range(-mx,mx):
        dp[i][j] += dp[i-1][j-x[i]]
        dp[i][j] += dp[i-1][j]
    #print(*dp[i])
print(dp[n-1][0]-1)
Buggy python submission (verdict: Runtime Error):
#numpy使ってみる
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split( ))))

ans = 10**10

for i in range(-100,101):
    tmp = ((a-i)**2).sum()
    ans = min(tmp,ans)
print(ans)

Fixed submission:
#numpy使ってみる
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split( ))))

ans = 10**10

for i in range(-100,101):
    tmp = ((a-i)**2).sum()
    ans = min(tmp,ans)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

S = [0 for _ in range(N+1)]
mod = 1000000007

for i in range(N-1):
    st = 0
    for j in range(i+1):
        st += A[j] * A[i+1]
    S[i+1] = S[i] + st

print(int(S[N-1] % mod))

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

S = [0 for _ in range(N+1)]
T = [0 for _ in range(N+1)]
mod = 1000000007

for i in range(N-1):
    st = 0
    T[i+1] = T[i] + A[i]
    S[i+1] = S[i] + A[i+1] * T[i+1]

print(int(S[N-1] % mod))

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

S = [0 for _ in range(N+1)]
mod = 1000000007

for i in range(N-1):
    st = 0
    for j in range(i+1):
        st += A[j] * A[i+1]
    S[i+1] = S[i] + st

print(int(S[N-1] % mod))

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

S = [0 for _ in range(N+1)]
T = [0 for _ in range(N+1)]
mod = 1000000007

for i in range(N-1):
    st = 0
    T[i+1] = T[i] + A[i]
    S[i+1] = S[i] + A[i+1] * T[i+1]

print(int(S[N-1] % mod))
Buggy python submission (verdict: Runtime Error):
from collections import deque
N, M, K = map(int, input().split())
A = deque(list(map(int, input().split())))
B = deque(list(map(int, input().split())))
dp = [0] * (len(A)+len(B)+1)
i = j = 0
for idx in range(len(dp)):
    if i >= len(A) and j >= len(B):
        print(i+j)
        exit()
    if i >= len(A):
        dp[idx+1] = dp[idx] + B[j]
        j += 1
    elif j >= len(B):
        dp[idx+1] = dp[idx] + A[j]
    elif dp[idx] + A[i] < dp[idx] + B[j]:
        dp[idx+1] = dp[idx] + A[i]
        i += 1
    else:
        dp[idx+1] = dp[idx] + B[j]
        j += 1
    if dp[idx+1] > K:
        break
print(i+j-1)

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a_s = [0] * (len(A)+1)
b_s = [0] * (len(B)+1)
for i in range(len(A)):
    a_s[i+1] = a_s[i] + A[i]
for i in range(len(B)):
    b_s[i + 1] = b_s[i] + B[i]

ans = 0
j = M
for i in range(len(a_s)):
    if a_s[i] > K:
        break
    while b_s[j] + a_s[i] > K:
        j -= 1
    ans = max(ans, i+j)
print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import deque
N, M, K = map(int, input().split())
A = deque(list(map(int, input().split())))
B = deque(list(map(int, input().split())))
dp = [0] * (len(A)+len(B)+1)
i = j = 0
for idx in range(len(dp)):
    if i >= len(A) and j >= len(B):
        break
    if i >= len(A):
        dp[idx+1] = dp[idx] + B[j]
        j += 1
    elif j >= len(B):
        dp[idx+1]
    elif dp[idx] + A[i] < dp[idx] + B[j]:
        dp[idx+1] = dp[idx] + A[i]
        i += 1
    else:
        dp[idx+1] = dp[idx] + B[j]
        j += 1
    if dp[idx+1] > K:
        break
print(idx)

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a_s = [0] * (len(A)+1)
b_s = [0] * (len(B)+1)
for i in range(len(A)):
    a_s[i+1] = a_s[i] + A[i]
for i in range(len(B)):
    b_s[i + 1] = b_s[i] + B[i]

ans = 0
j = M
for i in range(len(a_s)):
    if a_s[i] > K:
        break
    while b_s[j] + a_s[i] > K:
        j -= 1
    ans = max(ans, i+j)
print(ans)
Buggy python submission (verdict: Runtime Error):
X, N = map(int, input().split())
p = list(map(int, input().split()))

if len(p) == 0:
    print(X)
    exit()

if not X in p:
    print(X)
    exit()

small = [i for i in range(-1, X)]
big = [i for i in range(X+1, 101)]
small.reverse()
print(small)
print(big)
print(max(len(big),len(small)))
for i in range(max(len(big),len(small))):
    if not small[i] in p:
        print(small[i])
        exit()
    elif not big[i] in p:
        print(big[i])
        exit()

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

if len(p) == 0:
    print(X)
    exit()

if not X in p:
    print(X)
    exit()

small = [i for i in range(-101, X)]
big = [i for i in range(X+1, 102)]
small.reverse()
for i in range(max(len(big),len(small))):
    if not small[i] in p:
        print(small[i])
        exit()
    elif not big[i] in p:
        print(big[i])
        exit()

Buggy python submission (verdict: Runtime Error):
X, N = map(int, input().split())
p = list(map(int, input().split()))

if len(p) == 0:
    print(X)
    exit()

if not X in p:
    print(X)
    exit()

small = [i for i in range(1, X)]
big = [i for i in range(X+1, 101)]

small.reverse()
for i in range(max(len(big),len(small))):
    if not small[i] in p:
        print(small[i])
        exit()
    elif not big[i] in p:
        print(big[i])
        exit()

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

if len(p) == 0:
    print(X)
    exit()

if not X in p:
    print(X)
    exit()

small = [i for i in range(-101, X)]
big = [i for i in range(X+1, 102)]
small.reverse()
for i in range(max(len(big),len(small))):
    if not small[i] in p:
        print(small[i])
        exit()
    elif not big[i] in p:
        print(big[i])
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
c = collections.Counter(A)
cnt = 0
max = int(10e5+1)
l = [0] * (max+1)
for n in A:
    for j in range(n, max+1, n):
        l[j] += 1
for n in A:
    if c[n] > 1:
        continue
    if l[n] == 1:
        cnt += 1
print(cnt)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
cnt = 0
max = int(10e5+1)
l = [0] * (max+1)
for n in A:
    if l[n] != 0:
        l[n] = 2
        continue
    for j in range(n, max+1, n):
        l[j] += 1
for n in A:
    if l[n] == 1:
        cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
c = collections.Counter(A)
cnt = 0
for i in range(len(A)):
    if i == len(A) - 1:
        if c[A[i]] == 1:
            cnt += 1
    else:
        if c[A[i]] > 1:
            continue
        divide_flag = 0
        for j in range(i+1, len(A)):
            if A[i] % A[j] == 0:
                divide_flag = 1
                break
        if divide_flag == 0:
            cnt += 1
print(cnt)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
cnt = 0
max = int(10e5+1)
l = [0] * (max+1)
for n in A:
    if l[n] != 0:
        l[n] = 2
        continue
    for j in range(n, max+1, n):
        l[j] += 1
for n in A:
    if l[n] == 1:
        cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(N):
    divide_flag = 0
    for j in range(N):
        if i == j:
            continue
        if A[i] % A[j] == 0:
            divide_flag = 1
            break
    if divide_flag == 0:
        cnt += 1
print(cnt)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
cnt = 0
max = int(10e5+1)
l = [0] * (max+1)
for n in A:
    if l[n] != 0:
        l[n] = 2
        continue
    for j in range(n, max+1, n):
        l[j] += 1
for n in A:
    if l[n] == 1:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
ans = 1
if 0 in A:
    print(-1)
else:
    for i in A:
        ans *= i
        if ans > 1000000000000000000:
            print(-1)
            exit()
print(ans)

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

ans = 1
if 0 in A:
    print(0)
else:
    for i in A:
        ans *= i
        if ans > 1000000000000000000:
            print(-1)
            exit()
    print(ans)

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

ans = 1
for i in A:
    ans *= i
if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)

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

ans = 1
if 0 in A:
    print(0)
else:
    for i in A:
        ans *= i
        if ans > 1000000000000000000:
            print(-1)
            exit()
    print(ans)

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

ans = 1
for i in A:
    ans *= i
if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)

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

ans = 1
if 0 in A:
    print(0)
else:
    for i in A:
        ans *= i
        if ans > 1000000000000000000:
            print(-1)
            exit()
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
cnt = 0
N = int(input())
A = list(map(int, input().split()))
minus_list = [j - A[j] for j in range(N)]
for i in range(N):
    add = A[i] + i
    cnt += minus_list.count(add)
print(cnt)

Fixed submission:
from collections import Counter
cnt = 0
N = int(input())
A = list(map(int, input().split()))
minus_list = [j - A[j] for j in range(N)]
counter = Counter(minus_list)
for i in range(N):
    add = A[i] + i
    cnt += counter[add]
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
cnt = 0
N = int(input())
A = list(map(int, input().split()))
add_list = [A[i] + i for i in range(N)]
minus_list = [j - A[j] for j in range(N)]
for x in add_list:
    cnt += minus_list.count(x)
print(cnt)

Fixed submission:
from collections import Counter
cnt = 0
N = int(input())
A = list(map(int, input().split()))
minus_list = [j - A[j] for j in range(N)]
counter = Counter(minus_list)
for i in range(N):
    add = A[i] + i
    cnt += counter[add]
print(cnt)

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

Fixed submission:
from collections import Counter
cnt = 0
N = int(input())
A = list(map(int, input().split()))
minus_list = [j - A[j] for j in range(N)]
counter = Counter(minus_list)
for i in range(N):
    add = A[i] + i
    cnt += counter[add]
print(cnt)
Buggy python submission (verdict: Runtime Error):
import itertools
N, M, Q = map(int, input().split())
for i in range(Q):
    q_list.append(list(map(int, input().split())))

q_list = []
final_score = 0
for A in itertools.combinations_with_replacement(range(1,11), N):
    score = 0
    for q in q_list:
        if A[q[1]-1] - A[q[0]-1] == q[2]:
            score += q[3]
        final_score = max([final_score, score])
print(final_score)

Fixed submission:
import itertools
N, M, Q = map(int, input().split())
q_list = []
final_score = 0
for i in range(Q):
    q_list.append(list(map(int, input().split())))
for A in itertools.combinations_with_replacement(range(1,M+1), N):
    score = 0
    for q in q_list:
        if A[q[1]-1] - A[q[0]-1] == q[2]:
            score += q[3]
        final_score = max([final_score, score])
print(final_score)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
print(A.count(1))
for i in range(len(A)):
    print(A.count(i+2))

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

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
print(A.count(1))
for i, num in enumerate(A):
    ORG = A[:]
    ORG.pop(i)
    me = i + 2
    print(ORG.count(me))

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

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
print(len([n for n in A if n == 1]))
for i, num in enumerate(A):
    ORG = A[:]
    ORG.pop(i)
    me = i + 2
    print(ORG.count(me))

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

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
print(len([n for n in A if n == 1]))
for i, num in enumerate(A):
    ORG = A[:]
    ORG.pop(i)
    me = i + 2
    print(ORG.count(me))

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

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
print(len([n for n in A if n == 1]))
for i, num in enumerate(A):
    ORG = A[:]
    ORG.pop(i)
    me = i + 2
    sub = len([n for n in ORG if n == me])
    print(sub)

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

Fixed submission:
import math
N = int(input())
sum = 0
for i in range(1,N+1):
    for j in range(i,N+1):
        for k in range(j,N+1):
            if i == j and j == k and k == i:
                sum += math.gcd(math.gcd(i,j),k)
            elif i != j and j != k and k != i:
                sum += 6 * math.gcd(math.gcd(i,j),k)
            else:
                sum += 3 * math.gcd(math.gcd(i,j),k)
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
SL = list(S)
cnt = 0
nr = SL.count('R')
ng = SL.count('G')
nb = SL.count('B')
all = nr * ng * nb
cnt = 0
for i in range(len(S)):
    for j in range(i+1,len(S)):
        for k in range(j+1,len(S)):
            if (not (S[i] == S[j] or S[i] == S[k] or S[j] == S[k])) and (j-i) == (k-j):
                cnt += 1
print(all-cnt)

Fixed submission:
N = int(input())
S = input()
SL = list(S)
cnt = 0
nr = SL.count('R')
ng = SL.count('G')
nb = SL.count('B')
ans = nr * ng * nb
cnt = 0
for i in range(len(S)):
    for d in range(N):
        j = i + d
        k = j + d
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
cnt = 0
for i in range(len(S)):
    for j in range(i+1,len(S)):
        for k in range(j+1,len(S)):
            if S[i] != S[j] and S[i] != S[k] and S[j] != S[k] and (j-i) != (k-j):
                cnt += 1
print(cnt)

Fixed submission:
N = int(input())
S = input()
SL = list(S)
cnt = 0
nr = SL.count('R')
ng = SL.count('G')
nb = SL.count('B')
ans = nr * ng * nb
cnt = 0
for i in range(len(S)):
    for d in range(N):
        j = i + d
        k = j + d
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
cnt = 0
for i in range(len(S)):
    for j in range(i+1,len(S)):
        for k in range(j+1,len(S)):
            if S[i] != S[j] and S[i] != S[k] and S[j] != S[k] and (j-i) != (k-j):
                cnt += 1
print(cnt)

Fixed submission:
N = int(input())
S = input()
SL = list(S)
cnt = 0
nr = SL.count('R')
ng = SL.count('G')
nb = SL.count('B')
ans = nr * ng * nb
cnt = 0
for i in range(len(S)):
    for d in range(N):
        j = i + d
        k = j + d
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
N = len(S)
zen = S[:int((N-1)/2)]
kou = S[int((N+3)/2)-1:]
if S = S[::-1] and zen == zen[::-1] and kou == kou[::-1]:
    print("Yes")
else:
    print("No")

Fixed submission:
S = input()
N = len(S)
zen = S[:int((N-1)/2)]
kou = S[int((N+3)/2)-1:]
if S == S[::-1] and zen == zen[::-1] and kou == kou[::-1]:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
S = input()
N = len(S)
zen = S[:int((N-1)/2)]
kou = S[int((N+3)/2)-1:]
if zen == zen[::-1] and kou == kou[::-1]
    print("Yes")
else:
    print("No")

Fixed submission:
S = input()
N = len(S)
zen = S[:int((N-1)/2)]
kou = S[int((N+3)/2)-1:]
if S == S[::-1] and zen == zen[::-1] and kou == kou[::-1]:
    print("Yes")
else:
    print("No")