Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
l,r = map(int, input().split())


a=l%2019
b=r%2019
ans=99999999
for i in range(a,b+1):
  for j in range(i+1,b+1):
  tmpans=(i*j)%2019
  if ans>tmpans:
    ans=tmpans
print(ans)
    


Fixed submission:
def baisuaru(l,r,m):
  if l//m < r//m:
    return True
  elif l%m==0:
    return True
  else:
    return False
    

l,r = map(int, input().split())


if baisuaru(l,r,2019):
  print(0)
else:
  if baisuaru(l,r,3) and baisuaru(l,r,673):
    print(0)
  else:
    a=l%2019
    b=r%2019
    ans=99999999
    for i in range(a,b+1):
      for j in range(i+1,b+1):
        tmpans=(i*j)%2019
        if ans>tmpans:
          ans=tmpans
    print(ans)
Buggy python submission (verdict: Runtime Error):
import math
mod =1000000000+7

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

def convcal(a,b):
  kekka = (math.factorial(a) //math.factorial(a-b)  ) // math.factorial(b) 
  return kekka

for i in range(1,k+1):
  #print(i)
  #print(k-1,i-1)
  #print(n-k-1,i)
  print(convcal(k-1,i-1)*convcal(n-k+1,i) % mod)


Fixed submission:
import math
mod =1000000000+7

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

def convcal(a,b):
  kekka = (math.factorial(a) //math.factorial(a-b)  ) // math.factorial(b) 
  return kekka

for i in range(1,k+1):
  #print(i)
  #print(k-1,i-1)
  #print(n-k+1,i)
  if n-k+1-i>=0:
    print(convcal(k-1,i-1)% mod * convcal(n-k+1,i) % mod)
  else:
    print(0)
Buggy python submission (verdict: Runtime Error):
n = int(input())

balls=[]
for i in range(n):
  x,y = map(int, input().split())
  balls.append([x,y])

balls.sort()  
sorted(balls, key=lambda x: x[1])

hyo={}

for i in range(n):
  for j in range(i+1,n):
    difx=balls[j][0]-balls[i][0]
    dify=balls[j][1]-balls[i][1]
    if (difx,dify) in hyo.keys():
      hyo[(difx,dify)] +=1
    else:
      hyo[(difx,dify)] =1

#print(hyo)
p,q=max(hyo,key=hyo.get)

chk=[1]*n

for i in range(n-1,-1,-1):
  x=balls[i][0]-p
  y=balls[i][1]-q
  if [x,y] in balls:
    chk[i]=0
#print(balls)
#print(chk)
print(sum(chk))


Fixed submission:
n = int(input())

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

balls=[]
for i in range(n):
  x,y = map(int, input().split())
  balls.append([x,y])

balls.sort()  
sorted(balls, key=lambda x: x[1])

hyo={}

for i in range(n):
  for j in range(i+1,n):
    difx=balls[j][0]-balls[i][0]
    dify=balls[j][1]-balls[i][1]
    if (difx,dify) in hyo.keys():
      hyo[(difx,dify)] +=1
    else:
      hyo[(difx,dify)] =1

#print(hyo)
p,q=max(hyo,key=hyo.get)

chk=[1]*n

for i in range(n-1,-1,-1):
  x=balls[i][0]-p
  y=balls[i][1]-q
  if [x,y] in balls:
    chk[i]=0
#print(balls)
#print(chk)
print(sum(chk))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a=list(map(int, input().split()))

tasug=[]
hikug=[]
for i in range(n):
  if a[i]<0:
    hikug.append(a[i])
  else:
    tasug.append(a[i])

if len(hikug)==0:
  tasug.sort()
  ans=sum(tasug)-2*tasug[0]
  print(ans)
  for i in range(len(tasug)-1):
    if i ==0:
      print(tasug[0],tasug[1])
      a=tasug[0]-tasug[i]
    elif i==1:
      continue
    else:
      print(a,tasug[i])
      a=a-tasug[i]
  if not n==2:
    print(tasug[len(tasug)-1],a)
  
  
elif len(tasug)==0:
  hikug.sort()
  ans=-sum(hikug)+2*hikug[n-1]
  print(ans)
  for i in range(n-1):
    if i ==0:
      a=hikug[n-1]

    print(a,hikug[i])
    a=a-hikug[i]

else:
  ans=sum(tasug)-sum(hikug)
  print(ans)
  for i in range(len(tasug)-1):
    if i ==0:
      print(hikug[0],tasug[i])
      a=hikug[0]-tasug[i]
    else:
      print(a,tasug[i])
      a=a-tasug[i]

  print(tasug[len(tasug)-1],a)
  a=tasug[len(tasug)-1]-a

  for i in range(1,len(hikug)):
    print(a,hikug[i])
    a=a-hikug[i]


  
  
  

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

tasug=[]
hikug=[]
for i in range(n):
  if a[i]<0:
    hikug.append(a[i])
  else:
    tasug.append(a[i])

if len(hikug)==0:
  tasug.sort()
  ans=sum(tasug)-2*tasug[0]
  print(ans)
  for i in range(len(tasug)-1):
    if i ==0:
      print(tasug[0],tasug[1])
      a=tasug[0]-tasug[i]
    elif i==1:
      continue
    else:
      print(a,tasug[i])
      a=a-tasug[i]
  if not n==2:
    print(tasug[len(tasug)-1],a)
  
  
elif len(tasug)==0:
  hikug.sort()
  ans=-sum(hikug)+2*hikug[n-1]
  print(ans)
  for i in range(n-1):
    if i ==0:
      a=hikug[n-1]

    print(a,hikug[i])
    a=a-hikug[i]

else:
  ans=sum(tasug)-sum(hikug)
  print(ans)
  if len(tasug)==1:
    for i in range(len(hikug)):
      if i ==0:
        print(tasug[0],hikug[i])
        a=tasug[0]-hikug[i]
      else:
        print(a,hikug[i])
        a=a-hikug[i]
  else:
    for i in range(len(tasug)-1):
      if i ==0:
        print(hikug[0],tasug[i])
        a=hikug[0]-tasug[i]
      else:
        print(a,tasug[i])
        a=a-tasug[i]

    print(tasug[len(tasug)-1],a)
    a=tasug[len(tasug)-1]-a
  
    for i in range(1,len(hikug)):
      print(a,hikug[i])
      a=a-hikug[i]
Buggy python submission (verdict: Time Limit Exceeded):
import copy

s="Z"
s+=input()
len_s=len(s)

def work(s,totalnum):
  new_s=["Z"]
  num=0
  skipnum=0
  for i in range(1,len_s):
    #print(i,s,new_s)
    if skipnum>0:
      skipnum-=1
      continue

    if i<=len_s-3:
      if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
        new_s.append("B")
        new_s.append("C")
        new_s.append("A")
        num+=1
        skipnum+=2
      else:
        new_s.append(s[i])
    else:
        new_s.append(s[i])

  totalnum+=num
  #print("d")
  #print(s,new_s)
  if num==0:
    return totalnum
  else:
    return work(new_s,totalnum)

print(work(s,0))

Fixed submission:
s=input()
t=s.replace("BC","D")
a=0
ans=0
for i in t:
  if i=="A":
    a+=1
  elif i=="D":
    ans+=a
  else:
    a=0

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import copy

s="Z"
s+=input()
len_s=len(s)

def work(s,totalnum):
  new_s=["Z"]
  num=0
  skipnum=0
  for i in range(1,len_s):
    #print(i,s,new_s)
    if skipnum>0:
      skipnum-=1
      continue

    if i<=len_s-3:
      if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
        new_s.append("B")
        new_s.append("C")
        new_s.append("A")
        num+=1
        skipnum+=2
      else:
        new_s.append(s[i])
    else:
        new_s.append(s[i])

  totalnum+=num
  #print("d")
  #print(s,new_s)
  if num==0:
    return totalnum
  else:
    return work(new_s,totalnum)

print(work(s,0))

Fixed submission:
s=input()
t=s.replace("BC","D")
a=0
ans=0
for i in t:
  if i=="A":
    a+=1
  elif i=="D":
    ans+=a
  else:
    a=0

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int, input().split())

maxr=N//R
maxg=N//G
maxb=N//B

ans=0
flg=0
for r in range(maxr,-1,-1):
  tmpb=0
  for g in range(maxg,-1,-1):
    for b in range(tmpb,maxb+1):
      if R*r+G*g+B*b==N:
        ans+=1
        tmpb=b
        break
print(ans)

Fixed submission:
R,G,B,N = map(int, input().split())

maxr=N//R
maxg=N//G

ans=0
for r in range(maxr,-1,-1):
  for g in range(maxg,-1,-1):
    if N-(r*R+g*G)>=0:
      if (N-(r*R+g*G))%B==0:
        ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int, input().split())

