Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

s = 'HAKUTYUMU' + input()


def check(s):
    next_s = s

    if s[-5:] == 'dream':
        next_s = s[:-5]
    if s[-7:] == 'dreamer':
        next_s = s[:-7]
    if s[-5:] == 'erase':
        next_s = s[:-5]
    if s[-6:] == 'eraser':
        next_s = s[:-6]

    if s == 'HAKUTYUMU':
        return True

    if s == next_s:
        return False

    return check(next_s)


if check(s):
    print('YES')
else:
    print('NO')


Fixed submission:
import sys
sys.setrecursionlimit(10000)

s = 'HAKUTYUMU' + input()


while s != 'HAKUTYUMU':
    next_s = s

    if s[-5:] == 'dream':
        next_s = s[:-5]
    if s[-7:] == 'dreamer':
        next_s = s[:-7]
    if s[-5:] == 'erase':
        next_s = s[:-5]
    if s[-6:] == 'eraser':
        next_s = s[:-6]

    if s == next_s:
        print('NO')
        exit()

    s = next_s

print('YES')

Buggy python submission (verdict: Runtime Error):
s = 'HAKUTYUMU' + input()


def check(s):
    next_s = s

    if s[-5:] == 'dream':
        next_s = s[:-5]
    if s[-7:] == 'dreamer':
        next_s = s[:-7]
    if s[-5:] == 'erase':
        next_s = s[:-5]
    if s[-6:] == 'eraser':
        next_s = s[:-6]

    if s == 'HAKUTYUMU':
        return True

    if s == next_s:
        return False

    return check(next_s)


if check(s):
    print('YES')
else:
    print('NO')


Fixed submission:
import sys
sys.setrecursionlimit(10000)

s = 'HAKUTYUMU' + input()


while s != 'HAKUTYUMU':
    next_s = s

    if s[-5:] == 'dream':
        next_s = s[:-5]
    if s[-7:] == 'dreamer':
        next_s = s[:-7]
    if s[-5:] == 'erase':
        next_s = s[:-5]
    if s[-6:] == 'eraser':
        next_s = s[:-6]

    if s == next_s:
        print('NO')
        exit()

    s = next_s

print('YES')

Buggy python submission (verdict: Runtime Error):
s = 'HAKUTYUMU' + input()


def check(s):
    next_s = s

    if s[-5:] == 'dream':
        next_s = s[:-5]
    if s[-7:] == 'dreamer':
        next_s = s[:-7]
    if s[-5:] == 'erase':
        next_s = s[:-5]
    if s[-6:] == 'eraser':
        next_s = s[:-6]

    if s == 'HAKUTYUMU':
        return True

    if s == next_s:
        return False

    return check(next_s)


if check(s):
    print('YES')
else:
    print('NO')


Fixed submission:
import sys
sys.setrecursionlimit(10000)

s = 'HAKUTYUMU' + input()


while s != 'HAKUTYUMU':
    next_s = s

    if s[-5:] == 'dream':
        next_s = s[:-5]
    if s[-7:] == 'dreamer':
        next_s = s[:-7]
    if s[-5:] == 'erase':
        next_s = s[:-5]
    if s[-6:] == 'eraser':
        next_s = s[:-6]

    if s == next_s:
        print('NO')
        exit()

    s = next_s

print('YES')
Buggy python submission (verdict: Runtime Error):
A=list(map(input().split()))
ans=sorted(A)
if ans==[5,5,7]:
  print('YES')
else:
  print('NO')

Fixed submission:
A=list(map(int,input().split()))
ans=sorted(A)
if ans==[5,5,7]:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = n*(n+1)*(n+2)//6
for i in range(n):
  a, b = map(int, input().split())
  if b < a:
    a, b = b, a
  ans -= a*(n-b+1)
print(ans)


Fixed submission:
n = int(input())
ans = n*(n+1)*(n+2)//6
for i in range(n-1):
  a, b = map(int, input().split())
  if b < a:
    a, b = b, a
  ans -= a*(n-b+1)
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = n*(n+1)*(n+2)//6
for i in range(n-1):
  a, b = map(int, input.split())
  ans -= a*(n-b+1)
print(ans)


