Harryxun/stf_run huggingface dataset:
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]
counter = Counter(s)
#output = ['AC', 'WA', 'TLE', 'RE']

for key in output:
    print(f'{key} x {counter[key]}')

### FIXED CODE ###

from collections import Counter

n = int(input())
s = [input() for _ in range(n)]
counter = Counter(s)
output = ['AC', 'WA', 'TLE', 'RE']

for key in output:
    print(f'{key} x {counter[key]}')
import sys
input = sys.stdin.readline

n = int(input())
ab = [[ (int(i)-1) for i in input().split()] for i in range(n-1)]
c = sorted([int(i) for i in input().split()], reverse=True)

if n==1:
    print(0)
    print(c[0])
    exit()
    
dic = {}
for i in range(n):
    dic[i] = []

cnt = [0]*n
for a,b in ab:
    dic[a].append(b)
    dic[b].append(a)
    cnt[a] += 1
    cnt[b] += 1

c_idx = 0
res = 0
res_arr = [""]*n
used = [0]*n
def f(idx):
    global c_idx, res, used
    used[idx] = 1
    res_arr[idx] = str(c[c_idx])
    for x in dic[idx]:
        if used[x] == 0:
            c_idx += 1
            res += c[c_idx]
            f(x)

f(cnt.index(1))
print(res)
print(" ".join(res_arr))

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(11000)

n = int(input())
ab = [[ (int(i)-1) for i in input().split()] for i in range(n-1)]
c = sorted([int(i) for i in input().split()], reverse=True)

if n==1:
    print(0)
    print(c[0])
    exit()

dic = {}
for i in range(n):
    dic[i] = []

cnt = [0]*n
for a,b in ab:
    dic[a].append(b)
    dic[b].append(a)
    cnt[a] += 1
    cnt[b] += 1

c_idx = 0
res = 0
res_arr = [""]*n
used = [0]*n
def f(idx):
    global c_idx, res, used
    used[idx] = 1
    res_arr[idx] = str(c[c_idx])
    for x in dic[idx]:
        if used[x] == 0:
            c_idx += 1
            res += c[c_idx]
            f(x)

f(cnt.index(1))
print(res)
print(" ".join(res_arr))
a = input('')
b = input('')

seki = int(a) * int(b)
sa = int(a) - int(b)
wa = int(a) + int(b)

if wa >= seki and wa >= sa:
    print(wa)
elif sa >= wa and sa >= seki:
    print(sa)
else:
    print(seki)


### FIXED CODE ###

a, b = input().split()

seki = int(a) * int(b)
sa = int(a) - int(b)
wa = int(a) + int(b)

if wa >= seki and wa >= sa:
    print(wa)
elif sa >= wa and sa >= seki:
    print(sa)
else:
    print(seki)
a, b = map(input().split())
if a > b:
    print("Alice")
elif a < b:
    print("Bob")
else:
    print("Draw")

### FIXED CODE ###


def one(x):
    if x == 1:
        ret = 14
        return ret
    else:
        ret = x
        return ret

a, b = map(int, input().split())
if one(a) > one(b):
    print("Alice")
elif one(a) < one(b):
    print("Bob")
else:
    print("Draw")
line = ["0", "0", "0"]
number = ''

N,M=(int(x) for x in input().split())

for y in range(M):
    s,c=input().split()
    S =int(s)-1
    #if not line[S] == "0": #ミスあり
    line[S] = c
print('line'line)

for z in line:
    #if not line[z] == "0":
    number += z
print(number)

if N == 3 and number[0]=='0':
    print('-1')
elif N == 2 and number[1]=='0':
    print('-1')
elif N == 1 and not number[0]=='0':
    print('-1')
elif N == 1 and not number[1]=='0':
    print('-1')    
elif number[0]=='0' and N==3:
    print('-1')
elif number[1]=='0' and N==2:
    print('-1')
elif number[2]=='0' and N==1:
    print('-1')
else:
    number = int(number)
    print(number)


### FIXED CODE ###

N,M=[int(x) for x in input().split()]
num_list = [None]*N
error = False
for y in range(M):
    s_,c = input().split()
    s = int(s_)
    if s == 1 and c == '0' and N > 1:
        error = True
    elif num_list[s-1] is not None and num_list[s-1]!=c:
        error = True
    else:
        num_list[s-1] = c
    #print(num_list)

