Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N = int(input())
nums = []
for i in range(N):
    A = int(input())
    if A in nums:
        nums.remove(A)
    else:
        nums.append(A)

print(len(nums))


### FIXED CODE ###

N = int(input())
nums = {}
for i in range(N):
    A = int(input())
    nums.setdefault(A, 0)
    nums[A] += 1

result = 0
for k, v in nums.items():
    if v % 2 != 0:
        result += 1

print(result)
### BUGGY CODE ###

from collections import defaultdict
n = int(input())
s = input()

dp = [defaultdict(int), defaultdict(int)]

dp[0][""] = 1
for i in range(n):
    dp[(i + 1) % 2] = defaultdict(int)
    for j in dp[i % 2]:
        dp[(i + 1) % 2][j] = dp[i % 2][j]
        if len(j) < 3:
            dp[(i + 1) % 2][j + s[i]] += dp[i % 2][j]

ans = 0
for j in dp[n % 2]:
    if len(j) == 3:
        # print(j)
        ans += 1

print(ans)


### FIXED CODE ###

n = int(input())
s = input()

dp = [set(), set()]

dp[0].add("")
for i in range(n):
    dp[(i + 1) % 2] = dp[i % 2].copy()
    i1 = (i + 1) % 2
    i0 = (i + 0) % 2
    for j in dp[i0]:
        if len(j) < 3:
            dp[i1].add(j + s[i])

ans = 0
for j in dp[n % 2]:
    if len(j) == 3:
        # print(j)
        ans += 1

print(ans)
### BUGGY CODE ###

from collections import OrderedDict
N, M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(M)]
IDs = OrderedDict()
result = [None] * M
for i, (p, y) in enumerate(L):
    if p not in IDs:
        IDs[p] = OrderedDict()
    IDs[p][y] = i
P = sorted(IDs.keys())
for p in P:
    Y = sorted(IDs[p].keys())
    for i, y in enumerate(Y):
        result[IDs[p][y]] = "{:06}{:06}".format(p, i + 1)
for r in result:
    print(r)


### FIXED CODE ###

N, M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(M)]
Y = sorted([(i, (p, y)) for i, (p, y) in enumerate(L)], key=lambda x: x[1])
result = [""] * M
x = 0
before_p = 0
for i, (p, y) in Y:
    if before_p != p:
        x = 0
        before_p = p
    x += 1
    result[i] = "{:06}{:06}".format(p, x)
for r in result:
    print(r)
### BUGGY CODE ###

from functools import reduce
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))


lcm = A[0]
for i in range(1, N):
    lcm = lcm * A[i] // gcd(lcm, A[i])

MOD = 10 ** 9 + 7
ans = 0
for a in A:
    ans += lcm * pow(a, MOD-2, MOD)
    ans %= MOD

print(ans)


### FIXED CODE ###

from functools import reduce
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))


lcm = A[0]
for a in A[1:]:
    lcm = lcm * a // gcd(lcm, a)


MOD = 10 ** 9 + 7
lcm %= MOD
ans = 0
for a in A:
    ans += lcm * pow(a, MOD-2, MOD)
    ans %= MOD

print(ans)
### BUGGY CODE ###

mod = 10**9 + 7
n = int(input())
A = [int(i) for i in input().split()]
for i in range(1,n+1):
	l = 0
	if A.count(i) > 1:
		l = i
		p = []
		for j in range(n+1):
			if A[j] == l:
				p.append(j)
		break
	if l:
		break

t = 1
d = 1
for k in range(n+1):

	t *= (n+1-k)*pow(k+1,mod-2,mod)#n+1Ck
	if not k:
		print(n)
	elif k <= n+p[0]-p[1]:
		d *= (n+p[0]-p[1]-k+1)*pow(k,mod-2,mod)
		print((t - d)%mod)
	else:
		print(t%mod)



### FIXED CODE ###

from collections import Counter
mod = 10**9 + 7
n = int(input())
A = [int(i) for i in input().split()]
C = Counter(A)
l = 0
for i in range(1,n+1):
	if C[i] > 1:
		l = i
		p = []
		for j in range(n+1):
			if A[j] == l:
				p.append(j)
				if len(p) > 1:
					break
		break
	if l:
		break