maxr=N//R
maxg=N//G
maxb=N//B

ans=0
flg=0
for i in range(maxr,-1,-1):
  for j in range(maxg,-1,-1):
    for k in range(maxb,-1,-1):
      if R*i+G*j+B*k==N:
        ans+=1
        break
print(ans)

Fixed submission:
R,G,B,N = map(int, input().split())

maxr=N//R
maxg=N//G

ans=0
for r in range(maxr,-1,-1):
  for g in range(maxg,-1,-1):
    if N-(r*R+g*G)>=0:
      if (N-(r*R+g*G))%B==0:
        ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int, input().split())

maxr=N//R
maxg=N//G
maxb=N//B

ans=0
for i in range(maxr+1):
  for j in range(maxg+1):
    for k in range(maxb+1):
      if R*i+G*j+B*k==N:
        ans+=1
print(ans)

Fixed submission:
R,G,B,N = map(int, input().split())

maxr=N//R
maxg=N//G

ans=0
for r in range(maxr,-1,-1):
  for g in range(maxg,-1,-1):
    if N-(r*R+g*G)>=0:
      if (N-(r*R+g*G))%B==0:
        ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int, input().split())

S = list(input())

ansList=[]
for i in range(N-1):
  if S[i] =="A" and S[i+1] =="C":
      ansList.append(1)
  else:
    ansList.append(0)

