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

from itertools import permutations
N, M, R = map(int, input().split())
r = [int(i) - 1 for i in input().split()]
d = [[float('inf')] * N for j in range(N)]
for i in range(M):
    A, B, C = map(int, input().split())
    d[A-1][B-1] = min(d[A-1][B-1], C)
    d[B-1][A-1] = min(d[A-1][B-1], C)
for k in range(N):
    for s in range(N):
        for e in range(N):
            d[s][e] = min(d[s][e], d[s][k] + d[k][e])
l = True
for o in permutations(r):
    tmp_l = 0
    for s, e in zip(o[:-1], o[1:]):
        tmp_l = tmp_l + d[s][e]
    if l is True:
        l = tmp_l
    else:
        l = min(l, tmp_l)
print(l)

### FIXED CODE ###

from itertools import permutations
N, M, R = map(int, input().split())
r = [int(i) - 1 for i in input().split()]
d = [[10000000 for i in range(N)] for j in range(N)]
for i in range(M):
    A, B, C = map(int, input().split())
    d[A-1][B-1] = min(d[A-1][B-1], C)
    d[B-1][A-1] = min(d[A-1][B-1], C)
for k in range(N):
    for s in range(N):
        for e in range(N):
            d[s][e] = min(d[s][e], d[s][k] + d[k][e])
l = True
for o in permutations(r):
    tmp_l = 0
    for s, e in zip(o[:-1], o[1:]):
        tmp_l = tmp_l + d[s][e]
    if l is True:
        l = tmp_l
    else:
        l = min(l, tmp_l)
print(l)
### BUGGY CODE ###

from collections import deque

n = int(input())
ab = [(0, 0) for _ in range(n)]

for i in range(n):
    ab[i] = tuple(map(int, input().split()))
    
def mergesort(ab, l, r):
    if r - l == 1:
        return [ab[l]]
    m = (l + r) // 2
    ab1 = mergesort(ab, l, m)
    ab2 = mergesort(ab, m, r)
    res = []
    i1, i2 = 0, 0
    while i1 < len(ab1) or i2 < len(ab2):
        if i1 == len(ab1):
            res.append(ab2[i2])
            i2 += 1
        elif i2 == len(ab2):
            res.append(ab1[i1])
            i1 += 1
        else:
            if ab1[i1][1] <= ab2[i2][1]:
                res.append(ab1[i1])
                i1 += 1
            else:
                res.append(ab2[i2])
                i2 += 1
    return res
    
sorted_ab = mergesort(ab, 0, n)

now = 0
flag = True
for task in sorted_ab:
    now += task[0]
    if now > task[1]:
        print('No')
        flag = False
        break

if flag:
    print('Yes')


### FIXED CODE ###

from collections import deque

n = int(input())
ab = [(0, 0) for _ in range(n)]

for i in range(n):
    ab[i] = tuple(map(int, input().split()))
    
def mergesort(ab, l, r):
    if r - l == 1:
        return [ab[l]]
    m = (l + r) // 2
    ab1 = mergesort(ab, l, m)
    ab2 = mergesort(ab, m, r)
    res = []
    i1, i2 = 0, 0
    while i1 < len(ab1) or i2 < len(ab2):
        if i1 == len(ab1):
            res.append(ab2[i2])
            i2 += 1
        elif i2 == len(ab2):
            res.append(ab1[i1])
            i1 += 1
        else:
            if ab1[i1][1] <= ab2[i2][1]:
                res.append(ab1[i1])
                i1 += 1
            else:
                res.append(ab2[i2])
                i2 += 1
    return res
    
sorted_ab = mergesort(ab, 0, n)

now = 0
flag = True
for task in sorted_ab:
    now += task[0]
    if now > task[1]:
        print('No')
        flag = False
        break

if flag:
    print('Yes')
### BUGGY CODE ###

n, q = list(map(int, input().split()))
s = input()
lr = []
for i in range(q):
  lr.append(list(map(int, input().split())))

for i in range(q):
  str_a = s[(lr[i][0] - 1):(lr[i][1])].replace('AC', '+')
  print(str_a.count('+'))

### FIXED CODE ###

n, q = list(map(int, input().split()))
s = input()
cnt = 0
word_list = []
for i in range(n):
  if i > 0:
    if(s[i - 1] == 'A') and (s[i] == 'C') : cnt += 1 
  word_list.append(cnt)
