Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]
m = M-1

def DFS(s):
    if len(s) == N:
        return [s]
    ans = []
    if s == '':
        r = 0
    else:
        r = int(s[-1])
    for i in range(r, M):
        ans.extend(DFS(s+str(i)))
    return ans


V = DFS('')
final_ans = 0
for v in V:
    answer = 0
    A = [int(c)+1 for c in v]
    for a, b, c, d in abcd:
        if int(v[b-1]) - int(v[a-1]) == c:
            answer += d
    final_ans = max(final_ans , answer)
print(final_ans)

Fixed submission:
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]
m = M-1

def DFS(s):
    if len(s) == N:
        return [s]
    ans = []
    if s == '':
        r = 0
    else:
        r = int(s[-1])
    for i in range(r, M):
        ans.extend(DFS(s+str(i)))
    return ans


V = DFS('')
final_ans = 0
for v in V:
    answer = 0
    A = [int(c)+1 for c in v]
    for a, b, c, d in abcd:
        if int(v[b-1]) - int(v[a-1]) == c:
            answer += d
    final_ans = max(final_ans , answer)
print(final_ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]
m = M-1

def DFS(s):
    if len(s) == N:
        return [s]
    ans = []
    if s == '':
        r = 0
    else:
        r = int(s[-1])
    for i in range(r, M):
        ans.extend(DFS(s+str(i)))
    return ans


V = DFS('')
final_ans = []
for v in V:
    answer = 0
    for q in abcd:
        if int(v[q[1]-1]) - int(v[q[0]-1]) == q[2]:
            answer += q[3]
    final_ans.append(answer)
print(max(final_ans))

Fixed submission:
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]
m = M-1

def DFS(s):
    if len(s) == N:
        return [s]
    ans = []
    if s == '':
        r = 0
    else:
        r = int(s[-1])
    for i in range(r, M):
        ans.extend(DFS(s+str(i)))
    return ans


V = DFS('')
final_ans = 0
for v in V:
    answer = 0
    A = [int(c)+1 for c in v]
    for a, b, c, d in abcd:
        if int(v[b-1]) - int(v[a-1]) == c:
            answer += d
    final_ans = max(final_ans , answer)
