Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
# B  => TLE
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0]*n
for i in range(1, n):
    a = 10**100
    if i >= k:
        for j in range(1, k+1):
            if a > dp[i-j] + abs(h[i-j]-h[i]):
                a = dp[i-j] + abs(h[i-j]-h[i])
    else:
        for j in range(1, i+1):
            if a > dp[i-j] + abs(h[i-j]-h[i]):
                a = dp[i-j] + abs(h[i-j]-h[i])
    dp[i] = a
    
print(dp[-1])

Fixed submission:
# B  => TLE
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0]*n
for i in range(1, n):
    a = 10**100
    if i >= k:
        for j in range(1, k+1):
            if a > dp[i-j] + abs(h[i-j]-h[i]):
                a = dp[i-j] + abs(h[i-j]-h[i])
    else:
        for j in range(1, i+1):
            if a > dp[i-j] + abs(h[i-j]-h[i]):
                a = dp[i-j] + abs(h[i-j]-h[i])
    dp[i] = a
    
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0]*n
for i in range(1, n):
    a = []
    if i >= k:
        for j in range(1, k+1):
            a.append(dp[i-j] + abs(h[i-j]-h[i]))
    else:
        for j in range(1, i+1):
            a.append(dp[i-j] + abs(h[i-j]-h[i]))
    dp[i] = min(a)
    
print(dp[-1])

Fixed submission:
# B  => TLE
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0]*n
for i in range(1, n):
    a = 10**100
    if i >= k:
        for j in range(1, k+1):
            if a > dp[i-j] + abs(h[i-j]-h[i]):
                a = dp[i-j] + abs(h[i-j]-h[i])
    else:
        for j in range(1, i+1):
            if a > dp[i-j] + abs(h[i-j]-h[i]):
                a = dp[i-j] + abs(h[i-j]-h[i])
    dp[i] = a
    
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
# D
n, W = map(int, input().split())
w = []
v = []
for i in range(n):
    ww, vv = map(int, input().split())
    w.append(ww)
    v.append(vv)
    
dp = [[0]*(W+1) for _ in range(n+1)]
for i in range(n):
    for j in range(W+1):
        if j < w[i]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])
print(dp[n][W])

Fixed submission:
# D
n, W = map(int, input().split())
w = []
v = []
for i in range(n):
    ww, vv = map(int, input().split())
    w.append(ww)
    v.append(vv)
    
dp = [[0]*(W+1) for _ in range(n+1)]
for i in range(n):
    for j in range(W+1):
        if j < w[i]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])
print(dp[n][W])
Buggy python submission (verdict: Runtime Error):
# B
x1, y1, x2, y2 = map(int, input().split())

import numpy as np
R_90 = np.array([[0, -1], [1, 0]])
oa = np.array([x1, y1])
ab = np.array([x2 - x1, y2 - y1])
ad = R_90 @ ab
od = oa + ad
oc = od + ab

od = map(str, list(od))
oc = map(str, list(oc))

print(' '.join(list(oc)) +' ' + ' '.join(list(od)))

Fixed submission:
# B
x1, y1, x2, y2 = map(int, input().split())

od = [x1+y1-y2, y1-x1+x2]
oc = [x2-y2+y1, -x1+x2+y2]

od = map(str, list(od))
oc = map(str, list(oc))

print(' '.join(list(oc)) +' ' + ' '.join(list(od)))

Buggy python submission (verdict: Runtime Error):
# B
x1, y1, x2, y2 = map(int, input().split())

import numpy as np
R_90 = np.array([[0, -1], [1, 0]])
oa = np.array([x1, y1])
ab = np.array([x2 - x1, y2 - y1])
ad = R_90 @ ab
od = oa + ad
oc = od + ab

od = map(str, list(od))
oc = map(str, list(oc))

print(' '.join(list(oc)) +' ' + ' '.join(list(od)))

Fixed submission:
# B
x1, y1, x2, y2 = map(int, input().split())