t = 1
d = 1
for k in range(n+1):

	t *= (n+1-k)%mod
	t %= mod
	t *= pow(k+1,mod-2,mod)
	t %= mod
	if not k:
		print(n)
	elif k <= n+p[0]-p[1]:
		d *= (n+p[0]-p[1]-k+1)%mod
		d %= mod
		d *= pow(k,mod-2,mod)
		d %= mod
		print((t - d)%mod)
	else:
		print(t%mod)
### BUGGY CODE ###

from sys import stdin


def readline_from_stdin() -> str:
    return stdin.readline().rstrip


if __name__ == '__main__':
    N, K, = input().split()
    A = [int(i) for i in input().split()]
    N, K = int(N), int(K)

    score = 1
    for i in range(K):
        score *= A[i]

    # scores = [score]
    # for i in range(N-K):
    #     print(i, K+i)
    #     score = int(score / A[i]) * A[K+i]
    #     scores.append(score)
    #
    # print(scores)
    #
    # results = [False for i in range(len(scores)-1)]
    #
    # for i in range(len(scores)-1):
    #     results[i] = scores[i+1] > scores[i]
    #
    # [print("Yes") if r else print("no") for r in results]

    for i in range(N-K):
        new_score = int(score / A[i]) * A[K+i]
        if new_score > score:
            print("Yes")
        else:
            print("No")
        score = new_score


### FIXED CODE ###

from sys import stdin


def readline_from_stdin() -> str:
    return stdin.readline().rstrip


if __name__ == '__main__':
    N, K, = input().split()
    A = [int(i) for i in input().split()]
    N, K = int(N), int(K)

    for i in range(N-K):
        if A[i] < A[K+i]:
            print("Yes")
        else:
            print("No")
### BUGGY CODE ###

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = sorted(map(int, input().split()), reverse=True)

AB = [0]*(X*Y)
i = 0
for a in A:
  for b in B:
    AB[i] = a+b
    i += 1
AB.sort(reverse = True)

ans = [0]*(K*Z)
j = 0
for ab in AB[:K]:
  for c in C:
    ans[j] = ab+c
    j += 1

ans.sort(reverse=True)
print(*ans[:K], sep="\n")

### FIXED CODE ###

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = sorted(map(int, input().split()), reverse=True)

AB = []
for a in A:
  for b in B:
    AB.append(a+b)
AB.sort(reverse = True)

ans = []
for ab in AB[:K]:
  for c in C:
    ans.append(ab+c)

ans.sort(reverse=True)
print(*ans[:K], sep="\n")
### BUGGY CODE ###

N, M = map(int, input().split())
A=[0]*N
B=[0]*N
for i in range(N):
    A[i], B[i] = map(int, input().split())

dy = 0
ans = 0
total_dy = 0
cnt = 0
while total_dy <= M:
    for i, x in enumerate(B):
        if x == max(B):
            if cnt == 0:
                tmp_max_idx = i
                cnt += 1
            elif cnt > 0 and A[tmp_max_idx] < A[i]:
                tmp_max_idx = i
    cnt = 0
    tmp_max = max(B)
    if A[tmp_max_idx]+dy <= M:
        ans += tmp_max
        total_dy = A[tmp_max_idx] + dy
        dy += 1

    A.pop(tmp_max_idx)
    B.pop(tmp_max_idx)
    tmp_max_idx = 0
    if A == [] or B ==[]:
        break

print(ans)

### FIXED CODE ###

from operator import itemgetter
import heapq

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

AB.sort(key=itemgetter(0))
q = []
idx = 0
ans = 0

for i in range(1, M+1):
    while idx < N:
        a, b = AB[idx]
        if a <= i:
            heapq.heappush(q, -b)
            idx += 1
        else:
            break
    if len(q)>0:
        b = heapq.heappop(q)
        ans -= b
print(ans)
### BUGGY CODE ###

import math
from heapq import heappush, heappop
import sys
input = sys.stdin.readline

def dijkstra(graph: list, node: int, start: int) -> list:
    # graph[node] = [(cost, to)]
    inf = 3 * 10 ** 9
    dist = [inf] * node

    dist[start] = 0
    heap = [(0, start)]
    while heap:
        cost, thisNode = heappop(heap)
        for NextCost, NextNode in graph[thisNode]:
            dist_cand = dist[thisNode] + NextCost
            if dist_cand < dist[NextNode]:
                dist[NextNode] = dist_cand
                heappush(heap,(dist[NextNode], NextNode))
    return dist
    # dist = [costs to nodes]

xs, ys, xt, yt = map(int, input().split())
n = int(input())
circles = [(xs, ys, 0), (xt, yt, 0)]
for i in range(n):
    circles.append(tuple(map(int, input().split())))