print(final_ans)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())
answer = 0
for i in range(min(B,N+1)):
    mae = (A*i)//B
    usiro = A*(i//B)

    l = mae-usiro
    if l > answer:
        answer = l
print(answer)

Fixed submission:
A, B, N = map(int, input().split())
answer = 0
if B > N:
    mae = (A*N)//B
    usiro = A*(N//B)
    l = mae-usiro
else:
    i = (B-1)
    mae = (A*i)//B
    usiro = A*(i//B)
    l = mae-usiro
print(l)
Buggy python submission (verdict: Runtime Error):
while A > 0 and C > 0:
    C -= B
    if C <= 0:
        print("Yes")
        exit()
    A -= D
    if A <= 0:
        print("No")
        exit()

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


while A > 0 and C > 0:
    C -= B
    if C <= 0:
        print("Yes")
        exit()
    A -= D
    if A <= 0:
        print("No")
        exit()
Buggy python submission (verdict: Runtime Error):
X , Y ,Z = int(input())
print(Z, X, Y)

Fixed submission:
X, Y, Z = map(int, input().split())
print(Z, X, Y)
Buggy python submission (verdict: Runtime Error):
mark = []
for i in range(N):
    b = int(input())
    for j, a in enumerate(A):
        for k, aa in enumerate(a):
            if aa == b:
                mark.append((j,k))



if ( ((0,0) and (1,1) and (2,2)) or ((0,2) and (1,1) and (2,0)) ) in mark:
    print("Yes")
    exit()
else:
    for i in range(3):
        if ((i,0) and (i,1) and (i,2)) in mark:
            print('Yes')
            exit()
        if ((0,i) and (1,i) and (2,i)) in mark:
            print("Yes")
            exit()

print("No")

Fixed submission:

A = [list(map(int, input().split())) for i in range(3)]
N = int(input())

mark = [[0]*3, [0]*3, [0]*3]

for i in range(N):
    b = int(input())
    for j, a in enumerate(A):
        for k, aa in enumerate(a):
            if aa == b:
                mark[j][k] = 1


if mark[0][0] == mark[1][1] == mark[2][2] == 1 or  mark[0][2] == mark[1][1] == mark[2][0] == 1:
    print("Yes")
    exit()
else:
    for i in range(3):
        if mark[i][0] == mark[i][1] == mark[i][2] == 1:
            print('Yes')
            exit()
        if mark[0][i] == mark[1][i] == mark[2][i] == 1:
            print("Yes")
            exit()

print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = list(map(int, input().split()))

sum_p = 0
sum_list = []
sum_list.append(sum_p)
for p_element in p:
    sum_p += p_element 
    sum_list.append(sum_p)

sum = 0
for i in range(N-K+1):
    if sum < sum_list[i+K]-sum_list[i]:
        sum = sum_list[i+K]-sum_list[i]
        select_list = []
        for j in range(K):
            select_list.append(p[i+j])

answer = 0
for i in select_list:
    answer += (1+i)/2
print(answer)

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

sum_p = 0
sum_list = []
sum_list.append(sum_p)
for p_element in p:
    sum_p += p_element 
    sum_list.append(sum_p)

sum = 0
start = 0
for i in range(N-K+1):
    if sum < sum_list[i+K]-sum_list[i]:
        sum = sum_list[i+K]-sum_list[i]
        start = i

answer = 0
for i in range(K):
    answer += (1+p[start+i])/2
print(answer)

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

sum_p = 0
sum_list = []
sum_list.append(sum_p)
for p_element in p:
    sum_p += p_element 
    sum_list.append(sum_p)

sum = 0
for i in range(N-K+1):
    if sum < sum_list[i+K]-sum_list[i]:
        sum = sum_list[i+K]-sum_list[i]
        select_list = []
        for j in range(K):
            select_list.append(p[i+j])

answer = 0
for i in select_list:
    for pro in range(i):
        answer += (pro+1)*(1/i)
print(answer)

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

sum_p = 0
sum_list = []
sum_list.append(sum_p)
for p_element in p:
    sum_p += p_element 
    sum_list.append(sum_p)

sum = 0
start = 0
for i in range(N-K+1):
    if sum < sum_list[i+K]-sum_list[i]:
        sum = sum_list[i+K]-sum_list[i]
        start = i

answer = 0
for i in range(K):
    answer += (1+p[start+i])/2
print(answer)
Buggy python submission (verdict: Runtime Error):
H = int(input())
W = int(input())
N = int(input())
for i in range(min(H,W)):
    N -= max(H, W):
    if N <= 0:
        print(i+1)

Fixed submission:
H = int(input())
W = int(input())
N = int(input())
for i in range(min(H,W)):
    N -= max(H, W)
    if N <= 0:
        print(i+1)
        exit()
Buggy python submission (verdict: Runtime Error):
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
Nl =[]
for i in range(N):
    Nl.append(i+1)

P_answer = 0
Q_answer = 0
for i, permu in enumerate(itertools.permutations(Nl)):
    if list(permu) == P:
        P_answer = i+1
    if list(permu) == Q:
        Q_answer = i+1

print(abs(P_answer-Q_answer))

Fixed submission:
import itertools
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
Nl =[]
for i in range(N):
    Nl.append(i+1)

P_answer = 0
Q_answer = 0
for i, permu in enumerate(itertools.permutations(Nl)):
    if list(permu) == P:
        P_answer = i+1
    if list(permu) == Q:
        Q_answer = i+1

print(abs(P_answer-Q_answer))
Buggy python submission (verdict: Runtime Error):
import math
#N = int(input())
a,b= map(int,input().split())
#v =list(map(int,input().split()))
# [list(map(int,input().split())) for i in range(N)]

print(a * b / math.gcd(a, b))


Fixed submission:
a,b= map(int,input().split())
#v =list(map(int,input().split()))
# [list(map(int,input().split())) for i in range(N)]
from fractions import gcd
def lcm(a,b): return a*b//gcd(a,b)

print(lcm(a,b))
Buggy python submission (verdict: Runtime Error):
S = input()
SUN,MON,TUE,WED,THU,FRI,SAT

if S[0]=='M':
  print(6)
elif S[2]=='E':
  print(5)
elif S[0] == 'W':
  print(4)
elif S[1] == 'H':
  print(3)
elif S[0] == 'F':
  print(2)
elif S[1] == 'A':
  print(1)
else:
  print(7)

Fixed submission:
S = input()
if S[0]=='M':
  print(6)
elif S[2]=='E':
  print(5)
elif S[0] == 'W':
  print(4)
elif S[1] == 'H':
  print(3)
elif S[0] == 'F':
  print(2)
elif S[1] == 'A':
  print(1)
else:
  print(7)
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q=map(int,input().split())
A=[int(input()) for i in range(Q)]
count =0
for i in range(N):
    count = A.count(i+1)
    if K-(Q-count) >0:
        print('Yes')
    else:
        print('No')


Fixed submission:
from collections import Counter
N,K,Q=map(int,input().split())
A=[int(input()) for i in range(Q)]
C = Counter(A)
for i in range(N):
    count = C[i+1]
    if K-(Q-count) >0:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=list(map(int,input().split()))
A = sorted(A,reverse=True)
for i in range(M):
    A[0] =A[0]//2
    m = max(A)
    i = A.index(max(A))
    if m != A[0]:
        A[i] = A[0]
        A[0] = m
print(sum(A))


Fixed submission:
#from operator import itemgetter
#from collections import Counter
import heapq
#N = int(input())
N, M = map(int, input().split())
A = list(map(lambda x: int(x)*(-1), input().split()))
#A = [int(input()) for i in range(N)]

heapq.heapify(A)

for i in range(M):
    max = heapq.heappop(A)
    heapq.heappush(A, max*(-1)//2*(-1))
print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=list(map(int,input().split()))
A = sorted(A,reverse=True)
temp = 0
for i in range(M):
    A[0] =A[0]//2
    if len(A)>=2:
        if A[0] < A[1]:
            A = sorted(A,reverse=True)
print(sum(A))


Fixed submission:
#from operator import itemgetter
#from collections import Counter
import heapq
#N = int(input())
N, M = map(int, input().split())
A = list(map(lambda x: int(x)*(-1), input().split()))
#A = [int(input()) for i in range(N)]

heapq.heapify(A)

for i in range(M):
    max = heapq.heappop(A)
    heapq.heappush(A, max*(-1)//2*(-1))
print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=list(map(int,input().split()))
for i in range(M):
    A[A.index(max(A))] = max(A)//2


print(sum(A))


Fixed submission:
#from operator import itemgetter
#from collections import Counter
import heapq
#N = int(input())
N, M = map(int, input().split())
A = list(map(lambda x: int(x)*(-1), input().split()))
#A = [int(input()) for i in range(N)]

heapq.heapify(A)

for i in range(M):
    max = heapq.heappop(A)
    heapq.heappush(A, max*(-1)//2*(-1))
print(-sum(A))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

answer = sum(B)
for i in range(len(B)):
  if B[i+1] = B[i]+1:
    answer += C[i]

print(answer)
  

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

answer = sum(B)
for i in range(len(A)-1):
  if A[i+1] == A[i]+1:
    answer += C[A[i]-1]

print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 0
for i in range(1,N):
  ans += i
print(ans)

Fixed submission:
N = int(input())
ans = (N*(N-1)//2)
print(ans)
Buggy python submission (verdict: Runtime Error):
for i, s in enumerate(S):
    if i != len(S)-1:
        if s == 'R':
            if S[i+1] == 'R':
                R_counter += 1
            else:
                R_counter += 1
                index_save = i
        if s == 'L':
            if S[i+1] == 'L':
                L_counter += 1
            else:
                L_counter += 1
                output[index_save] = ((R_counter+1)//2 + L_counter //2)
                output[index_save+1] = (R_counter//2 + (L_counter+1)//2)
                R_counter = 0
                L_counter = 0
    else:
        L_counter += 1
        output[index_save] = ((R_counter+1)//2 + L_counter //2)
        output[index_save+1] = (R_counter//2 + (L_counter+1)//2)
        
        
print(*output)



    

Fixed submission:
S = input()

output = [0] * len(S)
R_counter = 0
L_counter = 0
index_save = 0

for i, s in enumerate(S):
    if i != len(S)-1:
        if s == 'R':
            if S[i+1] == 'R':
                R_counter += 1
            else:
                R_counter += 1
                index_save = i
        if s == 'L':
            if S[i+1] == 'L':
                L_counter += 1
            else:
                L_counter += 1
                output[index_save] = ((R_counter+1)//2 + L_counter //2)
                output[index_save+1] = (R_counter//2 + (L_counter+1)//2)
                R_counter = 0
                L_counter = 0
    else:
        L_counter += 1
        output[index_save] = ((R_counter+1)//2 + L_counter //2)
        output[index_save+1] = (R_counter//2 + (L_counter+1)//2)
        
        
print(*output)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A =[int(input()) for i in range(N)]

for i in range(N):
    if i == 0:
        print(max(A[1:N]))
    elif i == N-1:
        print(max(A[0:N-1]))
    else:
        print(max([ max(A[0:i]) , max(A[i+1:N]) ] ))


Fixed submission:
N = int(input())
A =[int(input()) for i in range(N)]

def my_index_multi(l, x):
    return [i for i, _x in enumerate(l) if _x == x]

m = max(A)
maxindexlist = my_index_multi(A,m)

if len(maxindexlist) == 1:
    for i in range(N):
        if i != (maxindexlist[0]):
            print(m)
        else:
            A.pop(maxindexlist[0])
            print(max(A))
else:
    for i in range(N):
        print(m)
Buggy python submission (verdict: Runtime Error):
import math
all ,blue = map(int,input().split())
red = all - blue

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1,blue+1):
    if (red+1) < i:
        print('0')
    else:
        print((combinations_count(blue-1,i-1)*combinations_count(red+1,i))%(10**9+7))





Fixed submission:
S = list(input())
S.sort()
if S[0] == S[1] and S[1] != S[2] and S[2] == S[3]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
mport math
all ,blue = map(int,input().split())
red = all - blue

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1,blue+1):
    if (red+1) < i:
        print('0')
    else:
        print((combinations_count(blue-1,i-1)*combinations_count(red+1,i))%(10**9+7))


Fixed submission:
import math
all ,blue = map(int,input().split())
red = all - blue

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1,blue+1):
    if (red+1) < i:
        print('0')
    else:
        print((combinations_count(blue-1,i-1)*combinations_count(red+1,i))%(10**9+7))

Buggy python submission (verdict: Runtime Error):
import math
all ,blue = map(int,input().split())
red = all - blue

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1,blue+1):
    print((combinations_count(blue-1,i-1)*combinations_count(red+1,i))%(1000000007))




Fixed submission:
import math
all ,blue = map(int,input().split())
red = all - blue

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1,blue+1):
    if (red+1) < i:
        print('0')
    else:
        print((combinations_count(blue-1,i-1)*combinations_count(red+1,i))%(10**9+7))
Buggy python submission (verdict: Runtime Error):
N ,L= map(int,input().split())
one_aji = 0
aji = []
answer = []
for i in range(N):
    one_aji = L+i
    if one_aji < 0:
        answer.append(one_aji)
        one_aji *= -1
        aji.append(one_aji)
    else:
        aji.append(one_aji)
        answer.append(one_aji)
zettai = 500
ind = 0
for i, a in enumerate(aji):
    a = int(a)
    if a < zettai:
        zettai = a
        ind = i
         
answer.pop(ind)
print(sum(answer))


Fixed submission:
S = input()
# = map(int,input().split())
ans = ''
for s in S:
    if s == ans:
        print('Bad')
        exit()
    else:
        ans = s
print('Good')
Buggy python submission (verdict: Runtime Error):
N ,L= map(int,input().split())
one_aji = 0
aji = []
answer = []
for i in range(N):
    one_aji = L+i
    if one_aji < 0:
        answer.append(one_aji)
        one_aji *= -1
        aji.append(one_aji)
    else:
        aji.append(one_aji)
        answer.append(one_aji)
zettai = 500
ind = 0
for i, a in enumerate(aji):
    a = int(a)
    if a < zettai:
        zettai = a
        ind = i
        
        
answer.pop(ind)
print(sum(answer)

Fixed submission:
N ,L= map(int,input().split())
one_aji = 0
aji = []
answer = []
for i in range(N):
    one_aji = L+i
    if one_aji < 0:
        answer.append(one_aji)
        one_aji *= -1
        aji.append(one_aji)
    else:
        aji.append(one_aji)
        answer.append(one_aji)
zettai = 500
ind = 0
for i, a in enumerate(aji):
    a = int(a)
    if a < zettai:
        zettai = a
        ind = i
         
answer.pop(ind)
print(sum(answer))
Buggy python submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
answer = []
answer2 = []
lis = []
lis2 = []
for i in range(N):
    x, y = map(int, input().split())
    lis.append([x, y])
    lis2.append([y, x])
sort_lis = sorted(lis)
sort_lis2 = sorted(lis2)

if N == 1:
    print(1)
    exit()
for i in range(N-1):
    answer.append([sort_lis[i][0] -sort_lis[i+1][0],sort_lis[i][1]-sort_lis[i+1][1]])
    answer2.append([sort_lis2[i][0] -sort_lis2[i+1][0],sort_lis2[i][1]-sort_lis2[i+1][1]])
ans = list(map(tuple,answer))
#print(ans)
ans2 = list(map(tuple,answer2))
#print(ans2)
a = Counter(ans).most_common()
#print(a)
a2 = Counter(ans2).most_common()
#print(a2)
if a[0][1] > a2[0][1]:
    c = 1
    for i in range(1,len(a)):
        c += a[i][1]
else:
    c = 1
    for i in range(1,len(a2)):
        c += a2[i][1]
print(c)


Fixed submission:
def input_func():
    N, K= map(int,input().split())
    return N, K

def evaluate(N,K):
    if K == 1:
        answer = 0
    else:
        answer = N - K
    return answer

if __name__ == '__main__':
    N, K = input_func()
    answer = evaluate(N,K)
    print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))

for i in range(M):
    num, value = map(int, input().split())
    A += [value] * num
Answer = 0
A = sorted(A,reverse=True)
for i in range(N):
    Answer += A[i]
print(Answer)

Fixed submission:
from operator import itemgetter
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for i in range(M)]
BC_list = []
BC_sorted = sorted(BC,key=itemgetter(1) ,reverse = True)

for i in BC_sorted:
    BC_list += [i[1]] * i[0]
    if len(BC_list) > N:
        break

Answer = 0
A += BC_list
ALL = sorted(A, reverse = True)

for i in range(N):
    Answer += ALL[i]
print(Answer)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
lis = []
for i in range(M):
    B ,C = map(int, input().split())
    if C > A[N-1]:
        for j in range(B):
            A.append(C)
        A.sort(reverse=True)
ans = 0
for i in range(N):
    ans += A[i]
print(ans)


Fixed submission:
from operator import itemgetter
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for i in range(M)]
BC_list = []
BC_sorted = sorted(BC,key=itemgetter(1) ,reverse = True)

for i in BC_sorted:
    BC_list += [i[1]] * i[0]
    if len(BC_list) > N:
        break

Answer = 0
A += BC_list
ALL = sorted(A, reverse = True)

for i in range(N):
    Answer += ALL[i]
print(Answer)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
lis = []
for i in range(M):
    B ,C = map(int, input().split())
    if C > A[-1]:
        for j in range(B):
            A.append(C)
            A.sort(reverse=True)
ans = 0
for i in range(N):
    ans += A[i]
print(ans)

Fixed submission:
from operator import itemgetter
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for i in range(M)]
BC_list = []
BC_sorted = sorted(BC,key=itemgetter(1) ,reverse = True)

for i in BC_sorted:
    BC_list += [i[1]] * i[0]
    if len(BC_list) > N:
        break

Answer = 0
A += BC_list
ALL = sorted(A, reverse = True)

for i in range(N):
    Answer += ALL[i]
print(Answer)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
lis = []
for i in range(M):
    B ,C = map(int, input().split())
    for j in range(B):
        A.append(C)
A.sort(reverse=True)
ans = 0
for i in range(N):
    ans += A[i]
print(ans)


Fixed submission:
from operator import itemgetter
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for i in range(M)]
BC_list = []
BC_sorted = sorted(BC,key=itemgetter(1) ,reverse = True)

for i in BC_sorted:
    BC_list += [i[1]] * i[0]
    if len(BC_list) > N:
        break

Answer = 0
A += BC_list
ALL = sorted(A, reverse = True)

for i in range(N):
    Answer += ALL[i]
print(Answer)
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
count = 0
for i in range(N//R+1):
    for j in range(N//G+1):
        if (N - R*i - G*j) % B == 0 and (N-R*i-G*j)>=0:
            count += 1
print(count)


Fixed submission:
R, G,B,N = map(int, input().split())
l = [R,G,B]
l = sorted(l)
ma = l[2]
mi = l[0]
mid = l[1]
id = N // ma
count = 0
for i in range(id+1):
    res = N - ma * i
    if res >= mid:
        for j in range(res//mid+1):
            if res % mi == 0:
                count += 1
            res -= mid
    else:
        if res % mi == 0:
            count +=1
print(count)
Buggy python submission (verdict: Runtime Error):
for i in range(N):
    if S[i][-1:] == 'A' and S[i][0] == 'B':
        con.append(S[i])
    elif S[i][-1:] == 'A':
        Alis.append(S[i])
    elif S[i][0] == 'B':
        Blis.append(S[i])
if (len(Alis)+len(Blis)+len(con))==len(con):
    count += len(con)-1
else:
    count += min(len(con)+len(Alis),len(con)+len(Blis))
print(count)


Fixed submission:
N = int(input())
S = [input() for i in range(N)]
count = 0
con = []
Alis = []
Blis = []
for s in S:
    count += s.count('AB')
for i in range(N):
    if S[i][-1:] == 'A' and S[i][0] == 'B':
        con.append(S[i])
    elif S[i][-1:] == 'A':
        Alis.append(S[i])
    elif S[i][0] == 'B':
        Blis.append(S[i])
if len(Alis)== 0 and len(Blis) == 0 and len(con) > 0:
    count += len(con)-1
else:
    count += min(len(con)+len(Alis),len(con)+len(Blis))
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
count = 0
for i in range(1,N):
    if N % i != 0:
        if N//i == N % i:
            count += i
print(count)


Fixed submission:
N = int(input())
count = 0
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

if __name__=="__main__":
    lis = make_divisors(N)
    for i in lis:
        if i!= 1:
            if N // (i-1) == N % (i-1):
                count += i-1
    print(count)