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

def solve(n, a, b, c, q, k, x, y):
    E = {}
    G = {}
    for u, v, d in zip(a, b, c):
        if not u in E:
            E[u] = []
        if not v in E:
            E[v] = []
        E[u].append(v)
        E[v].append(u)
        G[u, v] = d
        G[v, u] = d
    dist = {}
    dist[k] = 0
    que = [k]
    group = {}
    while que:
        v = que.pop(0)
        for u in E[v]:
            if not u in dist:
                dist[u] = dist[v] + G[u,v]
                if v == k:
                    group[u] = u
                else:
                    group[u] = group[v]
                que.append(u)
    for i in range(q):
        if group[x[i]] == group[y[i]]:
            print(dist[x[i]] + dist[y[i]])
        else:
            print(dist[x[i]] + dist[y[i]])

n = int(input())
a = [0] * (n-1)
b = [0] * (n-1)
c = [0] * (n-1)
for i in range(n-1):
    a[i], b[i], c[i] = map(int, input().split())
q, k = map(int, input().split())
x = [0] * q
y = [0] * q
for i in range(q):
    x[i], y[i] = map(int, input().split())
solve(n, a, b, c, q, k, x, y)

### FIXED CODE ###

from collections import deque

def solve(n, a, b, c, q, k, x, y):
    E = {}
    G = {}
    for u, v, d in zip(a, b, c):
        if not u in E:
            E[u] = []
        if not v in E:
            E[v] = []
        E[u].append(v)
        E[v].append(u)
        G[u, v] = d
        G[v, u] = d
    dist = {}
    dist[k] = 0
    que = deque([k])
    while que:
        v = que.pop()
        for u in E[v]:
            if not u in dist:
                dist[u] = dist[v] + G[u,v]
                que.append(u)
    for i in range(q):
        print(dist[x[i]] + dist[y[i]])

n = int(input())
a = [0] * (n-1)
b = [0] * (n-1)
c = [0] * (n-1)
for i in range(n-1):
    a[i], b[i], c[i] = map(int, input().split())
q, k = map(int, input().split())
x = [0] * q
y = [0] * q
for i in range(q):
    x[i], y[i] = map(int, input().split())
solve(n, a, b, c, q, k, x, y)
### BUGGY CODE ###

def solve():
  h,w = (int(i) for i in input().split())
  maze = [input() for _ in range(h)]
  count = 0
  ans = 0
  
  white = []
  for i in range(h):
    for j in range(w):
      if maze[i][j] == ".":
        white.append((i,j))

  d = [(1,0),(0,1),(-1,0),(0,-1)]
  while white:
   x,y = white.pop(0)
   query = [(x,y,0)]
   visit = [[False]*w for i in range(h)]
   while query:
    x,y,move = query.pop(0)
    nm = move + 1
    for dx,dy in d:
      
     nx,ny  =x+dx,y+dy
     if nx < 0 or nx >= h or ny < 0 or ny >=w :
        continue
     else:
      if visit[nx][ny]:
        continue
      else:
        visit[nx][ny] = True

        if maze[nx][ny] == ".":
          query.append((nx,ny,nm))
         

        else:
          ans = max(ans,nm)
          query = []
          break

  print(ans)
solve()


### FIXED CODE ###


from collections import deque
def solve():
  h,w = (int(i) for i in input().split())
  maze = ["0"*(w+2)]
  for i in range(h):
    maze.append("0"+input()+"0")
  maze.append("0"*(w+2))
  black = deque([])
  count = 0
  visit = [[False]*(w+2) for _ in range(h+2)]
  
  for i in range(h+2):
    for j in range(w+2):
      if maze[i][j] == "#":
        black.append((0,i,j)) #move,h,w

  d = [(0,1),(1,0),(-1,0),(0,-1)]
  ans = 0
  
  while count != h*w:
    move,y,x = black.popleft()
    #print(move,y,x)
    if visit[y][x]:
      continue
    else:
      visit[y][x] = True
      count += 1
      for dy,dx in d:
        ny,nx = y+dy,x+dx
        if visit[ny][nx]:
          continue
        elif maze[ny][nx] ==".":
          black.append((move+1,ny,nx))
  print(move)
          

    
solve()
### BUGGY CODE ###