for i in range(Q):
  l,r = map(int, input().split())
  print(sum(ansList[l-1:r-1]))


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

S = list(input())

ansList=[0]
ans=0
for i in range(N-1):
  if S[i] =="A" and S[i+1] =="C":
      ans+=1
      ansList.append(ans)
  else:
    ansList.append(ans)

for i in range(Q):
  l,r = map(int, input().split())
  print(ansList[r-1]-ansList[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
mod = 10**9+7
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)

if len(a) != len(set(a)) or len(b) != len(set(b)):
    print(0)
    exit()

#a = set(a)
#b = set(b)

c = 1
N = 0
M = 0
for k in range(n*m, 0, -1):
    if k in a and k in b:
        N += 1
        M += 1
    elif k in a:
        c *= M
        N += 1
    elif k in b:
        c *= N
        M += 1
    else:
        c *= M*N - (m*n-k)
    c %= mod

print(c)


Fixed submission:
mod = 10**9+7
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)

if len(a) != len(set(a)) or len(b) != len(set(b)):
    print(0)
    exit()

a = set(a)
b = set(b)

c = 1
N = 0
M = 0
for k in range(n*m, 0, -1):
    if k in a and k in b:
        N += 1
        M += 1
    elif k in a:
        c *= M
        N += 1
    elif k in b:
        c *= N
        M += 1
    else:
        c *= M*N - (m*n-k)
    c %= mod

print(c)
Buggy python submission (verdict: Runtime Error):
n,p=map(int,input().split())

if n==1:
  print(p)
else:
  ans=1
  for i in range(1,int(p**(1/n))+2):
    tmp=i**n
    if (p>=tmp) and (p%tmp == 0):
     ans=i
    if(p<tmp):
      break
  print(ans)