for i in range(q):
  l, r = list(map(int, input().split()))
  print(word_list[r - 1] - word_list[l - 1])
### BUGGY CODE ###

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

tmp = 1
import sys

for i in range(N):
    tmp *= A[i]
if tmp > 10**18:
    print(-1)
else:
    print(tmp)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
import sys
tmp = 1
A.sort(reverse = True)
if 0 in A:
    print(0)
else:
    for i in range(N):
        tmp *= A[i]
        if tmp > 10**18:
            print(-1)
            sys.exit()
    print(tmp)
### BUGGY CODE ###

import numpy as np
N=int(input())
x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

x=np.array(x)
y=np.array(y)
z=np.vstack((x,y))
zz=np.argsort(z[1,:])[::-1]
z=z[:,zz]

left=z[1,0]
flag='Yes'
for i in range(N):
  if min(left,z[1,i])<z[0,i:].sum():
    flag='No'
    break
  else:
    left=z[1,i]-z[0,i]
print(flag)

### FIXED CODE ###

import numpy as np
N=int(input())
x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

x=np.array(x)
y=np.array(y)
z=np.vstack((x,y))
zz=np.argsort(z[1,:])[::-1]
z=z[:,zz]

left=z[1,0]
flag='Yes'
sumarray=np.cumsum(z[0][::-1])[::-1]
for i in range(N):
  
  if min(left,z[1,i])<sumarray[i]:
    flag='No'
    break
  else:
    left=z[1,i]-z[0,i]
print(flag)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

def rec(i, j, k):
    global dp
    #print(i, j, k)
    if dp[i][j][k] < float("inf"):
        return dp[i][j][k]
    if i+j+k == 0:
        return 0

    num = float(i+j+k)
    ans = float(N) / num
    if i > 0:
        ans += (rec(i-1, j, k) * i) / num
    if j > 0:
        ans += (rec(i+1, j-1, k) * j) / num
    if k > 0:
        ans += (rec(i, j+1, k-1) * k) / num
    dp[i][j][k] = ans
    return ans

N = ii()
A = li()

dp = dp3(float("inf"), N+1, N+1, N+1)
dp[0][0][0] = 0
cnt = [0, 0, 0]

for a in A:
    cnt[a-1] += 1

print(rec(cnt[0], cnt[1], cnt[2]))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

N = ii()
N_f = float(N)
A = li()

cnt = [0, 0, 0]
for a in A:
    cnt[a-1] += 1

#dp = dp3(-1.0, cnt[2]+1, cnt[1]+cnt[2]+1, N+1)
dp = dp3(0.0, N+1, N+1, N+1)
#dp = dp3(0.0, 301, 301, 301)
dp[0][0][0] = 0

for k in range(cnt[2]+1):
#for i in range(N+1):
    for j in range(cnt[1]+cnt[2]+1-k):
    #for j in range(N+1):
        #for k in range(cnt[2]+1):
        #for k in range(N+1):
        for i in range(N+1-j-k):
            #print(i, j, k)
            if i+j+k == 0:
                continue
            num = i+j+k
            dp[i][j][k] = N_f
            if i > 0:
                dp[i][j][k] += dp[i-1][j][k] * i
            if j > 0:
                dp[i][j][k] += dp[i+1][j-1][k] * j
            if k > 0:
                dp[i][j][k] += dp[i][j+1][k-1] * k
            dp[i][j][k] /= num

print(dp[cnt[0]][cnt[1]][cnt[2]])
### BUGGY CODE ###

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

ans = 0

for i in range(0, n-k+1):
    x = 0
    for j in range(k):
        x += (p[i+j] + 1)/2
    ans = max(ans, x)
print(ans)

### FIXED CODE ###

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

x = sum(p[0:k])
ans_i = 0
ans_max = x
ans = 0

for i in range(1, n-k+1):
    x = x - p[i-1] + p[i+k-1]
    if x > ans_max:
        ans_max = x
        ans_i = i
        
for j in range(ans_i, ans_i+k):
    ans += (p[j]+1)/2
print(ans)
### BUGGY CODE ###