N = int(input())
S = str(input())
count = 0
for i in range(N):
  for j in range(i,N):
    for k in range(j,N):
      if S[i] != S[j] and S[i] != S[k] and S[j] != S[k] and j-i != k-j:
        count += 1
print(count)

### FIXED CODE ###

N = int(input())
S = str(input())
count = S.count('R')*S.count('G')*S.count('B')
for i in range(N):
  for l in range(N):
    j = i + l
    k = j + l
    if k >= N:
      break
    if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
      count -= 1

print(count)
### BUGGY CODE ###

S = input()
ans = 0
MOD = 2019

for i in range(len(S)):
    for j in range(i+1, len(S)+1):
        if int(S[i:j]) % MOD == 0:
            ans += 1
            break

print(ans)

### FIXED CODE ###

from collections import defaultdict
S = input()
n = len(S)
N = defaultdict(int)
x = 0
for i in reversed(range(n)):
    x += int(S[i])*pow(10,(n-i-1),2019)
    x %= 2019
    N[x] += 1
ans = N[0]
for j in N.values():
    ans += j*(j-1)//2
print(ans)
### BUGGY CODE ###

import os
import sys
import heapq

def main():
    H , K = map(int , input().split())
    n_list = [s for s in input().split()]
    n_list = list(map(int,n_list))
    #print (n_list)
    #c = sum(int(i) for i in list)
    list_small = []
    new_list = []
    if K >= len(n_list) :
        print (str(0))
    elif K == 0 :
        c = sum(int(i) for i in n_list)
        print (str(c))
    else :
        list_small = heapq.nlargest(K,n_list)
        list_small = list(map(int,list_small))
        #print (list_small)
        #new_list = list(set(n_list)-set(list_small))
        new_list = list_difference(n_list, list_small)
        #print (list_small)
        #print (new_list)
        c = sum(int(i) for i in new_list)
        print (str(c))
    #print (str(X))
def list_difference(list1, list2):
    result = list1.copy()
    for value in list2:
        if value in result:
            result.remove(value)

    return result

if __name__ == '__main__':
    main()

### FIXED CODE ###

import os
import sys
import heapq

def main():
    H , K = map(int , input().split())
    n_list = [s for s in input().split()]
    n_list = list(map(int,n_list))
    #print (n_list)
    #c = sum(int(i) for i in list)
    list_small = []
    new_list = []
    if K >= len(n_list) :
        print (str(0))
    elif K == 0 :
        c = sum(int(i) for i in n_list)
        print (str(c))
    else :
        list_small = heapq.nlargest(K,n_list)
        list_small = list(map(int,list_small))
        #print (list_small)
        #new_list = list(set(n_list)-set(list_small))
        #new_list = list_difference(n_list, list_small)
        #print (list_small)
        #print (new_list)
        c = sum(int(i) for i in n_list)
        d = sum(int(i) for i in list_small)
        print (str(c-d))
    #print (str(X))

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

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

n = int(input())
pl = list(map(int, input().split()))

ans = 0
for i in range(n):
    mi = min(pl[:i+1])
    if mi == pl[i]:
        ans += 1
print(ans)


### FIXED CODE ###

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

n = int(input())
pl = list(map(int, input().split()))

ans = 0
mi = float('inf')
for p in pl:
	if p<mi:
		ans += 1
	mi = min(mi, p)
print(ans)
### BUGGY CODE ###

import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    N, M = li_input()
    A = li_input()

    ans = 0

    cumsum = [0]
    c_sum = 0
    for a in A:
        c_sum += a
        cumsum.append(c_sum)

    for r in range(1, len(cumsum)):
        for l in range(r):
            if (cumsum[r] - cumsum[l]) % M == 0:
                ans += 1

    print(ans)


main()


### FIXED CODE ###

import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    N, M = li_input()
    A = li_input()

    ans = 0
    d = collections.defaultdict(lambda: 0)

    cumsum = [0]
    c_sum = 0
    for a in A:
        c_sum = (c_sum + a) % M
        cumsum.append(c_sum)

    for c in cumsum:
        d[c] += 1

    for v in d.values():
        if v >= 2:
            ans += v * (v - 1) // 2

    print(ans)


main()
### BUGGY CODE ###

