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

import sys
import numpy as np
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix

read = sys.stdin.read
readline = sys.stdin.readline

n, m, s, t, *uvab = map(int, read().split())
u = np.array(uvab[::4], np.int64)
v = np.array(uvab[1::4], np.int64)
a = np.array(uvab[2::4], np.int64)
b = np.array(uvab[3::4], np.int64)

yen_matrix = csr_matrix((a, (u, v)), shape=(n + 1, n + 1))
snuuk_matrix = csr_matrix((b, (u, v)), shape=(n + 1, n + 1))

yen = dijkstra(yen_matrix, directed=False, indices=s)
snuuk = dijkstra(snuuk_matrix, directed=False, indices=t)

costs = (yen[1:] + snuuk[1:]).astype(int)
answer = 10 ** 15 - np.minimum.accumulate(costs[::-1])[::-1]
print('\n'.join(map(str, answer.tolist())))


### FIXED CODE ###

import sys
input = sys.stdin.read
sys.setrecursionlimit(10 ** 7)

import numpy as np
from heapq import heappush, heappop

N,M,S,T, *uvab = map(int,input().split())
graph = [[] for _ in range(N+1)]
for u,v,a,b in zip(*[iter(uvab)]*4):
    graph[u].append((v,a,b))
    graph[v].append((u,a,b))

def dijkstra(start, mode):
    INF = 10 ** 15
    dist = [INF] * (N+1)
    dist[start] = 0
    q = [(0,start)]
    while q:
        d,v = heappop(q)
        if dist[v] < d:
            continue
        for w,*a in graph[v]:
            d1 = d + a[mode]
            if dist[w] > d1:
                dist[w] = d1
                heappush(q, (d1,w))
    return dist

d1 = np.array(dijkstra(S,0))
d2 = np.array(dijkstra(T,1))

d1 += d2
answer = 10 ** 15 - np.minimum.accumulate(d1[::-1])[::-1][1:]
print('\n'.join(map(str, answer.tolist())))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
a.reverse()
mod = 7 + 10**9
leng = 60
data = [[0 for i in range(leng+1)] for j in range(n)]
#pre
for i in range(n):
    k = list(bin(a[i]))
    k.reverse()
    ll = len(k)
    for j in range(1, leng+1):
        temp = data[i - 1][j]
        if j - 1 >= ll:
            data[i][j] = temp
            continue
        if k[j - 1] == "1":
            data[i][j] = temp + 1
        else:
            data[i][j] = temp
ans = 0
a.reverse()
data.reverse()
for i in range(n-1):
    k = format(a[i], 'b')
    k = list(k.zfill(leng))
    k.reverse()
    for j in range(leng):
        if k[j] == "1":
            ans += ((n - i - 1) - data[i+1][j+1]) * (2**j)
            ans %= mod
        else:
            ans += data[i+1][j+1] * (2**j)
            ans %= mod
print(ans)


### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    n = int(input())
    a = list(map(int, input().split()))
    a.reverse()
    mod = 7 + 10**9
    leng = len(format(max(a), 'b'))
    bit_acc = [0 for i in range(leng)]
    for i in range(n):
        #先頭から二進数を0埋めした
        bit_data = format(a[i], 'b').zfill(leng)
        for j in range(leng):
            if bit_data[j] == '1':
                bit_acc[j] += 1
    ans = 0
    p = [pow(2,leng - 1 - j, mod) for j in range(leng)]
    for i in range(n):
        bit_data = format(a[i], 'b').zfill(leng)
        for j in range(leng):
            if bit_data[j] == '1':
                ans += (n - bit_acc[j]) * p[j]
            else:
                ans += bit_acc[j] * p[j]
            ans %= mod
    print((ans * 500000004) % mod)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

a,b=map(int,input().split())
num=[]
flag=0
for i in range(2,min(a,b)+1):
    flag=0
    if a%i==0 and b%i==0:
        num.append(i)
        for j in range(len(num)-1):
            if len(num)>1 and i%num[j]==0:
                num.pop(-1)
                break
print(len(num)+1)


### FIXED CODE ###

import math
#最大公約数
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
#因数分解
def factorize(x):
    f=[]
    div=2
    while div**2<=x:
        while x%div==0:
            f.append(div)
            x=x//div
        div+=1
    if x>1:
        f.append(x)
    return f

