Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N=int(input())
if 1000-N%1000>0:
  print(1000-N%1000)
else print(0)

Fixed submission:
N=int(input())
if N%1000>0:
  print(1000-N%1000)
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
N=int(inpuit())
print(1000-N%1000)

Fixed submission:
N=int(input())
if N%1000>0:
  print(1000-N%1000)
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
AC = 0
WA = 0
TLE = 0
RE = 0
N = int(input())
for i in range(N):
	a = input()
	if(a == "AC"):
		AC = AC + 1
	if(a == "WA"):
 		WA = WA + 1
	if(a == "TLE"):
		TLE = TLE + 1
	if(a=="RE"):
		RE = RE + 1
print("AC x "+ str(AC))
print("WA x "+ str(WA))
print("TLE x "+ str(TLE))
print("RE x "+ str(RE))

Fixed submission:
N = int(input())
if(N%1000==0):
	print("0")
else:
  	print(1000-N%1000)

Buggy python submission (verdict: Runtime Error):
AC = 0
WA = 0
TLE = 0
RE = 0
N = int(input())
for i in range(N):
	a = input()
	if(a == "AC"):
		AC = AC + 1
	if(a == "WA"):
 		WA = WA + 1
	if(a == "TLE"):
		TLE = TLE + 1
	if(a=="RE"):
		RE = RE + 1
print("AC x "+ str(AC))
print("WA x "+ str(WA))
print("TLE x "+ str(TLE))
print("RE x "+ str(RE))

Fixed submission:
N = int(input())
if(N%1000==0):
	print("0")
else:
  	print(1000-N%1000)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if (a*b%2):
	printf("Even")
else:
	printf("Odd")

Fixed submission:
a, b = map(int, input().split())
if (a*b%2):
	print("Odd")
else:
	print("Even")
Buggy python submission (verdict: Runtime Error):
a = int(input())
ans = a*(1+a+a*a*)
print(ans)

Fixed submission:
a = int(input())
ans = a + (a*a) + (a*a*a)
print(ans)
Buggy python submission (verdict: Runtime Error):
a = input()
ans = upper(a)
if a == ans:
  print("A")
else:
  print("a") 

Fixed submission:
a = input()
ans = a.upper()
if a == ans:
  print("A")
else:
  print("a")

Buggy python submission (verdict: Runtime Error):
a = str(input())
ans = str(upper(a))
if a = ans:
  print("A")
else:
  print("a")

Fixed submission:
a = input()
ans = a.upper()
if a == ans:
  print("A")
else:
  print("a")

Buggy python submission (verdict: Runtime Error):
a = input()
ans = upper(a)
if a = ans:
  print("A")
else:
  print("a")

Fixed submission:
a = input()
ans = a.upper()
if a == ans:
  print("A")
else:
  print("a")
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

N = int(input())
L_list = list(map(int,input().split()))
L_list.sort()
ans = 0
list = []
M = 0

for i in range(N-1):
    for j in range(N-i-1):
        list.append((L_list[i]+L_list[j+i+1],i,j+i+1))
        M += 1

for k in range(N):
    for z in range(M):
        if L_list[k] < list[z][0]:
            if (k > list[z][2]):
                ans += 1

print(ans)



Fixed submission:
import bisect

N = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        insert_index = bisect.bisect_left(l, l[i] + l[j],j) #l[i] + l[j]を挿入できる点を探す。同じ者がlにすでにある時は、一番左になるようにする
        ans += (insert_index - j - 1)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L_list = list(map(int,input().split()))
ans = 0
L_list.sort()

for i in range(N-2):
    J = i+1
    for x in range(N-i-1):
        j = J+x
        K = j+1
        for y in range(N-j-1):
            k = K+y
            if L_list[i] + L_list[j] > L_list[k]:
                ans += 1
            else:
                break

print(ans)

Fixed submission:
import bisect

N = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        insert_index = bisect.bisect_left(l, l[i] + l[j],j) #l[i] + l[j]を挿入できる点を探す。同じ者がlにすでにある時は、一番左になるようにする
        ans += (insert_index - j - 1)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

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

ans = [A_list.index(i+1)+1 for i in range(N)]

for i in range(N):
    print(ans[i], end=" ")

Fixed submission:
import heapq
N = int(input())

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

list = [(A_list[i],i+1) for i in range(N)]
heapq.heapify(list)

for i in range(N):
    print(heapq.heappop(list)[1], end=" ")

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

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