if error:
    print('-1')
else:
    for y in range(N):
        if num_list[y] is None:
            if y==0 and N >1:
                num_list[y] = '1'   
            else:
                num_list[y] = '0'

    number = ''.join(num_list)
    print(number)
N,K,Q = map(int,input().split())
string_list=[int(input()) for i in range(Q)]
a = [K-Q]*N
for i in string_list:
    a[i] += 1
for i in a:
    print('Yes' if i > 0 else 'No')

### FIXED CODE ###

N,K,Q = map(int,input().split())
string_list=[int(input()) for i in range(Q)]
a = [K-Q]*N
for i in string_list:
    a[i-1] += 1
for i in a:
    print('Yes' if i > 0 else 'No')
a, b = list(map(int, input().split()))

    if a > b:
        print(str(b)*a)
    else:
        print(str(a)*b)

### FIXED CODE ###

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

if a > b:
    print(str(b)*a)
else:
    print(str(a)*b)
import math
N,D = [int(x) for x in input().split()]
count = 0
for i in range(D):
  X,Y = [int(x) for x in input().split()]
  if math.sqrt(X**2 + Y**2) <= D:
      count += 1
print(count)      

### FIXED CODE ###

import math
N,D = [int(x) for x in input().split()]
count = 0
for i in range(0,N):
  X,Y = [int(x) for x in input().split()]
  if math.sqrt(X**2 + Y**2) <= D:
      count += 1