a,aa=map(int,input().split())
b=list(map(int,input().split()))
c=[0]*a
c[0]=0
for i in range(1,a):
  c[i] = min(c[j] + abs(b[i] - b[j]) for j in range(max(0,i-aa),i))
print(c[-1])

### FIXED CODE ###

def solve():
  a,aa=map(int,input().split())
  b=list(map(int,input().split()))
  c=[0]*a
  c[0]=0
  for i in range(1,a):
    c[i] = min(c[j] + abs(b[i] - b[j]) for j in range(max(0,i-aa),i))
  print(c[-1])
  
solve()
### BUGGY CODE ###

N = int(input())
S = input()

p = 10**6
q = [0]*N
for i in range(N):
    Sl = S[:i] if i > 0 else "0"
    Sr = S[i+1:] if i < N-1 else "0"
    q[i] = Sl.count("W") + Sr.count("E")

print(min(q))


### FIXED CODE ###

N = int(input())
S = input()

listw = [0]
for i in range(N):
    listw.append(listw[-1]+1 if S[i] == "W" else listw[-1])

liste = [0]
for i in range(N):
    liste.append(liste[-1]+1 if S[i] == "E" else liste[-1])

list = [0]*N
for i in range(N):
    list[i] = listw[i] + liste[-1] - liste[i+1 if i != N-1 else -1]

list.sort()

print(list[0])
### BUGGY CODE ###

N = int(input())
S = [list(input()) for _ in range(N)]
ans = 0
for i in range(N):
    S[i].sort()
print
for i in range(N):
    for j in range(i+1,N):
        if S[i] == S[j]:
            ans += 1
print(ans)

### FIXED CODE ###

N = int(input())
S = [input() for _ in range(N)]
mydict = {}
ans = 0
for i in range(N):
    T = [str(x) for x in S[i]]
    T.sort()
    S[i] = ''.join(T)
for j in range(N):
    if S[j] in mydict.keys():
        ans += mydict[S[j]]
        mydict[S[j]] += 1
    else:
        mydict.setdefault(S[j],1)
print(ans)
### BUGGY CODE ###

import sys
input=sys.stdin.buffer.readline
n=int(input())+1
data=[0]*n*2
def update(i,x):
  i+=n
  data[i]=x
  i//=2
  while i:
    data[i]=data[i*2]|data[i*2+1]
    i//=2
def query(l,r):
  l+=n
  r+=n
  s=0
  while l<r:
    if l&1:
      s|=data[l]
      l+=1
    if r&1:
      r-=1
      s|=data[r]
    l//=2
    r//=2
  return bin(s).count('1')
for i,c in enumerate(input()[:-1]):update(i,2**(c-97))
s=[]
for _ in range(int(input())):
  q,a,b=input().split()
  if q[0]>49:s+=query(int(a)-1,int(b)),
  else:update(int(a)-1,2**(b[0]-97))
print(*s)

### FIXED CODE ###

import sys
input=sys.stdin.buffer.readline
n=int(input())+1
data=[0]*n*2
def update(i,x):
  i+=n
  data[i]=x
  i//=2
  while i:
    data[i]=data[i*2]|data[i*2+1]
    i//=2
def query(l,r):
  l+=n
  r+=n
  s=0
  while l<r:
    if l&1:
      s|=data[l]
      l+=1
    if r&1:
      r-=1
      s|=data[r]
    l//=2
    r//=2
  return sum(map(int,bin(s)[2:]))
for i,c in enumerate(input()[:-1]):
  update(i,2**(c-97))
for _ in range(int(input())):
  q,a,b=input().split()
  if q[0]>49:print(query(int(a)-1,int(b)))
  else:update(int(a)-1,2**(b[0]-97))
### BUGGY CODE ###

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

def solve():
    S = input()
    Q = int(input())

    is_reverse = False # 反転中か？

    # for _ in range(Q):
    #     query = input().split()
    #     if query[0] == "1":
    #         is_reverse = True
    #     else:
    #         t, f, c = query
    #         if f == "1":
    #             if is_reverse:
    #                 # 末尾にcを追加
    #                 S = S + c
    #             else:
    #                 # 先頭にcを追加
    #                 S = c + S
    #         else:
    #             if is_reverse:
    #                 # 先頭に追加
    #                 S = c + S
    #             else:
    #                 # 末尾に追加
    #                 S = S + c
    #     print(S)
    # if is_reverse:
    #     print(S[::-1])
    # else:
    #     print(S)

    for _ in range(Q):
        query = input().split()
        if query[0] == "1":
            S = S[::-1]
        else:
            t, f, c = query
            if f == "1":
                S = c + S
            else:
                S = S + c

    print(S)