n += 2

edges = [[] for i in range(n)]
for i in range(n):
    for j in range(i+1, n):
        dist = math.sqrt((circles[i][0] - circles[j][0]) ** 2 + (circles[i][1] - circles[j][1]) ** 2)
        cost = max(0, dist - circles[i][2] - circles[j][2])
        edges[i].append((cost, j))
        edges[j].append((cost, i))


dist = dijkstra(edges, n, 0)

print(dist[1])


### FIXED CODE ###

import sys
input = sys.stdin.readline

def dijkstra(edge_adj: list, node: int, start: int) -> list:
    # graph[node] = [(cost, to)]
    inf = 3 * 10 ** 9
    dist = [inf] * node
    used = [False] * node

    dist[start] = 0
    while True:
        v = -1
        for i in range(node):
            if not used[i] and (v == -1 or dist[v] > dist[i]):
                v = i

        if v == -1:
            break

        used[v] = True
        for i in range(node):
            if dist[i] > dist[v] + edge_adj[v][i]:
                dist[i] = dist[v] + edge_adj[v][i]

    return dist
    # dist = [costs to nodes]

xs, ys, xt, yt = map(int, input().split())
n = int(input())
circles = [(xs, ys, 0), (xt, yt, 0)]
for i in range(n):
    circles.append(tuple(map(int, input().split())))
n += 2

edges = [[0] * n for i in range(n)]
for i in range(n):
    for j in range(i+1, n):
        dist = ((circles[i][0] - circles[j][0]) ** 2 + (circles[i][1] - circles[j][1]) ** 2) ** 0.5
        cost = max(0, dist - circles[i][2] - circles[j][2])
        edges[i][j] = cost
        edges[j][i] = cost


dist = dijkstra(edges, n, 0)

print(dist[1])
### BUGGY CODE ###

def main():
    N, Q = map( int, input().split())
    C = list( map( int, input().split()))
    LRI = []
    for i in range(Q):
        l, r = map( int, input().split())
        LRI.append((r,l,i))
    LRI.sort(key=lambda x:x[0])
    lastAppend = [-1]*(N+1)
    BIT = [0]*(N+1)
    #A1 ~ Aiまでの和 O(logN)
    def BIT_query(idx):
        res_sum = 0
        if idx == 0:
            return 0
        while idx > 0:
            res_sum += BIT[idx]
            idx -= idx&(-idx)
        return res_sum

    #Ai += x O(logN)
    def BIT_update(idx,x):
        while idx <= N:
            BIT[idx] += x
            idx += idx&(-idx)
        return

    ANS = [0]*Q
    now = 1
    for r, l, i in LRI:
        while now <= r:
            c = C[now-1]
            if lastAppend[c] == -1:
                BIT_update(now, 1)
            else:
                BIT_update( now, 1)
                BIT_update(lastAppend[c],-1)
            lastAppend[c] = now                
            now += 1
        ANS[i] = BIT_query(r) - BIT_query(l-1)
    print( "\n".join( map( str, ANS)))
    
    

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N, Q = map( int, input().split())
    C = list( map( int, input().split()))
    LRI = []
    for i in range(Q):
        l, r = map( int, input().split())
        LRI.append((r,l,i))
    LRI.sort(key=lambda x:x[0])
    lastAppend = [-1]*(N+1)
    BIT = [0]*(N+1)
    #A1 ~ Aiまでの和 O(logN)
    def BIT_query(idx):
        res_sum = 0
        if idx == 0:
            return 0
        while idx > 0:
            res_sum += BIT[idx]
            idx -= idx&(-idx)
        return res_sum

    #Ai += x O(logN)
    def BIT_update(idx,x):
        while idx <= N:
            BIT[idx] += x
            idx += idx&(-idx)
        return

    ANS = [0]*Q
    now = 1
    for r, l, i in LRI:
        while now <= r:
            c = C[now-1]
            if lastAppend[c] == -1:
                BIT_update(now, 1)
            else:
                BIT_update( now, 1)
                BIT_update(lastAppend[c],-1)
            lastAppend[c] = now                
            now += 1
        ANS[i] = BIT_query(r) - BIT_query(l-1)
    print( "\n".join( map( str, ANS)))
    
    

if __name__ == '__main__':
    main()
### BUGGY CODE ###

import numpy as np
n = int(input())
v = list(map(int,input().split()))

v = np.array(v)

