Harryxun/stf_run huggingface dataset:
from heapq import heappop, heappush 
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    def dijkstra():
        inf = 10 ** 9
        visited = [[False]*(w+2) for _ in range(h+2)]

        dp = [[inf]*(w+2) for _ in range(h+2)]
        dp[xs][ys] = 0

        que = [(0, xs, ys, 0)]
        direction = [[-1, 0], [0, 1], [1, 0], [0, -1]]
        while que:
            cost, x, y, dirt = heappop(que)
            # if (x, y) == (xg, yg):
            #     ans = (dp[x][y] + k - 1)//k
            #     return ans

            if not visited[x][y]:
                for i in range(4):
                    nx, ny = x + direction[i][0], y + direction[i][1]
                    if field[nx][ny]:
                        if i == dirt:
                            if dp[nx][ny] > dp[x][y] + 1:
                                dp[nx][ny] = dp[x][y] + 1
                                heappush(que, (dp[nx][ny], nx, ny, i))
                        else:
                            if dp[nx][ny] > (dp[x][y] + k-1)//k*k + 1:
                                dp[nx][ny] = (dp[x][y] + k-1)//k*k + 1
                                heappush(que, (dp[nx][ny], nx, ny, i))
                visited[x][y] = True
        if dp[xg][yg] == inf
            return -1
        else:
            return (dp[xg][yg] + k - 1)//k


    h, w, k= map(int, input().split())
    xs, ys, xg, yg = map(int, input().split())
    field = [[False]*(w+2)]
    for _ in range(h):
        s = [False]
        s += [True if i == '.' else False for i in input()]
        s += [False]
        field.append(s)
    field.append([False]*(w+2))
    ans = dijkstra()
    print(ans)




if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
from collections import deque
def input(): return sys.stdin.readline().rstrip()

def main():
    
    h, w, k = map(int, input().split())
    xs, ys, xg, yg = map(lambda x: int(x)-1, input().split())
    field = [input() for _ in range(h)]

    inf = 1e7

    dist = [[inf]*w for _ in range(h)]
    dist[xs][ys] = 0
    que = deque([(xs, ys)])
    dx = [-1, 0, 1, 0]
    dy = [0, 1, 0, -1]
    while que:
        x, y = que.popleft()
        for i in range(4):
            nx, ny = x, y
            for _ in range(k):
                nx += dx[i]
                ny += dy[i]
                if nx < 0 or nx >= h or ny < 0 or ny >= w: break
                if field[nx][ny] == '@' or dist[nx][ny] <= dist[x][y]: break
                if dist[nx][ny] > dist[x][y] + 1:
                    dist[nx][ny] = dist[x][y] + 1
                    que.append((nx, ny))
        
    if dist[xg][yg] == inf:
        print(-1)
    else:
        print(dist[xg][yg])
    
if __name__ == '__main__':
    main()
N,M = map(int,input().split())
info = [list(map(int,input().split())) for i in range(M)]

def root(x):
    # ノードが負 <=> xは根
    if nodes[x] < 0:
        return x
    else:
        parent = nodes[x]
        # 経路圧縮:再帰的に根を調べてその過程で通った要素は全て根に直接つなぎ直す
        nodes[x] = root(nodes[x])
        # 親の重みの累積和をとる. これがxを根に直接繋いだ時の重みになる
        weight[x] += weight[parent]
        return nodes[x]

def unite(x,y,w):
    root_x = root(x); root_y = root(y)
    #根ノードは木の高さを表す(負数で表していることに注意)
    rank_x = -nodes[root_x]; rank_y = -nodes[root_y]
    if rank_x >= rank_y:
        root_l = root_x; root_s = root_y
        l = x; s = y
    else:
        root_l = root_y; root_s = root_x
        l = y; s = x
        w *= -1
    # 繋いだ分だけ木を高くする
    nodes[root_l] += nodes[root_s]
    # 低い木を高い木に繋げる
    nodes[root_s] = root_l
    # 繋ぎ直す時の重みの変更
    weight[root_s] = w - weight[s] + weight[l]

# 根が同じ->True
def same(x,y):
    return root(x) == root(y)

# xからyへの重み
def diff(x,y):
    return weight[y] - weight[x]

# ノードは-1で初期化, Nは頂点数
nodes = [-1]*N
# ウェイトは0で初期化, Nは頂点数
weight = [0]*N

