Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    h,n = map(int,ipt().split())
    atks = [tuple(map(int,ipt().split())) for i in range(n)]
    dam = [10**18]*(h+1)
    dam[0] = 0
    for i in range(1,h+1):
        for aj,bj in atks:
            if aj > i and dam[i] > bj:
                dam[i] = bj
            elif dam[i] > dam[i-aj]+bj:
                dam[i] = dam[i-aj]+bj

    print(dam[h])

    return None

if __name__ == '__main__':
    main()


Fixed submission:
import numpy as np
h, n = map(int,input().split())
a = np.zeros(n,dtype=int)
b = np.zeros(n,dtype=int)
for i in range(n):
    ai ,bi = map(int,input().split())
    a[i] = ai
    b[i] = bi

mh = np.zeros(10001,dtype=int)
for i in range(1,h+1):
    mh[i] = (mh[i-a]+b).min()

print(mh[h])

Buggy python submission (verdict: Time Limit Exceeded):
h, n = map(int,input().split())
a = [0 for i in range(n)]
b = [0 for i in range(n)]
for i in range(n):
    ai ,bi = map(int,input().split())
    a[i] = ai
    b[i] = bi


mh = [0 for i in range(10003)]
for i in range(1,h+1):
    mb = 10**9
    for j in range(n):
        if mb > mh[i-a[j]] + b[j]:
            mb = mh[i-a[j]] + b[j]
    mh[i] = mb

print(mh[h])


Fixed submission:
import numpy as np
h, n = map(int,input().split())
a = np.zeros(n,dtype=int)
b = np.zeros(n,dtype=int)
for i in range(n):
    ai ,bi = map(int,input().split())
    a[i] = ai
    b[i] = bi

mh = np.zeros(10001,dtype=int)
for i in range(1,h+1):
    mh[i] = (mh[i-a]+b).min()

print(mh[h])
Buggy python submission (verdict: Runtime Error):
import math
n, d, a = map(int,input().split())
e = [[] for i in range(n)]
for i in range(n):
    x, h = map(int,input().split())
    e[i] = [x,h]
num = 0

e.sort()
sd = [0 for i in range(n)]
l = [i for i in range(n)]
for i in range(n):
    for j in range(l[i-1],i):
        if e[i][0]-e[j][0] <= 2*d:
            l[i] = j
            break

for i in range(n):
    res = x[i][1] - sd[i-1] + sd[l[i]-1]
    if res < 0:
        sd[i] = sd[i-1]
    else:
        k = math.ceil(res/a)
        sd[i] = sd[i-1]+k*a
        num += k
        
print(num)


Fixed submission:
import math
n, d, a = map(int,input().split())
e = [[] for i in range(n)]
for i in range(n):
    x, h = map(int,input().split())
    e[i] = [x,h]
num = 0

e.sort()
sd = [0 for i in range(n)]
l = [i for i in range(n)]
for i in range(n):
    for j in range(l[i-1],i):
        if e[i][0]-e[j][0] <= 2*d:
            l[i] = j
            break

for i in range(n):
    res = e[i][1] - sd[i-1] + sd[l[i]-1]
    if res < 0:
        sd[i] = sd[i-1]
    else:
        k = math.ceil(res/a)
        sd[i] = sd[i-1]+k*a
        num += k

print(num)

Buggy python submission (verdict: Time Limit Exceeded):
import math
n, d, a = map(int,input().split())
e = [[] for i in range(n)]
for i in range(n):
    x, h = map(int,input().split())
    e[i] = [x,h]
e.sort()
num = 0

for i in range(n):
    if e[i][1] > 0:
        k = math.ceil(e[i][1]/a)
        num += k
        for j in range(i+1,n):
            if e[j][0] <= e[i][0] + 2*d:
                e[j][1] -= k*a
            else:
                break

print(num)


Fixed submission:
import math
n, d, a = map(int,input().split())
e = [[] for i in range(n)]
for i in range(n):
    x, h = map(int,input().split())
    e[i] = [x,h]
num = 0

e.sort()
sd = [0 for i in range(n)]
l = [i for i in range(n)]
for i in range(n):
    for j in range(l[i-1],i):
        if e[i][0]-e[j][0] <= 2*d:
            l[i] = j
            break

for i in range(n):
    res = e[i][1] - sd[i-1] + sd[l[i]-1]
    if res < 0:
        sd[i] = sd[i-1]
    else:
        k = math.ceil(res/a)
        sd[i] = sd[i-1]+k*a
        num += k

print(num)
Buggy python submission (verdict: Runtime Error):
n, m = map(int,input(),split())

