Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int, input().split()))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
ans=0
for i in range(N):
    a=A[i]
    D=make_divisors(a)
    #print(D)
    L=A[:i]+A[i+1:]
    for d in D:
        if d in L:
            ans+=1
            break
print(N-ans)


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




MAX=max(A)
nums=[0]*(MAX)

ans=0

for i in range(N):
    a=A[i]
    kousin=True
    if i!=0:
        if A[i-1]==a:
            kousin=False
    if i!=N-1:
        if a==A[i+1]:
            kousin=False

    if nums[a-1]==0 and kousin:
        ans+=1
        
                
        if a>MAX//2:
            continue
            

    count=1
    num=a
    while num<=MAX:
        nums[num-1]+=1
        count+=1
        num=a*count
    
#print(nums)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int, input().split())
G=[[] for _ in range(N)]
for i in range(M):
    a,b=map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

siru=[-1]*(N-1)#2~~N
que=[0]

while len(que)>0:
    #print(que)
    now=que.pop(0)
    nexlist=G[now]
    for nex in nexlist:
        if nex==0:
            continue
        if siru[nex-1]==-1:
            siru[nex-1]=now
            que.append(nex)
X=siru.count(-1)
if X>=1:
    print("No")
else:
    print("Yes")
    for num in siru:
        print(num+1)


Fixed submission:
N,M=map(int, input().split())
G=[[] for _ in range(N)]
for i in range(M):
    a,b=map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

siru=[-1]*(N-1)#2~~N
que=[0]

while len(que)>0:
    #print(que)
    now=que.pop(0)
    nexlist=G[now]
    for nex in nexlist:
        if nex==0:
            continue
        if siru[nex-1]==-1:
            siru[nex-1]=now
            que.append(nex)
X=siru.count(-1)
if X>=1:
    print("No")
else:
    print("Yes")
    for num in siru:
        print(num+1)
Buggy python submission (verdict: Runtime Error):
N,K=map(int, input().split())
A=list(map(int, input().split()))
import sys
sys.setrecursionlimit(10**8)
import numpy as np
done=np.array([0]*N)
X=[0]*2
L=[]
F=[True]
def dfs(start, steps):
    done[start-1]+=1
    L.append(start)
    if done[start-1]==3:
        X[1]=steps
        return
    elif done[start-1]==2 and F[0]:
        X[0]=steps
        F[0]=False
    nex=A[start-1]
    dfs(nex, steps+1)
dfs(1,0)
#print(done)
#print(X)
#print(L)
first=L[:X[0]-(X[1]-X[0])]
sec=L[X[0]-(X[1]-X[0]):X[0]-(X[1]-X[0])+(X[1]-X[0])]
#print(first, sec)
if len(first)==0:
    first=sec
if K-1<=len(first):
    print(first[K])
else:
    K=K-len(first)
    print(sec[(K%len(sec))])


Fixed submission:
N,K=map(int, input().split())
A=list(map(int, input().split()))
import sys
sys.setrecursionlimit(10**8)
import numpy as np
done=np.array([0]*N)
X=[0]*2
L=[]
F=[True]
def dfs(start, steps):
    done[start-1]+=1
    L.append(start)
    if done[start-1]==3:
        X[1]=steps
        return
    elif done[start-1]==2 and F[0]:
        X[0]=steps
        F[0]=False
    nex=A[start-1]
    dfs(nex, steps+1)
dfs(1,0)
#print(done)
#print(X)
#print(L)
first=L[:X[0]-(X[1]-X[0])]
sec=L[X[0]-(X[1]-X[0]):X[0]-(X[1]-X[0])+(X[1]-X[0])]
#print(first, sec)
if len(first)==0:
    first=sec
if K+1<=len(first):
    print(first[K])
else:
    K=K-len(first)
    print(sec[(K%len(sec))])

Buggy python submission (verdict: Runtime Error):
N,K=map(int, input().split())
A=list(map(int, input().split()))
import sys
sys.setrecursionlimit(10**6)
import numpy as np
done=np.array([0]*N)
X=[0]*2
L=[]
F=[True]
def dfs(start, steps):
    done[start-1]+=1
    L.append(start)
    if done[start-1]==3:
        X[1]=steps
        return
    elif done[start-1]==2 and F[0]:
        X[0]=steps
        F[0]=False
    nex=A[start-1]
    dfs(nex, steps+1)