ans = "Yes"

for L,R,D in info:
    L -= 1; R -= 1
    unite(L,R,D)

for L,R,D in info:
    L -= 1; R -= 1
    if diff(L,R) != D:
        ans = "No"
        break

print(ans)

### FIXED CODE ###

N,M = map(int,input().split())
info = [list(map(int,input().split())) for i in range(M)]
nodes = [i for i in range(N)]
rank = [0]*N
diff_weight = [0]*N

def root(x):
    if nodes[x] == x:
        return x
    root_x = root(nodes[x])
    diff_weight[x] += diff_weight[nodes[x]]
    nodes[x] = root_x
    return nodes[x]

def weight(x):
    root(x)
    return diff_weight[x]

def unite(x,y,w):
    w += weight(x); w -= weight(y)
    x = root(x); y = root(y)
    if x == y:
        return
    if rank[x] >= rank[y]:
        nodes[y] = x
        diff_weight[y] = w
        if rank[x] == rank[y]:
            rank[x] += 1
    else:
        nodes[x] = y
        diff_weight[x] = -w

def same(x,y):
    return root(x) == root(y)

def diff(x,y):
    return weight(y) - weight(x)

ans = "Yes"

for L,R,D in info:
    L -= 1; R -= 1
    if same(L,R):
        if diff(L,R) != D:
            ans = "No"
            break
    else:
        unite(L,R,D)

print(ans)
from collections import deque
n = int(input())
s = [input() for i in range(n)]
q = deque([0])
d = [float('inf')] * n
d[0] = 0
while q:
    p = q.popleft()
    for i, c in enumerate(s[p]):
        if c == '1' and d[i] == float('inf'):
            d[i] = d[p] + 1
            q.append(i)
m = 0
for i in range(n):
    if d[m] < d[i]:
        m = i
q = deque([m])
d = [float('inf')] * n
d[m] = 0
while q:
    p = q.popleft()
    for i, c in enumerate(s[p]):
        if c == '1':
            if d[i] == float('inf'):
                d[i] = d[p] + 1
                q.append(i)
            elif d[i] != d[p] + 1 and d[i] != d[p] - 1:
                print(-1)
                exit(1)
m = 0
for i in range(n):
    m = max(m, d[i])
print(m + 1)


### FIXED CODE ###

from collections import deque
n = int(input())
s = [input() for i in range(n)]
ans = -2
for k in range(n):
    q = deque([k])
    d = [float('inf')] * n
    d[k] = 0
    while q:
        flg = 0
        p = q.popleft()
        for i, c in enumerate(s[p]):
            if c == '1':
                if d[i] == float('inf'):
                    d[i] = d[p] + 1
                    q.append(i)
                elif d[i] != d[p] + 1 and d[i] != d[p] - 1:
                    flg = 1
                    break
        if flg:
            break
    if flg:
        continue
    for i in range(n):
        ans = max(ans, d[i])
print(ans + 1)
N = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(1,N+1):
    if p[i-1] != i:
        count += 1
    if count >2:
        print('NO')
        exit(0)
print('YES')

### FIXED CODE ###

