Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import itertools
from collections import Counter
N = int(input())
s = [input() for _ in range(N)]
comb = list(itertools.combinations(range(N), 2))

count=0
for i in range(len(comb)):
    if Counter(s[comb[i][0]].upper()) == Counter(s[comb[i][1]].upper()):
        count+=1
print(count)

### FIXED CODE ###

N = int(input())
s = [''.join(sorted(input())) for _ in range(N)]
dic = {}
count=0
for i in range(N):
    if s[i] in dic:
        dic[s[i]] = dic[s[i]] + 1
    else:
        dic.setdefault(s[i], 1)
for i in dic.values():
    if i > 1:
        count += i* (i - 1) // 2
print(count)
### BUGGY CODE ###

import scipy.sparse as sps
import scipy.sparse.csgraph as spsc
import numpy as np

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

S,T = map(int,input().split())
S,T = S-1,T-1

E = sps.dok_matrix((N,N),dtype=int)

adj = list(list() for _ in range(N))

def it():
  for _ in range(M):
    u,v,d = map(int,input().split())
    u,v = u-1,v-1
    adj[u].append((v,d))
    adj[v].append((u,d))
    yield ((u,v),d)
    yield ((v,u),d)
E.update(it())

dS,dT = spsc.dijkstra(E,directed=False, indices=[S,T])
D = dS[T]

V = dS+dT == D
MOD = 10**9+7

def helper(start, dist):
  import heapq as hq
  cnts = [0]*N
  cnts[start] = 1

  edges = []
  for u in range(N):
    if V[u]:
      for v,d in adj[u]:
        if V[v] and dist[v]-dist[u] == d:
          edges.append((dist[u],u,v))

  edges.sort()

  for _,u,v in edges:
    cnts[v] += cnts[u]
    cnts[v] %= MOD

  return cnts


Sn = helper(S,dS)
Tn = helper(T,dT)


c0 = 0
c1 = 0

for v in range(N):
  if V[v]:
    dv = dS[v]

    if dv*2 == D:
      c0 += Sn[v]*Tn[v]
      c0 %= MOD

    elif dv*2 < D:
      for u,d in adj[v]:
        du = dS[u]
        if V[u] and du*2 > D and du-dv == d:
          c1 += Sn[v]*Tn[u]
          c1 %= MOD

total = Sn[T]*Tn[S]
cnt = c0+c1

print((total-cnt)%MOD)


### FIXED CODE ###

from collections import defaultdict
from functools import reduce
import heapq as hq
from sys import stdin
 
MOD = 10**9+7
N,M = map(int,stdin.readline().split())
S,T = map(int,stdin.readline().split())
S,T = S-1,T-1
 
E = defaultdict(list)
lines = stdin.readlines()
for line in lines:
  u,v,d = map(int,line.split())
  E[u-1].append((v-1,d))
  E[v-1].append((u-1,d))
 
dS = [None]*N
dT = [None]*N
 
Q = [(0,S,False),(0,T,True)]
 
D = float('inf')
 
 
while Q:
  d,v,f = hq.heappop(Q)
  if d*2 > D:
    break

  dM = dT if f else dS
  dN = dS if f else dT
  if dM[v] is None:
    dM[v] = d
    for u,dd in E[v]:
      if dM[u] is None and (d+dd)*2 <= D:
        hq.heappush(Q,(d+dd,u,f))
 
  if dN[v] is not None:
    D = min(dN[v]+d,D)
 
del Q

def helper(start,dist):
  cnts = [0]*N
  cnts[start] = 1

  for d,v in sorted((d,v) for v,d in enumerate(dist) if d is not None):
    c = cnts[v]
    for u,dd in E[v]:
      if dd+d == dist[u]:
        cnts[u] = (cnts[u]+c) % MOD

  return cnts

Sn = helper(S,dS)
Tn = helper(T,dT)


def it():
  for v in range(N):
    if dS[v] is not None:
      ds = dS[v]
      if dT[v] == ds and ds*2 == D:
        yield Sn[v]*Tn[v] % MOD
      else:
        for u,d in E[v]:
          if dT[u] is not None and abs(dT[u]-ds) < d and ds+d+dT[u] == D:
            yield Sn[v]*Tn[u] % MOD


