peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
# atCoder:
# 1e8: 546 ms
# 1e7: 
# 
#


#import sys
#import platform

#print(sys.version)
#print(platform.architecture())

n = int(1e7)

p = 1
x = (1 << 32) - 1
#print(4294967295 == x)
#print(100000000 == n)

for i in range(1, n + 1):
    p += i
    p %= x

# should be 988623866
print(p)
# Judge status: Wrong Answer
N,M = map(int,input().split())
H = list(map(int,input().split()))
A_B = [list(map(int, input().split())) for _ in range(M)]

H_list = []
ans = []

for t in A_B:
  T = []
  T1 = T.append(H[t[0]-1])
  T2 = T.append(H[t[1]-1])
  H_list.append(T)
  if T[0] == T[1]:
    continue
  elif T[0] > T[1]:
    ans.append(T[0])
  else:
    ans.append(T[1])

H_list2 = list(set(sum(H_list,[])))
H_last = list(set(H_list2)^set(H))
if H_last != []:
  ans.append(H_last[0])
else:
  pass
print(len(set(ans)))
# Judge status: Accepted
a, b, c, d = map(int, input().split())

if a <= c and c <= b and b <= d:
  print(b-c)
elif c <= a and a <= d and d <= b:
  print(d-a)
elif a <= c and d <= b:
  print(d-c)
elif c <= a and b <= d:
  print(b-a)
else:
  print(0)
# Judge status: Accepted
n, k = map(int, input().split())
P = list(map(int, input().split()))

import numpy as np

max_v = np.sum(P[:k])

#print(max_v)
j = 0
cum = 0

temp_max = max_v

for i in range(k, n):
  temp_max += P[i]
  temp_max -= P[i-k]
  if temp_max>max_v:
    max_v = temp_max
    j=i-k
              