# ans = [A_list.index(i+1)+1 for i in range(N)]
#
# print(ans)

for i in range(N):
    print(A_list.index(i + 1) + 1,end=" ")


Fixed submission:
import heapq
N = int(input())

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

list = [(A_list[i],i+1) for i in range(N)]
heapq.heapify(list)

for i in range(N):
    print(heapq.heappop(list)[1], end=" ")
Buggy python submission (verdict: Time Limit Exceeded):
def minus(n):
    return n-1

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

A_list = [int(input()) for i in range(Q)]
Point_list = [K for i in range(N)]

for j in range(Q):
    Point_list = list(map(minus,Point_list))
    Point_list[A_list[j]-1] += 1

for j in range(N):
    if Point_list[j] <= 0:
        print("No")

    else:
        print("Yes")


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

A_list = [int(input()) for i in range(Q)]
Point_list = [K-Q for i in range(N)]

for j in range(Q):
    Point_list[A_list[j]-1] += 1

for j in range(N):
    if Point_list[j] <= 0:
        print("No")

    else:
        print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

sum = 0

for i in range(N):
    if i == N-1:
        sum += 0
    else:
        sum += (i+1)%(i+2)

print(sum)


# りゅうせいの解答1　実行時間超過
#  N = int(input())
#
# P_list = []
# M_list = []
#
#
# for i in range(N):
#     if i == N-1:
#         P_list.append(1)
#
#     else:
#         P_list.append(i+2)
#
#
# for i in range(N):
#     M_list.append((i+1) % P_list[i])
#
# print(sum(M_list))

Fixed submission:
N = int(input())

mod_sum = N*(N-1)//2
print(mod_sum)

#りゅうせいの解答2 不正解2つあり
# N = int(input())
#
# mod_sum = int(N*(N-1)/2)
# print(mod_sum)

# りゅうせいの解答1　実行時間超過
#  N = int(input())
#
# P_list = []
# M_list = []
#
#
# for i in range(N):
#     if i == N-1:
#         P_list.append(1)
#
#     else:
#         P_list.append(i+2)
#
#
# for i in range(N):
#     M_list.append((i+1) % P_list[i])
#
# print(sum(M_list))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

P_list = []
M_list = []


for i in range(N):
    if i == N-1:
        P_list.append(1)

    else:
        P_list.append(i+2)


for i in range(N):
    M_list.append((i+1) % P_list[i])

print(sum(M_list))

Fixed submission:
N = int(input())

mod_sum = N*(N-1)//2
print(mod_sum)

#りゅうせいの解答2 不正解2つあり
# N = int(input())
#
# mod_sum = int(N*(N-1)/2)
# print(mod_sum)

# りゅうせいの解答1　実行時間超過
#  N = int(input())
#
# P_list = []
# M_list = []
#
#
# for i in range(N):
#     if i == N-1:
#         P_list.append(1)
#
#     else:
#         P_list.append(i+2)
#
#
# for i in range(N):
#     M_list.append((i+1) % P_list[i])
#
# print(sum(M_list))
Buggy python submission (verdict: Time Limit Exceeded):
N , M = map(int,input().split())

AB_list =[]
for i in range(N):
    AB_list.append(tuple(map(int,input().split())))

AB_list.sort()
#print(AB_list)
ans = 0

for i in range(M):
    hoshu = 0
    t = 0
    flag = False
    for j in range(N):
        if (AB_list[j][0] <= i+1):
            if hoshu <= AB_list[j][1]:
                hoshu = AB_list[j][1]
                t = j
                flag = True

        else:
            break

    if flag:
        del AB_list[t]
        N -= 1
    #print(hoshu, t)
    ans += hoshu
    #print(AB_list)

print(ans)






Fixed submission:
import heapq

# 標準入力受け取り
N, M = list(map(int, input().split()))
jobs = [[] for _ in range(M)]  #日数分(M)だけ[]を用意
# print(jobs)

for i in range(N):
    d, r = list(map(int, input().split()))   #d = A[i], r = B[i]
    if d - 1 < M:   #d-1番目の要素にrを追加して、同じ受け取り日数のバイトを同じ要素に入れる。d-1より、2日後のはjobs[1]におかれる。
        jobs[d - 1].append(-r)  # マイナスにしている
# print(jobs)

rewards = 0
heap = []

