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

price = [int(input()) for i in range(N)]
price.sort()

total = sum(price)-price(-1)/2
print(int(total))

Fixed submission:
N= int(input())

price = [int(input()) for i in range(N)]

total = sum(price)-max(price)/2
print(int(total))
Buggy python submission (verdict: Runtime Error):
import collections

N = int(input())
li = list(map(int,input().split()))
even = [li[i] for i in range(N) if i%2==0]
odd =[ li[i] for i in range(N) if i%2!=0]

e = collections.Counter(even).most_common()
o = collections.Counter(odd).most_common()

ec=e[0][1]
oc=o[0][1]

if e[0][0]==o[0][0]:
  if e[0][1] > o[0][1]:
    oc=o[1][1]
  else:
    ec=e[1][1]
    
ans = N-(ec+oc)
print(ans)


Fixed submission:
from collections import Counter

ans = int(input())
V = [int(i) for i in input().split()]

v1 = []
v2 = []

for i, v in enumerate(V):
    if i % 2 == 0:
       v1.append(v)
    else:
        v2.append(v)

v1c = Counter(v1).most_common()
v2c = Counter(v2).most_common()

k1, v1 = v1c[0][0], v1c[0][1]
k2, v2 = v2c[0][0], v2c[0][1]

if k1 == k2:
    ans -= v2
    m = 0
    if len(v1c) >= 2:
        m = max(m, v1c[1][1])
    if len(v2c) >= 2:
        m = max(m, v2c[1][1])
    ans -= m
else:
    ans -= v1 + v2

print(ans)

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

N = int(input())
even = [input() for i in range(N) if i%2==0]
odd =[ input() for i in range(N) if i%2!=0]

e = collections.Counter(even)
o = collections.Counter(odd)

ec=e[0][1]
oc=o[0][1]

if e[0][0]==o[0][0]:
  if e[0][1] > o[0][1]:
    oc=o[1][1]
  else:
    ec=e[1][1]
    
ans = N-(ec+oc)
print(ans)

Fixed submission:
from collections import Counter

ans = int(input())
V = [int(i) for i in input().split()]

v1 = []
v2 = []

for i, v in enumerate(V):
    if i % 2 == 0:
       v1.append(v)
    else:
        v2.append(v)

v1c = Counter(v1).most_common()
v2c = Counter(v2).most_common()

k1, v1 = v1c[0][0], v1c[0][1]
k2, v2 = v2c[0][0], v2c[0][1]

if k1 == k2:
    ans -= v2
    m = 0
    if len(v1c) >= 2:
        m = max(m, v1c[1][1])
    if len(v2c) >= 2:
        m = max(m, v2c[1][1])
    ans -= m
else:
    ans -= v1 + v2

print(ans)
Buggy python submission (verdict: Runtime Error):
*a = map(int, input().split())

print(max(a)-min(a))

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

print(max(a)-min(a))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = 0
n = N

while n != 1:
  S += n % 10
  n //= 10
  
if N % S == 0:
  print("Yes")
else: print("No")


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

while n != 0:
  S += n % 10
  n //= 10
  
if N % S == 0:
  print("Yes")
else: print("No")

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

while n > 1:
  S += n % 10
  n //= 10
  
if N % S == 0:
  print("Yes")
else: print("No")

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

while n != 0:
  S += n % 10
  n //= 10
  
if N % S == 0:
  print("Yes")
else: print("No")
Buggy python submission (verdict: Runtime Error):
A,B,C,D = [int(input) for _ in range(4)]

print(min(A,B)+min(C,D))


Fixed submission:
A,B,C,D = [int(input()) for _ in range(4)]

print(min(A,B)+min(C,D))

Buggy python submission (verdict: Runtime Error):
A,B,C,D = [int(input) for _ in range(4)]

print(min(A,B)+min(C,D)


Fixed submission:
A,B,C,D = [int(input()) for _ in range(4)]

print(min(A,B)+min(C,D))
Buggy python submission (verdict: Runtime Error):
s = [input() for _ in range(int(input))]
t = [input() for _ in range(int(input))]

l = list(set(s))

print(max(0, max(s.count(l[i]) - t.count(l[i]) for i in range(len(l)))))

Fixed submission:
s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(input()))]

l = list(set(s))

print(max(0, max(s.count(l[i]) - t.count(l[i]) for i in range(len(l)))))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = int(input())

amari =　N % 500

