Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(reversed([int(input()) for i in range(n+1) ]))

prime = [2,3]

for i in range(5,100000):
    f = True
    for p in prime:
        if(p*p > i):break
        if i % p == 0 :
            f = False
            break
    if f :prime.append(i)

def gcd(x,y):
    if(x < y): x,y = y,x
    if(y == 0): return x
    return gcd(y,x % y)

def isprime(x):
    f = True
    for p in prime:
        if(p*p > x):break
        if x % p == 0:
            f = False
            break
    return f

g = 0
for i in a:
    g = gcd(abs(i),g)



for p in prime:
    if (p > n):break
    m = [0 for i in range(p-1)]
    for i in range(n+1):
        m[i % (p-1)] += (a[i] % p)
    f = True
    for i in m:
        if i % p > 0 :
            f = False
            break    
    if f:print(p)




for p in prime:
    if g == 1:break
    if(g % p == 0):
        g //= p
        if (p > n):print(p)

if(g != 1):
    if isprime(g):print(g)

Fixed submission:
n = int(input())
a = list(reversed([int(input()) for i in range(n+1) ]))

prime = [2,3]

for i in range(5,100000):
    f = True
    for p in prime:
        if(p*p > i):break
        if i % p == 0 :
            f = False
            break
    if f :prime.append(i)

def gcd(x,y):
    if(x < y): x,y = y,x
    if(y == 0): return x
    return gcd(y,x % y)

def isprime(x):
    f = True
    for p in prime:
        if(p*p > x):break
        if x % p == 0:
            f = False
            break
    return f

g = 0
for i in a:
    g = gcd(abs(i),g)



for p in prime:
    if (p > n+1):break
    m = [0 for i in range(p-1)]
    if a[0] % p != 0:continue
    for i in range(n+1):
        m[i % (p-1)] += (a[i] % p)
    f = True
    for i in m:
        if i % p > 0 :
            f = False
            break    
    if f:print(p)




for p in prime:
    if g == 1:break
    if(g % p == 0):
        g //= p
        if (p > n+1):print(p)

if(g != 1):
    if isprime(g):print(g)
Buggy python submission (verdict: Runtime Error):
MOD = 10**9+7

n = int(input())

dp = [0 for i in range(n+1)]


dic = {}

ind = [0 for i in range(n+1)]

for i in range(1,n+1):
    c = int(input())
    if c in dic:
        ind[i] = dic[c][-1]
        dic[c].append(i)
    else:
        dic[c] = [i]

dp[0] , dp[1],dp[2] = 1,1,1

for i in range(3,n+1):
    dp[i] = (dp[i] + dp[i-1]) % MOD
    if(ind[i] == 0):continue
    if(ind[i] == i-1):continue
    dp[i] = (dp[i] + dp[ind[i]]) % MOD

print(dp[n])

Fixed submission:
MOD = 10**9+7

n = int(input())

dp = [0 for i in range(n+1)]

if(n == 1):
    print("1")
    exit()
if(n==2):
    print("1")
    exit()

dic = {}

ind = [0 for i in range(n+1)]

for i in range(1,n+1):
    c = int(input())
    if c in dic:
        ind[i] = dic[c][-1]
        dic[c].append(i)
    else:
        dic[c] = [i]

dp[0] , dp[1],dp[2] = 1,1,1

for i in range(3,n+1):
    dp[i] = (dp[i] + dp[i-1]) % MOD
    if(ind[i] == 0):continue
    if(ind[i] == i-1):continue
    dp[i] = (dp[i] + dp[ind[i]]) % MOD

print(dp[n])
Buggy python submission (verdict: Time Limit Exceeded):

par1 , rank1 = [],[] 
par2 , rank2 = [],[]


def find(x,par,rank):
    if par[x] == x : return x
    else:
        par[x] = find(par[x],par,rank)
        return par[x]

def unite(x,y,par,rank): 
    x = find(x,par,rank)
    y = find(y,par,rank)
    if (x != y):
        if rank[x] < rank[y]:
            par[x] = y
        else :
            par[y] = x
            if (rank[x] == rank[y]) : rank[x] += 1

def same(x,y,par,rank):
    return (find(x,par,rank) == find(y,par,rank)) 

n,k,l = map(int,input().split())

for i in range(n): 
    par1.append(i)
    rank1.append(0)
    par2.append(i)
    rank2.append(0)

for i in range(k):
    pp,qq = map(int,input().split())
    unite(pp-1,qq-1,par1,rank1)

