Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import collections
def cal(n):
    ans = int(n*(n-1)/2)
    return ans 
n = int(input())
a = list(map(int,input().split()))

temp_list = []
for i in range(1,n+1):
    temp = a[:i-1]+a[i:]
    # print(temp)
    temp_c = collections.Counter(temp)
    temp_k = temp_c.values()
    temp_cal = list(map(cal,temp_k))
    print(sum(temp_cal))

Fixed submission:
import collections
def cal(n):
    ans = int(n*(n-1)/2)
    return ans 
n = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)
temp = list(c.values())
t_val = list(map(cal,c.values()))
t_key = list(c.keys())
t_cal = sum(t_val)
# print(t_key)
# print(t_cal)
# print(temp)
for i in range(n):
    ans1 = c[a[i]]-1
    print(t_cal - ans1)
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
if a>n:
  print(a)
ans = 0
else:
  temp = N//(a+b)
  ans = temp*a
  temp2 = N- temp
  if temp2 < a:
    print(ans+temp2)
  else:
    print(ans+a)

Fixed submission:
n,a,b = map(int,input().split())
temp = n//(a+b)
ans = temp*a
temp2 = n%(a+b)
print(ans+min(temp2,a))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
v = np.array(list(map(int,input().split()))) 
c = np.array(list(map(int,input().split())))
ans = -(1<<60)
for i in range(2**n):
    temp = (bin(i)[2:]).zfill(n)
    temp = np.array(list(map(int, temp)))
    X = np.dot(temp, v)
    Y = np.dot(temp,c)
    ans = max(ans,X-Y)
print(ans)

