Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)


n = int(input())
ans = 0
done = []
for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            if (i, j, k) in done:
                continue
            else:
                ans += gcd(i, j, k)
                done.append((i, j, k))
print(ans)

Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)


n = int(input())
ans = 0
for i in range(1, n+1):
    for j in range(1, n+1):
        if i == j:
            ans += gcd(i, i, i)
        else:
            ans += gcd(i, i, j) * 3

kai = math.factorial(n)
for i in range(1, n+1):
    for j in range(i+1, n+1):
        for k in range(j+1, n+1):
            ans += gcd(i, j, k) * 6
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)


n = int(input())
ans = 0
for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            ans += gcd(i, j, k)
print(ans)


Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)


n = int(input())
ans = 0
for i in range(1, n+1):
    for j in range(1, n+1):
        if i == j:
            ans += gcd(i, i, i)
        else:
            ans += gcd(i, i, j) * 3

kai = math.factorial(n)
for i in range(1, n+1):
    for j in range(i+1, n+1):
        for k in range(j+1, n+1):
            ans += gcd(i, j, k) * 6
print(ans)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
ans = n
done = [n]

if k == 1 or n == k:
    print(0)
elif n > k:
    r = n % k
    print(k-r)
elif n < k:
    print(k%n)

Fixed submission:
n, k = map(int, input().split())

if n == 0 or k == 1:
    print(0)
else:
    if n > k:
        n %= k
    print(min(n, k-n))

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
ans = n
done = [n]

if k == 1:
    print(0)
else:
    while 1:
        n = abs(n-k)
        ans = min(ans, n)

        if n in done or n == 0:
            break
        else:
            done.append(n)
    print(ans)

Fixed submission:
n, k = map(int, input().split())

if n == 0 or k == 1:
    print(0)
else:
    if n > k:
        n %= k
    print(min(n, k-n))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
k = [int(i) for i in input().split()]
pair = {}

for i in range(n):
    pair.setdefault(k[i], []).append(i)

for i in range(n):
    ans = 0
    for value in pair.values():
        l = len(value)-1 if i in value else len(value)
        ans += l*(l-1)//2
    print(ans)

Fixed submission:
n = int(input())
k = [int(i) for i in input().split()]
pair = {}

for i in range(n):
    pair.setdefault(k[i], []).append(i)

sum = 0
for value in pair.values():
    l = len(value)
    sum += l*(l-1)//2