n,m = map(int,input().split())
INF = 10**9+7
inv = {}
inv[0] = 1
inv[1] = 1
def p(x):
    if x in inv:
        return inv[x]
    else:
        inv[x] = ((-1)* p(INF%x) * (INF//x))% INF
        return inv[x]
# n H y
memo = [0 for i in range(m+1)]
def f(y):
    def g(v):
        if v == 0:
            return 1
        elif v == 1:
            return n
        elif memo[v] != 0:
            return memo[v]
        else:
            memo[v] = ((n+v-1)*g(v-1)*p(v))%INF
            return memo[v]
    return g(y)
# M を素因数分解
def h(x):
    t = x
    d = {}
    for i in range(2,x):
        if i*i > x:
            break
        if t % i != 0:
            continue
        if t % i == 0:
            ind = 0
            while t % i == 0:
                t = t // i
                ind += 1
            d[i] = ind
    if t != 1:
        d[x] = 1
    return d

res = 1
for i in h(m):
    res = (res *  f(h(m)[i])) % INF

print(res)

### FIXED CODE ###

n,m = map(int,input().split())
INF = 10**9+7
inv = {}
inv[0] = 1
inv[1] = 1
def p(x):
    if x in inv:
        return inv[x]
    else:
        inv[x] = ((-1)* p(INF%x) * (INF//x))% INF
        return inv[x]
# n H i
l = [1] * 31
l[1] = n 
for i in range(2,31):
    l[i] = ((n+i-1)*l[i-1]*p(i))%INF
# M を素因数分解
def h(x):
    t = x
    d = {}
    for i in range(2,x):
        if i*i > x:
            break
        if t % i != 0:
            continue
        if t % i == 0:
            ind = 0
            while t % i == 0:
                t = t // i
                ind += 1
            d[i] = ind
    if t != 1:
        d[x] = 1
    return d

res = 1
for i in h(m):
    res = (res *  l[h(m)[i]]) % INF

print(res)
### BUGGY CODE ###

import copy
N = int(input())
lst = []
for i in range(N):
    lst.append(int(input()))


for i in range(N):
    lst2 = copy.copy(lst)
    lst2.pop(i)
    print(max(lst2))


### FIXED CODE ###

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B = sorted(A, reverse = True)

for i in range(N):
    if A[i] == B[0]:
        print(B[1])
    else:
        print(B[0])
### BUGGY CODE ###

import numpy as np

N, W = map(int, raw_input().split())
dp = np.zeros(W+1)

for i in range(N):
    w, v = map(int, raw_input().split())
    for j in range(W, w-1, -1):
        dp[j] = max(dp[j], dp[j-w]+v)
 
print int(dp[-1])


### FIXED CODE ###

def main():

    N, W = map(int, raw_input().split())
    dp = [0]*(W+1)
 
    for i in xrange(N):
        w, v = map(int, raw_input().split())
        for j in xrange(W, w-1, -1):
            x = dp[j-w] + v
            if x > dp[j]:
                dp[j] = x
 
    print dp[-1]

main()
### BUGGY CODE ###

N,M = map(int, input().split())
t_table = {}
for i in range(M):
	x,y = map(int, input().split())
	if x-1 in t_table: t_table[x-1].append(y-1)
	else: t_table[x-1] = [y-1]
ans = 0
dp = [1 for _ in range(N)]
zerolist = [0 for _ in range(N)]
while True:
	pnode = dp.copy()
	dp = [0 for _ in range(N)]
	for i in range(N):
		if pnode[i] == 1 and i in t_table:
			for j in t_table[i]:
				if dp[j]==0 : dp[j]= 1
	if(dp == zerolist):
	 	print(ans)
	 	break
	ans += 1


### FIXED CODE ###

import sys

sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline

N,M = map(int, input().split())
lst_edge = [[] for _ in range(N)]
for _ in range(M):
	x,y = map(int, input().split())
	lst_edge[x-1].append(y-1)

dp = [-1] * N

def rec(v):
	if dp[v] != -1:
		return dp[v]
	ans = 0
	lst_nv = lst_edge[v]
	for nv in lst_nv:
		ans = max(ans, rec(nv)+1)
	dp[v] = ans
	return dp[v]

ans = 0
for v in range(N):
	ans = max(ans,rec(v))
print(ans)
### BUGGY CODE ###

def count(P):
  cnt = 0
  for i in range(N):
    min = P[i]
    for j in range(i):
      if min > P[j]:
        min = P[j]
    if min == P[i]:
      cnt += 1
        
  return cnt

N = int(input())
P = list(map(int, input().split()))
print(count(P))

### FIXED CODE ###

def count(P, N):
  cnt = 0
  min = P[0]
  M = [0] * N
  for i in range(N):
    if P[i] <= min:
      M[i] = P[i]
      min = P[i]
      cnt += 1
    else:
      M[i] = min
        
  return cnt

N = int(input())
P = list(map(int, input().split()))
print(count(P, N))
### BUGGY CODE ###

r,g,b,n = map(int, input().split())
max_y = n//g
max_z = n//b

count = 0
for y in range(max_y + 1):
    for z in range(max_z + 1):
        x_before = n - g*y - b*z
        if( (x_before / r) < 0 ):
            break
        if( (x_before % r == 0) ):
            count += 1
print(count)

### FIXED CODE ###

def counter(r,g,b,n):
    count = 0
    max_y = n//g
    max_z = n//b

    for y in range(max_y + 1):
        for z in range(max_z + 1):
            x_before = n - g*y - b*z
            if( (x_before / r) < 0 ):
                break
            if( (x_before % r == 0) ):
                count += 1
    return count

r,g,b,n = map(int, input().split())
print(counter(r,g,b,n))
### BUGGY CODE ###

N, M = map(int, input().split())
A_list = []
for i in range(N):
    A, B = map(int, input().split())
    A_list += [A for i in range(B)]
A_list.sort()
value = sum(A_list[0:M])
print(value)

### FIXED CODE ###

N, M = map(int, input().split())
AB_list = [list(map(int, input().split())) for i in range(N)]
AB_list.sort()
ans, cnt = 0, 0
for a, b in AB_list:
    ans += a*b
    cnt += b
    if cnt > M:
        ans = ans-(a*(cnt-M))
        break
print(ans)
### BUGGY CODE ###


 # print(sorted(a, key=itemgetter(1)))
N,M = map(int,input().split())

#Aは小さい順に並べる
A_list = list(map(int,input().split()))
A_list = sorted(A_list)
BC_list = []

ans = 0

for i in range(M):
    bi,ci = map(int,input().split())
    BC_list.append([bi,ci])

#BC_listからCの配列(長さはN)を作成する(大きい順)
C_list=[]
for i in range(M):
    for j in range(BC_list[i][0]):
        C_list.append(BC_list[i][1])

C_list=sorted(C_list,reverse=True)

#NにたりないばあいはNまで1で埋める、Nより大きい場合はNまでを使う
if len(C_list) > N:
    C_list = C_list[0:N]
else:
    for i in range(N-len(C_list)):
        C_list.append(1)

#どこの添字からAとCが逆転するか調べる
for i in range(N):
    #Aは昇順、Cは降順
    if C_list[i] > A_list[i]:
        A_list[i] = C_list[i]


print(sum(A_list))


### FIXED CODE ###


#AのリストにCのリストを加えて大きい順に並べ替えてNまでの和を求める
N,M = map(int,input().split())

#Aの入力
A_list = list(map(int,input().split()))

C_list = []

#Cのリストに追加する
for i in range(M):
    bi,ci = map(int,input().split())
    C_list.append([bi,ci])

#C_listをCの値でソート
C_list=sorted(C_list, reverse=True, key=lambda x:x[1])

count = 0
for bi,ci in C_list:
    count += bi
    if count > N:
        #countがNより大きくなったらNより大きくなった分だけ使う
        bi = N - count + bi
    A_list.extend([ci]*bi)

#A_Listを大きい順に並べ替える
A_list=sorted(A_list,reverse=True)

#N番目までの総和を求める
print(sum(A_list[0:N]))
### BUGGY CODE ###

N = int(input())
S = input()

R = []
G = []
B = []
ans = 0
for i in range(len(S)):    
    if S[i] == "R":
        R.append(i)
    if S[i] == "G":
        G.append(i)
    if S[i] == "B":
        B.append(i)
# r, g, b = 0, 0, 0
# while (r < len(R) and g < len(G) and b < len(B)):
#     target = min(R[r], g, b)
#     if (abs(R[r] - g) != abs(g - b) and abs(R[r] - g) != abs(R[r] - b) and abs(g - b) != abs(R[r] - b)):
#         ans += 1
#     if target == R[r]:
#         r += 1
#     if target == g:
#         g += 1
#     if target == b:
#         b += 1
for r in R:
    for g in G:
        for b in B:
            if (abs(r - g) != abs(g - b) and abs(r - g) != abs(r - b) and abs(g - b) != abs(r - b)):
                ans += 1
            
print(ans)
    

### FIXED CODE ###

N = int(input())
S = input()

R = []
G = []
B = []
ans = 0
for i in range(len(S)):
    if S[i] == "R":
        R.append(i)
    if S[i] == "G":
        G.append(i)
    if S[i] == "B":
        B.append(i)
rem = 0
setB = set(B)

for r in R:
    for g in G:
        if g - abs(r - g) in setB:
            rem += 1
        if r - abs(g - r) in setB:
            rem += 1
        if (g + r) / 2 in setB:
            rem += 1
        if g + abs(r - g) in setB:
            rem += 1
        if r + abs(g - r) in setB:
            rem += 1


print(len(R)*len(G)*len(B) - rem)
### BUGGY CODE ###

x=input()
x0=x.split()
n=int(x0[0])
k=int(x0[1])
a0=input()
a0=a0.split()
a=[int(s) for s in a0]
a1=list(range(n+1))
for f in range(k):
    a1=[0 for s in a1]
    for x in range(n):
        y=max(0,x-a[x])
        a1[y]=a1[y]+1    
        z=min(n-1,x+a[x])
        a1[z+1]=a1[z+1]-1
    a[0]=a1[0]
    for x in range(1,n):    
        a[x]=a[x-1]+a1[x]
    if sum(a)==n**2:
        break
a=[str(s) for s in a]
a=" ".join(a)
print(a)

### FIXED CODE ###

from numba import njit

@njit(cache=True)
def aaa(n,k,a):
    for f in range(k):
        a1=[0]*(n+1)
        for x in range(n):
            y=max(0,x-a[x])
            a1[y]=a1[y]+1    
            z=min(n-1,x+a[x])
            a1[z+1]=a1[z+1]-1
        a[0]=a1[0]
        for x in range(1,n):    
            a[x]=a[x-1]+a1[x]
        if a==[n]*n:
            break
    return a

x=input()
x0=x.split()
n=int(x0[0])
k=int(x0[1])
a0=input()
a0=a0.split()
a=[int(s) for s in a0]

b=aaa(n,k,a)
for i in range(n):
    print(b[i])
### BUGGY CODE ###

class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納
        # par[x]=xの時そのノードは根　
        self.par = [i for i in range(n + 1)]
        # rank
        self.rank = [0] * (n + 1)

    def find(self, x):
        # 根の番号を返す(所属する集合を確認する)
        # ここの再帰をDFSで実装して高速化できるか試す
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def check(self, x, y):
        # x,yが同じ集合に属するかどうか調べる
        return self.find(x) == self.find(y)


    def size(self,x):
        # 集合のサイズを調べる
        return self.par.count(self.find(x))

    def union(self, vx, vy):
        # 根を探す
        x = self.find(vx)
        y = self.find(vy)
        # rankの小さいものを大きいほうにくっつける
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.find(vx)
        else:
            self.par[y] = x
            self.find(vy)
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

n,m,k=map(int,input().split())
uf=UnionFind(n)
out=[[] for i in range(n+1)]

for i in range(m):
    a,b=map(int,input().split())
    uf.union(a,b)
    out[a].append(b)
    out[b].append(a)

for i in range(k):
    c,d=map(int,input().split())
    if uf.check(c,d):
        out[c].append(d)
        out[d].append(c)
'''
print(out)
print(uf.par)
'''
for i in range(1,n+1):
    ans=uf.size(i)-1-len(out[i])
    print(ans,end=' ')


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納
        # par[x]=xの時そのノードは根　
        self.par = [-1] * n
        # rank
        self.size = [1] * n

    def find(self, x):
        # 根の番号を返す(所属する集合を確認する)
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def check(self, x, y):
        # x,yが同じ集合に属するかどうか調べる
        return self.find(x) == self.find(y)


    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:return
        self.par[y]=x
        self.size[x]+=self.size[y]

import sys
input=sys.stdin.readline
n,m,k=map(int,input().split())
uf=UnionFind(n)
out=[[] for i in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    uf.union(a-1,b-1)
    out[a-1].append(b-1)
    out[b-1].append(a-1)

for i in range(k):
    c,d=map(int,input().split())
    if uf.check(c-1,d-1):
        out[c-1].append(d-1)
        out[d-1].append(c-1)

for i in range(n):
    ans=uf.size[uf.find(i)]-1-len(out[i])
    print(ans,end=' ')
### BUGGY CODE ###

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

for i in range(n):
    memory = a[0]
    a.remove(a[0])
    print(max(a))
    a.append(memory)

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]

m = max(a)
count = a.count(m)

if count != 1:
    for i in range(n):
        print(m)

else:
    switch = 0
    for i in range(n-1):
        if a[i] == m:
            a.remove(m)
            m2max = max(a)
            print(m2max)
            a.append(m)
            switch = 1
        else:
            print(m)
    
    if switch == 1:
        print(m)
    else:
        a.remove(m)
        m2max = max(a)
        print(m2max)
### BUGGY CODE ###

import math
S = int(input())
a = S//2 #x1*y2
isOk = False
while a > 0 and not isOk:
  b = S - a #x2*y1
  x1 = int(math.sqrt(a))
  y2 = -1
  while x1 >= 1:
    y2 = a//x1
    if x1*y2 == a:
      break
    x1 -= 1
  x2 = int(math.sqrt(b))
  y1 = -1
  while x2 >= 1:
    y1 = b // x2
    if x2*y1 == b:
      break
    x2 -= 1
  if y2 > 0 and y1 > 0 and max(x1, x2, y1, y2) <=10**9:
    m = min(x1, x2, y1, y2)
    if m == x1 and x1+x2 <= 10**9:
      ans = [0, y1, x2+x1, y2, x1, 0]
      isOk = True
    elif m == x2 and x1+x2 <= 10**9:
      ans = [x1+x2, y1, 0, y2, x2, 0]
      isOk = True
    elif m == y1 and y1+y2 <= 10**9:
      ans = [x1, 0, x2, y1+y2, 0, y1]
      isOk = True
    elif m == y2 and y1+y2 <= 10**9:
      ans = [x1, y1+y2, x2, 0, 0, y2]
      isOk = True
    if isOk:
      print(" ".join([str(a) for a in ans]))
  a -= 1
if not isOk:
  a = 0
  b = S - a
  x2 = int(math.sqrt(b))
  y1 = -1
  while x2 >= 1:
    y1 = b // x2
    if x2*y1 == b:
      break
    x2 -= 1
  if y1 > 0 and min(x2, y1) <= 10**9:
    print(" ".join([str(a) for a in [0, y1, x2, 0, 0, 0 ]]))

### FIXED CODE ###

import math
S = int(input())
v = 10**9
x3 = (v-S%v)%v
y3 = (S+x3)//v
print("0 0 %d 1 %d %d"%(10**9, x3, y3))
### BUGGY CODE ###

N = int(input())
a = list(map(int,input().split(' ')))
a.sort(reverse = True)
 
 
fathers = [a.pop(0)]
for _ in range(N):
    sons = []
    b = []

    for father in fathers:
        while a:
            x = a.pop(0)
            if father > x:
                sons.append(x)
                break
            else:
                b.append(x)
                continue
                
    a = b + a
    fathers += sons
    fathers.sort(reverse = True)
    


if len(fathers) == 2**N:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

N = int(input())
A = sorted((int(x) for x in input().split()))
 
parent = [A[-1]]
rest = A[:-1]
bl = True
for _ in range(N):
    next_parent = []
    next_rest = []
    for p in parent[::-1]:
        while rest:
            x = rest.pop()
            if x < p:
                next_parent.append(x)
                break
            else:
                next_rest.append(x)
                continue
    parent += next_parent
    parent.sort()
    rest = rest + next_rest[::-1]
 
bl = len(parent) == (2**N)
answer = 'Yes' if bl else 'No'
print(answer)