od = [x1+y1-y2, y1-x1+x2]
oc = [x2-y2+y1, -x1+x2+y2]

od = map(str, list(od))
oc = map(str, list(oc))

print(' '.join(list(oc)) +' ' + ' '.join(list(od)))
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())

if abs(b-a) <= d:
    if abs(c-b) <= d:
        print('Yes')
    else:
        print('No')
        break
else:
    print('No')

Fixed submission:
a, b, c, d = map(int, input().split())

if abs(b-a) <= d and abs(c-b) <= d:
        print('Yes')
elif abs(a-c) <= d:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
if B-A < 2*K:
  for i in range(A, B+1):
    print(i)
else:
  for i in range(0, K):
    print(A+i)
  for i in reversed(range(0, K)):
    print(B-i)
A, B, K = map(int, input().split())
if B-A < 2*K:
  for i in range(A, B+1):
    print(i)
else:
  for i in range(0, K):
    print(A+i)
  for i in reversed(range(0, K)):
    print(B-i)

Fixed submission:
A, B, K = map(int, input().split())
if B-A < 2*K:
  for i in range(A, B+1):
    print(i)
else:
  for i in range(0, K):
    print(A+i)
  for i in reversed(range(0, K)):
    print(B-i)
Buggy python submission (verdict: Runtime Error):
a = list(map(str, input())
b = list(map(str, input())
c = list(map(str, input())

print(a[0]+b[1]+c[2], end='')

Fixed submission:
a = list(map(str, input()))
b = list(map(str, input()))
c = list(map(str, input()))

print(a[0]+b[1]+c[2], end='')

Buggy python submission (verdict: Runtime Error):
a = list(map(str, input().split()))
b = list(map(str, input().split()))
c = list(map(str, input().split()))

print(a[0]+b[1]+c[2], end='')

Fixed submission:
a = list(map(str, input()))
b = list(map(str, input()))
c = list(map(str, input()))

print(a[0]+b[1]+c[2], end='')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

alice = []
bob = []

while A != []:
	alice.append(max(A))
	A.remove(max(A))
	bob.append(max(A))
	A.remove(max(A))
	
print(sum(alice)-sum(bob))

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

alice = []
bob = []

while A != []:
	alice.append(max(A))
	A.remove(max(A))
	if A != []:
		bob.append(max(A))
		A.remove(max(A))
	else: 
		break
print(sum(alice)-sum(bob))
Buggy python submission (verdict: Runtime Error):
A, B, C, X = map(int, input().split())
ans = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if X == 500*a + 100*b + 50*c:
                ans += 1
            else:
                continue
print(ans)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if X == 500*a + 100*b + 50*c:
                ans += 1
            else:
                continue
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
t = [0]
x = [0]
y = [0]
for _ in range(N):
    T, X, Y = map(int, input().split())
    t.append(T)
    x.append(X)
    y.append(Y)
    
bool = True
for i in range(N):
    dt = t[i+1]-t[i]
    dist = abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
    if dt < dist:
        bool = False
    elif dist%2 != dt%2:
        bool = False
        
if bool == True:
    print('Yes')
else:
    print('No')

Fixed submission:
a, b = map(int, input().split())
if (a*b)%2 == 0:
    print('Even')
elif (a*b)%2 == 1:
    print('Odd')

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    a.append(list(map(int, input().split())))
x = 0
y = 0


for i in range(len(a)):
  x_goal = a[i][1]
  y_goal = a[i][2]
  if i == 0:
    t = a[i][0]
    if y_goal >= 0:
      while y != y_goal:
        y += 1
        t -= 1
    else:
      while y != y_goal:
        y -= 1
        t -= 1
    for time0 in range(t):
      if x > x_goal:
        x -= 1
      else:
        x += 1
    if x == x_goal:
      continue
    else:
      continue
      
  elif i != 0:
    t = a[i][0]-a[i-1][0]
    t = a[i][0]-a[i-1][0]
  while y != y_goal:
    if y_goal > y:
      y += 1
      t -= 1
    elif y_goal < y:
      y -= 1
      t -= 1
    
    for time1 in range(t):
      if x > x_goal:
        x -= 1
      else:
        x += 1
if x == x_goal:
  print('Yes')
else:
  print('No')

Fixed submission:
a, b = map(int, input().split())
if (a*b)%2 == 0:
    print('Even')
elif (a*b)%2 == 1:
    print('Odd')

Buggy python submission (verdict: Runtime Error):
a, b = int(input())
if (a*b)%2 == 0:
    print('Even')
elif (a*b)%2 == 1:
    print('Odd')

Fixed submission:
a, b = map(int, input().split())
if (a*b)%2 == 0:
    print('Even')
elif (a*b)%2 == 1:
    print('Odd')

Buggy python submission (verdict: Runtime Error):
a, b = int(input())
if (a*b)%2 == 0:
  print('Even')
elif (a*b)%2 == 1:
  print('Odd')

Fixed submission:
a, b = map(int, input().split())
if (a*b)%2 == 0:
    print('Even')
elif (a*b)%2 == 1:
    print('Odd')
Buggy python submission (verdict: Runtime Error):
a, b = input().split()
ab = int(a + b)
for _ in range(100000):
  if ab == i^2:
    print('Yes')
  else:
    print('No')

Fixed submission:
a, b = input().split()
ab = int(a + b)
ans = False
for i in range(100000):
    if ab == i**2:
        ans = True
    else:
        continue
if ans == True:
    print('Yes')
elif ans == False:
    print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
d = [int(input()) for i in range(n)]

num = [0]*100
for i in range(n):
    num[d[i]] += 1

ans = 0
for i in range(100):
    if num[i] > 0:  # num[i] == 1　の方が直観的に理解しやすいかも
        ans += 1
print(ans)

Fixed submission:
N = int(input())
mochi = set()
for i in range(N):
	r = int(input())
	mochi.add(r)

print(len(mochi))
Buggy python submission (verdict: Time Limit Exceeded):
q = int(input())
a = []
for i in range(q):
    l, r = map(int, input().split())
    a.append([l, r])

def is_prime(n):
    for i in range(2, int(n**(1/2))+1, 1):
        if n%i == 0:
            return False
    return n != 1

def lnum(n):  # Like number
    if is_prime(n) and is_prime((n+1)//2):
        return True
    else:
        return False

ans = [0]*q
for j in range(q):
    for k in range(a[j][0], a[j][1]+1, 1):
        if lnum(k):
            ans[j] += 1
        else:
            continue
for x in ans:
    print(x, end=" ")

Fixed submission:
def is_prime(n):
    for i in range(2, int(n**(1/2))+1, 1):
        if n%i == 0:
            return False
    return n != 1

def lnum(n):  # Like number
    if is_prime(n) and is_prime((n+1)//2):
        return True
    else:
        return False

MAX = 101010
a = [0]*MAX
for i in range(MAX):
    if lnum(i):
        a[i] = 1
    else:
        continue

s = [0]*MAX
for i in range(MAX-1):
    s[i+1] = s[i] + a[i]
    
q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    print(s[r+1]-s[l])
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

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

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

count = gcd_list(a)
ans = 0
while count%2 == 0:
    ans += 1
    count /= 2
    
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(len(a)):
    count = 0
    while a[i]%2 == 0:
        a[i] = a[i]/2
        count += 1
    if a[i]%2 == 1:
        ans.append(count)
print(min(ans))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

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

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

count = gcd_list(a)
ans = 0
while count%2 == 0:
    ans += 1
    count /= 2
    
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(len(a)):
    count = 0
    while a[i]%2 == 0:
        a[i] = a[i]/2
        count += 1
    if a[i]%2 == 1:
        ans.append(count)
print(min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
# C
n = int(input())
l = list(map(int, input().split()))

m = 0
for i in range(1, 10**5):
    if m < l.count(i-1)+l.count(i)+l.count(i+1):
        m = l.count(i-1)+l.count(i)+l.count(i+1)
        
print(m)

Fixed submission:
# C
n = int(input())
a = list(map(int, input().split()))

l = [0]*(10**5+10)
for i in range(n):
    l[a[i]] += 1
    
s = 0
for j in range(1, len(l)-1):
    if  s < l[j-1] + l[j] + l[j+1]:
        s = l[j-1] + l[j] + l[j+1]
        
print(s)
Buggy python submission (verdict: Runtime Error):
S = set(map(str, (input())))
s = list(S)
s.sort()
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'z']
for i in range(len(s)-1):
    alphabet.remove(s[i])

if alphabet == []:
    print('None')
else:
    print(alphabet[0])

Fixed submission:
S = set(map(str, (input())))
s = list(S)
s.sort()
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
for i in range(len(s)):
    alphabet.remove(s[i])

if alphabet == []:
    print('None')
else:
    print(alphabet[0])

Buggy python submission (verdict: Runtime Error):
S = set(map(str, (input())))
s = list(S)
s.sort()
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'z']
for i in range(len(s)-1):
    alphabet.remove(s[i])

if alphabet == []:
    print('None')
else:
    print(alphabet[0])

Fixed submission:
S = set(map(str, (input())))
s = list(S)
s.sort()
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
for i in range(len(s)):
    alphabet.remove(s[i])

if alphabet == []:
    print('None')
else:
    print(alphabet[0])
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
ans = []

for i in range(K):
    ans.append(l[i])
    
print(sum(ans))

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

if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0:
    print('Possible')
else:
    print('Impossible')
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
L = list(map(int, input().split()))
L = L.sorted(reverse=True)
sum = 0

for i in L:
  sum += L[i]

Fixed submission:
N, K = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
ans = []

for i in range(K):
    ans.append(l[i])
    
print(sum(ans))

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
L = list(map(int, input().split()))
L = L.sort(reverse=True)
sum = 0

for i in L:
  sum += L[i]

Fixed submission:
N, K = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
ans = []

for i in range(K):
    ans.append(l[i])
    
print(sum(ans))
Buggy python submission (verdict: Runtime Error):
n = int(input())

def F(a, b):
    return max(len(str(a)), len(str(b)))

ans = 10**10
for i in range(1, n**(1/2)+1):
    j = n / i
    if (n/i)%1 == 0:
        j = n // i
        if ans > F(i, j):
            ans = F(i, j)
        
print(ans)

Fixed submission:
# ABC 057 C - Digits in Multiplication
# 2020/04/07　20:6-
n = int(input())

def F(a, b):
    A = len(str(a))
    B = len(str(b))
    return max(A, B)

ans = 10**12
for i in range(1, int(n**(1/2))+1):
    j = n / i
    if j%1 == 0:
        j = n // i
        if ans > F(i, j):
            ans = F(i, j)
            
print(ans)

Buggy python submission (verdict: Runtime Error):
# ABC 057 C - Digits in Multiplication
# 2020/04/07　20:6-
n = int(input())

def F(a, b):
    A = len(str(a))
    B = len(str(b))
    return max(A, B)

ans = math.inf
for i in range(1, int(n**(1/2))+1):
    j = n / i
    if j%1 == 0:
        j = n // i
        if ans > F(i, j):
            ans = F(i, j)
            
print(ans)

Fixed submission:
# ABC 057 C - Digits in Multiplication
# 2020/04/07　20:6-
n = int(input())

def F(a, b):
    A = len(str(a))
    B = len(str(b))
    return max(A, B)

ans = 10**12
for i in range(1, int(n**(1/2))+1):
    j = n / i
    if j%1 == 0:
        j = n // i
        if ans > F(i, j):
            ans = F(i, j)
            
print(ans)
Buggy python submission (verdict: Runtime Error):
def fact(n):
    if n == 1:
        return n
    else:
        return n*fact(n-1)
    
n = int(input())
print(fact(n)%(10**9+7))

Fixed submission:
import math
n = int(input())
print(math.factorial(n)%(10**9+7))

Buggy python submission (verdict: Runtime Error):
def fact(n):
    if n == 1:
        return n
    else:
        return n*fact(n-1)
    
n = int(input())
print(fact(n)%(10**9+7))

Fixed submission:
import math
n = int(input())
print(math.factorial(n)%(10**9+7))
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input())

print(max(a*b, c*d))

Fixed submission:
a, b, c, d = map(int, input().split())

print(max(a*b, c*d))
Buggy python submission (verdict: Time Limit Exceeded):
# B
k, s = map(int, input().split())

count = 0
for i in range(k+1):
    for j in range(k+1):
        for k in range(k+1):
            if i+j+k == 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 l in range(k+1):
  for m in range(k+1):
    for n in range(k+1):
      if l+m+n == 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):
a, b, x = map(int, input().split())

count = 0
i = 0
while x*i <= b:
    if a <= x*i:
        count += 1
    i += 1
print(count)

Fixed submission:
# B
def how_many(a, b, c):
    # 1からa-1までのcの倍数の個数と1からbまでのcの倍数の個数を求める
    A, B = (a-1)//c, b//c
    # それらを引いて答えが求まる
    return B-A

a, b, x = map(int, input().split())

print(how_many(a, b, x))
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)
    exit()
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = 1
for i in range(N):
    if(A[i]==0):
        print(0)
        exit()
for i in range(N):
    ans *= A[i]
    if(ans > 10**18):
        print(-1)
        exit()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N= int(input())
A = list(map(int,input().split()))
dict_L = {}
for i in range(-max(A),N+max(A)+1):
    dict_L[i] = 0
for i in range(N):
    dict_L[i+1+A[i]] += 1
cnt = 0
for j in range(N):
    R = j+1-A[j]
    cnt += dict_L[R]
print(cnt)

Fixed submission:
N= int(input())
A = list(map(int,input().split()))
dict_L = {}
for i in range(N):
    if(i+1+A[i] in dict_L.keys()):
        dict_L[i+1+A[i]] += 1
    else:
        dict_L[i+1+A[i]] = 1
cnt = 0
for j in range(N):
    R = j+1-A[j]
    if(R in dict_L.keys()):
        cnt += dict_L[R]
print(cnt)

Buggy python submission (verdict: Runtime Error):
N= int(input())
A = list(map(int,input().split()))
dict_L = {}
#dict_R = {}
for i in range(-max(A),N+max(A)):
    dict_L[i] = 0
    #dict_R[i] = 0
for i in range(N):
    dict_L[i+1+A[i]] += 1
    #dict_R[i-A[i]] += 1
cnt = 0
for j in range(N):
    R = j+1-A[j]
    cnt += dict_L[R]
print(cnt)

Fixed submission:
N= int(input())
A = list(map(int,input().split()))
dict_L = {}
for i in range(N):
    if(i+1+A[i] in dict_L.keys()):
        dict_L[i+1+A[i]] += 1
    else:
        dict_L[i+1+A[i]] = 1
cnt = 0
for j in range(N):
    R = j+1-A[j]
    if(R in dict_L.keys()):
        cnt += dict_L[R]
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import math
A,B,N = map(int,input().split())
ans,point = 0,0
looked = min(B-1,N)
i = 2
while(looked <= N):
    point = (A*looked)//B - A*(looked//B)
    ans = max(ans,point)
    looked = i*B-1
    i += 1
print(ans)

Fixed submission:
import math
A,B,N = map(int,input().split())
looked = min(B-1,N)
ans = (A*looked)//B - A*(looked//B)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
A,B,N = map(int,input().split())
ans,point = 0,0
for i in range(1,N+1):
    amari = i%B
    Aamari = A*amari
    point = math.floor(Aamari/B)
    ans = max(ans,point)
print(ans)

Fixed submission:
import math
A,B,N = map(int,input().split())
looked = min(B-1,N)
ans = (A*looked)//B - A*(looked//B)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
A,B,N = map(int,input().split())
ans,point = 0,0
for i in range(1,N+1):
    amari = i/B-i//B
    point = math.floor(A*amari)
    ans = max(ans,point)
print(ans)

Fixed submission:
import math
A,B,N = map(int,input().split())
looked = min(B-1,N)
ans = (A*looked)//B - A*(looked//B)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
cnt = 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)

    # divisors.sort()
    return divisors
