Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = sorted(map(int, input().split())) [::-1]
ans = 0
for i in range(0, 3*N, 2):
  ans += a[i+1]
print(ans)

Fixed submission:
N = int(input())
a = sorted(map(int, input().split())) [::-1]
ans = 0
cnt = 0
for i in range(0, 3*N, 2):
  ans += a[i+1]
  cnt += 1
  if cnt == N:
    break
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = sorted(map(int, input().split())) [::-1]
ans = 0
for i in range(0, 3N, 2):
  ans += a[i+1]
print(ans)

Fixed submission:
N = int(input())
a = sorted(map(int, input().split())) [::-1]
ans = 0
cnt = 0
for i in range(0, 3*N, 2):
  ans += a[i+1]
  cnt += 1
  if cnt == N:
    break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
N = int(input())
ans = 10
for A in range(1, N+1):
  if N % A == 0:
    B = N//A
    F = max(len(str(A)), len(str(B)))
    if ans > F:
      ans = F 
print(ans)

Fixed submission:
import math
N = int(input())
ans = 10
for A in range(1, int(math.sqrt(N))+1):
  if N % A == 0:
    B = N//A
    F = max(len(str(A)), len(str(B)))
    if ans > F:
      ans = F 
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
ans = 10
for A in range(1, int(math.sqrt(N))):
  if N % A == 0:
    B = N//A
    F = max(len(str(A)), len(str(B)))
    ans = F if ans > F
print(ans)

Fixed submission:
import math
N = int(input())
ans = 10
for A in range(1, int(math.sqrt(N))+1):
  if N % A == 0:
    B = N//A
    F = max(len(str(A)), len(str(B)))
    if ans > F:
      ans = F 
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
i = 0
while s[i] != 'A':
  i += 1
s.reverse()
j = 0
while s[j] != 'Z':
  j += 1
print(j-i+1)

Fixed submission:
s = input()
a = s.find('A')
b = s.rfind('Z')
print(b-a+1)
Buggy python submission (verdict: Runtime Error):
K, S = map(int, input().split())
count = 0
for X in range(K+1):
  for Y in range(K+1):
    Z = S - X - Y:
      if 0 <= Z and Z <= K:
        count += 1
print(count)

Fixed submission:
k, s = map(int, input().split())
count = 0
for x in range(k+1):
  for y in range(k+1):
    z = s - x - y
    if 0 <= z and z <= k:
      count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
count = 0
for X in range(K+1):
  for Y in range(K+1):
    for Z in range(K+1):
      if X + Y + Z == S:
        count += 1
print(count)

Fixed submission:
k, s = map(int, input().split())
count = 0
for x in range(k+1):
  for y in range(k+1):
    z = s - x - y
    if 0 <= z and z <= k:
      count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
K, S = map(int, input().split())
count = 0
for X in range(K+1):
  for Y in range(K+1):
    for Z in range(K+1):
      if X + Y + Z = S:
        count += 1
print(count)

Fixed submission:
k, s = map(int, input().split())
count = 0
for x in range(k+1):
  for y in range(k+1):
    z = s - x - y
    if 0 <= z and z <= k:
      count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
count = 0
for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x + y + z == s:
        count += 1
print(count)

Fixed submission:
k, s = map(int, input().split())
count = 0
for x in range(k+1):
  for y in range(k+1):
    z = s - x - y
    if 0 <= z and z <= k:
      count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import functools
import operator
n=int(input())
li = list(map(int,input().split()))
result = functools.reduce(operator.mul, li)
if result >10**18: print(-1)
else:print(result)

Fixed submission:
import numpy as np
n = int(input())
target = 1
List = list(map(int,input().split()))
if 0 in List:
  print(0)
  exit()
for i in range(len(List)):
  target*=List[i]
  if target>10**18 :
    print(-1)
    exit()
print(target)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
List=list(map(int,input().split()))
total = 1
for i in range(n):
  total *= List[i]
if total >10**18: print(-1)
else:print(total)

Fixed submission:
import numpy as np
n = int(input())
target = 1
List = list(map(int,input().split()))
if 0 in List:
  print(0)
  exit()
for i in range(len(List)):
  target*=List[i]
  if target>10**18 :
    print(-1)
    exit()
