Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
S = input()

if len(S) < 26:
    for c in [chr(i) for i in range(ord('a'), ord('a') + 26)]:
        # print(c)
        if c not in S:
            ans = S + c
            break
elif S == 'zyxwvutsrqponmlkjihgfedcba':
    ans = -1
else:
    for i in range(25, -1, -1):
        # print(S[i], S[-1])
        if ord(S[i]) < ord(S[-1]):
            ans = S[:i] + S[-1]
            break
print(ans)

Fixed submission:
S = input()

if len(S) < 26:
    for c in [chr(i) for i in range(ord('a'), ord('a') + 26)]:
        # print(c)
        if c not in S:
            ans = S + c
            break
elif S == 'zyxwvutsrqponmlkjihgfedcba':
    ans = -1
else:
    for i in range(1, len(S)):
        j = - i
        if ord(S[j - 1]) < ord(S[j]):
            break
    # print(S[j:])
    change = 'z'
    for c in S[j:]:
        if ord(S[j - 1]) < ord(c) < ord(change):
            change = c
    ans = S[:j - 1] + change
print(ans)
Buggy python submission (verdict: Runtime Error):
X, Y = map(int, input().split())
import math

print(1 + math.floor(math.log2(Y/X)))

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

a=X
cnt=1
while a <= Y:
    a *= 2
    if a <= Y:
        cnt+=1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

def binsearch(threshold, lst):
    left, right = -1, len(lst)
    while right - left > 1:
        mid = (left + right) // 2
        if lst[mid] > threshold:
            right = mid
        else:
            left = mid
    return right

ans = 0
for a in A:
    b_min_index = binsearch(a, B)
    for i in range(b_min_index, N):
        c_min_index = binsearch(B[i], C)
        ans += N - c_min_index
        #print(a, B[b_min_index], C[c_min_index])
print(ans)


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

def binsearch(threshold, lst):
    left, right = -1, len(lst)
    while right - left > 1:
        mid = (left + right) // 2
        if lst[mid] > threshold:
            right = mid
        else:
            left = mid
    return right

ans = 0

BtoC = [None] * N
for i in range(0, N):
    BtoC[i] = N - binsearch(B[i], C)
#print(BtoC)

cumulative=[0]
for i in range(N):
    cumulative.append(cumulative[i] + BtoC[N-i-1])
#print(cumulative)
cumulative.reverse()
#print(cumulative)

for j in range(0, N):
    temp = binsearch(A[j], B)
    ans += cumulative[temp]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

#print(N,A,B,C)

count=0
for i in range(N):
    for j in range(N):
        for k in range(N):
            if A[i]<B[j]<C[k]:
                count+=1
print(count)
#do binary search



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

def binsearch(threshold, lst):
    left, right = -1, len(lst)
    while right - left > 1:
        mid = (left + right) // 2
        if lst[mid] > threshold:
            right = mid
        else:
            left = mid
    return right

ans = 0

BtoC = [None] * N
for i in range(0, N):
    BtoC[i] = N - binsearch(B[i], C)
#print(BtoC)

cumulative=[0]
for i in range(N):
    cumulative.append(cumulative[i] + BtoC[N-i-1])
#print(cumulative)
cumulative.reverse()
#print(cumulative)

for j in range(0, N):
    temp = binsearch(A[j], B)
    ans += cumulative[temp]

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a=list(map(int, input().split()))
cnt=[0]*(max(a)+1)
for i in range(N):
    cnt[a[i]]+=1
#print(cnt)

tri=[cnt[i]+cnt[i+1]+cnt[i+2] for i in range(len(cnt)-2)]
#print(tri)
print(max(tri))

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

if max(a)<=1:
    print(N)
else:
    cnt=[0]*(max(a)+1)
    for val in a:
        cnt[val]+=1
    #print(cnt)

    tri=[cnt[i]+cnt[i+1]+cnt[i+2] for i in range(len(cnt)-2)]
    #print(tri)
    print(max(tri))
Buggy python submission (verdict: Runtime Error):
N = int(input())
abc=[]
for _ in range(N-1):
    abc.append(tuple(map(int, input().split())))