"""def factorize(x):
    ans=1#約数１
    div=2
    while div**2<=x:
        while x%div==0:
            x=x//div
            flag=1
        if flag==1:
            ans+=1
        div+=1
        flag=0
    if x>1:
        ans+=1
    return ans"""

a,b=map(int,input().split())
g=gcd(a,b)
f=factorize(g)
print(len(set(f))+1)
### BUGGY CODE ###

from collections import deque
import numpy as np

def solve(h, w, a): 
    dist = np.full((h, w), -1, dtype=int)
    que = deque([])
    for r in range(h):
        for c in range(w):
            if a[r][c] == "#":
                que.append((r, c, 0)) 
                dist[r, c] = 0 
    neighbors = [(1,0), (0,1), (-1,0), (0,-1)]
    while que:
        r, c, k = que.popleft()
        for dr, dc in neighbors:
            nr, nc = r+dr, c+dc
            if (0 <= nr < h) and (0 <= nc < w) and (dist[nr, nc] == -1):
                que.append((nr, nc, k+1))
                dist[nr, nc] = k+1 
    return np.max(dist)

h, w = map(int, input().split())
a = [input() for _ in range(h)]
print(solve(h, w, a)) 

### FIXED CODE ###

from collections import deque

def solve(h, w, a):
    used = [[True] * (w+2) for _ in range(h+2)]
    que = deque()
    for r in range(h):
        used[r+1][1:-1] = map(lambda _:_=="#", a[r])
        for c in range(w):
            if a[r][c] == "#":
                que.append((r+1, c+1, 0))
    neighbors = [(1,0), (0,1), (-1,0), (0,-1)]
    while que:
        r, c, k = que.popleft()
        for dr, dc in neighbors:
            nr, nc = r+dr, c+dc
            if not used[nr][nc]:
                que.append((nr, nc, k+1))
                used[nr][nc] = True
    return k

h, w = map(int, input().split())
a = [input() for _ in range(h)]
print(solve(h, w, a))
### BUGGY CODE ###

H, N = map(int, input().split())
magic = []
for _ in range(N):
    A, B = map(int, input().split())
    magic.append((A,B))

dp = [10**10] * (H+1)
dp[0] = 0
for i in range(1,H+1):
    for m in magic:
        if m[0] > i:
            dp[i] = min(dp[i], m[1])
        else:
            dp[i] = min(dp[i], dp[i-m[0]]+m[1])

print(dp[H])

### FIXED CODE ###

H, N = map(int, input().split())
magic = []
for _ in range(N):
    A, B = map(int, input().split())
    magic.append((A,B))

dp = [10**10] * (H+1)
dp[0] = 0
for i in range(1,H+1):
    for m in magic:
        if m[0] > i:
            dp[i] = min(dp[i], m[1])
        else:
            dp[i] = min(dp[i], dp[i-m[0]]+m[1])

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

def main():
    n, m = map(int, input().split())
    a = [int(x) for x in input().split()]
    a.sort(reverse=True)
    ans = sum(a)
    diff = 0
    for i in range(1, m+1):
        a_i = a[:i]
        a_m = max(a_i)
        diff += a_m  - a_m // 2
        a_m_i = a_i.index(a_m)
        a[a_m_i] = a[a_m_i] // 2
    ans -= diff
    print(ans)
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

from heapq import heapify, heappush, heappop