if n == m:
    print("Yes")
else:
    print("No")

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

if n == m:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n, k, s = map(int,input().split())
if s == 10**9:
    ans = [0 for i in range(n)]
    ans[0] = 10**9-n+k
    for i in range(1,n-k+1):
        ans[i] = 1
else:
    ans = [10**9 for i in range(n)]
    ans[0] = s
    for i in range(1,k):
        ans[i] = 0

print(" ".join(map(str,ans)))


Fixed submission:
n, k, s = map(int,input().split())
if s == 10**9:
    ans = [1 for i in range(n)]
    for i in range(k):
        ans[i] = 10**9
else:
    ans = [10**9 for i in range(n)]
    for i in range(k):
        ans[i] = s

print(" ".join(map(str,ans)))
Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())
a = [[0,0] for i in range(n)]
ac = 0
wa = 0

for i in range(m):
    p, s = input().split()
    p = int(p-1)
    if s == "WA" and a[p][1] == 0:
        a[p][0] += 1
    elif s == "AC" and a[p][1] == 0:
        ac += 1
        a[p][1] = 1

for i in a:
    if i[1] == 1:
        wa += i[0]

print(ac,wa)


Fixed submission:
n, m = map(int,input().split())
a = [[0,0] for i in range(n)]
ac = 0
wa = 0

for i in range(m):
    p, s = input().split()
    p = int(p)-1
    if s == "WA" and a[p][1] == 0:
        a[p][0] += 1
    elif s == "AC" and a[p][1] == 0:
        ac += 1
        a[p][1] = 1

for i in a:
    if i[1] == 1:
        wa += i[0]

print(ac,wa)
Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int,input().split())
way = []
for i in range(h):
    s = input()
    for j in range(w):
        if s[j] == ".":
            way.append(i*w+j)
wayn = len(way)
mat = 0

for i in way:
    al = [i]
    time = 0
    pp = [i]
    while not len(al) == wayn:
        np = [j for j in pp]
        pp = []
        for j in np:
            if j%w < w-1 and j+1 in way and (not j+1 in al) and (not j+1 in pp):
                pp.append(j+1)
                al.append(j+1)
            if j%w > 0 and j-1 in way and (not j-1 in al) and (not j-1 in pp):
                pp.append(j-1)
                al.append(j-1)
            if j//w < h-1 and j+w in way and (not j+w in al) and (not j+w in pp):
                pp.append(j+w)
                al.append(j+w)
            if j//w > 0 and j-w in way and (not j-w in al) and (not j-w in pp):
                pp.append(j-w)
                al.append(j-w)
        time += 1
    if time > mat:
        mat = time

print(mat)


Fixed submission:
import queue
h, w = map(int,input().split())
way = ["" for i in range(h+1)]
way[h] = "#"*(w+1)
for i in range(h):
    way[i] = str(input())+"#"
G = [[[] for j in range(w)] for i in range(h)]
road = []
for i in range(h):
    for j in range(w):
        if way[i][j] == "#":
            continue
        else:
            road.append([i,j])
        if way[i+1][j] == ".":
            G[i][j].append([i+1,j])
        if way[i-1][j] == ".":
            G[i][j].append([i-1,j])
        if way[i][j+1] == ".":
            G[i][j].append([i,j+1])
        if way[i][j-1] == ".":
            G[i][j].append([i,j-1])
M = 0

for i in road:
    q = queue.Queue()
    q.put(i)
    t = [[-1 for k in range(w+1)] for j in range(h+1)]
    t[i[0]][i[1]] = 0
    while not q.empty():
        j = q.get()
        for l in G[j[0]][j[1]]:
            if t[l[0]][l[1]] == -1:
                t[l[0]][l[1]] = t[j[0]][j[1]] + 1
                q.put(l)
    for k in t:
        if M < max(k):
            M = max(k)

