Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n=int(input())
d=dict()
for i in map(int,input().split()):
  if i not in d:
    d[i]=1
  else:
    d[i]+=1
ans=[]
for i in d.keys():
  for _ in range(d[i]//2):
    ans.append(i)
ans.sort(reverse=1)
print(ans[0]*ans[1])

Fixed submission:
n=int(input())
d=dict()
for i in map(int,input().split()):
  if i not in d:
    d[i]=1
  else:
    d[i]+=1
ans=[0,0]
for i in d.keys():
  for _ in range(d[i]//2):
    ans.append(i)
ans.sort(reverse=1)
print(ans[0]*ans[1])
Buggy python submission (verdict: Runtime Error):
a=input()
for i in range(len(a)):
  if not a[i]==a[len(a)-1-i]:
    ans=1
if ans==1:
  print("No")
else:
  print("Yes")

Fixed submission:
a=input()
ans=0
for i in range(len(a)):
  if not a[i]==a[len(a)-1-i]:
    ans=1
if ans==1:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
N = int(input())
T = [int(input()) for _ in range(N)]
def gcd(a, b):
	while b:
        a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd(a, b)
l = 1
for i in T:
    l = lcm(l, i)
print(l)


Fixed submission:
N = int(input())
T = [int(input()) for _ in range(N)]

def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

ans=1
for i in T:
    ans = lcm(ans,i)

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
T = [int(input() for _ in range(N))]

def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

ans=1
for i in range(T):
    ans = lcm(ans,i)

print(ans)


Fixed submission:
N = int(input())
T = [int(input()) for _ in range(N)]

def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

ans=1
for i in T:
    ans = lcm(ans,i)

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
T = [int(input() for _ in range(N))]

def gcd(a,b):
    while b:
        a,b=b,a%b
    return b

def lcm(a,b):
    return a*b//gcd(a,b)

ans=1
for i in range(T):
    ans = lcm(ans,i)
    
print(ans)


Fixed submission:
N = int(input())
T = [int(input()) for _ in range(N)]

def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

ans=1
for i in T:
    ans = lcm(ans,i)

print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
m=list(map(int,input().split()))
for i in range(n):
  a=0
  for m[i]>1:
    m[i]//=2
    a+=1
  if a>2:
    a=2
  m[i]=a
if m.count(2)>m.count(1):
  print("Yes")
else:
  print("No")

Fixed submission:
n=int(input())
m=list(map(int,input().split()))
for i in range(n):
  a=0
  while m[i]%2==0:
    m[i]//=2
    a+=1
  if a>2:
    a=2
  m[i]=a
if m.count(2)>=m.count(0):
  print("Yes")
elif m.count(0)==0:
  print("Yes")
elif m.count(1)==0 and m.count(2)>=m.count(0)-1:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
l=[int(input())for i in range(n)]
l.sort(reverse=1)
print(sum(l[:k]))

Fixed submission:
n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=1)
print(sum(l[:k]))
Buggy python submission (verdict: Runtime Error):
n,p=map(int,input().split())
l=list(map(lambda x:int(x)%2,input().split()))
a,b=0,0
for i in l:
  if l%2>0:
    a+=1
  else:
    b+=1
if a==0:
  if p==0:
    print(2**n)
  else:
    print(0)
else:
  print(2**(n-1))

Fixed submission:
n,p=map(int,input().split())
l=list(map(lambda x:int(x)%2,input().split()))
a,b=0,0
for i in l:
  if i>0:
    a+=1
  else:
    b+=1
if a==0:
  if p==0:
    print(2**n)
  else:
    print(0)
else:
  print(2**(n-1))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=input()
ans=""
for i in range(n-1,-1,-2):
  ans+=a[i]
for i in range(n%a,n,2):
  ans+=a[i]
print(ans)

Fixed submission:
n=int(input())
a=input().split()
ans=""
for i in range(n-1,-1,-2):
  ans+=a[i]+" "
for i in range(n%2,n,2):
  ans+=a[i]+" "
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=input().split()
ans=""
for i in range(n-1,-1,-2):
  ans+=a[i]
for i in range(n%a,n,2):
  ans+=a[i]
print(ans)

Fixed submission:
n=int(input())
a=input().split()
ans=""
for i in range(n-1,-1,-2):
  ans+=a[i]+" "
for i in range(n%2,n,2):
  ans+=a[i]+" "
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
d=[int(input())-1for i in range(n)]
s=set(0)
ans=0
b=0
while 1>0:
  if d[b] in s:
    ans=-1
    break
  b=d[b]
  s.add(b)
  ans+=1
  if b==1:
    break
print(ans)

Fixed submission:
n=int(input())
d=[int(input())-1for i in range(n)]
s=set()
s.add(0)
ans=0
b=0
while 1>0:
  if d[b] in s:
    ans=-1
    break
  b=d[b]
  s.add(b)
  ans+=1
  if b==1:
    break
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
d=[int(input())-1for i in range(n)]
s=set(0)
ans=0
b=0
while 1>0:
  if d[b] in s:
    ans=-1
    break
  b=d[b]
  s+=d[b]
  ans+=1
  if b==1:
    break
print(ans)

Fixed submission:
n=int(input())
d=[int(input())-1for i in range(n)]
s=set()
s.add(0)
ans=0
b=0
while 1>0:
  if d[b] in s:
    ans=-1
    break
  b=d[b]
  s.add(b)
  ans+=1
  if b==1:
    break
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=wap(int,input().split())
if a+b>9:
  print("error")
else:
  print(a+b)

Fixed submission:
a,b=map(int,input().split())
if a+b>9:
  print("error")
else:
  print(a+b)
Buggy python submission (verdict: Runtime Error):
s=input()
a={}
ans="yes"
for i in range(len(s)):
  if s[i] in a:
    ans="no"
    break
  a.add(s[i])
print(ans)

Fixed submission:
s=input()
a=set()
ans="yes"
for i in range(len(s)):
  if s[i] in a:
    ans="no"
    break
  a.add(s[i])
print(ans)

Buggy python submission (verdict: Runtime Error):
s=input()
a={}
ans="yes"
for i in range(len(s)):
  if s[i] in a:
    ans="no"
    break
  a=a|{s[i]}
print(ans)

Fixed submission:
s=input()
a=set()
ans="yes"
for i in range(len(s)):
  if s[i] in a:
    ans="no"
    break
  a.add(s[i])
print(ans)

Buggy python submission (verdict: Runtime Error):
s=input()
a={}
ans="yes"
for i in range(len(s)):
  if s[i] in a:
    ans="no"
    break
  a+={s[i]}
print(ans)

Fixed submission:
s=input()
a=set()
ans="yes"
for i in range(len(s)):
  if s[i] in a:
    ans="no"
    break
  a.add(s[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
n,t=map(int,input().split())
k=1000000000
for i in map(int,input().split()):
  ans+=min(t,max(i-k,0))
  k=i
ans+=t
print(ans)

Fixed submission:
n,t=map(int,input().split())
ans=0
k=1000000000
for i in map(int,input().split()):
  ans+=min(t,max(i-k,0))
  k=i
ans+=t
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())

m = int(N **0.5)
for i in range(1,m):
    j = N // i
    if i*j < N:
        continue
    k = i
a = N // k
ans=0
b = str(a)
ans = len(b)

print(ans)


Fixed submission:
N = int(input())

m = int(N **0.5)+1
for i in range(1,m):
    j = N // i
    if i*j < N:
        continue
    k = i
a = N // k
ans=0
b = str(a)
ans = len(b)

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())

m = int(N **0.5)
for i in range(1,m):
    j = N / i
    if int(j) < j:
        continue
    k = i
a = N // k
ans=0
while a >= 1:
    a //=10
    ans+=1

print(ans)


Fixed submission:
N = int(input())

m = int(N **0.5)+1
for i in range(1,m):
    j = N // i
    if i*j < N:
        continue
    k = i
a = N // k
ans=0
b = str(a)
ans = len(b)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
ans=1
a=[i for i in range(1,int(input())+1)]
for i in a:
  ans*=i
print(ans%(10**9+7))

Fixed submission:
ans=1
a=[i for i in range(1,int(input())+1)]
for i in a:
  ans*=i
  ans%=10**9+7
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
ans=1
for i in range(1,int(input())+1):
  ans*=i
print(ans%(10**9+7))

Fixed submission:
ans=1
a=[i for i in range(1,int(input())+1)]
for i in a:
  ans*=i
  ans%=10**9+7
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d=dict()
for i in range(1,n+1):
  for j in range(1,i+1):
    while i%j==0:
      if j not in d:
        d[j]=1
      else:
        d[j]+=1
      i//=j
ans=1
for i in d.values():
  ans*=i+1
print(ans%1000000007)


Fixed submission:
n=int(input())
d=dict()
for i in range(1,n+1):
  for j in range(1,i+1):
    if j==1:
      continue
    while i%j==0:
      if j not in d:
        d[j]=1
      else:
        d[j]+=1
      i//=j
ans=1
for i in d.values():
  ans*=i+1
print(ans%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ans=1
d=dict()
for i in range(1,n+1):
  k=1
  for j in range(1,i+1):
    if j==0 or j==i:
      continue
    if i%j==0:
      k=0
  if k:
    d[i]=0
    n0=n
    while n0:
      d[i]+=n0//i
      n0//=i
for i in d.values():
  ans*=i+1
print(ans)

Fixed submission:
n=int(input())
d=dict()
for i in range(1,n+1):
  for j in range(1,i+1):
    if j==1:
      continue
    while i%j==0:
      if j not in d:
        d[j]=1
      else:
        d[j]+=1
      i//=j
ans=1
for i in d.values():
  ans*=i+1
print(ans%1000000007)

Buggy python submission (verdict: Runtime Error):
n=int(input())
d=dict()
m=[2,3,5,7,11,13,17,19,23,29,31]
for i in m:
  d[i]=0
  nn=n
  while nn:
    d[i]+=nn//i
    nn//=i
ans=1
for i in dict.values():
  ans*=i+1
print(ans)


Fixed submission:
n=int(input())
d=dict()
for i in range(1,n+1):
  for j in range(1,i+1):
    if j==1:
      continue
    while i%j==0:
      if j not in d:
        d[j]=1
      else:
        d[j]+=1
      i//=j
ans=1
for i in d.values():
  ans*=i+1
print(ans%1000000007)

Buggy python submission (verdict: Runtime Error):
n=int(input())
d=dict()
if n==1:
  print(1)
else:
  for i in range(2,n+1):
    for j in range(2,i+1):
      if i%j==0:
        if j not in d:
          d[i]=1
        else:
          d[i]+=1
  ans=1
  for i in d.values():
    ans*=i+1
  print(ans)

Fixed submission:
n=int(input())
d=dict()
for i in range(1,n+1):
  for j in range(1,i+1):
    if j==1:
      continue
    while i%j==0:
      if j not in d:
        d[j]=1
      else:
        d[j]+=1
      i//=j
ans=1
for i in d.values():
  ans*=i+1
print(ans%1000000007)

Buggy python submission (verdict: Runtime Error):
n=int(input())
d=dict()
if n==1:
  print(1)
else:
  for i in range(2,n+1):
    for j in range(2,i+1):
      if i%j==0:
        if j not in d:
          d[i]=1
        else:
          d[i]+=1
  ans=1
  for i in d.values():
    ans*=i+1

Fixed submission:
n=int(input())
d=dict()
for i in range(1,n+1):
  for j in range(1,i+1):
    if j==1:
      continue
    while i%j==0:
      if j not in d:
        d[j]=1
      else:
        d[j]+=1
      i//=j
ans=1
for i in d.values():
  ans*=i+1
print(ans%1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
ans=0

for x in range(k,-1,-1):
    if s-x > k*2:
        break
    if s < x:
        continue
    for y in range(k,-1,-1):
        if s-x-y > k:
            break
        if s < x+y:
            continue
        for z in range(k,-1,-1):
            if s-x-y-z > 0:
                break
            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,-1):
    if s-x > k*2:
        break
    if s < x:
        continue
    for y in range(k,-1,-1):
        if s-x-y > k:
            break
        if 0<= s-x-y <=k:
            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,-1):
    if s-x > k*2:
        break
    if s < x:
        continue
    for y in range(k,-1,-1):
        if s-x-y > k:
            break
        if 0<= s-x-y <=k:
            ans +=1

print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
#ne,[7,5,3,1,1,3,5,7]8
#no,[8,6,4,2,0,2,4,6,8]9
m=[0]*n
for i in map(int,input().split()):
  m[i]+=1
ans=1
for i in range(n-1,0,-2):
  if d[i]!=2:
    ans=0
if d[0]!=n%2:
  ans=0
if ans:
  print(2**(n//2)%1000000007)
else:
  print(0)
    

Fixed submission:
n=int(input())
#ne,[7,5,3,1,1,3,5,7]8
#no,[8,6,4,2,0,2,4,6,8]9
m=[0]*n
for i in map(int,input().split()):
  m[i]+=1
ans=1
for i in range(n-1,0,-2):
  if m[i]!=2:
    ans=0
if m[0]!=n%2:
  ans=0
if ans:
  print(2**(n//2)%1000000007)
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
n=int(input())
#ne,[7,5,3,1,1,3,5,7]8
#no,[8,6,4,2,0,2,4,6,8]9
m=[0]*n
for i in map(int,input().split()):
  m[i]+=1
ans=1
for i in range(n-1,0,-2):
  d[i]!=2:
    ans=0
if d[0]!=n%2:
  ans=0
if ans:
  print(2**(n//2)%1000000007)
else:
  print(0)
    

Fixed submission:
n=int(input())
#ne,[7,5,3,1,1,3,5,7]8
#no,[8,6,4,2,0,2,4,6,8]9
m=[0]*n
for i in map(int,input().split()):
  m[i]+=1
ans=1
for i in range(n-1,0,-2):
  if m[i]!=2:
    ans=0
if m[0]!=n%2:
  ans=0
if ans:
  print(2**(n//2)%1000000007)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
for i in range(h):
  a=input()
  if 'snuke' in a:
    b=a.find('snuke')
    break
print(chr(ord('A')+b)+str(a+1))

Fixed submission:
h,w=map(int,input().split())
for i in range(h):
  a=input()
  if 'snuke' in a:
    b=a.find('snuke')
    break
print(chr(ord('A')+b//6)+str(i+1))
Buggy python submission (verdict: Runtime Error):
k,t=map(int,input().split())
l=list(map(int,input().split()))
if len(l)==n:
  print(n-1)
else:
  print(max(0,max(l)//2-n))

Fixed submission:
k,t=map(int,input().split())
l=list(map(int,input().split()))
if len(l)==1:
  print(k-1)
else:
  if k%2==0:
    print(max(0,(max(l)-k//2)*2-1))
  else:
    print(max(0,(max(l)-k//2-1)*2))

Buggy python submission (verdict: Runtime Error):
k,t=wap(int,input().split())
l=list(map(int,input().split()))
print(max(0,max(l)//2-n))

Fixed submission:
k,t=map(int,input().split())
l=list(map(int,input().split()))
if len(l)==1:
  print(k-1)
else:
  if k%2==0:
    print(max(0,(max(l)-k//2)*2-1))
  else:
    print(max(0,(max(l)-k//2-1)*2))
Buggy python submission (verdict: Runtime Error):
n=input()
m=[[]for _ in range(n)]
m[0]+=[[0,int(n[0])]]
for i in range(1,len(n)):
  a=int(n[i])
  for m0,m1 in m[i-1]:
    m[i]+=[[m0+m1,a]]
    m[i]+=[[m0,m1*10+a]]
ans=0
for m0,m1 in m[len(n)-1]:
  ans+=m0+m1
print(ans)

Fixed submission:
n=input()
m=[[]for _ in range(len(n))]
m[0]+=[[0,int(n[0])]]
for i in range(1,len(n)):
  a=int(n[i])
  for m0,m1 in m[i-1]:
    m[i]+=[[m0+m1,a]]
    m[i]+=[[m0,m1*10+a]]
ans=0
for m0,m1 in m[len(n)-1]:
  ans+=m0+m1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=[int(input()) for i in range(n)]
s=sum(l)/n
if s-int(s)<int(s)+1-s:
  s=int(s)
else:
  s=int(s)+1
ans=0
for i in l:
  ans+=(s-i)**2
print(ans)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
s=sum(l)/n
if s-int(s)<int(s)+1-s:
  s=int(s)
else:
  s=int(s)+1
ans=0
for i in l:
  ans+=(s-i)**2
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a*b<=0::
  print("Zero")
else:
  if a>0 or (b-a)%2>0:
    print("Positive")
  else:
    print("Negative")

Fixed submission:
a,b=map(int,input().split())
if a*b<=0:
  print("Zero")
else:
  if a>0 or (b-a)%2>0:
    print("Positive")
  else:
    print("Negative")
Buggy python submission (verdict: Runtime Error):
n,l=map(int,input().split())
s =[]
for _ in range(n):
    t = input()
    s +=[t]

def dic(a,b):
    for i in range(l):
        if ord(a[i])<ord(b[i]):
            c =0
            break
        if ord(b[i])<ord(a[i]):
            c =1
            break
    return c

for i in range(1,n):
    for j in range(i):
        j = i - j
        if dic(s[j-1],s[j]):
            s[j],s[j-1]=s[j-1],s[j]
        else:
            break       

ans =""
for x in s:
    ans +=x

print(ans) 


Fixed submission:
n,l=map(int,input().split())
s =[]
for _ in range(n):
    t = input()
    s +=[t]

s.sort()

ans =""
for x in s:
    ans +=x

print(ans)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
m=[]
for i in range(10):
  if i not in a:
    m.append(i)
k=0
for a in m:
  for b in m:
    for c in m:
      for d in m:
        for e in m:
        num=a*10000+b*1000+c*100+d*10+e
        if k==0 and num>=n:
          print(num)
          k=1

Fixed submission:
n,k=map(int,input().split())
m=list(map(int,input().split()))
for i in range(n,100000):
  k=1
  for a in str(i):
    if int(a) in m:
      k=0
  if k:
    print(i)
    break

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
m=[]
for i in range(10):
  if i not in a:
    m.append(i)
k=0
for a in m:
  for b in m:
    for c in m:
      for d in m:
        num=a*1000+b*100+c*10+d
        if k==0 and num>=n:
          ans=num
          k=1
print(ans)

Fixed submission:
n,k=map(int,input().split())
m=list(map(int,input().split()))
for i in range(n,100000):
  k=1
  for a in str(i):
    if int(a) in m:
      k=0
  if k:
    print(i)
    break

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
m=[]
for i in [0,1,2,3,4,5.6,7,8,9]:
  if i not in a:
    m.append(i)
k=0
for a in m:
  for b in m:
    for c in m:
      for d in m:
        num=a*1000+b*100+c*10+d
        if k==0 and num>=n:
          ans=num
          k=1
print(ans)

Fixed submission:
n,k=map(int,input().split())
m=list(map(int,input().split()))
for i in range(n,100000):
  k=1
  for a in str(i):
    if int(a) in m:
      k=0
  if k:
    print(i)
    break

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
m=[]
for i in [0,1,2,3,4,5.6,7,8,9]:
  if i not in a:
    m.append(i)
k=0
for a in m:
  for b in m:
    for c in m:
      for d in m:
        if k:
          break
        num=a*1000+b*100+c*10+d
        if num>=n:
          ans=num
          k=1
print(ans)

Fixed submission:
n,k=map(int,input().split())
m=list(map(int,input().split()))
for i in range(n,100000):
  k=1
  for a in str(i):
    if int(a) in m:
      k=0
  if k:
    print(i)
    break
Buggy python submission (verdict: Runtime Error):
x, y, z = input.split(",")

print(x, y, z)

Fixed submission:
x, y, z = input().split(",")
print(x, y, z)
Buggy python submission (verdict: Runtime Error):
A, B, C, K = [int(i) for i in input().split()]
D = [1] * A + [0] * B + [-1] * C
print(sum(D[:K]))

Fixed submission:
A, B, C, K = [int(i) for i in input().split()]
if A + B >= K:
    if K < A:
        print(K)
    else:
        print(A)
else:
    tmp = K - A - B
    print(A - tmp)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = [int(i) for i in input().split()]
ans = 0
if N < B:
    ans = int(( A * (N % B) - (A * N) % B) / B)
else:
    for x in range(B-1, N+1, B):
        tmp = int(( A * (x % B) - (A * x) % B) / B)
        if tmp >= ans:
            ans = tmp
print(ans)

Fixed submission:
A, B, N = [int(i) for i in input().split()]
ans = 0
if N < B:
    ans = int(( A * (N % B) - (A * N) % B) / B)
else:
    tmp_ = int(( A * (N % B) - (A * N) % B) / B)
    x = (N - N % B - 1)
    tmp = int(( A * (x % B) - (A * x) % B) / B)
    ans = max(tmp, tmp_)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = [int(i) for i in input().split()]
ans = 0
for i in range(B):
    x = N - i
    if x < 0:
        break
    tmp = int(A * (x % B / B) - (A * x % B) / B)
    if tmp >= ans:
        ans = tmp
print(ans)

Fixed submission:
A, B, N = [int(i) for i in input().split()]
ans = 0
if N < B:
    ans = int(( A * (N % B) - (A * N) % B) / B)
else:
    tmp_ = int(( A * (N % B) - (A * N) % B) / B)
    x = (N - N % B - 1)
    tmp = int(( A * (x % B) - (A * x) % B) / B)
    ans = max(tmp, tmp_)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = [int(i) for i in input().split()]
ans = 0
for i in range(B):
    x = N - i
    if x < 0:
        break
    tmp = int(A * (x % B / B) - (A * x % B) / B)
    if tmp >= ans:
        ans = tmp
print(ans)

Fixed submission:
A, B, N = [int(i) for i in input().split()]
ans = 0
if N < B:
    ans = int(( A * (N % B) - (A * N) % B) / B)
else:
    tmp_ = int(( A * (N % B) - (A * N) % B) / B)
    x = (N - N % B - 1)
    tmp = int(( A * (x % B) - (A * x) % B) / B)
    ans = max(tmp, tmp_)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = [int(i) for i in input().split()]
ans = 0
for i in range(A*B):
    x = N - i
    if x < 0:
        break
    tmp = int(A * (x % B / B) - (A * x % B) / B)
    if tmp >= ans:
        ans = tmp
print(ans)

Fixed submission:
A, B, N = [int(i) for i in input().split()]
ans = 0
if N < B:
    ans = int(( A * (N % B) - (A * N) % B) / B)
else:
    tmp_ = int(( A * (N % B) - (A * N) % B) / B)
    x = (N - N % B - 1)
    tmp = int(( A * (x % B) - (A * x) % B) / B)
    ans = max(tmp, tmp_)
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
from functools import lru_cache
sys.setrecursionlimit(10000)

@lru_cache(maxsize = None)
def rec(i, j):
    flag = False
    flag_ = False
    tmp = dp[i][j] + A[i+j][0] * abs(A[i+j][1] - i)
    if tmp > dp[i+1][j]:
        dp[i+1][j] = tmp
        flag = True
    tmp_ = dp[i][j] + A[i+j][0] * abs(A[i+j][1] - N + j + 1)
    if tmp_ > dp[i][j+1]:
        dp[i][j+1] = tmp_ if tmp_ > dp[i][j+1] else dp[i][j+1]
        flag_ = True
    if i + j == N - 1:
        return
    if flag:
        rec(i + 1, j)
    if flag_:
        rec(i, j + 1)
    
N = int(input())
A = sorted([(int(j),i) for i, j in enumerate(input().split())])[::-1]

dp = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
rec(0, 0)
ans = -1
for i in range(N):
    for j in range(N):
        if dp[i][j] > ans:
            ans = dp[i][j]
print(ans)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
B = [0]*N
for i in A:
    B[i-1] += 1
for i in B:
    print(i)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

def rec(i, j):
    flag = False
    flag_ = False
    tmp = dp[i][j] + A[i+j][0] * abs(A[i+j][1] - i)
    if tmp > dp[i+1][j]:
        dp[i+1][j] = tmp
        flag = True
    tmp_ = dp[i][j] + A[i+j][0] * abs(A[i+j][1] - N + j + 1)
    if tmp_ > dp[i][j+1]:
        dp[i][j+1] = tmp_ if tmp_ > dp[i][j+1] else dp[i][j+1]
        flag_ = True
    if i + j == N - 1:
        return
    if flag:
        rec(i + 1, j)
    if flag_:
        rec(i, j + 1)
    
N = int(input())
A = sorted([(int(j),i) for i, j in enumerate(input().split())])[::-1]

dp = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
rec(0, 0)
ans = -1
for i in range(N):
    for j in range(N):
        if dp[i][j] > ans:
            ans = dp[i][j]
print(ans)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
B = [0]*N
for i in A:
    B[i-1] += 1
for i in B:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
ans = S
for _ in range(Q):
    q = [i for i in input().split()]
    if int(q[0]) == 1:
        S = S[::-1]
    else:
        if int(q[1]) == 1:
            S = q[2] + S
        else:
            S += q[2]
print(S)

Fixed submission:
from collections import deque

S = input()
Q = int(input())
d = deque()
for i in S:
    d.append(i)
flag = True
for _ in range(Q):
    q = [i for i in input().split()]
    if int(q[0]) == 1:
        flag = not flag
    else:
        if (int(q[1]) == 1 and flag) or (int(q[1]) == 2 and not flag):
            d.appendleft(q[2])
        else:
            d.append(q[2])
S = ""
while(len(d)>0):
    if flag:
        S += d.popleft()
    else:
        S += d.pop()
print(S)