print(target)
Buggy python submission (verdict: Runtime Error):
a,b = map(float,input().split())

x =(a*b,abs_tool =0.001)
print(int(x))

Fixed submission:
a,b = map(str,input().split())
a = int(a)
b = int(float(b)*100+0.001)
print(a*b//100)
Buggy python submission (verdict: Runtime Error):
import numpy as np
n,m = map(int,input().split())
H = list(map(int,input().split()))
A=np.zeros((n,n))
for i in range(m):
    a,b=input().split()
    A[int(a)-1][int(b)-1]=1
    A[int(b)-1][int(a)-1]=1
count = 0    
for i in range(n):
  best = H[i]
  for j in range(n):
      if A[i][j]==1 and best <= H[j]:
        best = H[j]
  if best == H[i]:
    count += 1
print(count)  

Fixed submission:
s= input()
if s == 'ABC':
  print('ARC')
elif s == 'ARC':
  print('ABC')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
A  =sorted(A)
for i in range(1,N):
    k = A.count(i)
    print(k)
    A = A[k:N]

print(0)

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

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
A  =sorted(A)
for i in range(1,N):
  if i in A :
    k = A.count(i)
    print(k)
    A = A[k:N]
  else:
    print(0)
print(0)

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

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

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

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
for i in range(1,N+1):
  print(A.count(i))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
l = [0]*N
for i in range(1,N):
  l[A[i-1]-1] += 1
for i in range(N):
  print(l[i])
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
import itertools
K = int(input())
def gcd(*numbers):
    return reduce(math.gcd, numbers)
count = 0
for i, j , k in itertools.product(range(K), range(K), range(K)):
  count += gcd(i+1,j+1,k+1)
      
print(count)

Fixed submission:
import math
K = int(input())
count = 0
for i in range(K):
  for j in range(K):
    x = math.gcd(i+1,j+1)
    for k in range(K):
      count += math.gcd(x,k+1)    
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
K = int(input())
def gcd(*numbers):
    return reduce(math.gcd, numbers)
count = 0
for i in range(K):
  for j in range(K):
    for k in range(K):
      count += gcd(i+1,j+1,k+1)
      
print(count)

Fixed submission:
import math
K = int(input())
count = 0
for i in range(K):
  for j in range(K):
    x = math.gcd(i+1,j+1)
    for k in range(K):
      count += math.gcd(x,k+1)    
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import math
K = int(input())
def gcd(a,b,c) :
  x = math.gcd(a,b)
  return math.gcd(x,c)
count = 0
for i in range(K):
  for j in range(K):
    for k in range(K):
      count += gcd(i+1,j+1,k+1)
      
print(count)

Fixed submission:
import math
K = int(input())
count = 0
for i in range(K):
  for j in range(K):
    x = math.gcd(i+1,j+1)
    for k in range(K):
      count += math.gcd(x,k+1)    
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
x0 = n
x1 = n
count = 0
while x0 >= 0 :
  x0 -= k
  count += 1
else:
  if min(x0+k,-x0) ==x0+k:
    print(x0+k)
  else :
    print(-x0)

Fixed submission:
n,k = map(int,input().split())
x0 = n
t = n//k+1
print(min(n%k,t*k-n))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = []
for i in range(n):
  S.append(input())
T = list(set(S))
count = []
for i in range(len(T)):
  count.append(S.count(T[i]))
best = max(count)
ans = []
for i in range(len(T)):
  if count[i] == best:
    ans.append( T[i])
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i]) 

Fixed submission:
from collections import Counter
n = int(input())
S = []
for i in range(n):
  S.append(input())
S = sorted(S)
c = Counter(S)
X = c.most_common()
A = []
for i in range(len(X)):
  if X[0][1] == X[i][1]:
    A.append(X[i][0])
  else:
    break
A = sorted(A)
for i in range(len(A)):
  print(A[i])

Buggy python submission (verdict: Runtime Error):
n = int(input())
S = []
for i in range(n):
  S.append(input())
T = list(set(S))
for i in range(len(T)):
  count.append(S.count(T[i]))
best = max(count)
ans = []
for i in range(len(T)):
  if count[i] == best:
    ans.append( T[i])
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i]) 

Fixed submission:
from collections import Counter
n = int(input())
S = []
for i in range(n):
  S.append(input())
