Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def n_ary1(l,d): # リストl中の文字でd桁を全列挙(sorted)
    if d == 1:
        return(l)
    ll = n_ary1(l,d-1)
    lll = []
    for i in l:
        for j in ll:
            lll.append(i+j)
            #lll.append(int(i+j)) ## n進数の場合
    return(lll)
In = list(map(int,input().split()))
op = n_ary1([[0],[1]],3)

for i in op:
    s = In[0]
    for j in range(3):
        if i[j]:
            s += In[j+1]
        else:
            s -= In[j+1]
    if s == 7:
        ansl = i
        break


ans = str(In[0])
for i in range(3):
    if ansl[i] :
        ans = ans + '+' + str(In[i+1])
    else:
        ans = ans + '-' + str(In[i+1])
ans = ans + '=7'
print(ans)


Fixed submission:
def n_ary1(l,d): # リストl中の文字でd桁を全列挙(sorted)
    if d == 1:
        return(l)
    ll = n_ary1(l,d-1)
    lll = []
    for i in l:
        for j in ll:
            lll.append(i+j)
            #lll.append(int(i+j)) ## n進数の場合
    return(lll)
In = list(input())
In = [int(i) for i in In]
op = n_ary1([[0],[1]],3)

for i in op:
    s = In[0]
    for j in range(3):
        if i[j]:
            s += In[j+1]
        else:
            s -= In[j+1]
    if s == 7:
        ansl = i
        break


ans = str(In[0])
for i in range(3):
    if ansl[i] :
        ans = ans + '+' + str(In[i+1])
    else:
        ans = ans + '-' + str(In[i+1])
ans = ans + '=7'
print(ans)
Buggy python submission (verdict: Runtime Error):
x,y = map(int,input().split())
if ord(x)<ord(y):
    print('<')
elif ord(x) == ord(y):
    print('=')
else:
    print('>')


Fixed submission:
x,y = input().split()
if ord(x)<ord(y):
    print('<')
elif ord(x) == ord(y):
    print('=')
else:
    print('>')
Buggy python submission (verdict: Runtime Error):
C = [list(input().split()) for i in range(2)]
if C[0][0] == C[1][2] and C[1][0] == C[0][2] and C[0][1] == C[1][1]:
    print('YES')
else:
    print('NO')



Fixed submission:
C = [list(input()) for i in range(2)]
if C[0][0] == C[1][2] and C[1][0] == C[0][2] and C[0][1] == C[1][1]:
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Runtime Error):
C = [list(map(int,input().split())) for i in range(2)]
if C[0][0] == C[1][2] and C[1][0] == C[0][2] and C[0][1] == C[1][1]:
    print('YES')
else:
    print('NO')