def main():
    n, m = map(int, input().split())
    a = [int(x)*-1 for x in input().split()]
    ans = sum(a)*-1
    diff = 0
    
    heapify(a)
    for _ in range(1, m+1):
        _h_a = heappop(a) * -1
        diff += _h_a - _h_a // 2
        heappush(a, (_h_a // 2)*-1)
    ans -= diff
    print(ans)
    
if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


N, Q = map(int, input().split())
G = [[] for _ in [0]*N]
for _ in [0]*(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

cnt = [0]*N
pre = [-1]*N
k = 0


def init(v=0, p=-1):
    global k
    pre[v] = k
    k += 1

    for u in G[v]:
        if u == p:
            continue
        init(u, v)


def dfs(v, x):
    cnt[v] += x
    for u in G[v]:
        if pre[v] > pre[u]:
            continue
        dfs(u, x)
    return


init()
for _ in [0]*Q:
    p, x = map(int, input().split())
    dfs(p-1, x)

print(*cnt)


### FIXED CODE ###

# AtCoder Beginner Contest 138
# D - Ki
# https://atcoder.jp/contests/abc138/tasks/abc138_d
import sys
sys.setrecursionlimit(10**6)

input = sys.stdin.readline
N, Q = map(int, input().split())

G = [[] for _ in [0]*N]
for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

counter = [0]*N

for _ in range(Q):
    p, x = map(int, input().split())
    counter[p-1] += x

visited = [False]*N


def dfs(v=0, x=0):
    visited[v] = True
    counter[v] += x
    for u in G[v]:
        if visited[u]:
            continue
        dfs(u, counter[v])


dfs()
print(*counter)
### BUGGY CODE ###

from collections import deque

H, W = map(int, input().split())

m = [['X' for i in range(W+2)]]
for i in range(H):
  row = [c for c in input()]
  row.insert(0, 'X')
  row.append('X')
  m.append(row)
m.append(['X' for i in range(W+2)])

# for i in m:
#   print(i)

q = deque([])

init = []
for i in range(1, 1+H):
  for j in range(1, 1+W):
    if m[i][j] == '#':
      init.append((i, j))
q.append(init)

cnt = 0
while(True):
  if not q:
    break
  tt = q.popleft()
  nn = []
  for t in tt:
    for d in ('left', 'right', 'up', 'down'):
      if d == 'left':
        n = (t[0]-1, t[1])
      elif d == 'right':
        n = (t[0]+1, t[1])
      elif d == 'up':
        n = (t[0], t[1]-1)
      elif d == 'down':
        n = (t[0], t[1]+1)
      if m[n[0]][n[1]] == '.':
        nn.append(n)
        m[n[0]][n[1]] = '#'
  if nn:
    q.append(nn)
  # print(q)
  # for i in m:
  #   print(i)
  # print()
  cnt += 1

print(cnt-1)


### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())

m = [['X'] * (W+2)]
for i in range(H):
  row = [c for c in input()]
  row.insert(0, 'X')
  row.append('X')
  m.append(row)
m.append(['X'] * (W+2))

q = deque([deque([(i, j) for j in range(1, 1+W) for i in range(1, 1+H) if m[i][j] == '#'])])

cnt = 0
while(True):
  if not q:
    break
  tt = q.popleft()
  nn = deque([])
  for t in tt:
    # left, right, up, down
    for n in ((t[0]-1, t[1]), (t[0]+1, t[1]), (t[0], t[1]-1), (t[0], t[1]+1)):
      if m[n[0]][n[1]] == '.':
        nn.append(n)
        m[n[0]][n[1]] = '#'
  if nn:
    q.append(nn)
  cnt += 1

print(cnt-1)
### BUGGY CODE ###

import pdb


def main():
    num = int(input())
    array = []
    tmp = input()
    for i in range(num):
        array.append(int(tmp.split()[i]))
        
    ans = 1
    div = 0
    prev = 0
    count = 0
    #pdb.set_trace()
    for tmp in array:
        count += 1
        if count == 1:
            prev = tmp
            continue

        if div == 0:
            if prev < tmp:
                div = 1
            elif prev > tmp:
                div = -1
        else:
            if prev < tmp and div == -1:
                ans += 1
                div = 0
            elif prev > tmp and div == 1:
                ans += 1
                div = 0
                
        prev = tmp
        
    print(ans)

        
if __name__ == '__main__':
    main()


### FIXED CODE ###

import pdb


def main():
    num = int(input())
    array = []
    tmp = input()
    tmp = tmp.split()
    for i in range(num):
        array.append(int(tmp[i]))
        
    ans = 1
    div = 0
    prev = 0
    count = 0
    #pdb.set_trace()
    for tmp in array:
        count += 1
        if count == 1:
            prev = tmp
            continue

        if div == 0:
            if prev < tmp:
                div = 1
            elif prev > tmp:
                div = -1
        else:
            if prev < tmp and div == -1:
                ans += 1
                div = 0
            elif prev > tmp and div == 1:
                ans += 1
                div = 0
                
        prev = tmp
        
    print(ans)

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

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from sys import stdin
import math
import copy

move_limit = 10 ** 5

rl_list  = stdin.readline()

before_child_list = [1] * (len(rl_list)-1)
now_child_list = [1] * (len(rl_list)-1)


# 多分、一定回数うごくと、あとは奇数回動かしたか偶数回動かしたかになる

for i in range(move_limit):
    for j in range(len(rl_list)-1):
        if rl_list[j] == 'R':
            now_child_list[j+1] += before_child_list[j]
            now_child_list[j] -= before_child_list[j]
# 'L'
        else:
            now_child_list[j-1] += before_child_list[j]
            now_child_list[j] -= before_child_list[j]
    before_child_list = copy.copy(now_child_list)

print(*now_child_list)


### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from sys import stdin
import math
import copy
# 多分、一定回数うごくと、あとは奇数回動かしたか偶数回動かしたかになる

#for i in range(move_limit):
#    for j in range(length):
#        if rl_list[j] == 'R':
#            now_child_list[j+1] += before_child_list[j]
#            now_child_list[j] -= before_child_list[j]
## 'L'
#        else:
#            now_child_list[j-1] += before_child_list[j]
#            now_child_list[j] -= before_child_list[j]
#    before_child_list = copy.copy(now_child_list)
#
#print(*now_child_list)



rl_list  = stdin.readline().strip()

length = len(rl_list) 

r_child_list = [0] * (length)
l_child_list = [0] * (length)
child_list = [0] * (length)

cnt = 0
for i in range(length):
    if rl_list[i] == 'R':
        cnt +=1
    else :#rl_list == 'L'
        r_child_list[i] += cnt
        cnt = 0
r_child_list[length-1] += cnt
for i in reversed(range(length)):
    if rl_list[i] == 'L':
        cnt += 1
    else :#rl_list == 'R':
        l_child_list[i] += cnt
        cnt = 0
l_child_list[0] += cnt
for i in range(length):
    if r_child_list[i] != 0:
        child_list[i] += math.floor(r_child_list[i] / 2)
        child_list[i-1] += math.ceil(r_child_list[i] / 2)
    if l_child_list[i] != 0:
        child_list[i] += math.floor(l_child_list[i] / 2)
        child_list[i+1] += math.ceil(l_child_list[i] / 2)

print(*child_list)
### BUGGY CODE ###

def main():
  N,K=map(int,input().split())
  h=list(map(int,input().split()))
  DP=[0]*N
  for i in range(1,N):
    min_k=float('inf')
    for j in range(max(i-K,0),i):
      min_k=min(min_k,DP[j]+abs(h[i]-h[j]))
    DP[i]=min_k
    pass
  print(DP[-1])

if __name__ == '__main__':
  main()



### FIXED CODE ###

def main():
  #import sys
  #input = sys.stdin.readline
  N,K=map(int,input().split())
  h=list(map(int,input().split()))
  DP=[0]*N
  DP[0]=0
  for i in range(1,N):
  #j=1
  #while j<=K and j<=i:
  #  DP[i]=min(DP[i],abs(h[i]-h[i-j])+DP[i-j])
  #for j in range(max(0, i-K),i):
    #DP[i]=min(DP[i],abs(h[i]-h[j])+DP[j])
    r=max(0, i-K)
    DP[i]=min([abs(h[i]-h[j])+DP[j] for j in range(r,i)])
  print(DP[-1])
if __name__ == '__main__':
  main()
### BUGGY CODE ###

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

from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

def main():
    sum = 0
    for i in range(1,n+1):
        if (i==a) or (i==b):
            continue
        sum += combinations_count(n,i)

    print(sum)

main()

### FIXED CODE ###

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

mod = 10**9+7

def combi(n,r):
    x, y = 1,1
    for i in range(n-r+1,n+1):
        x *= i
        x %= mod
        
    for j in range(1,r+1):
        y *= j
        y %= mod
    yinv = pow(y,mod-2,mod)
    
    return x*yinv%mod

def main():
    nca = combi(n,a)
    ncb = combi(n,b)
    ans = pow(2,n,mod)-1 - (nca + ncb)
        
    print(ans%mod)
    
main()
### BUGGY CODE ###

[N, K] = map(int, input().split())
A = list(map(int, input().split()))
count = 0
while len(A) != 1:
  A = A[K:] + [0]
  count = count + 1 
print(count)


### FIXED CODE ###

[N, K] = map(int, input().split())
A = list(map(int, input().split()))
print(-(-(N - 1) // (K - 1)))
### BUGGY CODE ###

N = int(input())
A = sorted(list(map(int, input().split())))
dp = {}
quota = 0
res = 0
baseSize = 0
for i in range(N-1):
  a = A[i]
  target = i+1
  baseSize += a
  size = baseSize
  while target < N and A[target] <= size*2:
    size += A[target]
    target += 1
  if target == N:
    res = target - i
    break

if res == 0:
  print(1)
else:
  print(res)


### FIXED CODE ###

N = int(input())
A = sorted(list(map(int, input().split())))
dp = {}
quota = 0
res = 0
size = 0
streak = 1
for i in range(N-1):
  a = A[i]
  size += a
  if A[i+1] <= size*2:
    streak += 1
  else:
    streak = 1

print(streak)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 7)
N, Q = map(int, input().split())
#link = [[0]*(N+1) for _ in range(N+1)]
link = [[] for _ in range(N+1)]
for n in range(N-1):
    a, b = map(int, input().split())
    # link[a][b] = 1
    # link[b][a] = 1
    link[a].append(b)
    link[b].append(a)
V = [0] * (N+1)
ans = [0] * (N+1)
for q in range(Q):
    p, x = map(int, input().split())
    V[p] += x

def dfs(i, parent, acc):
    V[i] += acc
    # for j in range(1,N+1):
    #     if link[i][j] == 1 and parent!=j:
    #         dfs(j,i,V[i])
    for j in link[i]:
        if j==parent:
            continue
        dfs(j,i,V[i])
cur = 1
parent = 0
acc = 0

dfs(cur, parent , acc)
V = [str(v) for v in V]
print (" ".join(V[1:]))

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

# 遅延評価で加えてあげるだけ

N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in PX:
    value[p] += x

def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])

dfs(1,0,0)

answer = ' '.join(map(str,value[1:]))
print(answer)
### BUGGY CODE ###

def bfs(graph, start, goal, connection):
    visited = {start: None}
    unvisited = [start]
    while unvisited:
        now = unvisited[0]
        if now == goal or (1000000*now + goal) in connection:
            connection[1000000*start + goal] = 1
            connection[1000000*goal + start] = 1
            return "yes"
        unvisited = unvisited[1:]
        for next in graph[now]:
            if not (next in visited):
                unvisited.append(next)
                visited[next] = now
    return "no"

n, m = map(int, input().split())
g = [[] for i in range(n)]
c = {}

for i in range(m):
    inp = list(map(int, input().split()))
    g[inp[0]].append(inp[1])
    g[inp[1]].append(inp[0])

q = int(input())

for i in range(q):
    s, t = map(int, input().split())
    print(bfs(g, s, t, c))

### FIXED CODE ###

from collections import deque

def bfs(graph, start):
    visited = {start: None}
    unvisited = deque()
    unvisited.append(start)
    while unvisited:
        now = unvisited.popleft()
        for next in graph[now]:
            if not (next in visited):
                unvisited.append(next)
                visited[next] = now
    return visited

n, m = map(int, input().split())
g = [set() for i in range(n)]
group = []

for i in range(m):
    a, b = map(int, input().split())
    g[a].add(b)
    g[b].add(a)

q = int(input())

for i in range(q):
    s, t = map(int, input().split())
    for j in range(len(group)):
        if s in group[j] and t in group[j]:
            print("yes")
            break
        elif s in group[j]:
            print("no")
            break
    else:
        group_tmp = set(bfs(g, s).keys())
        if t in group_tmp:
            print("yes")
        else:
            print("no")
        group.append(group_tmp)
### BUGGY CODE ###

def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    n = int(stdin.readline()[:-1])   
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    a = list(map(int, r.split()))
    #a, b = map(int, r.split())
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]

    ma = max(a)
    mi = min(a)
    res = a.count(mi)
    d = [i for i in a if ma != i or mi != i]
    for i in range(1,len(d)):
        b = a[:i]
        if min(b) >= a[i]:
            res += 1
    print(res)

    #'Yes', 'No', 'YES', 'NO', ':(', 'Yay!'
    #res = 0
    #a, b = map(int, r.split())
    #print()

if __name__ == '__main__':
    main()



### FIXED CODE ###

def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    n = int(stdin.readline()[:-1])   
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    a = list(map(int, r.split()))
    #a, b = map(int, r.split())
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]

    res = 1
    bk = a[0]
    for i in range(1,n):
        if bk >= a[i]:
            bk = a[i]
            res += 1
    print(res)


