Harryxun/stf_run huggingface dataset:
N, M = map(int, input().split())


L, R = map(int, input().split())
ar = [i for i in range(L, R+1)]
for i in range(M-1):
      L, R = map(int, input.split())
      if ar[-1] < L or ar[0] > R:
        break
      else:
        if ar[0] < L < ar[-1]:
          ar = [x for x in range(L, ar[-1]+1)]
        elif ar[0] < R <ar[-1]:
          ar = [x for x in range(ar[0], R+1)]
print(len(ar))

### FIXED CODE ###

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


for i in range(M-1):
      L1, R1 = map(int, input().split())
      if R1 < L or R < L1:
        print(0)
        exit()
      else:
        if L <= L1 <= R:
          L = L1
          
        elif L <= R1 <= R:
          R = R1
        
          
print(R-L+1)
import os

def main():
        n = int(input())
        a_list = tuple(map(int, input().split()))
        list_set = set(a_list)
        zero_list = [0]*n
        for l in list_set:
                zero_list[i-1] = a_list[i]
        for i in zero_list:
                print(i)

if __name__ == "__main__":
        main()

### FIXED CODE ###

import os

def main():
	n = int(input())
	a_list = list(map(int, input().split()))
	result = [0]*n
	for i in a_list:
		result[i-1] += 1
	for i in result:
		print(i)

if __name__ == "__main__":
	main()
import itertools
N, M = [int(_) for _ in input().split()]
S = [int(_) for _ in input().split()]
T = [int(_) for _ in input().split()]
mod = 10**9 + 7
dp = [[1] * (N + 1)] + [[1] + [0] * M for _ in range(N)]
for n, m in itertools.product(range(N), range(M)):
    dp[n + 1][m + 1] = dp[n][m + 1] + dp[n + 1][m] - dp[n][m]
    if S[n] == T[m]:
        dp[n + 1][m + 1] += dp[n][m]
    dp[n + 1][m + 1] %= mod
print(dp[-1][-1])


### FIXED CODE ###

import itertools
N, M = [int(_) for _ in input().split()]
S = [int(_) for _ in input().split()]
T = [int(_) for _ in input().split()]
mod = 10**9 + 7
dp = [[1] * (M + 1)] + [[1] + [0] * M for _ in range(N)]
for n, m in itertools.product(range(N), range(M)):
    dp[n + 1][m + 1] = dp[n][m + 1] + dp[n + 1][m] - dp[n][m]
    if S[n] == T[m]:
        dp[n + 1][m + 1] += dp[n][m]
    dp[n + 1][m + 1] %= mod
print(dp[-1][-1])
N,Y = map(int,input().split())
A = list(range(0,N+1))
B = list(range(0,N-A+1))
a=-1
b=-1
c=-1
for i in A:
    for j in B:
        if 10000*i+5000*j+1000*(N-i-j) == Y:
            a=i
            b=j
            c=N-i-j
            break
print([a,b,c])

### FIXED CODE ###

N,Y = map(int,input().split())
A = list(range(0,N+1))
a=-1
b=-1
c=-1
for i in A:
    for j in list(range(0,N-i+1)):
        if 10000*i+5000*j+1000*(N-i-j) == Y:
            a=i
            b=j
            c=N-i-j
            break
print(a,b,c)
if __name__ == "__main__":
    # 1 <= N <= 2 * 10^5
    # 1 <= K <= N + 1
    N, K = map(int, input().split(" "))

    total_num = 0
    for k in range(K, N+2):
        # NからN-(k-1)までの和
        sum_max = k*(2*N - k + 1) / 2
        # 0から(k-1)までの和
        sum_min = k*(k-1) / 2
        # 個数を計上
        total_num += sum_max - sum_min + 1
        total_num %= 1000000007
    
    print(total_num)

### FIXED CODE ###

import math

if __name__ == "__main__":
    R = int(input())
    print(2*math.pi*R)
N = int(input())
A = [int(input()) for _ in range(N)]

sum_index = [0]*(N+1)

for i in range(N)[::-1]:
    sum_ = 0    
    for j in sum_index[i+1::i+1]:
        sum_ ^= j
    sum_index[i+1] = sum_ ^ A[i] 