Fixed submission:
C = [list(input()) for i in range(2)]
if C[0][0] == C[1][2] and C[1][0] == C[0][2] and C[0][1] == C[1][1]:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
N = int(input())
flag = True
for h in range(1,3501):
    for n in range(1,3501):
        if flag and (N*n*h) % (4*h*n-N*(n+h)) == 0:
            print(str(h)+' '+str(N*n*h // (4*h*n+N*(n+h)))+' '+str(n))
            flag = False
        if not flag:
            break
    if not flag:
        break


Fixed submission:
N = int(input())
flag = True
for h in range(1,3501):
    for n in range(1,3501):
        if 4*h*n-N*(n+h) <= 0:
            continue
        if N*h*n < (4*h*n-N*(n+h)):
            continue
        if flag and (N*n*h) % (4*h*n-N*(n+h)) == 0:
            print(str(h)+' '+str(N*n*h //(4*h*n-N*(n+h)))+' '+str(n))
            flag = False
        if not flag:
            break
    if not flag:
        break
Buggy python submission (verdict: Runtime Error):
A,B,C,D,E,F = map(int,input().split())
concent = 0
ans = []
for one in range(F//(100*A)+1):
    for two in range((F-100*A*one)//(100*B)+1):
        for three in range((F-100*A*one-100*B*two)//C+1):
            for four in range((F-100*A*one-100*B*two-C*three)//D+1):
                water = 100*A*one+100*B*two
                sugar = C*three+D*four
                all = water + sugar
                if all == 0:
                    continue
                if E*water//100 < sugar or all > F:
                    continue
                if concent < 100*sugar/all:
                    concent = 100*sugar/all
                    ans = [all,sugar]
print(str(ans[0])+' '+str(ans[1]))




Fixed submission:
A,B,C,D,E,F = map(int,input().split())
concent = 0
ans = []
for one in range(F//(100*A)+1):
    for two in range((F-100*A*one)//(100*B)+1):
        for three in range((F-100*A*one-100*B*two)//C+1):
            for four in range((F-100*A*one-100*B*two-C*three)//D+1):
                water = 100*A*one+100*B*two
                sugar = C*three+D*four
                all = water + sugar
                if all == 0:
                    continue
                if E*water//100 < sugar or all > F:
                    continue
                if concent < 100*sugar/all:
                    concent = 100*sugar/all
                    ans = [all,sugar]
if len(ans) == 0:
    print(str(100*A)+' '+str(0))
else:
    print(str(ans[0])+' '+str(ans[1]))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
one = []
nnn = []
for i in range(M):
    ai,bi = map(int,input().split())
    if ai == 1:
        one.append(bi)
    if bi == N:
        nnn.append(ai)
def bs_left(l, target): # l=sorted, target以上の値をもつ要素のうち一番左のindexを返す
    low, high = 0, len(l)
    while low < high:
        mid = (low+high)//2
        if l[mid] < target:
            low = mid+1
        else:
            high = mid
    return low
flag = False
if len(one) == 0 or len(nnn) == 0:
    pass
else:
    nnn.sort()
    for i in range(len(one)):
        if nnn[bs_left(nnn,one[i])] == one[i]:
            flag = True
            break

if flag:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Fixed submission:
N,M = map(int,input().split())
one = []
nnn = []
for i in range(M):
    ai,bi = map(int,input().split())
    if ai == 1:
        one.append(bi)
    if bi == N:
        nnn.append(ai)
def bs_left(l, target): # l=sorted, target以上の値をもつ要素のうち一番左のindexを返す
    low, high = 0, len(l)
    while low < high:
        mid = (low+high)//2
        if l[mid] < target:
            low = mid+1
        else:
            high = mid
    if low == len(l):
        return -1
    return low
flag = False
if len(one) == 0 or len(nnn) == 0:
    pass
else:
    nnn.sort()
    for i in range(len(one)):
        if nnn[bs_left(nnn,one[i])] == one[i]:
            flag = True
            break

if flag:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = []
if n % 2 == 0:
    for i in range(n-1,0,-2):
        ans = ans + [a[i]]
    for i in range(0,n,2):
        ans = ans + [a[i]]
else:
    for i in range(n-1,-1,-2):
        ans = ans + [a[i]]
    for i in range(1,n,2):
        ans = ans + [a[i]]
print(' '.join([str(i) for i in ans]))


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = []
if n % 2 == 0:
    for i in range(n-1,0,-2):
        ans.append(a[i])
    for i in range(0,n,2):
        ans.append(a[i])
else:
    for i in range(n-1,-1,-2):
        ans.append(a[i])
    for i in range(1,n,2):
        ans.append(a[i])
print(' '.join([str(i) for i in ans]))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = []
if n % 2 == 0:
    for i in range(n-1,0,-2):
        ans = ans + [a[i]]
    for i in range(0,n,2):
        ans = ans + [a[i]]
else:
    for i in range(n-1,-1,-2):
        ans = ans + [a[i]]
    for i in range(1,n,2):
        ans = ans + [a[i]]
print(' '.join([str(i) for i in ans]))


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = []
if n % 2 == 0:
    for i in range(n-1,0,-2):
        ans.append(a[i])
    for i in range(0,n,2):
        ans.append(a[i])
else:
    for i in range(n-1,-1,-2):
        ans.append(a[i])
    for i in range(1,n,2):
        ans.append(a[i])
print(' '.join([str(i) for i in ans]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = list(map(int,input().split()))
ss = sum(s)
m = 101
for i in range(N):
    if s[i] % 10 != 0 and s[i] < m:
        m = s[i]
if m == 101: print(0)
elif ss % 10 == 0: print(ss-m)
else: print(ss)


Fixed submission:
N = int(input())
s = [int(input()) for i in range(N)]
ss = sum(s)
m = 101
for i in range(N):
    if s[i] % 10 != 0 and s[i] < m:
        m = s[i]
if m == 101:
    print(0)
elif ss % 10 == 0:
    print(ss-m)
else:
    print(ss)

Buggy python submission (verdict: Runtime Error):
N = int(input())
s = list(map(int,input().split()))
ss = sum(s)
m = 101
for i in range(N):
    if s[i] % 10 != 0 and s[i] < m: m = s[i]
if m == 101: print(0)
elif ss % 10 == 0: print(ss-m)
else: print(ss)


Fixed submission:
N = int(input())
s = [int(input()) for i in range(N)]
ss = sum(s)
m = 101
for i in range(N):
    if s[i] % 10 != 0 and s[i] < m:
        m = s[i]
if m == 101:
    print(0)
elif ss % 10 == 0:
    print(ss-m)
else:
    print(ss)
Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split())
a = H%2
b = W%2
ans = 10**9
if H%3==0 or W%3==0:
    print(0)
elif H==1 or W==1:
    print(1)
else:
    for i in range(1,W):
        c = (H*i,H//2*(W-i),H*W-H*i-(H//2)*(W-i))
        ans = min(ans,max(c)-min(c))
    for i in range(1,H):
        c = (W*i,W//2*(H-i),H*W-W*i-(W//2)*(H-i))
        ans = min(ans,max(c)-min(c))
    d = (H*(W//3),(H*W-H*(W//3))//2,H*W-H*(W//3)-(H*W-H*(W//3))//2)
    e = (W*(H//3),(H*W-W*(H//3))//2),H*W-W*(H//3),(H*W-W*(H//3))//2)
    ans = min(ans,max(d)-min(d))
    ans = min(ans,max(e)-min(e))
    print(ans)

Fixed submission:
H,W = map(int,input().split())
a = H%2
b = W%2
ans = 10**9
if H%3==0 or W%3==0:
    print(0)
elif H==1 or W==1:
    print(1)
else:
    for i in range(1,W):
        c = (H*i,H//2*(W-i),H*W-H*i-(H//2)*(W-i))
        ans = min(ans,max(c)-min(c))
        c = (H*i,(W-i)//2*H,H*W-H*i-(W-i)//2*H)
        ans = min(ans,max(c)-min(c))
    for i in range(1,H):
        c = (W*i,W//2*(H-i),H*W-W*i-(W//2)*(H-i))
        ans = min(ans,max(c)-min(c))
        c = (W*i,(H-i)//2*W,H*W-W*i-(H-i)//2*W)
        ans = min(ans,max(c)-min(c))
    
    print(ans)
Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
if A>B:
    print('GREATER')
elif A<B:
    print('LESS')
else:
    print('EQUAL')

Fixed submission:
A=int(input())
B = int(input())
if A>B:
    print('GREATER')
elif A<B:
    print('LESS')
else:
    print('EQUAL')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
s = 0
sign = a[0]//abs(a[0])
ans = 0
for i in range(n):
    s += a[i]
    if s == 0:
        s = sign
        ans += 1
    
    elif s//abs(s) == sign:
        pass
    else:
        ans += abs(sign-s)
        s = sign
    sign *= -1
print(ans)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
trueans = float('inf')
for k in [-1,1]:
    sign = k
    ans = 0
    s = 0
    for i in range(n):
        s += a[i]
        if s == 0:
            s = sign
            ans += 1
        elif s//abs(s) == sign:
            pass
        else:
            ans += abs(sign-s)
            s = sign
        sign *= -1
    trueans = min(ans,trueans)
print(trueans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
divide = 0
if A[0] < A[1]:
    up = 1
elif A[0] > A[1]:
    up = -1
else:
    up = 0
for i in range(1,N-1):
    if A[i] == A[i+1]:
        continue
    elif A[i] < A[i+1]:
        if up < 0:
            divide += 1
            up = 0
        else:
            up = 1
            continue
    else:
        if up > 0:
            divide += 1
            up = 0
        else:
            up = -1
            continue
print(divide+1)

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

if N == 1:
    print(1)
else:
    divide = 0
    if A[0] < A[1]:
        up = 1
    elif A[0] > A[1]:
        up = -1
    else:
        up = 0
    for i in range(1,N-1):
        if A[i] == A[i+1]:
            continue
        elif A[i] < A[i+1]:
            if up < 0:
                divide += 1
                up = 0
            else:
                up = 1
                continue
        else:
            if up > 0:
                divide += 1
                up = 0
            else:
                up = -1
                continue
    print(divide+1)
Buggy python submission (verdict: Runtime Error):
O = input()
E = input()

ans = ''
for i in range(len(O)+len(E)):
    if i%2==0:
        ans = ans+O[i]
    else:
        ans = ans+E[i//2]
print(ans)

Fixed submission:
O = input()
E = input()

ans = ''

if len(O)==len(E):
    for i in range(len(O)):
        ans=ans+O[i]
        ans=ans+E[i]
else:
    for i in range(len(O)-1):
        ans=ans+O[i]
        ans=ans+E[i]
    ans=ans+O[len(O)-1]


print(ans)
Buggy python submission (verdict: Runtime Error):
A,B = int(input())
if A<B:
    if A == 1:
        print('Alice')
    else:
        print('Bob')
elif A == B:
    print('Draw')
else:
    if B == 1:
        print('Bob')
    else:
        print('Alice')


Fixed submission:
A,B = map(int,input().split())
if A<B:
    if A == 1:
        print('Alice')
    else:
        print('Bob')
elif A == B:
    print('Draw')
else:
    if B == 1:
        print('Bob')
    else:
        print('Alice')
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
dict = {}
for m in range(M):
    a,b = map(int,input().split())
    if a in dict:
        dict[a].append(b)
    else:
        dict[a] = [b]
    if b in dict:
        dict[b].append(a)
    else:
        dict[b] = [a]
ans = 0
l = [0 for i in range(N+1)]
l[1] = 1
def dfs(now):
    global l
    global ans
    if sum(l) == N:
        ans += 1
        return(0)
    for i in dict[now]:
        if l[i] == 0:
            l[i] += 1
            now = i
            dfs(l,now)
            l[i] -= 1
        else:
            continue
dfs(l,1)
print(ans)


Fixed submission:
N,M = map(int,input().split())
dict = {}
for m in range(M):
    a,b = map(int,input().split())
    if a in dict:
        dict[a].append(b)
    else:
        dict[a] = [b]
    if b in dict:
        dict[b].append(a)
    else:
        dict[b] = [a]
ans = 0
l = [0 for i in range(N+1)]
l[1] = 1
def dfs(l,now):
    global ans
    if sum(l) == N:
        ans += 1
        return(0)
    for i in dict[now]:
        if l[i] == 0:
            l[i] += 1
            now = i
            dfs(l,now)
            l[i] -= 1
        else:
            continue
dfs(l,1)
print(ans)
Buggy python submission (verdict: Runtime Error):
x,y = map(int,input().split())
if x == 0 and y > 0:
    print(y-x)
elif x == 0 and y < 0:
    print(1+abs(x+y))
elif y == 0 and x > 0:
    print(1+abs(x+y))
elif y == 0 and x < 0:
    print(y-x)
    
elif 0 < x and x < y:
    print(y-x)
elif 0 < x and x > y:
    #print(abs(y+x)+1)
elif x < 0 and y > 0:
    print(abs(y+x)+1)
elif y < 0 and x < y:
    print(y-x)
elif x < 0 and y < x:
    print(2+abs(x-y))



Fixed submission:
x,y = map(int,input().split())
if x == 0 and y > 0:
    print(y-x)
elif x == 0 and y < 0:
    print(1+abs(x+y))
elif y == 0 and x > 0:
    print(1+abs(x+y))
elif y == 0 and x < 0:
    print(y-x)
elif x < 0 and y < x:
    print(2+abs(x-y))
elif 0 < x and x < y:
    print(y-x)
elif 0 < y and x > y:
    print(2+abs(x-y))
elif 0 > y and x > y:
    print(abs(y+x)+1)
elif x < 0 and y > 0:
    print(abs(y+x)+1)
elif y < 0 and x < y:
    print(y-x)

Buggy python submission (verdict: Runtime Error):
x,y = map(int,input().split())
if x == 0 and y > 0:
    print(y-x)
elif x == 0 and y < 0:
    print(1+abs(x+y))
elif y == 0 and x > 0:
    print(1+abs(x+y))
elif y == 0 and x < 0:
    print(y-x)
    
elif 0 < x and x < y:
    print(y-x)
elif 0 < x and x > y:
    print(abs(y+x)+1)
elif x < 0 and y > 0 
    print(abs(y+x)+1)
elif y < 0 and x < y:
    print(y-x)
elif x < 0 and y < x:
    print(2+abs(x-y))



Fixed submission:
x,y = map(int,input().split())
if x == 0 and y > 0:
    print(y-x)
elif x == 0 and y < 0:
    print(1+abs(x+y))
elif y == 0 and x > 0:
    print(1+abs(x+y))
elif y == 0 and x < 0:
    print(y-x)
elif x < 0 and y < x:
    print(2+abs(x-y))
elif 0 < x and x < y:
    print(y-x)
elif 0 < y and x > y:
    print(2+abs(x-y))
elif 0 > y and x > y:
    print(abs(y+x)+1)
elif x < 0 and y > 0:
    print(abs(y+x)+1)
elif y < 0 and x < y:
    print(y-x)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(N):
    if a[a[i]-1]-1 == i:
        ans += 1
print(ans//2)



Fixed submission:
s = input()
print(s[:4]+' '+s[4:])
Buggy python submission (verdict: Runtime Error):
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [int(input()) for _ in range(D)]
M = int(input())
dq = [list(map(int, input().split())) for _ in range(M)]

def calc(t, D, s):
  last = [0 for _ in range(26)]
  value = 0
  for i in range(D):
    day = i + 1
    value += s[i][t[i]-1]
    last[t[i]-1] = day
    for j in range(26):
      value -= c[j] * (day - last[j])
  return value

for i in range(M):
  t[dq[i][0]-1] = dq[i][1]
  print(calc(t, D, s))

Fixed submission:
import bisect

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ruiseki_a = [0]
ruiseki_b = [0]

a_index = N+1
for i in range(N):
  if K < ruiseki_a[-1] + A[i]:
    a_index = i+1
    break
  ruiseki_a.append(ruiseki_a[-1] + A[i])
b_index = M+1
for i in range(M):
  if K < ruiseki_b[-1] + B[i]:
    b_index = i+1
    break
  ruiseki_b.append(ruiseki_b[-1] + B[i])
lis = [0 for _ in range(a_index)]
for i in range(a_index):
  index = bisect.bisect_left(ruiseki_b, K-ruiseki_a[i]+1)
  lis[i] = i + max(0, index - 1)
print(max(lis))
Buggy python submission (verdict: Time Limit Exceeded):
for i in range(4*10**10):
  print(i)

Fixed submission:
S = input()
T = input()

flag = 0
for i in range(len(S)):
  if S[i] == T[i]:
    continue
  flag = 1

if flag == 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()))

for i in range(N):
  A[i] -= 1

loop_lis = [0]
for i in range(K):
  loop_lis.append(A[loop_lis[-1]])
  if len(loop_lis) != len(set(loop_lis)):
    break
for j in range(len(loop_lis)):
  if loop_lis[j] == loop_lis[-1]:
    break
if i == K-1:
  print(loop_lis[-1]+1)
else:
  print(loop_lis[j+(K-j)%(i+1-j)]+1)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
 
for i in range(N):
  A[i] -= 1

loop_lis = [0]
visited = [-1 for _ in range(N)]
visited[0] = 0
flag = 0
for i in range(K):
  if visited[A[loop_lis[-1]]] != -1:
    loop_time = i+1-visited[A[loop_lis[-1]]]
    start_loop = visited[A[loop_lis[-1]]]
    flag = 1
    break
  visited[A[loop_lis[-1]]] = i+1
  loop_lis.append(A[loop_lis[-1]])

if i == K-1 and flag == 0:
  print(loop_lis[-1]+1)
else:
  print(loop_lis[start_loop+(K-start_loop)%loop_time]+1)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))

loop_lis = [1]
visited = [0 for _ in range(N)]
visited[0] = 1
loop_time = 0
start_loop = 0
for i in range(K):
  if visited[A[loop_lis[-1]-1]-1] != 0:
    loop_time = (i+1)-(visited[A[loop_lis[-1]-1]-1])
    start_loop = i+1 - loop_time
    break
  visited[A[loop_lis[-1]-1]-1] = i+1
  loop_lis.append(A[loop_lis[-1]-1])
print(loop_lis[start_loop+(K-start_loop)%loop_time])

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
 
for i in range(N):
  A[i] -= 1

loop_lis = [0]
visited = [-1 for _ in range(N)]
visited[0] = 0
flag = 0
for i in range(K):
  if visited[A[loop_lis[-1]]] != -1:
    loop_time = i+1-visited[A[loop_lis[-1]]]
    start_loop = visited[A[loop_lis[-1]]]
    flag = 1
    break
  visited[A[loop_lis[-1]]] = i+1
  loop_lis.append(A[loop_lis[-1]])

if i == K-1 and flag == 0:
  print(loop_lis[-1]+1)
else:
  print(loop_lis[start_loop+(K-start_loop)%loop_time]+1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

cnt = 0
for i in range(N):
  for j in range(A[i]+i,N):
    if j-i==A[i]+A[j]:
      cnt += 1
print(cnt)

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

B = [0 for _ in range(N)]
C = [0 for _ in range(N)]
for i in range(N):
  B[i] = i - A[i]
  C[i] = i + A[i]
lis1 = collections.Counter(B)
lis2 = collections.Counter(C)
count = 0
for key, value in lis1.items():
  if key in lis2:
    count += value * lis2[key]
print(count)
Buggy python submission (verdict: Runtime Error):
import math
A, B, N = map(int, input().split())

if (B > N+1):
  x = N
  print((A*x)//B-A*(x//B))
else:
  x = N-N%(B-1)
  print((A*x)//B-A*(x//B))

Fixed submission:
import math
A, B, N = map(int, input().split())

if (B == 1):
  print(0)
elif (B > N+1):
  x = N
  print((A*x)//B-A*(x//B))
else:
  x = N-N%(B-1)
  print((A*x)//B-A*(x//B))

Buggy python submission (verdict: Runtime Error):
import math
A, B, N = map(int, input().split())

if (B > N+1):
  x = N
  print(math.floor(A*x/B)-A*math.floor(x/B))
else:
  x = N-N%(B-1)
  print(math.floor(A*x/B)-A*math.floor(x/B))

Fixed submission:
import math
A, B, N = map(int, input().split())

if (B == 1):
  print(0)
elif (B > N+1):
  x = N
  print((A*x)//B-A*(x//B))
else:
  x = N-N%(B-1)
  print((A*x)//B-A*(x//B))

Buggy python submission (verdict: Runtime Error):
import numpy as np
A, B, N = map(int, input().split())

x = np.arange(1, max(10**6,N+1))
print(int(np.max(np.floor(A*x/B)-A*np.floor(x/B))))

Fixed submission:
import math
A, B, N = map(int, input().split())

if (B == 1):
  print(0)
elif (B > N+1):
  x = N
  print((A*x)//B-A*(x//B))
else:
  x = N-N%(B-1)
  print((A*x)//B-A*(x//B))
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce

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

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
K = int(input())

count=0
for i in range(1, K+1):
  for j in range(i, K+1):
    for k in range(j, K+1):
      if i == j and j == k:
        kake = 1
      elif i == j or j == k or i == k:
        kake = 3
      else:
        kake = 6
      count += gcd(i, j, k) * kake

print(count)

Fixed submission:
def euclid(a, b):
    while b:
        a, b = b, a%b
    return a
  
K = int(input())

count=0
for i in range(1, K+1):
  for j in range(i, K+1):
    for k in range(j, K+1):
      if i == j and j == k:
        kake = 1
      elif i == j or j == k or i == k:
        kake = 3
      else:
        kake = 6
      count += euclid(euclid(i, j), k) * kake

print(count)

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

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

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
K = int(input())

count=0
for i in range(1, K+1):
  for j in range(i, K+1):
    for k in range(j, K+1):
      if i == j and j == k:
        kake = 1
      elif i == j or j == k or i == k:
        kake = 3
      else:
        kake = 6
      count += gcd(i, j, k) * kake

print(count)

Fixed submission:
def euclid(a, b):
    while b:
        a, b = b, a%b
    return a
  
K = int(input())

count=0
for i in range(1, K+1):
  for j in range(i, K+1):
    for k in range(j, K+1):
      if i == j and j == k:
        kake = 1
      elif i == j or j == k or i == k:
        kake = 3
      else:
        kake = 6
      count += euclid(euclid(i, j), k) * kake

print(count)
Buggy python submission (verdict: Runtime Error):
import math
 
N = int(input())
 
cnt = 0
 
if N == 2:
  print(1)
  exit()
 
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
res1 = sorted(make_divisors(N))
res1 = res1[1:math.ceil(len(res1)/2)]
 
for num in res1:
  kensa = N
  while True:
    if kensa % num == 0:
      kensa = kensa // num
      continue
    break
  if kensa % num == 1:
    cnt += 1
 
res2 = sorted(make_divisors(N-1))
cnt += len(res2[1:])+1
 
print(cnt)

Fixed submission:
X, Y, Z = map(int, input().split())

print(Z, X, Y)