Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from math import gcd, ceil


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


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

for i in range(n):
    a[i] = a[i]//2

lcm_v = a[0]
for i in range(1, n):
    lcm_v = lcm(lcm_v, a[i])

ok = True
for aa in a:
    if (lcm_v//aa) % 2 != 1:
        ok = False
        break

if ok:
    ans = ((m//lcm_v)+1)//2
print(ans)

Fixed submission:
# ABC150 D
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
from fractions import gcd
from math import ceil
def lcm(x, y):
    return (x * y) // gcd(x, y)
n,m=nm()
a=nl()
ans=0
a=[x//2 for x in a] 

lcm_v=a[0]
for i in range(n):
    lcm_v=lcm(lcm_v,a[i])
ok_flg=[(lcm_v//i)%2==1 for i in a]
if all(ok_flg):
    ans=((m//lcm_v)+1)//2
print(ans)

Buggy python submission (verdict: Runtime Error):
# ABC150 D
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
from fractions import gcd
from math import ceil
def lcm(x, y):
    return (x * y) // gcd(x, y)
n,m=nm()
a=nl()
ans=0
a=[x//2 for x in a] 

lcm_v=a[0]
for i in range(n):
    lcm_v=lcm(lcm_v,a[i])
ok_flg=[(lcm_v//i)%2==1 for i in a]
if all(ok_flg):
    ans=((m//lcm)+1)//2
print(ans)



Fixed submission:
# ABC150 D
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
from fractions import gcd
from math import ceil
def lcm(x, y):
    return (x * y) // gcd(x, y)
n,m=nm()
a=nl()
ans=0
a=[x//2 for x in a] 

lcm_v=a[0]
for i in range(n):
    lcm_v=lcm(lcm_v,a[i])
ok_flg=[(lcm_v//i)%2==1 for i in a]
if all(ok_flg):
    ans=((m//lcm_v)+1)//2
print(ans)

Buggy python submission (verdict: Runtime Error):
# ABC150 D
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
from fractions import gcd
def lcm(x, y):
    """
    xとyの最小公倍数を求める。

    Parameters
    ----------
    x,y : int
        自然数

    Returns
    -------
        最小公倍数：int

    """
    return (x * y) // gcd(x, y)
n,m=nm()
a=nl()
b=[]
lc=[]

# for i in range(n):
#     b.append(a[i]//2)
# print(a)
for i in range(n):
    a[i]//=2
# print(a)
t=0
for i in range(n-1):
    if i==0:
        t=lcm(a[i],a[i+1])
        lc.append(t)
    elif i!=0:
        t=lcm(lc[i-1],a[i+1])
        # t=min(lc[i-1],t)
        lc.append(t)
# print(lc)
# print(max(a))
# ans=(m-max(a)//max(lc))//2
ans=0
ans=(m+max(a))//max(lc)
if ans%2==1:
    ans//=2
    ans+=1
else:
    ans//=2
print(ans)



Fixed submission:
# ABC150 D
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
from fractions import gcd
from math import ceil
def lcm(x, y):
    return (x * y) // gcd(x, y)
n,m=nm()
a=nl()
ans=0
a=[x//2 for x in a] 

lcm_v=a[0]
for i in range(n):
    lcm_v=lcm(lcm_v,a[i])
ok_flg=[(lcm_v//i)%2==1 for i in a]
if all(ok_flg):
    ans=((m//lcm_v)+1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
# ABC148 E
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
import math
n=ni()

if n==0:
    print(0)

if n%2==1:
    print(0)
    exit()

five=math.floor(math.log(n,5))
ans=0

# for i in range(five):
for j in range(five):
    t=n//(5**(five-j))
    ans+=t//2
print(ans)


Fixed submission:
# ABC148 E
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
import math
n=ni()

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

if n%2==1:
    print(0)
    exit()

five=math.floor(math.log(n,5))
ans=0

# for i in range(five):
for j in range(five):
    t=n//(5**(five-j))
    ans+=t//2
print(ans)

Buggy python submission (verdict: Runtime Error):
# ABC148 E
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
import math
n=ni()

if n%2==1:
    print(0)
    exit()

five=math.floor(math.log(n,5))
ans=0

# for i in range(five):
for j in range(five):
    t=n//(5**(five-j))
    ans+=t//2
print(ans)


Fixed submission:
# ABC148 E
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
import math
n=ni()

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

if n%2==1:
    print(0)
    exit()

five=math.floor(math.log(n,5))
ans=0

# for i in range(five):
for j in range(five):
    t=n//(5**(five-j))
    ans+=t//2
print(ans)
Buggy python submission (verdict: Runtime Error):
    #ABC147 C
    si = lambda: input()
    ni = lambda: int(input())
    nm = lambda: map(int, input().split())
    nl = lambda: list(map(int, input().split()))
    n=int(input())
    shogen=[]
    for _ in range(n):
    a=int(input())
    t=[]
    for __ in range(a):
        s=list(map(int,input().split()))
        t.append(s)
    shogen.append(t)

    ans=0

    for i in range(2**n):
    flag=True
    for j in range(n):
        if not flag:
        break
        if ((i>>j) & 1):
        for s in shogen[j]:
            if ((i>>s[0]-1)&1) !=s[1]:
            flag=False
    if flag:
        mnt = bin(i).count("1")
        ans=max(ans,mnt)
    print(ans)



Fixed submission:
#ABC147 C
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n=int(input())
shogen=[]
for _ in range(n):
    a=int(input())
    t=[]
    for __ in range(a):
        s=list(map(int,input().split()))
        t.append(s)
    shogen.append(t)

ans=0

for i in range(2**n):
    flag=True
    for j in range(n):
        if not flag:
            break
        if ((i>>j) & 1):
            for s in shogen[j]:
                if ((i>>s[0]-1)&1) !=s[1]:
                    flag=False
    if flag:
        mnt = bin(i).count("1")
        ans=max(ans,mnt)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
c=[0]*60
for aa in a:
  for i in range(60):
    if aa&(1<<i):c[i]+=1
ans=0
for i,cc in enumerate(c):
  ans+=cc*(n-cc)*2**i
  ans%=mod
print(ans)




Fixed submission:
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
c=[0]*60
for aa in a:
  for i in range(60):
    if aa&(1<<i):c[i]+=1
ans=0
for i,cc in enumerate(c):
  ans+=cc*(n-cc)*2**i
  ans%=mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
c=[0]*60
for aa in a:
  for i in range(60):
    if aa&(1<<i):c[i]+=1
ans=0
for i,cc in enumerate(c):
  ans+=cc*(n-cc)*2**i
  ans%=mod
print(ans)




Fixed submission:
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
c=[0]*60
for aa in a:
  for i in range(60):
    if aa&(1<<i):c[i]+=1
ans=0
for i,cc in enumerate(c):
  ans+=cc*(n-cc)*2**i
  ans%=mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
ans=0
for i in range(1000):
  t_str=str(i)
  t_len=len(t_str)
  t_str=(3-t_len)*"0"+t_str
  cur_idx=0
  ok=0
  for j,ss in enumerate(s):
    if ss==t_str[cur_idx]:
      cur_idx+=1
      ok+=1
    if cur_idx==3:break
  if cur_idx==3:
    ans+=1
print(ans) 



Fixed submission:
n=int(input())
s=input()
ans=0
for i in range(1000):
  t_str=str(i)
  t_len=len(t_str)
  t_str=(3-t_len)*"0"+t_str
  cur_idx=0
  ok=0
  for j,ss in enumerate(s):
    if ss==t_str[cur_idx]:
      cur_idx+=1
      ok+=1
    if cur_idx==3:break
  if cur_idx==3:
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
# DDCC C
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
h,w,k = nm()
C = []
itigo = []
itigo_sum = []
ans = [[] for i in range(h)]
for i in range(h):
    C.append(si())
s = 0
for c in C:
    ii = c.count('#')
    s += ii
    itigo.append(ii)
    itigo_sum.append(s)

itigo_cnt = 0
cnt = 1

for i in range(h):
    itigo_cnt = 1
    if i>=1:
        itigo_cnt += itigo_sum[i-1]
    if itigo[i]==0:
        for j in range(w):
            ans[i].append(ans[i-1][j])
    else:
        cnt = itigo_cnt
        for j in range(w):
            ans[i].append(cnt)
            if C[i][j:j+1]=='#':
                if itigo_sum[i]>cnt:
                    cnt += 1

for aa in ans:
    print(*aa)


Fixed submission:
# DDCC C
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
h,w,k = nm()
C = []
itigo = []
itigo_sum = []
is_copy = []
ans = [[] for i in range(h)]
for i in range(h):
    C.append(si())
s = 0
for c in C:
    ii = c.count('#')
    s += ii
    itigo.append(ii)
    itigo_sum.append(s)

itigo_cnt = 0
cnt = 1

for i in range(h):
    itigo_cnt = 1
    if i>=1:
        itigo_cnt += itigo_sum[i-1]
    if itigo[i]==0:
        continue
    else:
        cnt = itigo_cnt
        for j in range(w):
            ans[i].append(cnt)
            if C[i][j:j+1]=='#':
                if itigo_sum[i]>cnt:
                    cnt += 1
idx = 0
for i,aa in enumerate(ans):
    if aa:
        idx = i
        if is_copy:
            for j in range(len(is_copy)):
                t = is_copy.pop()
                for k in range(w):
                    ans[t].append(ans[i][k])
    else:
        is_copy.append(i)
    
    if i==len(ans)-1:
        for j in range(len(is_copy)):
            t = is_copy.pop()
            for k in range(w):
                ans[t].append(ans[idx][k])

for aa in ans:
    print(*aa)
Buggy python submission (verdict: Time Limit Exceeded):
class Combination:
    '''mod上の
    計算量：階乗・逆元テーブルの作成O(N)
    nCkを求めるO(1)'''
 
    def __init__(self, n, mod):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % mod)
        self.inv_fact = [pow(self.fact[i], mod - 2, mod) for i in range(n + 1)]
        self.mod = mod
 
    def factorial(self, k):
        """k!を求める O(1)"""
        return self.fact[k]
 
    def inverse_factorial(self, k):
        """k!の逆元を求める O(1)"""
        return self.inv_fact[k]
 
    def permutation(self, k, r):
        """kPrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[r]) % self.mod
 
    def combination(self, k, r):
        """kCrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.mod

    def combination_large(self, k, r):
        """kCrを求める O(r) kが大きいが、r <= nを満たしているときに使用"""
        if k < r:
            return 0
        res = 1
        for l in range(r):
            res *= (k - l)
            res %= self.mod
        return (res * self.inv_fact[r]) % self.mod

x, y = map(int, input().split())
mod = 10**9 + 7
comb = Combination(10**6,mod)

if (x+y)%3 != 0:
    print(0)
    exit(0)
i = (2*x-y)//3
j = (2*y-x)//3
print(comb.combination(i+j, i))


Fixed submission:
# ABC145 D Knight
def factorial_mod(n, mod):
    a = 1
    for i in range(1, n + 1):
        a *= i
        a %= mod
    return a

def comb_mod(n, k, mod):
    if k > n or k < 0:
        return 0
    fact_n = factorial_mod(n, mod)
    fact_k = factorial_mod(k, mod)
    fact_n_k = factorial_mod(n - k, mod)
    return (fact_n * pow(fact_k, mod - 2, mod) * pow(fact_n_k, mod - 2, mod)) % mod

x, y = map(int, input().split())
MOD = 10**9 + 7
if (2 * x - y) % 3 != 0 or (2 * y - x) % 3 != 0:
    print(0)
    exit()
i = (2 * x - y) // 3
j = (2 * y - x) // 3
print(comb_mod(i + j, i, MOD))
Buggy python submission (verdict: Runtime Error):
# E - All-you-can-eat
n,t=map(int,input().split())
a,b=[],[]
for i in range(n):
    aa,bb=map(int,input().split())
    a.append(aa)
    b.append(bb)

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

for i in range(n):
    for j in range(1,2*t+1):
        # if j-a[i]>=0:
        #     dp[i+1][j]=max(dp[i+1][j],dp[i][j-a[i]]+b[i])
        # dp[i+1][j]=max(dp[i+1][j],dp[i][j])
        if j-a[i]>=0:
            dp[i+1][j]=max(dp[i+1][j],dp[i][j-a[i]]+b[i])
        dp[i+1][j]=max(dp[i+1][j],dp[i][j])
# print(dp)
# print(dp[10][124])
a_max=max(a)
ans=0
if t+a_max-1>2*t:
    print(dp[n][sum(a)])
    exit()

for i in range(t-a_max-1,t+a_max-2):
    ans=max(dp[n][i],ans)

print(ans)


Fixed submission:
# E - All-you-can-eat
n,t=map(int,input().split())
a,b=[],[]
for i in range(n):
    aa,bb=map(int,input().split())
    a.append(aa)
    b.append(bb)

dp1=[[0]*t for _ in range(n+1)] # 前から
dp2=[[0]*t for _ in range(n+1)] # 後ろから
arev=a[::-1]
brev=b[::-1]

for i in range(1,n+1):
    for j in range(t):
        if j-a[i-1]>=0:
            dp1[i][j]=max(dp1[i-1][j-a[i-1]]+b[i-1],dp1[i-1][j])
        else:
            dp1[i][j]=dp1[i-1][j]

for i in range(1,n+1):
    for j in range(t):
        if j-arev[i-1]>=0:
            dp2[i][j]=max(dp2[i-1][j-arev[i-1]]+brev[i-1],dp2[i-1][j])
        else:
            dp2[i][j]=dp2[i-1][j]

ans=-1
for i in range(1,n+1):
    for j in range(t):
        ans=max(ans,dp1[i-1][j]+dp2[n-i][t-1-j]+b[i-1])
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())

L = []
LS = []
ans = 0
streak = 1
s = ''

for i in range(len(S)-1):
    if i == 0:
        s = S[0]
        streak = 1
    
    if s == '':
        if S[i+1:i+2] == S[i:i+1]:
            s = S[i:i+1]
            streak += 1
    else:
        if S[i+1:i+2] == s:
            streak += 1
        else:
            L.append(streak)
            LS.append(s)
            s = ''
            streak = 1
    
    if i == len(S)-2:
        if streak >= 2:
            L.append(streak)
            LS.append(s)
        if streak == len(S):
            ans = K*(len(S)//2)
            print(ans)
            exit()

if LS[0] != LS[-1]:
    for l in L:
        if i >=2:
            ans += l//2
    ans *= K
elif LS[0] == LS[-1]:
    for i in range(1,len(L)-1):
        ans += L[i]//2
    ans = K*ans + L[0]//2 + (K-1)*(L[0]+L[-1])//2 + L[-1]//2
print(ans)

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

if len(S) == 1:
    print(K//2)
    exit()
L = []
LS = []
ans = 0
streak = 1
s = ''

for i in range(len(S)-1):
    if i == 0:
        s = S[0]
        streak = 1
    
    if s == '':
        if S[i+1:i+2] == S[i:i+1]:
            s = S[i:i+1]
            streak += 1
    else:
        if S[i+1:i+2] == s:
            streak += 1
        else:
            L.append(streak)
            LS.append(s)
            s = ''
            streak = 1
    
    if i == len(S)-2:
        L.append(streak)
        LS.append(S[-1])
        # if streak == len(S):
        #     ans = K*(len(S)//2)
        #     print(ans)
        #     exit()

# print(LS)
# print(L)
if streak == len(S):
    ans = (len(S)*K)//2
    # print(len(S))
    print(ans)
    exit()

if LS[0] != LS[-1]:
    for l in L:
        # if l >=2:
        ans += l//2
    ans = K*ans
elif LS[0] == LS[-1]:
    for i in range(1,len(L)-1):
        ans += L[i]//2
    ans = K*ans + L[0]//2 + (K-1)*((L[0]+L[-1])//2) + L[-1]//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a,c=[],[]
for _ in range(m):
  a.append(list(map(int,input().split()))[0])
  c.append(sum((1<<(int(i)-1)) for i in input().split()))
inf=float('inf')
dp=[inf]*(1<<n)
dp[0]=0
for i in range(2**n):
  for j in range(m):
    dp[i|c[j]]=min(dp[i|c[j]],dp[i]+a[j])
print(dp[-1] if inf!=dp[-1] else-1)


Fixed submission:
n,m=map(int,input().split())
a,c=[],[]
for _ in range(m):
  a.append(list(map(int,input().split()))[0])
  c.append(sum((1<<(int(i)-1)) for i in input().split()))
inf=float('inf')
# dp[i]: 状態がbin(i)の時のの費用の最小値
# bin(i)のj桁が1: j番目の宝箱を開けることが可能
dp=[inf]*(1<<n)
dp[0]=0
for i in range(2**n):
  for j in range(m):
    dp[i|c[j]]=min(dp[i|c[j]],dp[i]+a[j])
print(dp[-1] if inf!=dp[-1] else-1)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import math

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

for i in range(m):
    idx = np.argmax(a)
    if a[idx] != 0:
        a[idx] /= 2

for i in range(n):
    a[i] = math.floor(a[i])

print(int(sum(a)))

Fixed submission:
# ABC141 D - Powerful Discount Tickets
from heapq import heappop,heappush,heapify

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

a_minus = [-x for x in a]

heapify(a_minus)

for _ in range(m):
    heappush(a_minus,-((-heappop(a_minus))//2))
ans = -sum(a_minus)
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s=0
for i in range(1,N+1):
    s += i-1
print(s)

Fixed submission:
N = int(input())
ans = N*(N-1)//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
S = []
T = []
S = [input() for i in range(N)]
ans = 0

for i,s in enumerate(S):
    s = sorted(list(s))
    s = ''.join(s)
    T.append(s)

for i in range(N):
    for j in range(i,N-1):
        if T[i] == T[j+1]:
            ans += 1
print(ans)

Fixed submission:
n = int(input())
s = [''.join(sorted(input())) for _ in range(n)]
d = {}
ans = 0
for S in s:
    if S in d:
        ans += d[S]
        d[S]+=1
    else:
        d[S]=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m,p=map(int,input().split())
E=[list(map(int,input().split())) for i in range(m)]
INF=float("inf")
dist=[INF]*n
dist[0]=0
for i in range(n):
  for fr,to,cost in E:
    fr,to=fr-1,to-1
    cost*=-1
    cost+=p
    if dist[fr]!=INF and dist[to]>dist[fr]+cost:
      dist[to]=dist[fr]+cost
      if i==n-1 and to==n-1:
        print(-1)
        exit(0)
print(0) if -dist[n-1]<0 else print(-dist[n-1])

Fixed submission:
n,m,p=map(int,input().split())
E=[list(map(int,input().split())) for i in range(m)]
INF=float("inf")
dist=[INF]*n
dist[0]=0
prev=0
# 閉路の長さの最大はnなので2*n回ループさせれば閉路検出ができる
for i in range(2*n):
  for fr,to,cost in E:
    fr,to=fr-1,to-1
    cost*=-1
    cost+=p
    if dist[fr]!=INF and dist[to]>dist[fr]+cost:
      dist[to]=dist[fr]+cost
      if i>=n:
        dist[to]=-float("inf")
    if i==n-1:
      prev=dist[n-1]
if prev==dist[n-1]:
  print(max(-dist[n-1],0))
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = [int(i) for i in input().split()]
count = 0
for i in range(n):
    if p[i] != i + 1:
        count += 1
if count == 0:
    print('YES')

if count == 2:
    print('YES')

if count > 2:
    print('No')


Fixed submission:
A, B = list(map(int, input().split()))
C = A + B
if C%2 == 0:
    answer = (A + B)/2
    print(int(answer))
else:
    answer = 'IMPOSSIBLE'
    print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)
# dp[i][j]:上からi桁目で13で割った余りがjの場合の数
dp = [[0]*13 for i in range(n+1)]
dp[0][0] = 1
mod = 10**9+7
for i in range(n):
    for j in range(13):
        if s[i] == "?":
            for k in range(10):
                dp[i+1][(j*10+k)%13] += dp[i][j]
                dp[i+1][(j*10+k)%13] %= mod
        else:
            k = int(s[i])-0
            dp[i+1][(j*10+k)%13] += dp[i][j]
            dp[i+1][(j*10+k)%13] %= mod

print(dp[n][5])

Fixed submission:
s = input()
n = len(s)
# dp[i][j]:上からi桁目で13で割った余りがjの場合の数
dp = [[0]*13 for i in range(n+1)]
dp[0][0] = 1
mod = 10**9+7
for i in range(n):
    for j in range(13):
        if s[i] == "?":
            for k in range(10):
                dp[i+1][(j*10+k)%13] += dp[i][j]
                dp[i+1][(j*10+k)%13] %= mod
        else:
            k = int(s[i])-0
            dp[i+1][(j*10+k)%13] += dp[i][j]
            dp[i+1][(j*10+k)%13] %= mod

print(dp[n][5])

Buggy python submission (verdict: Runtime Error):
mouikkai

Fixed submission:
s = input()
n = len(s)
# dp[i][j]:上からi桁目で13で割った余りがjの場合の数
dp = [[0]*13 for i in range(n+1)]
dp[0][0] = 1
mod = 10**9+7
for i in range(n):
    for j in range(13):
        if s[i] == "?":
            for k in range(10):
                dp[i+1][(j*10+k)%13] += dp[i][j]
                dp[i+1][(j*10+k)%13] %= mod
        else:
            k = int(s[i])-0
            dp[i+1][(j*10+k)%13] += dp[i][j]
            dp[i+1][(j*10+k)%13] %= mod

print(dp[n][5])
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = []
b = 0
a.append(int(input()))
# for i in range(N):

for i in range(N):
    b = a[i]
    a[i] = 0
    print(max(a))
    a[i] = b


Fixed submission:
N = int(input())
a = []
b = []
a_max = 0
a_second = 0

for i in range(N):
    a.append(int(input()))

b = a[:]
a.sort(reverse=True)

a_max = a[0]
a_second = a[1]

for i in range(N):
    if b[i] == a_max:
        print(a_second)
    else:
        print(a_max)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = []
b = 0

for i in range(N):
    a.append(int(input()))

for i in range(N):
    b = a[i]
    a[i] = 0
    print(max(a))
    a[i] = b


Fixed submission:
N = int(input())
a = []
b = []
a_max = 0
a_second = 0

for i in range(N):
    a.append(int(input()))

b = a[:]
a.sort(reverse=True)

a_max = a[0]
a_second = a[1]

for i in range(N):
    if b[i] == a_max:
        print(a_second)
    else:
        print(a_max)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(input())
A,B = map(int,input().split())
train = N*A
cab = B
result = train - cab

if result >= 0:
    print(cab)
else:
    print(train)

Fixed submission:
# -*- coding: utf-8 -*-
N,A,B = map(int,input().split())
train = N*A
taxi = B
result = train - taxi

if result >= 0:
    print(taxi)
else:
    print(train)
Buggy python submission (verdict: Time Limit Exceeded):
l,r = map(int,input().split())

def mod(x,y):
    return (x*y)%2019

ans = 2020
if l-r >= 2019:
    ans = 0
elif l-r < 2019:
    for i in range(l,r,1):
        for j in range(i+1,r+1,1):
            temp = mod(i,j)
            ans = min(temp,ans)
            if ans == 0:
                break

print(ans)



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

def mod(x,y):
    return (x*y)%2019

ans = 2020
if l-r >= 2019:
    ans = 0
elif l-r < 2019:
    for i in range(l,r,1):
        for j in range(i+1,r+1,1):
            temp = mod(i,j)
            ans = min(temp,ans)
            if ans == 0:
                break
        else:
            continue
        break

print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
import math
A, B, C, D = list(map(int, input().split()))

def lcm(x, y):
    return (x * y) / math.gcd(x, y)
E = lcm(C, D)

u = np.arange(A,B+1)
count_U = len(u)
u_c = [i for i in u if i % C == 0]
count_C = len(u_c)
u_d = [i for i in u if i % D == 0]
count_D = len(u_d)
u_e = [i for i in u if i % E == 0]
count_E = len(u_e)

answer = count_U - (count_C + count_D -count_E)
print(answer)


Fixed submission:
S = input()
result = 'Good'
for i in range(3):
    if S[i] == S[i + 1]:
        result = 'Bad'
        break
    else:
        result = 'Good'
print(result)