Fixed submission:
n=input()

ans=0
for i in range(len(n)):
  if n[i]=="2":
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
s=list(input())

ima=0
wNum=0
for i in range(len(s)):
  if s[i]=="W":
    ima += i
    wNum += 1

def kasan(n):
  if n==0:
    return 0
  else:
    return kasan(n-1) + n
if wNum==0:
  print(0)
else:
  saigo = kasan(wNum-1)
  print(ima-saigo)

Fixed submission:
s=list(input())

ima=0
wNum=0
for i in range(len(s)):
  if s[i]=="W":
    ima += i
    wNum += 1

def kasan(n):
  if n==0:
    return 0
  else:
    return kasan(n-1) + n

saigo = ((wNum-1)+0)*wNum//2
print(ima-saigo)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
hList=[]
for i in range(n):
  hList.append(int(input()))
hList.sort()
//print(hList)
ans=100000000000000
for i in range(n-k+1):
  tmp=hList[i+k-1]-hList[i]
  if(ans>tmp):
    ans=tmp
print(ans)


Fixed submission:
n,k=map(int,input().split())
hList=[]
for i in range(n):
  hList.append(int(input()))
hList.sort()
#print(hList)
ans=100000000000000
for i in range(n-k+1):
  tmp=hList[i+k-1]-hList[i]
  if(ans>tmp):
    ans=tmp
print(ans)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
hList=[]
for i in range(n):
  hList.append(int(input()))
hList.sort()
//print(hList)
ans=100000000000000
for i in range(n-k+1):
  tmp=hList[i+k-1]-hList[i]
  if(ans>tmp):
    ans=tmp
print(ans)

Fixed submission:
n,k=map(int,input().split())
hList=[]
for i in range(n):
  hList.append(int(input()))
hList.sort()
#print(hList)
ans=100000000000000
for i in range(n-k+1):
  tmp=hList[i+k-1]-hList[i]
  if(ans>tmp):
    ans=tmp
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

n,m = map(int, input().split())

x=int(math.sqrt(m))

ans=1
for i in range(1,x+1):
  if i*n<=m:
    if i <= y:
      ans=max(ans,i)
    if (m/i)*n<=m:
      ans=max(ans,m/i)
print(ans)




Fixed submission:
import math

n,m = map(int, input().split())

x=int(math.sqrt(m))

ans=1
for i in range(1,x+1):
  if m%i==0:
    if i*n<=m:
      ans=max(ans,i)
    if int(m/i)*n<=m:
      ans=max(ans,int(m/i))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n,m = map(int, input().split())

amari=m % n
x=int((m-amari)/n)

aaa=np.mod(m,range(1,x+1))
#print(aaa)
index=np.where(aaa==0)
print(index[0][-1]+1)


Fixed submission:
import math

n,m = map(int, input().split())

x=int(math.sqrt(m))

ans=1
for i in range(1,x+1):
  if m%i==0:
    if i*n<=m:
      ans=max(ans,i)
    if int(m/i)*n<=m:
      ans=max(ans,int(m/i))
print(ans)

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

amari=m % n
x=int((m-amari)/n)

ans=1
for i in range(1,x+1):
  if(m % i==0):
    ans=i
    
print(ans)


Fixed submission:
import math

n,m = map(int, input().split())

x=int(math.sqrt(m))

ans=1
for i in range(1,x+1):
  if m%i==0:
    if i*n<=m:
      ans=max(ans,i)
    if int(m/i)*n<=m:
      ans=max(ans,int(m/i))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math

n,m = map(int, input().split())

x=math.floor(m/n)

ans=[]
for i in range(1,x+1):
  if(m % i==0):
    ans.append(i)
    
print(ans[-1])

Fixed submission:
import math

n,m = map(int, input().split())

x=int(math.sqrt(m))

ans=1
for i in range(1,x+1):
  if m%i==0:
    if i*n<=m:
      ans=max(ans,i)
    if int(m/i)*n<=m:
      ans=max(ans,int(m/i))
