Harryxun/stf_run huggingface dataset:
import itertools

n = input()
p = map(int, input().split())
q = map(int, input().split())

x = itertools.permutations(list(range(n)), n)
pnum = 0
qnum = 0
for index, xx in enumerate(x):
  if(xx == p):
    pnum = index
  if(xx == q):
    qnum = index
    
print(abs(pnum - qnum))

### FIXED CODE ###

import itertools

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

x = itertools.permutations(list(range(1, n+1)), n)
pnum = 0
qnum = 0
for index, xx in enumerate(x):
  if(list(xx) == p):
    pnum = index
  if(list(xx) == q):
    qnum = index
    
print(abs(pnum - qnum))
s=int(input())

if s==4 or s==2 or s==1:
    print(4)
    
l=[]
else:
    for i in range(10**6+1):
        l.append(s)
        if l.count(4)>2:
            break
        elif s%2==0:
            s=s//2
        else:
            s=3*s+1
    x=l.index(4)

    l=l[x+1:]
    y=l.index(4)

    print(y+x+2)

### FIXED CODE ###

s=int(input())

if s==4 or s==2 or s==1:
    print(4)
    

else:
    l=[]
    for i in range(10**6+1):
        l.append(s)
        if l.count(4)>2:
            break
        elif s%2==0:
            s=s//2
        else:
            s=3*s+1
    x=l.index(4)

    l=l[x+1:]
    y=l.index(4)

    print(y+x+2)
n = int(input())
h = list(map(int, input().split()))

cnt =0
m =[]
for i in range(n - 1):
	if h[i] >= h[i + 1]:
		cnt += 1
		if i == n - 2:
			m.append(cnt)
	else:
		m.append(cnt)
		cnt = 0

print(max(m))

### FIXED CODE ###

full_num = int(input())     
A = list(map(int, input().split()))  
move = 0
A_result = ""
for i in range(full_num-1):
   if  A[i] >= A[i+1]:
       A_result =A_result+"1"
   else:
       A_result =A_result+"0"
B = list(A_result.split("0"))
C = []
for i in B:
    C.append(len(i))
print(max(C))
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
l = []
for i in range(n):
  l.append(abs(a-(t-x*6/1000)))
print(l.index(min(l))+1)


### FIXED CODE ###

n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
l = []
for i in range(n):
  l.append(abs(a-(t-h[i]*6/1000)))
print(l.index(min(l))+1)
#include<iostream>
using namespace std; 
  
int countValues(int n) 
{ 
    int unset_bits=0; 
    while (n) 
    { 
        if ((n & 1) == 0) 
            unset_bits++; 
        n=n>>1; 
    } 
  
    return 1 << unset_bits; 
} 
  
int main() 
{ 
    int n;
  cin >> n;
    cout << countValues(n) << endl; 
    return 0; 
} 


### FIXED CODE ###

p, q, r = map(int, input().split())

a = p + q
b = q + r
c = r + p
print(min(a, b, c))
dxy = [[1, 0], [0, 1], [-1, 0], [0, -1]]
field = []
H, W = 0, 0
def solver(x, y, symbol):
  global field, H, W
  if x < 0 or y < 0 or x >= H or y >= W:
    return
  for dx, dy in dxy:
    if x+dx < 0 or y+dy < 0 or x+dx >= H or y+dy >= W:
      continue
    if field[x+dx][y+dy] == symbol:
      field[x+dx][y+dy] = '.'
      solver(x+dx, y+dy, symbol)

while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  field = [list(raw_input()) for i in range(H)]

  ans = 0
  for x in xrange(H):
    for y in xrange(W):
      if field[x][y] != '.':
        solver(x, y, field[x][y])
        ans += 1
  print ans

### FIXED CODE ###

import Queue

dxy = [[1, 0], [0, 1], [-1, 0], [0, -1]]
field = []
H, W = 0, 0
q = Queue.Queue()

