Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict, deque
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate
import sys


def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007



n, w = LI()
weight, value = list(zip(*LIR(n)))
dp = (w + 1) * [0]
for i in range(n):
    for j in range(w, weight[i]-1, -1):
        dp[j] = max(dp[j], dp[j - weight[i]] + value[i])



print(dp[-1])

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



n, limit = LI()
weight = []
value = []
for w, v in LIR(n):
    weight += [w]
    value += [v]


w1 = min(weight)
w2, w3, w4 = w1 + 1, w1 + 2, w1 + 3
w1_list = [0] + list(accumulate(sorted([value[i] for i in range(n) if weight[i] == w1], reverse=True)))
w2_list = [0] + list(accumulate(sorted([value[i] for i in range(n) if weight[i] == w2], reverse=True)))
w3_list = [0] + list(accumulate(sorted([value[i] for i in range(n) if weight[i] == w3], reverse=True)))
w4_list = [0] + list(accumulate(sorted([value[i] for i in range(n) if weight[i] == w4], reverse=True)))


ans = 0
for i, j, k, l in product(range(len(w1_list)), range(len(w2_list)), range(len(w3_list)), range(len(w4_list) )):
    if i * w1 + j * w2 + k * w3 + l * w4 > limit:
        continue
    ans = max(ans, w1_list[i] + w2_list[j] + w3_list[k] + w4_list[l])