print(sum(sum_index))
print(sum_index[1:])

### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split(" ")]

sum_index = [0]*(N+1)
index = []
for i in range(N)[::-1]:
    sum_ = 0
    for j in sum_index[i+1::i+1]:
        sum_ ^= j
    sum_index[i+1] = sum_ ^ A[i]
    if sum_index[i+1] == 1:
        index.append(str(i+1))

print(sum(sum_index))
if index:
    print(" ".join(index))
#!/usr/local/bin/python3

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

def f(x, m):
    return x**2 % m

check = [False for _ in range(M)]
d = [X]
max_x = 0
for _ in range(1, N+1):
    X = f(X, M)
    if check[X]:
        break
    else:
        check[X] = True
    d.append(X)

idx = d.index(X)
ans = sum(d[:idx])
N -= idx
d = d[idx:]

sumd = sum(d)
ans += N//len(d) * sumd

ans += sum(d[:N%len(d)])

print(ans)


### FIXED CODE ###

S = input()
if S[-1] == 's':
    print(S+'es')
else:
    print(S+'s')
r = int(input())
print(3*(a**2))

### FIXED CODE ###

r = int(input())
print(3*(r**2))
n=int(input())
h=list(map(int,input().split()))
if n>1:
    l=[]
    a=0
    for i in range(n-1):
        if h[i]>=h[i+1]:
            a+=1
        else:
            l.append(a)
            a=0
    a=0
    h.reverse()
    for i in range(n-1):
        if h[i]<=h[i+1]:
            a+=1
        else:
            l.append(a)
            a=0
    print(max(l))
else:
    print(0)


### FIXED CODE ###

n=int(input())
h=list(map(int,input().split()))
l=[0]*n
for i in range(1,n):
    if h[i]<=h[i-1]:
        l[i]=1+l[i-1]
print(max(l))
#!/usr/bin/env python3
h,n = map(int,input().split())
a = list(map(int,input().split()))
sum=0
for i in a:
    sum+=i

if sum>=h:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

#!/usr/bin/env python3
H, A = map(int,input().split())
count=0
while H>0:
    count+=1
    H-=A
print(count)
a=input()
l=set()
s=""
for i in list(a):
  s+=i
  if s not in l:
    l.append(s)
    s=""
  else:continue
print(len(l))

### FIXED CODE ###

s=input()
if len(s)<=2:
    print(len(set(list(s))));exit()
dp=[0]*(len(s)+ 1)
dp[0]=0
dp[1]=1
dp[2]=(len(set(list(s[:2]))))

for i in range(3,1+len(s)):
    dp[i]=(dp[i-1]+1) if s[i-1]!=s[i-2]else (dp[i-3]+2)
print(dp[-1])
import itertools

DIM = int(input())
args = [int(input()) for a in range(DIM)]
i = DIM
while(i>0):
    comb = list(itertools.combinations(args, DIM))
    combMax = list(map(sum, comb))
    for c in combMax.sort().reversed():
        if c%10==0:
            continue
        else:
            print(c)
            exit()
    i = i -1
print(0)
exit()

### FIXED CODE ###

import itertools

DIM = int(input())
args = [int(input()) for a in range(DIM)]
temp = list(map(lambda x:x%10, args))
if sum(temp) == 0:
    print(0)
    exit()
i = DIM
while(i>0):
    comb = list(itertools.combinations(args, i))
    combMax = list(map(sum, comb))
    for c in sorted(combMax, reverse=True):
        if c%10==0:
            continue
        else:
            print(c)
            exit()
    i = i -1
print(0)
exit()
N = int(input())
dic = {}
for i in range(1,N+1):
    key = input()
    if key not in dic:
        dic[key] = 1
    else:
        dic[key] += 1
lis = []
for key,val in dic.items():
    lis.append([val,key])
lis.sort(reverse = True)

lis2 = []
fnum = lis[0][0]
j = 0
while lis[j][0] == fnum:
    lis2.append(lis[j][1])
    j += 1
lis2.sort()
for k in lis2:
    print(k)
    

### FIXED CODE ###