S = sorted(S)
c = Counter(S)
X = c.most_common()
A = []
for i in range(len(X)):
  if X[0][1] == X[i][1]:
    A.append(X[i][0])
  else:
    break
A = sorted(A)
for i in range(len(A)):
  print(A[i])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = []
for i in range(n):
  S.append(input())
T = list(set(S))
count = []
counter =  []
for i in range(len(T)):
  count.append(S.count(T[i]))
  counter.append(T[i])
best = max(count)
ans = []
for i in range(len(T)):
  if count[i] == best:
    ans.append(counter[i])
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i]) 

Fixed submission:
from collections import Counter
n = int(input())
S = []
for i in range(n):
  S.append(input())
S = sorted(S)
c = Counter(S)
X = c.most_common()
A = []
for i in range(len(X)):
  if X[0][1] == X[i][1]:
    A.append(X[i][0])
  else:
    break
A = sorted(A)
for i in range(len(A)):
  print(A[i])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
for i in range(1,N):
  if A[i] in A[0:i]:
    print('NO')
    exit()
print('YES')

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = set(A)
if sorted(A) == sorted(B):
  print('YES')
else:
  print('NO')

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
track = []
for i in range(N):
  if A[i] in track:
    print('NO')
    exit()
  else:
    track.append(A[i])
print('YES')

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = set(A)
if sorted(A) == sorted(B):
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
H = list(map(int,input().split()))
H = sorted(H,reverse = True)
for i in range(k):
  if H == []:
    print(0)
    exit()
  else:
    H.pop(0)
print(sum(H))

Fixed submission:
n,k = map(int,input().split())
H = list(map(int,input().split()))
H = sorted(H,reverse = True)
if k >= n:
  print(0)
else:
  del H[0:k]
  print(sum(H))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
ans = 10000000000000000000000000000000000
n, k = map(int, input(). split())
p = list(map(int, input(). split()))
P = list(itertools.combinations(p, k))
s = len(P)
for i in range(s):
  P[i] = list(P[i])
  q = sum(P[i])
  if ans >= q:
    ans = q
print(ans)

Fixed submission:
n, k = map(int, input(). split())
p = list(map(int, input(). split()))
p = sorted(p)
ans = 0
for i in range(k):
  ans += p[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
ans = 10000000000000000000000000000000000
n, k = map(int, input(). split())
p = list(map(int, input(). split()))
P = list(itertools.permutations(p, k))
s = len(P)
for i in range(s):
  P[i] = list(P[i])
  q = sum(P[i])
  if ans >= q:
    ans = q
print(ans)

Fixed submission:
n, k = map(int, input(). split())
p = list(map(int, input(). split()))
p = sorted(p)
ans = 0
for i in range(k):
  ans += p[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input(). split()))
ans = 1
if a.count(0) >= 1:
  print(0)
  exit()
for i in range(n):
  ans = ans*a[i]
  if ans > 10**18:
    ans = -1
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input(). split()))
ans = 1
if a.count(0) >= 1:
  print(0)
  exit()
for i in range(n):
  ans = ans*a[i]
  if ans > 10**18:
    ans = -1
    break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input(). split()))
ans = 1
for i in range(n):
  ans = ans*a[i]
if ans > 10**18:
  ans = -1
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input(). split()))
ans = 1
if a.count(0) >= 1:
  print(0)
  exit()
for i in range(n):
  ans = ans*a[i]
  if ans > 10**18:
    ans = -1
    break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
c = 0
i = 0
for p in range(2, n): #nが合成数
  if n%p == 0:
    c += 1
    n /= p
    i += 1
if n != 1 and i == 0: #nが素数
  c += 1
print(c)

Fixed submission:
n = int(input())
c = 0
for p in range(2, int(n**0.5)+1): #nが合成数
  e = 0
  while n%p == 0:
    n //= p
    e += 1
  i = 1
  while e >= i:
    e -= i
    c += 1
    i += 1
if n != 1: #nが素数
  c += 1
print(c)
Buggy python submission (verdict: Runtime Error):
sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    s = list(input())
    t = list(input())
    x = len(s)
    y = len(t)
    ans = "Yes"
    for i in range(x):
      if (s[i] == t[i]) and (x+1 == y):
        ans = "Yes"
        continue
      else:
        ans = "No"
        break
    print(ans)    
      
    return