dfs(1,0)
#print(done)
#print(X)
#print(L)
first=L[:X[0]-(X[1]-X[0])]
sec=L[X[0]-(X[1]-X[0]):X[0]-(X[1]-X[0])+(X[1]-X[0])]
#print(first, sec)
if len(first)==0:
    first=sec
if K-1<=len(first):
    print(first[K])
else:
    K=K-len(first)
    print(sec[(K%len(sec))])


Fixed submission:
N,K=map(int, input().split())
A=list(map(int, input().split()))
import sys
sys.setrecursionlimit(10**8)
import numpy as np
done=np.array([0]*N)
X=[0]*2
L=[]
F=[True]
def dfs(start, steps):
    done[start-1]+=1
    L.append(start)
    if done[start-1]==3:
        X[1]=steps
        return
    elif done[start-1]==2 and F[0]:
        X[0]=steps
        F[0]=False
    nex=A[start-1]
    dfs(nex, steps+1)
dfs(1,0)
#print(done)
#print(X)
#print(L)
first=L[:X[0]-(X[1]-X[0])]
sec=L[X[0]-(X[1]-X[0]):X[0]-(X[1]-X[0])+(X[1]-X[0])]
#print(first, sec)
if len(first)==0:
    first=sec
if K+1<=len(first):
    print(first[K])
else:
    K=K-len(first)
    print(sec[(K%len(sec))])
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int, input().split()))

L=[0]*(10**6)
for i in range(N):
    if i-A[i]>=0:
        L[i-A[i]]+=1
ans=0
for i in range(N):
    tall=A[i]
    ans+=L[tall+i]
print(ans)
#print(L[:10])

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

L=[0]*(10**6)
for i in range(N):
    if i-A[i]>=0:
        L[i-A[i]]+=1
ans=0
for i in range(N):
    tall=A[i]
    if tall+i<len(L):
        ans+=L[tall+i]
print(ans)
#print(L[:10])
Buggy python submission (verdict: Time Limit Exceeded):
S=list(input())
mod=2019
S=list(reversed(S))
N=len(S)
A=[0]*(N)
p=1
for i in range(N):
    p=(10**i)%mod
    now=(int(S[i])*p)%mod
    A[i]=now
    #print(now)
rui=[0]*(N+1)
for i in range(1,N+1):
    rui[i]=(rui[i-1]+A[i-1])%mod
total=[0]*2019
for r in rui:
    total[r]+=1
ans=0
for t in total:
    ans+=t*(t-1)//2
print(ans)


Fixed submission:
S=input()
N=len(S)
R=[0]*(N+1)
mul=1
for i in range(1,N+1):
    R[-(i+1)]=(((int(S[-i])*mul))%(2019)+R[-i])%2019
    mul*=10
    mul%=2019
#print(R)
L=[0]*2019
for r in R:
    L[r]+=1