for i in range(l):
    rr,ss = map(int,input().split())
    if (same(rr-1,ss-1,par1,rank1)) : unite(rr-1,ss-1,par2,rank2)

dic = {}
parlis = []
for i in range(n):
    p1 = find(i,par2,rank2)
    parlis.append(p1)
    if p1 in dic:
        dic[p1] += 1
    else: 
        dic[p1] = 1

ans = str(dic[parlis[0]])

for i in range(1,n):
    ans = ans + " " + str(dic[parlis[i]])

print(ans)

Fixed submission:
import sys

def find(x,par,rank):
    if par[x] == x : return x
    else:
        par[x] = find(par[x],par,rank)
        return par[x]

def unite(x,y,par,rank): 
    x = find(x,par,rank)
    y = find(y,par,rank)
    if (x != y):
        if rank[x] < rank[y]:
            par[x] = y
        else :
            par[y] = x
            if (rank[x] == rank[y]) : rank[x] += 1

def same(x,y,par,rank):
    return (find(x,par,rank) == find(y,par,rank)) 

n,k,l = map(int, sys.stdin.readline().split())

par1 = [i for i in range(n)]
par2 = [i for i in range(n)]
rank1 = [0 for i in range(n)]
rank2 = [0 for i in range(n)]

for i in range(k):
    pp,qq = map(int, sys.stdin.readline().split())
    unite(pp-1,qq-1,par1,rank1)

for i in range(l):
    rr,ss = map(int, sys.stdin.readline().split())
    unite(rr-1,ss-1,par2,rank2)

dic = {}
parlis = []
for i in range(n):
    p1 = find(i,par1,rank1)
    p2 = find(i,par2,rank2)
    parlis.append((p1,p2))
    if (p1,p2) in dic:
        dic[(p1,p2)] += 1
    else: 
        dic[(p1,p2)] = 1

ans =[]

for i in range(n):
    ans.append(dic[parlis[i]])