# 解法
for i in range(M):
    # 要素を一つづつヒープに追加
    for reward in jobs[i]:
        heapq.heappush(heap, reward)
    # print(heap)
    if len(heap) > 0:
        # 最大値(最小値)をヒープから取り出し
        reward = heapq.heappop(heap)
        rewards += -reward  # マイナスにしている
    # print(heap)

print(rewards)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, D = map(int,input().split())

ans = 0
j = A
while j <= B:
    count = 0
    if j%C:
        count += 1
    if j%D:
        count += 1

    if count == 2:
        ans += 1

    j+= 1

print(ans)

Fixed submission:
#考え方
#（BについてCでもDでも割り切れない数の個数）-（についてCでもDでも割り切れない数の個数）
#↑それぞれは、B -（B//C + B//D - B//lcm(C,D)) 、　A -（A//C + A//D - A//lcm(C,D))で出せる

def gcd(x, y):
    if x%y == 0:
        return y

    else:
        return gcd(y,x%y)



A, B, C, D = map(int,input().split())

if C < D:
    t = C
    C = D
    D = t

max_ky = gcd(C,D)

#最小公倍数
lcm_c = C//max_ky
lcm_d = D//max_ky
lcm = max_ky * lcm_c * lcm_d

count_b = B - (B//C + B//D - B//lcm)
count_a = A - (A//C + A//D - A//lcm)
if(A%C != 0 and A%D != 0):
    count_a -= 1
ans = count_b - count_a

print(ans)






#りゅうせいの解答1 実行時間超過
#A, B, C, D = map(int,input().split())
# ans = 0
# j = A
# while j <= B:
#     count = 0
#     if j%C:
#         count += 1
#     if j%D:
#         count += 1
#
#     if count == 2:
#         ans += 1
#
#     j+= 1
#
# print(ans)
Buggy python submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())

# 面積は必ず二等分可能
# 面積を二等分する直線は長方形の中心を通る
ans = '{} {}'.format(
    W * H / 2,
    1 if x == W / 2 and y == H / 2 else
    0
)

# 出力
print(ans)

Fixed submission:
x, a = input().split()

if(x < a):
    print(0)
else:
    print(10)

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

x = sys.argv[1]
a = sys.argv[2]

if(x < a):
    print(0)
else:
    print(10)
    

Fixed submission:
x, a = input().split()

if(x < a):
    print(0)
else:
    print(10)
Buggy python submission (verdict: Time Limit Exceeded):
from math import *
from heapq import *

def mi():
    return map(int, input().split())
def ii():
    return int(input())
def li():
    return list(mi())
def gcd(a,b):return a if(not b) else gcd(b,a%b)
def qw(a,b,p):
    '''quick pow'''
    ans = 1
    while b:
        if b & 1:
            ans = ans * a % p
        a = a * a % p
        b >>= 1
    return ans
def is_prime(x):
    if(x < 2): return 0
    for i in range(2,int(sqrt(x)+1)):
        if(x % i == 0) : return 0
    return 1

n = ii()
a = li()
ans = 1
for i in range(0,n):
    ans = ans * a[i]
if(ans > 1000000000000000000):print(-1)
else: print(ans)





Fixed submission:
from math import *
from heapq import *

def mi():
    return map(int, input().split())
def ii():
    return int(input())
def li():
    return list(mi())
def gcd(a,b):return a if(not b) else gcd(b,a%b)
def qw(a,b,p):
    '''quick pow'''
    ans = 1
    while b:
        if b & 1:
            ans = ans * a % p
        a = a * a % p
        b >>= 1
    return ans
def is_prime(x):
    if(x < 2): return 0
    for i in range(2,int(sqrt(x)+1)):
        if(x % i == 0) : return 0
    return 1

n = ii()
a = li()
ans = 1
ok = 1
a.sort()
for i in range(0,n):
    ans = ans * a[i]
    if(ans > 1000000000000000000):
        ok = 0
        break
# print(ans)
if(ok == 0):print(-1)
else: print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from math import *
from heapq import *

def mi():
    return map(int, input().split())
def ii():
    return int(input())
def li():
    return list(mi())
def gcd(a,b):return a if(not b) else gcd(b,a%b)
def qw(a,b,p):
    '''quick pow'''
    ans = 1
    while b:
        if b & 1:
            ans = ans * a % p
        a = a * a % p
        b >>= 1
    return ans
def is_prime(x):
    if(x < 2): return 0
    for i in range(2,int(sqrt(x)+1)):
        if(x % i == 0) : return 0
    return 1

n = ii()
a = li()
ans = 1
for i in range(0,n):
    ans = ans * a[i]
if(ans > 1000000000000000000):print(-1)
else: print(ans)





Fixed submission:
from math import *
from heapq import *

def mi():
    return map(int, input().split())
def ii():
    return int(input())
def li():
    return list(mi())
def gcd(a,b):return a if(not b) else gcd(b,a%b)
def qw(a,b,p):
    '''quick pow'''
    ans = 1
    while b:
        if b & 1:
            ans = ans * a % p
        a = a * a % p
        b >>= 1
    return ans
def is_prime(x):
    if(x < 2): return 0
    for i in range(2,int(sqrt(x)+1)):
        if(x % i == 0) : return 0
    return 1

n = ii()
a = li()
ans = 1
ok = 1
a.sort()
for i in range(0,n):
    ans = ans * a[i]
    if(ans > 1000000000000000000):
        ok = 0
        break
# print(ans)
if(ok == 0):print(-1)
else: print(ans)
Buggy python submission (verdict: Runtime Error):
ans = 0
for i in range(5):
	if int(input()) == 0:
		ans = i+1
print(ans)  


Fixed submission:
a = list(map(int, input().split()))
for i in range(5):
  if a[i] == 0:
    print(i+1)

Buggy python submission (verdict: Runtime Error):
ans = 0
for i in range(5):
  a = int(input())
  if a == 0:
    ans = i+1
print(ans)  


Fixed submission:
a = list(map(int, input().split()))
for i in range(5):
  if a[i] == 0:
    print(i+1)

Buggy python submission (verdict: Runtime Error):
ans = 0
for i in range(5):
  if int(input()) == 0:
    ans = i+1
print(ans)  

Fixed submission:
a = list(map(int, input().split()))
for i in range(5):
  if a[i] == 0:
    print(i+1)
Buggy python submission (verdict: Runtime Error):
import sys
X, Y = map(int, input().split())
for i in range(X+1):
  j = X - i
  if 2*i+4*j == Y:
    print('Yes')
    sys.exit()
print('No")

Fixed submission:
import sys
X, Y = map(int, input().split())
for i in range(X+1):
  j = X - i
  if 2*i+4*j == Y:
    print('Yes')
    sys.exit()
print('No')
Buggy python submission (verdict: Runtime Error):
import sys
N = int(input())
A = list(map(int, input().split()))
A.sort(reversed=True)
res = 1
for a in A:
  res *= a
  if res > 1e18:
    print(-1)
    sys.exit()
print(res)

Fixed submission:
import sys
N = int(input())
A = list(map(int, input().split()))
A.sort()
res = 1
for a in A:
  res *= a
  if res > 1e18:
    print(-1)
    sys.exit()
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
res = 1
for a in A:
  res *= a
if res > 1e18:
  print(-1)
else:
  print(res)

Fixed submission:
import sys
N = int(input())
A = list(map(int, input().split()))
A.sort()
res = 1
for a in A:
  res *= a
  if res > 1e18:
    print(-1)
    sys.exit()
print(res)
Buggy python submission (verdict: Runtime Error):
#include<bits/stdc++.h>

using namespace std;

long long n, a, b;

int main(){
	cin >> n >> a >> b;
	cout << a*n/(a+b)+min(a, n%(a+b)) << endl;
}

Fixed submission:
N, A, B = map(int, input().split())
print(N//(A+B)*A+min(A, N%(A+B)))
Buggy python submission (verdict: Runtime Error):
N = int(input())
e = list(map(int,input().split()))
for i in range(N):
    x = int(input())
    e.append(x)
e.sort()
for i in range(N - 1):
    a = e.pop(0)
    b = e.pop(0)
    e.insert(0, (a+b)/2)
ans = e[0]
print(ans)

Fixed submission:
N = int(input())
e = list(map(int,input().split()))
e.sort()
for i in range(N - 1):
    a = e.pop(0)
    b = e.pop(0)
    e.insert(0, (a+b)/2)
ans = e[0]
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
e = list()
for i in range(N):
    x = int(input())
    e.append(x)
e.sort()
for i in range(N - 1):
    a = e.pop(0)
    b = e.pop(0)
    e.insert(0, (a+b)/2)
ans = e[0]
print(ans)

Fixed submission:
N = int(input())
e = list(map(int,input().split()))
e.sort()
for i in range(N - 1):
    a = e.pop(0)
    b = e.pop(0)
    e.insert(0, (a+b)/2)
ans = e[0]
print(ans)
Buggy python submission (verdict: Runtime Error):
m = int(input())

d = [input() fot i in range(m)]

print('AC x ', d.count("AC"))
print('WA x ', d.count("WA"))
print('TLE x ', d.count("TLE"))
print('RE x ', d.count("RE"))


Fixed submission:
m = int(input())

d = [input() for i in range(m)]

print('AC x ', d.count("AC"))
print('WA x ', d.count("WA"))
print('TLE x ', d.count("TLE"))
print('RE x ', d.count("RE"))

Buggy python submission (verdict: Runtime Error):
m = int(input())

d = [input() fot i in range(m)]

print("AC x " + d.count("AC"))
print("WA x " + d.count("WA"))
print("TLE x " + d.count("TLE"))
print("RE x " + d.count("RE"))

Fixed submission:
m = int(input())

d = [input() for i in range(m)]

print('AC x ', d.count("AC"))
print('WA x ', d.count("WA"))
print('TLE x ', d.count("TLE"))
print('RE x ', d.count("RE"))
Buggy python submission (verdict: Runtime Error):
S = int(input())

if S.count(5) == 2 && S.count(7):
  print("YES")
else:
  print("NO")

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

if S.count(5) == 2 and S.count(7):
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
N, M, K = map(int,input().split())

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

X = 0
I = 0
J = 0



def read(i,j,k,x):
  
#  print('i',i,' j',j,' k',k,' x',x)
  
  if i == len(A):
    ans1 = x
  else:
    if k >= A[i]:
      ans1 = read(i+1,j,k-A[i],x+1)
    else:
      ans1 = x
  
  if j == len(B):
    ans2 = x
  else:
    if k >= B[j]:
      ans2 = read(i,j+1,k-B[j],x+1)
    else:
      ans2 = x
  
  return max(ans1,ans2)
  
print(read(I,J,K,0))

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

A = list(map(int,input().split()))
A.insert(0, 0)
B = list(map(int,input().split()))
a = []
b = []

def nibun(L,l,r,target):

  wrk = -(-(l+r)//2)
  
#  print(l,r,target,wrk)
  
  if r == l:
    if r == len(L):
      return 0
    else:
      return wrk + 1
  
  if l == (len(L)-1):
    if L[wrk-1] > target:
      return wrk
    else:
      return 0

  if L[wrk] == target:
    return wrk+1

  elif L[wrk] > target:
    return nibun(L,l,wrk-1,target)

  else:
    return nibun(L,wrk,r,target)

  
s = 0
for i,e in enumerate(B):
  s += e 
  b.append(s)

s = 0
ans = 0
for i in range(len(A)):
#  print(i,'kaime')
#  print(s,i,A[i])
  s += A[i]
  if s > K:
    break
  else:  
    wrk = nibun(b,-1,len(b),K-s)
    
    ans=max(ans,i+wrk)
#    print('koko',s,wrk,ans)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,k = map(int, input().split())

ans = 0

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

print(ans)

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

ans = 0

if k < a:
  ans = k

elif k <= a+b:
  ans = a
else:
  ans = a - (1 * (k - a -b) )
  


print(ans)
Buggy python submission (verdict: Runtime Error):
s = int(input())
#print(s)

N=1000
d=[0]*N


for i in range(N):
  d[i]=i**5
  
for i in range(N):
  for j in range(i,N):
    if (d[i] + d[j] == s) :
      print(i,-j)
      sys.exit
    elif (d[i] - d[j] == s):
      print(i,j)
      sys.exit
    elif (d[j] + d[i] == s):
      print(j,-i)
      sys.exit
    elif (d[j] - d[i] == s):
      print(j,i)
      sys.exit

Fixed submission:
import sys

s = int(input())
#print(s)

N=1000
d=[0]*N


for i in range(N):
  d[i]=i**5
  
for i in range(N):
  for j in range(i,N):
    if (d[i] + d[j] == s) :
      print(i,-j)
      sys.exit
    elif (d[i] - d[j] == s):
      print(i,j)
      sys.exit
    elif (d[j] + d[i] == s):
      print(j,-i)
      sys.exit
    elif (d[j] - d[i] == s):
      print(j,i)
      sys.exit

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

s = int(input())
#print(s)

N=10000
d=[0]*N


for i in range(N):
  d[i]=i**5
  
for i in range(N):
  for j in range(i,N):
    if (d[i] + d[j] == s) :
      print(i,-j)
      sys.exit
    elif (d[i] - d[j] == s):
      print(i,j)
      sys.exit
    elif (d[j] + d[i] == s):
      print(j,-i)
      sys.exit
    elif (d[j] - d[i] == s):
      print(j,i)
      sys.exit

Fixed submission:
import sys

s = int(input())
#print(s)

N=1000
d=[0]*N


for i in range(N):
  d[i]=i**5
  
for i in range(N):
  for j in range(i,N):
    if (d[i] + d[j] == s) :
      print(i,-j)
      sys.exit
    elif (d[i] - d[j] == s):
      print(i,j)
      sys.exit
    elif (d[j] + d[i] == s):
      print(j,-i)
      sys.exit
    elif (d[j] - d[i] == s):
      print(j,i)
      sys.exit
Buggy python submission (verdict: Runtime Error):
flg = 0
for s in n:
    if s == '7':
        print(s)
        flg = 1

if flg == 1:
      print('Yes')
else:
      print('No')


Fixed submission:
n=input()
flg = 0
for s in n:
    if s == '7':
        flg = 1
 
if flg == 1:
      print('Yes')
else:
      print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
num=[0]*3

for i,co in enumerate(('R','G','B')):
  for c in s:
    if c == co:
      num[i] +=1
      
all = num[0]*num[1]*num[2]

ot = 0
i=1
while i*2 +1 <= len(s):
  idx = 0
  #print(i)
  while idx + i*2 < len(s):
    #print('index',idx)
    wk = s[idx]+s[idx+i]+s[idx+2*i]
    #print(wk)
    if ('R' in wk) and ('G' in wk) and ('B' in wk):
      ot +=1
    idx +=1
  i += 1
  
print(all-ot)

Fixed submission:
n = int(input())
s = input()
num=[0]*3

for i,co in enumerate(('R','G','B')):
  for c in s:
    if c == co:
      num[i] +=1
      
all = num[0]*num[1]*num[2]

ot = 0
i=1
while i*2 +1 <= len(s):
  idx = 0
  #print(i)
  while idx + i*2 < len(s):
    #print('index',idx)
    wk = s[idx]+s[idx+i]+s[idx+2*i]
    #print(wk)
    if ('R' in wk) and ('G' in wk) and ('B' in wk):
      ot +=1
    idx +=1
  i += 1
  
print(all-ot)
Buggy python submission (verdict: Runtime Error):
k , n = (int(x) for x in input().split())
a = [int(i) for i in input().split()]
b = []

for i in range(n-1):
    b.append(a[i+1] - a[i])
    
b.append(a[0] + k -a[n-1])

ans=0

b.sort()

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

Fixed submission:
s = input()

if s[2] == s[3]:
    
    if s[4] == s[5]:
        print('Yes')
    else:
        print('No')

else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
k , n = (int(x) for x in input().split())
a = [int(i) for i in input().split()]

b = []
  
for i in range(n-1):
    b.append(a[i+1] - a[i])
    
b.append(a[0] + k -a[n-1])
 
lans=0
ans = 999999999999
 
for i in range(len(b)):
    lans = 0
    for j in range(len(b)):
        if i != j:
            lans = b[j] + lans
    ans = min(ans,lans)
    
print(ans)

Fixed submission:
k , n = (int(x) for x in input().split())
a = [int(i) for i in input().split()]
b = []
 
for i in range(n-1):
    b.append(a[i+1] - a[i])
    
b.append(a[0] + k -a[n-1])

ans=0 
b.sort()
 
for i in range(len(b)-1):
    ans = b[i] + ans

print(ans)

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

for i in range(n-1):
    b.append(a[i+1] - a[i])
    
b.append(a[0] + k -a[n-1])

lans=0
ans = 999999999999

for i in range(len(b)):
    lans = 0
    for j in range(len(b)):
        if i != j:
            lans = b[j] + lans
    ans = min(ans,lans)
    
print(ans)

Fixed submission:
k , n = (int(x) for x in input().split())
a = [int(i) for i in input().split()]
b = []
 
for i in range(n-1):
    b.append(a[i+1] - a[i])
    
b.append(a[0] + k -a[n-1])

ans=0 
b.sort()
 
for i in range(len(b)-1):
    ans = b[i] + ans

print(ans)