Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02690 (python)

Fixed submission:
X = int(input())

FIVES = [x ** 5 for x in range(200)]

for ki,vi in enumerate(FIVES):
    for kj,vj in enumerate(FIVES):
        if vi - vj == X:
            print(ki,kj)
            exit()
        if vj - vi == X:
            print(kj,ki)
            exit()
        if vi + vj == X:
            print(ki,-kj)
            exit()

Buggy submission (verdict: Runtime Error):
X = int(input())

FIVES = [x ** 5 for x in range(200)]

for ki,vi in enumerate(FIVES):
    for kj,vj in enumerate(FIVES):
        if and vi - vj == X:
            print(ki,kj)
            exit()
        if vj - vi == X:
            print(kj,ki)
            exit()
        if vi + vj == X:
            print(ki,-kj)
            exit()

Buggy submission (verdict: Runtime Error):
X = int(input())

FIVES = [x ** 5 for x in range(200)]

for ki,vi in enumerate(FIVES):
    for kj,vj in enumerate(FIVES):
        if and vi - vj == X:
            print(ki,kj)
            exit()
        if vj - vi == X:
            print(kj,ki)
            exit()
        if vi + vj == X:
            print(ki+1,-(kj+1))
            exit()
Problem p02698 (python)

Fixed submission:
import bisect
import sys
sys.setrecursionlimit(3*10**5)

INF = 10**10

N = int(input())
a = list(map(int,input().split()))
T = [set() for x in range(N)]
for i in range(N-1):
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    T[u].add(v)
    T[v].add(u)

search = [0]*N

A = [INF]*N

ans = [-1]*N

def dfs(V):
    num = a[V]
    k = bisect.bisect_left(A,num)
    v = A[k]
    A[k] = num
    ans[V] = bisect.bisect_left(A,INF)
    # このにぶたん無駄じゃね？まあ間に合うからいいか……
    for VV in T[V]:
        if search[VV]:
            continue
        search[VV] = 1
        dfs(VV)
    A[k] = v

search[0] = 1
dfs(0)

print(*ans,sep="\n")

Buggy submission (verdict: Runtime Error):
import bisect
import sys
sys.setrecursionlimit(3*10**5)

INF = 10**10

N = int(input())
a = list(map(int,input().split()))
T = [set() for x in range(N)]
for i in range(N-1):
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    T[u].add(v)
    T[v].add(u)

search = [0]*N

A = [INF]

ans = [-1]*N

def dfs(V):
    num = a[V]
    added = 0
    if A[-1] > num:
        A.append(num)
        added = 1
    else:
        k = bisect.bisect_left(A,num)
        v = A[k]
        A[k] = num
    ans[V] = len(A)
    for VV in T[V]:
        if search[VV]:
            continue
        search[VV] = 1
        dfs(VV)
    if added:
        A.pop()
    else:
        A[k] = v

search[0] = 1
dfs(0)

print(*ans,sep="\n")

Buggy submission (verdict: Runtime Error):
import bisect
import sys
sys.setrecursionlimit(3*10**5)

INF = 10**10

N = int(input())
a = list(map(int,input().split()))
T = [set() for x in range(N)]
for i in range(N-1):
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    T[u].add(v)
    T[v].add(u)

A = [INF]*N

ans = [-1]*N

def dfs(V):
    num = a[V]
    k = bisect.bisect_left(A,num)
    v = A[k]
    A[k] = num
    ans[V] = bisect.bisect_left(A,INF)
    # このにぶたん無駄じゃね？まあ間に合うからいいか……
    for VV in T[V]:
        dfs(VV)
        T[VV].remove(V)
    A[k] = v

dfs(0)

print(*ans,sep="\n")
Problem p02803 (python)

Fixed submission:
from collections import deque

