Harryxun/stf_run huggingface dataset:
def csum(c):
  r = 0
  for index, item in enumerate(c):
    r += index * item
  return r

n = int(input())
l= list(map(int,input().split()))
c = [0] * 10001
for i in l:
  c[i] += 1
n = int(input())
for i in range(0, n):
  be,af = map(int,input().split())
  c[af] += c[be]
  c[be] = 0
  print(csum(c))

### FIXED CODE ###

N = int(input())
A= list(map(int,input().split()))
Q = int(input())
heavy = [0] * (10 ** 5 + 1)
for i in A:
  heavy[i] += 1
s = sum(A)
for i in range(Q):
  be,af = map(int,input().split())
  s -= be * heavy[be]
  s += af * heavy[be]
  heavy[af] += heavy[be]
  heavy[be] = 0
  print(s)
from bisect import bisect_right
from sys import setrecursionlimit

setrecursionlimit(10**8)
n = int(input())
A = list(map(int, input().split()))
gr = []
for i in range(n):
    gr.append([])
for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    gr[a].append(b)
    gr[b].append(a)
ans = [0] * n
dp = [10 ** 10 for i in range(n)]
dp[0] = -10 ** 10
kek = 1
used = {0}


def dfs(v):
    global kek
    j = bisect_right(dp, A[v] - 1)
    old = -1
    if dp[j - 1] < A[v] < dp[j]:
        old = dp[j]
        dp[j] = A[v]
        if kek == j:
            for h in range(kek + 1, n):
                if dp[h] == 10 ** 10:
                    kek = h
                    break
            if kek == j:
                kek = n
    ans[v] = kek - 1
    for u in gr[v]:
        if u not in used:
            used.add(u)
            dfs(u)
    dp[j] = old
    if kek > j and old == 10 ** 10:
        kek = j


dfs(0)
print(*ans)

### FIXED CODE ###

from bisect import bisect_right
from sys import setrecursionlimit

setrecursionlimit(10**8)
n = int(input())
A = list(map(int, input().split()))
gr = []
for i in range(n):
    gr.append([])
for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    gr[a].append(b)
    gr[b].append(a)
ans = [0] * n
dp = [10 ** 10 for i in range(1 + n)]
dp[0] = -10 ** 10
kek = 1
used = {0}


def dfs(v):
    global kek
    j = bisect_right(dp, A[v] - 1)
    old = dp[j]
    if dp[j - 1] < A[v] < dp[j]:
        old = dp[j]
        dp[j] = A[v]
        if kek == j:
            for h in range(kek + 1, 1 + n):
                if dp[h] == 10 ** 10:
                    kek = h
                    break
            if kek == j:
                kek = n + 1
    ans[v] = kek - 1
    for u in gr[v]:
        if u not in used:
            used.add(u)
            dfs(u)
    dp[j] = old
    if kek > j and old == 10 ** 10:
        kek = j


dfs(0)
print(*ans)
x=int(input()).split
a=x[0]
b=x[1]
c=a*b
d=(a+b)*2
print c, d

### FIXED CODE ###

list=input().split()
x=int(list[0])
y=int(list[1])
print (x*y,(x*2)+(y*2))
A, B =map(int, input().split())
if B%A=0:
    print(A+B)
else:
    print(B-A)

### FIXED CODE ###

A, B = map(int, input().split())
if B%A==0:
  print(A+B)
else:
  print(B-A)
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
change = [list(map(int,input().split())) for _ in range(M)]

def tempchange(l,change):
  cnt = []
  total = sum(l)
  for i in range(M):
    B,C = change[i][0],change[i][1]
    for j in range(B):
      dif = C - l[-1]
      if dif > 0:
        l.pop()
        cnt.append(dif)
  return total + sum(cnt)

A.sort(reverse = True)
change.sort(key = lambda x:x[1],reverse =True)
print(tempchange(A,change))

### FIXED CODE ###

from heapq import heappush,heappop,heapify

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