Q, K = map(int, input().split())
xy=[]
for _ in range(Q):
    xy.append(tuple(map(int, input().split())))
#print(abc)
#print(xy)

G = [[] for _ in range(N+1)]
for el in abc:
    a,b,c = el
    G[a].append((b,c))
    G[b].append((a,c))
#print(G)

seen=[False]*(N+1)
distance=[0]*(N+1)
def dfs(n):
    seen[n]=True
    for el in G[n]:
        if seen[el[0]] == False:
            distance[el[0]] = distance[n] + el[1]
            dfs(el[0])
dfs(K)
#print(distance)

for q in xy:
    print(distance[q[0]]+distance[q[1]])


Fixed submission:
import sys
sys.setrecursionlimit(10**6)


N = int(input())
abc=[]
for _ in range(N-1):
    abc.append(tuple(map(int, input().split())))
Q, K = map(int, input().split())
xy=[]
for _ in range(Q):
    xy.append(tuple(map(int, input().split())))
#print(abc)
#print(xy)

G = [[] for _ in range(N+1)]
for el in abc:
    a,b,c = el
    G[a].append((b,c))
    G[b].append((a,c))
#print(G)

seen=[False]*(N+1)
distance=[0]*(N+1)
def dfs(n):
    seen[n]=True
    for el in G[n]:
        if seen[el[0]] == False:
            distance[el[0]] = distance[n] + el[1]
            dfs(el[0])
dfs(K)
#print(distance)

for q in xy:
    print(distance[q[0]]+distance[q[1]])
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
ab=[]
for _ in range(M):
    ab.append(tuple(map(int, input().split())))
#print(ab)

for island in range(2,N):
    if (1,island) in ab and (island,N) in ab:
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')

Fixed submission:
N, M = map(int, input().split())
ab=[]
for _ in range(M):
    ab.append(tuple(map(int, input().split())))
#print(ab)

from_1=set([el[1] for el in ab if el[0]==1])
from_N=set([el[0] for el in ab if el[1]==N])
#print(from_1, from_N)
if from_1 & from_N:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
AB = []
for _ in range(N):
    AB.append(tuple(map(int, input().split())))

cnt = 0
AB.reverse()
for el in AB:
    A, B = el
    A += cnt
    while A % B != 0:
        A += 1
        cnt += 1
print(cnt)

Fixed submission:
N = int(input())
AB = []
for _ in range(N):
    AB.append(tuple(map(int, input().split())))

cnt = 0
AB.reverse()
for el in AB:
    A, B = el
    A += cnt
    if A % B != 0:
        cnt += (B - A % B)
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
K, T = map(int, input().split())
a = list(map(int, input().split()))
# print(a)
m = 10 ** 5
for situ in range(0, 2 ** T):
    block_a = 0
    block_b = 0
    for j in range(T):
        if (situ >> j) & 1:
            block_a += a[j]
        else:
            block_b += a[j]
    diff = abs(block_a - block_b)
    # print(bin(situ), block_a, block_b, diff)
    m = min(diff, m)
print(max(0, m - 1))

Fixed submission:
K, T = map(int, input().split())
a = list(map(int, input().split()))

M = max(a)
ans = max(M - 1 - (K - M), 0)
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

if (T[:len(S)] == S) and (len(T) = len(S) + 1):
    print('Yes')
else:
    print('No')

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

if (T[:len(S)] == S) and (len(T) == len(S) + 1):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
S = input()

count = 0

for i in len(S):
    for j in range(i, len(S)):
        if int(S[i:j]) % 2019 == 0:
            count += 1
      
      
print(count)

Fixed submission:
S, W = map(int, input().split())
if S <= W:
  print('unsafe')
else:
  print('safe')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [0]
A.extend(list(map(int, input().split())))

buka_num = []

for i in range(1,N):
    buka_num.append(A.count(i))
    
buka_num.append(0)
for ele in buka_num:
    print(ele)

Fixed submission:
import math
R = int(input())
print(R*2*math.pi)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [0]
A.extend(list(map(int, input().split())))

