Harryxun/stf_run huggingface dataset:
#                          JAI SHREE RAM

import math; from collections import *
import sys; from functools import reduce

# sys.setrecursionlimit(10**6)
def get_ints(): return map(int, input().strip().split())
def get_list(): return list(get_ints())
def get_string(): return list(input().strip().split())
def printxsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")

UGLYMOD = int(1e9)+7; SEXYMOD = 998244353; MAXN = int(1e5)

# sys.stdin=open("input.txt","r");sys.stdout=open("output.txt","w")

# for _testcases_ in range(int(input())):
s = input()
n = s = e = w = False
if 'N' in s: n = True
if 'S' in s: s = True
if 'E' in s: e = True
if 'W' in s: w = True
print("Yes" if not(n^s) and not(e^w) else "No")


'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS MINE @luctivud ( UDIT GUPTA )
Link may be copy-pasted here if it's taken from other source.
DO NOT PLAGIARISE.
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

### FIXED CODE ###

#                          JAI SHREE RAM

import math; from collections import *
import sys; from functools import reduce

# sys.setrecursionlimit(10**6)
def get_ints(): return map(int, input().strip().split())
def get_list(): return list(get_ints())
def get_string(): return list(input().strip().split())
def printxsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")

UGLYMOD = int(1e9)+7; SEXYMOD = 998244353; MAXN = int(1e5)

# sys.stdin=open("input.txt","r");sys.stdout=open("output.txt","w")

# for _testcases_ in range(int(input())):
st = input()
n = s = e = w = False
if 'N' in st: n = True
if 'S' in st: s = True
if 'E' in st: e = True
if 'W' in st: w = True
print("Yes" if not(n^s) and not(e^w) else "No")


'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS MINE @luctivud ( UDIT GUPTA )
Link may be copy-pasted here if it's taken from other source.
DO NOT PLAGIARISE.
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''
A,B,K = map(int,input().split())
count = min(A,B)
k = 0
while count > 0:
  if A%count == 0 nad B%count == 0:
    k += 1
  if k == K:
    print(count)
    break
  else:
    count -= 1

### FIXED CODE ###

A,B,K = map(int,input().split())
count = min(A,B)
k = 0
while count > 0:
  if A%count == 0 and B%count == 0:
    k += 1
  if k == K:
    print(count)
    break
  else:
    count -= 1
n,k =map(int,input().split())
a=[-1 for x in range(n)]

def kaijo(x):
	if x<=1:
		return 1
	if a[x-1]==-1:
		a[x-1]=x*kaijo(x-1)
	return a[x-1]

for i in range(1,k+1):
	c=kaijo(k-1)/kaijo(k-i)/kaijo(i-1)*kaijo(n-k+1)/kaijo(i)/kaijo(n-k+1-i)
	print('{}'.format(c))

### FIXED CODE ###

from operator import mul
from functools import reduce

n,k=map(int,input().split())

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(lambda x,y: x*y ,range(n,n-r,-1))
    under = reduce(mul,range(1,r+1))
    return over // under %(1000000000+7)

for i in range(1,k+1):
    c=0
    if i<=n-k+1:
        c=cmb(n-k+1,i)*cmb(k-1,i-1)%(1000000000+7)
    print("{}".format(c))
N = int(input())
s = [sorted(input()) for _ in range(N)]
s_dict = {}
sum = 0
for i in range(N):
    if s[i] in s_dict.keys():
        sum +=s_dict[s[i]]
        s_dict[s[i]] += 1
    else:
        s_dict[s[i]] = 1
print(sum)

### FIXED CODE ###

N = int(input())
s = [''.join(sorted(input())) for _ in range(N)]

s_dict ={}
ans = 0
for i in range(N) :
    if s[i] in s_dict.keys() :
        ans += s_dict[s[i]]
        s_dict[s[i]] += 1
    else :
        s_dict[s[i]] = 1
print(ans)
N = int(input())
K = int(input())
pi = list(int(x) for x in input().split())