if ( A >= amari):
    print("Yes")
else:
    print("No")

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

if (N >= 500):
    amari = N % 500
    if ( A >= amari):
        print("Yes")
    else:
        print("No")

else:
    if ( A >= N):
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
N= int(input())
num = list()

for i in range(0,N-1):
  d = int(input())
  num[d] = 1
  
res = 0
for i in range (0,101):
  res += num[i]
  
print(res)
  



Fixed submission:
N = int(input())
num = list()

for i in range (N):
  d = int (input())
  num.append(d)
  
print(len(set(num)))

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

for i in range(0,N-1):
  d = int(input())
  num[d] = 1
  
res = 0
for i in range (0,N-1):
  res += num[i]
  
print(res)
  



Fixed submission:
N = int(input())
num = list()

for i in range (N):
  d = int (input())
  num.append(d)
  
print(len(set(num)))
Buggy python submission (verdict: Runtime Error):
N , A , B = map(int, input().split())
res = 0

for i in range(N):
  temp = 0
  
  while (a >= 10):
  
  	temp += i % 10
  	a = i // 10
  temp += a
  
  if (temp >= A and temp <= B):
    res += temp
    
print(res)

Fixed submission:
def findSUM(n):
    sum = 0
    while (n > 0):
        sum += n % 10
        n //= 10
    return sum

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

total = 0
for i in range(N+1):
    sum = findSUM(i)
    if (sum >= A and sum <= B):
        total += i

print(total)
Buggy python submission (verdict: Runtime Error):
N = int(input())
num = list(map(int,input().split()))

ans=0
while all(a%2==0 for a in A):
  A = [a/2 for a in A]
  ans+=1
  
print(ans)


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

ans=0
while all(a%2==0 for a in A):
  A = [a/2 for a in A]
  ans+=1
  
print(ans)

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

ans=0
while all(a%2==0 for a in A):
  A = [a/2 for a in A]
  ans+=1
  
print(ans)

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

ans=0
while all(a%2==0 for a in A):
  A = [a/2 for a in A]
  ans+=1
  
print(ans)
Buggy python submission (verdict: Runtime Error):
def findSUM(n):
  sum = 0
  while( n > 0 ):
    sum += n % 10
    n //= 10
  return sum

N = int(input().split())

f = findSUM(N)
if (N % f == 0):
  print("Yes")
else:
  print("No")

Fixed submission:
def findSUM(n):
  sum = 0
  while( n > 0 ):
    sum += n % 10
    n //= 10
  return sum

N = int(input())

f = findSUM(N)
if (N % f == 0):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
s = input()

print({}{}{}).format(s[0],len(s)-2,s[-1])

Fixed submission:
s = input()

a = s[0]
b = str(len(s) -2)
c = s[-1]

ans = [a,b,c]
res = "".join(ans)
print(res)
Buggy python submission (verdict: Runtime Error):
rgb = int(input())

if (rgb % 4 == 0):
    print("YES")
else:
    print("NO")

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

rgb = 100*r + 10*g + b

if (rgb % 4 == 0):
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
k, s = map(int, input().split())

ans = 0
num = max(k, s)

for i in range(num+1):
  for j in range(num+1):
    res = S - (i+j)
    if res >= 0:
      ans += res+1
      
print(ans)

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

ans=[1 for x in range(K+1) for y in range(K+1) if 0<=S-x-y <= K]

print(len(ans))

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

ans=[1 for x in (K+1) for y in (K+1) if 0<=S-x-y <= K]

print(len(ans))


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

ans=[1 for x in range(K+1) for y in range(K+1) if 0<=S-x-y <= K]

print(len(ans))

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

ans=[1 for x in (K+1) for y in (K+1) if K-x-y <= K]

print(len(ans))

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

ans=[1 for x in range(K+1) for y in range(K+1) if 0<=S-x-y <= K]

print(len(ans))
Buggy python submission (verdict: Runtime Error):
s = list(input())
ans=[]

for i in s:
  if i == "0":
    ans.append("0")
  elif i == "1":
    ans.append("1")
  else:
    ans.pop()
    
print(ans,sep ="")

Fixed submission:
s = list(input())
ans=[]

for i in s:
  if i == "0":
    ans.append("0")
  elif i == "1":
    ans.append("1")
  else:
    if len(ans) == 0: continue
    else: ans.pop()
    