print(*ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
print(1000 - (input % 1000))

Fixed submission:
N = int(input())
mod = N % 1000
res = 0 if mod == 0 else 1000 - mod
print(res)
Buggy python submission (verdict: Runtime Error):
N = input()
if(N.lower() = N):
  print("a")
else:
  print("A")

Fixed submission:
N = input()
if(N.lower() == N):
  print("a")
else:
  print("A")

Buggy python submission (verdict: Runtime Error):
N = input()
if(N.lower() = N):
  print("a")
else:
  print("A")

Fixed submission:
N = input()
if(N.lower() == N):
  print("a")
else:
  print("A")
Buggy python submission (verdict: Runtime Error):
a1 = input()
a2 = input()
a3 = input()
a4 = input()
a5 = input()
if a1 == 0:
  print(1)
if a2 == 0:
  print(2)
if a3 == 0:
  print(3)
if a4 == 0:
  print(4)
if a5 == 0:
  print(5)


Fixed submission:
a1,a2,a3,a4,a5 = map(int, input().split())
ans = [a1,a2,a3,a4,a5]
print(ans.index(0)+1)
Buggy python submission (verdict: Runtime Error):
n = input()
sum = 0

for i in range(1,n+1,1):
  if(i%3 == 0 or i%5 == 0):
    continue
  sum += i
  
print(sum)



Fixed submission:
n = int(input())
sum = 0

for i in range(1,n+1,1):
  if(i%3 == 0 or i%5 == 0):
    continue
  sum += i
  
print(sum)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

solved = [0]* 10*5
penalty_sum = 0
penalty = 0

for _ in range(m):
    q, result = input().split()
    q = int(q)
    
    if result == 'AC':
        if solved[q] == 0:
            penalty_sum += penalty
            penalty = 0
    else:
        if solved[q] == 0:
            penalty += 1

print(str(len(ac)) + " " + str(penalty_sum))

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

solved = [0]* 10**5
penalty = [0]* 10**5
penalty_sum = 0
for _ in range(m):
    q, result = input().split()
    q = int(q) - 1
    
    if result == 'AC':
        if solved[q] == 0:
            solved[q] = 1
            penalty_sum += penalty[q]
    else:
        if solved[q] == 0:
            penalty[q] += 1

print(str(sum(solved)) + " " + str(penalty_sum))
Buggy python submission (verdict: Runtime Error):
Jupyter Notebook
0temp-Copy3
(autosaved)
Current Kernel Logo
Python 3 
File
Edit
View
Insert
Cell
Kernel
Navigate
Widgets
Help

7
ABC147
from ipywidgets import Textarea
import io
​
if 'open' in globals():
    del open
if 'input' in globals():
    del input
​
original_open = open
​
class custom_open():
    def __init__(self):
        self.text = ''
​
    def __call__(self, file, *args, **kwargs):
        if file == 0:
            return io.StringIO(self.text)
        return original_open(file, *args, **kwargs)
​
    def updater(self, change):
        self.text = change["new"]
​
class custom_input():
    def __init__(self):
        self.__sio = io.StringIO('')
        self.shell = get_ipython()
        if self.shell.events.callbacks['pre_run_cell'] != []:
            self.shell.events.callbacks['pre_run_cell'] = []
        self.shell.events.register('pre_run_cell', self.pre_run_cell)
​
    def __call__(self):
        return self.__sio.readline().strip()
​
    def pre_run_cell(self, info):
        text = self.shell.user_ns.get('text_area', None).value
        self.__sio = io.StringIO(text)
​
open = custom_open()
input = custom_input()
​
text_area = Textarea()
text_area.observe(open.updater, names='value')
display(text_area)
vvvvvv
### B - Palindrome-philia
s = input()
​
n = len(s)
if n % 2 == 1:
    front = s[:(n//2 - 1)]
    rev = front[::-1]
    end = s[(n//2 - 1):]
else:
    front = s[:(n//2)]
    rev = front[::-1]
    end = s[(n//2):]
​
res = 0
for i in range(n//2 - 1):
    if rev[i] != end[i]:
        res += 1
print(res)
0
rev
'cder'
end
'oder'


Fixed submission:
s = input()
n = len(s)
res = 0
for i in range(n//2):
    if s[i] != s[-(i+1)]:
        res += 1
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]

s_dict = []


for i in range(n):
    count = {}
    for c in s[i]:
        count.setdefault(c,0)
        count[c] += 1
    s_dict.append(count)
    
ans = 0
for i in range(n):
    for j in range(i+1,n):
        if s_dict[i] == s_dict[j]: ans +=1
print(ans)

Fixed submission:
n = int(input())
s = [input() for i in range(n)]

ans = 0
count = {}
for i in range(n):
    c = ''.join(sorted(s[i]))
    count.setdefault(c,0)
    count[c] += 1
    if(count[c] > 0):
        ans += count[c] -1

print(ans)
Buggy python submission (verdict: Runtime Error):
x = [int(input()) for i in range(5)]

x_1 = [int(i / 10) for i in x]
x_2 = [(i % 10) for i in x]

ans = sum(x_1)*10 

for i in range(x_2.count(0)):
    x_2.remove(0)

ans += min(x_2)
ans += (len(x_2)-1)*10

print(ans)

Fixed submission:
x = [int(input()) for i in range(5)]

x_1 = [int(i / 10) for i in x]
x_2 = [(i % 10) for i in x]

ans = sum(x_1)*10 

for i in range(x_2.count(0)):
    x_2.remove(0)

if(x_2 != []):
    ans += min(x_2)
    ans += (len(x_2)-1)*10

print(ans)
Buggy python submission (verdict: Runtime Error):
a = [int(i) for i in input().split()] 

b = a[1]*a[2] - (a[3]*a[2] + a[4]*(a[1]-1[3]))
print(b)

Fixed submission:
a = [int(i) for i in input().split()] 
b = [int(i) for i in input().split()] 


c = a[0]*a[1] - ( b[0]*a[1] + b[1]*(a[0]-b[0]) )
print(c)
Buggy python submission (verdict: Runtime Error):
a, b = map(int,input().split())

if( (a+b) >= 10):
    print("error")
else:
    print(A+B)

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

if( (a+b) >= 10):
    print("error")
else:
    print(a+b)

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

if( (a+b) >= 10):
    print("error")
else:
    print(A+B)

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

if( (a+b) >= 10):
    print("error")
else:
    print(a+b)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))

sum=0
for i in range(n):
  sum=sum+b[a[i]]
  if i>0 | a[i-1] == a[i]+1:
    sum=sum+c[a[i-1]]
print(sum)

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

sum=0
for i in range(n):
    sum=sum+b[i]
    if i>0 and a[i-1] == a[i]-1:
        sum=sum+c[a[i]-2]
print(sum)

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

sum=0
for i in range(n):
  sum=sum+b[a[i]]
  if i>0 | a[i-1] == a[i]+1:
    sum=sum+c[a[i-1]]

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

sum=0
for i in range(n):
    sum=sum+b[i]
    if i>0 and a[i-1] == a[i]-1:
        sum=sum+c[a[i]-2]
print(sum)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
count=1
x=a
if b > 1:
  while X < b:
    x = x + (a-1)
    count += 1
  print(count)
else:
  print(0)

Fixed submission:
a,b=map(int,input().split())
count=1
x=a
if b > 1:
  while x < b:
    x = x + (a-1)
    count += 1
  print(count)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
n=int(input())
v=list(map(int, input().split())).sort()
sum=v[0]
for i in range(1,len(v)):
  sum=(sum+v[i])/2
print(sum)

Fixed submission:
n=int(input())
v=list(map(int, input().split()))
v.sort()
sum=v[0]
for i in range(1,len(v)):
  sum=(sum+v[i])/2
print(sum)
Buggy python submission (verdict: Runtime Error):
K, X = map(int, input().split())

for i in range(2*K):
  list[i]=(X-K+1+i)
  print(*list)

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

for i in range(2*K-1):
  print(X-K+1+i,end=" ")
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if (a-b)>=c:
  print(0)
  else:
    print(c-a+b)

Fixed submission:
a,b,c=map(int,input().split())
if (a-b)>=c:
  print(0)
else:
  print(c-a+b)
Buggy python submission (verdict: Runtime Error):
    n,a,b=map(int,input().split())
    print(min(n*a,b))

Fixed submission:
n,a,b=map(int,input().split())
print(min(n*a,b))
Buggy python submission (verdict: Runtime Error):
l=[int(input()) for i in range(6)]
if l[4]-l[0] <=l[5]:
  print('Yay!')
else:
  print(':(')

Fixed submission:
a,b=map(int, input().split())
sum=0
for i in range(2):
  if a>=b:
    sum+=a
    a=a-1
  else:
    sum+=b
    b=b-1
print(sum)
Buggy python submission (verdict: Runtime Error):
m=int(input())
if m==25:
  print('Christmas')
elif m==24:
  print('Christmas Eve')
elif m==23:
  print('Christmas Eve Eve')
elif: m==22:
  print('Christmas Eve Eve Eve')

Fixed submission:
m=int(input())
if m==25:
  print('Christmas')
elif m==24:
  print('Christmas Eve')
elif m==23:
  print('Christmas Eve Eve')
elif m==22:
  print('Christmas Eve Eve Eve')
Buggy python submission (verdict: Runtime Error):
s=input()
for i in range(3):
  if s[i] =='9':
    s[i]='1'
  else:
    s[i]='9'
print(s)

Fixed submission:
s=input()
t=[]
for i in range(3):
  if s[i] =='9':
    t.append('1')
  else:
    t.append('9')
st="".join(t)
print(st)
Buggy python submission (verdict: Runtime Error):
    a,b=map(int,input().split())
    if a==2 or b==2:
      print('No')
    else:
      print('Yes')

Fixed submission:
a,b=map(int,input().split())
if a==2 or b==2:
  print('No')
else:
  print('Yes')

Buggy python submission (verdict: Runtime Error):
a,b=map(int(input().split()))
if a==2 or b==2:
  print('No')
else:
  print('Yes')

Fixed submission:
a,b=map(int,input().split())
if a==2 or b==2:
  print('No')
else:
  print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
for i in range(1,10**9+1):
  if i%2==0 and i%n==0:
    print(i)
    exit()

Fixed submission:
n=int(input())
if(n%2==0):
  print(n)
else:
  print(n*2)

Buggy python submission (verdict: Runtime Error):
n=int(input())
for i in 10**9:
  if n%2==0 and n%i==0:
    print(i)
    exit()

Fixed submission:
n=int(input())
if(n%2==0):
  print(n)
else:
  print(n*2)
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
if abs(a-c)<=d:
  print('Yes')
elif:
  abs(a-b)<=d and abs(b-d)<=d:
    print('Yes')
else:
  print('No')

Fixed submission:
a,b,c,d=map(int,input().split())
if abs(a-c)<=d:
  print('Yes')
elif abs(a-b)<=d and abs(b-c)<=d:
    print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
a,b,x-map(int,input().split())
if a<=x<=b:
  print('YES')
else:
  print('NO')

Fixed submission:
a,b,x=map(int,input().split())
if a<=x<=a+b:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
x,a,b=map(int,input().split())
print((x-a)%b)

Fixed submission:
x,a,b=[int(input()) for i in range(3)]
print((x-a)%b)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input())
print((n-1)*(m-1))

Fixed submission:
n,m=map(int,input().split())
print((n-1)*(m-1))

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input())
print((n-a)*(m-1))

Fixed submission:
n,m=map(int,input().split())
print((n-1)*(m-1))
Buggy python submission (verdict: Runtime Error):
a,b,c=input()
print('YES' if a[-1]==b[0] and b[-1] == c[0] else 'NO')

Fixed submission:
a,b,c=input().split()
print('YES' if a[-1]==b[0] and b[-1] == c[0] else 'NO')
Buggy python submission (verdict: Runtime Error):
a,b,c=map(upper(),input().split())
print(a[0],b[0],c[0])

Fixed submission:
a,b,c=input().split()
s=a[0].upper() + b[0].upper() + c[0].upper()
print(s)
Buggy python submission (verdict: Runtime Error):
a,b=input()
if a=='H' and b=='H':
  print('H')
elif a=='H' and b=='D':
  print('D')
elif a=='D' and b=='D':
  print('H')
else:
  print('D')

Fixed submission:
a,b=input().split()
if a=='H' and b=='H':
  print('H')
elif a=='H' and b=='D':
  print('D')
elif a=='D' and b=='D':
  print('H')
else:
  print('D')
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a==b:
  print('Draw')
elif a==1 or (a>b and B!=1):
  print('Alice')
else:
  print('Bob')

Fixed submission:
a,b=map(int,input().split())
if a==b:
  print('Draw')
elif a==1 or (a>b and b!=1):
  print('Alice')
else:
  print('Bob')
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int.input().split())
if a*b>=c*d:
  print(a*b)
else:
  print(c*d)

Fixed submission:
a,b,c,d=map(int,input().split())
if a*b>=c*d:
  print(a*b)
else:
  print(c*d)
Buggy python submission (verdict: Runtime Error):
a,b,c=input()
print('A'+b[0]+'C')

Fixed submission:
a,b,c=input().split()
print('A'+b[0]+'C')
Buggy python submission (verdict: Runtime Error):
l=list(map(int,input().split()))
l=sorted(l)
if s[0]+l[1]==s[2]:
  print('Yes')
else:
  print('No')

Fixed submission:
l=list(map(int,input().split()))
l=sorted(l)
if (l[0]+l[1])==l[2]:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n=int(input())
sum=0
for i in range(1:n+1):
  sum+=i
print(sum)

Fixed submission:
n =int(input())
sum=0
for i in range(n):
  sum+=(i+1)
print(sum)
Buggy python submission (verdict: Runtime Error):
# n,m = map(int,input().split())
h_list = list(map(int,input().split()))
roads = []
for i in range(m):
    a,b = map(int,input().split())
    roads.append([a,b])
#print(roads)
terrace = [1] * n
for road in roads:
    if h_list[road[0]-1] > h_list[road[1]-1]:
        terrace[road[1]-1] = 0
    elif h_list[road[0]-1] == h_list[road[1]-1]:
        terrace[road[0]-1] = 0
        terrace[road[1]-1] = 0
    elif h_list[road[0]-1] < h_list[road[1]-1]:
        terrace[road[0]-1] = 0
print(terrace.count(1))

Fixed submission:
n,m = map(int,input().split())
h_list = list(map(int,input().split()))
roads = []
for i in range(m):
    a,b = map(int,input().split())
    roads.append([a,b])
#print(roads)
terrace = [1] * n
for road in roads:
    if h_list[road[0]-1] > h_list[road[1]-1]:
        terrace[road[1]-1] = 0
    elif h_list[road[0]-1] == h_list[road[1]-1]:
        terrace[road[0]-1] = 0
        terrace[road[1]-1] = 0
    elif h_list[road[0]-1] < h_list[road[1]-1]:
        terrace[road[0]-1] = 0
print(terrace.count(1))
Buggy python submission (verdict: Time Limit Exceeded):
a,b,n = map(int,input().split())
#(a*x)//b - a*(x//b) の最大値を求める
ax_list = [a*i for i in range(1,n+1)]
if b > n:
    # ax//b だけ考えればいい
    print(a*n//b)
else:
    # ax//b か　bより大きいx で探す
    x = 2*b-1
    first = a*(b-1)//b
    second = (a*x)//b - a*(x//b)
    print(first if first >= second else second)

Fixed submission:
a,b,n = map(int,input().split())
#(a*x)//b - a*(x//b) の最大値を求める
if b > n:
    # ax//b だけ考えればいい
    print(a*n//b)
else:
    # ax//b か　bより大きいx で探す
    x = 2*b-1
    first = a*(b-1)//b
    second = (a*x)//b - a*(x//b)
    print(first if first >= second else second)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,n = map(int,input().split())
#(a*x)//b - a*(x//b) の最大値を求める
ax_list = [a*i for i in range(1,n+1)]
if b > n:
    # ax//b だけ考えればいい
    print(a*n//b)
else:
    # ax//b か　bより大きいx で探す
    x = 2*b-1
    first = a*(b-1)//b
    second = (a*x)//b - a*(x//b)
    print(first if first >= second else second)

Fixed submission:
a,b,n = map(int,input().split())
#(a*x)//b - a*(x//b) の最大値を求める
if b > n:
    # ax//b だけ考えればいい
    print(a*n//b)
else:
    # ax//b か　bより大きいx で探す
    x = 2*b-1
    first = a*(b-1)//b
    second = (a*x)//b - a*(x//b)
    print(first if first >= second else second)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,n = map(int,input().split())
#(a*x)//b - a*(x//b) の最大値を求める
ax_list = [a*i for i in range(1,n+1)]
if b > n:
    # ax//b だけ考えればいい
    print(a*n//b)
else:
    # ax//b か　bより大きいx で探す
    x = 2*b-1
    print(a*(b-1)//b if a*(b-1)//b >= (a*x)//b-a*(x//b) else (a*x)//b-a*(x//b))

Fixed submission:
a,b,n = map(int,input().split())
#(a*x)//b - a*(x//b) の最大値を求める
if b > n:
    # ax//b だけ考えればいい
    print(a*n//b)
else:
    # ax//b か　bより大きいx で探す
    x = 2*b-1
    first = a*(b-1)//b
    second = (a*x)//b - a*(x//b)
    print(first if first >= second else second)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
k = int(input())
total = 0
ab_gcd = []
for a in range(1,k+1):
    for b in range(1,k+1):
        ab_gcd.append(gcd(a,b))
for ab in ab_gcd:
    for c in range(1,k+1):
        abc = gcd(ab,c)
        total += abc
print(total)

Fixed submission:
from math import gcd
k = int(input())
total = 0
ab_gcd = []
for a in range(1,k+1):
    for b in range(1,k+1):
        ab_gcd.append(gcd(a,b))
for ab in ab_gcd:
    for c in range(1,k+1):
        abc = gcd(ab,c)
        total += abc
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
k = int(input())
summation = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ab = gcd(a,b)
            abc = gcd(ab,c)
            summation += abc
print(summation)

Fixed submission:
from math import gcd
k = int(input())
total = 0
ab_gcd = []
for a in range(1,k+1):
    for b in range(1,k+1):
        ab_gcd.append(gcd(a,b))
for ab in ab_gcd:
    for c in range(1,k+1):
        abc = gcd(ab,c)
        total += abc
print(total)
Buggy python submission (verdict: Runtime Error):
page = input()
if page%2 = 0 :
  print(page/2)
elif page%2 = 1 :
  print(page/2 + 1)

Fixed submission:
page = int(input())

if page%2 == 0 :
  print(int(page/2))
elif page%2 == 1 :
  print(page//2 + 1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a_copy = a.copy()
biggest = max(a)
a_copy.remove(biggest)
second_biggest = max(a_copy)

for j in range(n):
    if a[j] == biggest:
        print(second_biggest)
    else:
        print(biggest)

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a_copy = a.copy()
biggest = max(a)
a_copy.remove(biggest)
second_biggest = max(a_copy)

for j in range(n):
    if a[j] == biggest:
        print(second_biggest)
    else:
        print(biggest)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
for j in range(n):
    excp = a.pop(j)
    print(max(a))
    a.insert(j, excp)

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a_copy = a.copy()
biggest = max(a)
a_copy.remove(biggest)
second_biggest = max(a_copy)

for j in range(n):
    if a[j] == biggest:
        print(second_biggest)
    else:
        print(biggest)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
for j in range(n):
    excp = a.pop(j)
    print(max(a))
    a.insert(j, excp)

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a_copy = a.copy()
biggest = max(a)
a_copy.remove(biggest)
second_biggest = max(a_copy)

for j in range(n):
    if a[j] == biggest:
        print(second_biggest)
    else:
        print(biggest)