ans=0
for l in L:
    if l>=2:
        ans+=l*(l-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S=input()
N=len(S)
R=[0]*(N+1)
for i in range(1,N+1):
    R[-(i+1)]=((int(S[-i])*10**(i-1))%(2019)+R[-i])%2019
#print(R)
L=[0]*2019
for r in R:
    L[r]+=1
ans=0
for l in L:
    if l>=2:
        ans+=l*(l-1)//2
print(ans)



Fixed submission:
S=input()
N=len(S)
R=[0]*(N+1)
mul=1
for i in range(1,N+1):
    R[-(i+1)]=(((int(S[-i])*mul))%(2019)+R[-i])%2019
    mul*=10
    mul%=2019
#print(R)
L=[0]*2019
for r in R:
    L[r]+=1
ans=0
for l in L:
    if l>=2:
        ans+=l*(l-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S=input()
N=len(S)
#dp?
ans=0
for l in range(N-4):
    r=l+4
    X=S[l:r+1]
    on=False
    while r<N:
        T=int(X)
        if T%(2019)==0:
            ans+=1
            if not on:
                add=r-l+1
                on=True
        if on:
            
            X+=S[r+1:r+add+1]
            r+=add
        else:
            r+=1
            X+=S[min(r,N-1)]
print(ans)

Fixed submission:
S=input()
N=len(S)
R=[0]*(N+1)
mul=1
for i in range(1,N+1):
    R[-(i+1)]=(((int(S[-i])*mul))%(2019)+R[-i])%2019
    mul*=10
    mul%=2019
#print(R)
L=[0]*2019
for r in R:
    L[r]+=1
ans=0
for l in L:
    if l>=2:
        ans+=l*(l-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S=input()
N=len(S)
#dp?
ans=0
for l in range(N-4):
    r=l+4
    on=False
    while r<N:
        X=int(S[l:r+1])
        if int(X)%(2019)==0:
            ans+=1
            if not on:
                add=r-l+1
                on=True
        if on:
            r+=add
        else:
            r+=1
print(ans)

Fixed submission:
S=input()
N=len(S)
R=[0]*(N+1)
mul=1
for i in range(1,N+1):
    R[-(i+1)]=(((int(S[-i])*mul))%(2019)+R[-i])%2019
    mul*=10
    mul%=2019
#print(R)
L=[0]*2019
for r in R:
    L[r]+=1
ans=0
for l in L:
    if l>=2:
        ans+=l*(l-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S=input()
N=len(S)
count=0
for l in range(N-3):
    for r in range(l+3,N):
        if int(S[l:r+1])%2019==0:
            count+=1
print(count)


Fixed submission:
S=input()
N=len(S)
R=[0]*(N+1)
mul=1
for i in range(1,N+1):
    R[-(i+1)]=(((int(S[-i])*mul))%(2019)+R[-i])%2019
    mul*=10
    mul%=2019
#print(R)
L=[0]*2019
for r in R:
    L[r]+=1
ans=0
for l in L:
    if l>=2:
        ans+=l*(l-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
if N%2==1:
  a=b
import numpy as np
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])

  if temp!=1:
    arr.append([temp, 1])

  if arr==[]:
    arr.append([n, 1])

  return arr

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
d=np.array(make_divisors(N))
soin=factorization(N)
#print(d)
#(K: 314132908543,  )
#割り切れて１になる。。。。Nの一通り
#Kで割ってK+1になった 約数の差が１
# M*(x-K)=K+1
#(x-K)%K==1
#(x-K)/K=M:::1
#x-K=M*K+1
#N-1の約数
#２は必ず入る
#素因数分解して素数一つならそれも
count=0


#print(make_divisors(N-1))
S=make_divisors(N-1)
#print(soin)
#１除くN加える
ans=len(S)-1+1
if 2 not in S:
  ans+=1
if len(soin)==1 and soin[0][0]!=N:
  for i in range(1,soin[0][1]+1):
    if soin[0][1]%i==0 and (soin[0][0])**i not in S and (soin[0][0])**i not in [2,N]:
      ans+=1
      #print((soin[0][0])**i)
  
print(ans)
#print(S)

Fixed submission:
N=int(input())
if N==2:
  print(1)
  exit()
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)

    # divisors.sort()
  return divisors
#N-1の約数(1は除く)　Nそのもの
#2
d=make_divisors(N-1)
if not 2 in d:
  d.append(2)
#print(d)
d2=make_divisors(N)
#print(len(d))
for i in d2:
  if i!=N and i!=1 and i not in d:
    now=N
    while now%i==0:
      now/=i
    if now%i==1:
      d.append(i)
print(len(d))
Buggy python submission (verdict: Time Limit Exceeded):
X, Y, A, B, C=map(int, input().split())
P=sorted(list(map(int, input().split())), )[-X:]
Q=sorted(list(map(int, input().split())), )[-Y:]
R=sorted(list(map(int, input().split())), reverse=True)

PQ=sorted(P+Q)

ans=0
for i in range(len(PQ)):
  if len(R)>0:
    
    now=max(PQ[i], R.pop(0))
  else:
    now=PQ[i]
  ans+=now
  
print(ans)


Fixed submission:
import numpy as np
X, Y, A, B, C=map(int, input().split())
P=sorted(list(map(int, input().split())), )[-X:]
Q=sorted(list(map(int, input().split())), )[-Y:]
R=sorted(list(map(int, input().split())), reverse=True)

PQ=sorted(P+Q)

ans=0
for i in range(len(PQ)):
  if len(R)>0:
    
    now=max(PQ[i], R.pop(0))
  else:
    now=PQ[i]
  ans+=now
  
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
ABC=["A","B","C","D","E","F","G","H","I",,"J"]
def dfs(n,s):
  if len(s)==N:
    print(s)
    return
  
  for i in range(n+1):
    _s=s+ABC[i]
    dfs(max(n,i+1),_s)
    
dfs(0,"")

Fixed submission:
N=int(input())
ABC=["a","b","c","d","e","f","g","h","i","j"]
def dfs(n,s):
  if len(s)==N:
    print(s)
    return
  
  for i in range(n+1):
    _s=s+ABC[i]
    dfs(max(n,i+1),_s)
    
dfs(0,"")
Buggy python submission (verdict: Runtime Error):
N, M=map(int, input().split())

S=[list(map(int, input().split())) for i in range(M)]

num=["a"]*N
ans=True
for s in S:
  if (num[s[0]-1]!="a") and (num[s[0]-1]!=s[1]):
    ans=False
    break
  else:
    num[s[0]-1]=s[1]
    
if num[0]==0 and len(num)>1:
  ans=False
    
if ans:
  if len(num[0])==1:
    if num[0]=="a":
      print(0)
    else:
      print(num[0])
  else:
    for i in range(N):
      if num[i]=="a":
        if i==0:
          print(1, end="")
        else:
          print(0, end="")
      else:
        print(num[i], end="")
else:
  print(-1)
  

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

S=[list(map(int, input().split())) for i in range(M)]

num=["a"]*N
ans=True
for s in S:
  if (num[s[0]-1]!="a") and (num[s[0]-1]!=s[1]):
    ans=False
    break
  else:
    num[s[0]-1]=s[1]
    
if num[0]==0 and len(num)>1:
  ans=False
    
if ans:
  if len(num)==1:
    if num[0]=="a":
      print(0)
    else:
      print(num[0])
  else:
    for i in range(N):
      if num[i]=="a":
        if i==0:
          print(1, end="")
        else:
          print(0, end="")
      else:
        print(num[i], end="")
else:
  print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=map(int, input().split())

p=10**9+7
ans=0
for i in range(1,n+1):
    if i==1:
        now=n%p
    else:
        now=now*(n+1-i)*pow(i,p-2,p)%p
    if i==a or i==b:
        continue
    else:
        ans+=now
        ans%=p



print(ans)


Fixed submission:
n, a, b=map(int, input().split())
mod = 10 ** 9 + 7 
def cmb(n, r, mod):
    r = min(r, n -r)
    if r == 0: return 1
    over, under = 1, 1
    for i in range(1, r+1):
        over = over * (n-i+1) % mod
        under = under * i % mod
    
    inv=pow(under, mod-2, mod)
    
    return over*inv % mod
  
print((pow(2,n,mod)-1 - cmb(n, a,mod)-cmb(n,b,mod))%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n, a, b=map(int, input().split())
M=10**9 +7
SUM=0
now=n
for i in range(1,n+1):
  if i==1:
    now=n
  else:
    now=now*(n-i+1)/i%M
  if not (i==a or i==b):
    SUM+=now%M
    



print(int(SUM%M))

Fixed submission:
n, a, b=map(int, input().split())
mod = 10 ** 9 + 7 
def cmb(n, r, mod):
    r = min(r, n -r)
    if r == 0: return 1
    over, under = 1, 1
    for i in range(1, r+1):
        over = over * (n-i+1) % mod
        under = under * i % mod
    
    inv=pow(under, mod-2, mod)
    
    return over*inv % mod
  
print((pow(2,n,mod)-1 - cmb(n, a,mod)-cmb(n,b,mod))%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n, a, b=map(int, input().split())
M=10**9 +7
SUM=0
now=n
for i in range(1,n+1):
  if i==1:
    now=n
  else:
    now=now*(n-i+1)/i%M
  if not (i==a or i==b):
    SUM+=now%M
    



print(int(SUM%M))

Fixed submission:
n, a, b=map(int, input().split())
mod = 10 ** 9 + 7 
def cmb(n, r, mod):
    r = min(r, n -r)
    if r == 0: return 1
    over, under = 1, 1
    for i in range(1, r+1):
        over = over * (n-i+1) % mod
        under = under * i % mod
    
    inv=pow(under, mod-2, mod)
    
    return over*inv % mod
  
print((pow(2,n,mod)-1 - cmb(n, a,mod)-cmb(n,b,mod))%mod)
Buggy python submission (verdict: Runtime Error):
S,T=map(lambda x: x, input().split())
A,B=int(input().split())
U=input()
L=[(S,A),(T,B)]
for l in L:
  x,y=l
  if x==U:
    print(y-1, end=" ")
  else:
    print(y, end=" ")

Fixed submission:
S, T=input().split()

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

if U==S:
  A-=1
else:
  B-=1
print(A, B)
Buggy python submission (verdict: Runtime Error):
S=input()
S=list(S)
for i in len(S):
  print("x", end="")

Fixed submission:
S=input()
S=list(S)
for i in range(len(S)):
  print("x", end="")
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
K=int(input())
import sys
sys.setrecursionlimit(10**6)
def solve(N, K):
    if K==1:
        l=len(str(N))
        ans=0
        for i in range(l):
            if i!=l-1:
                ans+=9
            else:
                ans+=int(str(N)[0])
        #print(ans)
        return ans
    else:
        nextK=K-1
        l=len(str(N))
        ini=int(str(N)[0])
        res=ini*(10**(l-1))-1
        #print(res)
        if l>=K:
            ans=solve(res, K)
        else:
            ans=0
        if l-1>=nextK:
            nextN=int(str(N)[1:])
            ans+=solve(nextN, nextK)
            return ans
        return ans
ans=solve(N,K)
print(ans)

Fixed submission:
N=int(input())
K=int(input())
import sys
sys.setrecursionlimit(10**6)
def solve(N, K):
    if K==1:
        l=len(str(N))
        ans=0
        for i in range(l):
            if i!=l-1:
                ans+=9
            else:
                ans+=int(str(N)[0])
        #print(ans)
        return ans
    else:
        nextK=K-1
        l=len(str(N))
        ini=int(str(N)[0])
        res=ini*(10**(l-1))-1
        #print(res)
        if l>=K:
            ans=solve(res, K)
            nextN=int(str(N)[1:])
            ans+=solve(nextN, nextK)
            return ans
        else:
            return 0
ans=solve(N,K)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
K=int(input())
import sys
sys.setrecursionlimit(10**6)
def solve(N, K):
    if K==1:
        l=len(str(N))
        ans=0
        for i in range(l):
            if i!=l-1:
                ans+=9
            else:
                ans+=int(str(N)[0])
        #print(ans)
        return ans
    else:
        nextK=K-1
        l=len(str(N))
        ini=int(str(N)[0])
        res=ini*(10**(l-1))-1
        #print(res)
        if l>=K:
            ans=solve(res, K)
            nextN=int(str(N)[1:])
            ans+=solve(nextN, nextK)
            return ans
        else:
            return 0
ans=solve(N,K)
print(ans)

Fixed submission:
N=int(input())
K=int(input())
import sys
sys.setrecursionlimit(10**6)
def solve(N, K):
    if K==1:
        l=len(str(N))
        ans=0
        for i in range(l):
            if i!=l-1:
                ans+=9
            else:
                ans+=int(str(N)[0])
        #print(ans)
        return ans
    else:
        nextK=K-1
        l=len(str(N))
        ini=int(str(N)[0])
        res=ini*(10**(l-1))-1
        #print(res)
        if l>=K:
            ans=solve(res, K)
            nextN=int(str(N)[1:])
            ans+=solve(nextN, nextK)
            return ans
        else:
            return 0
ans=solve(N,K)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K=map(int, input().split())
H=list(map(int, input().split()))

if N<=K:
  print(0)
elif K==0:
  print(sum(H))
else:
  for i in range(K):
    
    maxh=max(H)
    H.remove(maxh)
    
  print(sum(H))



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

if N<=K:
  print(0)
elif K==0:
  print(sum(H))
else:
  H=sorted(H)
  print(sum(H[:len(H)-K]))

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

if N<=K:
  print(0)
elif K==0:
  print(sum(H))
else:
  for i in range(K):
    maxh=max(H)
    H=H.remove(maxh)
  print(sum(H))




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

if N<=K:
  print(0)
elif K==0:
  print(sum(H))
else:
  H=sorted(H)
  print(sum(H[:len(H)-K]))

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

if N<=K:
  print(0)
else:
  for i in range(K):
    maxh=max(H)
    H=H.remove(maxh)
  print(sum(H))




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

if N<=K:
  print(0)
elif K==0:
  print(sum(H))
else:
  H=sorted(H)
  print(sum(H[:len(H)-K]))

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

if N<=K:
  print(0)
else:
  for i in range(K):
    maxh=max(H)
    H=H.remove(maxh)
  print(len(H))


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

if N<=K:
  print(0)
elif K==0:
  print(sum(H))
else:
  H=sorted(H)
  print(sum(H[:len(H)-K]))

Buggy python submission (verdict: Runtime Error):
N, K=map(int, innput().split())
H=list(map(int, input().split()))

if N<=K:
  print(0)
else:
  for i in range(K):
    maxh=max(H)
    H=H.remove(maxh)
  print(len(H))

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

if N<=K:
  print(0)
elif K==0:
  print(sum(H))
else:
  H=sorted(H)
  print(sum(H[:len(H)-K]))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
H,N=map(int, input().split())
M=[]
for i in range(N):
    a,b=map(int, input().split())
    M.append((a,b))

dp=[np.inf]*(H+1)
dp[0]=0
for i in range(1,H+1):
    sub=np.inf
    for j in range(N):
        a,b=M[j]
        if i-a>=0:
            sub=min(dp[i-a]+b,sub)
        else:
            sub=min(b,sub)
    dp[i]=sub

print(dp[H])
#print(dp)

Fixed submission:
import numpy as np
H, N=map(int, input().split())
A=[]
B=[]
for i in range(N):
  a,b=map(int, input().split())
  A.append(a)
  B.append(b)
A=np.array(A)
B=np.array(B)
#n番目を1回は使う時の魔力最小値
dp=np.zeros((H+A.max()))
for i in range(1,H+1):
  dp[i]=(dp[i-A]+B).min()
  

      
      
print(int(dp[H]))

Buggy python submission (verdict: Runtime Error):
import numpy as np
H, N=map(int, input().split())
A=[]
B=[]
for i in range(N):
  a,b=map(int, input().split())
  A.append(a)
  B.append(b)
A=np.array(A)
B=np.array(B)
#n番目を1回は使う時の魔力最小値
dp=np.zeros((H+1))
for i in range(1,H+1):
  dp[i]=(dp[i-A]+B).min()
  

      
      
print(int(dp[H]))

Fixed submission:
import numpy as np
H, N=map(int, input().split())
A=[]
B=[]
for i in range(N):
  a,b=map(int, input().split())
  A.append(a)
  B.append(b)
A=np.array(A)
B=np.array(B)
#n番目を1回は使う時の魔力最小値
dp=np.zeros((H+A.max()))
for i in range(1,H+1):
  dp[i]=(dp[i-A]+B).min()
  

      
      
print(int(dp[H]))
Buggy python submission (verdict: Runtime Error):
N=int(input())

M=[[0]*10 for _ in range(10)]

for i in range(1,N+1):
  S=str(i)
  M[int(S[0])][int(S[-1])]+=1
  
for i in range(10):
  for j in range(10):
    ans+=M[i][j]*M[j][i]
    
print(ans)

Fixed submission:
N=int(input())

M=[[0]*10 for _ in range(10)]
for i in range(1,N+1):
  S=str(i)
  f=int(S[0])
  b=int(S[-1])
  M[f][b]+=1
  
ans=0
for i in range(10):
  for j in range(10):
    ans+=M[i][j]*M[j][i]
    
print(ans)

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

M=[[0]*10 for _ in range(10)]
for i in range(1,N+1):
  S=str(i)
  f=int(S[0])
  b=int(S[-1])
  M[f][s]+=1
  
ans=0
for i in range(10):
  for j in range(10):
    ans+=M[i][j]*M[j][i]
    
print(ans)


Fixed submission:
N=int(input())

M=[[0]*10 for _ in range(10)]
for i in range(1,N+1):
  S=str(i)
  f=int(S[0])
  b=int(S[-1])
  M[f][b]+=1
  
ans=0
for i in range(10):
  for j in range(10):
    ans+=M[i][j]*M[j][i]
    
print(ans)

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

M=[[0]*10 for _ in range(10)]
for i in range(1,N+1):
  S=str(N)
  f=int(S[0])
  b=int(S[-1])
  M[f][s]+=1
  
ans=0
for i in range(10):
  for j in range(10):
    ans+=M[i][j]*M[j][i]
    
print(ans)


Fixed submission:
N=int(input())

M=[[0]*10 for _ in range(10)]
for i in range(1,N+1):
  S=str(i)
  f=int(S[0])
  b=int(S[-1])
  M[f][b]+=1
  
ans=0
for i in range(10):
  for j in range(10):
    ans+=M[i][j]*M[j][i]
    
print(ans)