print(*ans,sep ="")
Buggy python submission (verdict: Runtime Error):
def cul(li,s):
  for i in li:
    a += (i - s)^2
  return a

N = int(input())
li = list(map(int,input().split()))

s1 = sum(li)//len(li)
s2 = s1 + 1

ans1 = cul(li,s1)
ans2 = cul(li,s2)

print(min(ans1,ans2))

Fixed submission:
def cul(li,s):
  a = 0
  for i in li:
    a += (i - s)**2
  
  return a

N = int(input())
li = list(map(int,input().split()))

s1 = sum(li)//len(li)
s2 = s1 + 1

ans1 = cul(li,s1)
ans2 = cul(li,s2)

print(min(ans1,ans2))
Buggy python submission (verdict: Runtime Error):
N,L = map(str,input().split())

words = list()
for i in range(N):
  words.append(input())
  
words.sort()

print(*words,sep ="")


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

words = list()
for i in range(N):
  words.append(input())
  
words.sort()

print(*words,sep ="")

Buggy python submission (verdict: Runtime Error):
N,L = map(str,input().split())

words = list()
for i in range(N):
  words.append(input())
  
words = words.sort()

print(*words,sep ="")


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

words = list()
for i in range(N):
  words.append(input())
  
words.sort()

print(*words,sep ="")

Buggy python submission (verdict: Runtime Error):
N,L = map(str,input().split())

words = list()
for i in range(N):
  words.append(input())
  
words.sort()

print(*words,seq ="")


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

words = list()
for i in range(N):
  words.append(input())
  
words.sort()

print(*words,sep ="")

Buggy python submission (verdict: Runtime Error):
N,L = map(str,input().split())

words = list()
for i in range(N):
  words.append(input())
  
words = words.sort()

print(*words,seq ="")

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

words = list()
for i in range(N):
  words.append(input())
  
words.sort()

print(*words,sep ="")
Buggy python submission (verdict: Time Limit Exceeded):
n=input()
x=1
for i in map(int,input().split()):
  x*=i
if x>10**18:
  print(-1) 
else:
  print(x)

Fixed submission:
input()
x=1
l=sorted(map(int,input().split()))
for i in l:
  if i==0:
    print(0)
    break
  x*=i
  if x>10**18:
    print(-1)
    break
else:
  if x>10**18:
    print(-1)
  else:
    print(x)
Buggy python submission (verdict: Runtime Error):
from sys import stdin as s
n,m=map(int,s.readline().split())
l=[0]*n
wa=[0]*n
cor,pen=0
for i in range(m):
  x,y=s.readline().split()
  x=int(x)-1
  if y=="AC":
    l[x]=1
  elif not l[x]:
    wa[x]+=1
for i in range(n):
  if l[i]:
    cor+=1
    pen+=wa[i]
print(cor,pen)

Fixed submission:
from sys import stdin as s
n,m=map(int,s.readline().split())
l=[0]*n
wa=[0]*n
cor,pen=0,0
for i in range(m):
  x,y=s.readline().split()
  x=int(x)-1
  if y=="AC":
    l[x]=1
  elif not l[x]:
    wa[x]+=1
for i in range(n):
  if l[i]:
    cor+=1
    pen+=wa[i]
print(cor,pen)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=map(int,input().split())
for i in range(k):
  if a>0:
    a-=1
  elif b>0:
    b-=1
print(a,b)

Fixed submission:
a,b,k=map(int,input().split())
if a>=k:
  print(a-k,b)
elif a+b>=k:
  print(0,b+a-k)
else:
  print(0,0)
Buggy python submission (verdict: Runtime Error):
n=int(input())
t=tuple(map(int,input().split()))
while True:
  if t[0]!=0:
    print(0)
    break
  m=max(t)
  a=tuple(t.count(i) for i in range(m+1))
  if a[0]!=1:
    print(0)
    break
  s=1
  for i in range(m):
    s=(s*(a[i]**a[i+1]))%998244353
  print(s)
  break