#    b = [0]*n
#    for i in range(n):
#        b[a[i]-1] = i

#    res = 0
#    mem = b[0]
#    for i in range(1,n):
#        if mem <= b[i]:
#            print(b[i])
##            mem = b[i]
#        else:
#            res += 1
#    print(res)

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

N,X,Y = map(int,input().split())
from collections import defaultdict as ddict
ans = ddict(int)
for n in range(N):
    for i in range(n+1,N):
        s = i+1
        d = n+1
        p1 = abs(s-d)
        p2 = abs(s-X)+abs(d-Y)+1
        p3 = abs(s-Y)+abs(d-X)+1
        ans[min(p1,p2,p3)] += 1
for n in range(1,N):
    print(ans[n])


### FIXED CODE ###

N,X,Y = map(int,input().split())
from collections import defaultdict as ddict
ans = ddict(int)
for n in range(N):
    for i in range(n+1,N):
        s = i+1
        d = n+1
        p1 = abs(s-d)
        p2 = abs(s-X)+abs(d-Y)+1
        p3 = abs(s-Y)+abs(d-X)+1
        ans[min(p1,p2,p3)] += 1
for n in range(1,N):
    print(ans[n])
### BUGGY CODE ###

N, M = map(int, input().split())
a = [int(i) for i in input().split()]