def solver(x, y, symbol):
  global q, field, H, W
  while True:
    if x < 0 or y < 0 or x >= H or y >= W:
      continue
    for dx, dy in dxy:
      if x+dx < 0 or y+dy < 0 or x+dx >= H or y+dy >= W:
        continue
      if field[x+dx][y+dy] == symbol:
        field[x+dx][y+dy] = '.'
        q.put([x+dx, y+dy])
    if q.empty():
      return
    x, y = q.get()

while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  field = [list(raw_input()) for i in range(H)]

  ans = 0
  for x in xrange(H):
    for y in xrange(W):
      if field[x][y] != '.':
        solver(x, y, field[x][y])
        ans += 1
  print ans
a,b,k = map(int,input().split())
num = min(a,k)
a -= num
k -= num
print(a,max(b-k,0))


### FIXED CODE ###

a, b = input().split()

print(b+a)
# -*- coding: utf-8 -*-
def check(z, zz, z_list, dire):
  zz += z_list[0] * dire
  if len(z_list) == 1:
    if z == zz:
      return 1
    else:
      return 0
  else:
    if check(z, zz, z_list[1:], 1) == 0 and check(z, zz, z_list[1:], -1) == 0:
      return 0
    else:
      return 1

    
def func(x, y, xx, yy, x_list, y_list):
  if len(x_list) == 0:
    if x != xx:
      return 0
  else:
    if check(x, xx, x_list, 1) == 0 and check(x, xx, x_list, -1) == 0:
      return 0
  if len(y_list) == 0:
    if y != yy:
      return 0
  else:
    if check(y, yy, y_list, 1) == 0 and check(y, yy, y_list, -1) == 0:
      return 0
  return 1

s = input()
x, y = map(int, input().split())
data = s.split("T")
xx, yy = 0, 0
i = 0
x_list = []
y_list = []
for Fs in data:
  if len(Fs) == 0:
    i += 1
  else:
    if i == 0:
      xx = len(Fs)
    elif i % 2 == 0:
      x_list.append(len(Fs))
    else:
      y_list.append(len(Fs))
    i += 1
if func(x, y, xx, yy, x_list, y_list) == 1:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

# -*- coding: utf-8 -*-
def check(z, zz, z_list):
  if len(z_list) == 0:
    if z != zz:
      return 0
    else:
      return 1
  else:
    z_n = len(z_list)
    z_hash = {}
    z_hash[0] = {}
    z_hash[0][zz] = 1
    z_hash[z_n] = {}
    z_hash[z_n][z] = 1
    for i in range(0,z_n):
      if i+1 not in z_hash:
        z_hash[i+1] = {}
        for b_z in z_hash[i]:
          a_z = b_z + z_list[i]
          z_hash[i+1][a_z] = 1
          a_z = b_z - z_list[i]
          z_hash[i+1][a_z] = 1
      else:
        for b_z in z_hash[i]:
          a_z = b_z + z_list[i]
          if a_z in z_hash[i+1]:
            return 1
          a_z = b_z - z_list[i]
          if a_z in z_hash[i+1]:
            return 1
        return 0
      if z_n-i-1 not in z_hash:
        z_hash[z_n-i-1] = {}
        for a_z in z_hash[z_n-i]:
          b_z = a_z + z_list[z_n-i-1]
          z_hash[z_n-i-1][b_z] = 1
          b_z = a_z - z_list[z_n-i-1]
          z_hash[z_n-i-1][b_z] = 1
      else:
        for a_z in z_hash[z_n-i]:
          b_z = a_z + z_list[z_n-i-1]
          if b_z in z_hash[z_n-i-1]:
            return 1
          b_z = a_z - z_list[z_n-i-1]
          if b_z in z_hash[z_n-i-1]:
            return 1
        return 0



s = input()
x, y = map(int, input().split())
data = s.split("T")
xx, yy = 0, 0
i = 0
x_list = []
y_list = []
for Fs in data:
  if len(Fs) == 0:
    i += 1
  else:
    if i == 0:
      xx = len(Fs)
    elif i % 2 == 0:
      x_list.append(len(Fs))
    else:
      y_list.append(len(Fs))
    i += 1
if check(x, xx, x_list) == 1 and check(y, yy, y_list) == 1:
  print("Yes")