X = list(it())

 
total = reduce(lambda a,b:(a+b)%MOD, X,0)
total = total*total % MOD
 
sub = reduce(lambda a,b:(a+b)%MOD, map(lambda x: x*x % MOD, X),0)
print((total-sub)%MOD)
### BUGGY CODE ###

n = int(input())
s = []
for i in range(n):
    a = input()
    s.append(a)

sts = []
nums = []
for new_st in s:
    new_st = sorted([x for x in new_st])
    exist_in_sts = False
    for i in range(len(sts)):
        if (new_st == sts[i]):
            nums[i] += 1
            exist_in_sts = True
    if exist_in_sts == False:
        sts.append(new_st)
        nums.append(1)

print(sum([int(x * (x - 1) / 2) for x in nums]))

### FIXED CODE ###

n = int(input())
s = []
for i in range(n):
    s.append(input())

dictS = {}
for new_st in s:
    new_st = "".join(sorted([x for x in new_st]))
    if new_st in dictS:
        dictS[new_st] += 1
    else:
        dictS[new_st] = 1

ans = sum([int(x * (x - 1) / 2) for x in dictS.values()])
print(ans)
### BUGGY CODE ###

#16:41
h,w,k = map(int,input().split())
x1,y1,x2,y2 = map(lambda x:int(x)-1, input().split())
raw = []
for _ in range(h):
  raw.append(input())
inf = 10**6
seen = [[[inf for _ in range(4)] for _ in range(w)] for _ in range(h)]
seen[x1][y1] = [0,0,0,0]

dire = [[1,0],[-1,0],[0,1],[0,-1]]
def add(x,y,di,s):
  dx,dy = dire[di]
  if 0 <= x+dx < h and 0 <= y+dy < w:
    if raw[x+dx][y+dy] == '.' and seen[x+dx][y+dy][di] > s:
      now.append([s,x+dx,y+dy,di])
      seen[x+dx][y+dy][di] = s
def turn(x,y,di,s):
  dx,dy = dire[di]
  if seen[x][y][di] > s:
    nex.append([s,x,y,di])
    seen[x][y][di] = s

nex = [[0,x1,y1,d] for d in range(4)]
while nex:
  now = nex
  nex = []
  for i in range(k):
    last = now
    now = []
    for sxydi in last:
      s,x,y,di = sxydi
      if seen[x][y][di] < s:
        continue
      if x == x2 and y == y2:
        print(s)
        exit()
      add(x,y,di,s+1-int(bool(i)))
      for d in range(4):
        if di != d:
          turn(x,y,d,s)
  nex += now
print(-1)

### FIXED CODE ###

#16:41
h,w,k = map(int,input().split())
x1,y1,x2,y2 = map(lambda x:int(x)-1, input().split())
raw = []
for _ in range(h):
  raw.append(input())
inf = 10**6
seen = [[inf for _ in range(w)] for _ in range(h)]
seen[x1][y1] = 0
from heapq import heappush as push
from heapq import heappop as pop
now = [[0,x1,y1]]

while now:
  s,x,y = pop(now)
  if x == x2 and y == y2:
    print(s)
    exit()
  for i in range(1,k+1):
    if x-i == -1 or raw[x-i][y] == '@' or seen[x-i][y] < s+1:
      break
    if seen[x-i][y] != s+1:
      seen[x-i][y] = s+1
      push(now,[s+1,x-i,y])
  for i in range(1,k+1):
    if y-i == -1 or raw[x][y-i] == '@' or seen[x][y-i] < s+1:
      break
    if seen[x][y-i] != s+1:
      seen[x][y-i] = s+1
      push(now,[s+1,x,y-i])
  for i in range(1,k+1):
    if x+i == h or raw[x+i][y] == '@' or seen[x+i][y] < s+1:
      break
    if seen[x+i][y] != s+1:
      seen[x+i][y] = s+1
      push(now,[s+1,x+i,y])
  for i in range(1,k+1):
    if y+i == w or raw[x][y+i] == '@' or seen[x][y+i] < s+1:
      break
    if seen[x][y+i] != s+1:
      seen[x][y+i] = s+1
      push(now,[s+1,x,y+i])