buka_num = []

for i in range(1,N):
    #tmp_A = A[i:]
    buka_num.append(tmp_A.count(i))
    
buka_num.append(0)
for ele in buka_num:
    print(ele)

Fixed submission:
import math
R = int(input())
print(R*2*math.pi)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [0]
A.extend(list(map(int, input().split())))

buka_num = []

for i in range(1,N):
    tmp_A = A[i:]
    buka_num.append(tmp_A.count(i))
    
buka_num.append(0)
print(buka_num, sep='\n')

Fixed submission:
import math
R = int(input())
print(R*2*math.pi)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [0]
A.extend(list(map(int, input().split())))

buka_num = []

for i in range(1,N):
    tmp_A = A[i:]
    buka_num.append(tmp_A.count(i))
    
buka_num.append(0)
print(buka_num, sep='\n')

Fixed submission:
import math
R = int(input())
print(R*2*math.pi)

Buggy python submission (verdict: Runtime Error):
mport math
R = int(input())
print(R*2*math.pi)

Fixed submission:
import math
R = int(input())
print(R*2*math.pi)

Buggy python submission (verdict: Runtime Error):
mport math
R = int(input())
print(R*2*math.pi)

Fixed submission:
import math
R = int(input())
print(R*2*math.pi)
Buggy python submission (verdict: Runtime Error):
A = input()
B = input()
C = input()
X = input()
count = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            x = (a*500) + (b*100) + (c*50)
            if x == X:
                count += 1
print(count)
    

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            x = (a*500) + (b*100) + (c*50)
            if x == X:
                count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
str=input()
count=0
for i in range(0,len(str)-3):
    for j in range(4,len(str)-i+1):
        if float(str[i:j+i])%2019==0:
            count=count+1
            if j+4>len(str):
                break
            else:
                j=j+3
print(count)

Fixed submission:
s=input()
b=[0]*2019
b[0]=1
now=0
m=2019
c=1
ans=0
for i in range(len(s)-1,-1,-1):
    now+=int(s[i])*c
    now=now%m
    c=c*10
    ans=ans+b[now]
    b[now]=b[now]+1
    c=c%m

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
str=input()
count=0
for i in range(0,len(str)-3):
    for j in range(4,len(str)-i+1):
        if int(str[i:j+i])%2019==0:
            count=count+1
            if j+4>len(str):
                break
            else:
                j=j+3
print(count)

Fixed submission:
s=input()
b=[0]*2019
b[0]=1
now=0
m=2019
c=1
ans=0
for i in range(len(s)-1,-1,-1):
    now+=int(s[i])*c
    now=now%m
    c=c*10
    ans=ans+b[now]
    b[now]=b[now]+1
    c=c%m

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
str=input()
count=0
for i in range(4,len(str)+1):
    for j in range(0,len(str)-i+1):
        if int(str[j:i+j])%2019==0:
            count=count+1
print(count)

Fixed submission:
s=input()
b=[0]*2019
b[0]=1
now=0
m=2019
c=1
ans=0
for i in range(len(s)-1,-1,-1):
    now+=int(s[i])*c
    now=now%m
    c=c*10
    ans=ans+b[now]
    b[now]=b[now]+1
    c=c%m

print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
str=input()
count=str.count("R")*str.count("G")*str.count("B")
count0=0
for i in range(0,n-2):
    for j in range(i+1,(n+i)/2):
        k=2*j-i
        if str[k]!=str[i] and str[k]!=str[j] and str[i]!=str[j]:
            count0=count0+1
print(count-count0)

Fixed submission:
n=int(input())
str=input()
count=str.count("R")*str.count("G")*str.count("B")
count0=0
for i in range(0,n-2):
    for j in range(i+1,int((n+i-1)/2)+1):
        k=2*j-i
        if str[k]!=str[i] and str[k]!=str[j] and str[i]!=str[j]:
            count0=count0+1
print(count-count0)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
str=input()
count=str.count("R")*str.count("G")*str.count("B")
count0=0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        if 2*j-i<n:
            k=2*j-i
            if str[k]!=str[i] and str[k]!=str[j] and str[i]!=str[j]:
                count0=count0+1