Fixed submission:
n = int(input())
ans = n*(n+1)*(n+2)//6
for i in range(n-1):
  a, b = map(int, input().split())
  if b < a:
    a, b = b, a
  ans -= a*(n-b+1)
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = n*(n+1)*(n+2)//6
for i in range(n):
  a, b = map(int, input.split())
  ans -= a*(n-b+1)
print(ans)

Fixed submission:
n = int(input())
ans = n*(n+1)*(n+2)//6
for i in range(n-1):
  a, b = map(int, input().split())
  if b < a:
    a, b = b, a
  ans -= a*(n-b+1)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = list(map(int, input().split()))

L.sort
if sum(L[:-1]) > L[-1]
    ans = "Yes"
else: ans = "No"

print(ans)

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

L.sort()

if sum(L[:-1]) > L[-1]:
    ans = "Yes"
else: ans = "No"

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
for i in range(M//N, 0, -1):
    if M % i == 0:
        print(i)
        break

Fixed submission:
def div(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, M = map(int, input().split())
for i in reversed(div(M)):
    if i <= M//N:
        print(i)
        break
Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if a<b:
        temp = a
        a = b
        b = temp

    r = a%b
    
    while r>0:
        r = a%b
        a = b
        b = r
    
    return b

        

N, X = map(int, input().split())
x = list(map(int, input().split()))

x2 = [abs(i-X) for i in x]

D = x2[0]
for i in range(N-1):
    D = gcd(D, x2[i+1])

print(D)

Fixed submission:
def gcd(a, b):

	while b:

		a, b = b, a % b

	return a

N, X = map(int, input().split())
x = list(map(int, input().split()))

x2 = [abs(i-X) for i in x]

D = x2[0]
for i in range(N-1):
    D = gcd(D, x2[i+1])

print(D)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
x = list(map(int, input().split()))

dis = 300000000

for i in range(N-K+1):
    y = list(x[i:i+K])

    disl = abs(x[i]) + abs(x[i+K-1]-x[i])
    disr = abs(x[i+K-1]) + abs(x[i+K-1]-x[i])

    dis = min(dis, disl, disr)
#    if (y[0]*y[-1]<0):
#        disy = y[-1]-y[0]+min(abs(y[-1]), abs(y[0]))
#    else:
#        disy = max(abs(y[0]), abs(y[-1]))
#    dis = min(dis, disy)

print(dis)

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

dis = 300000000

for i in range(N-K+1):
    disl = abs(x[i]) + abs(x[i+K-1]-x[i])
    disr = abs(x[i+K-1]) + abs(x[i+K-1]-x[i])

    dis = min(dis, disl, disr)
#    if (y[0]*y[-1]<0):
#        disy = y[-1]-y[0]+min(abs(y[-1]), abs(y[0]))
#    else:
#        disy = max(abs(y[0]), abs(y[-1]))
#    dis = min(dis, disy)

print(dis)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, K = map(int, input().split())
x = list(map(int, input().split()))

dis = 300000000

for i in range(N-K+1):
    y = list(x[i:i+K])
    if (y[0]*y[-1]<0):
        disy = y[-1]-y[0]+min(abs(y[-1]), abs(y[0]))
    else:
        disy = max(abs(y[0]), abs(y[-1]))
    dis = min(dis, disy)

print(dis)

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

dis = 300000000

for i in range(N-K+1):
    disl = abs(x[i]) + abs(x[i+K-1]-x[i])
    disr = abs(x[i+K-1]) + abs(x[i+K-1]-x[i])

    dis = min(dis, disl, disr)
#    if (y[0]*y[-1]<0):
#        disy = y[-1]-y[0]+min(abs(y[-1]), abs(y[0]))
#    else:
#        disy = max(abs(y[0]), abs(y[-1]))
#    dis = min(dis, disy)

print(dis)
Buggy python submission (verdict: Runtime Error):
s = input()
K = int(input())

n = len(s)

sub = []
alp = [chr(i) for i in range(ord('a'), ord('z')+1)]

for a in alp:
    if a in s:
        start = -1
        while True:
            start = s.find(a, start+1)
            if start==-1:
                break
            for j in range(start+1, min(start+K,n+1)):
                if s[start:j] not in sub:
                    sub.append(s[start:j])
    if len(sub) > K:
        break

sub.sort()
print(sub[K-1])

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

n = len(s)

sub = []
alp = [chr(i) for i in range(ord('a'), ord('z')+1)]

for a in alp:
    if a in s:
        start = -1
        while True:
            start = s.find(a, start+1)
            if start==-1:
                break
            for j in range(start+1, min(start+K+1,n+1)):
                if s[start:j] not in sub:
                    sub.append(s[start:j])
    if len(sub) > K:
        break

sub.sort()
print(sub[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())

n = len(s)

sub = []
alp = [chr(i) for i in range(ord('a'), ord('z')+1)]

for a in alp:
    if a in s:
        start = -1
        while True:
            start = s.find(a, start+1)
            if start==-1:
                break
            for j in range(start+1, n+1):
                if s[start:j] not in sub:
                    sub.append(s[start:j])
    if len(sub) > K:
        break

sub.sort()
print(sub[K-1])

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

n = len(s)

sub = []
alp = [chr(i) for i in range(ord('a'), ord('z')+1)]

for a in alp:
    if a in s:
        start = -1
        while True:
            start = s.find(a, start+1)
            if start==-1:
                break
            for j in range(start+1, min(start+K+1,n+1)):
                if s[start:j] not in sub:
                    sub.append(s[start:j])
    if len(sub) > K:
        break

sub.sort()
print(sub[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())

n = len(s)
sub = []
for i in range(n):
    for j in range(i+1, n+1):
        if s[i:j] not in sub:
            sub.append(s[i:j])
sub.sort()
print(sub[K-1])

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

n = len(s)

sub = []
alp = [chr(i) for i in range(ord('a'), ord('z')+1)]

for a in alp:
    if a in s:
        start = -1
        while True:
            start = s.find(a, start+1)
            if start==-1:
                break
            for j in range(start+1, min(start+K+1,n+1)):
                if s[start:j] not in sub:
                    sub.append(s[start:j])
    if len(sub) > K:
        break

sub.sort()
print(sub[K-1])
Buggy python submission (verdict: Runtime Error):
S = input()

def check(s):
    n = len(s)
    if n%2 != 0:
        return False
    else:
        s1 = s[:(n//2)]
        s2 = s[(n//2):]
        if s1 == s2:
            return True
        else:
            return False

for i in range(len(S)-1, 0, -2):
    if check(S[:i]):
        ans = len(S[:i])
        break

print(ans)

Fixed submission:
S = input()

def check(s):
    n = len(s)
    if n%2 != 0:
        return False
    else:
        s1 = s[:(n//2)]
        s2 = s[(n//2):]
        if s1 == s2:
            return True
        else:
            return False

for i in range(len(S)-1, 0, -1):
    if check(S[:i]):
        ans = len(S[:i])
        break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def digit(n):
    ans = 0
    while n > 0:
        ans += 1
        n //= 10
    return ans

N = int(input())

check = 100
for i in range(1, 1+N):
    if N % i != 0:
        continue
    if N // i < i:
        break
    j = N // i
    f = max(digit(i), digit(j))
    check = min(check, f)

print(check)

Fixed submission:
def digit(n):
    ans = 0
    while n > 0:
        ans += 1
        n //= 10
    return ans

N = int(input())

check = 100
for i in range(1, int(1e6)):
    if N % i != 0:
        continue
    if N // i < i:
        break
    j = N // i
    f = max(digit(i), digit(j))
    check = min(check, f)

print(check)
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

ans = 0
for i in range(0, K+1):
    for j in range(0, K+1):
        for k in range(0, K+1):
            if i + j + k == S:
                ans += 1

print(ans)

Fixed submission:
K, S = map(int, input().split())

ans = 0
for i in range(0, K+1):
    for j in range(0, K+1):
        if 0 <= (S-i-j) <= K:
            ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
print(max(a*c, a*d, b*c, b*d))


Fixed submission:
N = int(input())
ans = N*(N-1)
mod = 10**9 + 7
ans %= mod
ans = 1
A = 1
B = 1
C = 1
for i in range(N):
    A *= 10
    B *= 9
    C *= 8
    A %= mod
    B %= mod
    C %= mod

print((A-B*2+C) % mod)
Buggy python submission (verdict: Time Limit Exceeded):

def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    A = list(map(int, input().split()))

    d = dict()
    for x in A:
        if x in d:
            d[x] += 1
        else:
            d[x] = 1
    A.sort()

    ans = 0
    dp = [True]*N

    for i in range(N):
        if dp[i]:
            if d[A[i]] == 1:
                ans += 1
            dp[i] = False
            for j in range(i+1, N):
                if dp[j]:
                    if A[j] % A[i] == 0:
                        dp[j] = False
        else:
            continue

    print(ans)


main()


Fixed submission:

def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    A = list(map(int, input().split()))

    d = dict()
    for x in A:
        if x in d:
            d[x] += 1
        else:
            d[x] = 1
    A.sort()

    ans = 0
    M = max(A)
    dp = [True]*(M+1)
    for x in A:
        for xx in range(x+x, M+1, x):
            dp[xx] = False
    for x in A:
        if d[x] == 1 and dp[x]:
            ans += 1
    print(ans)


main()

Buggy python submission (verdict: Time Limit Exceeded):

def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    A = list(map(int, input().split()))

    d = dict()
    for x in A:
        if x in d:
            d[x] += 1
        else:
            d[x] = 1
    A = set(A)

    ans = 0
    while(A):
        x = min(A)
        if d[x] == 1:
            ans += 1
        next = set()
        for y in A:
            if y % x != 0:
                next.add(y)
        A = set()
        A |= next

    print(ans)


main()


Fixed submission:

def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    A = list(map(int, input().split()))

    d = dict()
    for x in A:
        if x in d:
            d[x] += 1
        else:
            d[x] = 1
    A.sort()

    ans = 0
    M = max(A)
    dp = [True]*(M+1)
    for x in A:
        for xx in range(x+x, M+1, x):
            dp[xx] = False
    for x in A:
        if d[x] == 1 and dp[x]:
            ans += 1
    print(ans)


main()
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))

# 計算はimos法でできそう
# O(N*K)になってしまう
for _ in range(K):
    tmp = [0] * (N+1)
    for i in range(N):
        tmp[max(0, i-A[i])] += 1
        tmp[min(N-1, i+A[i]) + 1] -= 1

    ans = [0]*N
    A[0] = tmp[0]
    for i in range(1, N):
        A[i] = A[i-1] + tmp[i]

    # print(*A)
    if sum(A) == N*N:
        break
print(*A)


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

for _ in range(K):
    tmp = [0] * (N+1)
    for i in range(N):
        tmp[max(0, i-A[i])] += 1
        tmp[min(N-1, i+A[i]) + 1] -= 1

    ans = [0]*N
    A[0] = tmp[0]
    for i in range(1, N):
        A[i] = A[i-1] + tmp[i]

    # print(*A)
    if sum(A) == N*N:
        break
print(*A)
Buggy python submission (verdict: Runtime Error):
A, B = map(int(input().split()))
print(A*B)


Fixed submission:
A, B = map(int, input().split())
print(A*B)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range(N):
    ans *= A[i]
if ans > 10**18:
    ans = -1
print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = 1
A.sort()
if A[0] == 0:
    print(0)
else:
    for i in range(N):
        ans *= A[i]
        if ans > 10**18:
            print(-1)
            exit(0)
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())
l = -1
r = N
# ans = 0
# for i in range(1, N+1):
#     ans = max(ans, (A*i)//B - (A*(i//B)))
ans2 = (A*N)//B - (A*(N//B))
for i in range(B-1, N, B):

    ans2 = max(ans2, (A*i)//B - (A*(i//B)))
print(ans2)


Fixed submission:
A, B, N = map(int, input().split())
l = -1
r = N
# ans = 0
# for i in range(1, N+1):
#     ans = max(ans, (A*i)//B - (A*(i//B)))
k = min(B-1, N)
ans2 = (A*k)//B - (A*(k//B))

print(ans2)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())
l = -1
r = N
# ans = 0
# for i in range(1, N+1):
#     ans = max(ans, (A*i)//B - (A*(i//B)))
ans2 = 0
for i in range(B-1, N+B, B):
    if i >= N:
        i = N
    ans2 = max(ans2, (A*i)//B - (A*(i//B)))

print(ans2)


Fixed submission:
A, B, N = map(int, input().split())
l = -1
r = N
# ans = 0
# for i in range(1, N+1):
#     ans = max(ans, (A*i)//B - (A*(i//B)))
k = min(B-1, N)
ans2 = (A*k)//B - (A*(k//B))

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

s = (1+N)*N // 2
if N >= 3:
    s1 = ((3 + (N//3)*3) * (N//3)) // 2
if N >= 5:
    s2 = ((5 + (N//5)*5) * (N//5)) // 2
if N >= 15:
    s3 = ((15 + (N//15)*15) * (N//15)) // 2
print(s + s3 - s1 - s2)


Fixed submission:
N = int(input())

s = (1+N)*N // 2
s1 = 0
s2 = 0
s3 = 0
if N >= 3:
    s1 = ((3 + (N//3)*3) * (N//3)) // 2
if N >= 5:
    s2 = ((5 + (N//5)*5) * (N//5)) // 2
if N >= 15:
    s3 = ((15 + (N//15)*15) * (N//15)) // 2
print(s + s3 - s1 - s2)
Buggy python submission (verdict: Runtime Error):
N = int(input())
tmp = [i for i in range(1, 10)]
ans = list(tmp)
for i in range(10):
    tmp2 = []
    for x in tmp:
        k = int(str(x)[-1])
        if k != 0:
            ans.append(10*x-1 + k)
            tmp2.append(10*x-1 + k)
        if k != 9:
            tmp2.append(10*x+1 + k)
            ans.append(10*x+1 + k)
        tmp2.append(10*x + k)
        ans.append(10*x + k)
    tmp = list(tmp2)

ans.sort()
print(ans[N-1])


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

print(min(N % K, K - N % K))
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, S = map(int, input().split())
    A = list(map(int, input().split()))
    s = [0]*(N+1)
    for i in range(N):
        s[i+1] = s[i] + A[i]
    mod = 998244353
    ans = 0
    # for i in range(N):
    #     for j in range(i+1, N+1):
    #         if s[j] - s[i] == S:
    #             left = i+1
    #             right = N - j + 1
    #             ans += left*right % mod
    #             print(left, right, i, j)
    # print(ans % mod)

    dp = [[0, dict()] for i in range(S+1)]
    dp[0][0] = 1

    for j, a in enumerate(A):
        for i in range(S-1, -1, -1):
            if dp[i][0] > 0 and i+a <= S:
                dp[i+a][0] += dp[i][0]
                if i == 0:
                    dp[i+a][1][((j, j))] = 1
                else:
                    for l, r in dp[i][1]:

                        ll = min(l, j)
                        rr = max(r, j)
                        if (ll, rr) in dp[i+a][1]:
                            dp[i+a][1][(ll, rr)] += dp[i][1][(l, r)]
                        else:
                            dp[i+a][1][(ll, rr)] = dp[i][1][(l, r)] % mod

    for l, r in dp[S][1]:
        ans += (l+1) * (N - r) * dp[S][1][l, r]
        ans %= mod
    print(ans)


main()


Fixed submission:
def main():
    N, S = map(int, input().split())
    A = list(map(int, input().split()))
    mod = 998244353
    ans = 0
    dp = [0]*S

    for i, a in enumerate(A):
        if a > S:
            continue
        dp[0] = i+1
        ans += dp[S-a]*(N-i)

        for j, x in enumerate(dp[:S-a]):
            dp[j+a] += x
    print(ans % mod)


main()
Buggy python submission (verdict: Time Limit Exceeded):
def cmb(n, r):
    if n - r < r:
        r = n - r
    if r == 0:
        return 1
    if r == 1:
        return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


def binary(n):
    return bin(n)[2:]


def pow_by_binary_exponentiation(a, x, n):  # a^x mod n
    x = [int(b) for b in binary(x)]
    y = a
    for i in range(1, len(x)):
        y = (y**2) % n
        if x[i] == 1:
            y = (y * a) % n
    return y


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

mod = 10**9 + 7
A = pow_by_binary_exponentiation(2, n, mod) - 1

A -= cmb(n, a) % mod
A -= cmb(n, b) % mod
print(A % mod)


Fixed submission:

def binary(n):
    return bin(n)[2:]


def pow_by_binary_exponentiation(a, x, n):  # a^x mod n
    x = [int(b) for b in binary(x)]
    y = a
    for i in range(1, len(x)):
        y = (y**2) % n
        if x[i] == 1:
            y = (y * a) % n
    return y


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

mod = 10**9+7
fact = [1]
fact_inv = [1]
for i in range(max(a, b)):
    new_fact = fact[-1]*(i+1) % mod
    fact.append(new_fact)


def mod_comb_k(n, k, mod):
    ret = 1
    for i in range(k):
        ret *= (n-i)
        ret %= mod
    return ret * pow(fact[k], mod-2, mod) % mod


A = pow_by_binary_exponentiation(2, N, mod) - 1

A -= mod_comb_k(N, a, mod)
A -= mod_comb_k(N, b, mod)
print(A % mod)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = set(list(map(Int, input().split())))
if len(A) == N:
    print("YES")
else:
    print("NO")


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


table = collections.defaultdict(int)
for x in A:
    table[x] += 1
    if table[x] > 1:
        print("NO")
        exit(0)
print("YES")
Buggy python submission (verdict: Time Limit Exceeded):

def main():
    H, N = map(int, input().split())
    AB = [tuple(map(int, input().split())) for i in range(N)]

    dp = [-1]*(H+1)
    dp[H] = 0

    for i in range(H, 0, -1):
        for a, b in AB:

            if dp[i] >= 0:
                next = max(i-a, 0)
                if dp[next] < 0:
                    dp[next] = dp[i] + b
                else:
                    if dp[next] > dp[i] + b:
                        dp[next] = dp[i] + b

    print(dp[0])
main()

Fixed submission:
import math
import sys
input = sys.stdin.readline
H, N = map(int, input().split())
AB = [tuple(map(int, input().split())) for i in range(N)]

dp = [[10**10, 0] for i in range(H+1)]
dp[0][0] = 0
# i 減らすのに最小で必要なMP

for i in range(1, H+1):
    if dp[i-1][1] > 0:
        dp[i][0] = dp[i-1][0]
        dp[i][1] = dp[i-1][1] - 1
    else:
        for A, B in AB:
            if A > i:
                if dp[i][0] > B:
                    dp[i][0] = B
                    dp[i][1] = A - i
            else:
                if dp[i][0] > dp[i - A][0] + B:
                    dp[i][0] = dp[i-A][0] + B
                    dp[i][1] = dp[i-A][1] + A - i

print(dp[H][0])

Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
input = sys.stdin.readline
H, N = map(int, input().split())
AB = [tuple(map(int, input().split())) for i in range(N)]

dp = [[10**10, 0] for i in range(H+1)]
dp[0][0] = 0
# i 減らすのに最小で必要なMP

for i in range(1, H+1):
    if dp[i-1][1] > 0:
        dp[i][0] = dp[i-1][0]
        dp[i][1] = dp[i-1][1] - 1
    else:
        for A, B in AB:
            if A > i:
                if dp[i][0] > B:
                    dp[i][0] = B
                    dp[i][1] = A - i
            else:
                if dp[i][0] > dp[i - A][0] + B:
                    dp[i][0] = dp[i-A][0] + B
                    dp[i][1] = dp[i-A][1] + A - i

print(dp[H][0])


Fixed submission:
import math
import sys
input = sys.stdin.readline
H, N = map(int, input().split())
AB = [tuple(map(int, input().split())) for i in range(N)]

dp = [[10**10, 0] for i in range(H+1)]
dp[0][0] = 0
# i 減らすのに最小で必要なMP

for i in range(1, H+1):
    if dp[i-1][1] > 0:
        dp[i][0] = dp[i-1][0]
        dp[i][1] = dp[i-1][1] - 1
    else:
        for A, B in AB:
            if A > i:
                if dp[i][0] > B:
                    dp[i][0] = B
                    dp[i][1] = A - i
            else:
                if dp[i][0] > dp[i - A][0] + B:
                    dp[i][0] = dp[i-A][0] + B
                    dp[i][1] = dp[i-A][1] + A - i

print(dp[H][0])