def tempchange(l,change):
  heapify(l)  
  for B,C in change:
    for j in range(B):
      a = heappop(l)
      if C - a > 0:
        heappush(l,C)
      else:
        heappush(l,a)
        break
  return sum(l)

#A.sort(reverse = True)
change.sort(key = lambda x:x[1],reverse =True)
print(tempchange(A,change))
import math
nums = list(map(int , input().split())
a = nums[0]
b = nums[1]
print(a // b)
print(a % b)
print(float(a / b))

### FIXED CODE ###

nums = list(map(int , input().split()))
a = nums[0]
b = nums[1]
print(a // b , end = " ")
print(a % b , end = " ")
print("{0:.5f}".format((a / b)))
K,X=map(int,input().split())
print(*[x for x in range(X-K+1,X+K)]

### FIXED CODE ###

K,X=map(int,input().split())
print(*[x for x in range(X-K+1,X+K)])
def solve(stns, idx, mem):
    
    if idx >= len(stns) -1:
        return 0

    if idx in mem: 
        return mem[idx]

    if idx == len(stns) - 2: 
        # can take only one step
        final_step = solve(stns, idx + 1, mem) + abs(stns[idx] - stns[idx+1])
        mem[idx] = final_step
        return final_step
    else: 
        # step: i + 1
        step1 = solve(stns, idx + 1, mem) + abs(stns[idx] - stns[idx+1])
        # step: i + 2
        step2 = solve(stns, idx + 2, mem) + abs(stns[idx] - stns[idx+2])

    min_cost = min(step1, step2)
    mem[idx] = min_cost 

    return min_cost



def take_input():
    n = input()
    stns = [int(x) for x in input().split(' ')]
    mem = {}
    res = solve(stns, 0, mem)
    print(res)

take_input()

### FIXED CODE ###

import sys
def solve(stns, idx, mem):

    if idx >= len(stns) -1:
        return 0

    if idx in mem: 
        return mem[idx]

    if idx == len(stns) - 2: 
        # can take only one step
        # print(idx)  
        # final_step = solve(stns, idx + 1, mem) + abs(stns[idx] - stns[idx+1])
        final_step = abs(stns[idx] - stns[idx+1])
        mem[idx] = final_step
        return final_step
    else: 
        # step: i + 11
        step1 = solve(stns, idx + 1, mem) + abs(stns[idx] - stns[idx+1])
        # step: i + 2
        step2 = solve(stns, idx + 2, mem) + abs(stns[idx] - stns[idx+2])

        min_cost = min(step1, step2)
        mem[idx] = min_cost 

        return min_cost



def take_input():
    # n = input()
    # stns = [int(x) for x in input().split(' ')]



    reader = (s.rstrip() for s in sys.stdin)
    input = reader.__next__
    sys.setrecursionlimit(1000000)
    # do magic here
    n = int(input())
    stns = [int(x) for x in input().split()]
    mem = {}
    res = solve(stns, 0, mem)
    print(res)

take_input()
# -*- coding: utf-8 -*-
import functools 
import math

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

toshiList = list(map(int,input().split()))

absList =[0] * len(toshiList)

for i in range(0,len(toshiList)):
    absList[i] = abs( toshiList[i] -X)

ans = functools.reduce(math.gcd,absList)

    
print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import fractions
from functools import reduce

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

toshiList = list(map(int,input().split()))

absList =[0] * len(toshiList)

for i in range(0,len(toshiList)):
    absList[i] = abs( toshiList[i] - X)

ans = reduce(fractions.gcd,absList)
    
print(ans)
x,y = map(int,input().split())

if y%2 == 0 and x*2=<y<=x*4:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

x,y = map(int,input().split())

if y%2 == 0 and x*2 <=y <=x*4:
  print('Yes')
else:
  print('No')
from collections import defaultdict

n, m = [int(i) for i in raw_input().split()]

parents = {}

i = 0
while i < m:
    u, v = [int(x) for x in raw_input().split()]
    if v-1 in parents:
        parents[v-1].append(u-1)
    else:
        parents[v-1] = [u-1]
    i += 1

def calc_f(parents, f, i):
    if f[i] != -1:
        return f[i]

    f[i] = 0
    if i in parents:
        for v in parents[i]:
            f[i] = max(f[i], calc_f(parents, f, v)+1)

    return f[i]

f = [-1] * n
j = 0
while j < n:
    calc_f(parents, f, j)
    j += 1

print max(f)


### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(1000000)

n, m = [int(i) for i in raw_input().split()]
parents = defaultdict(list)

i = 0
while i < m:
    u, v = [int(x) for x in raw_input().split()]
    parents[v-1].append(u-1)
    i += 1

def calc_f(parents, f, i):
    if i < 0 or i >= len(f):
        return 0

    if f[i] != -1:
        return f[i]

    f[i] = 0
    for v in parents[i]:
        f[i] = max(f[i], calc_f(parents, f, v)+1)

    return f[i]

f = [-1] * n
j = 0
while j < n:
    calc_f(parents, f, j)
    j += 1

if len(f) == 0:
    print 0
else:
    print max(f)
port sys
import math
from collections import deque
input = lambda: sys.stdin.readline().rstrip()
Yes = lambda boolean: print('Yes') if boolean else print('No')
YES = lambda boolean: print('YES') if boolean else print('NO')
aint = lambda: int(input())
ints = lambda: list(map(int, input().split()))
is_even = lambda x: True if x%2==0 else False

n = aint()
get = []
for i in range(n):
  s = input()
  if s not in get:
    get.append(s)
print(len(get))

### FIXED CODE ###

import sys
import math
from collections import deque
input = lambda: sys.stdin.readline().rstrip()
Yes = lambda boolean: print('Yes') if boolean else print('No')
YES = lambda boolean: print('YES') if boolean else print('NO')
aint = lambda: int(input())
ints = lambda: list(map(int, input().split()))
is_even = lambda x: True if x%2==0 else False

n = aint()
get = []
for i in range(n):
    s = input()
    get.append(s)
ss = set(get)
print(len(ss))
N,A=map(int, input().split())
x=tuple(map(lambda i:int(i)-A,input().split()))
l=[0]*5001
l[0]=1
for i in x:
    f=l.copy()
    for j in range(-2500,2501):
        if l[j]:
            f[i+j]+=l[j]
    l=f.copy()
print(l[0]-1)

### FIXED CODE ###

N,A=map(int, input().split())
x=tuple(map(lambda i:int(i)-A,input().split()))
l=[0]*5001
l[0]=1
for i in x:
    f=l.copy()
    for j in range(-2500,2501):
        if l[j]:
            f[i+j]+=l[j]
    l=f.copy()
print(l[0]-1)
a = input()
b = input()
a = int(a)
b = int(b)

def P(x,y):
 print(x*y,2*(x+y))
 return 0

P(a,b)

### FIXED CODE ###

t = input()
t = t.split()
a = int(t[0])
b = int(t[1])

def P(x,y):
 print(x*y,2*(x+y))
 return 0

P(a,b)
a,b = map(str,input().split())
print(b+c)


### FIXED CODE ###

a,b = map(str,input().split())
print(b+a)
while True:
 result = 0
 i = input().split()
 if i[1] == '+':
  result = int(i[0]) + int(i[2])
 elif i[1] == '-':
  result = int(i[0]) - int(i[2])
 elif i[1] == '*':
  result = int(i[0]) * int(i[2])
 elif i[1] == '/':
  result = int(i[0]) // int(i[2])
 print(result)

### FIXED CODE ###

while True:
 result = 0
 i = input().split()
 if i[1] == '+':
  result = int(i[0]) + int(i[2])
 elif i[1] == '-':
  result = int(i[0]) - int(i[2])
 elif i[1] == '*':
  result = int(i[0]) * int(i[2])
 elif i[1] == '/':
  result = int(i[0]) // int(i[2])
 elif i[1] == '?':
  break
 print(result)
import sys

sys.setrecursionlimit(100000)

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

visited = [0 for _ in range(N)]
graph = [[0] * M for _ in range(M)]
for _ in range(M):
    a, b = map(int, input().split())
    graph[a - 1][b - 1] = 1
    graph[b - 1][a - 1] = 1


def dfs(i, depth):
    if visited[i]:
        return 0
    if depth == N - 1:
        return 1

    visited[i] = 1
    ret = 0
    for j in range(0, N):
        if graph[i][j]:
            ret += dfs(j, depth + 1)

    visited[i] = 0

    return ret


print(dfs(0, 0))

### FIXED CODE ###

N, M = map(int, input().split())
graph = [[] for i in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)


def dfs(now, prev, visited):
    visited.append(now)
    if len(visited) == N:
        return 1

    ret = 0
    for edge in graph[now]:
        if edge == prev:
            continue
        if edge in visited:
            continue

        ret += dfs(edge, prev, visited[:])

    return ret


print(dfs(0, -1, []))
n, m = map(int, input().split(' '))
ab = []
for _ in range(n):
    ab.append(list(map(int, input().split(' '))))
ab = list(filter(lambda x: x[0] <= m, ab))
ab = sorted(ab, key=lambda x: (-x[1], -x[0]))

ans = 0
while m > 0:
    ab = list(filter(lambda x: x[0] <= m, ab))
    if ab[0][0] <= m:
        ans += ab[0][1]
        ab.pop(0)
    else:
        break
    m -= 1
print(ans)


### FIXED CODE ###

import heapq


class Reverse:
    def __init__(self, val):
        self.val = val

    def __lt__(self, other):
        return self.val > other.val

    def __repr__(self):
        return repr(self.val)


class Heapq:
    def __init__(self, arr, desc=False):
        if desc:
            for i in range(len(arr)):
                arr[i] = Reverse(arr[i])
        self.desc = desc
        self.hq = arr
        heapq.heapify(self.hq)

    def pop(self):
        if len(self.hq) == 0:
            return None
        if self.desc:
            return heapq.heappop(self.hq).val
        else:
            return heapq.heappop(self.hq)

    def push(self, a):
        if self.desc:
            heapq.heappush(self.hq, Reverse(a))
        else:
            heapq.heappush(self.hq, a)

    def top(self):
        if self.desc:
            return self.hq[0].val
        else:
            return self.hq[0]

    def __len__(self):
        return len(self.hq)


n, m = map(int, input().split(' '))
ab = []
for _ in range(n):
    a, b = map(int, input().split(' '))
    if a > m:
        continue
    ab.append((a, b))
ab.sort(reverse=True)

ans = 0
h = Heapq([], desc=True)
for i in range(1, m+1):
    while ab and ab[-1][0] <= i:
        a, b = ab.pop()
        h.push(b)
    if h:
        ans += h.pop()
print(ans)
N, M = map(int, input().split())
a = list(map(int, input().split()))

from math import gcd, floor
from functools import reduce


def lcm(x, y):
    return x * y // gcd(x, y)


b = [n // 2 for n in a]
lcm_b = reduce(lcm, b)
n = floor((M / lcm_b - 1) / 2) + 1

print(n)


### FIXED CODE ###

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

from math import floor
from fractions import gcd
from functools import reduce


def lcm(x, y):
    return x * y // gcd(x, y)


b = [n // 2 for n in a]

lcm_b = reduce(lcm, b)

for n in b:
    if (lcm_b // n) % 2 == 0:
        print(0)
        exit()

n = floor((M / lcm_b - 1) / 2) + 1

print(n)
import fractions

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

a_c = (a - 1)//c
a_d = (a - 1) // d
a_cd = (a - 1) // (c * d // math.gcd(c, d))

b_c = b // c
b_d = b // d
b_cd = b // (c * d // math.gcd(c, d))

print((b - b_c - b_d + b_cd) - ((a - 1) - a_c - a_d + a_cd))


### FIXED CODE ###

import fractions

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

a_c = (a - 1) // c
a_d = (a - 1) // d
a_cd = (a - 1) // (c * d // fractions.gcd(c, d))

b_c = b // c
b_d = b // d
b_cd = b // (c * d // fractions.gcd(c, d))

print((b - b_c - b_d + b_cd) - ((a - 1) - a_c - a_d + a_cd))
S=input()

ans_lst=[]
ans=0
for s in S:
    if s in ['A','C','G','T']:
        ans+=1
    else:
        ans_lst.append(ans)
        ans=0

print(max(ans_lst))

### FIXED CODE ###

S=input()

ans_lst=[0]*len(S)
l=['A','C','G','T']
if S[0] in l:
    ans_lst[0]=1

for i in range(1,len(S)):
    if S[i] in l:
        ans_lst[i]=ans_lst[i-1]+1

print(max(ans_lst))
import bisect as bi

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

A = sorted([A[i]-i-1 for i in range(N)])

nega_cnt = bi.bisect_left(A, 0)
posi_cnt = N - bi.bisect_right(A, 0)
zero_cnt = N - nega_cnt - posi_cnt


def calc():
    if nega_cnt + zero_cnt >= posi_cnt and posi_cnt + zero_cnt >= nega_cnt:
        return sum([abs(t) for t in A])

    if posi_cnt > nega_cnt + zero_cnt:
        idx = (posi_cnt-(nega_cnt + zero_cnt) - 1) // 2 + 1
        a = A[-posi_cnt:][idx]
        return sum([abs(t-a) for t in A])

    if posi_cnt + zero_cnt < nega_cnt:
        idx = (nega_cnt-(posi_cnt + zero_cnt))//2 + 1
        a = A[:nega_cnt][-idx]
        return sum([abs(t-a) for t in A])


print(calc())


### FIXED CODE ###

import bisect as bi

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

A = sorted([A[i]-i-1 for i in range(N)])

nega_cnt = bi.bisect_left(A, 0)
posi_cnt = N - bi.bisect_right(A, 0)
zero_cnt = N - nega_cnt - posi_cnt


def calc():
    if nega_cnt + zero_cnt >= posi_cnt and posi_cnt + zero_cnt >= nega_cnt:
        return sum([abs(t) for t in A])

    if posi_cnt > nega_cnt + zero_cnt:
        idx = (posi_cnt-(nega_cnt + zero_cnt)) // 2 + 1
        a = A[-posi_cnt:][idx-1]
        return sum([abs(t-a) for t in A])

    if posi_cnt + zero_cnt < nega_cnt:
        idx = (nega_cnt-(posi_cnt + zero_cnt))//2 + 1
        a = A[:nega_cnt][-idx]
        return sum([abs(t-a) for t in A])


print(calc())
D,G = map(int,input().split())
PC = []

L = []

P = [0] * D

t = 10 ** 9
m = 0

for i in range(1,D + 1):
  p,c = map(int,input().split())
  s = 0
  pc = []
  for j in range(p):
    s += i * 100
    if j == p - 1:
      s += c
      L.append([j + 1,s])
    if s >= G and j + 1 < t:
      t = j + 1
    pc.append([j + 1,s])
  PC.append(pc)

def recur(score,times,i,problems):
  if score <= max( [L[i][1] for i in range(D) if P[i] == 0]) and i == 5:
    ans = 10 ** 9
    for j in range(D):
      #使わなかったリストから
      if P[j] == 0:
        #点数のリスト
        for k in range(len(PC[j])):
          #引いた後のスコアを上回る点数のなかから最小値を記録
          if score <= PC[j][k][1] and ans >= PC[j][k][1]:
            ans = PC[j][k][0]
    ans += times
    return ans
  
  elif i == 5:
    return 10 ** 9
  
  else:
    #使う
    ret1 = recur(score - L[i][1],times + L[i][0],i + 1,P[i] + 1)
    #使わない
    ret2 =recur(score,times,i + 1,P[i] + 0)
    
    return min(ret1,ret2)

if t == 10 ** 9:
  print(recur(G,0,0,P))
  
else:
  print(t)

### FIXED CODE ###

D,G = map(int,input().split())
PC = []

L = []

t = 10 ** 9
m = 0

for i in range(1,D + 1):
  p,c = map(int,input().split())
  s = 0
  pc = []
  for j in range(p):
    s += i * 100
    if j == p - 1:
      s += c
      L.append([j + 1,s])
    if s >= G and j + 1 < t:
      t = j + 1
    pc.append([j + 1,s])
  PC.append(pc)

def recur(problems):
  #探索の終了
  if len(problems) == D:
    ans = 10 ** 9
    score = 0
    times = 0
    #全部使用した問題セットの合計点と回答数を記録
    for j in range(D):
      if problems[j] == 1:
        score += L[j][1]
        times += L[j][0]
    #全問全回答の例を除く
    if score >= G:
      ans = min(ans,times)
      return ans
    #残りの数以上となる回答数のうち最小のものが見つかれば更新し
    #全回答の回答数に足す
    else:
      remain = G - score
      if remain <= max([L[i][1] for i in range(D) if problems[i] == 0]):
        for k in range(D):
          if problems[k] == 0:
            for l in range(len(PC[k])):
              if remain <= PC[k][l][1] and ans >= PC[k][l][0]:
                ans = PC[k][l][0]
        ans += times
        return ans
      else:
        return 10 ** 9
  
  else:
    #問題セットを全部使う
    ret1 = recur(problems + [1])
    #使わない
    ret2 = recur(problems + [0])
    
    return min(ret1,ret2)

print(recur([]))
#include <bits/stdc++.h>
using namespace std;

int main()
{

    int h, w;

    cin >> h >> w;

    if(h*w==2) cout << 3 <<endl;
    if(h*w==3) cout << 2 <<endl;
    if(h*w==6) cout << 1 <<endl;
}

### FIXED CODE ###

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

if a*b==2:
    print(3)
elif a*b==3:
    print(2)
else:
    print(1)
=int(input())

print(a*800-200*(a//15))

### FIXED CODE ###

a=int(input())
 
print(a*800-200*(a//15))
a,b=map(float,input().split())
a=int(a)
b=str(b)
b.replace(".","")
x=a*int(b)/100
print(x)

### FIXED CODE ###

A, B = input().split()
A, B = int(A), int(B.replace('.', ''))
print(A * B // 100)
O, K = input().split()
i = O*int(k)
u = K*int(O)
print(sorted([i,u])[0])

### FIXED CODE ###

N, M = input().split()
a = N*int(M)
b = M*int(N)
print(sorted([a,b])[0])
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = [list(map(lambda x: int(x)-1, input().split())) for _ in range(n)]
N = n*(n-1)//2
index = {}
ind = 0
from collections import defaultdict
ns = defaultdict(list)
for i in range(n):
    for j in range(i+1,n):
        index[i,j] = ind
        index[j,i] = ind
        ind += 1
for i in range(n):
    for j in range(n-2):
        u = index[i,a[i][j]]
        v = index[i,a[i][j+1]]
        ns[u].append(v)
### サイクル検出 cycle detection
seen = [False] * N
done = [False] * N
vals = [None] * N
def dfs(u):
    s = [u]
    seen[u] = True
    while s:
        u = s.pop()
        if u>=0:
            s.append(~u)
            for v in ns[u]:
                if done[v]:
                    continue
                elif not seen[v]:
                    seen[v] = True
                    s.append(v)
                else:
                    # 閉路発見
                    return True
        else:
            u = ~u
            done[u] = True
            # ここに帰りがけ処理を書く
            val = 0
            for v in ns[u]:
                val = max(val, vals[v]+1)
            vals[u] = val
    return False

ans = -float("inf")
for u in range(N):
    if seen[u]:
        continue
    pos = dfs(u)
    if pos:
        print(-1)
        break
else:
    raise RuntimeError
    print(max(vals)+1)

### FIXED CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = [list(map(lambda x: int(x)-1, input().split())) for _ in range(n)]
N = n*(n-1)//2
index = {}
ind = 0
from collections import defaultdict
ns = defaultdict(list)
for i in range(n):
    for j in range(i+1,n):
        index[i,j] = ind
        index[j,i] = ind
        ind += 1
for i in range(n):
    for j in range(n-2):
        u = index[i,a[i][j]]
        v = index[i,a[i][j+1]]
        ns[u].append(v)
### サイクル検出 cycle detection
seen = [False] * N
done = [False] * N
vals = [None] * N
def dfs(u):
    # uからdfs
    seen[u] = True
    ans = 0
    for v in ns[u]:
        if done[v]:
            ans = max(ans, vals[v]+1)
            continue
        elif seen[v]:
            # サイクルを検出
            return 1
        else:
            pos = dfs(v)
            if pos>=0:
                return 1
            ans = max(ans, vals[v]+1)
    done[u] = True
    vals[u] = ans
    return -1
ans = -float("inf")
for u in range(N):
    if seen[u]:
        continue
    pos = dfs(u)
    if pos>=0:
        print(-1)
        break
else:
    print(max(vals)+1)
n = int(input())
S = map(int, input().split())
q = int(input())
T = map(int, input().split())
print(len(S & T)

### FIXED CODE ###

n = int(input())
S = set(map(int, input().split()))
q = int(input())
T = set(map(int, input().split()))
print(len(S & T))
a,b,c = input().split()

if(a + b + c) != 17:
  print("NO")
elif(a + b + c) = 17:
    if(a + b == 10) || (b + c == 10) || (c + a == 10):
      print("YES")
    else:
      print("NO")
else:
  print("NO")

### FIXED CODE ###

a,b,c = input().split()
 
a = int(a)
b = int(b)
c = int(c)
 
 
if(a + b + c) != 17:
  print("NO")
elif(a + b + c) == 17:
    if(a + b == 10) | (b + c == 10) | (c + a == 10):
      print("YES")
    else:
      print("NO")
else:
  print("NO")
import time
import numpy as np

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

time1=time.time()


S=[0]*(N+1)
for i in range(N):
    S[i+1]=(A[i]+S[i])%M


def tr(k):
    return k*(k-1)//2

time2=time.time()
countlist=np.zeros(M)
check=set()

time3=time.time()

for i in range(1,N+1):
    countlist[S[i]]+=1
    check=check|{S[i]}
    
    

time4=time.time()



ANS=countlist[0]

for i in check:
    ANS+=tr(countlist[i])



print(int(ANS))






### FIXED CODE ###

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

S=[0]*(N+1)
for i in range(N):
    S[i+1]=(A[i]+S[i])%M


def tr(k):
    return k*(k-1)//2


countlist=dict()
check=set()


for i in range(1,N+1):
    countlist[S[i]]=countlist.get(S[i],0)+1

    
    


ANS=countlist.get(0,0)

for i in countlist.keys():
    ANS+=tr(countlist[i])



print(ANS)
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]

XY.sort(key=lambda x: x[0])

PQ = {}

for i in range(N):
    x0, y0 = XY[i]
    for j in range(N):
        if i == j:
            continue
        x1, y1 = XY[j]
        p, q = x0 - x1, y0 - y1
        key = str(p) + ',' + str(q)
        if key in PQ:
            PQ[key] += 1
        else:
            PQ[key] = 1
ansL = PQ.values()
print(N - max(list(ansL)))


### FIXED CODE ###

N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
if N == 1:
    print(1)
    exit()

XY.sort(key=lambda x: x[0])

PQ = {}

for i in range(N):
    x0, y0 = XY[i]
    for j in range(N):
        if i == j:
            continue
        x1, y1 = XY[j]
        p, q = x0 - x1, y0 - y1
        key = str(p) + ',' + str(q)
        if key in PQ:
            PQ[key] += 1
        else:
            PQ[key] = 1
ansL = PQ.values()
print(N - max(list(ansL)))