N1_yakusu = make_divisors(N-1)
N_yakusu = make_divisors(N)
cnt += len(N1_yakusu)
for s in N_yakusu:
    new_N = s
    while(new_N%K==0):
        new_N = new_N//K
    if(new_N%K == 1):
        cnt += 1
print(cnt)

Fixed submission:
N = int(input())
cnt = 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)
    divisors.pop(0)
    return divisors
N1_yakusu = make_divisors(N-1)
N_yakusu = make_divisors(N)
cnt += len(N1_yakusu)
for K in N_yakusu:
    new_N = N
    while(new_N%K==0):
        new_N = new_N//K
    if(new_N%K == 1):
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
import collections 
N,X,Y = map(int,input().split())
d = [[0]*(N+1) for _ in range(N+1)]
for i in range(1,N):#i => j
    for j in range(i+1,N+1):
        if(i>=Y or j<=X):
            d[i][j] = j-i
        elif(i<=X and j>=Y):
            d[i][j] = (X-i)+1+(j-Y)
        else:
            a_path = j-i
            b_path = abs(X-i)+1+abs(Y-j)
            d[i][j] = min(a_path,b_path)

ans = [0]
for i in range(N+1):
    ans += d[i]
c = Counter(ans)
for k in range(1,N): 
    print(c[k])