for i in range(n):
    len_pair = len(pair[k[i]])
    if len_pair != 1:
        ans = sum - ((len_pair*(len_pair-1)//2)-((len_pair-1)*(len_pair-2)//2))
        print(ans)
    else:
        print(sum)
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
if h == 1 or w == 1:
    print(a)
else:
    print(int(((h*w)+1) / 2))

Fixed submission:
h, w = map(int, input().split())
if h == 1 or w == 1:
    print(1)
else:
    print(int(((h*w)+1) / 2))
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = int(input())
re = 1

for i in range(n):
    q = input().split()
    if q[0] == '1':
        re = re * -1
    else:
        if re == 1:
            if q[1] == '1':
                s.insert(0, q[2])
            else:
                s.append(q[2])
        else:
            if q[1] == '1':
                s.append(q[2])
            else:
                s.insert(0, q[2])

print(''.join(s)) if re == 1 else print(''.join(s[::-1]))

Fixed submission:
s = input()
n = int(input())
re = 1
head = ''
tail = ''

for i in range(n):
    q = input().split()
    if q[0] == '1':
        re = re * -1
    else:
        if re == 1:
            if q[1] == '1':
                head = q[2] + head
            else:
                tail = tail + q[2]
        else:
            if q[1] == '1':
                tail = tail + q[2]
            else:
                head = q[2] + head

print(head+s+tail) if re == 1 else print((head+s+tail)[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = int(input())
re = 1

for i in range(n):
    q = input().split()
    if q[0] == '1':
        re = re * -1
    else:
        if re == 1:
            if q[1] == '1':
                s = q[2] + s
            else:
                s = s + q[2]
        else:
            if q[1] == '1':
                s = s + q[2]
            else:
                s = q[2] + s

print(s) if re == 1 else print(s[::-1])

Fixed submission:
s = input()
n = int(input())
re = 1
head = ''
tail = ''

for i in range(n):
    q = input().split()
    if q[0] == '1':
        re = re * -1
    else:
        if re == 1:
            if q[1] == '1':
                head = q[2] + head
            else:
                tail = tail + q[2]
        else:
            if q[1] == '1':
                tail = tail + q[2]
            else:
                head = q[2] + head

print(head+s+tail) if re == 1 else print((head+s+tail)[::-1])

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

for i in range(n):
    q = input().split()
    if q[0] == '1':
        s = s[::-1]
    else:
        if q[1] == '1':
            s = q[2] + s
        else:
            s = s + q[2]

print(s)

Fixed submission:
s = input()
n = int(input())
re = 1
head = ''
tail = ''

for i in range(n):
    q = input().split()
    if q[0] == '1':
        re = re * -1
    else:
        if re == 1:
            if q[1] == '1':
                head = q[2] + head
            else:
                tail = tail + q[2]
        else:
            if q[1] == '1':
                tail = tail + q[2]
            else:
                head = q[2] + head

print(head+s+tail) if re == 1 else print((head+s+tail)[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = list(range(9, 1, -1))
ans = 0
flag = 1

if n > 1:
    while n > 1:
        for i in list:
            if n % i == 0:
                n = n / i
                ans += 1
                flag = 0
                break

        if flag == 1:
            ans = 0
            break
elif n == 1:
    ans = 2

if 0 < ans <= 2:
    print("Yes")
else:
    print("No")


Fixed submission:
n = int(input())
list = list(range(9, 1, -1))
ans = 0

if n > 1:
    while n > 1:
        flag = 1
        for i in list:
            if n % i == 0:
                n = n / i
                ans += 1
                flag = 0
                break

        if flag == 1:
            ans = 0
            break
elif n == 1:
    ans = 2

if 0 < ans <= 2:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = list(range(9, 1, -1))
ans = 0

while n > 1:
    for i in list:
        if n % i == 0:
            n = n / i
            ans += 1
            break

if ans > 2:
    print("No")
else:
    print("Yes")


Fixed submission:
n = int(input())
list = list(range(9, 1, -1))
ans = 0

if n > 1:
    while n > 1:
        flag = 1
        for i in list:
            if n % i == 0:
                n = n / i
                ans += 1
                flag = 0
                break

        if flag == 1:
            ans = 0
            break
elif n == 1:
    ans = 2

if 0 < ans <= 2:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0

for a in range(len(L)-2):
    for b in range(a+1, len(L)-1):
        ans += bisect.bisect_left(L[b+1:], L[a]+L[b])
print(ans)

Fixed submission:
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0

for a in range(N-2):
    for b in range(a+1, N-1):
        ans += bisect.bisect_left(L, L[a]+L[b]) - (b+1)
print(ans)

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

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0

for a in range(len(L)):
    for b in range(a+1, len(L)):
        ans += bisect.bisect_left(L[b+1:], L[a]+L[b])
print(ans)

Fixed submission:
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0

for a in range(N-2):
    for b in range(a+1, N-1):
        ans += bisect.bisect_left(L, L[a]+L[b]) - (b+1)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = map(int, input().split())
point = [k]*n

for i in range(q):
  answer = int(input())
  
  point = [p-1 for p in point]
  point[answer-1] += 1

for p in point:
  if p <= 0:
    print("No")
  else:
    print("Yes")

Fixed submission:
n, k, q = map(int, input().split())
point = [k-q]*n

for i in range(q):
  answer = int(input())
  
  point[answer-1] += 1

for p in point:
  if p <= 0:
    print("No")
  else:
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))

for i in range(M):
  index = A.index(max(A))
  A[index] = A[index] // 2
  
print(sum(A))

Fixed submission:
import heapq
import math

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = [i*-1 for i in A]

heapq.heapify(A)

for i in range(M):
  kk = math.ceil(heapq.heappop(A) / 2)
  heapq.heappush(A, kk)

A = [i*-1 for i in A]

print(sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = list(map(int, input().split()))
count = 0

for i in range(N-1):
  moving = 0
  for j in range(i, N-1):
    if H[j] >= H[j+1]:
      moving += 1
    else:
      i = j + 1
      break
      
    if moving > count:
      count = moving
      
print(count)

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
count = 0
i = 0

while i < N-1:
  moving = 0
  for j in range(i, N-1):
    if H[j] >= H[j+1]:
      moving += 1
    else:
      i = j + 1
      break
      
    if moving > count:
      count = moving
      
    i += 1
      
print(count)

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

for i in range(N-1):
  moving = 0
  for j in range(i, N-1):
    if H[j] >= H[j+1]:
      moving += 1
    else:
      break
      
    if moving > count:
      count = moving
      
print(count)

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
count = 0
i = 0

while i < N-1:
  moving = 0
  for j in range(i, N-1):
    if H[j] >= H[j+1]:
      moving += 1
    else:
      i = j + 1
      break
      
    if moving > count:
      count = moving
      
    i += 1
      
print(count)
Buggy python submission (verdict: Runtime Error):
n, k = input().split()
d = input().split()
valid = [i for i in range(10) if str(i) not in d]
ans = ''

if valid[-1] < int(n[0]):
    if valid[0] == 0:
        ans += str(valid[1])
    else:
        ans += str(valid[0])
    ans += str(valid[0]) * len(n)
else:
    for i, s in enumerate(n):
        if i > 0 and ans[i-1] > n[i-1]:
            ans += str(valid[0]) * (len(n)-i)
            break

        for k in valid:
            if k >= int(s):
                ans += str(k)
                break
print(ans)

Fixed submission:
n, k = input().split()
d = input().split()
valid = [i for i in range(10) if str(i) not in d]
ans = ''

if valid[-1] < int(n[0]):
    if valid[0] == 0:
        ans += str(valid[1])
    else:
        ans += str(valid[0])
    ans += str(valid[0]) * len(n)
elif valid[-1] == int(n[0]):
    for s in n:
        if s > str(valid[-1]):
            ans = str(valid[-1])
            ans += str(valid[0]) * len(n)
            break
        ans += str(valid[-1])
else:
    for i, s in enumerate(n):
        if i > 0 and ans[i-1] > n[i-1]:
            ans += str(valid[0]) * (len(n)-i)
            break

        for k in valid:
            if k >= int(s):
                ans += str(k)
                break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = map(int,input().split())
ans=1
for i in li:
    ans*=i
    if ans>10**18:
        ans=-1
if ans<0:
    ans=-1
print(ans)

Fixed submission:
n = int(input())
li = map(int,input().split())
ans=1
mx=10**18
for i in li:
    ans*=i
    if ans>mx:
        ans=-1
        break
for i in li:
    if i==0:
        ans=0
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
n=map(int,input().split())
print(0.5 if n%2==0 else ceil(n/2)/n)

Fixed submission:
import math
n=int(input())
ans=0.5 if n%2==0 else math.ceil(n/2)/n
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
ans = -1
if K in [2,5]:
    pass
else:
    num = 7
    ans = 0
    while True:
        ans += 1
        if num % K == 0:
            break
        else:
            num = (num * 10 + 7)%K
print(ans)

Fixed submission:
K = int(input())
ans = -1
if K%2 == 0:
    pass
elif K%5 == 0:
    pass
else:
    num = 7
    ans = 0
    while True:
        ans += 1
        if num % K == 0:
            break
        else:
            num = (num * 10 + 7)%K
print(ans)

Buggy python submission (verdict: Runtime Error):
ans = -1
if K in [2,5]:
    pass
else:
    num = 7
    ans = 0
    while True:
        ans += 1
        if num % K == 0:
            break
        else:
            num = (num * 10 + 7)%K
print(ans)

Fixed submission:
K = int(input())
ans = -1
if K%2 == 0:
    pass
elif K%5 == 0:
    pass
else:
    num = 7
    ans = 0
    while True:
        ans += 1
        if num % K == 0:
            break
        else:
            num = (num * 10 + 7)%K
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
ans = -1
if K in [2,5]:
    pass
else:
    num = 7
    ans = 0
    while True:
        ans += 1
        if num % K == 0:
            break
        else:
            num = num * 10 + 7
print(ans)

Fixed submission:
K = int(input())
ans = -1
if K%2 == 0:
    pass
elif K%5 == 0:
    pass
else:
    num = 7
    ans = 0
    while True:
        ans += 1
        if num % K == 0:
            break
        else:
            num = (num * 10 + 7)%K
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
def digit_sum(n):
    # 各桁の和を求める
    # 計算量: O(logN)
    ans = 0
    while n > 0:
        ans += n % 10
        n //= 10
    return ans
if digit_sum(n)%9 ==0:
  print('Yes')
else:
  print('No')

Fixed submission:
n = int(input())
if n%9 ==0:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a =list(map(int,input().split()))
b = []
c = 1
for i in range(0,k):
  c *= a[i]
b.append(c)
for i in range(0, n-k):
  b.append(b[i]*a[i+k]//a[i])
for j in range(1, len(b)):
  if b[j-1] < b[j]:
    print('Yes')
  else:
    print('No')

Fixed submission:
n,k = map(int,input().split())
a =list(map(int,input().split()))
for i in range(0, len(a)-k):
  if a[i] < a[i+k]:
    print('Yes')
  else:
    print('No')

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a =list(map(int,input().split()))
b = []
c = 1
for i in range(0,k):
  c *= a[i]
b.append(c)
for i in range(0, n-k):
  b.append(b[i]*a[i+k]//a[i])
for j in range(1, len(b)):
  if b[j-1] < b[j]:
    print('Yes')
  else:
    print('No')

Fixed submission:
n,k = map(int,input().split())
a =list(map(int,input().split()))
for i in range(0, len(a)-k):
  if a[i] < a[i+k]:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
for p in range(1,n+1):
  ans = 0
  for i in range(1, 101):
    for j in range(1, min(i+1,50)):
      for k in range(1, min(j+1, 34)):
        if (i+j+k)**2-i*j-j*k-k*i == p:
          if i==j==k:
            ans += 1
          else:
            ans += 3
  print(ans) 
    


Fixed submission:
n = int(input())
a = [0]*10**4
ans = 0
for i in range(1, 101):
  for j in range(1, min(i+1,101)):
    for k in range(1, min(j+1, 101)):
       if (i+j+k)**2-i*j-j*k-k*i <= 10**4:
          p = (i+j+k)**2-i*j-j*k-k*i
          if i==j==k:
             a[p-1] +=1
          elif i != j and j != k:
             a[p-1] +=6
          else:
             a[p-1] +=3
for q in a[:n]:
  print(q)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
for p in range(1,n+1):
  ans = 0
  for i in range(1, 101):
    for j in range(1, min(i+1,50)):
      for k in range(1, min(j+1, 34)):
        if (i+j+k)**2-i*j-j*k-k*i == p:
          if i==j==k:
            ans += 1
          else:
            ans += 3
  print(ans) 
    

Fixed submission:
n = int(input())
a = [0]*10**4
ans = 0
for i in range(1, 101):
  for j in range(1, min(i+1,101)):
    for k in range(1, min(j+1, 101)):
       if (i+j+k)**2-i*j-j*k-k*i <= 10**4:
          p = (i+j+k)**2-i*j-j*k-k*i
          if i==j==k:
             a[p-1] +=1
          elif i != j and j != k:
             a[p-1] +=6
          else:
             a[p-1] +=3
for q in a[:n]:
  print(q)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a.sort()
p = []
while True:
        if len(a) == 0:
           break
        prime = min(a)       
        if len(a) ==  1:
            p.append(prime)
            break    
        if prime != a[1]:
          p.append(prime)    
        i = 0
        while i < len(a):
            if a[i] % prime == 0:
                a.pop(i)
                continue
            i += 1  
print(len(p))

Fixed submission:
n = int(input())
a = sorted(map(int,input().split()))

ans = 0

baisu = [0]*(a[n-1]+1)
an = a[n-1]

for i in range(n):
    a0 = a[i]
    a1 = a0
    while a1 <= an:
        baisu[a1] += 1
        a1 += a0


for i in range(n):
    if baisu[a[i]] == 1:
        ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a.sort()
p = []
while True:
        if len(a) == 0:
           break
        prime = min(a)       
        if len(a) ==  1:
            p.append(prime)
            break    
        if prime != a[1]:
          p.append(prime)    
        i = 0
        while i < len(a):
            if a[i] % prime == 0:
                a.pop(i)
                continue
            i += 1  
print(len(p))

Fixed submission:
n = int(input())
a = sorted(map(int,input().split()))

ans = 0

baisu = [0]*(a[n-1]+1)
an = a[n-1]

for i in range(n):
    a0 = a[i]
    a1 = a0
    while a1 <= an:
        baisu[a1] += 1
        a1 += a0


for i in range(n):
    if baisu[a[i]] == 1:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
s = list(input())
if s[0] == '?':
  s[0] = "D"
for i in range(1, len(s)):
  if s[i] == '?':
    if s[i-1]== 'D' and (s[i+1] == 'D' or s[i+1] == '?'):
      s[i] = 'P'
    else: 
      s[i] = 'D'
print("".join(s))

Fixed submission:
s = list(input())
if s[0] == '?':
  s[0] = "D"
for i in range(1, len(s)-1):
  if s[i] == '?':
    if s[i-1]== 'D' and (s[i+1] == 'D' or s[i+1] == '?'):
      s[i] = 'P'
    else: 
      s[i] = 'D'
if s[len(s)-1] == '?':
  s[len(s)-1] = 'D'
print("".join(s))
Buggy python submission (verdict: Runtime Error):
a

Fixed submission:
T = int(input())

for t in range(T):
    N, A, B, C, D = map(int, input().split())
    memo = {}

    def dist(n):
        if n == 0:
            return 0
        if n == 1:
            return D
        if n in memo:
            return memo[n]
        
        ret = min(
            D * n,
            D * abs(n - n//5*5) + C + dist(n//5),
            D * abs(n - (n+4)//5*5) + C + dist((n+4)//5),
            D * abs(n - n//3*3) + B + dist(n//3),
            D * abs(n - (n+2)//3*3) + B + dist((n+2)//3),
            D * abs(n - n//2*2) + A + dist(n//2),
            D * abs(n - (n+1)//2*2) + A + dist((n+1)//2)
        )

        memo[n] = ret
        return ret
    print(dist(N))
Buggy python submission (verdict: Runtime Error):
n = input()
if n[-1] == "3":
  print("bon")
if n[-1] == "0" or n[-1] == "1" or n[-1] == "6" or n[-1] == "8":
  print("pon")
else:
  print(hon)

Fixed submission:
n = input()
if n[-1] == "3":
  print("bon")
elif n[-1] == "0" or n[-1] == "1" or n[-1] == "6" or n[-1] == "8":
  print("pon")
else:
  print("hon")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split())) 
c = 0
for i in range(n):
  for j in range(i+1, n):
    if max(i-j, j-i) == a[i]+a[j]:
      c +=1
print(c)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
# a+i と i-aのとりうる値の個数をカウントするが
# 一致するとしても[0, n)の範囲だけなのでDの大きさはnで十分
D = [0]*n
for i, a in enumerate(A):
    if 1+i+a < n:
        D[i+a] += 1
ans = 0
# i-aに対応するD[i-a]を加えるだけで答えが求まる
for i, a in enumerate(A):
    if 1+i-a >= 0:
        ans += D[i-a]
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
ans = 0
for x in range(n+1):
 c = int(a*x/b)
 d = int(x/b)
 e = c - a*d
 ans = max(ans, e)
print(ans)


Fixed submission:
k=int(input())
a, b=map(int, input().split())
c = True
for i in range(a, b+1):
  if i%k ==0:
    print("OK")
    c = False
    break
if c:
  print("NG")

Buggy python submission (verdict: Runtime Error):
k=int(input())
a, b=map(int, input().split())
c = True
for i in range(a, b+1):
  if i%k ==0:
    print(OK)
    c = False
    break
if c:
  print(NG)


Fixed submission:
k=int(input())
a, b=map(int, input().split())
c = True
for i in range(a, b+1):
  if i%k ==0:
    print("OK")
    c = False
    break
if c:
  print("NG")
Buggy python submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
c = max(b-1, n)
parint(int(a*c/b))

Fixed submission:
a, b, n = map(int, input().split())
c = min(b-1, n)
print(int(a*c/b))

Buggy python submission (verdict: Time Limit Exceeded):
a, b, n = map(int, input().split())
p = 10**9+7
ans = 0
for x in range(n+1):
 c = (int((a*x)%p/b))%p
 d = (int(x/b))%p
 e = (c - a*d)%p
 ans = max(ans, e)
print(ans)

Fixed submission:
a, b, n = map(int, input().split())
c = min(b-1, n)
print(int(a*c/b))

Buggy python submission (verdict: Time Limit Exceeded):
a, b, n = map(int, input().split())
ans = 0
for x in range(n+1):
 c = int(a*x/b)
 d = int(x/b)
 e = c - a*d
 ans = max(ans, e)
print(ans)


Fixed submission:
a, b, n = map(int, input().split())
c = min(b-1, n)
print(int(a*c/b))

Buggy python submission (verdict: Time Limit Exceeded):
a, b, n = map(int, input().split())
ans = 0
for x in range(n+1):
 c = int(a*x/b)
 d = int(x/b)
 e = c - a*d
 ans = max(ans, e)
print(ans)


Fixed submission:
a, b, n = map(int, input().split())
c = min(b-1, n)
print(int(a*c/b))
Buggy python submission (verdict: Runtime Error):
s,w = map(int, input().split())
if s =< w:
  print("unsafe")
else:
  print("safe")

Fixed submission:
s,w = map(int, input().split())
if s <= w:
  print("unsafe")
else:
  print("safe")