print(ans)

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

n,m = map(int, input().split())

x=math.floor(m/n)

ans=[]
for i in range(2,x+1):
  if(m % i==0):
    ans.append(i)

ans.sort()
ans.reverse()
print(ans[0])

Fixed submission:
import math

n,m = map(int, input().split())

x=int(math.sqrt(m))

ans=1
for i in range(1,x+1):
  if m%i==0:
    if i*n<=m:
      ans=max(ans,i)
    if int(m/i)*n<=m:
      ans=max(ans,int(m/i))
print(ans)
Buggy python submission (verdict: Runtime Error):
import collections


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

gusuList=[]
kisuList=[]

for i in range(n):
  if(i % 2==0):
    gusuList.append(vList[i])
  else:
    kisuList.append(vList[i])
#print(gusuList)
#print(kisuList)

g = collections.Counter(gusuList)
gStatus=g.most_common()

k = collections.Counter(kisuList)
kStatus=k.most_common()

ans=-100

if(not gStatus[0][0]==kStatus[0][0]):
    ans=(n/2-gStatus[0][1])+(n/2-kStatus[0][1])
else:
  if(gStatus[0][1]>kStatus[0][1]):
    if(not len(kStatus)==1):
      ans=(n/2-gStatus[0][1])+(n/2-kStatus[1][1])
    else:
      ans=(n/2-gStatus[0][1])+n/2
  elif(gStatus[0][1]<kStatus[0][1]):
    if(not len(gStatus)==1):
      ans=(n/2-gStatus[1][1])+(n/2-kStatus[0][1])
    else:
      ans=n/2+(n/2-kStatus[0][1])
  elif(gStatus[0][1]==kStatus[0][1]):
      if(gStatus[1][1]>=kStatus[1][1]):
        if(not len(kStatus)==2):
          ans=(n/2-gStatus[0][1])+(n/2-kStatus[2][1])
        else:
          ans=(n/2-gStatus[0][1])+(n/2-kStatus[1][1])
      elif(gStatus[0][1]<kStatus[0][1]):
        if(not len(gStatus)==2):
          ans=(n/2-gStatus[2][1])+(n/2-kStatus[0][1])
        else:
          ans=(n/2-gStatus[1][1])+(n/2-kStatus[0][1])
      
    
    
print(int(ans))


Fixed submission:
import collections

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

gusuList=[]
kisuList=[]

for i in range(n):
  if(i % 2==0):
    gusuList.append(vList[i])
  else:
    kisuList.append(vList[i])
#print(gusuList)
#print(kisuList)

g = collections.Counter(gusuList)
gStatus=g.most_common()

k = collections.Counter(kisuList)
kStatus=k.most_common()

ans=-100
if(not gStatus[0][0]==kStatus[0][0]):
    ans=(n/2-gStatus[0][1])+(n/2-kStatus[0][1])
else:
    ans1=-101
    ans2=-102
    if(not len(kStatus)==1):
      ans1=(n/2-gStatus[0][1])+(n/2-kStatus[1][1])
    else:
      ans1=(n/2-gStatus[0][1])+n/2

    if(not len(gStatus)==1):
      ans2=(n/2-gStatus[1][1])+(n/2-kStatus[0][1])
    else:
      ans2=n/2+(n/2-kStatus[0][1])

    ans=min(ans1,ans2)

print(int(ans))
Buggy python submission (verdict: Runtime Error):
a, b= map(int, [input() for i in range(2)])

if a<=8 and b=<8:
    print("Yay!")
else:
    print(":(")

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

if a<=8 and b<=8:
    print("Yay!")
else:
    print(":(")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

t_prev,a_prev=map(int,input().split())
for i in range(n-1):
  t,a=map(int,input().split())
  i=1
  t_now=t
  a_now=a
  
  while not (t_prev<=t_now and a_prev<=a_now):
    t_now=t*i
    a_now=a*i
    i+=1
    
  t_prev=t_now
  a_prev=a_now