print(-1)
### BUGGY CODE ###

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

ans = 0
for k in range(28, -1, -1):
    i_1, i_2, i_3 = 0, 0, 0
    T = 1<<k
    add = 0

    for i in range(n):
        a[i] %= 2*T
        b[i] %= 2*T

    a = sorted(a, reverse = True)
    b = sorted(b)
    for i in range(n):
        while i_1 < n and a[i]+b[i_1] < T:
            i_1 += 1
        while i_2 < n and a[i]+b[i_2] < 2*T:
            i_2 += 1
        while i_3 < n and a[i]+b[i_3] < 3*T:
            i_3 += 1
        add += (i_2-i_1) + (n-i_3)

    if add%2 == 1:
        ans += T

print(ans)


### FIXED CODE ###

# Greatly refered to the solution: https://atcoder.jp/contests/abc091/submissions/3549633
from sys import stdin
import numpy as np
ORD = 28

n = int(stdin.readline())
a = np.array(list(map(int, stdin.readline().split())))
b = np.array(list(map(int, stdin.readline().split())))

def search(a_, b_, pow2):
    c1 = np.searchsorted(a_, pow2 - b_)
    c2 = np.searchsorted(a_, 2*pow2 - b_)
    c3 = np.searchsorted(a_, 3*pow2 - b_)
    return n**2 - np.sum(c3) + np.sum(c2) - np.sum(c1)

a_ord = np.zeros((ORD, n), dtype = int)
b_ord = np.zeros((ORD, n), dtype = int)
for i in range(1, ORD+1):
    a_ord[i-1, :] = a%(2**i)
    b_ord[i-1, :] = b%(2**i)
a_ord = np.sort(a_ord, axis = 1)

ans = ''
for i in range(ORD):
    count = search(a_ord[i], b_ord[i], 2**i)
    ans += '0' if count%2 == 0 else '1'
    
count = search(a_ord[-1], b_ord[-1], 2**ORD)
ans += '0' if count%2 == 0 else '1'

print(int(ans[::-1], 2))
### BUGGY CODE ###

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

MOD = 10 ** 9 + 7

dp = [[0 for _ in range(m)] for _ in range(n)]
sd = [[0 for _ in range(m)] for _ in range(n)]

ans = 1

if s[0] == t[0]:
    dp[0][0] = 1
    sd[0][0] = 1
    ans += 1

for i in range(1, n):
    if s[i] == t[0]:
        dp[i][0] = 1
        ans += 1
    sd[i][0] = dp[i][0] + sd[i-1][0]

for j in range(1, m):
    if s[0] == t[j]:
        dp[0][j] = 1
        ans += 1
    sd[0][j] = dp[0][j] + sd[0][j-1]

for i in range(1, n):
    for j in range(1, m):
        if s[i] == t[j]:
            dp[i][j] = (sd[i-1][j-1] + 1) % MOD
            ans = (ans + dp[i][j]) % MOD
        sd[i][j] = (sd[i-1][j] + sd[i][j-1] - sd[i-1][j-1] + dp[i][j]) % MOD

print(ans)



### FIXED CODE ###

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

MOD = 10 ** 9 + 7

dp = [[0 for _ in range(m)] for _ in range(n)]
sd = [[0 for _ in range(m)] for _ in range(n)]

ans = 1

if s[0] == t[0]:
    dp[0][0] = 1
    sd[0][0] = 1
    ans += 1

for i in range(1, n):
    if s[i] == t[0]:
        dp[i][0] = 1
        ans += 1
    sd[i][0] = dp[i][0] + sd[i-1][0]

for j in range(1, m):
    if s[0] == t[j]:
        dp[0][j] = 1
        ans += 1
    sd[0][j] = dp[0][j] + sd[0][j-1]

for i in range(1, n):
    for j in range(1, m):
        if s[i] == t[j]:
            dp[i][j] = (sd[i-1][j-1] + 1) % MOD
            ans = (ans + dp[i][j]) % MOD
        sd[i][j] = (sd[i-1][j] + sd[i][j-1] - sd[i-1][j-1] + dp[i][j]) % MOD