Fixed submission:
import collections 
N,X,Y = map(int,input().split())
d = [[0]*(N+1) for _ in range(N+1)]
for i in range(1,N):#i => j
    for j in range(i+1,N+1):
        if(i>=Y or j<=X):
            d[i][j] = j-i
        elif(i<=X and j>=Y):
            d[i][j] = (X-i)+1+(j-Y)
        else:
            a_path = j-i
            b_path = abs(X-i)+1+abs(Y-j)
            d[i][j] = min(a_path,b_path)

ans = [0]
for i in range(N+1):
    ans += d[i]
c = collections.Counter(ans)
for k in range(1,N): 
    print(c[k])
Buggy python submission (verdict: Runtime Error):
S = input()
if(S == "hi"orS == "hihi"orS == "hihihi"orS == "hihihihi"orS == "hihihihihi"):
    print("Yes")
else:
    print("No")

Fixed submission:
S = input()
if(S == "hi"or S == "hihi"or S == "hihihi"or S == "hihihihi"or S == "hihihihihi"):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
Query = [list(map(str,input().split())) for i in range(Q)]
for i in range(Q):
    if(Query[i][0] == "1"):
        S = S[::-1]
    else:
        if(Query[i][1] == "1"):
            S = Query[i][2] + S
        else:
            S = S + Query[i][2]
            
print(S)

Fixed submission:
S = input()
Q = int(input())
Query = [list(map(str,input().split())) for i in range(Q)]
front = ""
back = ""
hanten_flag = 0
cnt = 0
for i in range(Q):
    if(Query[i][0] == "1"):
        hanten_flag ^= 1
    else:
        if(Query[i][1] == "1" and hanten_flag == 0):
            front = Query[i][2] + front
        elif(Query[i][1] == "1" and hanten_flag == 1):
            back = back + Query[i][2]
        elif(Query[i][1] == "2" and hanten_flag == 0):
            back = back + Query[i][2]
        else:
            front = Query[i][2] + front
SS = front + S + back
if(hanten_flag == 1):
    SS = SS[::-1]
print(SS)