print(M)
Buggy python submission (verdict: Time Limit Exceeded):
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 #998244353
dir = [(-1,0),(1,0),(0,-1),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"


def main():
    n = int(ipt())
    x = [int(i) for i in ipt().split()]
    d = [x[i+1]-x[i] for i in range(n-1)]
    k = [1]
    for i in range(1,n):
        k.append(k[-1]*i%mod)

    #n!の逆元を求める
    g2 = [1,1]
    inverse = [0,1] #逆元テーブル計算用テーブル
    for i in range(2,n+1):
        inverse.append((-inverse[mod%i]*(mod//i))%mod)
        g2.append((g2[-1]*inverse[-1])%mod)

    ans = 0
    na = 0
    for i in range(1,n):
        na = na*i+k[i-1]
        ans += na*d[i-1]*k[-1]*g2[i]
        ans %= mod

    print(ans)
    return None

if __name__ == '__main__':
    main()


Fixed submission:
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 #998244353
dir = [(-1,0),(1,0),(0,-1),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"


def main():
    n = int(ipt())
    x = [int(i) for i in ipt().split()]
    d = [x[i+1]-x[i] for i in range(n-1)]
    k = [1]
    for i in range(1,n):
        k.append(k[-1]*i%mod)

    #n!の逆元を求める
    g2 = [1,1]
    inverse = [0,1] #逆元テーブル計算用テーブル
    for i in range(2,n+1):
        inverse.append((-inverse[mod%i]*(mod//i))%mod)
        g2.append((g2[-1]*inverse[-1])%mod)

    ans = 0
    na = 0
    for i in range(1,n):
        na = na*i+k[i-1]
        na %= mod
        ans += na*d[i-1]*k[-1]*g2[i]
        ans %= mod

    print(ans)
    return None

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
ans = 2

p = [2]
i = 1
Flag = True
if x > 2:
    while Flag:
        i += 2
        for j in p:
            if i%j == 0:
                break
            elif j == p[-1]:
                p.append(i)
                if i >= x:
                    ans = i
                    Flag = False

print(ans)


Fixed submission:
x = int(input())
ans = 2

p = [2]
i = 1
Flag = True
while i**2 < 100001:
    i += 2
    for j in p:
        if i%j == 0:
            break
        elif j == p[-1]:
            p.append(i)
for i in range(100000):
    if x+i in p:
        ans = x+i
        break
    elif x+i > p[-1]:
        for j in p:
            if (x+i)%j == 0:
                break
            elif j == p[-1]:
                ans = x+i
                break
        if ans == x+i:
            break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
ans = 2

p = [2]
i = 3
while i < x:
    for j in p:
        if i%j == 0:
            break
        elif j == p[-1]:
            p.append(i)
    i += 2

if x > 2:
    flag = True
    while flag:
        for j in p:
            if i%j == 0:
                break
            elif j == p[-1]:
                ans = i
                flag = False
                break
        i += 2
print(ans)


Fixed submission:
x = int(input())
ans = 2

p = [2]
i = 1
Flag = True
while i**2 < 100001:
    i += 2
    for j in p:
        if i%j == 0:
            break
        elif j == p[-1]:
            p.append(i)
for i in range(100000):
    if x+i in p:
        ans = x+i
        break
    elif x+i > p[-1]:
        for j in p:
            if (x+i)%j == 0:
                break
            elif j == p[-1]:
                ans = x+i
                break
        if ans == x+i:
            break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int,input().split())
a = list(map(int,input().split()))
list.sort(a,reverse=True)
ans = 0

kouho = [[0,0]]
for i in range(m):
    max = 0
    m0 = -1
    m1 = -1
    for j in kouho:
        if a[j[0]]+a[j[1]] > max:
            max = a[j[0]]+a[j[1]]
            m0 = j[0]
            m1 = j[1]
    ans += max
    kouho.remove([m0,m1])
    if m0 < n-1 and (not [m0+1,m1] in kouho):
        kouho.append([m0+1,m1])
    if m1 < n-1 and (not [m0,m1+1] in kouho):
        kouho.append([m0,m1+1])

print(ans)


Fixed submission:
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,m = map(int,ipt().split())
    a = [int(i) for i in ipt().split()]
    a.sort()
    maa = max(a)

    pn = [0]*(2*maa+1)
    pn[0] = n
    pa = 0
    for i in a:
        for j in range(pa+1,i+1):
            pn[j] = pn[pa]
        pn[i+1] = pn[pa]-1
        pa = i+1

    l = 0
    r = 2*maa
    while l < r:
        mid = l+(r-l+1)//2
        nm = 0
        for i in a:
            if mid <= i:
                nm += n
            else:
                nm += pn[mid-i]
        if nm >= m:
            l = mid
        else:
            r = mid-1

    pt = [0]*(2*maa+1)
    pp = maa+1
    for i in a[::-1]:
        for j in range(pp-1,i,-1):
            pt[j] = pt[pp]
        pt[i] = pt[pp]+i
        pp = i
    for j in range(pp-1,-1,-1):
        pt[j] = pt[pp]

    ans = 0
    sm = 0
    for i in a:
        sm += pn[max(0,l-i)]
        ans += pt[max(0,l-i)]+pn[max(0,l-i)]*i
    print(ans-l*(sm-m))
    return

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n = int(input().split())
a = list(map(int,input().split()))
now = 1
for i in range(n):
    if a[i] == now:
        now += 1
if now == 1:
    print(-1)
else:
    print(n-now+1)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
now = 1
for i in range(n):
    if a[i] == now:
        now += 1
if now == 1:
    print(-1)
else:
    print(n-now+1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
code = [[n,n,n] for i in range(1000)]

for i in range(n):
    si = int(s[i])
    for j in range(100):
        if code[j*10+si][1] < i and code[j*10+si][2] == n:
            code[j*10+si][2] = i
            #print(i,j*10+si,2)
        if code[si*100+j][0] == n:
            code[si*100+j][0] = i
            #print(i,si*100+j,0)
        if code[(j//10)*100+si*10+j%10][0] < i and code[(j//10)*100+si*10+j%10][1] == n:
            code[(j//10)*100+si*10+j%10][1] = i
            #print(i,(j//10)*100+si*10+j%10,1)

ans = 0
for i in range(1000):
    if code[i][2] < n:
        ans += 1

print(ans)


Fixed submission:
# https://atcoder.jp/contests/sumitrust2019/submissions/13016562を見た

n = int(input())
s = input()
ans = 0

pin = [str(i).zfill(3) for i in range(1000)]

for i in pin:
    idx = -1
    for j in i:
        idx = s.find(j,idx+1)
        if idx < 0:
            break
    else:
        ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
code = [[-1,-1,-1] for i in range(1000)]

for i in range(n):
    si = int(s[i])
    for j in range(100):
        if code[j*10+si][1] < i and code[j*10+si][1] > -1 and code[j*10+si][2] == -1:
            code[j*10+si][2] = i
            #print(i,j*10+si,2)
        if code[si*100+j][0] == -1:
            code[si*100+j][0] = i
            #print(i,si*100+j,0)
        if code[(j//10)*100+si*10+j%10][0] < i and code[(j//10)*100+si*10+j%10][0] > -1 and code[(j//10)*100+si*10+j%10][1] == -1:
            code[(j//10)*100+si*10+j%10][1] = i
            #print(i,(j//10)*100+si*10+j%10,1)

ans = 0
for i in range(1000):
    if code[i][2] > -1:
        ans += 1

print(ans)


Fixed submission:
# https://atcoder.jp/contests/sumitrust2019/submissions/13016562を見た

n = int(input())
s = input()
ans = 0

pin = [str(i).zfill(3) for i in range(1000)]

for i in pin:
    idx = -1
    for j in i:
        idx = s.find(j,idx+1)
        if idx < 0:
            break
    else:
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if 1<=a<=9 and 1<=b<=9:
  print(a*b)
else:
  prit(-1)

Fixed submission:
a,b = map(int,input().split())
if 1<=a<=9 and 1<=b<=9:
  print(a*b)
else:
  print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,m = map(int,ipt().split())
    way = [[] for _ in range(n)]
    for _ in range(m):
        s,t = map(int, ipt().split())
        way[s].append(t)

    cos = [0]*(n+1)
    cos[n] = 0 * n
    for i in range(n-1,0,-1):
        nm = 0
        sm = 0
        for j in way[i]:
            nm += 1
            sm += 1+cos[j]
        cos[i] = sm/nm

    gm = cos[1]
    for i in range(1,n-1):
        nm = 0
        ma = 0
        sm = 0
        for j in way[i]:
            nm += 1
            sm += 1+cos[j]
            if ma < 1+cos[j]:
                ma = 1+cos[j]
        if nm == 1:
            continue
        else:
            cos[i] = (sm-ma)/(nm-1)
        for j in range(i-1,0,-1):
            nm = 0
            sm = 0
            for k in way[j]:
                nm += 1
                sm += 1+cos[k]
            cos[j] = sm/nm
#        print(cos)
        if cos[1] < gm:
            gm = cos[1]

    print(gm)


    return

if __name__ == '__main__':
    main()


Fixed submission:
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,m = map(int,ipt().split())
    way = [[] for _ in range(n)]
    for _ in range(m):
        s,t = map(int, ipt().split())
        way[s].append(t)

    cos = [0]*(n+1)
    cos[n] = 0 * n
    for i in range(n-1,0,-1):
        nm = 0
        sm = 0
        for j in way[i]:
            nm += 1
            sm += 1+cos[j]
        cos[i] = sm/nm

    gm = cos[1]
    for i in range(1,n-1):
        nm = 0
        ma = 0
        sm = 0
        for j in way[i]:
            nm += 1
            sm += 1+cos[j]
            if ma < 1+cos[j]:
                ma = 1+cos[j]
        if nm == 1:
            continue
        else:
            cos[i] = (sm-ma)/(nm-1)
        for j in range(i-1,0,-1):
            nm = 0
            sm = 0
            for k in way[j]:
                nm += 1
                sm += 1+cos[k]
            cos[j] = sm/nm
#        print(cos)
        if cos[1] < gm:
            gm = cos[1]

    print(gm)


    return

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7

def main():
    s = input()
    t = input()
    ls = len(s)
    lt = len(t)
    for i in t:
        if not i in s:
            print(-1)
            exit()
    s *= lt
    nm = 0
    for i,si in enumerate(s):
        if si == t[nm]:
            nm += 1
        if nm == lt:
            print(i+1)
            exit()

    return None

if __name__ == '__main__':
    main()


Fixed submission:
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7

def main():
    s = input()
    ls = len(s)
    t = input()
    if t[0] in s:
        idx = s.find(t[0])
    else:
        print(-1)
        exit()
    for i in t[1::]:
        nt = s.find(i,idx%ls+1)
        ntl = s.find(i)
        if ntl == -1:
            print(-1)
            exit()
        elif nt == -1:
            idx = (idx//ls)*ls+ls+ntl
        else:
            idx = (idx//ls)*ls+nt
    print(idx+1)
    return None

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
l, r = map(int,input().split())
if not l//2019 == r//2019:
    print(0)
else:
    l %= 2019
    r %= 2019
    ans = 10**10
    for i in range(l,r):
        for j in range(i+1,r+1):
            if ans > (i*j)%2019:
                ans = (i*j)%2019

print(ans)


Fixed submission:
l, r = map(int,input().split())
if not l//2019 == r//2019:
    print(0)
else:
    l = l%2019
    r = r%2019
    ans = 10**10
    for i in range(l,r):
        for j in range(i+1,r+1):
            if ans > (i*j)%2019:
                ans = (i*j)%2019
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    n,m = map(int,ipt().split())
    s = [int(i) for i in ipt().split()]
    t = [int(i) for i in ipt().split()]
    ans = 0

    dp = [[1]*(m+1) for i in range(n+1)]
    for i,si in enumerate(s):
        for j,tj in enumerate(t):
            if si == tj:
                dp[i+1][j+1] = dp[i][j+1]+dp[i+1][j]
            else:
                dp[i+1][j+1] = dp[i][j+1]+dp[i+1][j]-dp[i][j]

    print(dp[n][m]%mod)

    return None

if __name__ == '__main__':
    main()


Fixed submission:
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    n,m = map(int,ipt().split())
    s = [int(i) for i in ipt().split()]
    t = [int(i) for i in ipt().split()]
    ans = 0

    dp = [[1]*(m+1) for i in range(n+1)]
    for i,si in enumerate(s):
        for j,tj in enumerate(t):
            if si == tj:
                dp[i+1][j+1] = dp[i][j+1]+dp[i+1][j]

            else:
                dp[i+1][j+1] = dp[i][j+1]+dp[i+1][j]-dp[i][j]
            dp[i+1][j+1] %= mod

    print(dp[n][m])

    return None

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
d = dict()
p = []
for i in range(n):
    x,y = map(int,input().split())
    for j in p:
        if str(x-j[0])+" "+str(y-j[1]) in d:
            d[str(x-j[0])+" "+str(y-j[1])] += 1
        else:
            d[str(x-j[0])+" "+str(y-j[1])] = 1
        if str(j[0]-x)+" "+str(j[1]-y) in d:
            d[str(j[0]-x)+" "+str(j[1]-y)] += 1
        else:
            d[str(j[0]-x)+" "+str(j[1]-y)] = 1
    p.append([x,y])

ans = max(d.values())
print(n-ans)


Fixed submission:
n = int(input())
d = dict()
p = []
for i in range(n):
    x,y = map(int,input().split())
    for j in p:
        if str(x-j[0])+" "+str(y-j[1]) in d:
            d[str(x-j[0])+" "+str(y-j[1])] += 1
        else:
            d[str(x-j[0])+" "+str(y-j[1])] = 1
        if str(j[0]-x)+" "+str(j[1]-y) in d:
            d[str(j[0]-x)+" "+str(j[1]-y)] += 1
        else:
            d[str(j[0]-x)+" "+str(j[1]-y)] = 1
    p.append([x,y])

if len(d.values()) == 0:
    ans = 0
else:
    ans = max(d.values())
print(n-ans)