def a():
    H,W = map(int,input().split())
    S = ["" for _ in range(H)]
    for _ in range(H):
        S[_] = input()
    b = lambda n:S[n//W][n%W] == '.'
    v = list(filter(b,range(H*W)))
    u = list(map(lambda n:(n%W,n//W),v))

    le = len(v)

    def bfs(root):
        i = 0
        depth = [[-1]*W for _ in range(H)]
        in_que = [[0]*W for _ in range(H)]
        q = deque()
        q.append((root,0))
        xx,yy = root
        in_que[yy][xx] = 1
        while i < le:
            r,d = q.popleft()
            x,y = r
            depth[y][x] = d
            i += 1
            for dx,dy in ((1,0),(-1,0),(0,1),(0,-1)):
                dx += x
                dy += y
                if 0 <= dx < W and 0 <= dy < H and in_que[dy][dx] == 0 and S[dy][dx] == ".":
                    q.append(((dx,dy),d+1))
                    in_que[dy][dx] = 1
        return depth
    
    print(max([max([max(y) for y in x]) for x in map(bfs,u)]))

a()

Buggy submission (verdict: Runtime Error):
from collections import deque

def a():
    H,W = map(int,input().split())
    S = ["" for _ in range(H)]
    for _ in range(H):
        S[_] = input()
    b = lambda n:S[n//W][n%W]
    u = (lambda n:(n%W,n//W))(min(range(H*W),key=b))

    def bfs(root):
        depth = [[-1]*W for _ in range(H)]
        q = deque()
        q.append((root,0))
        while q:
            r,d = q.popleft()
            x,y = r
            depth[y][x] = d
            for dx,dy in ((1,0),(-1,0),(0,1),(0,-1)):
                dx += x
                dy += y
                if 0 <= dx < W and 0 <= dy < H and depth[dy][dx] == -1 and S[dy][dx] == ".":
                    q.append(((dx,dy),d+1))
        return depth

    c = bfs(u)
    d = lambda n:c[n//W][n%W]
    v = (lambda n:(n%W,n//W))(max(range(H*W),key=d))

    e = bfs(v)
    f = lambda n:e[n//W][n%W]
    print(f(max(range(H,W),key=f)))



a()
Problem p02823 (python)

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

if (A + B)%2 == 0:
    print(abs(A - B)//2)
else:
    print(min(A-1,N-B)+1+abs(A-B+1)//2)

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

N -= 1
A -= 1
B -= 1

def is_valid(p):
    x,y = p
    return 0 <= x < N and 0 <= y < N

def meet(p):
    x,y = p
    return abs(x-y)//2

def dist(p1,p2):
    x1,y1 = p1
    x2,y2 = p2
    return (abs(x1-x2)+abs(y1-y2))//2

oo = []
if (A + B)%2:
    o = []
    for i in [0,N]:
        for j in [1,-1]:
            o.append((i,B + j * abs(A-i)))
            o.append((A + j * abs(B-i),i))
    for x,y in filter(is_valid,o):
        for i in [1,-1]:
            for j in [1,-1]:
                xx = max(0,min(x+i,N))
                yy = max(0,min(y+i,N))
                oo.append(meet((xx,yy))+dist((A,B),(x,y))+1)
    print(min(oo))
else:
    print(meet((A,B)))

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

N -= 1
A -= 1
B -= 1

def is_valid(p):
    x,y = p
    return 0 <= x < N and 0 <= y < N

def meet(p):
    x,y = p
    return abs(x-y)//2

def dist(p1,p2):
    x1,y1 = p1
    x2,y2 = p2
    return (abs(x1-x2)+abs(y1-y2))//2

oo = []
if (A + B)//2:
    o = []
    for i in [0,N]:
        for j in [1,-1]:
            o.append((i,B + j * abs(A-i)))
            o.append((A + j * abs(B-i),i))
    for x,y in filter(is_valid,o):
        for i in [1,-1]:
            for j in [1,-1]:
                xx = max(0,min(x+i,N))
                yy = max(0,min(y+i,N))
                oo.append(meet((xx,yy))+dist((A,B),(x,y))+1)
    print(min(oo))
else:
    print(meet((A,B)))
Problem p02882 (python)

Fixed submission:
import math

a,b,x = map(int,input().split())

xdash = x / a
FULL = a * b

if xdash == FULL:
    print(0)
elif FULL / 2 == xdash:
    print(math.degrees(math.atan2(b,a)))
elif FULL / 2 > xdash:
    print(90-math.degrees(math.atan(2*xdash/b/b)))
else:
    print(90-math.degrees(math.atan(a*a/2/(a*b-xdash))))

Buggy submission (verdict: Runtime Error):
import math

a,b,x = map(int,input().split())

xdash = x / a
FULL = a * b

if FULL / 2 == xdash:
    print(math.degrees(math.atan2(b,a)))
elif FULL / 2 > xdash:
    print(90-math.degrees(math.atan(2*xdash/b/b)))
else:
    print(90-math.degrees(math.atan(a*a/2/(a*b-xdash))))
Problem p02888 (python)

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

L.sort()

s = 0

ma = L[N-1]
for j in range(N-2):
    ja = L[j]
    for k in range(j+1,N-1):
        ka = L[k]
        # L[i] < L[j]+L[k] となる L[i]の数を求める
        key = ja + ka
        l = k + 1
        r = N - 1
        while r - l > 1:
            m = l + (r - l) // 2
            if L[m] < key:
                l = m
            else:
                r = m
        kka = L[k+1]
        if kka < key <= ma:
            s += l-k
        elif key <= kka:
            s += 0
        else:
            s += N-k-1

print(s)

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

L.sort()
print(L)

s = 0
for j in range(N-2):
    for k in range(j+1,N-1):
        Ld = [0] + L[k+1::] + [3000]
        # L[i] < L[j]+L[k] となる L[i]の数を求める
        key = L[j]+L[k]
        l = 0
        r = j + 2
        while r - l > 1:
            m = (r + l) // 2
            if Ld[m] < key:
                l = m
            else:
                r = m
        s += l

print(s)
Problem p02900 (python)

Fixed submission:
def gcd(n,m):
    while n:
        m,n = [n,m%n]
    return m

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

S = gcd(A,B)

s = 1
i = 2
while True:
    if S == 1:
        break
    if i ** 2 >= S:
        break
    hoge = 0
    while S % i == 0:
        hoge += 1
        S //= i
    if hoge:
        s += 1
    i += 1

print(s + (S != 1))

Buggy submission (verdict: Runtime Error):
def gcd(n,m):
    while n:
        m,n = [n,m%n]
    return m

def prime(N):
    se = [0,0,1]+[1]*(N-2)
    n = 2
    while n ** 2 <= N:
        if se[n]:
            nn = 2*n
            while nn <= N:
                se[nn] = 0
                nn += n
        n += 1

    return [x for x in range(0,N+1) if se[x]]

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

S = gcd(A,B)

s = 1
for i in prime(S):
    hoge = 0
    while S % i == 0:
        hoge += 1
        S //= i
    if hoge:
        s += 1

print(s)
Problem p02911 (python)

Fixed submission:
N,K,Q = map(int,input().split())
score = [K-Q]*N
A = [0]*Q
for i in range(Q):
    A[i] = int(input())

for a in A:
    score[a-1] += 1

for i in map(lambda x:['No','Yes'][x>0],score):
    print(i)

Buggy submission (verdict: Runtime Error):
N,K,Q= map(int,input().split())
score = [K-Q]*N
A = [0]*Q
for i in range(Q):
    A[i] = int(input())

for a in A:
    score[a] += 1

print(*map(lambda x:['No','Yes'][x>0],score),sep='\n')
Problem p03006 (python)

Fixed submission:
import itertools
from collections import Counter
from collections import defaultdict

d = defaultdict(lambda:-1)
N = int(input())
X = [0]*N
Y = [0]*N
for i in range(N):
    X[i],Y[i] = map(int,input().split())
    d[(X[i],Y[i])] = i

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

o = []
for i,j in itertools.product(range(N),range(N)):
    if i == j:
        continue
    x = X[i] - X[j]
    y = Y[i] - Y[j]
    o.append((x,y))

p,q = Counter(o).most_common()[0][0]
o = []
for i in range(N):
    a = i
    while True:
        b = d[(X[a]+p,Y[a]+q)]
        if b == -1:
            o.append(a)
            break
        a = b

print(len(set(o)))

Buggy submission (verdict: Runtime Error):
import itertools
from collections import Counter
from collections import defaultdict

d = defaultdict(lambda:-1)
N = int(input())
X = [0]*N
Y = [0]*N
for i in range(N):
    X[i],Y[i] = map(int,input().split())
    d[(X[i],Y[i])] = i

o = []
for i,j in itertools.product(range(N),range(N)):
    if i == j:
        continue
    x = X[i] - X[j]
    y = Y[i] - Y[j]
    o.append((x,y))

p,q = Counter(o).most_common()[0][0]
o = []
for i in range(N):
    a = i
    while True:
        b = d[(X[a]+p,Y[a]+q)]
        if b == -1:
            o.append(a)
            break
        a = b

print(len(set(o)))
Problem p03014 (python)

Fixed submission:
H,W = map(int,input().split())
S = [0]*H
for i in range(H):
    S[i] = list(input())

def aaa(s):
    i = 0
    l = len(s)
    o = []
    while True:
        if i == l:
            break
        if s[i] == ".":
            n = 0
            while i < l and s[i] == '.':
                i += 1
                n += 1
            o += [n] * n
        else:
            o += [0]
            i += 1
    return o

Hor = [0]*H
y = 0
while y != H:
    Hor[y] = aaa(S[y])
    y += 1

Ver = [0]*W
x = 0
while x != W:
    _ = 0
    s = [0] * H
    while _ != H:
        s[_] = S[_][x]
        _ += 1
    Ver[x] = aaa(s)
    x += 1

ans = 1
x = 0
while x != W:
    y = 0
    while y != H:
        h = Hor[y][x]
        if h:
            v = Ver[x][y]
            ans = max(ans,h+v-1)
        y += 1
    x += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np 

H,W = map(int,input().split())
S = np.array([[[0,1][i == '.'] for i in input()] for _ in range(H)])

funcA = np.frompyfunc(lambda x,y:y and x+y,2,1)
funcB = np.frompyfunc(lambda x,y:x if y and x and 1 else y,2,1)
Hor = funcA.accumulate(S,dtype=np.object,axis=1).astype(np.int)[:,::-1]
Hor = funcB.accumulate(Hor,dtype=np.object,axis=1).astype(np.int)[:,::-1]
Ver = funcA.accumulate(S,dtype=np.object,axis=0).astype(np.int)[::-1,:]
Ver = funcB.accumulate(Ver,dtype=np.object,axis=0).astype(np.int)[::-1,:]
print(np.max(Hor+Ver-1))
Problem p03048 (python)

Fixed submission:
def gcd(n,m):
    while n > 0:
        a = n
        n = m % n
        m = a
    return m

R,G,B,N = map(int,input().split(" "))

C = G * B // gcd(G,B)

s = 0
b = 0
while b <= N:
    bb = b
    while bb <= N:
        if (N - bb) % B == 0:
            s += (N - bb) // C + 1
            bb = N + 1
        else:
            bb += G
    b += R

print(s)

Buggy submission (verdict: Runtime Error):
from math import gcd

R,G,B,N = map(int,input().split(" "))

C = G * B // gcd(G,B)

s = 0
b = 0
while b <= N:
    bb = b
    while bb <= N:
        if (N - bb) % B == 0:
            s += (N - bb) // C + 1
            bb = N + 1
        else:
            bb += G
    b += R

print(s)

Buggy submission (verdict: Runtime Error):
R,G,B,N = map(int,input().split(" "))

from math import gcd

C = G * B // gcd(G,B)

s = 0
b = 0
while b <= N:
    bb = b
    while bb <= N:
        if (N - bb) % B == 0:
            s += (N - bb) // C + 1
            bb = N + 1
        else:
            bb += G
    b += R

print(s)
Problem p03061 (python)

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

def gcd(m,n):
    while n != 0:
        a = n
        n = m % n
        m = a
    return m

l = [0]*N
r = [0]*N

l[0] = A[0]
r[-1] = A[-1]

for x in range(1,N):
    y = N - 1 - x
    l[x] = gcd(A[x],l[x-1])
    r[y] = gcd(A[y],r[y+1])

l.insert(0,0)
l.append(0)
r.insert(0,0)
r.append(0)

o = 1

for x in range(N):
    o = max(o,gcd(l[x],r[x+2]))

print(o)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split(" ")))

def gcd(m,n):
    while n != 0:
        a = n
        n = m % n
        m = a
    return m

l = [0]*N
r = [0]*N

l[0] = A[0]
r[-1] = A[-1]

for x in range(1,N):
    y = N - 1 - x
    l[x] = gcd(A[x],l[x-1])
    r[y] = gcd(A[y],r[y+1])

l.insert(0,0)
l.append(0)
r.insert(0,0)
r.append(0)

o = 1

for x in range(N):
    x += 1
    o = max(o,gcd(l[x-1],r[x+1]))

print(max(o))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
A = list(map(int,input().split(" ")))

gcd = math.gcd

l = [0]*N
r = [0]*N

l[0] = A[0]
r[-1] = A[-1]

for x in range(1,N):
    l[x] = gcd(A[x],l[x-1])

for x in range(N-2,-1,-1):
    r[x] = gcd(A[x],r[x+1])

l.insert(0,0)
l.append(0)
r.insert(0,0)
r.append(0)

o = []

for x in range(N):
    o.append(gcd(l[x-1],r[x+1]))

print(max(o))
Problem p03455 (python)

Fixed submission:
a,b = map(int, input().split())
print("Odd" if a*b % 2 else "Even")

Buggy submission (verdict: Runtime Error):
a,b = map(int, raw_input().split())
print("Odd" if a*b % 2 else "Even")

Buggy submission (verdict: Runtime Error):
a,b = map(int, raw_input().split())
print "Odd" if a*b % 2 else "Even"
Problem p03456 (python)

Fixed submission:
a,b = input().split()
c = int(a+b)
i = 0
txt = "No"
while i * i <= c:
  if i * i == c:
    txt = "Yes"
    break
  i = i + 1
print(txt)

Buggy submission (verdict: Runtime Error):
a,b = input().split()
c = math.ceil(math.sqrt(int(a+b)))
print("Yes" if c * 2 == int(a+b) else "No")

Buggy submission (verdict: Runtime Error):
a,b = raw_input().split()
c = math.ceil(math.sqrt(int(a+b)))
print("Yes" if c * 2 == int(a+b) else "No")
Problem p03657 (python)

Fixed submission:
A,B=map(int,input().split(" "))
print("Impossible" if A*B*(A+B)%3 else "Possible")

Buggy submission (verdict: Runtime Error):
A,B=input().split(" ")
print("Impossible" if A*B*(A+B)%3 else "Possible")
Problem p03694 (python)

Fixed submission:
N = int(input())
a = list(map(int,input().split(" ")))
print(max(a)-min(a))

Buggy submission (verdict: Runtime Error):
input()
a = map(int,input().split(" "))
print(max(a)-min(a))
Problem p03738 (python)

Fixed submission:
A = input()
B = input()

def compare(A,B):
    if A == B:
        return 'EQUAL'
    if len(A) > len(B):
        return 'GREATER'
    if len(B) > len(A):
        return 'LESS'
    for i in range(len(A)):
        a = int(A[i])
        b = int(B[i])
        if a > b:
            return 'GREATER'
        if b > a:
            return 'LESS'

print(compare(A,B))

Buggy submission (verdict: Runtime Error):
A,B = input().split(" ")

def compare(A,B):
    if A == B:
        return 'EQUAL'
    if len(A) > len(B):
        return 'GREATER'
    if len(B) > len(A):
        return 'LESS'
    for i in range(len(A)):
        a = int(A[i])
        b = int(B[i])
        if a > b:
            return 'GREATER'
        if b > a:
            return 'LESS'

print(compare(A,B))
Problem p02639 (python)

Fixed submission:
import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

import numpy as np

x = na()
for i, xi in enumerate(x):
    if xi==0:
        print(i+1)

Buggy submission (verdict: Runtime Error):

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

import numpy as np

x = na()
for i, xi in enumerate(x):
    if xi==0:
        print(i+1)
Problem p02640 (python)

Fixed submission:

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

x, y = na()
for t in range(100):
    for k in range(100):
        if x == (t + k) and y == 2*t + 4*k:
            print("Yes")
            quit()
print("No")

Buggy submission (verdict: Runtime Error):

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

import numpy as np

x, y = na()
if y % 2 == 0 and y / x <= 4:
    print("Yes")
else:
    print("No")
Problem p02641 (python)

Fixed submission:

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

x, n =na()
p = na()

ans = x
for i in range(100):
    temp = x - i
    if not temp in p:
        print(temp)
        quit()
    temp = x + i
    if not temp in p:
        print(temp)
        quit()

Buggy submission (verdict: Runtime Error):

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

x, n =na()
p = na()
notp = list()
for i in range(1, 101):
    if i in p:
        continue
    notp.append(i)
ans = notp[0]

for i in notp:
    if abs(ans - x) > abs(i - x):
        ans = i
print(ans)
Problem p02691 (python)

Fixed submission:
#create date: 2020-05-03 21:37

import sys
stdin = sys.stdin
from collections import defaultdict

import numpy as np

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    a = np.array(na())
    b = np.arange(1, n+1)
    c = a + b
    d = b - a
    l = defaultdict(lambda: 0)
    ans = 0
    for ci in c:
        l[ci] += 1
    for di in d:
        ans += l[di]
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#create date: 2020-05-03 21:37

import sys
stdin = sys.stdin

import numpy as np

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    a = np.array(na())
    b = np.arange(1, n+1)
    #print(a, b)
    ans = 0
    for i in range(n):
        anow = a[i]
        j = i+anow+1
        if j < n:
            ans += sum(a[j:]== b[:n-j])
    print(ans)


if __name__ == "__main__":
    main()
Problem p02702 (python)

Fixed submission:
#create date: 2020-04-26 21:06

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    s = ns()
    n = len(s)
    now = 0
    m = [0] * 2019
    for i in range(n):
        now = (now + int(s[n-i-1]) * pow(10, i, 2019)) % 2019
        #print(now)
        m[now] += 1
    m[0] += 1
    ans = 0
    for mi in m:
        ans += (mi-1) * mi //2
    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#create date: 2020-04-26 21:06

import sys
stdin = sys.stdin

from numba import njit

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    s = ni()
    n = len(str(s))

    @njit
    def d(s, n):
        m = [0] * 2019
        now = 0
        for i in range(n):
            now = (s % 10**(i+1)) % 2019
            #print(now)
            m[now] += 1
        return m
    m = d(s, n)

    ans = m[0]
    for mi in m[1:]:
        ans += (mi-1) * mi //2
    print(ans)

    
if __name__ == "__main__":
    main()
Problem p02783 (python)

Fixed submission:
import sys
import math
import functools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]


h, a = na()
print((h-1)//a+1)

Buggy submission (verdict: Runtime Error):
import sys
import math
import functools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

h, n = na()
a, b = [], []
for _ in range(n):
    ai, bi = na()
    a.append(ai)
    b.append(bi)
inf = 10**9
dp = [[inf]* (10**4+1) for _ in range(n+1)]
for i in range(n):
    for j in range(1, 10**4+1):
        if j < a[i]:
            dp[i+1][j] = min(dp[i][j],((j-1)//a[i]+1)*b[i])
        else:
            dp[i+1][j] = min(dp[i][j],((j-1)//a[i]+1)*b[i], dp[i+1][j - a[i]] + b[i])
print(dp[n][h])