print(count-count0)

Fixed submission:
n=int(input())
str=input()
count=str.count("R")*str.count("G")*str.count("B")
count0=0
for i in range(0,n-2):
    for j in range(i+1,int((n+i-1)/2)+1):
        k=2*j-i
        if str[k]!=str[i] and str[k]!=str[j] and str[i]!=str[j]:
            count0=count0+1
print(count-count0)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
str=input()
s=''
count=0
for i in range(0,n-3):
    for j in range(i+1,n-1):
        s=str[i]
        if str[j] not in s:
            s=str[i]+str[j]
            for k in range(j+1,n):
                if k-j != j-i:
                    if str[k] not in s:
                        count=count+1
print(count)

Fixed submission:
n=int(input())
str=input()
count=str.count("R")*str.count("G")*str.count("B")
count0=0
for i in range(0,n-2):
    for j in range(i+1,int((n+i-1)/2)+1):
        k=2*j-i
        if str[k]!=str[i] and str[k]!=str[j] and str[i]!=str[j]:
            count0=count0+1
print(count-count0)
Buggy python submission (verdict: Time Limit Exceeded):
import math
n,k=map(int,input().split())
if n%k==0:
    print(0)
else:
    while n>abs(n-k):
        n=abs(n-k)
    print(n)
            

Fixed submission:
import math
n,k=map(int,input().split())
n=n%k
while n>abs(n-k):
    n=abs(n-k)
print(n)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
gate=[input() for __ in range(M)]
s,e=map(int,gate[0].split())

ans=set([i for i in range(s,e+1)])

for g in gate:
    s,e=map(int,g.split())
    ans=set(ans)
    pre=set([i for i in range(s,e+1)])
    ans = list(ans & pre)

print(len(ans))


Fixed submission:
N,M=map(int,input().split())
gate=[input() for __ in range(M)]
s,e=map(int,gate[0].split())
for n in gate:
    pre_s,pre_e=map(int,n.split())
    s=(s if s>pre_s else pre_s)
    e=(e if e<pre_e else pre_e)

print(e+1-s if e>=s else 0)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=[input() for __ in range(M)]

for bc in BC:
    b,c=map(int,bc.split())
    A.extend(list([c]*b))
    A.sort(reverse=True)

print(sum(A[:N]))


Fixed submission:
N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=[list(map(int,input().split())) for __ in range(M)]
BC.sort(key=lambda x: x[1],reverse=True)

l=[]
for b,c in BC:
    if len(l)+b>N:
        l.extend(list([c]*b))
        break
    else:
        l.extend(list([c]*b))
A.extend(l)
A.sort(reverse=True)
print(sum(A[:N]))

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
BC=[input() for __ in range(M)]

for bc in BC:
    b,c=map(int,bc.split())

    for i in range(len(A)):
        if A[i]<c:
            A=A[:i]+[c]*b+A[i:]
            break
    A=A[:N]

print(sum(A))

Fixed submission:
N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=[list(map(int,input().split())) for __ in range(M)]
BC.sort(key=lambda x: x[1],reverse=True)

l=[]
for b,c in BC:
    if len(l)+b>N:
        l.extend(list([c]*b))
        break
    else:
        l.extend(list([c]*b))
A.extend(l)
A.sort(reverse=True)
print(sum(A[:N]))

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=[input() for __ in range(M)]

for bc in BC:
    b,c=map(int,bc.split())
    A.extend(list([c]*b))
    A.sort(reverse=True)
    A=A[:N]

print(sum(A))


Fixed submission:
N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=[list(map(int,input().split())) for __ in range(M)]
BC.sort(key=lambda x: x[1],reverse=True)

l=[]
for b,c in BC:
    if len(l)+b>N:
        l.extend(list([c]*b))
        break
    else:
        l.extend(list([c]*b))
A.extend(l)
A.sort(reverse=True)
print(sum(A[:N]))

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=[input() for __ in range(M)]