if len(np.unique(v)) == 1:
    print(int(len(v)/2))
else:
    vodd = v[np.arange(0,len(v),2)]
    vodd_unique = np.unique(vodd)
    d_odd = []
    odd_lis = []
    for vu in vodd_unique:
        d_odd.append(sum(vodd == vu))
        odd_lis.append(vu)

    veven = v[np.arange(1,len(v),2)]
    veven_unique = np.unique(veven)
    d_even = []
    even_lis = []
    for vu in veven_unique:
        d_even.append(sum(veven == vu))
        even_lis.append(vu)

    if even_lis[np.argmax(d_even)] != odd_lis[np.argmax(d_odd)]:
        score = np.max(d_even) + np.max(d_odd)
    else:
        score1 = even_lis[np.argsort(d_even)[-1]] + odd_lis[np.argsort(d_odd)[-2]]
        score2 = even_lis[np.argsort(d_even)[-2]] + odd_lis[np.argsort(d_odd)[-1]]
        score = max(score1,score2)
    print(len(v) - score)

### FIXED CODE ###

from collections import Counter
import numpy as np
n = int(input())
v = list(map(int,input().split()))

# v = [1, 1] * 5
# v += [2, 2] * 4
v = np.array(v)

if len(np.unique(v)) == 1:
    print(int(len(v)/2))
else:
    vodd = v[np.arange(0,len(v),2)]
    odd_count = Counter(vodd)

    veven = v[np.arange(1,len(v),2)]
    even_count = Counter(veven)
    

    d_odd = []
    odd_lis = list(odd_count.keys())
    for key in odd_count.keys():
        d_odd.append(odd_count[key])

    d_even = []
    even_lis = list(even_count.keys())
    for key in even_count.keys():
        d_even.append(even_count[key])

    
    if even_lis[np.argmax(d_even)] != odd_lis[np.argmax(d_odd)]:
        score = np.max(d_even) + np.max(d_odd)
    else:
#         print('a')
        score1 = d_even[np.argsort(d_even)[-1]] + d_odd[np.argsort(d_odd)[-2]]
        score2 = d_even[np.argsort(d_even)[-2]] + d_odd[np.argsort(d_odd)[-1]]
        score = max(score1,score2)
    print(len(v) - score)
### BUGGY CODE ###

n,w=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
dp=[[0 for _ in range(w+1)] for _ in range(n+1)]

for i in range(1,n+1):
  for j in range(w+1):
    if j-a[i-1][0]>=0:
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i-1][0]]+a[i-1][1])
    else:
      dp[i][j]=dp[i-1][j]
    
print(dp[n][w])

### FIXED CODE ###

n,w=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
dp=[[0 for _ in range(w+1)] for _ in range(n+1)]

for i in range(1,n+1):
  for j in range(w+1):
    if j-a[i-1][0]>=0:
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i-1][0]]+a[i-1][1])
    else:
      dp[i][j]=dp[i-1][j]
    
print(dp[n][w])
### BUGGY CODE ###


import sys
sys.setrecursionlimit(1000000)

def inc(tree, point, p, x):
    # 自分
    point[p] += x
    if tree[p] == -1:
        return

    for child in tree[p]:
        inc(tree, point, child, x)


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

tree = [-1] * (N+1)
point = [0] * (N+1)

for i in range(N-1):
    a, b = map(int, input().split())
    if tree[a] == -1:
        tree[a] = [b]
    else:
        tree[a] += [b]

for i in range(Q):
    p, x = map(int, input().split())

    inc(tree, point, p, x)

point.pop(0)
print(*point)

### FIXED CODE ###


import sys
input = sys.stdin.readline #for input speed
sys.setrecursionlimit(10**6) #for deep recursion
n, q = map(int, input().split())

tree_index = [[] for _ in range(n)]
for i in range(n-1):
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  tree_index[a].append(b) # a<bとは限らないため、双方向にする
  tree_index[b].append(a)

#print(tree_index)


ans = [0] * n
for i in range(q):
  p, x = map(int, input().split())
  ans[p-1] += x

def dfs(cur, par):
    for chl in tree_index[cur]:
      if chl == par: #parentとchildが等しい時はスキップ
        continue
      ans[chl] += ans[cur]
      dfs(chl, cur)
dfs(0, -1)
print(*ans)
### BUGGY CODE ###

#https://atcoder.jp/contests/agc033/tasks/agc033_a