#Solve
if __name__ == "__main__":
    solve()

Fixed submission:
s = input()
t = input()
if s == t[:-1]:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    s = list(input())
    t = list(input())
    x = len(s)
    y = len(t)
    ans = "Yes"
    for i in range(x):
      if (s[i] == t[i]) and (x+1 == y):
        ans = "Yes"
        continue
      else:
        ans = "No"
        break
    print(ans)    
      
    return

#Solve
if __name__ == "__main__":
    solve()

Fixed submission:
s = input()
t = input()
if s == t[:-1]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations, accumulate
mod = 2019

a = list(map(int,input()))
n = len(a) #入力の桁数

for i in range(n):
    a[i] *= pow(10,n-i-1) #pow(a,b)==a^b べき乗
    a[i] %= mod
s = [0]+list(accumulate(a)) #accumulate([1,2,3,4,5]) --> 1 3 6 10 15
d = [0]*mod
ans = 0
for i in s:
    j = i%mod
    ans += d[j]
    d[j] += 1
print(ans)

Fixed submission:
from itertools import permutations, accumulate
mod = 2019

a = list(map(int,input()))
n = len(a) #入力の桁数

for i in range(n):
    a[i] *= pow(10,n-i-1,mod) #pow(a,b)==a^b べき乗
    
s = [0]+list(accumulate(a)) #accumulate([1,2,3,4,5]) --> 1 3 6 10 15
d = [0]*mod
ans = 0
for i in s:
    j = i%mod
    ans += d[j]
    d[j] += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations, accumulate
mod = 2019

a = list(map(int,input()))
n = len(a) #入力の桁数

for i in range(n):
    a[i] *= pow(10,n-i-1) #pow(a,b)==a^b べき乗
    
s = [0]+list(accumulate(a)) #accumulate([1,2,3,4,5]) --> 1 3 6 10 15
d = [0]*mod
ans = 0
for i in s:
    j = i%mod
    ans += d[j]
    d[j] += 1
print(ans)

Fixed submission:
from itertools import permutations, accumulate
mod = 2019

a = list(map(int,input()))
n = len(a) #入力の桁数

for i in range(n):
    a[i] *= pow(10,n-i-1,mod) #pow(a,b)==a^b べき乗
    
s = [0]+list(accumulate(a)) #accumulate([1,2,3,4,5]) --> 1 3 6 10 15
d = [0]*mod
ans = 0
for i in s:
    j = i%mod
    ans += d[j]
    d[j] += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = sorted(list(map(int, input().split())))
l = [int(i) for i in range(1, 101)]
ll = []
for idx in l:
    if idx not in p:
        ll.append(idx)
mn = abs(ll[0] - x)
ans = ll[0]
for i in range(len(ll)):
    if abs(ll[i] - x) < mn:
        mn = abs(ll[i] - x)
        ans = ll[i]
print(ans)

Fixed submission:
x, n = map(int, input().split())
p = sorted(list(map(int, input().split())))
l = [int(i) for i in range(-200, 201)]
ll = []
for idx in l:
    if idx not in p:
        ll.append(idx)
mn = 1000
if len(ll) == 0:
    print("")
else:
    mn = 1000
    for i in range(len(ll)):
        if abs(ll[i] - x) < mn:
            mn = abs(ll[i] - x)
            ans = ll[i]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= a[i]
if ans > 10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 1
flag = True
if 0 in a:
    print(0)
else:
    for i in range(n):
        ans *= a[i]
        if ans > 10**18:
            flag = False
            print(-1)
            break
    if flag:
        print(ans)
Buggy python submission (verdict: Runtime Error):
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

n = int(input())
a = divisors(n)
cnt = 0
for i in range(1, len(a)):
    b = prime_decomposition(a[i])
    if len(list(set(b))) == 1:
        if n % a[i] == 0:
            n //= a[i]
            cnt += 1
print(cnt)

Fixed submission:
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

n = int(input())
a = sorted(divisor(n))
cnt = 0
for i in range(1, len(a)):
    b = prime_decomposition(a[i])
    if len(list(set(b))) == 1:
        if n % a[i] == 0:
            n //= a[i]
            cnt += 1