max = 0
maxi = 0
for i range(N - K):
    sum = pi(i) + pi(i + 1) + pi(i + 2)
    if sum >= max:
        max = sum
        maxi = i

out = 1 + (pi(i) - 1) * 0.5 + 1 + (pi(i + 1) - 1) * 0.5 + 1 + (pi(i + 2) - 1) * 0.5
print(out)

### FIXED CODE ###

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

tmp = sum(pi[0 : K])
max = tmp

if N == K:
    print((max + K) / 2)
else:
    for i in range(N - K):
        tmp = tmp - pi[i] + pi[i + K]
        if tmp > max:
            max = tmp
    print((max + K) / 2)
N=int(input())
A=list(list(map(int,input().split())))
ans=0
hoge=0
for i in range(N-1):
  if A[i] >A[i+1]:
    hoge+=1
    ans=max(ans,hoge)
    else:
       hoge=0
print(ans)


### FIXED CODE ###

N = int(input())
H = list(map(int,input().split()))
ans = 0
x = 0
for i in range(N-1):
  if H[i] >= H[i+1]:
    x += 1
    ans = max(ans,x)
  else:
    x = 0
print(ans)
a,b=(int(x) for x in input().split())
if a=='H':
    if b=='H':
        print("H")
    elif b=='D':
        print("D")
elif a=='D':
    if b=='H':
        print("D")
    elif b=='D':
        print("H")

### FIXED CODE ###

a,b=input().split()
if a=='H':
    if b=='H':
        print("H")
    elif b=='D':
        print("D")
elif a=='D':
    if b=='H':
        print("D")
    elif b=='D':
        print("H")
import itertools

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

int_tuple_list = list()
for i in range(Q):
    int_tuple_list.append(tuple(map(int, input().split())))

m_list = [i for i in range(1, M + 1)]
# print(m_list)
all_sequence_list = list()
score_list = list()
for sequence in itertools.combinations(m_list, N):
    # print(sequence)
    score_tmp = 0
    for ai, bi, ci, di in int_tuple_list:
        if ci == sequence[bi - 1] - sequence[ai - 1]:
            score_tmp += di

    # print(score_tmp)
    score_list.append(score_tmp)

print(max(score_list))



### FIXED CODE ###

import itertools
 
N, M, Q = map(int, input().split())
 
int_tuple_list = list()
for i in range(Q):
    int_tuple_list.append(tuple(map(int, input().split())))
 
m_list = [i for i in range(1, M + 1)]
# print(m_list)
all_sequence_list = list()
score_list = list()
for sequence in itertools.combinations_with_replacement(m_list, N):
    # print(sequence)
    score_tmp = 0
    for ai, bi, ci, di in int_tuple_list:
        if ci == sequence[bi - 1] - sequence[ai - 1]:
            score_tmp += di
 
    # print(score_tmp)
    score_list.append(score_tmp)
 
print(max(score_list))
# coding: utf-8
# Your code here!

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

l = [input() for i in range(b)]

l = sorted(l)
new_l = ''.join(l)
print(new_l)

### FIXED CODE ###

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

l = [input() for i in range(a)]

l.sort()
print("".join(l))
import math
n = int(input())
t = [int(input()) for i in range(n)]

for i in range(n - 1):
    t[i + 1] = t[i] * t[i + 1] // math.gcd(t[i], t[i + 1])

print(t[n - 1])


### FIXED CODE ###

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

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


for i in range(n - 1):
    t[i + 1] = t[i] * t[i + 1] // gcd(t[i], t[i + 1])

print(t[n - 1])
r = int(input())
 
print(math.pi * r * 2)

### FIXED CODE ###

import math

r = int(input())

print(math.pi * r * 2)
from collections import deque
from collections import defaultdict
import heapq

N,M=map(int, raw_input().split())
cost=map(int, raw_input().split())

if M==N-1:
	print 0
	quit()

nl=[ [] for i in range(N) ]

for i in range(M):
	x,y=map(int,raw_input().split())
	nl[x].append(y)
	nl[y].append(x)


