Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
if sqrt(a) + sqrt(b) < sqrt(c):
    print("Yes")
else:
    print("No")

Fixed submission:
a,b,c = map(int,input().split())
if (c-b-a) > 0 and (c-b-a)**2 > 4*a*b:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n,d ,a = map(int,input().split())
xh = []
for _ in range(n):
    x,y = map(int,input().split())
    kaisuu = y // a if y % a == 0 else y//a +1
    xh.append([x,kaisuu])
xh.sort()
migihasi = xh[0][0] + (2*d)
ans = 0
hidarindex = 0
bombs = [(xh[0][1],migihasi)] #[はぜる回数、右端]
for i in range(1,n):
    needkaisuu = xh[i][1]
    zahyo = xh[i][0]
    for cnt,migi in bombs:
        if zahyo <= migi and zahyo >= migi - (2*d):
            needkaisuu -= cnt
        if needkaisuu <=0:break
    if needkaisuu >0:
        bombs.append((needkaisuu,zahyo+(2*d)))
for x,y in bombs:
    ans+= x
print(ans)
        
    
    
    
    

Fixed submission:
from collections import deque
n,d,a = map(int,input().split())
f = [list(map(int,input().split()))for i in range(n)]
queue = deque()
f.sort()
tot = 0
ans = 0
for i in range(n):
    x = f[i][0]
    h = f[i][1]
    while queue and queue[0][0] < x:
        now = queue.popleft()
        tot -= now[1]
    h -= tot
    if h > 0:
        num = (h+a-1)//a
        ans += num
        damage = num*a
        tot+=damage
        queue.append((x+2*d,damage))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(n):
    if min(p[:i+1]) == p[i]:
        ans+=1
print(ans)

Fixed submission:
n = int(input())
p = list(map(int,input().split()))
ans = 0
pmin = 10**7
for i in range(n):
    pmin = min(pmin,p[i])
    if p[i] <= pmin:
        ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(n):
    if min(p[:i+1]) == p[i]:
        ans+=1
print(ans)