if __name__ == "__main__":
    solve()


### FIXED CODE ###

# -*- coding:utf-8 -*-
from collections import deque

def solve():
    d = deque(input())
    Q = int(input())

    is_reverse = False # 反転中か？

    for _ in range(Q):
        query = input()
        if query == "1":
            is_reverse = not is_reverse
        else:
            _, f, c = query.split()

            if f == "1":
                if is_reverse:
                    # 末尾にcを追加
                    d.append(c)
                else:
                    # 先頭にcを追加
                    d.appendleft(c)
            else:
                if is_reverse:
                    # 先頭に追加
                    d.appendleft(c)
                else:
                    # 末尾に追加
                    d.append(c)

    if is_reverse:
        print("".join(reversed(list(d))))
    else:
        print("".join(d))


def solve2():
    S = list(input())
    Q = int(input())
    M = 2*10**5+10
    data = [None]*M
    data.extend(S)
    data.extend([None]*M)
    left, right = M-1, M+len(S)

    is_reverse = False

    for _ in range(Q):
        query = input()
        if query == "1":
            is_reverse = not is_reverse
        else:
            t, f, c = query.split()
            if f == "1":
                if is_reverse:
                    # 末尾にcを追加
                    data[right] = c
                    right += 1
                else:
                    # 先頭にcを追加
                    data[left] = c
                    left -= 1
            else:
                if is_reverse:
                    # 先頭に追加
                    data[left] = c
                    left -= 1
                else:
                    # 末尾に追加
                    data[right] = c
                    right += 1

    # 出力
    if is_reverse:
        print("".join(data[right-1:left:-1]))
        # for i in range(right-1, left, -1):
        #     print(data[i], end="")
    else:
        # for i in range(left+1, right):
        #     print(data[i], end="")
        print("".join(data[left+1:right]))
    # print()


if __name__ == "__main__":
    solve()
### BUGGY CODE ###

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

count = 0
while 1:
    if K > 0:
        H[H.index(max(H))] = 0
        K -= 1
    else:
        break

count += sum(H)

print(count)

### FIXED CODE ###

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

count = 0
H = sorted(H,reverse=True)

count += sum(H[K:])

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

s = input()
K = int(input())

result = []
lst = []
for si in s:
    temp = []
    for li in lst:
        temp.append(li + si)
    temp.append(si)
    result.extend(temp)
    lst = temp

temp = list(set(result))
temp.sort()
print(temp[K - 1])


### FIXED CODE ###

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

N = len(S)

memo = []
for i in range(N):
    for d in range(1, min(K, N - i) + 1):
        memo.append(S[i:i + d])

print(sorted(set(memo))[K - 1])
### BUGGY CODE ###

def II(): return int(input())
def LI(): return [int(i) for i in input().split()]

N, K = LI()
H = LI()

cost = [0] * N
cost[0] = 0
for n in range(1, N):
  cost[n] = min([ cost[n-k]+abs(H[n-k]-H[n]) for k in range(1, min(n+1, K+1)) ])

print(cost[-1])

### FIXED CODE ###

#  def II(): return int(input())
#def LI(): return [int(i) for i in input().split()]

#N, K = LI()
#H = LI()

#cost = [0] * N
#cost[0] = 0
#for n in range(1, N):
#  cost[n] = min([ cost[n-k]+abs(H[n-k]-H[n]) for k in range(1, min(n+1, K+1)) ])

#print(cost[-1])

def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    a = [0] * n
    a[0] = 0
    for i in range(1, n):
        a[i] = min([a[j] + abs(h[i] - h[j]) for j in range(max(0, i - k), i)])
    print(a[-1])
 
if __name__ == '__main__':
    main()
### BUGGY CODE ###

#(縦, 横)
#bfs 徒歩→ワープ→徒歩→ワープ→…

h,w = map(int,input().split())
sy, sx = map(int,input().split())
start = (sy-1, sx-1)
gy, gx = (map(int,input().split()))
goal = (gy-1, gx-1)