N = int(input())
dic = {}
for i in range(1,N+1):
    key = input()
    if key not in dic:
        dic[key] = 1
    else:
        dic[key] += 1
lis = []
for key,val in dic.items():
    lis.append([val,key])
lis.sort(reverse = True)

lis2 = []
fnum = lis[0][0]

for j in range(0,len(lis)): 
    if lis[j][0] == fnum:
        lis2.append(lis[j][1])
    else:
        break
lis2.sort()
for k in lis2:
    print(k)
#include <complex>
#include <iostream>
#include <vector>
using namespace std;
typedef complex<double> P;
P A[100],j=sqrt(-1);
double a,b,d;
int n;
int f(int m,P p,P p1){
	int i,s1=2,s2=2;
	P p3=polar(1.0,b+d)+p,p4=polar(1.0,b-d)+p,q;
	for(i=0;i<n;i++){
		q=A[i];
		if(q==p||q==p1)continue;
		if(abs(q-p3)-1<1e-6)s1++;
		if(abs(q-p4)-1<1e-6)s2++;
	}
	if(m<s1)m=s1;
	if(m<s2)m=s2;
	return m;
}
int main(){
	int m,i,i1;
	char c;
	while(cin>>n,n!=0){
		for(i=0;i<n;i++){
			cin>>a>>c>>b;A[i]=P(a,b);
		}
		m=1;
		for(i=0;i<n;i++){
			P p=A[i],q;
			for(i1=i+1;i1<n;i1++){
				q=A[i1];a=abs(q-p);b=arg(q-p);d=acos(a/2);
				if(a<=2)m=f(m,p,q);
			}
		}
		cout<<m<<endl;
	}
}

### FIXED CODE ###

import math,cmath
def f(m):
  c=1j*math.acos(a/2)
  r=cmath.exp(b+c)+p
  s=cmath.exp(b-c)+p
  u,v=2,2
  for t in A:
    if t in[p,q]:continue
    if abs(t-r)-1<1e-6:u+=1
    if abs(t-s)-1<1e-6:v+=1
  return max(m,u,v)

while 1:
  n=input()
  if n==0:break
  N=range(n)
  A=[]
  for i in N:
    x,y=map(float,input())
    A+=[x+1j*y]
  m=1
  for i in N:
    p=A[i]
    for q in A[i+1:]:
      a,b=cmath.polar(q-p)
      b*=1j
      if a<=2:m=f(m)
  print m
N = int(input())
V = list(map(int, input().split()))

even_idx_cnt = {}
odd_idx_cnt = {}
for idx, v in enumerate(V):
    if idx % 2 == 0:
        if v not in even_idx_cnt:
            even_idx_cnt[v] = 0
        even_idx_cnt[v] += 1
    else:
        if v not in odd_idx_cnt:
            odd_idx_cnt[v] = 0
        odd_idx_cnt[v] += 1

if len(even_idx_cnt) == 1 and len(odd_idx_cnt) == 1:
    if even_idx_cnt.keys() == odd_idx_cnt.keys():
        print(N - even_idx_cnt[V[0]])
    else:
        print(0)
    exit()

even_idx_cnt = sorted(even_idx_cnt.items(), key=lambda  x:x[1], reverse=True)
odd_idx_cnt = sorted(odd_idx_cnt.items(), key=lambda  x:x[1], reverse=True)

if even_idx_cnt[0][0] != odd_idx_cnt[0][0]:
    print(N - even_idx_cnt[0][1] - odd_idx_cnt[0][1])
elif even_idx_cnt[0][0] > odd_idx_cnt[0][0]:
    print(N - even_idx_cnt[0][1] - odd_idx_cnt[1][1])
else:
    print(N - even_idx_cnt[1][1] - odd_idx_cnt[0][1])
N = int(input())
V = list(map(int, input().split()))

even_idx_cnt = {}
odd_idx_cnt = {}
for idx, v in enumerate(V):
    if idx % 2 == 0:
        if v not in even_idx_cnt:
            even_idx_cnt[v] = 0
        even_idx_cnt[v] += 1
    else:
        if v not in odd_idx_cnt:
            odd_idx_cnt[v] = 0
        odd_idx_cnt[v] += 1