Fixed submission:
n = int(input())
p = list(map(int,input().split()))
ans = 0
pmin = 10**7
for i in range(n):
    pmin = min(pmin,p[i])
    if p[i] <= pmin:
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math as m
from functools import reduce
n = int(input())
a = list(map(int,input().split()))
ans = 0
mod = 10**9+7
def lcm(x,y):
    return (x*y//m.gcd(x,y))
def lcml(nums):
    return reduce(lcm,nums,1)
l = lcml(a)
for x in a:
    ans+= (l*pow(x,mod-2,mod)) %mod
    ans%=mod
print(ans)

Fixed submission:
import fractions as m
from functools import reduce
n = int(input())
a = list(map(int,input().split()))
ans = 0
mod = 10**9+7
def lcm(x,y):
    return (x*y//m.gcd(x,y))
def lcml(nums):
    return reduce(lcm,nums,1)
l = lcml(a)
for x in a:
    ans+= (l*pow(x,mod-2,mod)) %mod
    ans%=mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions as m
from functools import reduce
n = int(input())
a = list(map(int,input().split()))
ans = 0
mod = 10**9+7
def lcm(x,y):
    return (x*y//m.gcd(x,y))
def lcml(nums):
    return reduce(lcm,nums,1)
l = lcml(a)
for x in a:
    ans+= (l*pow(x,mod-2,mod)) %mod
    ans%=mod
print(ans)

Fixed submission:
import fractions as m
from functools import reduce
n = int(input())
a = list(map(int,input().split()))
ans = 0
mod = 10**9+7
def lcm(x,y):
    return (x*y//m.gcd(x,y))
def lcml(nums):
    return reduce(lcm,nums,1)
l = lcml(a)
for x in a:
    ans+= (l*pow(x,mod-2,mod)) %mod
    ans%=mod
print(ans)
Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
field = [list(input())for i in range(h)]
a= [[0]*w for i in range(h)]

vec = [(-1,0),(1,0),(0,1),(0,-1)]
ans = 0
for i in range(h):
    for j in range(w):
        if field[i][j] == "#":continue
        stack = [(i,j)]
        visited = [[0]*w for i in range(w)]
        a[i][j] = 0
        
        while stack:
            next = []
            for x,y in stack:
                
                if visited[x][y]:continue

                visited[x][y] = 1
                

                for tx,ty in vec:
                    nx = x+tx
                    ny = y+ty
                    if nx < 0 or ny <0 or nx >=h or ny >=w:continue
                    if field[nx][ny] == "#" :continue
                    if visited[nx][ny]:continue
                    next.append((nx,ny))
                    a[nx][ny] = a[x][y] + 1
                    
                    
            stack = next
   
        for i in range(h):
            ans = max(ans,max(a[i]))
            a[i] = [0]*w
print(ans)
            
            
            
            

Fixed submission:
h,w = map(int,input().split())
field = [list(input())for i in range(h)]


vec = [(-1,0),(1,0),(0,1),(0,-1)]
ans = 0
for i in range(h):
    for j in range(w):
        if field[i][j] == "#":continue
        stack = [(i,j)]
        visited = [[0]*w for i in range(h)]
        a= [[0]*w for i in range(h)]
        
        while stack:
            next = []
            for x,y in stack:
                
                if visited[x][y]:continue

                visited[x][y] = 1
                

                for tx,ty in vec:
                    nx = x+tx
                    ny = y+ty
                    if nx < 0 or ny <0 or nx >=h or ny >=w:continue
                    if field[nx][ny] == "#" :continue
                    if visited[nx][ny]:continue
                    next.append((nx,ny))
                    a[nx][ny] = a[x][y]+1
                    
                    
            stack = next
        ans = max(ans,max(max(row)for row in a))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
c = list(map(int,input().split()))
mod = 10**9+7
c.sort()
ans = 0
for i in range(n):
    ans += c[i]*(2+n-1-i)*4**(n-1)
    ans %= mod

ans %= mod
print(ans)

Fixed submission:
n = int(input())
c = list(map(int,input().split()))
mod = 10**9+7
c.sort()
ans = 0
for i in range(n):
    ans += c[i]*(2+n-1-i)*pow(4,n-1,mod)
    ans %= mod

ans %= mod
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()
#dp[i][ｊ]:=i番目までで、最後にｊを出したときの点数の最大値
dp = [[-10**9]*3for i in range(n+10)]
for i in range(k):
    dp[i][0],dp[i][1],dp[i][2] = 0,0,0
    
    
 
for i in range(k):
    for j in range(n//k+3):
        if i > n-1:continue
        if t[i] == "r":
            dp[i+k][0] = max(dp[i][1],dp[i][2])
            dp[i+k][1] = max(dp[i][0],dp[i][2])
            dp[i+k][2] = max(dp[i][0]+p,dp[i][1]+p)
        
        elif t[i] == "s":
            dp[i+k][0] = max(dp[i][1]+r,dp[i][2]+r)
            dp[i+k][1] = max(dp[i][0],dp[i][2])
            dp[i+k][2] = max(dp[i][0],dp[i][1])
        
        elif t[i] == "p":
            dp[i+k][0] = max(dp[i][1],dp[i][2])
            dp[i+k][1] = max(dp[i][0]+s,dp[i][2]+s)
            dp[i+k][2] = max(dp[i][0],dp[i][1])
        i += k
ans = 0    
for i in range(n,n+k):
    ans += max(dp[i])
print(ans)


Fixed submission:
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input().strip()


def pon(computer, mine):
    if computer == 'r' and mine == 2: return P
    if computer == 's' and mine == 0: return R
    if computer == 'p' and mine == 1: return S
    return 0


dp = [[0 for _ in range(3)] for _ in range(N+10)]

ans = 0
for st in range(K):
    for i in range(st, N, K):
        for j in range(3):
            for k in range(3):
                if j == k:
                    continue
                if i+1-K >= 0:
                    dp[i+1][k] = max(dp[i+1][k], dp[i+1-K][j] + pon(T[i], k))
                else:
                    dp[i+1][k] = max(dp[i+1][k], pon(T[i], k))
    ans += max(dp[i+1])

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

Fixed submission:
import fractions
a,b = map(int,input().split())
gcd = fractions.gcd(a,b)
ans = a*b//gcd
print(ans)
Buggy python submission (verdict: Runtime Error):
n,u,v = map(int,input().split())
u-=1
v-=1
ki = [[]for i in range(n)]
distt = [0]*n
dista = [0]*n
for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    ki[a].append(b)
    ki[b].append(a)
def dfst(now,last = -1):
    for next in ki[now]:
        if next == last:continue
        distt[next] = distt[now]+1
        dfst(next,now)
def dfsa(now,last = -1):
    for next in ki[now]:
        if next == last:continue
        dista[next] = dista[now]+1
        dfsa(next,now)
    
dfst(u)
dfsa(v)
ans = 0
for i in range(n):
    if dista[i]<=distt[i]:continue
    ans = max(ans,dista[i]-1)
print(ans)
    

Fixed submission:
import sys

sys.setrecursionlimit(10**7)
n,u,v = map(int,input().split())
u-=1
v-=1
ki = [[]for i in range(n)]
distt = [0]*n
dista = [0]*n
for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    ki[a].append(b)
    ki[b].append(a)
def dfst(now,last = -1):
    for next in ki[now]:
        if next == last:continue
        distt[next] = distt[now]+1
        dfst(next,now)
def dfsa(now,last = -1):
    for next in ki[now]:
        if next == last:continue
        dista[next] = dista[now]+1
        dfsa(next,now)
    
dfst(u)
dfsa(v)
ans = 0
for i in range(n):
    if dista[i]<=distt[i]:continue
    ans = max(ans,dista[i]-1)
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
n,u,v = map(int,input().split())
ki = [[]for i in range(n)]
distt = [0]*n
dista = [0]*n
for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    ki[a].append(b)
    ki[b].append(a)
def dfst(now,last = -1):
    for next in ki[now]:
        if next == last:continue
        distt[next] = distt[now]+1
        dfst(next,now)
def dfsa(now,last = -1):
    for next in ki[now]:
        if next == last:continue
        dista[next] = dista[now]+1
        dfsa(next,now)
    
dfst(u)
dfsa(v)
ans = 0
for i in range(n):
    if dista[i]<=distt[i]:continue
    ans = max(ans,dista[i]-1)
print(ans)
    

Fixed submission:
import sys

sys.setrecursionlimit(10**7)
n,u,v = map(int,input().split())
u-=1
v-=1
ki = [[]for i in range(n)]
distt = [0]*n
dista = [0]*n
for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    ki[a].append(b)
    ki[b].append(a)
def dfst(now,last = -1):
    for next in ki[now]:
        if next == last:continue
        distt[next] = distt[now]+1
        dfst(next,now)
def dfsa(now,last = -1):
    for next in ki[now]:
        if next == last:continue
        dista[next] = dista[now]+1
        dfsa(next,now)
    
dfst(u)
dfsa(v)
ans = 0
for i in range(n):
    if dista[i]<=distt[i]:continue
    ans = max(ans,dista[i]-1)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
cnt = [0]*(66)
for num in a:
    for j in range(60):
        cnt[j] += (num >> j)%2
ans = 0
for b in range(60):
    ans += (cnt[b]*(n-cnt[b])) << b
    ans %= 10**9+7
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
cnt = [0]*(66)
for num in a:
    for j in range(60):
        cnt[j] += (num >> j)%2
ans = 0
for b in range(60):
    ans += (cnt[b]*(n-cnt[b])) << b
    ans %= 10**9+7
print(ans)
Buggy python submission (verdict: Runtime Error):
X=int(input())
dp = [0]*(X+1)
dp[0]=1
dp[100]=1
dp[101]=1
dp[102]=1
dp[103]=1
dp[104]=1
dp[105]=1
if X>105:

    for i in range(106,X+1):
	        if dp[i-100] == 1:
	    	        dp[i]=1
	        elif dp[i-101] == 1:
	    	        dp[i]=1
	        elif dp[i-102] == 1:
	    	        dp[i]=1
	        elif dp[i-103] == 1:
	    	        dp[i]=1
	        elif dp[i-104] == 1:
	        	dp[i]=1
	        elif dp[i-105] == 1:
	    	        dp[i]=1
	        else:
	    	        dp[i]=0
	    
print(dp[X])


Fixed submission:
x = int(input())
f = (x%100)//5
ff = (x%100)%5
a = [0,101,102,103,104]
if 105*f+a[ff]<= x:
    print(1)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
X=int(input())
dp = [0]*(X+1)
dp[0]=1
dp[100]=1
dp[101]=1
dp[102]=1
dp[103]=1
dp[104]=1
dp[105]=1
for i in range(106,X+1):
	    if dp[i-100] == 1:
	    	    dp[i]=1
	    elif dp[i-101] == 1:
	    	    dp[i]=1
	    elif dp[i-102] == 1:
	    	    dp[i]=1
	    elif dp[i-103] == 1:
	    	    dp[i]=1
	    elif dp[i-104] == 1:
	    	    dp[i]=1
	    elif dp[i-105] == 1:
	    	    dp[i]=1
	    else:
	    	    dp[i]=0
	    
print(dp[X])


Fixed submission:
x = int(input())
f = (x%100)//5
ff = (x%100)%5
a = [0,101,102,103,104]
if 105*f+a[ff]<= x:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
n = int(input())
ki = [[]for j in range(n)]
for i in range(n-1):
	    a,b=map(int,input().split())
	    a-=1
	    b-=1
	    ki[a].append([b,i])
	    ki[b].append([a,i])


a=[0]*n
for i in range(n):
	    a[i]= len(ki[i])
print(max(a))
clist=[-1]*(n-1)
visited=[[0]for i in range(n)]
def dfs(now,last,ban_color=-1):
	    color =1
	    for next,id in ki[now]:
	    	    
                     
	    	    if next == last:continue
	    	    if color == ban_color:
	    	    	    color+=1
	    	    clist[id] = color
	    	    dfs(next,now,color)
	    	    
	    	    color+=1
	    	    
dfs(0,-1)
for i in range(n-1):
    print(clist[i])


		

Fixed submission:
S = input()
w = ["SUN","MON","TUE","WED","THU","FRI","SAT","SUN"]
for i in range(7):
    if S == w[i]:
        print(7-i )
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = [0]+list(map(int,input().split()))
for i in range(n):
    a[i+1] += a[i]
cnt = {}
ans = 0
for i in range(n+1):
    left = i-k
    if left >= 0:
        ldiff = (a[left] - left)%k
        cnt[ldiff]-=1
    diff = (a[i]-i)%k
    if diff not in cnt:cnt[diff] = 0
    ans += cnt[diff]
    cnt[diff] +=1
print(ans)
             

Fixed submission:
n,k = map(int,input().split())
a = [0]+list(map(int,input().split()))
for i in range(n):
    a[i+1] += a[i]
cnt = {}
ans = 0
for i in range(n+1):
    left = i-k
    if left >= 0:
        ldiff = (a[left] - left)%k
        cnt[ldiff]-=1
    diff = (a[i]-i)%k
    if diff not in cnt:cnt[diff] = 0
    ans += cnt[diff]
    cnt[diff] +=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n= int(input())
a = list(map(int,input().split()))
now = a[0] 
a.sort()
res = 0
ans = 1
for i in range(n-1):
    if a[i+1] != now:
        ans+=1
        now = a[i+1]
if ans%2:print(ans)
else: print(ans-1)

Fixed submission:
n,m = map(int,input().split())
s = input()
cnt = [0]*(n+1)
r = n
for i in range(n-1,-1,-1):
    if s[i] == '1':
        cnt[i] = -1
        continue
    while r > i+m:r -=1
    while cnt[r] == -1:r -= 1
    if i == r:
        print(-1)
        exit(0)
    cnt[i] =cnt[r]+1
now = 0
ans = []
for i in range(n+1):
    if cnt[i] == -1:continue
    if cnt[i] == cnt[now]-1:
        ans.append(i-now)
        now = i
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
l1 = 0

for i in range(n):
    l1 += a[i] 
    if l1> sum(a)//2:break
r1 = sum(a) - l1
l2 = l1 -a[i]
r2 = sum(a) - l2
ans = min(abs(r1-l1),abs(r2-l2))
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
l1 = 0

for i in range(n):
    l1 += a[i] 
    if l1> s//2:break
r1 = s - l1
l2 = l1 -a[i]
r2 = s - l2
ans = min(abs(r1-l1),abs(r2-l2))
print(ans)
Buggy python submission (verdict: Runtime Error):
s =input()
n = len(s)
a = [0]*(n+1)
hidari = [0] *(n+1)
for i in range(1,n+1):
    if s[i-1] == '<':
        res +=1
    else:res = 0
    hidari[i] = res
hidari[-1] = res
res = 0
migi = [0] *(n+1)
for i in range(n-1,-1,-1):
    if s[i] == '>':
        res+=1
    else:res = 0
    migi[i] = res
migi[0] = res
ans = 0
for i in range(n+1):
    ans += max(migi[i],hidari[i])
print(ans)

Fixed submission:
s =input()
n = len(s)
a = [0]*(n+1)
res = 0
hidari = [0] *(n+1)
for i in range(1,n+1):
    if s[i-1] == '<':
        res +=1
    else:res = 0
    hidari[i] = res
hidari[-1] = res
res = 0
migi = [0] *(n+1)
for i in range(n-1,-1,-1):
    if s[i] == '>':
        res+=1
    else:res = 0
    migi[i] = res
migi[0] = res
ans = 0
for i in range(n+1):
    ans += max(migi[i],hidari[i])
print(ans)

Buggy python submission (verdict: Runtime Error):
s =input()
n = len(s)
a = [0]*(n+1)
hidari = [0] *(n+1)
for i in range(1,n+1):
    if s[i-1] == '<':
        res +=1
    else:res = 0
    hidari[i] = res
hidari[-1] = res
res = 0
migi = [0] *(n+1)
for i in range(n-1,-1,-1):
    if s[i] == '>':
        res+=1
    else:res = 0
    migi[i] = res
migi[0] = res
ans = 0
for i in range(n+1):
    ans += max(migi[i],hidari[i])
print(ans)

Fixed submission:
s =input()
n = len(s)
a = [0]*(n+1)
res = 0
hidari = [0] *(n+1)
for i in range(1,n+1):
    if s[i-1] == '<':
        res +=1
    else:res = 0
    hidari[i] = res
hidari[-1] = res
res = 0
migi = [0] *(n+1)
for i in range(n-1,-1,-1):
    if s[i] == '>':
        res+=1
    else:res = 0
    migi[i] = res
migi[0] = res
ans = 0
for i in range(n+1):
    ans += max(migi[i],hidari[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
スコード 

Copy
Copy
# a<=bとみなせるので探索回数は√nでよい
import math
n = int(input())
r_n = int(math.sqrt(n))+1
m = 10 ** 12
for i in range(1,r_n):
  if n % i == 0 and m > i + n / i - 2:
    m = i + n / i - 2
 
print(int(m))

Fixed submission:

# a<=bとみなせるので探索回数は√nでよい
import math
n = int(input())
r_n = int(math.sqrt(n))+1
m = 10 ** 12
for i in range(1,r_n):
  if n % i == 0 and m > i + n / i - 2:
    m = i + n / i - 2
 
print(int(m))
Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
ans = min(0,A-(2`B)
print(ans)

Fixed submission:
A,B = map(int,input().split())
ans = max(0,A-(2*B))
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = 0
d = list(map(int,input().split()))
for i in range(N*(N-1)//2-1):
    ans+= d[i]*d[i+1]
ans+=d[0]*d[N-1]
print(ans)

Fixed submission:
N = int(input())
ans = 0
d = list(map(int,input().split()))
for i in range(N-1):
    for j in range(i+1,N):
        ans+= d[i]*d[j]

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = 0
d = list(map(int,input().split()))
for i in range(N*(N-1)//2-1):
    ans+= d[i]*d[i+1]
ans+=d[0]*d[N-1]
print(ans)

Fixed submission:
N = int(input())
ans = 0
d = list(map(int,input().split()))
for i in range(N-1):
    for j in range(i+1,N):
        ans+= d[i]*d[j]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))
l = sorted(l)
ans = 0
for i in range(n):
	    for j in range(i+1,n):
	    	    bottom  = j
	    	    top = n
	    	    while top -bottom > 1:
	    	    	    middle = (top+bottom)//2
	    	    	    if l[middle] <l[i]+l[j]:
	    	    	    	    bottom = middle
	    	    	    else:
	    	    	    	    top = middle
	    	    ans += bottom - j 
print(ans)

Fixed submission:
import bisect
N = int(input())
ans = 0
L = list(map(int,input().split()))
L = sorted(L)
for i in range(N-1):
    for j in range(i+1,N):
        a = bisect.bisect(L,L[i]+L[j]-1)
       
        ans += a-j-1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
ans = 0
L = list(map(int,input().split()))
L = sorted(L)
for i in range(N-1):
    for j in range(i+1,N):
        a = bisect.bisect(L,L[i]+L[j])
        if L[i]+L[j] in L:
            a -= 1
        ans += a-j-1
     
print(ans)        
        

Fixed submission:
import bisect
N = int(input())
ans = 0
L = list(map(int,input().split()))
L = sorted(L)
for i in range(N-1):
    for j in range(i+1,N):
        a = bisect.bisect(L,L[i]+L[j]-1)
       
        ans += a-j-1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int,input().split()))
L = sorted(L)
L.reverse()
ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
         
            
            if L[i] >= L[j] + L[k]:
                break
            ans+=1
print(ans)

Fixed submission:
import bisect
N = int(input())
ans = 0
L = list(map(int,input().split()))
L = sorted(L)
for i in range(N-1):
    for j in range(i+1,N):
        a = bisect.bisect(L,L[i]+L[j]-1)
       
        ans += a-j-1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)
dp = [[0]*13 for i in range(n+5)]
dp[0][0] = 1
mod = 10**9+7
for i in range(n):
	    for j in range(13):
	    	    if s[i] != '?':
	    	    	    x = int(s[i])
	    	    	    ni = i+1
	    	    	    nj = (j*10+x)%13
	    	    	    dp[ni][nj] += dp[i][j]
	    	    	    dp[ni][nj]%= mod
	    	    	    continue
	    	    for d in range(10):
	    	    	    ni = i+1
	    	    	    nj = (j*10+d)%13
	    	    	    dp[ni][nj] += dp[i][j]
	    	    	    dp[ni][nj]%= mod
print(dp[n][5])

Fixed submission:
s = input()
n = len(s)
mod = 10**9+7
dp = [[0]*13 for i in range(n+5)]#dp[i][j] :=先頭i文字を見たとき、その数字を13で割ったあまりがｊであるような場合の数
dp[0][0] = 1#先頭０文字は”０”　で、１３で割ったあまりは０だから　dp[0][0] = 1
for i in range(n):
    for j in range(13):
        if s[i] == "?":
            for d in range(10):
                dp[i+1][(j*10+d)%13] += dp[i][j]
                dp[i+1][(j*10+d)%13] %= mod
                
        else:
            dp[i+1][(j*10+int(s[i]))%13] += dp[i][j]
            dp[i+1][(j*10+int(s[i]))%13] %= mod
ans = dp[n][5]
print(ans)

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

box=[0]*n
ans=[]
for i in range(n,0,-1):
    sum_=0
    for j in range(1,n+1):
        if j*i>n:
            break
        sum_+=box[j*i-1]
    if sum_%2!=a[i-1]:
        box[i-1]=1
        ans.append(i)

print(len(ans))
print(' '.join(list(map(str,ans))))


Fixed submission:
s = input()
n = len(s)
mod = 10**9+7
dp = [[0]*13 for i in range(n+5)]#dp[i][j] :=先頭i文字を見たとき、その数字を13で割ったあまりがｊであるような場合の数
dp[0][0] = 1#先頭０文字は”０”　で、１３で割ったあまりは０だから　dp[0][0] = 1
for i in range(n):
    for j in range(13):
        if s[i] == "?":
            for d in range(10):
                dp[i+1][(j*10+d)%13] += dp[i][j]
                dp[i+1][(j*10+d)%13] %= mod
                
        else:
            dp[i+1][(j*10+int(s[i]))%13] += dp[i][j]
            dp[i+1][(j*10+int(s[i]))%13] %= mod
ans = dp[n][5]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)
mod = 10**9+7
dp = [[0]*13 for i in range(n+5)]#dp[i][j] :=先頭i文字を見たとき、その数字を13で割ったあまりがｊであるような場合の数
dp[0][0] = 1#先頭０文字は”０”　で、１３で割ったあまりは０だから　dp[0][0] = 1
for i in range(n):
    for j in range(13):
        if s[i] == "?":
            for d in range(10):
                dp[i+1][(j*10+d)%13] += dp[i][j]
                dp[i+1][(j*10+d)%13] %= mod
                
        else:
            dp[i+1][(j*10+int(s[i]))%13] += dp[i][j]
            dp[i+1][(j*10+int(s[i]))%13] %= mod
ans = dp[n][5]
print(ans)

Fixed submission:
s = input()
n = len(s)
mod = 10**9+7
dp = [[0]*13 for i in range(n+5)]#dp[i][j] :=先頭i文字を見たとき、その数字を13で割ったあまりがｊであるような場合の数
dp[0][0] = 1#先頭０文字は”０”　で、１３で割ったあまりは０だから　dp[0][0] = 1
for i in range(n):
    for j in range(13):
        if s[i] == "?":
            for d in range(10):
                dp[i+1][(j*10+d)%13] += dp[i][j]
                dp[i+1][(j*10+d)%13] %= mod
                
        else:
            dp[i+1][(j*10+int(s[i]))%13] += dp[i][j]
            dp[i+1][(j*10+int(s[i]))%13] %= mod
ans = dp[n][5]
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(int(input()) for i in range(N))
ans = A[0]
for i in range(N):
    for n in range(i):
        if ans < A[i]:
            ans = A[i]
    for n in range(i+1,N):
        if ans < A[i]:
            ans = A[i]
    print(ans)
    ans = A[0]

Fixed submission:
r = int(input())
ans = r**2*3
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
L,R = map(int,input().split())
anslist = []
for i in range(L,R):
    for j in range(i+1,R+1):
        if i%2019 == j%2019:
            continue
        anslist.append((i*j)%2019)
ans = min(anslist)
print(ans)

Fixed submission:
L, R = map(int, input().split())
mn = 2019
for i in range(L, min(L + 2019, R + 1)):
    for j in range(i + 1, min(L + 2019, R + 1)):
        mn = min(mn, i * j % 2019)
print(mn)