print(cnt)

Buggy python submission (verdict: Runtime Error):
from sympy import divisors
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)

    divisors.sort()
    return divisors
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

n = int(input())
a = make_divisors(n)
cnt = 0
for i in range(1, len(a)):
    b = prime_decomposition(a[i])
    if len(list(set(b))) == 1:
        if n % a[i] == 0:
            n //= a[i]
            cnt += 1
print(cnt)

Fixed submission:
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

n = int(input())
a = sorted(divisor(n))
cnt = 0
for i in range(1, len(a)):
    b = prime_decomposition(a[i])
    if len(list(set(b))) == 1:
        if n % a[i] == 0:
            n //= a[i]
            cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n, m, x = map(int, input().split())
c = []
ans = []
for _ in range(n):
    l = list(map(int, input().split()))
    c.append(l)

for i in range(1, n+1):
    for vl in itertools.permutations(c, i):
        a = [0] * m
        p = 0
        for v in vl:
            p += v[0]
            for j in range(m):
                a[j] += v[1+j]
        flag = True
        for k in range(m):
            if a[k] < x:
                flag = False
        if flag:
            ans.append(p)
if len(ans) == 0:
    print(-1)
else:
    print(min(ans))

Fixed submission:
import itertools
n, m, x = map(int, input().split())
c = []
ans = []
for _ in range(n):
    l = list(map(int, input().split()))
    c.append(l)

for i in range(1, n+1):
    for vl in itertools.combinations(c, i):
        a = [0] * m
        p = 0
        for v in vl:
            p += v[0]
            for j in range(m):
                a[j] += v[1+j]
        flag = True
        for k in range(m):
            if a[k] < x:
                flag = False
        if flag:
            ans.append(p)
if len(ans) == 0:
    print(-1)
else:
    print(min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import math
a, b, n = map(int, input().split())
ans = 0
c = min(b, n)
for i in range(1, c+1):
    ans = max(ans, math.floor(a/b*i) - a * math.floor(i/b))
print(ans)

Fixed submission:
import math
a, b, n = map(int, input().split())
if b - 1 <= n:
    print(math.floor(a/b*(b-1)) - a * math.floor((b-1)/b))
else:
    print(math.floor(a/b*n) - a * math.floor(n/b))
Buggy python submission (verdict: Time Limit Exceeded):
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)

    divisors.sort()
    return divisors

n = int(input())
nl = make_divisors(n)
nl_p = make_divisors(n+1)
nl_m = make_divisors(n-1)
l = sorted(list(set(nl + nl_p+nl_m)))

ans = 0
for i in range(1, len(l)-1):
    p = n
    k = l[i]
    while p > k:
        if p%k == 0:
            p = p//k
        else:
            if (p-1)%k == 0:
                p = 1
                break
            p = p - k
    if p == 1:
        ans += 1
print(ans+1)

Fixed submission:
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)

    divisors.sort()
    return divisors

n = int(input())
nl = make_divisors(n)
nl_m = make_divisors(n-1)
l = sorted(list(set(nl + nl_m)))

ans = 0
for i in range(1, len(l)-1):
    p = n
    k = l[i]
    while p%k == 0:
        p = p // k
    if p%k == 1:
        ans += 1
print(ans+1)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
s = input()
que = deque(list(s))
q = int(input())
for _ in range(q):
    l = input()
    if l[0] == "1":
        s = s[::-1]
        que  = deque(list(s))
    else:
        if l[2] == "1":
            que.appendleft(l[4])
        else:
            que.append(l[4])
        s = list(que)
print("".join(s))

Fixed submission:
from collections import deque
s = input()
que = deque(list(s))
q = int(input())
flag = True
for _ in range(q):
    l = input()
    if flag:
        if l[0] == "1":
            flag = False
        else:
            if l[2] == "1":
                que.appendleft(l[4])
            else:
                que.append(l[4])
    else:
        if l[0] == "1":
            flag = True
        else:
            if l[2] == "1":
                que.append(l[4])
            else:
                que.appendleft(l[4])
if flag:
    ans = list(que)
    print("".join(ans))
else:
    ans = list(que)[::-1]
    print("".join(ans))