else:
  print("No")
limit = int(input())
string = input()

if limit < len(string):
    print(string[:7] + '...')
else:
    print(stirng)

### FIXED CODE ###

limit = int(input())
string = input()

if limit < len(string):
    string = string[:limit] + '...'

print(string)
a, b, c = map(lambda s: s.strip(), input().split())

print(f"{a[0].upper()}{b[0].upper()}{c[0].upper()}")

### FIXED CODE ###

a, b, c = map(lambda s: s.strip(), input().split())

print("{0}{1}{2}".format(a[0].upper(), b[0].upper(), c[0].upper()))
import math

N = int(input())
A = sorted(map(int, input().split()))

for i in range(N - 1):
    A[i + 1] = math.gcd(A[i], A[i + 1])

print(A[N - 1])


### FIXED CODE ###

import fractions as f

N = int(input())
A = sorted(map(int, input().split()))

for i in range(N - 1):
    A[i + 1] = f.gcd(A[i], A[i + 1])

res = A[N - 1]
print(res)
n = int(input())
lis = list(map(int,input().split()))
m = int(input())
num = sum(lis)
for i in range(n):
  a,b = map(int,input().split())
  print(num-(lis[a-1]-b))

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
m = int(input())
for i in range(m):
    b,c = map(int,input().split())
    nu = a[b-1] -c
    print(sum(a)-nu)
o = input()
e = input()

n = len(e)
ans = ''
for i in range(n):
	ans += o[i]
  	ans += e[i]
    
if len(o)%2==1:
	ans += o[-1]
    
print(ans)

### FIXED CODE ###

o = input()
e = input()

n = len(e)
ans = ''
for i in range(n):
  ans += o[i]
  ans += e[i]
    
if len(o)>n:
  ans += o[-1]

print(ans)
inp1 = input()
n = int(inp1.split(" ")[0])
k = int(inp1.split(" ")[1])
q = int(inp1.split(" ")[2])

each_point = []
for i in range(n):
  each_point.append(k)


for j in range(q):
  ans = int(input())
  for m in range(n):
    int_point[m] -= 1
  int_point[ans-1] += 1

for x in range(n):
  if (int_point[x] < 1):
    print("No")
  else:
    print("Yes")


### FIXED CODE ###

import sys

def happyo(n,each_point):
  for x in range(n):
    if (each_point[x] < 1):
      print("No")
    else:
      print("Yes")

inp1 = input()
n = int(inp1.split(" ")[0])
k = int(inp1.split(" ")[1])
q = int(inp1.split(" ")[2])

if(k>100000):
  for x in range(n):
    print("Yes")
  sys.exit()

each_point = []
for i in range(n):
  each_point.append(k-q)
 

for j in range(q):
  ans = int(input())
  each_point[ans-1] += 1
 
happyo(n,each_point)
n, m = map(int, input().split())
py = []
mli = [0]*m
li = [""]*m

for i in range(m):
    p,y = map(int, input().split())
    py.append([p,y,i])

py.sort(key=lambda x: x[1])

for p,y,i in py:
    mli[p-1] += 1
    pi = str(p).zfill(6)
    yi = str(mli[p-1]).zfill(6)
    li[i] = pi+yi

for i in li:
    print(i)

### FIXED CODE ###

n, m = map(int, input().split())
py = []
mli = [0]*n
li = [""]*m

for i in range(m):
    p,y = map(int, input().split())
    py.append([p,y,i])

py.sort(key=lambda x: x[1])

for p,y,i in py:
    mli[p-1] += 1
    pi = str(p).zfill(6)
    yi = str(mli[p-1]).zfill(6)
    li[i] = pi+yi

for i in li:
    print(i)
S = input()
K = int(input())

l = len(S)
pair = []
current = S[0]
seq = 1
for i in range(1, l):
    if(i == l-1):
        if(S[i]==current):
            seq += 1
        if(seq != 1):
            pair.append(seq)
    elif(S[i] == current):
        seq += 1
    else:
        if(seq != 1):
            pair.append(seq)
        seq = 1
        current = S[i]