Fixed submission:
n=int(input())
print((n-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
t=tuple(map(int,input().split()))
while True:
  if t[0]!=0:
    print(0)
    break
  m=max(t)
  a=tuple(t.count(i) for i in range(m+1))
  if a[0]!=1:
    print(0)
    break
  s=1
  for i in range(m):
    s=(s*(a[i]**a[i+1]))%998244353
  print(s)
  break

Fixed submission:
n=int(input())
t=tuple(map(int,input().split()))
while True:
  if t[0]!=0:
    print(0)
    break
  m=max(t)
  a=[0]*(m+1)
  for i in range(n):
    a[t[i]]+=1
  a=tuple(a)
  if a[0]!=1:
    print(0)
    break
  s=1
  for i in range(m):
    s=(s*(a[i]**a[i+1]))%998244353
  print(s)
  break
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
d={i:l.count(i) for i in set(l)}
t=tuple(l.keys())
m=len(t)
T=0
for i in range(m-2):
  a=t[i]
  for j in range(m-i-1):
    b=t[i+j+1]
    for k in range(m-i-j-2):
      c=t[i+j+k+2]
      if a<b+c and b<c+a and c<a+b:
        T+=d{a}*d{b}*d{c}
print(T)

Fixed submission:
l = list(map(int, input().split()))
a = l[0]
b = l[1]
s = a - 2*b
if s < 0:
  print(0)
else:
  print(s)

Buggy python submission (verdict: Runtime Error):
n = int(input())
t = tuple(map(int, input().split()))
T = 0
for i in range(n-2):
  a = t[i]
  for j in range(n-i-1):
    b = t[i+j+1]
    for k in range(n-i-j-2):
      c = t[i+j+k+2]
      m = max(a,b,c)
      if m < a+b+c-m :
        T += 1
print(T)

Fixed submission:
l = list(map(int, input().split()))
a = l[0]
b = l[1]
s = a - 2*b
if s < 0:
  print(0)
else:
  print(s)
Buggy python submission (verdict: Runtime Error):
N, A = int(input()), list(map(int, input().split()))
X=[]
for i in range(1, N+1):
  P = A.index(i) + 1
  X.append(P)
print(' '.join([str(x) for x in X]))

Fixed submission:
a = int(input())
if a % 2 == 0:
  print(a/(2*a))
else:
  print((a+1)/(2*a))

Buggy python submission (verdict: Runtime Error):
N, A = int(input()), list(map(int, input().split()))
X = []
for i in range(N):
	P = -1
	for j in range(N):
		if (P == -1 or A[j] > A[P]): P = j
	X.append(P + 1)
	A[P] = 0
X.reverse()
print(' '.join([str(x) for x in X]))

Fixed submission:
a = int(input())
if a % 2 == 0:
  print(a/(2*a))
else:
  print((a+1)/(2*a))

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
X = list(input().split())
X = list(map(int, X))
a = 0
for i in range(N):
  if X[i] >= K:
    a += 1
  else:
    a += 0
print(a)

Fixed submission:
a = int(input())
if a % 2 == 0:
  print(a/(2*a))
else:
  print((a+1)/(2*a))
Buggy python submission (verdict: Runtime Error):
WeatherToady = input()
if WeatherToday == "Sunny":
  print("Cloudy")
elif WeatherToday == "Cloudy":
  print("Rainy")
else:
  print("Sunny")


Fixed submission:
WeatherToday = input()
if WeatherToday == "Sunny":
  print("Cloudy")
elif WeatherToday == "Cloudy":
  print("Rainy")
else:
  print("Sunny")

Buggy python submission (verdict: Runtime Error):
WeatherToady = input("")
if WeatherToday == "Sunny":
  return "Cloudy"
elif WeatherToday == "Cloudy":
  return "Rainy"
else:
  return "Sunny"


Fixed submission:
WeatherToday = input()
if WeatherToday == "Sunny":
  print("Cloudy")
elif WeatherToday == "Cloudy":
  print("Rainy")
else:
  print("Sunny")

Buggy python submission (verdict: Runtime Error):
WeatherToady = input()
if WeatherToday == "Sunny":
  return "Cloudy"
elif WeatherToday == "Cloudy":
  return "Rainy"
else:
  return "Sunny"


Fixed submission:
WeatherToday = input()
if WeatherToday == "Sunny":
  print("Cloudy")
elif WeatherToday == "Cloudy":
  print("Rainy")
else:
  print("Sunny")

Buggy python submission (verdict: Runtime Error):
WeatherToady = input()
if WeatherToday == "Sunny":
  return("Cloudy")
elif WeatherToday == "Cloudy":
  return("Rainy")
else:
  return("Sunny")

Fixed submission:
WeatherToday = input()
if WeatherToday == "Sunny":
  print("Cloudy")
elif WeatherToday == "Cloudy":
  print("Rainy")
else:
  print("Sunny")
Buggy python submission (verdict: Runtime Error):
A = input()
B = input()
x = 0
for i in range(3):
  if a(i) == b(i):
    x += 1
print(x)

Fixed submission:
A = input()
B = input()
x = 0
for i in range(3):
  if A[i] == B[i]:
    x += 1
print(x)
Buggy python submission (verdict: Runtime Error):
a, b = int(input().split())
print(max(a+b, a-b, a*b))

Fixed submission:
a, b = map(int, input().split())
print(max(a+b, a-b, a*b))

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
print(max(a+b, a-b, a*b))

Fixed submission:
a, b = map(int, input().split())
print(max(a+b, a-b, a*b))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
arr=input()
prod=1
k=1;
l=list(map(int,arr.split(' ')))
for x in l:
    if(x==0):
        prod=0
        if(k==0):
            continue
    prod*=x
    if(prod>1000000000000000000):
        k=0
        prod=-1

    
print(prod)


Fixed submission:
n=int(input())
arr=input()
prod=1
k=1;
l=list(map(int,arr.split(' ')))
#l.sort()

for x in l:
    if(x==0):
        k=0
        break

if(k==0):
    print(0)
else:
    for x in l:
        prod*=x
        if(prod>1000000000000000000):
            prod=-1
            break
    print(prod)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
arr=input()
prod=1
k=1;
l=list(map(int,arr.split(' ')))
for x in l:
    if(x==0):
        prod=0
        if(k==0):
            continue
    prod*=x
    if(prod>1000000000000000000):
        k=0
        prod=-1

    
print(prod)


Fixed submission:
n=int(input())
arr=input()
prod=1
k=1;
l=list(map(int,arr.split(' ')))
#l.sort()

for x in l:
    if(x==0):
        k=0
        break

if(k==0):
    print(0)
else:
    for x in l:
        prod*=x
        if(prod>1000000000000000000):
            prod=-1
            break
    print(prod)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
arr=input()
prod=1
l=list(map(int,arr.split(' ')))
for x in l:
    prod*=x
    
if(prod>1000000000000000000):
    print(-1)
else:
    print(prod)




Fixed submission:
n=int(input())
arr=input()
prod=1
k=1;
l=list(map(int,arr.split(' ')))
#l.sort()

for x in l:
    if(x==0):
        k=0
        break

if(k==0):
    print(0)
else:
    for x in l:
        prod*=x
        if(prod>1000000000000000000):
            prod=-1
            break
    print(prod)
Buggy python submission (verdict: Runtime Error):
c = input()
print('A' if ord('A') <= ord(A) <= ord('Z') else 'a')

Fixed submission:
print('A' if ord('A') <= ord(input()) <= ord('Z') else 'a')
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split())).sort()
print(sum(a[:k]))