chizu = [input() for _ in range(h)]
yukaset = set()

for i in range(h):
	for j in range(w):
		if chizu[i][j] == ".":
			yukaset.add((i, j))

settansaku = set()
stock = set()
setmada = {start}
mode = 1
cost = 0

while len(setmada) > 0:
	while len(setmada) > 0:
		for i, j in list(setmada):
			settansaku.add((i, j))
			stock.add((i, j))
			setmada.remove((i, j))
			for k in [(i+1, j), (i-1, j), (i, j-1), (i, j+1)]:
				if k in yukaset:
					if not k in setmada:
						if not k in settansaku:
							setmada.add(k)
								
	if goal in settansaku:
		mode = 0
		break
	
	cost += 1
	for i, j in list(stock):
		for k in [(i-2, j-2), (i-1, j-2), (i, j-2), (i+1, j-2), (i+2, j-2), (i-2, j-1), (i-1, j-1), (i, j-1), (i+1, j-1), (i+2, j-1), (i-2, j), (i-1, j), (i+1, j), (i+2, j), (i-2, j+1), (i-1, j+1), (i, j+1), (i+1, j+1), (i+2, j+1), (i-2, j+2), (i-1, j+2), (i, j+2), (i+1, j+2), (i+2, j+2)]:
			if k in yukaset:
				if not k in settansaku:
					setmada.add(k)
	
	stock=set()
	
	if goal in settansaku:
		mode = 0
		break

if mode == 0:
	print(cost)
else:
	print(-1)

### FIXED CODE ###

h,w = map(int,input().split())
sy, sx = map(int,input().split())
start = (sy-1, sx-1)
gy, gx = (map(int,input().split()))
goal = (gy-1, gx-1)

yukaset = set()

for i in range(h):
	chizu = input()
	for j in range(w):
		if chizu[j] == ".":
			yukaset.add((i, j))

settansaku = {start}
stock = []
listmada = [start]
mode = 1
cost = 0

while len(listmada) > 0:
	for i, j in listmada:
		stock.append((i, j))
		for k in [(i+1, j), (i-1, j), (i, j-1), (i, j+1)]:
			if k in yukaset:
				if k not in settansaku:
					listmada.append(k)
					settansaku.add(k)

	if goal in settansaku:
		mode = 0
		break
	
	listmada = []
	cost += 1
	for i, j in stock:
		for k in [(i-2, j-2), (i-1, j-2), (i, j-2), (i+1, j-2), (i+2, j-2), (i-2, j-1), (i-1, j-1), (i, j-1), (i+1, j-1), (i+2, j-1), (i-2, j), (i-1, j), (i+1, j), (i+2, j), (i-2, j+1), (i-1, j+1), (i, j+1), (i+1, j+1), (i+2, j+1), (i-2, j+2), (i-1, j+2), (i, j+2), (i+1, j+2), (i+2, j+2)]:
			if k in yukaset:
				if k not in settansaku:
					listmada.append(k)
					settansaku.add(k)
	
	stock = []

if mode == 0:
	print(cost)
else:
	print(-1)
### BUGGY CODE ###

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

minimumCostToReach = [0 for i in range(N)]

minimumCostToReach[0] = 0
for currentIndex in range(1, N):
  minimumCostToReach[currentIndex] = 1000000000

  for previousIndex in range(max(currentIndex - K, 0), currentIndex):
    cost = minimumCostToReach[previousIndex] + abs(h[currentIndex] - h[previousIndex])
    minimumCostToReach[currentIndex] = min(minimumCostToReach[currentIndex], cost)

print(minimumCostToReach[N - 1])


### FIXED CODE ###

def solve():
  N, K = [int(i) for i in input().split()]
  H = [int(i) for i in input().split()]
  dp = [0] * N

  for i in range(1, N):
    dp[i] = min(dp[j] + abs(H[i] - H[j]) for j in range(max(i - K, 0), i))

  return dp[N - 1]

print(solve())
### BUGGY CODE ###

N=int(input())
A=[int(input()) for i in range(N)]
maxa=max(A)
for i in range(N):
  if A[i]==maxa:
    tmp=max(A[:i]+A[i+1:])
    print(tmp)
  else:
    print(maxa)

### FIXED CODE ###