A, B = map(int,input().split())
K = (A+B) 
if K % 2 == 0:
    print(K//2)
else:
    print('IMPOSSIBLE')
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,m,k = na()
mod = 998244353
aall = pow(m,n,mod)

p = n-k+1


def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**3*3
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

print(aall-cmb(n+p,p,mod))

### FIXED CODE ###

import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,m,k = na()
mod = 998244353


fact = [0] * 220000
invfact = [0] * 220000
 
fact[0] = 1
for i in range(1, 220000):
    fact[i] = fact[i-1] * i % mod
 
invfact[220000 - 1] = pow(fact[220000 - 1], mod-2, mod)
 
for i in range(220000 - 2, -1, -1):
    invfact[i] = invfact[i+1] * (i+1) % mod
 
def nCk(n, k):
    if k < 0 or n < k:return 0
    return fact[n] * invfact[k] * invfact[n-k] % mod
 
ans = 0

for i in range(k+1):
    ans += pow(m-1,n-i-1,mod)*nCk(n-1,i)

print(ans*m%mod)
x=input()
print(x*)


### FIXED CODE ###

x=int(input())
print(x*x*x)
import math
n=int(input())
a=[]
y=math.ceil(math.log(((n*25)/26)+1,26))
for i in range(y):
    a.append(n%(26**(i+1)))
    if(n%(26**(i+1))!=0):
       n=n-n%(26**(i+1))
    else:
        n=n-26**(i+1)
a.reverse()
#print(a,y)
q=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']    
for i in range(y):
    print(q[a[i]-1],end="")

### FIXED CODE ###

n=int(input())
s='zabcdefghijklmnopqrstuvwxy'
a=''
while(int(n)>0):
        t=n%26
        if t==0:
            n-=26
        a=s[t]+a
        n=n//26
print(a)
S = int(input())

x2 = 10**9
y2 = 1

quotient = S//(10**9)
mod = S%(10**9)

if mod != 0:
    x3 = quotient+1
    y3 = -(mod-10**9)
else:
    x3 = quotient
    y3 = mod
    
print(f"0 0 {x2} {y2} {x3} {y3}")

### FIXED CODE ###

S = int(input())

x2 = 1
y2 = 10**9

quotient = S//(10**9)
mod = S%(10**9)

if mod != 0:
    x3 = quotient+1
    y3 = -(mod-10**9)
else:
    x3 = quotient
    y3 = mod
    
print(" ".join(map(str,[0,0,x2,y2,x3,y3])))
#最大公約数
def gcd(a,b):
    while b!=0:
        a,b = b, a%b
    return a

#最小公倍数
def lcm(a,b):
    return a*b //gcd(a,b)

n,m = map(int,input().split())
s = input()
t = input()

l = lcm(n,m)
txt = ['.']*l
res = l
for i in range(n):
    txt[i*(l//n)] = s[i]
for i in range(m):
    if (txt[i*(l//m)]!='.'):
        if (txt[i*(l//m)]!=t[i]):
            res = -1
            break
print(res)

### FIXED CODE ###

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)
 
n,m = map(int,input().split())
s = input()
t = input()

l = lcm(n,m)
gaps = l//m
gapt = l//n

i,j = 0,0
while i<n:
    if s[i]!=t[j]:
        print(-1)
        break
    else:
        i += gaps
        j += gapt
else:
    print(l)
N,M=list(map(int,input_[0].split()))
l=1
r=N
for m in range(M):
    l_,r_ = list(map(int,input_[1+m].split()))
    l = max(l,l_)
    r = min(r,r_)
    
ans = r-l+1

print(ans)

### FIXED CODE ###

N,M=list(map(int,input().split()))
l=1
r=N
for m in range(M):
    l_,r_ = list(map(int,input().split()))
    l = max(l,l_)
    r = min(r,r_)
    
ans = r-l+1

if ans<0:
    ans=0
print(ans)
from functools import reduce
from operator import mul

mod = 10**9 + 7

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

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

if N == K:
    print(reduce(mul, A)%mod)

else:

    AP = []
    AM = []
    for i in A:
        if i < 0:
            AM.append(i)
        else:
            AP.append(i%mod)
            
    if len(AP) == 0 and K%2 != 0:
        AM.sort(reverse=True)
        AM = AM[:K]
        print(reduce(mul, AM)%mod)

    else:
        
        AP.sort(reverse=True)
        AM.sort()
        
        ans = 1
        p = 0
        m = 0
        cnt = 0
        while True:
            if (K - cnt) == 1:
                ans *= AP[p]
                print(ans%mod)
                break
                
            elif 2 <= (len(AM) - m) and 2 <= (len(AP) - p):   
                if AP[p]*AP[p+1] >= AM[m]*AM[m+1]:
                    ans *= (AP[p]*AP[p+1])%mod
                    p += 2
                    cnt += 2
                
                else:
                    ans *= (AM[m]*AM[m+1])%mod
                    m += 2
                    cnt += 2 
                    
            elif 1 >= (len(AP) - p) and 2 <= (len(AM) - m):
                ans *= (AM[m]*AM[m+1])%mod
                m += 2
                cnt += 2 
            
            elif 2 <= (len(AP) - p) and 1 >= (len(AM) - m):
                ans *= (AP[p]*AP[p+1])%mod
                p += 2
                cnt += 2
            
            

            if cnt == K:
                print(ans%mod)
                break


### FIXED CODE ###

from bisect import bisect_left,bisect_right
p=10**9+7
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
pi=1
ni=0
ans=1
i=0
while i<k-1:
  if a[ni]*a[ni+1]>a[-pi]*a[-pi-1]:
    ans=ans*a[ni]*a[ni+1]%p
    ni+=2
    i+=2
  else:
    ans=ans*a[-pi]%p
    pi+=1
    i+=1
if i==k-1:
  ans=ans*a[-pi]%p
if a[-1]<0 and k%2==1:
  ans=1
  for i in a[n-k:]:
    ans=ans*i%p
print(ans)
N=int(input())
S=input()
if N%2==1:
  print('No')
else:
  h_N=int(N/2)
  flg=True
  for i in range(h_N):
    if S[i]!=S[h_N+i]:
      flg=False
  if flg=True:
    print('Yes')
  else:
    print('No')

### FIXED CODE ###

N=int(input())
S=str(input())
if N%2==1:
  print('No')
else:
  f=True
  h=int(N/2)
  for i in range(0,h):
    if S[i]!=S[h+i]:
      f=False
  if f==True:
    print('Yes')
  else:
    print('No')
nm = [0,31,29,31,30,31,30,31,31,30,31,30]
while True:
                                                                                                                                      
    m,d = map(int,raw_input().split(" "))

    if m == 0:
        break
    else:
        nd = 0 
        for i in range(m):
           nd += nm[i]

        nd += d
        n = nd%7
        if n == 1:
            print "Thursday"
        elif n == 2:
            print "Friday"
        elif n == 3:
            print "Saturday"
        elif n == 4:
            print "Sunday"
        elif n == 5:
            print "Monday"
        elif n == 6:
            print "Tuesday"
        else:
            print "Wednesday"
~                                                                                                                                     
~                                                           

### FIXED CODE ###

nm = [0,31,29,31,30,31,30,31,31,30,31,30]
while True:

    m,d = map(int,raw_input().split(" "))

    if m == 0:
        break
    else:
        nd = 0
        for i in range(m):
           nd += nm[i]

        nd += d
        n = nd%7
        if n == 1:
            print "Thursday"
        elif n == 2:
            print "Friday"
        elif n == 3:
            print "Saturday"
        elif n == 4:
            print "Sunday"
        elif n == 5:
            print "Monday"
        elif n == 6:
            print "Tuesday"
        else:                                                                                                                                                                                                
            print "Wednesday"
n,l=map(int,input().split())
s=sorted([input() for i in range(n)])
print(*s,sep="")

### FIXED CODE ###

a,b,c=sorted(map(int,input().split()))
print("YES" if a==b==5 and c==7 else "NO")
a = input()
if "RRR" in a:
  print(3)
elif "RR" in a:
  print(2)
elif "R" in a:
  print(1)
else:a
  print(0)


### FIXED CODE ###

a = input()
if "RRR" in a:
  print(3)
elif "RR" in a:
  print(2)
elif "R" in a:
  print(1)
else:
  print(0)
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
n=len(a)
j=0
k=0
for i in range(n):
    while j<n and b[j]<=a[i]:
        j+=1
    while k<n and c[k]<=b[j]:
        k+=1



### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a[i]-=(i+1)
median=-1
a.sort()
if n%2==0:
    median=(a[n//2]+a[n//2-1])//2
else:
    median=a[n//2]
def comp(x):
    su=0
    for i in a:
        su+=abs(i-x)
    return su
print(min(comp(median-1),comp(median),comp(median+1)))
from collections import deque

N, K = map(int, input().split())
T = [[] for i in range(N)]
E = []
for i in range(N-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    T[a].append(b)
    T[b].append(a)
    E.append((a, b))


def bfs(n):
    visited = [False] * N
    dist = [0] * N
    queue = deque([n])
    while queue:
        node = queue.pop()
        if visited[node]:
            continue
        visited[node] = True
        for n in T[node]:
            if not visited[n]:
                dist[n] = dist[node] + 1
                queue.appendleft(n)
    return dist


dist = []
for i in range(N):
    dist.append(bfs(i))

ans = float('inf')
if K % 2 == 0:
    # 全ての頂点について全探索
    for i in range(N):
        ans = min(ans, len([d for d in dist[i] if d > K / 2]))
else:
    # 全ての辺について全探索
    for a, b in E:
        adist = [(1 if min(d1, d2) > (K-1) / 2 else 0) for d1, d2 in zip(dist[a], dist[b])]
        ans = min(ans, sum(adist))

print(ans)


### FIXED CODE ###

N = int(input())
L = sorted(list(map(int, input().split())))
print(sum(L[::2]))
N = int(input())

def sum_10(n):
  return sum[int(l) for l in str(n)]

li=[]
for i in range(1,N//2 +1):
  for k in range(N-N//2,N+1):
    if i + k == N:
      li.append(sum_10(i)+sum_10(k))
print(min(li))      

### FIXED CODE ###

N = int(input())

def sum_10(n):
  return sum([int(l) for l in str(n)])

li=[]
for i in range(1,N//2 +1):
    if N - N//2 <= N - i <= N:
      li.append(sum_10(i)+sum_10(N - i))
print(min(li))
import numpy as np
A,B,N = map(int,input().split())

x= np.arange(0,N+1,1)
y1 = np.floor(A*x/B)
y2 = A*np.floor(x/B)
y3 = y1-y2

print(int(max(y3)))



### FIXED CODE ###

import math
A,B,N = map(int,input().split())

def f(x):
    v = math.floor(A*x/B)-A*math.floor(x/B)
    return v

if N>=B-1:
    print(f(B-1))
else:
    print(f(N))
l,r,d = list(map(int,input()split()))
print(r//d-(l-1)//d)

### FIXED CODE ###

l,r,d=list(map(int,input().split()))
print(r//d-(l-1)//d)
m = 100005
visited = [False]*(m*2)
cnt = [0,0]
def dfs(i):
    global cnt
    if visited[i]:
        return
    visited[i] = True
    cnt[i//m] = cnt[i//m] + 1
    for j in to[i]:
        dfs(j)


n = int(input())
to = [[] for i in range(m*2)]
for i in range(n):
    x,y = map(int,input().split())
    y = y+m
    to[x].append(y)
    to[y].append(x)

ans = 0
for i in range(m*2):
    cnt = [0,0]
    dfs(i)
    ans = ans + cnt[0]*cnt[1]

print(ans-n)

### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)

    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    def Count(self, x):
        return -self.root[self.Find_Root(x)]

m = 100010
uf = UnionFind(m*2)
n = int(input())
for i in range(n):
    x,y = map(int,input().split())
    y = y+m
    uf.Unite(x,y)

lx = {}
ly = {}
ans = 0
for i in range(m):
    rx = uf.Find_Root(i)
    lx[rx] = lx.get(rx,0)+1
    ry = uf.Find_Root(i+m)
    ly[ry] = ly.get(ry,0)+1
for i in range(m*2):
    ans += lx.get(i,0)*ly.get(i,0)

print(ans-n)
n,m = map(int,input().split())
if(n % 2 == 0):
    d = n // 2 - 1
    c = 0
    i = 1
    while(d >= 0):
        print(i,i+d)
        d -= 2
        i += 1
        c += 1
        if(c == m):exit()
    d = n // 2 - 2
    i = n // 2 + 1
    while(d >= 0):
        print(i,i+d)
        d -= 2
        i += 1
        c += 1
        if(c == m):exit()


else:
    raise ValueError("error!")
    for i in range(m):
        print(i+1,n-i)


### FIXED CODE ###

n,m = map(int,input().split())
if(n % 2 == 0):
    d = n // 2 - 1
    c = 0
    i = 1
    while(d > 0):
        print(i,i+d)
        d -= 2
        i += 1
        c += 1
        if(c == m):exit()
    d = n // 2 - 2
    i = n // 2 + 1
    while(d > 0):
        print(i,i+d)
        d -= 2
        i += 1
        c += 1
        if(c == m):exit()


else:
    for i in range(m):
        print(i+1,n-i)
n = int(input())
A = [int(i) for i in input().split()]

if A[0] < A[1]:
    flag = 1
elif A[0] > A[1]:
    flag = -1
else:
    flag = 0
    
cnt = 1
x = A[1]
for i in range(2, n):
    if flag == 1:
        if x <= A[i]:
            pass
        else:
            cnt += 1
            flag = 0
    if flag == -1:
        if x < A[i]:
            cnt += 1
            flag = 0
        else:
            pass
    else:
        if x < A[i]:
            flag = 1
        elif x > A[i]:
            flag = -1
        else:
            flag = 0
    x = A[i]
    
print(cnt)

### FIXED CODE ###

n = int(input())
A = [int(i) for i in input().split()]

if n == 1:
    cnt = 1
else:
    if A[0] < A[1]:
        flag = 1
    elif A[0] > A[1]:
        flag = -1
    else:
        flag = 0
    
    cnt = 1
    x = A[1]
    for i in range(2, n):
        if flag == 1:
            if x <= A[i]:
                pass
            else:
                cnt += 1
                flag = 0
                
        elif flag == -1:
            if x < A[i]:
                cnt += 1
                flag = 0
            else:
                pass
            
        else:
            if x < A[i]:
                flag = 1
            elif x > A[i]:
                flag = -1
            else:
                flag = 0
        #print('x', x, 'A[i]', A[i], 'flag', flag, 'cnt', cnt)
        x = A[i]
    
print(cnt)
n=int(input())
a=list(map(int,input().split()))
x=0
a.sort()
for i in range(n-1):
  if a[i]=a[i+1]:
    x+=1
if x=0:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
x=0
a.sort()
for i in range(n-1):
  if a[i]==a[i+1]:
    x+=1
if x==0:
  print("YES")
else:
  print("NO")
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
const ll mod = 1000000007;

using namespace std;

int n, m;
int s[2010], t[2010];
int dp[2010][2010];

signed main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int i = 0; i < m; i++) cin >> t[i];

    for (int i = 0; i <= 2009; i++) {
        for (int j = 0; j <= 2009; j++) {
            dp[i][j] = 1;
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
            dp[i][j] += mod - dp[i-1][j-1];
            if (s[i - 1] == t[j - 1]) dp[i][j] += dp[i - 1][j - 1];
            dp[i][j] %= mod;
        }
    }

    cout << dp[n][m] << endl;
}

// 共通部分列


### FIXED CODE ###

MOD = 10**9 + 7

n,m = (int(num) for num in input().split())
s = [int(num) for num in input().split()]
t = [int(num) for num in input().split()]

dp = [[1]*(m+1) for _ in range(n+1)]

for i in range(1,n+1):
    for j in range(1,m+1):
        dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]
        if s[i-1] == t[j-1]:
            dp[i][j] += dp[i-1][j-1]
        dp[i][j] = dp[i][j] % MOD
        
        
print(dp[n][m])
import math
import sys

input = sys.stdin.readline


def main():
    A, B, C, D = [int(i) for i in input().split()]
    # X : AとBの間の整数の数
    X = B - A + 1
    # Y : AとBの間でCの倍数の数
    Y = (B // C) - ((A - 1) // C)
    # Z : AとBの間でDの倍数の数
    Z = (B // D) - ((A - 1) // D)
    # V : CとDの最小公倍数
    V = (C * D) // math.gcd(C, D)
    # W : AとBの間でVの倍数の数
    W = (B // V) - ((A - 1) // V)
    print(X - Y - Z + W)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys

input = sys.stdin.readline


def gcd(*args):
    a = max(args)
    b = min(args)
    while b != 0:
        a, b = b, a % b
    return a


def main():
    A, B, C, D = [int(i) for i in input().split()]
    # X : AとBの間の整数の数
    X = B - A + 1
    # Y : AとBの間でCの倍数の数
    Y = (B // C) - ((A - 1) // C)
    # Z : AとBの間でDの倍数の数
    Z = (B // D) - ((A - 1) // D)
    # V : CとDの最小公倍数
    V = (C * D) // gcd(C, D)
    # W : AとBの間でVの倍数の数
    W = (B // V) - ((A - 1) // V)
    print(X - Y - Z + W)


if __name__ == "__main__":
    main()
n=int(input())
s=list(input() for _ in range(n))
m,o,f,both=0,0,0,0

for i in range(n):
    m +=s[i].count("AB")
    if s[i][0]=="B":
        o +=1
for i in range(n):
    if s[i][-1]=="A":
        f +=1
for i in range(n):
    if s[i][0]=="B" and s[i][-1]=="A":
        both+=1
        o-=1
        f-=1

if both!=0:
    if i!=0 and f!=0:
        print(m+both+min(o,f))
    else:
        print(m+both+min(o,f)-1)

else:
    print(m+min(o,f))



### FIXED CODE ###

n,k=list(map(int,input().split()))
print(n-k+1)