Fixed submission:
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
print(sum(a[:k]))

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
sorted(a)
print(sum(a[:k])

Fixed submission:
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
print(sum(a[:k]))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = [int(i) for i in input().split()]

L.sort()
ans = 0
mem_k = 2
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(mem_k, N):
            if L[k] >= L[i] + L[j]:
                ans -= 1
                break
        ans += k - j
        mem_k = max(k, j+1)
    mem_k = i + 2

print(ans)



Fixed submission:
N = int(input())
L = [int(i) for i in input().split()]

L.sort()
ans = 0
mem_k = 2
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(mem_k, N):
            if L[k] >= L[i] + L[j]:
                ans -= 1
                break
        ans += k - j
        mem_k = max(k, j+1)
    mem_k = i + 2

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = [int(i) for i in input().split()]

A = sorted(A, reverse=True)

for _ in range(M):
    A[0] = A[0] / 2
    A = sorted(A, reverse=True)

ans = 0
for a in A:
    ans += int(a)

print(ans)


Fixed submission:
import heapq

N, M = map(int, input().split())
A = [-int(i) for i in input().split()]

heapq.heapify(A)

for _ in range(M):
    x = heapq.heappop(A) / 2
    heapq.heappush(A, x)

ans = 0
for a in A:
    ans -= int(a)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()

l = len(s)
d = dict()
for i in range(l):
    if s[i] in d.keys():
        d[s[i]].append(i+1)
    else:
        d[s[i]] = [i+1]

ans = 0
now = 0
for i in t:
    if i not in d.keys():
        print(-1)
        exit()

    for j in d[i]:
        if j > now:
            now = j
            break
    else:
        now = d[i][0]
        ans += l

print(ans + now)


Fixed submission:
import bisect
s = input()
t = input()

l = len(s)
d = dict()
for i in range(l):
    if s[i] in d.keys():
        d[s[i]].append(i+1)
    else:
        d[s[i]] = [i+1]

ans = 0
now = 0
for i in t:
    if i not in d.keys():
        print(-1)
        exit()

    a = bisect.bisect_right(d[i], now)
    if a == len(d[i]):
        now = d[i][0]
        ans += l
    else:
        now = d[i][a]

print(ans + now)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()

l = len(s)
d = dict()
for i in range(l):
    if s[i] in d.keys():
        d[s[i]].append(i+1)
    else:
        d[s[i]] = [i+1]

ans = 0
now = 0
for i in t:
    if i not in d.keys():
        print(-1)
        exit()

    for j in d[i]:
        if j > now:
            now = j
            break
    else:
        now = d[i][0]
        ans += l

print(ans + now)


Fixed submission:
import bisect
s = input()
t = input()

l = len(s)
d = dict()
for i in range(l):
    if s[i] in d.keys():
        d[s[i]].append(i+1)
    else:
        d[s[i]] = [i+1]

ans = 0
now = 0
for i in t:
    if i not in d.keys():
        print(-1)
        exit()

    a = bisect.bisect_right(d[i], now)
    if a == len(d[i]):
        now = d[i][0]
        ans += l
    else:
        now = d[i][a]

print(ans + now)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
MOD = 10**9 + 7

dp = [[0] * 13 for _ in range(2)]
dp[0][0] = 1

n = len(S)
for i in range(n):
    if i == 0:
        mod_array = [i for i in range(10)]
    else:
        mod_array = [i * 10 % 13 for i in mod_array]
    s = S[n-i-1]
    if s == '?':
        for a in mod_array:
            for k in range(13):
                dp[1][(k+a)%13] += dp[0][k]
    else:
        a = mod_array[int(s)]
        for k in range(13):
            dp[1][(k + a) % 13] += dp[0][k]
    for k in range(13):
        dp[0][k] = dp[1][k] % MOD
        dp[1][k] = 0

print(dp[0][5])




Fixed submission:
S = input()
MOD = 10**9 + 7

dp = [[0] * 13 for _ in range(2)]
dp[0][0] = 1

n = len(S)
for i in range(n):
    if i == 0:
        mod_array = [i for i in range(10)]
    else:
        mod_array = [i * 10 % 13 for i in mod_array]
    s = S[n-i-1]
    if s == '?':
        for a in mod_array:
            for k in range(13):
                dp[1][(k+a)%13] += dp[0][k]
    else:
        a = mod_array[int(s)]
        for k in range(13):
            dp[1][(k + a) % 13] += dp[0][k]
    for k in range(13):
        dp[0][k] = dp[1][k] % MOD
        dp[1][k] = 0

print(dp[0][5])

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
MOD = 10**9 + 7

dp = [0] * 13
dp[0] = 1

n = len(S)
for i in range(n):
    s = S[n-i-1]
    if s == '?':
        x = [0] * 13
        for j in range(10):
            a = j * (10**i) % 13
            for k in range(13):
                x[(k+a)%13] += dp[k]
        for k in range(13):
            dp[k] = x[k] % MOD
    else:
        a = int(s) * (10**i) % 13
        x = [0] * 13
        for k in range(13):
            x[(k + a) % 13] += dp[k]
        for k in range(13):
            dp[k] = x[k] % MOD

print(dp[5])




Fixed submission:
S = input()
MOD = 10**9 + 7

dp = [[0] * 13 for _ in range(2)]
dp[0][0] = 1

n = len(S)
for i in range(n):
    if i == 0:
        mod_array = [i for i in range(10)]
    else:
        mod_array = [i * 10 % 13 for i in mod_array]
    s = S[n-i-1]
    if s == '?':
        for a in mod_array:
            for k in range(13):
                dp[1][(k+a)%13] += dp[0][k]
    else:
        a = mod_array[int(s)]
        for k in range(13):
            dp[1][(k + a) % 13] += dp[0][k]
    for k in range(13):
        dp[0][k] = dp[1][k] % MOD
        dp[1][k] = 0

print(dp[0][5])