N=int(input())
A=[int(input()) for i in range(N)]
maxa=max(A)
id=A.index(maxa)
for i in range(N):
  if i==id:
    tmp=max(A[:i]+A[i+1:])
    print(tmp)
  else:
    print(maxa)
### BUGGY CODE ###

n = int(input())

for i in range(1, n + 1):
  count = 0
  # x <= y <= zとして考える
  if i >= 6:
    for x in range(1, i + 1):
      if 6 * x ** 2 > i:
        break
      a = i - x ** 2
      for y in range(x, i + 1):
        if 3 * y ** 2 + 2 * x * y > a:
          break
        for z in range(y , i + 1):
          if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == i:
            if x == y:
              if y == z:
                count += 1
              else:
                count += 3
            else:
              if y == z:
                count += 3
              else:
                count += 6
            break
          if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x > i:
            break
  print(count)

### FIXED CODE ###

ans = [0] * 10000
for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      k = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
      if k > 10000:
        break
      ans[k - 1] += 1

n = int(input())
for i in range(n):
  print(ans[i])
### BUGGY CODE ###

R, G, B, N = map(int, input().split())
cnt = 0

for r in range(N//R+1):
	for g in range(N+1):
		#b = (N - R * r - G * g) / B
		if R * r + G * g == N:
			cnt += 1
		elif ((N - R * r - G * g) / B).is_integer() and ((N - R * r - G * g) / B) > 0:
			cnt += 1
print(cnt)


### FIXED CODE ###

R, G, B, N = map(int, input().split())
cnt = 0

for r in range(N//R+1):
	for g in range((N-R*r)//G+1):
		if (N - R * r - G * g) % B == 0:
			cnt += 1
print(cnt)
### BUGGY CODE ###

import sys
imput=sys.stdin.readline
n=int(input())
c=[]
for i in range(n):
    a=int(input())
    if a not in c:
        c.append(a)
    else:
        c.remove(a)
print(len(c))

### FIXED CODE ###

n=int(input())
a=[int(input()) for i in range(n)]
a.append(1000000001)
a.append(0)
a.sort()
c=0
ans=0
s=0
#print(a)
for i in range(1,n+2):
    if a[i]==c:
        s+=1
    else:
        ans+=(s%2)
        c=a[i]
        s=1
    #print(s)
print(ans)
### BUGGY CODE ###

R, G, B, N = map(int, input().split())
ans = 0
for i in range(N//R+1):
    r = i
    for j in range(((N-R*r)//G)+1):
        g = j
        if N-R*r-G*g >= 0 and (N-R*r-G*g) % B == 0:
            ans += 1
print(ans)


### FIXED CODE ###

def main():

    R, G, B, N = map(int, input().split())

    ans = 0

    for i in range((N//R)+1):
        r = i
        for j in range(((N-R*r)//G)+1):
            g = j
            if (N-R*r-G*g) % B == 0 and N-R*r-G*g >= 0:
                ans += 1

    print(ans)

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

from collections import defaultdict


def dfs(v):
    global ret
    if ret:
        return
    if v == 2:
        if len(used) == cnt:
            ret = True
        return
    for idx, u in enumerate(edges[v]):
        tmp = tuple(sorted((u, v)) + [idx])
        if tmp in used:
            continue
        used.add(tmp)
        dfs(u)
        used.discard(tmp)

while 1:
    edges = defaultdict(list)
    cnt = 0
    try:
        a, b = map(int, raw_input().split())
        edges[a].append(b)
        edges[b].append(a)
        cnt += 1
    except EOFError:
        break
    while 1:
        a, b = map(int, raw_input().split())
        if a == b == 0:
            break
        edges[a].append(b)
        edges[b].append(a)
        cnt += 1
    stack = []
    ret = False
    used = set()
    dfs(1)
    if ret:
        print "OK"
    else:
        print "NG"

### FIXED CODE ###

while 1:
    edges = [0] * 101
    try:
        a, b = map(int, raw_input().split())
        edges[a] += 1
        edges[b] += 1
    except EOFError:
        break
    while 1:
        a, b = map(int, raw_input().split())
        if a == b == 0:
            break
        edges[a] += 1
        edges[b] += 1
    if edges[1] % 2 and edges[2] % 2 and all(map(lambda a: a % 2 == 0, edges[3:])):
        print "OK"
    else:
        print "NG"