for bc in BC:
    b,c=map(int,bc.split())
    l=[c]*b
    A.extend(l)
    A.sort(reverse=True)
    A=A[:N]

print(sum(A))


Fixed submission:
N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=[list(map(int,input().split())) for __ in range(M)]
BC.sort(key=lambda x: x[1],reverse=True)

l=[]
for b,c in BC:
    if len(l)+b>N:
        l.extend(list([c]*b))
        break
    else:
        l.extend(list([c]*b))
A.extend(l)
A.sort(reverse=True)
print(sum(A[:N]))
Buggy python submission (verdict: Runtime Error):
n,k==map(int,input().split())
print(n-k+1)

Fixed submission:
n,k=map(int,input().split())
print(n-k+1)
Buggy python submission (verdict: Runtime Error):
import math

n=int(input())
a=list(map(int,input().split()))

l=[0]*(n)
for i in range(n-1):
    l[i+1] = math.gcd(l[i],a[i])

r=[0]*(n)
for i in range(n-2,-1,-1):
    r[i] = math.gcd(r[i+1],a[i+1])

print(max([math.gcd(r[i],l[i]) for i in range(n)]))


Fixed submission:
from fractions import gcd

n=int(input())
a=list(map(int,input().split()))

l=[0]*(n)
for i in range(n-1):
    l[i+1] = gcd(l[i],a[i])

r=[0]*(n)
for i in range(n-2,-1,-1):
    r[i] = gcd(r[i+1],a[i+1])

print(max([gcd(r[i],l[i]) for i in range(n)]))

Buggy python submission (verdict: Runtime Error):
from math import gcd

n=int(input())
a=list(map(int,input().split()))

l=[0]*(n)
for i in range(n-1):
    l[i+1] = gcd(l[i],a[i])

r=[0]*(n)
for i in range(n-2,-1,-1):
    r[i] = gcd(r[i+1],a[i+1])

print(max([gcd(r[i],l[i]) for i in range(n)]))


Fixed submission:
from fractions import gcd

n=int(input())
a=list(map(int,input().split()))

l=[0]*(n)
for i in range(n-1):
    l[i+1] = gcd(l[i],a[i])

r=[0]*(n)
for i in range(n-2,-1,-1):
    r[i] = gcd(r[i+1],a[i+1])

print(max([gcd(r[i],l[i]) for i in range(n)]))

Buggy python submission (verdict: Runtime Error):
from math import gcd

n=int(input())
a=list(map(int,input().split()))

l=[0]*(n)
for i in range(n-1):
    l[i+1] = gcd(l[i],a[i])

r=[0]*(n)
for i in range(n-2,-1,-1):
    r[i] = gcd(r[i+1],a[i+1])

print(max([gcd(r[i],l[i]) for i in range(n)]))

Fixed submission:
from fractions import gcd

n=int(input())
a=list(map(int,input().split()))

l=[0]*(n)
for i in range(n-1):
    l[i+1] = gcd(l[i],a[i])

r=[0]*(n)
for i in range(n-2,-1,-1):
    r[i] = gcd(r[i+1],a[i+1])

print(max([gcd(r[i],l[i]) for i in range(n)]))
Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
ans=0
for x in range(k+1):
    if x>s: continue
    for y in range(k+1):
        if x+y>s: continue
        for z in range(k+1):
            if x+y+z == s:
                ans+=1

print(ans)



Fixed submission:
k,s=map(int,input().split())
ans=0

for x in range(k+1):
    for y in range(k+1):
        if s-x-y>=0 and k>=(s-x-y):
            ans+=1
print(ans)

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

print(ans)


Fixed submission:
k,s=map(int,input().split())
ans=0

for x in range(k+1):
    for y in range(k+1):
        if s-x-y>=0 and k>=(s-x-y):
            ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
Copy
a,b,c,k = map(int,input().split())
 
ans = 0
 
if k <= a:
  ans = a
  print(ans)
elif a< k <= a+b:
  ans = a
  print(ans)
else:
  ans = a-(K-a-b)
  if ans < 0:
    ans = 0
  print(ans)