print(ans)
Buggy python submission (verdict: Runtime Error):
normal_ant = [i for i, direction in ants if direction==1]
counter_ant = [i for i, direction in ants if direction==2]
cnt = (t // l) * len(normal_ant) + sum([1 for i in normal_ant if i + t%l >= l])
counter_cnt = (t // l) * len(counter_ant) + sum([1 for i in counter_ant if i - t%l < 0])
final_pos = sorted([(i-t)%l for i in counter_ant] + [(i+t)%l for i in normal_ant])
print(*final_pos[(cnt-counter_cnt)%n:] + final_pos[:(cnt-counter_cnt)%n], sep='\n')

Fixed submission:
n, l, t = list(map(int, input().split()))
ants = []
for i in range(n):
    ants.append(list(map(int, input().split())))
normal_ant = [i for i, direction in ants if direction==1]
counter_ant = [i for i, direction in ants if direction==2]
cnt = (t // l) * len(normal_ant) + sum([1 for i in normal_ant if i + t%l >= l])
counter_cnt = (t // l) * len(counter_ant) + sum([1 for i in counter_ant if i - t%l < 0])
final_pos = sorted([(i-t)%l for i in counter_ant] + [(i+t)%l for i in normal_ant])
print(*final_pos[(cnt-counter_cnt)%n:] + final_pos[:(cnt-counter_cnt)%n], sep='\n')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n = I()
G = [[] for _ in range(n)]
win_against = [[] for _ in range(n)]
A = IR(n - 1)
for i in range(n - 1):
    win_against[A[i] - 1] += [i + 1]

def f(x):
    ret = 0
    s = sorted([f(u) for u in win_against[x]])
    for k in range(1, len(win_against[x]) + 1):
        ret = max(ret, s.pop() + k)
    return ret

print(f(0))


Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n = I()
G = [[] for _ in range(n)]
win_against = [[] for _ in range(n)]
A = IR(n - 1)
for i in range(n - 1):
    win_against[A[i] - 1] += [i + 1]

def f(x):
    ret = 0
    s = sorted([f(u) for u in win_against[x]])
    for k in range(1, len(win_against[x]) + 1):
        ret = max(ret, s.pop() + k)
    return ret

print(f(0))
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce
from scipy.sparse.csgraph import floyd_warshall, csgraph_from_dense


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, m = LI()
graph = [[INF] * n for _ in range(n)]
for i in range(n):
    graph[i][i] = 0


for a, b, c in LIR(m):
    graph[a - 1][b - 1] = c
    graph[b - 1][a - 1] = c


dist = [[graph[i][j] for j in range(n)] for i in range(n)]




for i in range(n):
    for j in range(n):
        for k in range(n):
            dist[j][k]=min(dist[j][i]+dist[i][k], dist[j][k])



cnt = 0
for i in range(n):
    for j in range(i, n):
        if graph[i][j] != INF and graph[i][j] > dist[i][j]:
            cnt += 1


print(cnt)

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, m = LI()
graph = [[INF] * n for _ in range(n)]
for i in range(n):
    graph[i][i] = 0


for a, b, c in LIR(m):
    graph[a - 1][b - 1] = c
    graph[b - 1][a - 1] = c


dist = [[graph[i][j] for j in range(n)] for i in range(n)]




for i in range(n):
    for j in range(n):
        for k in range(n):
            dist[j][k]=min(dist[j][i]+dist[i][k], dist[j][k])



cnt = 0
for i in range(n):
    for j in range(i, n):
        if graph[i][j] != INF and graph[i][j] > dist[i][j]:
            cnt += 1


print(cnt)
Buggy python submission (verdict: Runtime Error):
a,b,c,k=[int(i) for i in input().split()]
print(k if k<= a else a if k <=a+b else 2a+b-k)

Fixed submission:
a,b,c,k=[int(i) for i in input().split()]
print(k if k<=a else a if k <=a+b else 2*a+b-k)
Buggy python submission (verdict: Runtime Error):
from itertools import product as pr
n,m,x=[int(i) for i in input().split()]
l=[[int(i) for i in input().split()]for j in range(n)]
p=list(pr([0,1],repeat=n))
suml=[[sum([l[j][k]*i[j] for j in range(n)])for k in range(m+1)]for i in p]
ans=[i[0] for i in suml if all([i[j] >=x for j in range(1,n+1)])]
if len(ans)==0:
  print(-1)
else:
  print(min(ans))

Fixed submission:
from itertools import product as pr
n,m,x=[int(i) for i in input().split()]
l=[[int(i) for i in input().split()]for j in range(n)]
p=list(pr([0,1],repeat=n))
suml=[[sum([l[j][k]*i[j] for j in range(n)])for k in range(m+1)]for i in p]
ans=[i[0] for i in suml if all([i[j] >=x for j in range(1,m+1)])]
if len(ans)==0:
  print(-1)
else:
  print(min(ans))

Buggy python submission (verdict: Runtime Error):
from itertools import product as pr
n,m,x=[int(i) for i in input().split()]
l=[[int(i) for i in input().split()]for j in range(n)]
p=list(pr([0,1],repeat=n))
suml=[[sum([l[j][k]*i[j] for j in range(n)])for k in range(m+1)]for i in p]
ans=min([i[0] for i in suml if all([i[j] >=x for j in range(1,6)])])
print(ans)

Fixed submission:
from itertools import product as pr
n,m,x=[int(i) for i in input().split()]
l=[[int(i) for i in input().split()]for j in range(n)]
p=list(pr([0,1],repeat=n))
suml=[[sum([l[j][k]*i[j] for j in range(n)])for k in range(m+1)]for i in p]
ans=[i[0] for i in suml if all([i[j] >=x for j in range(1,m+1)])]
if len(ans)==0:
  print(-1)
else:
  print(min(ans))

Buggy python submission (verdict: Runtime Error):
from itertools import *
n,m,x=[int(i) for i in input().split()]
l=[[int(i) for i in input().split()] for j in range(n)]
c=[i[0] for i in l]
l=[i[1:] for i in l]
p=list(product([0,1],repeat=m))
s=[[sum([l[k][j]*i[j] for k in range(n)]) for j in range(m)] for i in p]
print(s)
s=[c[i] for i in range(n) if all([s[i][j]>=x for j in range(m)])]
print(s)

Fixed submission:
from itertools import product as pr
n,m,x=[int(i) for i in input().split()]
l=[[int(i) for i in input().split()]for j in range(n)]
p=list(pr([0,1],repeat=n))
suml=[[sum([l[j][k]*i[j] for j in range(n)])for k in range(m+1)]for i in p]
ans=[i[0] for i in suml if all([i[j] >=x for j in range(1,m+1)])]
if len(ans)==0:
  print(-1)
else:
  print(min(ans))
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=map(int,input().split())
m=map(int,input().split())
def f(x):
	return l[x]-m[x]
print(sum([f(i) for i in range(n) if f(i)>0]))

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
m=list(map(int,input().split()))
def f(x):
	return l[x]-m[x]
print(sum([f(i) for i in range(n) if f(i)>0]))
Buggy python submission (verdict: Runtime Error):
*l=map(int,open(0))
while len(l)==0:
	ans=max(ans,max(l))
	l.remove(max(l))
	map(lambda x:x+10,l)
print(ans)

Fixed submission:
l=sorted(list(map(int,open(0))),key=lambda x:-x%10)
print(sum([i+(-i%10) for i in l[:4]])+l[4])
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
q = int(input())
dic = [0 for _ in range(10 ** 5)]
count = 0
for i in a:
    dic[i] += 1
    count += i

for i in range(q):
    b, c = map(int,input().split())
    count -= b * dic[b]
    dic[c] += dic[b]
    count += c * dic[b]
    dic[b] = 0
    print(count)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
q = int(input())
dic = [0 for _ in range(10 ** 5 + 1)]
count = 0
for i in a:
    dic[i] += 1
    count += i

for i in range(q):
    b, c = map(int,input().split())
    count -= b * dic[b]
    dic[c] += dic[b]
    count += c * dic[b]
    dic[b] = 0
    print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
q = int(input())
for i in range(q):
    b, c = map(int,input().split()) 
    while b in a:
        s = a.index(b)
        a[s] = c

    print(sum(a))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
q = int(input())
dic = [0 for _ in range(10 ** 5 + 1)]
count = 0
for i in a:
    dic[i] += 1
    count += i

for i in range(q):
    b, c = map(int,input().split())
    count -= b * dic[b]
    dic[c] += dic[b]
    count += c * dic[b]
    dic[b] = 0
    print(count)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
count=(a*(b**100))//100
print(count)

Fixed submission:
from decimal import Decimal as Dec
from math import floor
a,b=input().split()
a=int(a)
b=Dec(b)
print(floor(a*b))

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(a*(b*100)//100)

Fixed submission:
from decimal import Decimal as Dec
from math import floor
a,b=input().split()
a=int(a)
b=Dec(b)
print(floor(a*b))

Buggy python submission (verdict: Runtime Error):
a,b=map(int,ipnut().split())
print(a*(b*100)//100)

Fixed submission:
from decimal import Decimal as Dec
from math import floor
a,b=input().split()
a=int(a)
b=Dec(b)
print(floor(a*b))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
rec = [0]
i = 0
flag = [0 for _ in range(n + 1)]
while True:
    if flag[rec[i]] == 0:
        flag[rec[i]] = 1
        rec.append(a[rec[i]] - 1)
    else:
        start = rec.index(a[rec[i]] - 1)
        loop = rec[start:]
        pre = rec[:start]
        break
    i += 1
count = (k - len(pre)) % len(loop)
if k < len(pre):
    print(loop[k])
else:
    print(loop[count] + 1)


Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
rec = [0]
i = 0
flag = [0 for _ in range(n + 1)]
while True:
    if flag[rec[i]] == 0:
        flag[rec[i]] = 1
        rec.append(a[rec[i]] - 1)
    else:
        start = rec.index(a[rec[i]] - 1)
        loop = rec[start:]
        pre = rec[:start]
        break
    i += 1
count = (k - len(pre)) % len(loop)
if k <= len(pre):
    print(pre[k] + 1)
else:
    print(loop[count] + 1)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
rec = [0]
i = 0
flag = [0 for _ in range(n + 1)]
while True:
    if flag[rec[i]] == 0:
        flag[a[i]] = 1
        rec.append(a[rec[i]] - 1)
    else:
        start = rec.index(a[rec[i]] - 1)
        loop = rec[start:]
        pre = rec[:start]
        break
    i += 1
count = (k - len(pre)) % len(loop)
print(loop[count] + 1)


Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
rec = [0]
i = 0
flag = [0 for _ in range(n + 1)]
while True:
    if flag[rec[i]] == 0:
        flag[rec[i]] = 1
        rec.append(a[rec[i]] - 1)
    else:
        start = rec.index(a[rec[i]] - 1)
        loop = rec[start:]
        pre = rec[:start]
        break
    i += 1
count = (k - len(pre)) % len(loop)
if k <= len(pre):
    print(pre[k] + 1)
else:
    print(loop[count] + 1)
Buggy python submission (verdict: Time Limit Exceeded):
X=int(input())
for j in range(2,int(X**0.5)+1):
    if X%j==0:
        for a in range(X):
            b=a-j
            S=j*(a**4+b**4+(a**3)*b+(a**2)*(b**2)+a*(b**3))
            if S==X:
                print(a,b)
                exit(0)
if X==1:
    print(0,-1)



Fixed submission:
X=int(input())
for j in range(int(X**0.5)+2,0,-1):
    if X%j==0:
        for a in range(2*(10**4)):
            b=a-j
            S=j*(a**4+b**4+(a**3)*b+(a**2)*(b**2)+a*(b**3))
            if S==X:
                print(a,b)
                exit(0)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
sum1=0
for k in range(K,N+2,1):
    sum1+=(N-k+1)*k+1
print(sum1%(10**9+7))

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

buka=[0]*N
for i in A:
    buka[i-1]=buka[i-1]+1
for i in range(N):
    print(buka[i])
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=str(input())
list_R=[]
list_G=[]
list_B=[]
count=0
for i in range(N):
    if S[i]=="R":
        list_R.append(i)
    if S[i]=="G":
        list_G.append(i)
    if S[i]=="B":
        list_B.append(i)
for i in range(N):
    for j in range(N):
        if i+2*j>N-1:
            break
        if S[i]!=S[i+j] and S[i+j]!=S[i+j*2] and S[i+2*j]!=S[i]:
            count=count+1

print(len(list_B)*len(list_G)*len(list_R)-count)
        


Fixed submission:
N=str(input())
for i in range(len(N)):
    if int(N[i]) == 7:
        print("Yes")
        exit(0)
print("No")
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=str(input())
list_R=[]
list_G=[]
list_B=[]
count=0
for i in range(N):
    if S[i]=="R":
        list_R.append(i)
    if S[i]=="G":
        list_G.append(i)
    if S[i]=="B":
        list_B.append(i)
for i in range(N):
    for j in range(N):
        if i+2*j>N-1:
            break
        if S[i]!=S[i+j] and S[i+j]!=S[i+j*2] and S[i+2*j]!=S[i]:
            count=count+1

print(len(list_B)*len(list_G)*len(list_R)-count)
        


Fixed submission:
import math as np
K=int(input())
P=0
for i in range(1,K+1):
    for j in range(1,K+1):
        l=np.gcd(i,j)

        for k in range(1,K+1):
            m=np.gcd(l,k)
            P=m+P
print(P)

Buggy python submission (verdict: Time Limit Exceeded):
import math as np
K=int(input())
P=0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            l=np.gcd(i,j)
            m=np.gcd(l,k)
            P=m+P
print(P)

Fixed submission:
import math as np
K=int(input())
P=0
for i in range(1,K+1):
    for j in range(1,K+1):
        l=np.gcd(i,j)

        for k in range(1,K+1):
            m=np.gcd(l,k)
            P=m+P
print(P)

Buggy python submission (verdict: Time Limit Exceeded):
import math as np
K=int(input())
sum_gcd=[]
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            sum_gcd.append(np.gcd(np.gcd(i,j),k))
print(sum(sum_gcd))

Fixed submission:
import math as np
K=int(input())
P=0
for i in range(1,K+1):
    for j in range(1,K+1):
        l=np.gcd(i,j)

        for k in range(1,K+1):
            m=np.gcd(l,k)
            P=m+P
print(P)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=str(input())
list_R=[]
list_G=[]
list_B=[]
count=0
for i in range(N):
    if S[i]=="R":
        list_R.append(i)
    if S[i]=="G":
        list_G.append(i)
    if S[i]=="B":
        list_B.append(i)
for i in range(N):
    for j in range(N):
        k=2*j-i
        if i<j and j<k and k<N:
            if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
                count=count+1

print(len(list_B)*len(list_G)*len(list_R)-count)
        


Fixed submission:
N=int(input())
S=str(input())
list_R=[]
list_G=[]
list_B=[]
count=0
for i in range(N):
    if S[i]=="R":
        list_R.append(i)
    if S[i]=="G":
        list_G.append(i)
    if S[i]=="B":
        list_B.append(i)
for i in range(N):
    for j in range(N):
        if i+2*j>N-1:
            break
        if S[i]!=S[i+j] and S[i+j]!=S[i+j*2] and S[i+2*j]!=S[i]:
            count=count+1

print(len(list_B)*len(list_G)*len(list_R)-count)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=str(input())
list_R=[]
list_G=[]
list_B=[]
count=0
for i in range(N):
    if S[i]=="R":
        list_R.append(i)
    if S[i]=="G":
        list_G.append(i)
    if S[i]=="B":
        list_B.append(i)
for i in range(len(list_B)):
    for j in range(len(list_G)):
        for k in range(len(list_R)):
            x=[list_B[i],list_G[j],list_R[k]]
            x=sorted(x)
            if int(x[1])-int(x[0])!=int(x[2])-int(x[1]):
                count=count+1                
print(count)

Fixed submission:
N=int(input())
S=str(input())
list_R=[]
list_G=[]
list_B=[]
count=0
for i in range(N):
    if S[i]=="R":
        list_R.append(i)
    if S[i]=="G":
        list_G.append(i)
    if S[i]=="B":
        list_B.append(i)
for i in range(N):
    for j in range(N):
        if i+2*j>N-1:
            break
        if S[i]!=S[i+j] and S[i+j]!=S[i+j*2] and S[i+2*j]!=S[i]:
            count=count+1

print(len(list_B)*len(list_G)*len(list_R)-count)
Buggy python submission (verdict: Runtime Error):
N,M=[int(i) for i in input().split()]
A=list(int(input()))
for i in range(M):
    if A[i]>1/(4*M):
        print("Yes")
        exit()
print("No")

Fixed submission:
N,M=(int(i) for i in input().split())
A=list(map(int,input().split()))
S=len(A)
mono=0
soutoku=0
for i in range(S):
    soutoku=soutoku+A[i]
for i in range(S):
    if A[i]>=soutoku/(4*M):
        mono=mono+1
if mono>=M:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N,K=(int(i) for i in input().split())
while N>0:
    N=N-K
M=N+K
print(min(abs(N),M))
    

Fixed submission:
N,K=(int(i) for i in input().split())
N=N-N//K*K
M=N-K
print(min(N,abs(M)))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
A_new=sorted(A)
n=0
sum_number=0
index=[]
number=[]
for i in range(N-1):
    if A_new[i]==A_new[i+1]:
        n=n+1
    else:
        sum_number=n*(n+1)/2+sum_number
        index.append(i)
        number.append(n+1)
        n=0
if n!=0:
    sum_number=n*(n+1)/2+sum_number
if all(number):
    number.append(n+1)
    index.append(N-1)
I=len(index)
for i in range(N):
    for s,S in enumerate(index):
        if A[i]==A_new[S]:
            L=s
            break
    print(int(sum_number+1-number[L]))


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
number=[0]*(N+1)
all_sum=0
for i in A:
    number[i]+=1
for i in number:
    all_sum+=i*(i-1)/2
for i in range(N):
    print(int(all_sum-(number[A[i]]-1)))
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
B=[0]*(10**9)
for i in range(N):
    if B[A[i]-1]>=1: 
        print("NO")
        exit(0)
    else:
        B[A[i]-1]+=1
print("YES")

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
list.sort(A)
for i in range(N-1):
    if A[i]-A[i+1]==0:
        print("NO")
        exit(0)
print("YES")

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
B=[0]*(10**9)
for i in range(N):
    if B[A[i]-1]>=1: 
        print("NO")
        exit(0)
    else:
        B[A[i]-1]+=1
print("YES")

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
list.sort(A)
for i in range(N-1):
    if A[i]-A[i+1]==0:
        print("NO")
        exit(0)
print("YES")