if len(even_idx_cnt) == 1 and len(odd_idx_cnt) == 1:
    if even_idx_cnt.keys() == odd_idx_cnt.keys():
        print(N - even_idx_cnt[V[0]])
    else:
        print(0)
    exit()

even_idx_cnt = sorted(even_idx_cnt.items(), key=lambda  x:x[1], reverse=True)
odd_idx_cnt = sorted(odd_idx_cnt.items(), key=lambda  x:x[1], reverse=True)

if even_idx_cnt[0][0] != odd_idx_cnt[0][0]:
    print(N - even_idx_cnt[0][1] - odd_idx_cnt[0][1])
else:
    if even_idx_cnt[1][0] > odd_idx_cnt[1][0]:
        print(N - even_idx_cnt[0][1] - odd_idx_cnt[1][1])
    else:
        print(N - even_idx_cnt[1][1] - odd_idx_cnt[0][1])


### FIXED CODE ###

from collections import Counter
import heapq

N = int(input())
Vs = list(map(int,input().split()))

if len(set(Vs)) == 1:
  print(N//2)
  exit()

Veve, Vodd = [],[]
idx = 0
for v in Vs:
  if idx%2 == 0: Veve.append(v)
  else: Vodd.append(v)
  idx += 1

Veve_cnt, Vodd_cnt = [], []
[heapq.heappush(Veve_cnt, [-num,val]) for val, num in Counter(Veve).items()]
[heapq.heappush(Vodd_cnt, [-num,val]) for val, num in Counter(Vodd).items()]

neg_num, val = heapq.heappop(Veve_cnt)
eve_val = val
eve_num = -neg_num

neg_num, val = heapq.heappop(Vodd_cnt)
odd_val = val
odd_num = -neg_num

if eve_val != odd_val:
  print(N-eve_num-odd_num)
else:
  if len(Vodd_cnt) != 0:odd_num2 = -heapq.heappop(Vodd_cnt)[0]
  else:odd_num2 = -float('inf')

  if len(Veve_cnt) != 0:eve_num2 = -heapq.heappop(Veve_cnt)[0]
  else:eve_num2 = -float('inf')

  print(min(N-eve_num2-odd_num,N-eve_num-odd_num2))
N = int(input())
X = input().strip()
C = X.count("1")
D = int(X, 2)

p = [0]*(2*10**5+2)
for i in range(1, len(p)):
    n = i
    while True:
        b = bin(n).count("1")
        if b <= 0:
            break
        n = n % b
        p[i] += 1

for i in range(1, N+1):
    d = D
    c = C
    if X[i-1] == "1":
        c -= 1
        d -= 1 << (N-i)
    else:
        c += 1
        d += 1 << (N-i)

    d = d % c
    print(p[d]+1)


### FIXED CODE ###

N = int(input())
X = input().strip()
C = X.count("1")
D = int(X, 2)
Mm, Mp = 0, D % (C+1)
if C > 1:
    Mm = D % (C-1)

p = [0]*(2*10**5+2)
for i in range(1, len(p)):
    n = i
    while True:
        b = bin(n).count("1")
        if b <= 0:
            break
        p[i] += 1
        n = n % b

for i in range(1, N+1):
    c = C
    if X[i-1] == "1":
        c -= 1
        if c == 0:
            print(0)
            continue
        m = Mm
        d = pow(2, N-i, c)
        d = (m-d+c) % c
    else:
        c += 1
        m = Mp
        d = pow(2, N-i, c)
        d = (m+d) % c

    print(p[d]+1)
n=int(input())
a=input().split()
for i in range(1,n):
 k=int(a[i])
 j=i-1
 while int(a[j])>k:
  a[j+1]=a[j]
  j-=1
 a[j+1]=k
 print(*a)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
for i in range(1, N + 1):
    A[:i] = sorted(A[:i])
    print(*A)
import numpy as np
from collections import deque

h, w = map(int, input().split())
root = [[-np.inf]*w for i in range(h)]
root[0][0] = 1
s = [[] for i in range(h)]

cnt = 0
for i in range(h):
    s[i] = input()
    for j in range(w):
        if s[i][j] == '#': cnt+=1
dw = [-1, 0, 1, 0]
dh = [0, 1, 0, -1]
que = deque()
que.append([0, 0])
while que:
    x, y = que.pop()
    for dx, dy in zip(dw, dh):
        nx, ny = x+dx, y+dy
        if 0<=nx<w and 0<=ny<h and root[ny][nx]<=0 and s[ny][nx]=='.':
                que.append([nx, ny])
                root[ny][nx] = root[y][x] + 1
if root[h-1][w-1]<0:
    print(-1)
else:
    print(h*w - cnt - root[h-1][w-1])

### FIXED CODE ###

from collections import deque
inf = 1000000000
h, w = map(int, input().split())
root = [[-1]*w for i in range(h)]
root[0][0] = 1
s = [[] for i in range(h)]

cnt = 0
for i in range(h):
    s[i] = input()
    for j in range(w):
        if s[i][j] == '#': cnt+=1
dw = [-1, 0, 1, 0]
dh = [0, 1, 0, -1]
que = deque()
que.append([0, 0])
while len(que)>0:
    x, y = que.popleft()
    for dx, dy in zip(dw, dh):
        nx, ny = x+dx, y+dy
        if 0<=nx<w and 0<=ny<h and root[ny][nx]==-1 and s[ny][nx]=='.':
                que.append([nx, ny])
                root[ny][nx] = root[y][x] + 1
if root[h-1][w-1]<0:
    print(-1)
else:
    print(h*w - cnt - root[h-1][w-1])
nums = input(),rstrip(),split(" ")
n1 = int(nums[0])
n2 = int(nums[1])
n3 = int(nums[2])
if n1 == n2 and n2 == n3:
  print("No")
else if n1 != n2 and n2 =! n3:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

nums = input().rstrip().split(" ")
n1 = int(nums[0])
n2 = int(nums[1])
n3 = int(nums[2])
if n1 == n2 and n2 == n3 and n1 == n3:
  print("No")
elif n1 != n2 and n2 != n3 and n1 != n3:
  print("No")
else:
  print("Yes")
import math

while True:
    inp = input()
    if inp == '0': break

    num = math.factorial(int(inp))
    cnt = 0
    while True:
        if num % 10 == 0:
            cnt = cnt + 1
            num = num / 10
        else:
            break

    print(cnt)

### FIXED CODE ###

while True:
    inp = input()
    if inp == '0': break

    num = 1
    for i in range(1, int(inp)+1):
        num = num * i

    cnt = 0
    strnum = str(num)
    while True:
        if strnum[-1] == '0':
            cnt = cnt + 1
            strnum = strnum[:-1]
        else:
            break

    print(cnt)
N = int(input())

def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
 
if len(divisor(N)) < 3:
    print(N - 1)
else:
    divisor_list = divisor(N)
    tmp = N
    for i in divisor_list:
        A = i
        B = N / i
        if tmp > (A + B - 2):
            tmp = (A + B - 2)
    print(int(tmp))


### FIXED CODE ###

A, B = input().split(" ")
A = int(A)
B = int(B)

if (0 < A) & (A < 10):
    if (0 < B) & (B < 10):
        print(A * B)
    else:
        print(-1)
else:
    print(-1)
a,b,c = int(inpupt().split())
if((a-b)<c):
  print(c-(a-b))
else:
  print(0)


### FIXED CODE ###

a,b,c = map(int,input().split());
if((a-b)<c):
  print(c-(a-b))
else:
  print(0)
N, M = [int(x) for x in input().split()]
links = [tuple(map(int, input().split())) for _ in range(M)]
S, T = [int(x) for x in input().split()]

d = {}
for x, y in links:
    if x in d:
        d[x][0].add(y)
    else:
        d[x] = [set([y]), False]

def next_node(start):
    history = set()
    for s in start:
        if s in d:
            history |= d[s][0]
    return list(history)

history = [S]
s = 1
while True:
    for _ in range(3):
        history = next_node(history)
    if T in history:
        print(s)
        break
    for h in reversed(history):
        if d[h][1]:
            history.remove(h)
        else:
            d[h][1] = True
    if len(history) == 0:
        print(-1)
        break
    s += 1
    

### FIXED CODE ###

N, M = [int(x) for x in input().split()]
links = [tuple(map(int, input().split())) for _ in range(M)]
S, T = [int(x) for x in input().split()]

d = {}
for x, y in links:
    if x in d:
        d[x][0].add(y)
    else:
        d[x] = [{y}, False]

def next_node(start):
    history = set()
    for s in start:
        if s in d:
            history |= d[s][0]
    return history

history = {S}
s = 1
while True:
    for _ in range(3):
        history = next_node(history)
    if T in history:
        print(s)
        break
    for h in tuple(history):
        if h not in d or d[h][1]:
            history.remove(h)
        else:
            d[h][1] = True
    if len(history) == 0:
        print(-1)
        break
    s += 1
# -*- coding: utf-8 -*-

import sys
import itertools
import math

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

if N < M:
    t = M
    M = N
    N = t
    q = S
    S = T
    T = q

d = math.gcd(N, M)

n = N / d

ret = -1
for step in range(1, M+1):
    slen = step * N
    if slen % M != 0:
        continue
    mstep = slen // M
    good = True
    for i in range(N):
        u = (step * i) % mstep
        if u != 0:
            continue
        j = (step * i) // mstep
        if S[i] != T[j]:
            good = False
            break
    if good:
        ret = step * N
        break

# 出力
print("{}".format(ret))


### FIXED CODE ###

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

import sys
import itertools
import math

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

def main():
    N, M = map(int, input().split())
    S = input()
    T = input()

    if N < M:
        t = M
        M = N
        N = t
        q = S
        S = T
        T = q

    d = gcd(N,M)
    c = N * M // d

    ret = -1
    slen = c
    nstep = slen // N
    mstep = slen // M

    dd = gcd(nstep, mstep)
    cc = nstep * mstep // dd

    good = True
    for k in range(0, slen, cc):
        u = (k // nstep) % N
        j = (k // mstep) % M
        if S[u] != T[j]:
            good = False
            break
    if good:
        ret = slen

    # 出力
    print("{}".format(ret))


if __name__ == '__main__':
    main()
def main():
    from itertools import product
    H, W, K = map(int, input().split())
    G = [list(map(int, list(input()))) for _ in range(H)]

    ans = float('inf')
    for pattern in product([0, 1], repeat=H-1):
        tmp_ans = 0
        div = [0] + [i for i, p in enumerate(pattern, start=1) if p == 1] + [100]
        grids = []
        for i in range(len(div) - 1):
            grids.append(G[div[i]: div[i + 1]])

        rows = []
        for grid in grids:
            row = []
            for w in range(W):
                v = 0
                for h in range(len(grid)):
                    v += grid[h][w]
                row.append(v)
            rows.append(row)

        w = 0
        dead_flg = False
        counts = [0] * len(rows)
        dead_set = set()
        while w < W:
            for i, row in enumerate(rows):
                counts[i] += row[w]
                if counts[i] > K:
                    if w in dead_set:
                        dead_flg = True
                        break
                    dead_set.add(w)
                    tmp_ans += 1
                    counts = [0] * len(rows)
                    break
            else:
                w += 1

            if dead_flg:
                break
        tmp_ans += len(div) - 2
        ans = min(ans, tmp_ans)

    print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    from itertools import product
    H, W, K = map(int, input().split())
    G = [list(map(int, list(input()))) for _ in range(H)]

    ans = float('inf')
    for pattern in product([0, 1], repeat=H - 1):
        tmp_ans = 0
        div = [0] + [i for i, p in enumerate(pattern, start=1) if p == 1] + [100]
        grids = []
        for i in range(len(div) - 1):
            grids.append(G[div[i]: div[i + 1]])

        rows = []
        for grid in grids:
            row = []
            for w in range(W):
                v = 0
                for h in range(len(grid)):
                    v += grid[h][w]
                row.append(v)
            rows.append(row)

        w = 0
        d = set()
        df = False
        counts = [0] * len(rows)
        while w < W:
            for i, row in enumerate(rows):
                counts[i] += row[w]

            if [c for c in counts if c > K]:
                if w in d:
                    df = True
                    break
                d.add(w)
                tmp_ans += 1
                counts = [0] * len(rows)
            else:
                w += 1

            if df:
                break
        
        if not df:
            tmp_ans += len(div) - 2
            ans = min(ans, tmp_ans)

    print(ans)


if __name__ == '__main__':
    main()
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
d=Counter(a)
import math
def cmb(n,r):
    f = math.factorial
    return int(f(n) // f(r) // f(n-r))
def combination(n, r):
    a = 1
    b = 1
    for i in range(r):
        a *= (n - i)
        b *= (i + 1)
    return a // b
e={}
dd=0
for i,j in d.items():
    dd+=combination(j, 2)
    e[i]=combination(j-1, 1)

for i in a:
    print(dd-e[i])
  


### FIXED CODE ###

k=int(input())
if k<=9:
    print(k)
    exit()
a=[1,2,3,4,5,6,7,8,9]
cnt=9
while True:
    q=[]
    for i in a:
       for j in range(10):
            if abs(int(str(i)[-1])-j)<=1:
                cnt+=1
                if cnt==k:
                    print(int(str(i)+str(j)))
                    exit()
                q.append(int(str(i)+str(j)))         
    a=list(sorted(set(q)))
import math

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

if K == 0:
  C = 0
else:
  C = int(math.log2(K + 1))
L = [[0 for i in range(50)] for j in range(C + 1)]

for i in A:
  for j in range(len(L[0])):
    if i % 2 == 1:
      i -= 1
      L[0][j] += 1
    if i == 0:
      break
    i /= 2
for i in range(1, C + 1):
  for j in range(50):
    L[i][j] = L[0][j]

x = pow(2, C)
T = [K for i in range(C + 1)]
for i in range(C, -1, -1):
  for j in range(C + 1):
    if T[j] >= x:
      if j != i and L[j][i] <= N / 2:
        L[j][i] = N - L[j][i]
        T[j] -= x
  x //= 2

Ans = [0 for i in range(C + 1)]
x = 1
for i in range(50):
  for j in range(C + 1):
    Ans[j] += L[j][i] * x
  x *= 2

print(max(Ans))



### FIXED CODE ###

import math
def main():
  N, K = list(map(int, input().split()))
  A = list(map(int, input().split()))
 
  if K == 0:
    C = 0
  else:
    C = int(math.log2(K + 1))
  L = [[0 for i in range(44)] for j in range(C + 1)]
 
  for i in A:
    for j in range(len(L[0])):
      if i % 2 == 1:
        i -= 1
        L[0][j] += 1
      if i == 0:
        break
      i /= 2
  for i in range(1, C + 1):
    for j in range(44):
      L[i][j] = L[0][j]
 
  x = pow(2, C)
  T = [K for i in range(C + 1)]
  for i in range(C, -1, -1):
    for j in range(C + 1):
      if T[j] >= x:
        if j != i and L[j][i] <= N / 2:
          L[j][i] = N - L[j][i]
          T[j] -= x
    x //= 2
 
  Ans = [0 for i in range(C + 1)]
  x = 1
  for i in range(44):
    for j in range(C + 1):
      Ans[j] += L[j][i] * x
    x *= 2
 
  print(max(Ans))

main()
a, b = [int(i) for i in input().split]

if a < b:
    print("a < b")
if a > b:
    print("a > b")
else:
    print("a == b")

### FIXED CODE ###

a, b = [int(i) for i in input().split()]

if a < b:
    print("a < b")
elif a > b:
    print("a > b")
else:
    print("a == b")
n,m,x,y = map(int,input().split())
a = [int(input()) for i in range(n)]
a.append(x)
b = [int(input()) for i in range(m)]
b.append(y)
for i in range(x+1,y+1):
  if max(a) < i <= max(b):
    print("No War")
else:
  print("War")
    
    

### FIXED CODE ###

n,m,x,y = map(int,input().split())
a = list(map(int,input().split()))
a.append(x)
b = list(map(int,input().split()))
b.append(y)
for i in range(x+1,y+1):
  if max(a) < i <= min(b):
    print("No War")
    break
else:
  print("War")