print(count)
import math
a,b,c,d=map(int,input().split())
total=b-a+1
f1=(b//c)-(a//c)
if a%c==0:
    f1+=1
f2=(b//d)-(a//d)
if a%d==0:
    f2+=1
gcd=math.gcd(c,d)
lcm=(c*d)//gcd
f3=(b//lcm)-(a//lcm)
if a%lcm==0:
    f3+=1
f=f1+f2-f3
print(total-f)


### FIXED CODE ###

def gcd(x, y):
    while (y):
        x, y = y, x % y
    return x
a,b,c,d=map(int,input().split())
total=b-a+1
f1=(b//c)-(a//c)
if a%c==0:
    f1+=1
f2=(b//d)-(a//d)
if a%d==0:
    f2+=1
gcd=gcd(c,d)
lcm=(c*d)//gcd
f3=(b//lcm)-(a//lcm)
if a%lcm==0:
    f3+=1
f=f1+f2-f3
print(total-f)
#include <bits/stdc++.h>

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll>   pairl;
typedef vector<ll>     vl;
typedef vector<ll>     vll;
typedef vector<vector<ll> > vvl;
const   int            infi = numeric_limits<int>::max();
const   ll             infl = numeric_limits<ll>::max();
const   double         eps = 0;
const   int            ms  = 0;



int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    string s;
    cin >> s;
    string a[] = {"SUN", "MON" , "TUE", "WED", "THU", "FRI", "SAT"};
    for(int i = 1; i <= 6; i++){
        if(s == a[i]){
            cout << 7-i << endl;
            return 0;
        }
    }
    cout << 7 << endl;
    return 0;
}

### FIXED CODE ###

a = ["SUN", "MON" , "TUE", "WED", "THU", "FRI", "SAT"]

s = input()

for i in range(7):
    if s == a[i]:
        print(7-i)
import numpy as np

N, Q = map(int, input().split(" "))
s = input()
alpha = [chr(i) for i in range(65, 65+N)]
s_lst = np.array([alpha.index(i) for i in s])
gol = np.ones_like(s_lst)

for i in range(Q):
    t_str, d = input().split(" ")
    t = alpha.index(t_str)
    move_from = (s_lst == t)
    gol_move = gol * move_from
    gol[move_from] = 0
    if d == "R":
        gol_add = np.hstack((np.array([0]), gol_move[:-1]))
    else:
        gol_add = np.hstack((gol_move[1:], np.array([0])))
    gol = gol + gol_add
print(np.sum(gol))

### FIXED CODE ###

import numpy as np
import sys

N, Q = map(int, input().split(" "))
s = [np.nan] + list(input()) + [np.nan]
td = [input().split(" ") for _ in range(Q)]

l = 0
r = N+1

for i, j in td[::-1]:
    if s[l+1] == i and j == "L":
        l += 1
    elif s[l] == i and j == "R":
        l -= 1
    if s[r-1] == i and j == "R":
        r -= 1
    elif s[r] == i and j =="L":
        r += 1
ln = max(0, l)
rn = max(0, N+1-r)
print(N-ln-rn)
import sys

N, A, B = sys.argv[1:]

print min(N*A, B)

### FIXED CODE ###

import sys

for line in sys.stdin:
  N, A, B = map(int, line.split())

print min(N*A, B)
H,W,K = list(map(int,input().split()))
c = []
for i in range(H):
    c.append(list(input()))
ans = 0
H_pattern,W_pattern = 2**H,2**W
for i in range(0,H_pattern):
    for j in range(0,W_pattern):
        H_active,W_active=list(bin(H_pattern,i)[2:].zfill(H)),list(bin(W_pattern,j).zfill(H))
        count = 0
        for k,arr in enumerate(c):
            for l,item in enumerate(arr):
                if H_active[k] == "1" and W_active[l] == "1" and item == "#":
                    count += 1
        if count == K:
            ans += 1
print(ans)




### FIXED CODE ###

H,W,K = list(map(int,input().split()))
c = []
for i in range(H):
    c.append(list(input()))
ans = 0
H_pattern,W_pattern = 2**H,2**W
for i in range(0,H_pattern):
    for j in range(0,W_pattern):
        H_active_arr,W_active_arr=list(bin((H_pattern-1)&i)[2:].zfill(H)),list(bin((W_pattern-1)&j)[2:].zfill(W))
        count = 0
        for k,arr in enumerate(c):
            for l,item in enumerate(arr):
                if H_active_arr[k] == "1" and W_active_arr[l] == "1" and item == "#":
                    count += 1
        if count == K:
            ans += 1
print(ans)
M = map(int,input())
a = 48 - M
print(a)

### FIXED CODE ###

print(48 - int(input()))
# -*- coding: utf-8 -*-

a = int(input())
b = int(input())

out = "Even"	#Even奇数,Odd偶数


if ((a * b) % 2 == 0):
	out = "Odd"

print(out)

### FIXED CODE ###

X,Y = map(int, input().split())

if (X*Y % 2 == 0):  print("Even")
else:               print("Odd")
import sys
H, W, M = map(int, input().split())
hList = {i+1: 0 for i in range(H)}
wList = {i+1: 0 for i in range(W)}
pList = set()
#print(hList, wList, pList)
for _ in range(M):
  h, w = list(map(int, input().split()))
  #print(h, w)
  hList[h] += 1
  wList[w] += 1
  pList.add((h, w))
#print(hList, wList, pList)

maxHCount = max(hList.values())
maxHList = [h for h, count in hList.items() if count==maxHCount]


maxWCount = max(wList.values())
maxWList = [w for w, count in wList.items() if count==maxWCount]

#counterList = []
#for maxH in maxHList:
#  for maxW in maxWList:
#    counterList.append(hList[maxH] + wList[maxW] - (1 if ((maxH, maxW) in pList) else 0))
#print(max(counterList))
#print(max(((hList[maxH] + wList[maxW] - (1 if ((maxH, maxW) in pList) else 0)) for maxH in maxHList for maxW in maxWList)))
#print(max(((hList[maxH] + wList[maxW] - (1 if ((maxH, maxW) in pList) else 0)) for maxH in maxHList for maxW in maxWList)))

for maxH in maxHList:
  for maxW in maxWList:
    if (maxH, maxW) in pList:
      print(maxHCount + maxWList - 1)
      sys.exit(0)

print(maxHCount + maxWList])


### FIXED CODE ###

import sys
H, W, M = map(int, input().split())
hList = {i+1: 0 for i in range(H)}
wList = {i+1: 0 for i in range(W)}
pList = set()
#print(hList, wList, pList)
for _ in range(M):
  h, w = list(map(int, input().split()))
  #print(h, w)
  hList[h] += 1
  wList[w] += 1
  pList.add((h, w))
#print(hList, wList, pList)

maxHCount = max(hList.values())
maxHList = [h for h, count in hList.items() if count==maxHCount]


maxWCount = max(wList.values())
maxWList = [w for w, count in wList.items() if count==maxWCount]

#counterList = []
#for maxH in maxHList:
#  for maxW in maxWList:
#    counterList.append(hList[maxH] + wList[maxW] - (1 if ((maxH, maxW) in pList) else 0))
#print(max(counterList))
#print(max(((hList[maxH] + wList[maxW] - (1 if ((maxH, maxW) in pList) else 0)) for maxH in maxHList for maxW in maxWList)))
#print(max(((hList[maxH] + wList[maxW] - (1 if ((maxH, maxW) in pList) else 0)) for maxH in maxHList for maxW in maxWList)))

#if M < len(maxHList)*len(maxWList):
#	print(maxHCount + maxWCount)
#	sys.exit(0)

for maxH in maxHList:
  for maxW in maxWList:
    if (maxH, maxW) not in pList:
      print(maxHCount + maxWCount)
      sys.exit(0)

print(maxHCount + maxWCount - 1)
##C
a,b = map(int,input().split())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

aa = (prime_factorize(a))
bb = (prime_factorize(b))

def f(a1, b1):
  result = []
  for i in sorted(set(a1 + b1)):
    aa1 = [x for x in a1 if x == i]
    bb1 = [x for x in b1 if x == i]
    result += aa1 if len(aa1) < len(bb1) else bb1
  return result

from operator import mul
from functools import reduce

aabb = reduce(mul,f(aa,bb))

print(int(a*b/aabb))

### FIXED CODE ###

##C
a,b = map(int,input().split())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

aa = (prime_factorize(a))
bb = (prime_factorize(b))

def f(a1, b1):
  result = []
  for i in sorted(set(a1 + b1)):
    aa1 = [x for x in a1 if x == i]
    bb1 = [x for x in b1 if x == i]
    result += aa1 if len(aa1) < len(bb1) else bb1
  return result

from operator import mul
from functools import reduce

aabb1 = f(aa,bb)

if aabb1 == []:
    aabb1 = [1,1]

aabb = reduce(mul,aabb1)

print(int(a*b/aabb))
N,M=map(int,input().split())
S=list(map(int,input().split()))
S.sort()

TRADE=[[0 for j in range(2)] for i in range(M)]

for i in range(M):
    B,C=map(int,input().split())
    TRADE[i][0]=B
    TRADE[i][1]=C


T=sorted(TRADE,key=lambda x:x[1],reverse=True)


TLEN=0
pos=0
while TLEN<M:
    for i in range(T[TLEN][0]):
        if S[pos]<T[TLEN][1]:
            S[pos]=T[TLEN][1]
            pos+=1
    TLEN+=1

print(sum(S))

### FIXED CODE ###

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

TRADE=[[0 for j in range(2)] for i in range(M)]

for i in range(M):
    B,C=map(int,input().split())
    TRADE[i][0]=B
    TRADE[i][1]=C


T=sorted(TRADE,key=lambda x:x[1],reverse=True)


TLEN=0
pos=0
flag=True
while TLEN<M and flag==True:
    for i in range(T[TLEN][0]):
        if S[pos]<T[TLEN][1]:
            S[pos]=T[TLEN][1]
            pos+=1
        else:
            flag=False
            break
        if pos>len(S)-1:
            flag=False
            break
    TLEN+=1

print(sum(S))
n,m=(int(i) for i in input().split())
a=[]
a.append(int(j) for j in input().split())
for i in range(m):
  b,c=(int(i) for i in input().split())
  a.sort()
  for j in range(b):
    if a[j]<c:
      a[j]=c
r=0
for i in range(n):
  r=r+a[i]
print(r)

### FIXED CODE ###

a,b=(int(i) for i in input().split())
if a<=5:
  print(0)
elif 5<a<=12:
  print(b//2)
else:
  print(b)
from collections import deque
def main():
    n, k = map(int, raw_input().split())
    s = raw_input().strip()
    ans = deque(list(s))
    if n == 1:
        if k % 2:
            print 'A' if s[0] == 'B' else 'B'
        else:
            print s[0]
        return
    f = True
    for i in xrange(800020):
        if i >= k:
            if f:
                print ''.join(list(ans))
            else:
                print ''.join('A' if x == 'B' else 'B' for x in ans)
            break
        if (ans[0] == 'A') == f:
            ans[0] = 'B' if f else 'A'
        else:
            f = not f
            ans.popleft()
            ans.append('A' if f else 'B')
    else:
        k -= 800020
        k %= 2
        if not f:
            ans = ['B' if x == 'A' else 'A' for x in ans]
            ans = deque(ans)
        if k:
            if ans[0] == 'A':
                ans[0] = 'B'
            else:
                ans[0] = 'A'
        print ''.join(ans)
main()
from collections import deque
def main():
    n, k = map(int, raw_input().split())
    s = raw_input().strip()
    ans = deque(list(s))
    if n == 1:
        if k % 2:
            print 'A' if s[0] == 'B' else 'B'
        else:
            print s[0]
        return
    f = True
    for i in xrange(800020):
        if i >= k:
            if f:
                print ''.join(list(ans))
            else:
                print ''.join('A' if x == 'B' else 'B' for x in ans)
            break
        if (ans[0] == 'A') == f:
            ans[0] = 'B' if f else 'A'
        else:
            f = not f
            ans.popleft()
            ans.append('A' if f else 'B')
    else:
        k -= 800020
        k %= 2
        if not f:
            ans = ['B' if x == 'A' else 'A' for x in ans]
            ans = deque(ans)
        if k:
            if ans[0] == 'A':
                ans[0] = 'B'
            else:
                ans[0] = 'A'
        print ''.join(ans)
main()


### FIXED CODE ###

from collections import deque
def main():
    n, k = map(int, raw_input().split())
    s = raw_input().strip()
    ans = deque(list(s))
    if n == 1:
        if k % 2:
            print 'A' if s[0] == 'B' else 'B'
        else:
            print s[0]
        return
    f = True
    for i in xrange(400020):
        if i >= k:
            if f:
                print ''.join(list(ans))
            else:
                print ''.join('A' if x == 'B' else 'B' for x in ans)
            break
        if (ans[0] == 'A') == f:
            ans[0] = 'B' if f else 'A'
        else:
            f = not f
            ans.popleft()
            ans.append('A' if f else 'B')
    else:
        k -= 400020
        k %= 2
        if not f:
            ans = ['B' if x == 'A' else 'A' for x in ans]
            ans = deque(ans)
        if n % 2 and k:
            if ans[0] == 'A':
                ans[0] = 'B'
            else:
                ans[0] = 'A'
        print ''.join(ans)
main()
n = int(input())
A = list(map(int, input().split()))

zero_each_dig = [0 for _ in range(60)]
one_each_dig = [0 for _ in range(60)]

for i in range(n):
     for j in range(60):
        if (A[i] >> j) & 1 == 1:
            one_each_dig[j] += 1
        else:
            zero_each_dig[j] += 1

Multi = []
for k in range(n):
    Multi.append(zero_each_dig[k] * one_each_dig[k] * (2**k) % (10**9 +7))

ans = sum(Multi) % (10**9 +7)
print(ans)

### FIXED CODE ###

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

zero_each_dig = [0 for _ in range(60)]
one_each_dig = [0 for _ in range(60)]

for i in range(n):
     for j in range(60):
        if (A[i] >> j) & 1 == 1:
            one_each_dig[j] += 1
        else:
            zero_each_dig[j] += 1

Multi = []
for k in range(60):
    Multi.append(zero_each_dig[k] * one_each_dig[k] * (2**k) % (10**9 +7))

ans = sum(Multi) % (10**9 +7)
print(ans)
import numpy as np

def main():
    n, k = map(int, input().split())
    a = list(map(lambda x: int(x)-1, input().split()))
    count = 0
    foot = [0]
    is_loop = False

    for i in range(1,k):
        foot.append(a[foot[-1]])
        if foot.count(foot[-1]) == 2:
            st_i = foot.index(foot[-1])
            lo_size = len(foot)-1 - st_i

            k -= st_i
            k %= lo_size
            
            print(foot[st_i+k]+1)
            is_loop = True
            break
    
    if not is_loop:
        print(a[foot[-1]]+1)


if __name__ == '__main__':
    main()


### FIXED CODE ###

s = input()
t = input()
print('Yes' if s == t[:-1] else 'No')
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
import copy
K=int(input())
A=list(map(int,input().split()))
if A[-1]!=2:
    print(-1)
    exit()

maX=2
miN=2

for i in range(K-1,-1,-1):

    if A[i]//maX>=2:
        print(-1)
        exit()
    if A[i]//miN>=2:
        miN=A[i]
    else:
        if miN%A[i]==0:
            pass
        else:
            miN=(miN//A[i] +1) *A[i]
    maX=maX-max%A[i] + A[i]-1
print(miN,maX)


### FIXED CODE ###

# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
import copy
K=int(input())
A=list(map(int,input().split()))
if A[-1]!=2:
    print(-1)
    exit()

maX=2
miN=2

for i in range(K-1,-1,-1):

    if A[i]//maX>=2:
        print(-1)
        exit()
    if A[i]//miN>=2:
        miN=A[i]
    else:
        if miN%A[i]==0:
            pass
        else:
            miN=(miN//A[i] +1) *A[i]
    maX=maX-maX%A[i] + A[i]-1

mmaX=maX
for i in range(K):
    mmaX-=mmaX%A[i]
if mmaX==2:
    print(miN,maX)
else:
    print(-1)
n = input()
a = list(map(int, input()))
count = 0
while 1:
  b =[int(i/2) for i in a] 
  if a == b:
    count+=1
    a = b
  else:
    print(count)
    break



### FIXED CODE ###

n = input()
a = list(map(int, input().split()))
count = 0
while 1:
  if [int(i/2) for i in a] == [round(i/2, 1) for i in a]:
    count+=1
    a = [int(i/2) for i in a]
  else:
    print(count)
    break
n, k = map(int,input().split())
x = list(map(int, input().split()))

ns = 999999999

for i in range(n - k + 1):
    a = abs(x[i]) + (x[i + k - 1] - x[i])
    b = abs(x[i + k - 1]) + (x[i + k - 1] - x[i])
    ans = min(ans, a, b)
    
print(ans)

### FIXED CODE ###

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

ans = 999999999

for i in range(n - k + 1):
    a = abs(x[i]) + (x[i + k - 1] - x[i])
    b = abs(x[i + k - 1]) + (x[i + k - 1] - x[i])
    ans = min(ans, a, b)
    
print(ans)
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int,input().split())
P = list(map(int,input().split()))
uf = UnionFind(N)
for i in range(M):
    a, b = map(int,input().split())
    uf.union(a-1,b-1)
A = list(uf.all_group_members().values())
a = len(A)
B =[[] for i in range(a)]
import bisect
ans = 0
for i in range(a):
    S = A[i]
    for j in range(len(S)):
        s = S[j]
        insert_index = bisect.bisect_left(B[i],P[s]-1)
        B[i].insert(insert_index,P[s]-1)
    for k in range(len(S)):
        s = S[k]
        if B[i].count(s) == 1:
            ans += 1
print(ans)

### FIXED CODE ###

a,b,c,d = map(int,input().split())
ans = 'No'
if -d <= a-c <= d:
    ans = 'Yes'
if -d <= a-b <= d:
    if -d <= b-c <= d:
        ans = 'Yes'
print(ans)
from math import ceil
a,b,c,d = map(int, input().split())
x = (a+d-1)/d
y = (b+c-1)/b
if (x>=y):
  print("Yes")
  else:
    print("No")

### FIXED CODE ###

from math import ceil
a,b,c,d = map(int, input().split())
x = ceil(a/d)
y = ceil(c/b)
if (x>=y):
  print("Yes")
else:
  print("No")
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort(reverse = True)

if k > n:
    print(0)
else:
    for i in range(k):
        h.pop(i)
        
    print(sum(h))

### FIXED CODE ###

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

if k >= n:
    print(0)
else:
    h.sort()
    ans = 0
    for i in range(n - k):
        ans += h[i]
        
    print(ans)
x = long(input())

quotient = x // 11
remainder = x % 11

Answer = quotient * 2
if remainder > 6:
    Answer += 2
else:
    Answer += 1

print(Answer)

### FIXED CODE ###

x = int(input())

quotient = x // 11
remainder = x % 11

Answer = quotient * 2
if remainder > 6:
    Answer += 2
elif remainder > 0:
    Answer += 1
else:
    Answer += 0

print(Answer)