print(ans)
### BUGGY CODE ###

from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix

N, M = map(int, input().split())
row = []
col = []
for i in range(M):
  u, v = map(int, input().split())
  u -= 1; v -= 1
  row.extend([3*u, 3*u+1, 3*u+2])
  col.extend([3*v+1, 3*v+2, 3*v])

d = [1] * (3*M)

graph = csr_matrix((d, (row, col)), shape=(3*N, 3*N))

S, T = map(int, input().split())
S -= 1; T -= 1
dist = dijkstra(graph, indices=3*S).astype(int)

if dist[3*T] > 0:
  print(dist[3*T] // 3)
else:
  print(-1)

### FIXED CODE ###

from collections import deque

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

graph = [[] for i in range(3*N)]
for i in range(M):
  u, v = map(int, input().split())
  u, v = 3*(u - 1), 3*(v - 1)
  graph[u].append(v+1)
  graph[u+1].append(v+2)
  graph[u+2].append(v)

s, t = map(int, input().split())
s, t = 3*(s - 1), 3*(t - 1)


dist = [10**9] * 3*N
dist[s] = 0
d = deque([s])
while d:
  node = d.popleft()
  children = graph[node]
  for child in children:
    if dist[child] > dist[node] + 1:
      d.append(child)
      dist[child] = dist[node] + 1

if dist[t] < 10**9:
  print(dist[t]//3)
else:
  print(-1)
### BUGGY CODE ###

a,b = map(int,input().split())
ans = 0
for i in range(a,b+1):
    ans ^= i
print(ans)

### FIXED CODE ###

a,b = map(int,input().split())
ans = 0
if a%2 == 0:
    for i in range(a,a+4):
        ans ^= i
        if i == 0:
            continue
        if ans == 0:
            break
    m = (b-i)%4
    for r in range(m):
        ans ^= b
        b -= 1
else:
    ans = a
    m = (b-a)%4
    for r in range(m):
        ans ^= b
        b -= 1
print(ans)
### BUGGY CODE ###

import sys
from bisect import bisect_left as bl
input = sys.stdin.readline
N = int(input())
a = list(map(int,input().split()))
cs = [0] * N
cs[0] = a[0]
for i in range(N - 1): cs[i + 1] = cs[i] + a[i + 1]
#print(cs)
def solve(m):
  l = bl(cs[: m], cs[m] // 2)
  r = bl(cs[m: ], cs[m] + (cs[-1] - cs[m]) // 2) + m
  l -= l == m
  r += r == m
  nl = l + 0
  nr = r + 0
  for i in range(3):
    if 0 <= l + i - 1 < m:
      if abs(cs[m] - 2 * cs[l + i - 1]) < abs(cs[m] - 2 * cs[l]):
        nl = l + i - 1
    if m < r + i - 1 < N:
      if abs(cs[-1] - 2 * cs[r + i - 1] + cs[m]) < abs(cs[-1] - 2 * cs[r] + cs[m]):
        nr = r + i - 1
  l = nl
  r = nr
  return max(cs[l], cs[m] - cs[l], cs[r] - cs[m], cs[-1] - cs[r]) - min(cs[l], cs[m] - cs[l], cs[r] - cs[m], cs[-1] - cs[r])
res = float("inf")
for i in range(1, N - 1):
  res = min(res, solve(i))
  #print(solve(i))
print(res)

### FIXED CODE ###

import sys
from bisect import bisect_left as bl
input = sys.stdin.readline
N = int(input())
a = list(map(int,input().split()))
cs = [0] * N
cs[0] = a[0]
for i in range(N - 1): cs[i + 1] = cs[i] + a[i + 1]
res = float("inf")
for m in range(1, N - 1):
  l = bl(cs, cs[m] // 2, hi = m)
  r = bl(cs, cs[m] + (cs[-1] - cs[m]) // 2, lo = m)
  l -= l == m
  r += r == m
  nl = l + 0
  nr = r + 0
  for i in range(3):
    if i == 1: continue
    if 0 <= l + i - 1 < m:
      if abs(cs[m] - 2 * cs[l + i - 1]) < abs(cs[m] - 2 * cs[l]):
        nl = l + i - 1
    if m < r + i - 1 < N:
      if abs(cs[-1] - 2 * cs[r + i - 1] + cs[m]) < abs(cs[-1] - 2 * cs[r] + cs[m]):
        nr = r + i - 1
  l = nl
  r = nr
  res = min(res, max(cs[l], cs[m] - cs[l], cs[r] - cs[m], cs[-1] - cs[r]) - min(cs[l], cs[m] - cs[l], cs[r] - cs[m], cs[-1] - cs[r]))
print(res)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 0
MOD = 10**9 + 7
for i in range(60):
    tmp0 = 0
    tmp1 = 0
    for j in range(n):
        if a[j]>>i&1 == 0: tmp0 += 1
        else: tmp1 += 1
    ans += tmp0*tmp1*2**i%MOD
print(ans%MOD)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 0
MOD = 10**9 + 7
for i in range(60):
    tmp0 = 0
    tmp1 = 0
    for j in range(n):
        if a[j]>>i&1 == 0: tmp0 += 1
        else: tmp1 += 1
    ans += (tmp0*tmp1%MOD)*(2**i%MOD)
print(ans%MOD)
### BUGGY CODE ###

N, Q = map(int,input().split())
G = [[] for i in range(N+ 1)]
CNT = [[] for i in range(N+ 1)]
for _ in range(N - 1):
    a , b = map(int,input().split())
    G[a].append(b)
for _ in range(Q):
    p, x =map(int,input().split())
    CNT[p].append(x)
que=[1]
ANS = [0] * (N + 1)
while que:
    node = que.pop(0)
    _sum = sum(CNT[node])
    ANS[node] = _sum
    for child in G[node]:
        CNT[child].append(_sum)
        que.append(child)
for i in range(1, N + 1):
    print(ANS[i])

### FIXED CODE ###

N, Q = map(int,input().split())
G = [[] for i in range(N+ 1)]
ANS = [0] * (N + 1)
for _ in range(N - 1):
    a , b = map(int,input().split())
    G[a].append(b)
for _ in range(Q):
    p, x =map(int,input().split())
    ANS[p] += x
from collections import deque
que=deque([])
que.append(1)
while que:
    node = que.pop()
    ans = ANS[node]
    for child in G[node]:
        ANS[child] += ans
        que.append(child)
for i in range(1, N + 1):
    print(ANS[i])
### BUGGY CODE ###

import collections

N, K, Q = map(int,input().split())
A = []
for i in range(Q):
    A.append(int(input()))

c = collections.Counter(A)
cnt = [0] * N
for i in range(len(c.most_common())):
    cnt[c.most_common()[i][0]-1] = c.most_common()[i][1]

if K > Q:
    for i in range(N):
        print('Yes')
elif K <= Q:
    for i in cnt:
        if i >= Q-K+1:
            print('Yes')
        else:
            print('No')

### FIXED CODE ###

import collections

N, K, Q = map(int,input().split())
A = []
for i in range(Q):
    A.append(int(input()))

c = collections.Counter(A)
cnt = [0] * N
for i in c.most_common():
    cnt[i[0]-1] = i[1]

if K > Q:
    for i in range(N):
        print('Yes')
elif K <= Q:
    for i in cnt:
        if i >= Q-K+1:
            print('Yes')
        else:
            print('No')
### BUGGY CODE ###

# coding: utf-8

num = int(input())
l_cre = list(map(int, input().split()))
l_cre.sort()

counter = 0

for ind, cre in enumerate(l_cre):
    now_size = 0
    now_size += sum(l_cre[:(ind + 1)])
    rest_cre = len(l_cre) - ind - 1

    while True:
        if (ind + 1) == len(l_cre):
            counter += 1
            break

        ind += 1
        if (now_size * 2) >= l_cre[ind]:
            now_size += l_cre[ind]
            continue
        else:
            break

print(counter)

### FIXED CODE ###

# coding: utf-8

num = int(input())
l_cre = list(map(int, input().split()))
l_cre.sort()

counter = 0
now_size = 0

for i in range(len(l_cre) - 1):
    now_size += l_cre[i]
    if now_size * 2 >= l_cre[i + 1]:
        counter += 1
    else:
        counter = 0

counter += 1

print(counter)
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

import heapq

def main():
	h,w=MI()
	ch,cw=MI()
	dh,dw=MI()
	ch+=1
	cw+=1
	dh+=1
	dw+=1

	S=[["#"]*(w+4)]
	S.append(["#"]*(w+4))
	for _ in range(h):
		S.append(["#"]*2+list(RD())+["#"]*2)
	S.append(["#"]*(w+4))
	S.append(["#"]*(w+4))

	#print(S)

	Q=[[0,ch,cw]]
	heapq.heapify(Q)
	S[ch][cw]=0

	#print(Q)

	while Q:
		#print(Q)
		d,x,y=heapq.heappop(Q)

		if S[x][y]<d:
			continue

		for xx,yy in [[0,1],[0,-1],[1,0],[-1,0]]:
			if S[x+xx][y+yy]==".":
				S[x+xx][y+yy]=d
				heapq.heappush(Q,[d,x+xx,y+yy])
			elif S[x+xx][y+yy]=="#":
				continue
			elif S[x+xx][y+yy]>d:
				S[x+xx][y+yy]=d
				heapq.heappush(Q,[d,x+xx,y+yy])

		for xx,yy in [[0,1],[0,-1],[1,0],[-1,0]]:
			if S[x+xx][y+yy]=="#":
				for xxx in range(-2,3):
					for yyy in range(-2,3):
						if S[x+xxx][y+yyy]==".":
							S[x+xxx][y+yyy]=d+1
							heapq.heappush(Q,[d+1,x+xxx,y+yyy])
				break






	#print(S[2:-2])

	print(-1 if S[dh][dw]=="." else S[dh][dw])


if __name__ == "__main__":
	main()


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

from collections import deque

def main():
	h,w=MI()
	ch,cw=MI()
	dh,dw=MI()
	ch+=1
	cw+=1
	dh+=1
	dw+=1

	S=[["#"]*(w+4)]
	S.append(["#"]*(w+4))
	for _ in range(h):
		S.append(["#"]*2+list(RD())+["#"]*2)
	S.append(["#"]*(w+4))
	S.append(["#"]*(w+4))

	#print(S)

	S[ch][cw]=0
	Q=deque()
	Q.append([0,ch,cw])


	d1=[(0,1),(0,-1),(-1,0),(1,0)]
	d2=[(i,j) for i in range(-2,3) for j in range(-2,3)]

	while Q:
		#print(Q)
		d,x,y=Q.popleft()

		for xx,yy in d1:
			if S[x+xx][y+yy]==".":
				S[x+xx][y+yy]=d
				Q.appendleft([d,x+xx,y+yy])
			elif S[x+xx][y+yy]=="#":
				continue
			elif S[x+xx][y+yy]>d:
				S[x+xx][y+yy]=d
				Q.appendleft([d,x+xx,y+yy])

		for xx,yy in d2:
			if S[x+xx][y+yy]==".":
				S[x+xx][y+yy]=d+1
				Q.append([d+1,x+xx,y+yy])
			elif S[x+xx][y+yy]=="#":
				continue
			elif S[x+xx][y+yy]>d+1:
				S[x+xx][y+yy]=d+1
				Q.appendleft([d+1,x+xx,y+yy])



	#print(S[2:-2])

	print(-1 if S[dh][dw]=="." else S[dh][dw])


if __name__ == "__main__":
	main()
### BUGGY CODE ###

# -*- coding: utf-8 -*-

import sys
from math import sqrt
from collections import deque

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,K=MAP()
A=LIST()

sm=sum(A)

def divisor_set(N: int) -> set:
    """ 約数の列挙・個数 """
    # 1とその数はデフォで入れとく
    s = {1, N}
    # 終点はルート切り捨て
    for i in range(2, int(sqrt(N))+1):
        # 割り切れるなら、iとN/iを追加
        if N % i == 0:
            s.add(i)
            s.add(N // i)
    return s

divs=sorted(divisor_set(sm), reverse=True)

for div in divs:
    B=[]
    for i in range(N):
        if A[i]%div!=0:
            B.append(A[i]%div)
    B.sort()
    B=deque(B)
    cnt=0
    while len(B):
        B[0]-=1
        B[-1]+=1
        if B[0]%div==0:
            B.popleft()
        if B[-1]%div==0:
            B.pop()
        cnt+=1
    if cnt<=K:
        print(div)
        exit()


### FIXED CODE ###

# -*- coding: utf-8 -*-

import sys
from math import sqrt
from collections import deque

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,K=MAP()
A=LIST()

sm=sum(A)

def divisor_set(N: int) -> set:
    """ 約数の列挙・個数 """
    # 1とその数はデフォで入れとく
    s = {1, N}
    # 終点はルート切り捨て
    for i in range(2, int(sqrt(N))+1):
        # 割り切れるなら、iとN/iを追加
        if N % i == 0:
            s.add(i)
            s.add(N // i)
    return s

divs=sorted(divisor_set(sm), reverse=True)

for div in divs:
    B=[]
    for i in range(N):
        if A[i]%div!=0:
            B.append(A[i]%div)
    # mod取ったものをソート、これを前後からdivの約数に合わせていく
    B.sort()
    B=deque(B)
    cnt=0
    while len(B):
        # 先頭を引いていってdivの約数になるまでの距離
        dista=B[0]%div
        # 末尾を足していってdivの約数になるまでの距離
        distb=div-B[-1]%div
        # どちらが近いかに応じてリストBを操作する
        if dista>distb:
            B[0]-=distb
            B.pop()
            cnt+=distb
        elif dista<distb:
            B[-1]+=dista
            B.popleft()
            cnt+=dista
        elif dista==distb:
            B.pop()
            B.popleft()
            cnt+=dista
    # 操作回数がK回以内ならOK
    if cnt<=K:
        print(div)
        exit()
### BUGGY CODE ###

def resolve():
    def dijkstra(s, n, cost, inf=float("inf")):
        d = [inf] * n
        used = [False] * n
        d[s] = 0
        p = [-9999] * n
        while True:
            v = -1
            for i in range(n):
                if not used[i]:
                    if v == -1:
                        v = i
                    elif d[i] < d[v]:
                        v = i
            if v == -1:
                break
            used[v] = True
            for j in range(n):
                k = d[v] + cost[v][j]
                if k < d[j]:
                    d[j] = k
                    p[j] = v
        return d, p
    n, m = map(int, input().split())
    inf = 10 ** 10
    cost = [[inf for i in range(n)] for i in range(n)]
    for _ in range(m):
        x, y = [int(x) - 1 for x in input().split()]
        cost[x][y] = 1
        cost[y][x] = 1
    l, p = dijkstra(0, n, cost, inf)
    if min(p[1:]) < -1:
        print("No")
    else:
        print("Yes")
        for i in p[1:]:
            print(i + 1)


if __name__ == '__main__':
    resolve()


### FIXED CODE ###

def resolve():
    def Dijkstra(s, n, edge, inf=float("inf")):
        import heapq
        d = [inf] * n
        used = [False] * n
        d[s] = 0
        used[s] = True
        queue = []
        path = [-9999] * n
        for e in edge[s]:
            heapq.heappush(queue, e + [s])
        while len(queue):
            dist, point, before = heapq.heappop(queue)
            if used[point]:
                continue
            d[point] = dist
            used[point] = True
            path[point] = before
            for nextdist, nextp in edge[point]:
                if not used[nextp]:
                    heapq.heappush(queue, [dist + nextdist, nextp, point])
        return d, path
    n, m = map(int, input().split())
    inf = 10 ** 10
    edge = [[] for _ in range(n)]
    for _ in range(m):
        x, y = [int(x) - 1 for x in input().split()]
        edge[x].append([1, y])
        edge[y].append([1, x])
    l, p = Dijkstra(0, n, edge, inf)
    if min(p[1:]) < -1:
        print("No")
    else:
        print("Yes")
        for i in p[1:]:
            print(i + 1)


if __name__ == '__main__':
    resolve()