Fixed submission:
import numpy as np
n = int(input())
v = list(map(int,input().split())) 
c = list(map(int,input().split()))
ans = 0
for i in range(n):
    if v[i]-c[i]>=0:
        ans += v[i]-c[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
n,q = map(int,input().split())
s = input()
ans =[]
j = 0
for i in range(n-1):#どこにACという連続文字列があるかを調べる
    if s[i] == "A" and s[i+1] == "C":
        j += 1
        ans.append(j)
    else:
        ans.append(j)
for i in range(q):
    l,r = map(int, input().split())
    print(ans[r-2]-ans[l]+1)


Fixed submission:
n,q = map(int,input().split())
s = input()
ans =[0]
j = 0
for i in range(n-1):#どこにACという連続文字列があるかを調べる
    if s[i] == "A" and s[i+1] == "C":
        j += 1
        ans.append(j)
    else:
        ans.append(j)
# print(ans)
for i in range(q):
    l,r = map(int, input().split())
    print(ans[r-1]-ans[l-1])
Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A = np.array(A)
B = np.array(B)
if np.sum(A) < np.sum(B):
    print(-1) 
else:
    sub_a_b = A-B
    p_sub = sorted(list(sub_a_b[sub_a_b>0]),reverse = True)
    # print(p_sub)  
    m_sub = list(sub_a_b[sub_a_b<0])
    max_counter = p_sub[0]
    m_sub_sum = abs(sum(m_sub))
    count = 1 + len(m_sub) 
    # print(p_sub[0:1])
    for i in range(len(p_sub)):
        if max_counter >= m_sub_sum:
            print(count)
            exit()
        else:
            max_counter += p_sub[i+1]
            count += 1

Fixed submission:
n = list(map(int, input().split()))
if (1 in n) and (9 in n) and (7 in n) and 4 in n:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
B = np.array(B)
if np.sum(A) < np.sum(B):
    print(-1) 
else:
    sub_a_b = A-B
    p_sub = sorted(list(sub_a_b[sub_a_b>0]),reverse = True)
    # print(p_sub)  
    m_sub = list(sub_a_b[sub_a_b<0])
    max_counter = p_sub[0]
    m_sub_sum = abs(sum(m_sub))
    count = len(m_sub) 
    # print(p_sub[0:1])
    if max_counter >= m_sub_sum:
        print(count)
    else:
        count+=1

        for i in range(len(p_sub)):
            if max_counter >= m_sub_sum:
                print(count)
                exit()
            else:
                max_counter += p_sub[i+1]
                count += 1

Fixed submission:
import numpy as np
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A = np.array(A)
B = np.array(B)
if np.sum(A) < np.sum(B):
    print(-1) 
else:
    sub_a_b = A-B
    p_sub = sorted(list(sub_a_b[sub_a_b>0]),reverse = True)
    # print(p_sub)  
    m_sub = list(sub_a_b[sub_a_b<0])
    max_counter = p_sub[0]
    m_sub_sum = abs(sum(m_sub))
    count = len(m_sub) 
    # print(p_sub[0:1])
    # print(type(list(np.where(sub_a_b<0)[0])))
    # print(np.array([]))
    if list(np.where(sub_a_b<0)[0]) == [] :
        print(0)
        exit()
    else:
        count+=1

        for i in range(len(p_sub)):
            if max_counter >= m_sub_sum:
                print(count)
                exit()
            else:
                max_counter += p_sub[i+1]
                count += 1
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
ans = 0
judge = True

while judge:
    count = 0
    for i in range(1,len(s)):
        if s[-i] == "W" and s[-i-1] == "B":
            ans += 1
            s[-i] = "B"
            s[-i-1] = "W"
            count += 1
    if count == 0:
        judge =False
print(ans)

Fixed submission:
s = list(input())
ans = 0
count = 0
for i in range(len(s)):
    if s[i] == "B":
        count += 1
    if s[i] == "W":
        ans += count
print(ans)
Buggy python submission (verdict: Runtime Error):
#include<stdio.h>
int main(){
	int D;
	scanf("%d",&D);
	if (D==25){
		puts("Christmas");
	}
	else if (D == 24){
		puts("Christmas Eve");
	}
	else if(D==23){
		puts("Christmas Eve Eve");
	}
	else if(D ==22){
		puts("Christmas Eve Eve Eve");
	}
}

Fixed submission:
n = int(input())
if n == 25:
    print("Christmas")
elif(n == 24):
    print("Christmas Eve")
elif(n == 23):
    print("Christmas Eve Eve")
else:
    print("Christmas Eve Eve Eve")
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
h = []
ans = 1<<50
for i in range(n):
    h.append(int(input()))
h = sorted(h)
for i in range(n-k+1):
    temp = h[i:i+k]
    # print(temp)
    ans = min(ans,temp[-1]-temp[0])
print(ans)

Fixed submission:
n,k = map(int,input().split())
h = []
ans = 1<<50
for i in range(n):
    h.append(int(input()))
h = sorted(h)
for i in range(n-k+1):
    ans = min(ans,h[i+k-1]-h[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
# print()
if len(S)>=10**5+5*10**4:
    print("No")
else:
    for i in range(len(S)):
        if S[i] != T[i]:
            S = S.translate(str.maketrans({S[i]:T[i],T[i]:S[i]}))
            # S=S.replace(S[i],T[i])
    if S==T:
        print("Yes")
    else:
        print("No")

Fixed submission:
a,b,c=  map(int,input().split())
temp= [a,b,c]
temp.sort()
temp1=int(str(temp[-1])+str(temp[-2]))
print(temp1+temp[0])
Buggy python submission (verdict: Runtime Error):
N = int(input())
if N<105:
    print(0)

else:
    ans = 0
    for i in range(105,N+1,2):
        temp = 0
        for j in range(1,i+1):
            if i%j == 0:
                temp +=1
        if temp == 8:
            ans += 1
print(ans)



Fixed submission:
N = int(input())
if N<105:
    print(0)

else:
    ans = 0
    for i in range(105,N+1,2):
        temp = 0
        for j in range(1,i+1):
            if i%j == 0:
                temp +=1
        if temp == 8:
            ans += 1
    print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a.append(10**10)
counter = 1
ans = 0
for i in range(n):
    if a[i] == a[i+1]:
        counter += 1
    else:
        if counter %2 == 0 and counter != 1 :
            ans += counter/2
        elif counte %2 != 0 and counter != 1:
            ans += int(counter/2)
        counter = 1
print(int(ans))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.append(10**10)
counter = 1
ans = 0
for i in range(n):
    if a[i] == a[i+1]:
        counter += 1
    else:
        if counter %2 == 0 and counter != 1 :
            ans += counter/2
        elif counter %2 != 0 and counter != 1:
            ans += int(counter/2)
        counter = 1
print(int(ans))

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

a = list(map(int,input().split()))
a.append(10**10)
counter = 1
ans = 0
for i in range(n):
    if a[i] == a[i+1]:
        counter += 1
    else:
        if counter %2 == 0 and counter != 1 :
            ans += counter/2
        elif counte %2 != 0 and counter != 1:
            ans += int(counter/2)
        counter = 1
print(int(ans))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.append(10**10)
counter = 1
ans = 0
for i in range(n):
    if a[i] == a[i+1]:
        counter += 1
    else:
        if counter %2 == 0 and counter != 1 :
            ans += counter/2
        elif counter %2 != 0 and counter != 1:
            ans += int(counter/2)
        counter = 1
print(int(ans))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
temp_count = S.count("W")
ans_min = 10**10
count_E = N-temp_count
count_W = 0 
for i in range(N):
    if S[i] == "W":
        count_E -= 1
    else:
        count_W +=1
    if ans_min > coun_E+count_W:
        ans_min =  coun_E+count_W
print(ans_min)

Fixed submission:
N = int(input())
S = input()

count_E = S[1:].count("E")
ans = count_E
for i in range(1,N):
    if S[i-1] == "W":
        count_E += 1
    if S[i] == "E":
        count_E -= 1
    if ans >count_E:
        ans = count_E
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
temp_min =10**15
for i in range(1,N):
    temp = S[0:i-1]
    temp2 = S[i:N]
    temp3 = temp.count("W")+temp2.count("E")
    if temp_min > temp3:
        temp_min = temp3
print(temp_min)

Fixed submission:
N = int(input())
S = input()

count_E = S[1:].count("E")
ans = count_E
for i in range(1,N):
    if S[i-1] == "W":
        count_E += 1
    if S[i] == "E":
        count_E -= 1
    if ans >count_E:
        ans = count_E
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
temp_min =10**15
for i in range(1,N):
    temp = S[0:i-1]
    temp2 = S[i:N]
    if temp_min > temp.count("W")+temp2.count("E"):
        temp_min = temp.count("W")+temp2.count("E")
print(temp_min)

Fixed submission:
N = int(input())
S = input()

count_E = S[1:].count("E")
ans = count_E
for i in range(1,N):
    if S[i-1] == "W":
        count_E += 1
    if S[i] == "E":
        count_E -= 1
    if ans >count_E:
        ans = count_E
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
s = input()
K = int(input())
     
sort_s = sorted(list(s))
temp = []
for i in range(len(s)):
    for j in range(1,K+1):
        # if i >j:
        # print("{},{}".format(i,j))
        if i+j <= len(s):
            temp.append(s[i:i+j])
sort_temp=sorted(temp)
ans =[]
for i in sort_temp:
    if i not in ans:
        ans.append(i)
sort_ans = sorted(ans)
print(sort_ans[K-1])

Fixed submission:
import sys
s = input()
K = int(input())
     
# sort_s = sorted(list(s))
temp = set()
# temp = []
for i in range(len(s)):
    for j in range(i+1,i+K+1):
        # if i >j:
        # print("{},{}".format(i,j))
        temp.add(s[i:j])
        # if i+j <= len(s):
            # temp.append(s[i:i+j])
ans = sorted(temp)
print(ans[K-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
X = tuple(map(int,input().split()))
test = int(N/2)
for i in range(len(X)):
    temp = list(X)
    temp.pop(i)
    temp = sorted(temp)
    print(temp[test-1])


Fixed submission:
N = int(input())
X = list(map(int,input().split()))
X_sorted = sorted(X)
X_median = (N)/2
median1 = X_sorted[int(X_median)]
median2 = X_sorted[int(X_median-1)]
for i in range(N):
    if X[i] >=median1:
        print(median2)
    else:
        print(median1)

Buggy python submission (verdict: Runtime Error):
N = int(input())
X = tuple(map(int,input().split()))
test = N/2
for i in range(len(test)):
    temp = list(X)
    temp.pop(i)
    temp = sorted(temp)
    print(temp[test-1])


Fixed submission:
N = int(input())
X = list(map(int,input().split()))
X_sorted = sorted(X)
X_median = (N)/2
median1 = X_sorted[int(X_median)]
median2 = X_sorted[int(X_median-1)]
for i in range(N):
    if X[i] >=median1:
        print(median2)
    else:
        print(median1)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
X = tuple(map(int,input().split()))
for i in range(len(X)):
    temp = list(X)
    temp.pop(i)
    test = int((len(temp)+1)/2)
    temp = sorted(temp)
    print(temp[test-1])


Fixed submission:
N = int(input())
X = list(map(int,input().split()))
X_sorted = sorted(X)
X_median = (N)/2
median1 = X_sorted[int(X_median)]
median2 = X_sorted[int(X_median-1)]
for i in range(N):
    if X[i] >=median1:
        print(median2)
    else:
        print(median1)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K = map(int,input().split())
ans = []
for i in range(A,B+1):
    if i < A+K:
        if i in ans:
            pass
        else:
            ans.append(i)
    if i > B-K:
        if i in ans:
            pass
        else:
            ans.append(i)
for i in range(len(ans)):
    print(ans[i])

Fixed submission:
A,B,K = map(int,input().split())
if A+K > B:
    for i in range(A,B+1):
        print(i)
else:
    for i in range(A,A+K):
        print(i)
    if A+K > B-K:
        for i in range(A+K,B+1):
            print(i)
    else:
        for i in range(B-K+1,B+1):
            print(i)
Buggy python submission (verdict: Runtime Error):
N = int(input())
red_point=[]
blue_point=[]
for i in range(N):
    red_point.append(list(map(int,input().split())))
for i in range(N):
    blue_point.append(list(map(int,input().split())))
red_point.sort(reverse=True)
blue_point.sort()
# print(blue_point)
ans = 0
temp = 0 
# print(red_point)
for i in range(N):
    redx,redy=red_point[i][0],red_point[i][1]
    for j in range(len(blue_point)):
        # print("({},{})".format(i,j))
        # print(blue_point)
        bluex,bluey=blue_point[j][0],blue_point[j][1]
        if redx<bluex and redy<bluey:
            if temp<redx:
                temp = redx
                tempj=j   
            ans +=1
            # red_point.pop(i)
            blue_point.pop(tempj)
            # break
print(ans)

Fixed submission:
N = int(input())
red_point=[]
blue_point=[]
for i in range(N):
    red_point.append(list(map(int,input().split())))
for i in range(N):
    blue_point.append(list(map(int,input().split())))
red_point.sort(reverse=True)
blue_point.sort(key=lambda x:x[1])
# print(blue_point)
ans = 0
# temp = 0 
# print(red_point)
for i in range(N):
    redx,redy=red_point[i][0],red_point[i][1]
    for j in range(len(blue_point)):
        # print("({},{})".format(i,j))
        # print(blue_point)
        bluex,bluey=blue_point[j][0],blue_point[j][1]
        if redx<bluex and redy<bluey:
            # if temp<redx:
                # temp = redx
                # tempj=j   
            ans +=1
            # red_point.pop(i)
            blue_point.pop(j)
            break
print(ans)
Buggy python submission (verdict: Runtime Error):
c1 = list(map(int,input().split(" ")))
c2 = list(map(int,input().split(" ")))
c3 = list(map(int,input().split(" ")))
a1 = []
a2 = []
a3 = []
b1 = []
b2 = []
b3 = []
judge1 = False
judge2 = False
judge3 = False
judge4 = False
for i in range(c1[0]+1):
    a1.append(i)
b1 = sorted(a1,reverse = True)
for i in b1:
    a2.append(c2[0]-i)
for i in b1:
    a3.append(c3[0]-i)

for i in a1:
    b2.append(c1[1]-i)
for i in a1:
    b3.append(c1[2]-i)

for i in range(len(a1)):
    if c2[1] == a2[i]+b2[i]:
        judge1 = True
    if c3[2] == a3[i]+b3[i]:
        judge2 = True
    if c2[2] == a2[i]+b3[i]:
        judge3 = True
    if c3[1] == a3[i]+b2[i]:
        judge4 = True 
if judge1 and judge2 and judeg3 and judge4 :
    print("Yes")
else:
    print("No")

Fixed submission:
c1 = list(map(int,input().split(" ")))
c2 = list(map(int,input().split(" ")))
c3 = list(map(int,input().split(" ")))
a1 = []
a2 = []
a3 = []
b1 = []
b2 = []
b3 = []
judge1 = False
judge2 = False
judge3 = False
judge4 = False
for i in range(c1[0]+1):
    a1.append(i)
b1 = sorted(a1,reverse = True)
for i in b1:
    a2.append(c2[0]-i)
for i in b1:
    a3.append(c3[0]-i)

for i in a1:
    b2.append(c1[1]-i)
for i in a1:
    b3.append(c1[2]-i)

for i in range(len(a1)):
    if c2[1] == a2[i]+b2[i]:
        judge1 = True
    if c3[2] == a3[i]+b3[i]:
        judge2 = True
    if c2[2] == a2[i]+b3[i]:
        judge3 = True
    if c3[1] == a3[i]+b2[i]:
        judge4 = True 
if judge1 and judge2 and judge3 and judge4 :
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
c1 = list(map(int,input().split(" ")))
c2 = list(map(int,input().split(" ")))
c3 = list(map(int,input().split(" ")))
a1 = []
a2 = []
a3 = []
b1 = []
b2 = []
b3 = []
judge1 = False
judge2 = False
judge3 = False
judge4 = False
for i in range(c1[0]+1):
    a1.append(i)
b1 = sorted(a1,reverse = True)
for i in b1:
    a2.append(c2[0]-i)
for i in b1:
    a3.append(c3[0]-i)

for i in a1:
    b2.append(c1[1]-i)
for i in a1:
    b3.append(c1[2]-i)

for i in range(len(a1)):
    if c2[1] == a2[i]+b2[i]:
        judge1 = True
    if c3[2] == a3[i]+b3[i]:
        judge2 = True
    if c2[3] == a2[i]+b3[i]:
        judge3 = True
    if c3[1] == a3[i]+b2[i]:
        judge4 = True 
if judge1 and judge2 and judeg3 and judge4 :
    print("Yes")
else:
    print("No")

Fixed submission:
c1 = list(map(int,input().split(" ")))
c2 = list(map(int,input().split(" ")))
c3 = list(map(int,input().split(" ")))
a1 = []
a2 = []
a3 = []
b1 = []
b2 = []
b3 = []
judge1 = False
judge2 = False
judge3 = False
judge4 = False
for i in range(c1[0]+1):
    a1.append(i)
b1 = sorted(a1,reverse = True)
for i in b1:
    a2.append(c2[0]-i)
for i in b1:
    a3.append(c3[0]-i)

for i in a1:
    b2.append(c1[1]-i)
for i in a1:
    b3.append(c1[2]-i)

for i in range(len(a1)):
    if c2[1] == a2[i]+b2[i]:
        judge1 = True
    if c3[2] == a3[i]+b3[i]:
        judge2 = True
    if c2[2] == a2[i]+b3[i]:
        judge3 = True
    if c3[1] == a3[i]+b2[i]:
        judge4 = True 
if judge1 and judge2 and judge3 and judge4 :
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
 = int(input())
C = []
S = []
F = []
for i in range(N-1):
    C_temp,S_temp,F_temp = map(int,input().split())
    C.append(C_temp)
    S.append(S_temp)
    F.append(F_temp)
ans = S[0]
for i in range(N):
    t = 0
    for j in range(i,N-1):
        if t<S[j]:
            t = S[j]
        elif t%F[j] == 0:
            pass
        else:
            t = t+F[j] -t%F[j]
        t += C[j]
    print(t)


Fixed submission:
N = int(input())
C = []
S = []
F = []
for i in range(N-1):
    C_temp,S_temp,F_temp = map(int,input().split())
    C.append(C_temp)
    S.append(S_temp)
    F.append(F_temp)
ans = S[0]
for i in range(N):
    t = 0
    for j in range(i,N-1):
        if t<S[j]:
            t = S[j]
        elif t%F[j] == 0:
            pass
        else:
            t = t+F[j] -t%F[j]
        t += C[j]
    print(t)
Buggy python submission (verdict: Runtime Error):
import math
N,A,B = map(int,input().split())
# ans = 0
#N = list(str(N))
#N_len = len(N)
ans = 0
for i in range(1,int(N)+1):
    if (i < 10) and  (A <= i  and i<=B):
        ans += i
    elif 10<=i and i <100:
        list_i = list(str(i))
        if (A <= int(list_i[0])+int(list_i[1])  and int(list_i[0])+int(list_i[1])<=B):
            ans +=i
    elif 100<= i and i <1000:
        list_i = list(str(i))
        if (A <= int(list_i[0])+int(list_i[1])+int(list_i[2])  and int(list_i[0])+int(list_i[1])+int(list_i[2])<=B):
            ans +=i
    elif 1000 <=i:
        list_i = list(str(i))
        if (A <= int(list_i[0])+int(list_i[1])+int(list_i[2])+int(list_i[3])  and int(list_i[0])+int(list_i[1])+int(list_i[2])+list_i[3]<=B):
            ans +=i

print(ans)

Fixed submission:
import math
N,A,B = map(int,input().split())
ans = 0
for i in range(1,N+1):
    sum_temp = sum(map(int,list(str(i))))
    if A<=sum_temp<=B:
        ans +=i
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import collections
S = input()
count_dict = collections.Counter(S)
Num_A = count_dict["a"]
Num_B = count_dict["b"]
Num_C = count_dict["c"]

judge = sorted([a, b, c])
if judge[2]-judge[0]>1:
    print('NO')
else:
    print('YES')

Fixed submission:
import sys
import collections
S = input()
count_dict = collections.Counter(S)
Num_A = count_dict["a"]
Num_B = count_dict["b"]
Num_C = count_dict["c"]

judge = sorted([Num_A, Num_B, Num_C])
if judge[2]-judge[0]>1:
    print('NO')
else:
    print('YES')

Buggy python submission (verdict: Runtime Error):
import collections
import sys
S = input()
count_dict = collections.Counter(S)
Num_A = count_dict["a"]
Num_B = count_dict["b"]
Num_C = count_dict["c"]

s_list = {}
if Num_A !=0:
    s_list[0] ="a"
    Num_A -=1
elif Num_B != 0:
    s_list[0] ="b"
    Num_B -= 1
elif Num_C != 0:
    s_list[0] ="c"
    Num_C -= 1

if Num_A !=0 and s_list[0] !="a":
    s_list[1] ="a"
    Num_A -=1
elif Num_B != 0 and s_list[0] !="b":
    s_list[1] ="b"
    Num_B -= 1
elif Num_C != 0 and s_list[0] !="c":
    s_list[1] ="c"
    Num_C -= 1


i = 0
while Num_A + Num_B + Num_C != 0:
    if s_list[i] != "a" and s_list[i+1] != "a" and Num_A != 0:
        s_list[i+2] = "a"
        Num_A -=1
        i +=1

    elif s_list[i] != "b" and s_list[i+1] != "b" and Num_B != 0:
        s_list[i+2] = "b"
        Num_B -=1
        i +=1    
     
    elif s_list[i] != "c" and s_list[i+1] != "c" and Num_C != 0:
        s_list[i+2] = "c"
        Num_C -=1
        i +=1
    else:
        print("NO")    
        sys.exit()

print("YES")


Fixed submission:
import sys
import collections
S = input()
count_dict = collections.Counter(S)
Num_A = count_dict["a"]
Num_B = count_dict["b"]
Num_C = count_dict["c"]

judge = sorted([Num_A, Num_B, Num_C])
if judge[2]-judge[0]>1:
    print('NO')
else:
    print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 1
for i in range(1,n+1):
    ans *= i
print(ans%1000000007)

Fixed submission:
import math 
n = int(input())
print(math.factorial(n)%1000000007)