dic = {}
dic[1] = 2
dic[2] = 5
dic[3] = 5
dic[4] = 4
dic[5] = 5
dic[6] = 6
dic[7] = 3
dic[8] = 7
dic[9] = 6

ls = [-1]*8
dp = [-1]*(N+1)
dp[0] = ''
for i in a:
  j = dic[i]
  if ls[j]<i:
    ls[j] = i

tag = []
for i in range(len(ls)):
  if ls[i]!=-1:
    tag += [i]
for i in range(N+1):
  for j in tag:
    if i-j>-1 and dp[i-j]!=-1:
      s = str(ls[j])+str(dp[i-j])
      s = int(s)
      if i-j==0 and dp[i]<s:
        dp[i] = s
      elif dp[i]<s:
        dp[i] = s
m = 0

print(dp[N])


### FIXED CODE ###

n,m=map(int,input().split())
A=list(map(int,input().split()))
L=[0,2,5,5,4,5,6,3,7,6]
dp=[0]+[-1]*n
for i in range(n+1):
  for a in A:
    if i+L[a]<=n:
      dp[i+L[a]]=max(dp[i+L[a]],dp[i]*10+a)
print(dp[n])
### BUGGY CODE ###



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

count = n

shakutori = [0] 

max_limit = 2**20 - 1
for i in range(len(a)):
    shakutori.append(shakutori[i] + a[i])