HW = [int(i) for i in input().split()]
A = []
for i in range(HW[0]):
    A.append(list(str(input())))

B = []
for i in range(len(A)):
    B.append([])
    for j in range(len(A[i])):
        B[i].append(A[i][j])

count = 0
count2 = 0
while True:
    for i in range(len(A)):
        for j in range(len(A[i])):
            if A[i][j] == '.':
                if i < len(A) - 1 and A[i+1][j] == '#':
                    B[i][j] = '#'
                if i > 0 and A[i-1][j] == '#':
                    B[i][j] = '#'
                if j < len(A[i]) - 1 and A[i][j+1] == '#':
                    B[i][j] = '#'
                if j > 0 and A[i][j-1] == '#':
                    B[i][j] = '#'
            else:
                count += 1
    
    for i in range(len(A)):
        for j in range(len(A[i])):
            A[i][j] = B[i][j]
    if count == HW[0] * HW[1]:
        break
    else:
        count = 0
        count2 += 1

print(count2)

### FIXED CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

h, w = MAP()
a = [STR() for _ in range(h)]
b = [[inf for _ in range(w)] for _ in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            b[i][j] = 0
        else:
            for k in range(4):
                ny = i + dy[k]
                nx = j + dx[k]
                if 0 <= ny < h and 0 <= nx < w:
                    b[i][j] = min(b[ny][nx] + 1, b[i][j])
for i in reversed(range(h)):
    for j in reversed(range(w)):
        if a[i][j] == '#':
            b[i][j] = 0
        else:
            for k in range(4):
                ny = i + dy[k]
                nx = j + dx[k]
                if 0 <= ny < h and 0 <= nx < w:
                    b[i][j] = min(b[ny][nx] + 1, b[i][j])
ans = 0
for i in range(h):
    ans = max(ans, max(b[i]))
print(ans)
### BUGGY CODE ###

import collections
n=int(input())
a=list(map(int,input().split()))
b = collections.Counter(a)
total = 0

for i in b.values():
  total += i*(i-1)//2
  
for i in range(n):
  to = a.count(a[i])-1
  print(total-(to*(to+1)//2)+(to*(to-1)//2))
  
  
 

### FIXED CODE ###

import collections
n=int(input())
a=list(map(int,input().split()))
b = collections.Counter(a)
total = 0

for i in b.values():
  total += i*(i-1)//2
  
for i in a:
  c = b[i]
  print(total-(c*(c-1)//2)+((c-1)*(c-2)//2))
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
A.sort()
res = 0
Ab = [True] * N
cnt = 0
for i in range(N):
    if not Ab[i]:
        continue
    for j in range(i+1,N):
        if Ab[j] :
            if A[j] % A[i] == 0:
                 Ab[j] = False
                 if A[i] == A[j]:
                    Ab[i] = False
print(Ab.count(True))



### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)

A = set(A)
MAX_A = 10 ** 6
X = [0] * (MAX_A + 1)
for a in A:
    for i in range(a, MAX_A + 1, a):
        X[i] += 1

ans = len([a for a in A if (X[a] == 1) and (C[a] == 1)])
print(ans)
### BUGGY CODE ###


import sys


def max_sum_seq(lis):
    m = 0
    l = len(lis)
    for n in range(1, l+1):
        for s in every_slice(lis, n):
            sm = sum(s)
            if sm > m:
                m = sm
    return m

def every_slice(lis, n):
    l = len(lis)
    for i in range(l-n+1):
        yield lis[i:i+n]


while True:
    n = int(sys.stdin.readline())
    if n == 0:
        break
    lis = []
    for i in range(n):
        lis.append(int(sys.stdin.readline()))
    print max_sum_seq(lis)

### FIXED CODE ###


import sys


def max_sum_seq(lis):
    m = 0
    lis = compress(lis)
    l = len(lis)

    max_val = lis[0]
    for i in xrange(0, l):
        for j in xrange(i, l):
            if j == i:
                tmp_val = lis[j]
            else:
                tmp_val = tmp_val + lis[j]
            max_val = max(max_val, tmp_val)
    return max_val

def compress(tmp_lst):
    lim = len(tmp_lst)
    lst = []
    index = 0
    while index < lim:
        tmp = tmp_lst[index]
        index += 1
        while tmp > 0 and index < lim and tmp * tmp_lst[index] > 0:
            tmp += tmp_lst[index]
            index += 1
        lst.append(tmp)
    return lst


while True:
    n = int(sys.stdin.readline())
    if n == 0:
        break
    lis = []
    for i in range(n):
        lis.append(int(sys.stdin.readline()))
    print max_sum_seq(lis)
### BUGGY CODE ###

# 1-index
from sys import stdin
H, N = [int(x) for x in stdin.readline().rstrip().split()]

data = [0]*N

for i in range(N):
    A, B = [int(x) for x in stdin.readline().rstrip().split()]
    data[i] = (A, B)
dp = [10**9]*(H+1)
dp[0] = 0

for h in range(0,H+1):
    for a,b in data:
        if h+a >= H:
            dp[H] = min(dp[h]+b,dp[H])
        else:
            dp[h+a] = min(dp[h]+b,dp[h+a])
print(dp[H])

### FIXED CODE ###

# 1-index
from sys import stdin
H, N = [int(x) for x in stdin.readline().rstrip().split()]

data = [0]*N

for i in range(N):
    A, B = [int(x) for x in stdin.readline().rstrip().split()]
    data[i] = (A, B)
dp = [10**9]*(H+1)
dp[0] = 0

for h in range(0,H+1):
    for a,b in data:
        if h+a >= H:
            dp[H] = min(dp[h]+b,dp[H])
        else:
            dp[h+a] = min(dp[h]+b,dp[h+a])
print(dp[H])
### BUGGY CODE ###

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

result=[list(input().split()) for i in range(M)]
nums=[]
jud=[]
for i in range(M):
  nums.append(result[i][0])
  jud.append(result[i][1])
  
WAs={nums[i]: 0 for i in range(M)}
ACs=[]

AC=0
pena=0

for i in range(M):
  if nums[i] in ACs:
    continue
  else:
    if jud[i]=="WA":
      WAs[nums[i]]+=1
    else:
      AC+=1
      ACs.append(nums[i])
      pena+=WAs[nums[i]]
      
print(AC, pena)
        

### FIXED CODE ###

N, M=map(int, input().split())
import numpy as np

pena=np.array([0]*N)
status=np.array([0]*N)


for i in range(M):
  p,s=tuple(input().split())
  p=int(p)
  if s=="WA":
    if status[p-1]!=1:
      pena[p-1]+=1
  if s=="AC":
    if status[p-1]!=1:
      status[p-1]=1
nac=sum(status)
npena=sum(pena*status)
print(nac, npena)
### BUGGY CODE ###

K,S = (int(x) for x in input().split())
count = 0

for x in range(K+1):
    if x > S:
        break
    for y in range(K+1):
        if x + y > S:
            break
        for z in range(K+1):
            #print(x,y,z)
            if x + y + z == S:
                count += 1
                #print(x,y,z)


print(count)

### FIXED CODE ###

K,S = (int(x) for x in input().split())
count = 0

for x in range(K+1):
    if x > S:
        break
    for y in range(K+1):
        z = S - x - y
        if 0 <= z <= K:
            count += 1
        elif x + y > S:
            break


print(count)
### BUGGY CODE ###

N = int(input())
S = input()
L = list(S)
first = [L.index(str(i)) if str(i) in S else None for i in range(10)]
con = 0

for n in range(0,1000):
  c = str(n)
  c = "0" * (3 - len(c)) + c
  m = int(c[0])
  y = int(c[1])
  z = int(c[2])
  if ((first[m] != None) and (first[y] != None) and (first[z] != None) ) and first[m] < N - 1:
    i = first[m]
    for j in range(i + 1,len(S) - 1):
        if S[j] == c[1] and c[2] in S[j + 1:]:
          con += 1
          break

print(con)

### FIXED CODE ###

N = int(input())
S = input()
con = 0

for i in range(10):
  if str(i) in S:
    p = S.index(str(i))
    S2 = S[p + 1:]
    for j in range(10):
      if str(j) in S2:
        q = S2.index(str(j))
        S3 = S2[q + 1:]
        for k in range(10):
          if str(k) in S3:
            con += 1

print(con)
### BUGGY CODE ###

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

sa=float("inf")

for i in range(n-1):
  wa1=sum(a[0:1+i])
  wa2=sum(a[1+i:])
  temp=abs(wa1-wa2)
  sa=min(sa,temp)
print(sa)

### FIXED CODE ###

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

sa=float("inf")


wa1=0
wa2=sum(a)

for i in range(n-1):
  wa1+=a[i]
  wa2-=a[i]
  temp=abs(wa1-wa2)
  sa=min(sa,temp)
print(sa)