Fixed submission:
a,b,c,k = map(int,input().split())
 
ans = 0
 
if 0< k <= a:
  ans = k
  print(ans)
elif a+1 <= k <= a+b:
  ans = a
  print(ans)
else:
  ans = a-(k-a-b)
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,n = map(int,input().split())

if n<b:
  qlist = range(n+1)
else:
  qlist = range(b)
  
anslist = list(map(lambda x:a*x//b,qlist))

print(max(anslist))
 


Fixed submission:
a,b,n = map(int,input().split())
 
if n<b:
  maxq = n
else:
  maxq = b-1
  
ans = a*maxq//b
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,n = map(int,input().split())

if n<b:
  qlist = range(n+1)
else:
  qlist = range(b)
  
anslist = list(map(lambda x:a*x//b,qlist))

print(max(anslist))
 


Fixed submission:
a,b,n = map(int,input().split())
 
if n<b:
  maxq = n
else:
  maxq = b-1
  
ans = a*maxq//b
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,n = map(int,input().split())
maxans = 0

for x in range(n+1):
  ans = (a*x)//b - a*(x//b)

  if ans > maxans:
    maxans = ans

print(maxans)
 


Fixed submission:
a,b,n = map(int,input().split())
 
if n<b:
  maxq = n
else:
  maxq = b-1
  
ans = a*maxq//b
 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())

import math
from functools import reduce

sum = 3*(K-1)*(K-1) + 3*(K-1) + 1

for i in range(2, K + 1):
    for j in range(2, K + 1):
        for k in range(2, K + 1):
            sum += math.gcd(math.gcd(i,j),k)

print(sum)

Fixed submission:
K = int(input())

import math
from functools import reduce

sum = 3*(K-1)*(K-1) + 3*(K-1) + 1

for i in range(2, K + 1):
    for j in range(2, K + 1):
        for k in range(2, K + 1):
            sum += math.gcd(math.gcd(i,j),k)

print(sum)

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

import math
from functools import reduce

sum = 0

for i in range(1, K + 1):
    for j in range(1, K + 1):
        for k in range(1, K + 1):
            sum += math.gcd(math.gcd(i,j),k)

print(sum)

Fixed submission:
K = int(input())

import math
from functools import reduce

sum = 3*(K-1)*(K-1) + 3*(K-1) + 1

for i in range(2, K + 1):
    for j in range(2, K + 1):
        for k in range(2, K + 1):
            sum += math.gcd(math.gcd(i,j),k)

print(sum)

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

import math
from functools import reduce

sum = 0

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            sum += reduce(math.gcd, [i,j,k])

print(sum)

Fixed submission:
K = int(input())

import math
from functools import reduce

sum = 3*(K-1)*(K-1) + 3*(K-1) + 1

for i in range(2, K + 1):
    for j in range(2, K + 1):
        for k in range(2, K + 1):
            sum += math.gcd(math.gcd(i,j),k)

print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
answer = 0

for i in range(1,N+1):
    for j in range(i+1,N+1):
        for k in range(j+1,N+1):
            if (j-i) != (k-j):
                if S[i-1] != S[j-1] and S[i-1] != S[k-1] and S[j-1] != S[k-1]:
                    answer += 1

print(answer)

Fixed submission:
N = int(input())
S = input()

ans = S.count('R')*S.count('G')*S.count('B')

for i in range(N-2):
  for j in range(i+1,N-1):
    k = 2*j-i
    
    if k >= N:
      break
    
    if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
      ans -= 1
      
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
answer = 0
for i in range(1,N+1):
    for j in range(i+1,N+1):
        for k in range(j+1,N+1):
            if (j-i) != (k-j):
                if S[i-1] != S[j-1] and S[i-1] != S[k-1] and S[j-1] != S[k-1]:
                    answer += 1

print(answer)

Fixed submission:
N = int(input())
S = input()

ans = S.count('R')*S.count('G')*S.count('B')

for i in range(N-2):
  for j in range(i+1,N-1):
    k = 2*j-i
    
    if k >= N:
      break
    
    if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
      ans -= 1
      
print(ans)