for l in range(0, n):
    left = a[l]
    for r in range(l + 1,n):

        right = shakutori[r+1] - shakutori[l]

        left ^= a[r]

        if left >=  max_limit:
            break


        if right == left:
            count += 1
print(count)







### FIXED CODE ###

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

count = 0

xor_temp = 0
sum_temp = 0

r = 0
for l in range(n):
    while r < n and xor_temp^a[r]  == sum_temp + a[r]:
        xor_temp ^= a[r]
        sum_temp += a[r]
        r += 1

    xor_temp ^= a[l]
    sum_temp -= a[l]
    count += r - l

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

# -*- coding: utf-8 -*-
n,k=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
p=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
max = 0
#最大のリストを選定
before_pi = 0
for i in range(0,n-k+1):
    if before_pi > p[i+k-1]:
        before_pi = p[i]
        continue
    ck = sum(p[i:i+k])
    if ck > max:
        max = ck

#計算
print((max+k)/2.0)


### FIXED CODE ###

# -*- coding: utf-8 -*-
n,k=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
p=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
#最大のリストを選定
before_pi = p[0]
before_sum = sum(p[0:k])+ 0.0
suml = [sum(p[0:k])]
for i in range(1,n-k+1):
    before_sum = before_sum - before_pi+p[i+k-1]
    suml.append(before_sum)
    before_pi = p[i]

#計算
print((max(suml)+k)/2.0)