d=[ None for i in range(N) ]
V=[ None for i in range(N) ]

group_cost=defaultdict(lambda: [])

def dfs(start):
	q = deque([]) 
	V[start]=start
	d[start]=0
	heapq.heappush(group_cost[start],cost[start])
	q.append(start)

	while len(q)!=0:
		v=q.pop()
		for i in nl[v]:
			if V[i] is None:
				V[i]=start
				q.append(i)
				heapq.heappush(group_cost[start],cost[i])

while None in V:
	i=V.index(None)
	dfs(i)


edges=(N-M-1)*2

ans=0
for i in group_cost.keys():
	ans+=heapq.heappop(group_cost[i])
	edges-=1

nokori_cost=[]
if edges==0:
	print ans
	quit()
else:
	for i in group_cost.values():
		nokori_cost+=i

	if len(nokori_cost)<edges:
		print "Impossible"
		quit()

	for i in range(edges):
		ans+=heapq.heappop()
	print ans




### FIXED CODE ###

from collections import deque
from collections import defaultdict
import heapq

N,M=map(int, raw_input().split())
cost=map(int, raw_input().split())

if M==N-1:
	print 0
	quit()

nl=[ [] for i in range(N) ]

for i in range(M):
	x,y=map(int,raw_input().split())
	nl[x].append(y)
	nl[y].append(x)


d=[ None for i in range(N) ]
V=[ None for i in range(N) ]

group_cost=defaultdict(lambda: [])

def dfs(start):
	q = deque([]) 
	V[start]=start
	d[start]=0
	heapq.heappush(group_cost[start],cost[start])
	q.append(start)

	while len(q)!=0:
		v=q.pop()
		for i in nl[v]:
			if V[i] is None:
				V[i]=start
				q.append(i)
				heapq.heappush(group_cost[start],cost[i])

for i in range(N):
	if V[i] is None:
		dfs(i)


H = []

ans=0
for v in group_cost.values():
	v=sorted(v)
	ans+=v[0]
	H.append(v[1:])

nokori_cost=list(heapq.merge(*H))


if N < 2*(N-M-1):
	print "Impossible"
elif M == N-1:
	print 0
else:
	ans += sum(nokori_cost[:2*(N-M-1) - len(group_cost.keys())])
	print ans
while True:
    a_2 = 0
	n = int(input())
	if n == 0
		break
	
	score = [int(x) for x in input().split()]
	m = some(score)/len(score)

	for i in range(len(score)):
		a += (score[i]-m)*(score[i]-m)/n
	
	print('%.4f', a)

### FIXED CODE ###

import math
while True:
	a_2 = 0
	n = int(input())
	if n == 0:
		break
	
	score = [int(x) for x in input().split()]
	m = sum(score)/len(score)
	#print(m)

	for i in range(len(score)):
		a_2 += (score[i]-m)*(score[i]-m)/n
		#print(a_2)
	print('%.4f'% math.sqrt(a_2))
print(['vowel','consonant'][['a','e','i','o','u'].in(input())])

### FIXED CODE ###

print("vowel" if input() in ["a","e","i","o","u"] else "consonant")
from collections import Counter
n=int(input())
a=[input() for i in range(n)]
m=int(input())
b=[input() for i in range(m)]
ca = Counter(a)
cb = Counter(b)
ans = 0
for s,n in ca.items():
  ans.append(n-cb[s])
print(max(ans))

### FIXED CODE ###

from collections import Counter
n=int(input())
a=[input() for i in range(n)]
m=int(input())
b=[input() for i in range(m)]
ca = Counter(a)
cb = Counter(b)
ans = [0]
for s,n in ca.items():
  ans.append(n-cb[s])
print(max(ans))
import sys
input = sys.stdin.readline

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

def yakusu(x,X):
    for i in range(1,int(x**0.5)+1):
        if x%i==0:
            X.append(i)
            x//=i