print(t_prev+a_prev)

Fixed submission:
import math

n=int(input())

t_prev,a_prev=1,1
for i in range(n):
  t,a=map(int,input().split())
  #n_koho1=math.ceil(t_prev/t)
  #n_koho2=math.ceil(a_prev/a)

  n_koho1 = t_prev // t
  n_koho2 = a_prev // a
  if t_prev % t != 0:
      n_koho1 += 1
  if a_prev % a != 0:
      n_koho2 += 1
        
  n=max(n_koho1,n_koho2)
  t=n*t
  a=n*a
    
  t_prev=t
  a_prev=a

print(t_prev+a_prev)
Buggy python submission (verdict: Runtime Error):
N = int(input())
chr_num = 0
list_26 = [26 ** i for i in range(1, 12)]
for i in range(1, 12):
    if (N - sum(list_26[:i - 1])) // (26 ** i) == 0 or \
       ((N - sum(list_26[:i - 1])) == (26 ** i)):
        chr_num = i
        break
for j in range(chr_num):
    if j == 0:
        print(chr(((N - sum(list_26[:chr_num - 1])) % 26) + 96), end='')
    else:
        print(chr(((N - sum(list_26[:j])) // 26) + 97))
print()


Fixed submission:
def main():
    N = int(input())
    A = [1]
    ret = []
    for _ in range(100):
        A.append(A[-1] * 26)
    for n in range(1, 100):
        # Nは何文字の番号か調べる
        if N > A[n]:
            N -= A[n]
            continue
        N -= 1
        for _ in range(n):
            N, r = divmod(N, 26)
            ret.append(r)
        break
    ret = [chr(ord('a') + x) for x in ret]
    return ''.join(reversed(ret))


print(main())
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
answer = 1
for i in range(N):
    answer *= A[i]
print(answer if answer <= 10 ** 18 else -1)


Fixed submission:
N = int(input())
A = sorted(list(map(int, input().split())))
if A[0] == 0:
    print(0)
    exit()
answer = 1
for i in A:
    answer *= i
    if answer > 10 ** 18:
        print(-1)
        break
else:
    print(answer)
Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())
flg = True
for i in range(2 * max(A, C) + 1):
    if i % 2 == 0:
        C -= B
        print('C: ', C)
        if C <= 0:
            flg = False
            print('Yes')
    else:
        A -= D
        if A <= 0:
            flg = False
            print('No')
    if not flg:
        break


Fixed submission:
S, W = map(int, input().split())
if W >= S:
    print('unsafe')
else:
    print('safe')
Buggy python submission (verdict: Runtime Error):
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
permutation = list(itertools.permutations([x for x in range(1, N + 1)]))

a = permutation.index(P) + 1
b = permutation.index(Q) + 1
print(abs(a - b))


Fixed submission:
K, X = map(int, input().split())
print('Yes' if K * 500 >= X else 'No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

ans = 0

for i in range(1000):
    t = str(i).zfill(3)
    t_index = 0
    for s_index in range(N):
        if S[s_index] == t[t_index]:
            t_index += 1
            if t_index == 3:
                break
    if t_index == 3:
        ans += 1
print(ans)


Fixed submission:
N = int(input())
S = tuple(map(int, input()))

ans = 0

for i in range(10):
    if i in S[:N - 2]:
        i_index = S.index(i)
        for j in range(10):
            if j in S[i_index + 1: N - 1]:
                j_index = i_index + S[i_index + 1: N - 1].index(j) + 1
                for k in range(10):
                    if k in S[j_index + 1:]:
                        ans += 1
print(ans)

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

ans = 0

for i in range(1000):
    t = str(i).zfill(3)
    t_index = 0
    for s_index in range(N):
        if S[s_index] == t[t_index]:
            t_index += 1
            if t_index == 3:
                break
        if t_index == 3:
            ans += 1
print(ans)


Fixed submission:
N = int(input())
S = tuple(map(int, input()))

ans = 0

for i in range(10):
    if i in S[:N - 2]:
        i_index = S.index(i)
        for j in range(10):
            if j in S[i_index + 1: N - 1]:
                j_index = i_index + S[i_index + 1: N - 1].index(j) + 1
                for k in range(10):
                    if k in S[j_index + 1:]:
                        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

for i in range(N):
    temp = A[:i] + A[i + 1:]
    print(max(temp))


Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
sorted_A = sorted(A)
[print(sorted_A[-2] if sorted_A[-1] == A[i] else sorted_A[-1]) for i in range(N)]
Buggy python submission (verdict: Runtime Error):
S = input()
if S[0] == S[1] and S[2] == S[3] and len(set(S)) == 2:
    print('Yes')
elif S[0] == S[2] and S[1] == S[4] and len(set(S)) == 2:
    print('Yes')
elif S[0] == S[3] and S[1] == S[2] and len(set(S)) == 2:
    print('Yes')
else:
    print('No')


Fixed submission:
S = input()
if S[0] == S[1] and S[2] == S[3] and len(set(S)) == 2:
    print('Yes')
elif S[0] == S[2] and S[1] == S[3] and len(set(S)) == 2:
    print('Yes')
elif S[0] == S[3] and S[1] == S[2] and len(set(S)) == 2:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
answer = 0
cooking_time_order = sorted([A, B, C, D, E], key=lambda x: 10 - (x % 10))
for _ in range(5):
    if cooking_time_order[-1] % 10 == 0:
        answer += cooking_time_order[-1]
        cooking_time_order.pop()
    else:
        break
for cooking_time in cooking_time_order[:-1]:
    answer += (cooking_time + (10 - (cooking_time % 10)))
answer += (cooking_time_order[-1])
print(answer)


Fixed submission:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
answer = 0
cooking_time_order = sorted([A, B, C, D, E], key=lambda x: 10 - (x % 10))
for _ in range(5):
    if cooking_time_order[-1] % 10 == 0:
        answer += cooking_time_order[-1]
        cooking_time_order.pop()
    else:
        break
if len(cooking_time_order) == 0:
    pass
else:
    for cooking_time in cooking_time_order[:-1]:
        answer += (cooking_time + (10 - (cooking_time % 10)))
    answer += (cooking_time_order[-1])
print(answer)
Buggy python submission (verdict: Runtime Error):
N, T = map(int, input().split())
c_t = [list(map(int, input().split())) for _ in range(N)]
cost = 2_000_000
TLE_flg = True
for i in range(N):
    if c_t[i][1] <= T:
        cost = min(cost, c_t[i][0])
        TLE_flg = False
print('TLE' if TLE_flg else cost)


Fixed submission:
N, T = map(int, input().split())
c_t = [list(map(int, input().split())) for _ in range(N)]
cost = 2000000
TLE_flg = True
for i in range(N):
    if c_t[i][1] <= T:
        cost = min(cost, c_t[i][0])
        TLE_flg = False
print('TLE' if TLE_flg else cost)

Buggy python submission (verdict: Runtime Error):
N, T = map(int, input().split())
cost = 2_000_000
TLE_flg = True
for _ in range(N):
    c, t = map(int, input().split())
    if t <= T:
        cost = min(cost, c)
        TLE_flg = False
print('TLE' if TLE_flg else cost)


Fixed submission:
N, T = map(int, input().split())
c_t = [list(map(int, input().split())) for _ in range(N)]
cost = 2000000
TLE_flg = True
for i in range(N):
    if c_t[i][1] <= T:
        cost = min(cost, c_t[i][0])
        TLE_flg = False
print('TLE' if TLE_flg else cost)
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = [int(input()) for _ in range(N)]
ans = sum(s)
if ans % 10 != 0:
    print(ans)
else:
    for s_i in s:
        if s_i % 10 != 0:
            ans -= s_i
            print(ans)
            break
    else:
        print(0)


Fixed submission:
A, B = map(int, input().split())
if A + B >= 10:
    print('error')
else:
    print(A + B)