ans = 0
print(pair)
if(S[0] != S[l-1]):
    for i in range(len(pair)):
        ans += K * (pair[i]//2)
else:
    if(len(pair) == 1):
        ans += ((pair[0]+1)//2)*(K-1) + (pair[0]//2)
    else:
        for i in range(len(pair)-1):
            ans += K * i
        ans += ((pair[i+1]+1)//2)*(K-1) + (pair[i+1]//2)

print(ans)

### FIXED CODE ###

S = input()
K = int(input())

S += "1"
l = len(S)
pair = []
current = S[0]
seq = 1
for i in range(1, l):
    if(i == l):
        pair.append(seq)
    elif(S[i] == current):
        seq += 1
    else:
        pair.append(seq)
        seq = 1
        current = S[i]

ans = 0
#print(pair)
if(len(pair) == 1):
    ans += (K * pair[0])//2
elif(S[0] != S[l-2]):
    for i in range(len(pair)):
        ans += K * (pair[i]//2)
else:
    for i in range(1, len(pair)-1):
        ans += K * (pair[i]//2)
    ans += (pair[0]//2) + (pair[i+1]//2) + ((pair[0]+pair[i+1])//2)*(K-1)

print(ans)
a = [int(input()) for i in range 6]
print("Yay!" if a[4]-a[0]<=a[5] else ":(")

### FIXED CODE ###

a = [int(input()) for i in range(6)]
print("Yay!" if a[4]-a[0]<=a[5] else ":(")
#??????????????? : ?¨??????\??????????????????????????????, http://qiita.com/clarinet758/items/53e31ec10b873975438b
a, b = map(int, raw_input().split())

s = a * b
l = 2 * (a + b)

print "%d  %d" % (s ,l)

### FIXED CODE ###

#reference : http://qiita.com/clarinet758/items/53e31ec10b873975438b
#reference : #1511943 Solution for ITP1_1_C: Rectangle by Signorte
# print "%d %d" % (s ,l) => ERROR

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

s = a * b
l = 2 * (a + b)

print "%s %s" % (str(s) ,str(l))
#AtCoder

N, K = (int(x) for x in input().split())
S = (int(input()) for _ in range(N))

lst = list(S)

print(max(lst)-min)

### FIXED CODE ###

n, k = map(int, input().split())
h = [int(input()) for _ in range(n)]

h.sort()
m = sum(h)

for i in range(n - k + 1):
    m = min(h[i + k - 1] - h[i], m)
print(m)
import sys
while True :
    ab = sys.stdin.readline().split()
    a = ab[0].strip
    b = ab[1].strip
    if a == 0 and b == 0 :
        break

### FIXED CODE ###

import sys
while True :
    ab = list(map(int,sys.stdin.readline().split()))
    a = ab[0]
    b = ab[1]
    if a == 0 and b == 0 :
        break
    else :
        ab = sorted(ab)
        print(ab[0],ab[1])
from itertools import combinations

def score (cids):
    x = abs(sum(data[cid][0] for cid in cids))
    y = abs(sum(data[cid][1] for cid in cids))
    z = abs(sum(data[cid][2] for cid in cids))
    return x + y + z

n, m = map(int, input().split())
data = list([int(x) for x in input().split()] for _ in range(n))
print(max(score(x) for x in combinations(range(n), m)))
~

### FIXED CODE ###

n, m = map(int, input().split())
data = [[int(x) for x in input().split()] for _ in range(n)]

pats = [(x,y,z) for x in [-1,1] for y in [-1,1] for z in [-1,1]] # +++,++-,...,---
score = lambda sgns, vals: sum([s * x for(s, x) in zip(sgns, vals)])  # i.e.x+y-z
result = max(sum(sorted((score(pat, row) for row in data), reverse=True )[:m]) for pat in pats)
print(result)
# -*- coding: utf-8 -*-
N= int(input())
if N == 1:
# -*- coding: utf-8 -*-
N = int(input())
digit_count = len(str(N))
if digit_count == 1:
    print(N)
if (digit_count % 2 == 1):
    print(N - int(str(90) * (digit_count//2)))
else:
    total = 0
    for i in range(0, digit_count//2):
        total += 9*(100**i)
    print(total)

### FIXED CODE ###

# -*- coding: utf-8 -*-
N = int(input())
digit_count = len(str(N))
if digit_count == 1:
    print(N)
elif (digit_count % 2 == 1):
    print(N - int(str(90) * (digit_count//2)))
else:
    total = 0
    for i in range(0, digit_count//2):
        total += 9*(100**i)
    print(total)
imput_list = list(map(int,input().split()))
a = imput_list[1]/imput_list[0]
print(math.floor(math.log2(a)) + 1)

### FIXED CODE ###

input_list = list(map(int,input().split()))
for i in range(61):
    if (input_list[0]*(2**i )<=input_list[1])&(input_list[0]*(2**(i +1))>input_list[1]):
        print(i+1)
n=int(input())
text=[input() for i in range(n)]
print("".join(sorted(text)))

### FIXED CODE ###

ans=list(map(int,input().split()))
if ans.count(5)==2 and ans.count(7)==1:
    print("YES")
else: print("NO")
import collections

sys.stdin = io.StringIO(_INPUT)
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    acopy = a.copy()
    del acopy[i]
    c = collections.Counter(acopy)
    itm = c.values()
    ans = 0
    for j in itm:
        ans += j*(j-1)//2
    print(ans)

### FIXED CODE ###

import collections
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
v = c.values()
s = 0
for i in v:
    s += (i*(i-1))//2

for i in range(n):
    d = c[a[i]]
    x = (d*(d-1))//2 if d > 1 else 0
    y = ((d-1)*(d-2))//2 if d > 2 else 0
    print(s-x+y)
N = input()
A = list((map(int,input().split()))
B = list(map(int,input().split()))

ans = 0
         
for i in range(0,N):
    left = A[i] - B[i]
	ans += min(A[i],B[i])
         
    if left < 0:
		right = A[i+1] - abs(left)
    	ans += min( A[i+1],abs(left))
		A[i+1] = right

print(ans)


### FIXED CODE ###

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

ans = 0
         
for i in range(0,N):
      left = A[i] - B[i]
      ans += min(A[i],B[i])
         
      if left < 0:
          right = A[i+1] - abs(left)
          if right < 0: right = 0
          ans += A[i+1] - right
          A[i+1] = right

print(ans)
n,m = map(int, input().split())
a_list = [int(a) for a in input().split()]
a_list.sort()
bc_list = [0 for _ in range(m)]
for i in range(m):
    b,c = map(int, input().split())
    bc_list[i] = [b,c]
bc_list.sort(key= lambda x:x[1],reverse=True)
cur = 0
for i in range(m):
    b,c = bc_list[i][0],bc_list[i][1]
    for j in range(b):
        if a_list[cur]>=c or cur>=n:
            break
        else:
            a_list[cur] = c
            cur += 1
    else:
        continue
    break
print(sum(a_list))

### FIXED CODE ###

n,m = map(int, input().split())
a_list = [int(a) for a in input().split()]
a_list.sort()
bc_list = [0 for _ in range(m)]
for i in range(m):
    b,c = map(int, input().split())
    bc_list[i] = [b,c]
bc_list.sort(key= lambda x:x[1],reverse=True)
cur = 0
for i in range(m):
    b,c = bc_list[i][0],bc_list[i][1]
    for j in range(b):
        if cur >= n:
            break
        if a_list[cur]>=c:
            break
        else:
            a_list[cur] = c
            cur += 1
    else:
        continue
    break
print(sum(a_list))
n = map(int, input().split())
n.sort()
print(n[2]*10 + n[1] + n[0])

### FIXED CODE ###

n = [int(i) for i in input().split()]
n.sort()
print(n[2]*10 + n[1] + n[0])
def gcd( x, y ):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

N = gcd(A, B)
print(make_divisors(N)[-K])

### FIXED CODE ###

A, B, K = map(int, input().split())

def func(M, L, K):
    count = 0

    for ans in reversed(range(1,L+1)):
        if M % ans == 0 and L % ans == 0:

            count += 1

            if count == K:
                print(ans)

if A > B:
    func(A, B, K)
else:
    func(B, A, K)
N,M=map(int,input().split())
ans=['A']*(N+1)
for i in range(M):
    s,c=map(str,input().split())
    s=int(s)
    if ans[s]=='A' or ans[s]==c :
        ans[s]=c
    else:
        print('-1')
        exit()
if N>1 and ans[1]=='0':
    print('-1')
FA=ans[1:]
FA=''.join(FA)
if FA.count('A')>0:
    print(FA.replace('A','0'))
print(int(FA))


### FIXED CODE ###

N,M=map(int,input().split())
ans=[-1]*(N+1)
for i in range(M):
    s,c=map(int,input().split())
    if ans[s]==-1 :
        ans[s]=c
    elif ans[s]==c :
        pass
    else:
        print('-1')
        exit()

if N>=2 and ans[1]==0:
    print('-1')
    exit()
elif N>=2 and ans[1]==-1: #ここが間違ってた。
    ans[1]=1
else:
    pass

for j in range(len(ans)):
    if ans[j] == -1:
        ans[j] = 0

if N==1:
    FA=ans[-1]
elif N==2:
    FA=10*ans[-2]+ans[-1]
else:
    FA=100*ans[-3]+10*ans[-2]+ans[-1]
print(FA)
K = int(input())
A, B = map(int, input().split())

if A%K == 0 or B%K == 0
	print 'OK'

elif A <= K*(A//K + 1) and K*(A//K + 1) <= B :
	print 'OK'

else :
	print 'NG'


### FIXED CODE ###

K  = int((input() .split())[0])
A, B = map(int, input().split())

if A%K == 0 or  K*(A//K + 1) <= B :
	print('OK')

else :
	print('NG')
n=int(input())
s=input()
print(["No","Yes"][s[:int(n/2)]]==s[int(n/2):])

### FIXED CODE ###

n=int(input())
s=input()
print(["No","Yes"][s[:int(n/2)]==s[int(n/2):]])
c=input()
print("vowel"if c=='a','i','u','e','o' else "constant")

### FIXED CODE ###

c=input()
print("vowel"if c in "aiueo" else "consonant")
N,K = map(int,input().split())
A = [0]+list(map(int,input().split()))
dp = [False]*(N+1)
tele = 0
for i in range(10**5):
    if i==0:
        tele = 1
        dp[tele]=True
    else:
        tele = A[tele]
        if dp[tele]==True:
            finish = i
            tele1 = tele
            break
        else:
            dp[tele]=True
#print(finish)
#print(tele)
tele = 0
for i in range(10**5):
    if i == 0:
        tele = 1
        if tele == tele1:
            start = i
            break
    else:
        tele = A[tele]
        if tele == tele1:
            start = i
            break
#print(start)
loop = finish-start
if K<=start:
    ans = 1
    for i in range(K):
        ans = A[ans]
    print(ans)
else:
    ans = 1
    for i in range(start+(K-start)%loop):
        ans = A[ans]
    print(ans)

### FIXED CODE ###

N,K = map(int,input().split())
A = [0]+list(map(int,input().split()))
dp = [False]*(N+1)
tele = 0
for i in range(10**6):
    if i==0:
        tele = 1
        dp[tele]=True
    else:
        tele = A[tele]
        if dp[tele]==True:
            finish = i
            tele1 = tele
            break
        else:
            dp[tele]=True
#print(finish)
#print(tele)
tele = 0
for i in range(10**6):
    if i == 0:
        tele = 1
        if tele == tele1:
            start = i
            break
    else:
        tele = A[tele]
        if tele == tele1:
            start = i
            break
#print(start)
loop = finish-start
if K<=start:
    ans = 1
    for i in range(K):
        ans = A[ans]
    print(ans)
else:
    ans = 1
    for i in range(start+(K-start)%loop):
        ans = A[ans]
    print(ans)
from itertools import permutations
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]

def calc(p):
    ret = 0
    # 各条件を満たしていれば、dを加算していく
    for a, b, c, d in abcd:
        if p[b-1] - p[a-1] == c:
            ret += d
    return ret

ans = 0
for p in permutations(range(1,1+M)):
    p = list(p)[:N]
    ans = max(ans, calc(p))
print(ans)


### FIXED CODE ###

N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]

def calc(p):
    ret = 0
    # 各条件を満たしていれば、dを加算していく
    for a, b, c, d in abcd:
        if p[b-1] - p[a-1] == c:
            ret += d
    return ret

ans = [0]
def dfs(s):
    if len(s) == N:
        ans[0] = max(ans[0], calc(s))
        return
    for i in range(s[-1],M+1):
        dfs(s+[i])

for i in range(1, M+1):
    dfs([i])

print(ans[0])
import copy
N = int(input())
X = list(map(int,input().split()))
length = len(X)
sortx = sorted(X)
bef = sortx[int(length/2)]
aft = sortx[int(length/2)+1]

for i in range(N):
    if(X[i]<=bef):
        print(bef)
    else:
        print(aft)

### FIXED CODE ###

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

sortx = sorted(X)
bef = sortx[N//2-1]
aft = sortx[N//2]
for i in X:
        print(aft if i <= bef else bef)
t = [0]
x = [0]
y = [0]
N = int(input())
for i in range(1,N+1):
  ti,xi,yi = map(int,input(),split())
  t.append(ti)
  x.append(xi)
  y.append(yi)
  
flg = True
 
for i in range(0,N):
  if t[i+1]-t[i] <　x[i+1]-x[i] + y[i+1]-y[i]:
    flg = False
  else (t[i+1]-t[i])%2 - (x[i+1]-x[i] + y[i+1]-y[i])%2==0:
    flg = False
if (flg):
  print('Yes')
else:
  print('No')

### FIXED CODE ###

t = [0]
x = [0]
y = [0]
n = int(input())
for i in range(n):
    ti, xi, yi = map(int, input().split())
    t.append(ti)
    x.append(xi)
    y.append(yi)
    
flg=True
for i in range(1, n+1):
    if((x[i]-x[i-1])+(y[i]-y[i-1])>(t[i]-t[i-1])):
        flg=False
    elif(((x[i]-x[i-1])+(y[i]-y[i-1]))%2!=(t[i]-t[i-1])%2):
        flg=False
if(flg):
    print("Yes")
else:
    print("No")
N, M=map(int, input().split())
AB= [map(int, input().split()) for _ in range(M)]
A, B = [list(i) for i in zip(*AB)]
G=[[A[0],B[0]]]

for i in range(1,M):
    count=0
    for j in range(len(G)):
        if A[i] in G[j]:
            if B[i] not in G[j]:
                G[j].append(B[i])
                count=1
        elif B[i] in G[j]:
            if A[i] not in G[j]:
                G[j].append(A[i])
                count=1
    if count==0:
        G.append([A[i],B[i]])
print(max([len(v) for v in G]))

### FIXED CODE ###

N, M=map(int, input().split())
A=[]
B=[]
for i in range(M):
    a,b=map(int, input().split())
    A.append(a)
    B.append(b)
# AB= [map(int, input().split()) for _ in range(M)]
# A, B = [list(i) for i in zip(*AB)]
def find(x,parent):
    if parent[x]==x:
        return x
    else:
        parent[x]=find(parent[x],parent)
        return(parent[x])
        
def union(x,y,parent,rank):
    xroot=find(x,parent)
    yroot=find(y,parent)
    if rank[xroot]>rank[yroot]:
        parent[yroot]=xroot
    elif rank[yroot]>rank[xroot]:
        parent[xroot]=yroot
    elif rank[yroot]==rank[xroot]:
        parent[yroot]=xroot
        rank[xroot]+=1
    return(parent,rank)

    
parent=[i for i in range(N+1)]
rank=[0]*(N+1)
for i in range(M):
    parent,rank=union(A[i],B[i],parent,rank)
for i in range(N+1):
    find(i,parent)
G=parent[1:]
import collections
c=collections.Counter(G)
print(int(c.most_common()[0][1]))