A=[]
B=[]
yakusu(a,A)
yakusu(b,B)
ans=0
i=0
j=0
while i<len(A) and j<len(B):
    if A[i]==B[i]:
        ans+=1
        i+=1
        j+=1
    elif A[i]>B[j]:
        j+=1
    else:
        i+=1
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

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

def yakusu(x,X):
    for i in range(1,int(x**0.5)+1):
        if x%i==0:
            X.append(i)
            if x!=i:
                X.append(x//i)
    
A=[]
B=[]
yakusu(a,A)
yakusu(b,B)
A.sort()
B.sort()
#print(A,B)
kouyakusu=[]
i=0
j=0
while i<len(A) and j<len(B):
    if A[i]==B[j]:
        kouyakusu.append(A[i])
        i+=1
        j+=1
    elif A[i]>B[j]:
        j+=1
    else:
        i+=1

ans=0
for i in range(1,len(kouyakusu)):
    if not(kouyakusu[i]): continue
    ans+=1
    for j in range(i+1,len(kouyakusu)):
        if kouyakusu[j]%kouyakusu[i]==0:
            kouyakusu[j]=False
#print(kouyakusu)
print(ans+1)
#encoding=utf-8
import sys

def inp():
	for i in sys.stdin:
		xa,ya,xb,yb,xc,yc,xd,yd = map(float, i.split(","))	
		print hantei(xa,ya,xb,yb,xc,yc,xd,yd)

def hantei(xa,ya,xb,yb,xc,yc,xd,yd):
	count = [0,0,0,0]
	a1 = (ya - yc)/(xa - yc)
	b1 = ya - a1*xa

	a2 = (yb - yd)/(xb - xd)
	b2 = yb - a2*xb

	if xb*a1+b1 > yb:
		count[0] += 1
	else:
		count[1] += 1
	if xd*a1+b1 > yd:
		count[0] += 1
	else:
		count[1] += 1
	if xa*a2+b2 > ya:
		count[2] += 1
	else:
		count[3] += 1
	if xc*a2+b2 > yc:
		count[2] += 1
	else:
		count[3] += 1

	for i in xrange(4):
		if count[i] != 1:
			return "NO"
		else:
			pass
	return "YES"

inp()

### FIXED CODE ###

def S(x1,y1,x2,y2,x3,y3):
    return ((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1))/2.0
import sys
for dataset in sys.stdin:
    xa,ya,xb,yb,xc,yc,xd,yd=map(float,dataset.split(","))
    ABC=S(xa,ya,xb,yb,xc,yc)
    BCD=S(xb,yb,xc,yc,xd,yd)
    CDA=S(xc,yc,xd,yd,xa,ya)
    DAB=S(xd,yd,xa,ya,xb,yb)
    if ABC>0 and BCD>0 and CDA>0 and DAB>0:
        print "YES"
    elif ABC<0 and BCD<0 and CDA<0 and DAB<0:
        print "YES"
    else:
        print "NO"
ans=0
for s not in raw_input():
  if s in "ACGT":
    ans+=1
print ans


### FIXED CODE ###

s=-1
S=raw_input()+"!"
ans=0
for i in range(len(S)):
  if S[i]in "ATCG":
    if s==-1:
      s=i
  elif s!=-1:
    ans=max(ans, i-s)
    s=-1
print ans
def solve():
    a = raw_input()
    n = len(a)
    cost = [[0 for i in range(n)] for j in range(n)]
 
    for length in range(2, n+1):
        for i in range(0, n-length+1):
            k = i+length-1
            def f(i,j,k):
                return cost[i][j-1]+cost[j][k]+M[i][0]*M[j-1][1]*M[k][1]
            cost[i][k] = min([f(i,j,k) for j in range(i+1,k+1)])
    return cost[0][n-1]
 
n = raw_input()
M = []
for i in range(n):
    M.append(map(int, raw_input().split()))
     
print solve(M)

### FIXED CODE ###

def solve(a):
 n = len(a)
 cost = [[0 for i in range(n)] for j in range(n)]
 for length in range(2, n+1):
  for i in range(0, n-length+1):
   k = i+length-1
   def f(i,j,k):
    return cost[i][j-1]+cost[j][k]+M[i][0]*M[j-1][1]*M[k][1]
   cost[i][k] = min([f(i,j,k) for j in range(i+1,k+1)])
 return cost[0][n-1]
n = input()
M = []
for i in range(n):
 M.append(map(int, raw_input().split()))
print solve(M)
#!/usr/bin/env python3
N, M = map(int, input().split())
A = sorted(map(int, input().split()), reverse=True)

inf = float('inf')
num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [0] + [-inf] * N
for i in range(N + 1)[1::]:
    for x in A:
        if i >= num[x]:
            dp[i] = max(dp[i], dp[i - num[x]] + 1)

ans = ''
while N > 0:
    for x in A:
        if dp[N - num[x]] == dp[N] - 1:
            ans += str(x)
            N -= num[x]
            break

print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
N, M = map(int, input().split())
A = sorted(map(int, input().split()), reverse=True)

inf = float('inf')
num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [0] + [-inf] * N
for i in range(N + 1)[1::]:
    for x in A:
        if i >= num[x]:
            dp[i] = max(dp[i], dp[i - num[x]] + 1)

ans = ''
while N > 0:
    for x in A:
        if N >= num[x] and dp[N - num[x]] == dp[N] - 1:
            ans += str(x)
            N -= num[x]
            break

print(ans)
a,b,c,d = int(input().split())

print(max(a*c, a*d, b*c, b*d))

### FIXED CODE ###

a,b,c,d = map(int,input().split())

print(max(a*c, a*d, b*c, b*d))
N = int(input())
n = list(map(int,input().split()))
ans  = 0
for i in range(N):
    if n[n[i]-1] == i:
        ans += 1 
print(ans)

### FIXED CODE ###

s= str(input())
print(s[0:4]+" "+s[4:])
N, M = list(map(int, input().split()))

As = list(map(int, input().split()))
As.sort()

BCs = []
for _ in range(M):
  b, c = tuple(map(int, input().split()))
  BCs.append((b, c))
BCs.sort(key=lambda x: x[1], reverse=True)
  
num = 0
i = 0
for b, c in BCs:
  for j in range(b):
    a = As[i]
    if a >= c or i == len(As):
      break
    else:
      num += c
      i += 1
  if a >= c or i == len(As):
    break
num += sum(As[i: ])
    
print(num)

### FIXED CODE ###

A, B = [int(x) for x in input().split(' ')]

if A >= 13:
  print(B)
elif 6 <= A < 13:
  print(B//2)
else:
  print(0)
import sys
import numpy as np
import math
import collections
from collections import deque 
from functools import reduce

# input = sys.stdin.readline

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ai, bi = 0, 0
a.append(10**10)
b.append(10**10)
cnt = 0
tt = 0
cnt = 0
tt = 0
cnt = 0
tt = 0
while True:
    if a[ai] == b[bi]:
        aii = ai + 1
        bii = bi + 1
        while True:
            if a[aii] == b[bii]:
                aii += 1
                bii += 1
                continue
            if a[aii] < b[bii]:
                flg = 'a'
                break
            else:
                flg = 'b'
                break
    elif a[ai] > b[bi]:
        flg = 'b'
    else:
        flg = 'a'

    if flg == 'b':
        if (tt + b[bi] > k):
            break
        cnt += 1
        tt += b[bi]
        bi += 1
    else:
        if (tt + a[ai] > k):
            break
        cnt += 1
        tt += a[ai]
        ai += 1
                
print(cnt)

### FIXED CODE ###

import sys
import numpy as np
import math
import collections
from collections import deque 
from functools import reduce

# input = sys.stdin.readline
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a_t, b_t = [0], [0]
for i in range(n):
    a_t.append(a_t[i] + a[i])
for i in range(m):
    b_t.append(b_t[i] + b[i])
ans = 0
j = m
for i in range(n+1):
    if (a_t[i] > k):
        break
    while(a_t[i] + b_t[j] > k):
        j -= 1
    ans = max(ans, i + j)
print(ans)
n = int(input())
print(len(set(map(int, [input for i in range(n)]))))

### FIXED CODE ###

n = int(input())
print(len(set(map(int, [input() for i in range(n)]))))
N = int(input()) 
S = [int(input()) for i in range(N)]
S.sort()
max_ans = sum(S)

if max_ans % 10 == 0:
  i = 0
  while S[i] % 10 == 0:
    i += 1
    if i == N-1:
      print(0)
      exit(0)
  ans = max_ans - S[i]
  print(ans)
else:
  print(max_ans)

### FIXED CODE ###

N = int(input()) 
S = [int(input()) for i in range(N)]
S.sort()
max_ans = sum(S)

if N == 1:
  if max_ans % 10 == 0:
    print(0)
    exit(0)
  else:
    print(max_ans)
    exit(0)
if max_ans % 10 == 0:
  i = 0
  while S[i] % 10 == 0:
    i += 1
    if i == N-1:
      print(0)
      exit(0)
  ans = max_ans - S[i]
  print(ans)
else:
  print(max_ans)
while True:
    input = list(map(int,list(input())))
    if input == [0]:
        break
    else:
        print(sum(input))

### FIXED CODE ###

while True:
    i = list(map(int,list(input())))
    if i == [0]:
        break
    else:
        print(sum(i))
A, B = map(int, input().split())
if A == B:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

A, B = map(int, input().split())
if A == B:
    print('Yes')
else:
    print('No')
n=int(input())
h=list(map(int,input().split()))
dp=[10**6]*n
dp[0]=0
dp[1]=dp[0]+abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min((dp[i-1]+abs(h[i]-h[i-1])),(dp[i-2]+abs(h[i]-h[i-2])))
print(dp(n-1))


### FIXED CODE ###

n=int(input())
h=list(map(int,input().split()))
dp=[10**6]*n
dp[0]=0
dp[1]=dp[0]+abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min((dp[i-1]+abs(h[i]-h[i-1])),(dp[i-2]+abs(h[i]-h[i-2])))
print(dp[n-1])
f=lambda:map(int,input().split())
N,K=f()
A=list(f())

def isOK(X):
    return sum([-a//X*-1-1 for a in A])<=K


ok=10**10
ng=-1
while abs(ok-ng)>1:
    mid=(ok+ng)//2
    if isOK(mid):
        ok=mid
    else:
        ng=mid
print(ok)

### FIXED CODE ###

f=lambda:map(int,input().split())
N,K=f()
A=list(f())

def isOK(X):
    if X<=0:
        return False
    return sum([-a//X*-1-1 for a in A])<=K


ok=10**10
ng=-1
while abs(ok-ng)>1:
    mid=(ok+ng)//2
    if isOK(mid):
        ok=mid
    else:
        ng=mid
print(ok)
import math
try:
    A,B = map(int,input().split())
    def lcm(x, y):
        return (x * y) // math.gcd(x, y)
    print(lcm(A,B))
except EOFError:
    pass

### FIXED CODE ###

import fractions
try:
    A,B = map(int,input().split())
    def lcm(x, y):
        return (x * y) // fractions.gcd(x, y)
    print(lcm(A,B))
except EOFError:
    pass
N,A=int(input()),list(map(int,input().split()))
A=sorted(A,key=int)
l=[0]*(A[-1]+1)
for i in A:
    if l[i]==1:
        print("NO")
        exit()
    else:
        l[i]=1
print("YES")

### FIXED CODE ###

N,A=int(input()),list(map(int,input().split()))
A=sorted(A,key=int)
l=set([])
for i in A:
    if i in l:
        print("NO")
        exit()
    else:
        l.add(i)
print("YES")
n, m = [int(s) for s in input().split()]
s = [int(s) for s in input()]
board = [None]*(n+1)
left = 0
for i in range(1,n+1):
    if s[i]:
        continue
    left = max(left, i-m)
    while s[left]:
        left += 1
        if left >= i:
            break
    if left < i:
        board[i] = left
print(board)
if board[n] is None:
    print(-1)
else:
    steps = []
    j = n
    while True:
        step = j - board[j]
        steps.append(step)
        j = board[j]
        if j==0:
            break
    print(' '.join(str(s) for s in steps[::-1]))


### FIXED CODE ###


n, m = [int(s) for s in input().split()]
s = [int(s) for s in input()]
board = [None]*(n+1)
left = 0
board[left] = 0
for i in range(1,n+1):
    if s[i]:
        continue
    left = max(left, i-m)
    while board[left] is None:
        left += 1
        if left == i:
            break
    if left < i:
        board[i] = left
# print(board)
if board[n] is None:
    print(-1)
else:
    steps = []
    j = n
    while True:
        step = j - board[j]
        steps.append(step)
        j = board[j]
        if j==0:
            break
    print(' '.join(str(s) for s in steps[::-1]))
n = int(input())
l = map(int,input().split())
print(max(l) - min(l))

### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
print(max(l) - min(l))
import numpy as np

def main():
    input_string = list(map(int,input().split()))
    N = input_string[0]
    C = input_string[1]
    data = []
    for i in range(N):
        data.append(list(map(int,input().split())))

    data_np = np.array(data).reshape(N,3)

    max_time = max(data_np[:,1])
    schedule = np.zeros([max_time,C])

    for i in range(N):
        start = data[i][0]-1
        end = data[i][1]-1
        channel = data[i][2]-1
        for j in range(end-start+1):
            schedule[start+j][channel] = 1

    for c in range(C):
        for t in range(N):
            if t==0:continue
            if schedule[t][c]==1 and schedule[t-1][c]==0:
                schedule[t-1][c]=1

    max_N =0
    for t in range(max_time):
        sum_of_ch = sum(schedule[t])

        if sum_of_ch>max_N:
            max_N = int(sum_of_ch)
    print(max_N)







main()


### FIXED CODE ###

def main():
    input_string = list(map(int,input().split()))
    N = input_string[0]
    C = input_string[1]
    data = []
    max_time = 0
    for i in range(N):
        data.append(list(map(int,input().split())))
        max_num = max(data[i])
        if max_num>max_time:
            max_time=max_num

    #data_np = np.array(data).reshape(N,3)
    #data_np = np.array(data)

    #max_time = int(max(data))
    #print("max",max_time)
    schedule = [[0]*C for i in range(max_time)]
    #schedule = np.zeros([max_time,C])

    for i in range(N):
        start = data[i][0]-1
        end = data[i][1]-1
        channel = data[i][2]-1
        for j in range(end-start+1):
            if start+j-1<0:continue
            schedule[start+j-1][channel] = 1

#    for c in range(C):
#        for t in range(max_time):
#            if t==0:continue
#            if schedule[t][c]==1 and schedule[t-1][c]==0:
#                schedule[t-1][c]=1

    #max_N =0
    #for t in range(max_time):
    #    sum_of_ch = sum(schedule[t])

    temp = list(map(sum,list(schedule)))
    max_N = int(max(temp))


    #    if sum_of_ch>max_N:
    #        max_N = int(sum_of_ch)
    print(max_N)







main()
import sys
import numpy as np
from collections import defaultdict

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = np.array([0] + lr())
A = (A-1) % K
Acum = A.cumsum()
counter = defaultdict()
answer = 0
for i, x in enumerate(Acum):
    answer += counter[x]
    counter[x] += 1
    if i >= K-1:
        counter[Acum[i-(K-1)]] -= 1

print(answer)


### FIXED CODE ###

import sys
import numpy as np
from collections import defaultdict

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = np.array([1] + lr())
A = (A-1) % K
N += 1
Acum = (A.cumsum() % K).tolist()
d = defaultdict(int)
answer = 0
for i, x in enumerate(Acum):
    answer += d[x]
    d[x] += 1
    if i >= K-1:
        d[Acum[i-(K-1)]] -= 1

print(answer)