ans = (max_v+k)/2
print(ans)
#print(max_v)
# Judge status: Wrong Answer
a=int(input())
import math
x=math.factorial(a)
print(x//(10**9+7))
# Judge status: Accepted
A,B = map(int,input().rstrip().split())

n = m = 1
flg = 0
an = A
bm = B

while flg ==0:
  an = A * n
  bm = B* m
  if an == bm :
    flg = 1
    res = an
  elif an < bm:
    n += 1
  else :
    m += 1 
  
print(an)
# Judge status: Wrong Answer
N = int(input())
S = input()

ans = 0
highest = 0
for i in S:
    if i == "I":
        ans += 1
    else:
        ans -= 1
    print(ans)
    if highest <= ans:
        highest = ans 

print(highest)
# Judge status: Accepted

N=int(input())

if N%2==1:
    print((int(N/2)+1)/N)
else:
    print(1/2)
# Judge status: Accepted
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
s = input() #sys.stdin.readlineは最後が改行
t = input() #sys.stdin.readlineは最後が改行

ans = 2*n
for i in range(n):
    if s[i:n] == t[:(n-i)]:
        print(2*n-(n-i))
        exit()

print(2*n)
# Judge status: Accepted
from collections import Counter
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = Counter([e+i+1 for i,e in enumerate(a)])
    c = Counter([i+1-e for i,e in enumerate(a) if i+1-e > 1])
    ans = 0
    for i in c:
        ans += b[i] * c[i]
    print(ans)
if __name__ == '__main__':
    main()
# Judge status: Accepted
s = input()
s = s[0:-1]
if len(s) % 2 != 0:
    s = s[:-1]

for i in reversed(range(0, len(s)+2, 2)):
    half = i//2
    if s[:half] == s[half:]:
        print(len(s))
        break
    s = s[:-2]
# Judge status: Wrong Answer
N = int(input())
S = str(input())
S = list(S)
c = 0

for i in range(N):
    if S[i] == '#':
        for j in range(N-i):
            if S[i+j] == '.':
                c += 1
    break
                
print(c)
# Judge status: Wrong Answer
a = [int(input()) for i in range(5)]
k = int(input())

for i in range(4):
    if a[i] - a[0] > k:
        print(':(')
        exit()
print('Yay!')
# Judge status: Wrong Answer
s = input()
q = int(input())
a = [s]

for i in range(q):
    so = input()
    if so == '1':
        a[0], a[-1] = a[-1], a[0]
    else:
        d, f, c = so.split()
        if f == '1':
            a.insert(0, c)
        else:
            a.insert(-1, c)


print(''.join(a))
# Judge status: Wrong Answer
c=raw_input()
if c=="a,e,i,o,u":
  print "vowel"
else:
  print "consonant"
# Judge status: Wrong Answer
s = input()
t = input()

s = sorted(s)
t = sorted(t)
l = min([len(s),len(t)])

for i in range(l):
    dec = sorted(s[i] + t[-(i+1)])
    if (dec[0] == t[-(i+1)]) & (dec[0] != s[i]):
        print("No")
        break
    elif (i == l-1):
        if (len(s) >= len(t)):
            print("No")
        else:
            print("Yes")
# Judge status: Wrong Answer
n = int(input())
sn = str(n)
n3 = 0
minx = 0
temp = 753
sav = 0
for i in range(len(str(n//100))):
    n3 = int(sn[i:i+3])
    minx = abs(753-n3)
    if temp > minx:
        temp = minx
        sav = n3

print(sav)
# Judge status: Accepted
x,y = map(int,input().split())
list1 =[1,3,5,7,8,10,12]
list2 =[4,6,9,11]
if x == 2 or y == 2:
    print("No")
elif x in list1 and y in list1:
    print("Yes")
elif x in list2 and y in list2:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N = int(input())
p = list(map(int, input().split()))

q = sorted(p)

cor = q[int(N/2)] - q[int(N/2 - 1)]



if cor == 0:
 print(0)
else:
 print(cor + 1)
# Judge status: Accepted
import math
A,B = map(int,input().split())
if (A+1)/0.08 > B/0.1 and (B+1)/0.1 > A/0.08:
    print(max(math.ceil(A/0.08),math.ceil(B/0.1)))
else:
    print(-1)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt = [0, 0]
for ea, eb in zip(a, b):
    if ea > eb:
        cnt[1] += ea - eb
    else:
        cnt[0] += (eb - ea) // 2

if cnt[0] >= cnt[1]:
    ans = "Yes"
else:
    ans = "No"
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = sorted(list(map(int,input().split())),reverse = True)

ans = A[0]

for i in range(2,N):
  I = (i+2)//2
  ans += A[I]
  
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
sa = sum(A)
last = A[-1]
count = last
root = 1
for i in range(N):
  sa -= A[i]
  if root <= A[i]:
    print(-1)
    break
  elif root-A[i] > sa:
    root = sa + A[i]
  count+=root
  root = (root-A[i])*2
else:
  if count == 0 or root < last:
    count = -1
  print(count)
# Judge status: Wrong Answer
def maxvolume( s ): 
  
    # finding length 
    length = int(s / 3) 
      
    s -= length 
      
    # finding breadth 
    breadth = s / 2
      
    # finding height 
    height = s - breadth 
      
    return int(length * breadth * height) 
      
# Driven Program 
s = 8
print( maxvolume(int(input())) )
# Judge status: Wrong Answer
N = int(input())
for i in range(8):
    if 111 * i < N and N <= 111 * (i + 1):
        print(111 * (i + 1))
# Judge status: Accepted
s = input()

ans = []

for i in s:
    if i == "B":
        try:
            ans.pop()
        except:
            pass
    else:
        ans.append(i)
    
print("".join(ans))
# Judge status: Accepted
n = int(input())
x = (n * (n + 1)) // 2
#dsafasdfasdfasdfsadfsadfasldfjasdklfasdkfjhasdkjfhaskldjfhsakjdfhsalkdfhasdkfjhsad
print(x)
# Judge status: Accepted
N, K = map(int, input().split())

ans = 0
for i in range(1, N+1):
    c = 0
    while i<K:
        i *= 2
        c += 1
    ans += 1/N/pow(2, c)
print(ans)
# Judge status: Accepted
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    print(-(-N//111)*111)

if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
color = [0,0,0,0,0,0,0,0,0]
if min(a) >= 3200:
  print(1,len(a))
  quit()
for ai in a:
  if ai <= 3199:
    rnk = ai // 400
    color[rnk] += 1
  else:
    color[8] += 1

min_color = 0
for i in range(8):
  if color[i] > 0:
    min_color += 1
max_color = min_color + color[8]
print(min_color,max_color)
# Judge status: Accepted
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    ret = 0
    pv = 0
    for _ in range(N):
        nw = int(input())
        pa = min(pv, nw)
        ret += pa
        pv = nw - pa
        ret += pv//2
        pv = pv%2
    print(ret)

if __name__ == '__main__':
    main()
# Judge status: Accepted
s = input()

if s == 'RRR':
  print(3)
elif s[:2] == "RR" or s[1:] == "RR":
  print(2)
elif 'R' in s:
  print(1)
else:
  print(0)
# Judge status: Accepted
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
history = set()
now = 0
cnt = 0
while(True):
    if now in history:
        cnt = -1
        break
    else:
        cnt += 1
        history.add(now)
        now = a[now]-1
        if now == 1:
            break
print(cnt)
# Judge status: Accepted
n,k=map(int,input().split())
s=0
for i in range(k,n+2):
    s+=i*(n-i+1)+1
print(s%1000000007)
# Judge status: Accepted
from itertools import accumulate

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

turn_E = [0] + list(accumulate([s=="W" for s in S[:-1]]))
turn_W = list(reversed(list(accumulate([s=="E" for s in S[:0:-1]])))) + [0]

ans = [e+w for e, w in zip(turn_E, turn_W)]
print(min(ans))
# Judge status: Accepted
K, A, B = map(int, input().split())
ans = 0
if B - A <= 2:
  print(K + 1)

else:
  K -= A - 1
  ans += (K//2) * (B - A) + A
  ans += K % 2
  print(ans)
# Judge status: Accepted
N,K = map(int,input().split())
A = list(map(lambda x: int(x)-1,input().split()))

o = [0] * 63

def bi(x):
    i = 0
    while x != 0:
        o[i] = x%2
        x //= 2
        i += 1

bi(K)

n = 0
for i in range(63):
    if o[i]:
        n = A[n]
    A = [A[A[x]] for x in range(N)]
        
print(n+1)
# Judge status: Accepted
N = int(input())

cnt = 0
for i in range(N):
  a, b = map(int, input().split())
  if a == b:
    cnt += 1
  else:
    cnt = 0
  if cnt == 3:
    print('Yes')
    exit()
print('No')
# Judge status: Wrong Answer
n,m=map(int,input().split())
A=[]
B=[]
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    A.append(b)
    if b in B:
      print("POSSIBLE")
      break
  if b==n:
    B.append(a)
    if a in A:
      print("POSSLBLE")
      break
else:
  print("IMPOSSIBLE")
# Judge status: Accepted

x = int(input())

if 400 <= x <= 599 :
    ans = '8'
elif 600 <= x <= 799 :
    ans = '7'
elif 800 <= x <= 999 :
    ans = '6'
elif 1000 <= x <= 1199 :
    ans = '5'
elif 1200 <= x <= 1399 :
    ans = '4'
elif 1400 <= x <= 1599 :
    ans = '3'
elif 1600 <= x <= 1799 :
    ans = '2'
else :
    ans = '1'

print(ans)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
if a + b + c > 22:
    print("bust")
else:
    print("win")
# Judge status: Accepted
#ABC054.A
A,B = map(int,input().split())
if A ==1:
    if A<B:
        print('Alice')
    else:
        print('Draw')
elif A>B and B!=1:
    print('Alice')
elif A==B:
    print('Draw')
else:
    print('Bob')
# Judge status: Accepted
import sys
input=lambda: sys.stdin.readline().rstrip()
n,m,x=map(int,input().split())
A=[[int(i) for i in input().split()] for _ in range(n)]
ans=float("inf")
for i in range(2**n):
  B=[0]*(m+1)
  for j in range(n):
    if i&(1<<j):
      for k in range(m+1):
        B[k]+=A[j][k]
  if min(B[1:])>=x:
    ans=min(ans,B[0])
print(-1 if ans==float("inf") else ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = [0] * N
ans = []

for i in range(N, 0, -1):
  cnt = sum(B[(i-1)::i])%2
  B[i-1] = A[i-1] ^ cnt
  if B[i-1]:
    ans.append(i)

print(sum(B))
print(*ans)
# Judge status: Accepted
A,B,N=map(int,input().split())
Z=0
if N<B:
    Z=(A*N)//B

else:
    Z=(A*(B-1))//B

print(Z)
# Judge status: Wrong Answer
n = int(input())

for i in range(n+1):
    tmp = n
    now = i*(i+1)//2
    tmp -= now
    if tmp <= i:
        break

for j in range(1,i):
    print(j)

print(n-(i-1)*i//2)
# Judge status: Accepted
n=int(input())
a = 800*n
b = 200*(n//15)
print(a-b)
# Judge status: Wrong Answer
a,b,c,d = map(int,input().split())
print('Yes') if b-a <= d and c-b <= d else print('No')
# Judge status: Wrong Answer
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sumnum = 0
count = 0

B.reverse()
AB = A + B

while 1:
    if len(AB) == 0:
        break

    elif AB[0] < AB[-1]:
        tmp = sumnum + AB[0]
        AB.pop(0)

    else:
        tmp = sumnum + AB[-1]
        AB.pop(-1)

    if tmp > K:
        break

    else:
        sumnum = tmp
        count = count + 1


print(count)
# Judge status: Accepted
inps = input()
if inps[-1] == "s":
  print(inps + "es")
else:
  print(inps + "s")
# Judge status: Accepted
from math import gcd
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=list(set(a))
a=list(map(lambda x: x//2, a))

def lcm(q):
  x = q[0]
  for i in range(1, len(q)):
    x = (x * q[i]) // gcd(x, q[i])
  return x

lcma=lcm(a)
for i in range(len(a)):
  if (lcma//a[i])%2==0:
    print(0)
    exit()
temp=m//lcma
print(temp//2 if temp%2==0 else temp//2+1)
# Judge status: Wrong Answer
n,q=map(int,input().split())
s=input()
c=[0 for _ in range(n)]
p=''
for i in range(1,n):
  x=s[i]
  if p=='A' and x=='C':
    c[i-1]=1
  p=x
for i in range(q):
  ans=0
  l,r=map(int,input().split())
  ans=sum(c[l-1:r-1])
 # if s[]
  print(ans)
# Judge status: Wrong Answer
A,B=map(int,input().split())
H=[0]*1000

i=1
while i<=999:
    H[i]=i+H[i-1]
    i+=1

ans=0
while True:
    if (A+ans in H)and(B+ans in H):
        break
    else:
        ans+=1
    
print(ans)
# Judge status: Wrong Answer
A,B,C,K=list(map(int,input().split()))
if A+B>=K:
  print(A)
  exit()
print(A-(K-(A+B)))
# Judge status: Wrong Answer
A,B=map(int,input().split())
for i in range(1,10):
    for j in range(1,10):
        if A*B==i*j:
            print(A*B)
            exit(0)
print("-1")
# Judge status: Wrong Answer
N = str(input())
print('A'+ N[0] + 'C')
# Judge status: Accepted
a, b = map(int, input().split())

d = b-a
h2 = d*(d+1)/2
print(int(h2-b))
# Judge status: Accepted
import math
x,y=map(int,input().split())
f=0
for i in range(100):
    if x*2**i==y:
        f=1
print(math.ceil(math.log2(y)-math.log2(x))+f)
# Judge status: Accepted
N, A, B = map(int, input().split())

ans = 0
for i in range(1, N + 1):
    num = str(i)
    total = 0
    for n in num:
        total += int(n)
    if total >= A and total <= B:
        ans += i

print(ans)
# Judge status: Accepted
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    a=int(readline())
    b=int(readline())
    h=int(readline())

    print((a+b)*h//2)
if __name__=="__main__":
    main()
# Judge status: Accepted
H = int(input())
W = int(input())
N = int(input())

m = max(H,W)
if N%m == 0:
    print(N//m)
else:
    print(N//m + 1)
# Judge status: Wrong Answer
N=int(input())
AB=[list(map(int,input().split())) for _ in range(N)]
AB.sort(key=lambda x:x[1])
SUM_=0
for i in range(N):
    SUM_+=AB[i][0]

if SUM_<=AB[-1][-1]:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n,m=map(int,input().split())
py=[list(map(int,input().split())) for i in range(m)]
l=[[] for j in range(n)]
for p,y in py:
  l[p-1].append(y)
for j in range(n):
  l[j].sort()
for j in range(n):
  for t in range(len(l[j])):
    pre='0'*(6-len(str(j+1)))+str(j+1)
    y='0'*(6-len(str(t+1)))+str(t+1)
    print(pre+y)
# Judge status: Accepted
from collections import Counter

S = input()
if "N" in S and "S" not in S:
    print("No")
elif "S" in S and "N" not in S:
    print("No")
elif "E" in S and "W" not in S:
    print("No")
elif "W" in S and "E" not in S:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
a, b, c = map(int, input().split())
print("Yes" if c >= a and c <= b else "No")
# Judge status: Accepted
n,k = map(int,input().split())
A = list(map(int,input().split()))

from math import ceil

def main():
    print(ceil((n-1)/(k-1)))
        
if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

# Nが10程度で小さい
# 階乗の全探索をしても間に合う
# Pythonならitertoolsが使える
# permutations（関数）にlistを渡すと、順列を生成！
l = [i for i in range(1, N+1)]
permutations_l = list(itertools.permutations(l))

a, b = 0, 0
for i, R in enumerate(permutations_l):
  if R == P: a = i
  elif R == Q: b = i
    
print(abs(a-b))
# Judge status: Accepted
k, s = map(int, input().split())
counts = 0
for x in range(k+1):
    if (s - x) > 2 * k:
        continue
    for y in range(min(k+1, s-x+1)):
        if (s - x - y) <= k:
            counts += 1
print(counts)
# Judge status: Accepted
n,m = map(int,input().split())
cnt = [0] * 100
for i in range(n):
    a = list(map(int,input().split()))[1:]
    for j in a:
        cnt[j] += 1

print(sum(i == n for i in cnt))
# Judge status: Wrong Answer
import math
a,b,h,m = map(int , input().split())
long_needle =(5 * m)/60 + h * 5  
sort_needle = m
ans = math.sqrt(a**2 + b **2 - 2*a*b*abs(math.cos(abs(math.pi*(long_needle-sort_needle))/30)))
print(ans)
# Judge status: Accepted
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
n = ii()
s = set()
for i in range(n):
    num = ii()
    if num in s:
        s.remove(num)
    else:
        s.add(num)

print(len(s))
# Judge status: Accepted
n, k = map(int, input().split())
i = 0
while n >= k**i:
  i+=1
print(i)
# Judge status: Accepted
n=int(input())
a=[int(input()) for i in range(n)]
ans=0
for i in range(n-1):
    ans+=a[i]//2
    if a[i+1]:
        a[i+1]+=a[i]%2
ans+=a[-1]//2
print(ans)
# Judge status: Accepted
n = int(input())

ans = float("inf")  
for i in range(1, n):
    a = sum([int(i) for i in list(str(i))])
    b = sum([int(i) for i in list(str(n-i))])
    if ans > a+b:
        ans = a + b
print(ans)
# Judge status: Accepted
n = int(input())
s = input()
t = input()
f = 0
m = 0
ind = 0
for i in range(1,n+1):
      if(s[n-i:]==t[:i]):
            f=1
            if (len(t[:i])>m):
                  m = len(t[:i])
                  ind = i

print(2*n-ind) if f==1 else print(2*n)
# Judge status: Wrong Answer
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
l = max(b - a, c - b, d - c, e - d)
if l < k:
  print("Yay!")
else:
  print(":(")
# Judge status: Accepted
N = int(input())
c = input()
white = 0
white_ends = 0

for i in range(N):
  if c[i] == "W":
    white += 1
for i in range(N-white, N):
  if c[i] == "W":
    white_ends += 1
print(white-white_ends)
# Judge status: Accepted
input()
l = input()
print("NYoe s"[l[0:int(len(l)/2)] == l[int(len(l)/2):len(l)]::2])
# Judge status: Accepted
n = int(input())
a = [int(_) for _ in input().split()]

num_cnt = [0] * 200001
for i in a:
    num_cnt[i] += 1

pat_cnt = [0] * 200001
for i in range(200001):
    b = num_cnt[i]
    pat_cnt[i] = (b*(b-1))//2

ans = sum(pat_cnt)

for i in range(n):
    #print(ans, pat_cnt[a[i]], num_cnt[a[i]])
    print(ans - pat_cnt[a[i]] + ((num_cnt[a[i]]-1) * (num_cnt[a[i]]-2))//2)
# Judge status: Accepted
n = int(input())
s = input()
c = s.count('R')*s.count('G')*s.count('B')

for i in range(n):
    for j in range(i+1,n):
        if j + j - i >= n:break
        # print(j+j-i+1)
        if s[i]!=s[j] and s[j]!=s[j+j-i] and s[i]!=s[j+j-i]:
            c-=1

print(c)
# Judge status: Accepted
X = int(input())
quot1, rem = divmod(X,500)
quot2 = rem // 5
print(quot1*1000 + quot2*5)
# Judge status: Wrong Answer
a = int(input())
b = int(input())
n = int(input())
t = max(a, b)
print(n + t - 1 / t)
# Judge status: Wrong Answer
def main():
    a = list(map(int, input().split()))
    k = int(input())
    a.sort()
    print(a[0]+a[1]+a[2]*2*k)

if __name__ == "__main__":
    main()
# Judge status: Accepted
import math

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

def calc(theta):
    h = math.tan(theta) * a
    if h <= b:
        s = 1 / 2 * a * a * h
    else:
        c = h - b
        s = 1 / 2 * a * a * h
        s = s - s * ((c / h) ** 2)
    return s

l, r = 0.0, math.pi / 2
while abs(r - l) > 1e-12:
    m = (l + r) / 2
    rem = a * a * b - calc(m)
    if rem >= x:
        l = m
    else:
        r = m
print(l * 180 / math.pi)
# Judge status: Wrong Answer
a, b, c, k = map(int, input().split())

flag = True
for i in range(10**18):
    if k == 0:
        break
    if a == b and b == c:
        break
    A = a
    B = b
    C = c
    a = B + C
    b = A + C
    c = A + B
    if i == k - 1:
        break
    if a * 2 > 10**18 + c:
        flag = False
        break
if flag:
    print(a - b)
else:
    print('Unfair')
# Judge status: Accepted
N, M = map(int, input().split())
print(N*(N-1)//2 + M*(M-1)//2)
# Judge status: Accepted
N= int(input())
now=0
ans=1
S=0
l=list(map(int,input().split()))
for i in range(1,N):
   X=l[i]-l[i-1]
   X=0 if X==0 else 1 if X>0 else -1
   if X==0:
      continue
   elif S ==0:
      S=X
   elif S != X:
      ans+=1
      S=0
print(ans)
# Judge status: Accepted
from sys import stdin,setrecursionlimit
n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
lin = [0]*(n+1)
for i in li:
    lin[i] += 1
liv = [0]*(n+1)
point = 0
for j,k in enumerate(lin):
    point += k*(k-1)//2
    liv[j] += k*(k-1)//2
for i in li:
    print(point-liv[i]+(lin[i]-1)*(lin[i]-2)//2)
# Judge status: Accepted
D, T, S = map(int, input().split())
if S*T >= D:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def main():
    n = int(input())
    if n == 1:
        print(0)
    else:
        print(1)

if __name__ == "__main__":
    main()
# Judge status: Accepted
# -*- coding: utf-8 -*-
N = int(input())

import collections
s_frq_dict = collections.defaultdict(int)
for _ in range(N):
    s = [c for c in input()]
    s.sort()
    s_frq_dict[tuple(s)] += 1

ret = 0
for frq in s_frq_dict.values():
    ret += int(frq * (frq-1) * 0.5)

print(ret)
# Judge status: Wrong Answer
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''
import numpy as np


def main():
    N, K = list(map(int, input().split()))
    H = list(map(int, input().split()))
    H = np.array(H)

    cost = np.array([100000] * N)
    cost[0] = 0
    for i in range(1, N):
        cost[i] = min(
            cost[max(i - K, 0)] + abs(H[i] - H[max(i - K, 0): i]))
        # print(i, cost[i])
    print(cost[N - 1])


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
s = 0
k = int(input())

def gcd(p,q):
    if p%q == 0:
        return q
    return gcd(q, p%q)
    
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            s += gcd(gcd(a,b),c)
            
print(s)
# Judge status: Wrong Answer
import bisect
n = int(input())
s = input()
elist = []
wlist = []
for i in range(n):
	if s[i] == "E":
		elist.append(i)
	elif s[i] == "W":
		wlist.append(i)
ans = 10**18
lenelist = len(elist)
"""
西にいるWを数える
東にいるEを数える
"""
for i in range(n):
	tmp = lenelist-bisect.bisect_left(elist, i)+bisect.bisect_left(wlist, i)
	ans = min(tmp, ans)
print(ans)
# Judge status: Wrong Answer
a, b = map(int, input().split())
s = input()
flg = 0
for i in range(a +b):
    try:
        if (0 <= int(s[i]) <= 9):
            if i == a:
                flg = 0
    except:
        if i == a:
            flg = 1
        else:
            flg = 0
print("Yes" if flg == 1 else "No")
# Judge status: Wrong Answer
S = input()

if len(S) % 2 != 0:
  matched = False
else:
  matched = True
  index = len(S)//2
  for i in range(index):
    if S[i] != S[index+i]:
      matched = False
      break

if matched:
  print('Yes')
else:
  print('False')
# Judge status: Accepted
a, b, k = map(int, input().split())

if a >= k:
    a -= k
    print(a, b)

else:
    k -= a
    a = 0
    if  b >= k:
        b -= k
        print(a, b)
    else:
        b = 0
        print(a, b)
# Judge status: Accepted
from collections import deque

n = int(input())

c = 0
q = deque()
for i in range(1, 10):
    q.append(i)

k = 1
while c < n:
    k = q.popleft()
    # print(k)
    if k%10:
        q.append(10*k + k%10 - 1)
    q.append(10 * k + k % 10)
    if k%10 != 9:
        q.append(10*k + (k%10) + 1)
    c += 1

print(k)
# Judge status: Accepted
n=int(input())
p=list(map(int,input().split()))
ans=0
cnt=0
for i in range(n):
    if p[i]==i+1:
        cnt+=1
        if cnt==2:
            ans+=1
            cnt=0
    elif cnt==1:
        ans+=1
        cnt=0
if cnt==1:
    ans+=1
print(ans)
# Judge status: Wrong Answer
N,M=map(int,input().split())
shi=[[] for i in range(N+1)]
py=[]
for i in range(M):
    p,y=map(int,input().split())
    shi[p].append(y)
    py.append([p,y])
for i in range(N):
    shi[i].sort()
shidic=[{} for i in range(N+1)]
for i in range(N+1):
    for j in range(len(shi[i])):
        shidic[i][shi[i][j]]=j+1
for P,Y in py:
    print(str(P).zfill(6)+str(shidic[P][Y]).zfill(6))