Harryxun/stf_run huggingface dataset:
S = input()
S_length = len(S)
k = 1
s_l=[]
for i in range(S_length-1):
  s_x=S[i]
  if S[i+1]==s_x:
    k+=1
  else:
    s_l.append(s_x*k)
    k=1

if s_l[-1][0]!=S[-1]:
  s_l.append(S[-1])
  
        
        
def n_sum(n):
  return n*(n+1)//2
        

s_l_length = len(s_l)
answer=0
if s_l[0][0]=='<':
  if s_l_length%2==0:
    for i in range(0,s_l_length,2):
      s_1=s_l[i]
      s_2=s_l[i+1]
      s_1_l=len(s_1)
      s_2_l=len(s_2)
      if s_1_l<=s_2_l:
        answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
      else:
        answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
  else:
    for i in range(0,s_l_length,2):
      if i==s_l_length-1:
        answer+=n_sum(len(s_l[i]))
      else:
        s_1=s_l[i]
        s_2=s_l[i+1]
        s_1_l=len(s_1)
        s_2_l=len(s_2)
        if s_1_l<=s_2_l:
          answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
        else:
          answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
          
else:
  answer+=n_sum(len(s_l.pop(0)))
  s_l_length-=1
  if s_l_length%2==0:
    for i in range(0,s_l_length,2):
      s_1=s_l[i]
      s_2=s_l[i+1]
      s_1_l=len(s_1)
      s_2_l=len(s_2)
      if s_1_l<=s_2_l:
        answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
      else:
        answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
  else:
    for i in range(0,s_l_length,2):
      if i==s_l_length-1:
        answer+=n_sum(len(s_l[i]))
      else:
        s_1=s_l[i]
        s_2=s_l[i+1]
        s_1_l=len(s_1)
        s_2_l=len(s_2)
        if s_1_l<=s_2_l:
          answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
        else:
          answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
  
      
print(answer)

### FIXED CODE ###

S = input()
from itertools import groupby
S_length = len(S)
k = 1
s_l=[k*len(list(g)) for k, g in groupby(S)]
  
        
        
def n_sum(n):
  return n*(n+1)//2
        

s_l_length = len(s_l)
answer=0
if s_l[0][0]=='<':
  if s_l_length%2==0:
    for i in range(0,s_l_length,2):
      s_1=s_l[i]
      s_2=s_l[i+1]
      s_1_l=len(s_1)
      s_2_l=len(s_2)
      if s_1_l<=s_2_l:
        answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
      else:
        answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
  else:
    for i in range(0,s_l_length,2):
      if i==s_l_length-1:
        answer+=n_sum(len(s_l[i]))
      else:
        s_1=s_l[i]
        s_2=s_l[i+1]
        s_1_l=len(s_1)
        s_2_l=len(s_2)
        if s_1_l<=s_2_l:
          answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
        else:
          answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
          
else:
  answer+=n_sum(len(s_l.pop(0)))
  s_l_length-=1
  if s_l_length%2==0:
    for i in range(0,s_l_length,2):
      s_1=s_l[i]
      s_2=s_l[i+1]
      s_1_l=len(s_1)
      s_2_l=len(s_2)
      if s_1_l<=s_2_l:
        answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
      else:
        answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
  else:
    for i in range(0,s_l_length,2):
      if i==s_l_length-1:
        answer+=n_sum(len(s_l[i]))
      else:
        s_1=s_l[i]
        s_2=s_l[i+1]
        s_1_l=len(s_1)
        s_2_l=len(s_2)
        if s_1_l<=s_2_l:
          answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
        else:
          answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
  
      
print(answer)
import math


try:
    while True:
        r = int(input())

        A = [i for i in range(2, r+1)]
        P = []
        time = 0

        while True:
            prime = min(A)

            if prime > math.sqrt(r):
                break

            P.append(prime)

            i = 0
            while i < len(A):
                if A[i] % prime == 0:
                    A.pop(i)
                    continue
                i += 1
        for a in A:
            P.append(a)

        print(len(P))

except EOFError:
    pass



### FIXED CODE ###

LIMIT = 10000000
  
isPrime = [True for _ in range(LIMIT)]
 
isPrime[0] = isPrime[1] = False
  
for i in range(2, int(LIMIT ** 0.5)+1):
  if isPrime[i]:
    for j in range(i * i, LIMIT, i):
      isPrime[j] = False
  
try:
    while True:
        n = int(input())
 
        count = 0
        if n >= 2:
            count = 1
 
        for i in range(3, n+1, 2):
            if isPrime[i]:
                count += 1
 
        print(count)
except EOFError:
  pass
s = str(input())
f = "yes"
for i in range(0,len(s)):
    if s.count(i) != 1:
        f = "no"
        break
print(f)

### FIXED CODE ###

s = str(input())
f = "yes"
for i in range(0,len(s)):
    if s.count(s[i]) != 1:
        f = "no"
        break
print(f)
import numpy as np

N = int(input())

for i in range(1, int(np.sqrt(N))):
    if N % i == 0:
        ans = (i - 1) + ((N / i) - 1)

print(int(ans))

### FIXED CODE ###

import numpy as np

N = int(input())

for i in range(1, int(np.sqrt(N)) + 1):
    if N % i == 0:
        ans = (i - 1) + ((N / i) - 1)

print(int(ans))
# -*- coding: utf-8 -*-
N = int(input())
A = [int(input()) for _ in range(N)]
setA = set(A)
tempA = list(setA)
R = sorted(tempA, reverse=True)
max_v = R[0]
if len(R) >= 1:
  max_v2 = R[1]
  signal = 1
else:
  max_v2 = R[0]

for i in range(N):
  if A[i] == max_v:
    print(max_v2)
  else:
    print(max_v)

### FIXED CODE ###

# -*- coding: utf-8 -*-
N = int(input())
A = [int(input()) for _ in range(N)]
setA = set(A)
tempA = list(setA)
R = sorted(tempA, reverse=True)
max_v = R[0]
if len(R) >= 2:
  max_v2 = R[1]
else:
  max_v2 = R[0]
R2 = sorted(A, reverse=True)
if R2[0] == R2[1]:
  signal = 1
else:
  signal = 0
  
for i in range(N):
  if A[i] == max_v and signal == 0:
    print(max_v2)
  else:
    print(max_v)
# 4 5
import math
field = [int(i) for i in input().split(" ")]
field_num = field[0] * field[1]
if field_num[0] == 1 or field_num[1] == 1:
    print(1)
else:
    canFillBlock = 0
    canFillBlock += math.ceil(field[1]/2) * math.ceil(field[0]/2)
    canFillBlock += math.floor(field[1]/2) * math.floor(field[0]/2)
    print(canFillBlock)


### FIXED CODE ###

# 4 5
import math
field = [int(i) for i in input().split(" ")]
field_num = field[0] * field[1]
if field[0] == 1 or field[1] == 1:
    print(1)
else:
    canFillBlock = 0
    canFillBlock += math.ceil(field[1]/2) * math.ceil(field[0]/2)
    canFillBlock += math.floor(field[1]/2) * math.floor(field[0]/2)
    print(canFillBlock)
_ = input()

nums = [int(x) for x in input().split()]

max_ = max(nums)

pop(nums.index(max_))

rest = sum(nums)

if rest > max_:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

_ = input()

nums = [int(x) for x in input().split()]

max_ = max(nums)

nums.pop(nums.index(max_))

rest = sum(nums)

if rest > max_:
    print('Yes')
else:
    print('No')
n = int(input())
h_list = [int(_) for _ in input().split()]
ans = 0 
while sum(h_list) != 0:
    # 0で区切られた、1以上の数のかたまりを数える
    # 要素が全て1以上ならansに+1して次のループ
    if h_list.count(0) == 0:
        ans += 1
    else:
        for i in range(0,n):
            # 1以上から0に下がった時にかたまりをカウント
            if i != 0 and h_list[i] == 0 and h_list[i - 1] != 0:
                ans += 1
            elif i == n and h_list[i] != 0:
                ans += 1
    # 1以上の箇所を1段ずつ落とす
    for j in range(n):
        if h_list[j] != 0:
            h_list[j] -= 1

print(ans)

### FIXED CODE ###

ab,bc,ca = map(int, input().split())

print(bc * ab // 2)
n=int(input(""))
k=int(input(""))
s=n%k
ss=k-s
if(s<ss):
    print(s)
else:
    print(ss)

### FIXED CODE ###

l=input("").split(" ")
n=int(l[0])
k=int(l[1])
s=n%k
ss=k-s
if(s<ss):
    print(s)
else:
    print(ss)
s = input()
dic = {}
for i in range(2019):
  dic[i] = 0
dic[0] = 1
m = 0
for j in range(len(s)):
  m = 10*m + s[j]
  m %= 2019
  dic[m] += 1
ans = 0
for v in dic.values():
  ans += v*(v-1) // 2
print(ans)


### FIXED CODE ###

s = input()
dic = {}
for i in range(2019):
  dic[i] = 0
dic[0] = 1
m = 0
decimal = 1
for j in range(1, len(s)+1):
  m += int(s[-j]) * decimal
  m %= 2019
  dic[m] += 1
  decimal *= 10
  decimal %= 2019

ans = 0
for v in dic.values():
  ans += v*(v-1) // 2
print(ans)
import math
N, D=map(int, input())
Xs=[list(map(int, input().split())) for _ in range(N)]
cnt=0
for i in range(N):
  for j in range(i+1, N):
    dis=0
    for k in range(D):
      dis+=(X[i][k]-X[j][k])**2
    dis=math.sqrt(dis)
    if dis==int(dis):
      cnt+=1
print(cnt)

### FIXED CODE ###

import math
N, D=map(int, input().split())
X=[list(map(int, input().split())) for _ in range(N)]
cnt=0
for i in range(N):
  for j in range(i+1, N):
    dis=0
    for k in range(D):
      dis+=(X[i][k]-X[j][k])**2
    dis=math.sqrt(dis)
    if dis==int(dis):
      cnt+=1
print(cnt)
a = input()
for i in range(len(a)):
    if a[i] == '1':
        a[i] = '9'
    elif a[i] == '9':
        a[i] = '1'
print(a)


### FIXED CODE ###

a = input()
for i in range(len(a)):
    if a[i] == '1':
        a = a[:i] + '9' + a[i+1:]
    elif a[i] == '9':
        a = a[:i] + '1' + a[i+1:]
print(a)
while True:
    n = int(input())
    if n == 0:
        break
    a_score = 0
    b_score = 0
    for i in range(0,3):
        a,b = map(int,input().split())
        if a > b :
            a_score += a+b
        elif a < b :
            b_score += a+b
        else:
            a_score += a
            b_score += a
    print(a_score,b_score)


### FIXED CODE ###

while True:
    n = int(input())
    if n == 0:
        break
    a_score = 0
    b_score = 0
    for i in range(0,n):
        a,b = map(int,input().split())
        if a > b :
            a_score += a+b
        elif a < b :
            b_score += a+b
        else:
            a_score += a
            b_score += a
    print(a_score,b_score)
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

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

## Logic

ans = [0,0,0,0,0,0,0,0]
tmp = 0

for i in range(0,N):
    if A[i]//400 >= 8:
        tmp += 1
    else:
        ans[A[i]//400] = 1

print(max(1,sum(ans)),min(8,sum(ans)+tmp))



### FIXED CODE ###

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

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

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

## Logic

A.append(A[0]+K)

tmp = 0
for i in range(0,N):
    tmp = max(tmp,A[i+1]-A[i])
print(K-tmp)
def acinput():
    return list(map(int, input().split(" ")))


N, M = acinput()
a = [0]*(N+100)
for i in range(M):
    a[int(input())] = 1


Mod = 1000000007


def solve(x):
    global dp, Mod
    if dp[x] >= 0:
        return dp[x]

    if x < 0:
        return 0

    res = 0
    zeroflg = True

    if  a[x-2] != 1:
        res += solve(x-2) 
        zeroflg = False

    if a[x-1] != 1:
        res += solve(x-1)
        zeroflg = False


    if zeroflg:
        return 0
    dp[x] = res% Mod
    return res


dp = [-1]*(N+100)
dp[0] = 1
dp[1] = 1

print(solve(N) % Mod)


'''
5 1
1
'''


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

def acinput():
    return list(map(int, input().split(" ")))


N, M = acinput()
a = [0]*(N+1)
for i in range(M):
    a[int(input())] = 1


Mod = 1000000007


def solve(x):
    global dp, Mod
    if dp[x] >= 0:
        return dp[x]

    if x < 0:
        return 0

    res = 0
    zeroflg = True

    if  a[x-2] != 1:
        res += solve(x-2) 
        zeroflg = False

    if a[x-1] != 1:
        res += solve(x-1)
        zeroflg = False

    if zeroflg:
        return 0
    dp[x] = res% Mod
    return res


dp = [-1]*(N+1)
dp[0] = 1
dp[1] = 1

print(solve(N) % Mod)


'''
5 1
1
'''
input_line = int(input())
for i in range(input_line):
  s = input().rstrip().split(' ')
  print("hello = "+s[0]+" , world = "+s[1])

### FIXED CODE ###

s = input().split()

K = int(s[0])
N = int(s[1])

if K >= 10:
  print(N)
else:
  print(N + 100*(10-K))
a = input()
b = input()

a.sort()
b.sort(reverse=True)

print("Yes" if a < b else "No")

### FIXED CODE ###

a = input()
b = input()

print("Yes" if sorted(a) < sorted(b)[::-1] else "No")
s = input()
t = input()
before = -1
len_s = len(s)
ans = 0
cnt = 0
moji = [[] for _ in range(25)]
for i,S in enumerate(s):
        moji[ord(S) - 97].append(i)

for T in t:
        found = False
        if not moji[ord(T) - 97]:
                print(-1)
                exit()
        for num in moji[ord(T) - 97]:
                if num > before:
                        before = num
                        found = True
                        break
        if not found:
                cnt += 1
                before = moji[ord(T) - 97][0]
ans = cnt * len_s + before + 1
print(ans)

### FIXED CODE ###

import bisect
s = input()
t = input()
before = -1
len_s = len(s)
ans = 0
cnt = 0
moji = [[] for _ in range(26)]
for i,S in enumerate(s):
        moji[ord(S) - 97].append(i)

for T in t:
        if not moji[ord(T) - 97]:
                print(-1)
                exit()
        if moji[ord(T) - 97][-1] <= before:
                cnt += 1
                before = moji[ord(T) - 97][0]
                continue
        before = moji[ord(T) - 97][bisect.bisect_right(moji[ord(T) - 97],before)]
        # for num in moji[ord(T) - 97]:
        #         if num > before:
        #                 before = num
        #                 break
ans = cnt * len_s + before + 1
print(ans)
N = int(input())
A = list(map(int, input().split()))
for n in range(N):
caunter = 0
flag = "0"
while flag == "0":
    for i in range(N):
        if(A[i] % 2 != 1):
            flag = "1"
            break
        
    if(flag = "0"):
        for i in range(N):
            A[i] = A[i]/2
        caunter += 1
print(caunter)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
cau = 0
flag = True
while flag:
    for i in range(N):
        if A[i] % 2 == 1:
            flag = False
            break        
    if flag:
        for i in range(N):
            A[i] = A[i]/2
        cau += 1
print(cau)
S = input()
N = len(S)
P = 0
for i in range (N-1//2):
    if S[i] == S[N-1-i]:
        for k in range(N-1//2):
            if S[k] == S[((N-1)//2)-k] and S[((N+1)//2)+k] == S[N-1-k]:
                P = P
            else:
                P += 1
        else:
            P += 1

if P == 0:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

S = input()
N = len(S)
P = 0
for i in range ((N-1)//2):
    if S[i] == S[N-1-i]:
        for k in range((N-1)//2):
            if S[k] == S[((N-3)//2)-k] and S[((N+1)//2)+k] == S[N-1-k]:
                P = P
            else:
                P += 1
    else:
        P += 1

if P == 0:
    print('Yes')
else:
    print('No')
x,n = [int(i) for i in input().split()]
if n == 0:
  print(x)
  exit()
p = [int(i) for i in input().split()]

num = list(range(1,101))
nums = []
for i in num:
  if not(i in p):
    nums.append(i)
#print(nums)
p2 = [abs(nums[i]-x) for i in range(len(nums))]
p2min = min(p2)
for i in range(len(p2)):
  if p2[i] == p2min:
    print(nums[i])
    exit()


### FIXED CODE ###

x,n = [int(i) for i in input().split()]
if n == 0:
  print(x)
  exit()
p = [int(i) for i in input().split()]

num = list(range(102))
nums = []
for i in num:
  if not(i in p):
    nums.append(i)
#print(nums)
p2 = [abs(nums[i]-x) for i in range(len(nums))]
p2min = min(p2)
for i in range(len(p2)):
  if p2[i] == p2min:
    print(nums[i])
    exit()
alpha = input()
if alpha.isupper() == True:
    print(aplha.lower())
else :
    print(alpha.upper())


### FIXED CODE ###

alpha = input()
if alpha.isupper() == True:
    print("A")
else :
    print("a")
L, N = map(int, input().split())

C = list(range(N))

i=0

while i < N:
    C[i] = input()
    
    if len(C[i]) == L:
       i += 1
    else:
       pass

C.sort()

i=0

while i < N:
    print(C[i] , end ="")
    i += 1

### FIXED CODE ###

N, L = map(int, input().split())
 
C = [input() for i in range(N)]
 
C.sort()
 
i=0
 
while i < N:
    print(C[i] , end ="")
    i += 1
h, W = map(int,input().split())
if h % 2 != 0:
    if W % 2 != 0:
        ans = ((h-1)*W//2)+(W//2+1)
else:
    ans = (h*W)//2
print(ans)

### FIXED CODE ###

h, W = map(int,input().split())
if W <= 0:
    print(0)
elif h == 1:
    print(1)
elif W == 1:
    print(1)
else:
    if h % 2 != 0:
        if W % 2 != 0:
            ans = ((h-1)*W//2)+(W//2+1)
        else:
            ans = (h*W)//2
    else:
        ans = (h*W)//2
    print(ans)
import sys

sys.setrecursionlimit(10000)

def quick_sort2(a, i, j):
    if j <= i:
        pass
    else:
        p = a[j]; s = i
        for k in range(i, j):
            if a[k] <= p:
                a[s], a[k] = a[k], a[s]
                s += 1

        a[j], a[s] = a[s], a[j]
        quick_sort(a, i, s-1)
        quick_sort(a, s+1, j)


n = int(raw_input())
A = map(int, raw_input().split())

quick_sort2(A, 0, n - 1)

print " ".join(map(str, A))

### FIXED CODE ###

n = int(raw_input())
x = map(int,raw_input().split())
x.sort()
for i in xrange(n):
	print x[i],
n,a,b,c,d=map(int,input().split())
s=list(input())
fa=True
fb=True
ff=False
for i in range(a,c-1):
    if s[i]=="#" and s[i+1]=="#":
        fa=False
for i in range(b,d-1):
    if s[i]=="#" and s[i+1]=="#":
        fb=False
if c>d:
    for i in range(a,d):
        if s[i]=="." and s[i+1]=="." and s[i+2]==".":
            ff=True
if c<d:
    if fa and fb:
        print("Yes")
    else:
        print("No")
else:
    if fa and fb and ff:
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

n,a,b,c,d=map(int,input().split())
s=list(input())
fa=True
fb=True
ff=False
for i in range(a,c-1):
    if s[i]=="#" and s[i+1]=="#":
        fa=False
for i in range(b,d-1):
    if s[i]=="#" and s[i+1]=="#":
        fb=False
if c>d:
    for i in range(b-2,d-1):
        if s[i]=="." and s[i+1]=="." and s[i+2]==".":
            ff=True
if c<d:
    if fa and fb:
        print("Yes")
    else:
        print("No")
else:
    if fa and fb and ff:
        print("Yes")
    else:
        print("No")
s = input()
t = input()

LS = len(s)
LT = len(t)

num = LT
for i in range(LT):
  if s[0] == t[i]:
    num = i
    break

if LS == 1:
  if num == LT:
    print("")
  else:
    print (s)
  exit()
    
DP = [[0 if i < num or j != 0 else 1 for i in range(LT)] for j in range(LS)]
T = [1 if i == num else 0 for i in range(LT)]
if num != LT:
  L = [s[0]]
else:
  L = [[""]]
for i in range(1, LS):
  ma = DP[i-1][0]
  flag = 0
  for j in range(LT):
    if flag == 1:
      T[j] = 0
    if s[i] == t[j] and T[j] == 0:
      if flag == 0:
        T[j] = 1
        flag = 1
      Lt = DP[i-1][j]
      if len(L[ma-1]) <= len(L[Lt-1]):
        L.append(L[Lt-1] + s[i])
        ma = len(L)
    elif ma < DP[i-1][j]:
      ma = DP[i-1][j]
    DP[i][j] = ma

print(L[ma-1])


### FIXED CODE ###

def main(): 
  s = input()
  t = input()

  LS = len(s)
  LT = len(t)
      
  DP = [[0 for i in range(LT + 1)] for j in range(LS + 1)]
  L = [[0 for i in range(LT)] for j in range(LS)]
  for i in range(LS):
    for j in range(LT):
      a = DP[i+1][j]
      b = DP[i][j+1]
      if max(a, b) == a:
        DP[i+1][j+1] = a
        L[i][j] = 1
      else:
        DP[i+1][j+1] = b
        L[i][j] = 2
        a = b
      if s[i] == t[j]:
        c = DP[i][j] + 1
        if max(a, c) == c:
          DP[i+1][j+1] = c
          L[i][j] = 3       
        
  Ans = ""
  j = LS - 1
  k = LT - 1
  x = DP[LS][LT]
  for i in range(x, 0, -1):
    while True:
      if L[j][k] == 3:
        Ans += t[k]
        j -= 1
        k -= 1
        break
      elif L[j][k] == 2:
        j -= 1
      else:
        k -= 1
  print(Ans[::-1])
main()
n = input()
if int(n)%1000 = 0:
    print(0)
if int(n) < 1000:
    print(1000-int(n))
else:
    print(1000-int(n[-3:]))

### FIXED CODE ###

n = input()
if int(n)%1000 == 0:
    print(0)
elif int(n) < 1000:
    print(1000-int(n))
else:
    print(1000-int(n[-3:]))
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if (500*i) + (100*j) + (50*k) == x:
                count += 1
print(count)

### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if (500*i) + (100*j) + (50*k) == X:
                count += 1
print(count)
N = map(int, input().split())[0]
A = map(int, input().split())
sum = 0
for i in A:
  sum += A
if sum > N:
  print(-1)
else:
  print(N-sum)

### FIXED CODE ###

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

sum = 0
for i in A:
  sum = sum + i
if sum > N:
  print(-1)
else:
  print(N-sum)
# -*- coding: utf-8 -*-
# https://atcoder.jp/contests/abc126/tasks/abc126_d

import sys

def dfs(i):
  for v,w in V.get(i, []):
    if (w % 2) == 0:
      if color[v] == -1:
        color[v] = color[i]
      elif color[v] == color[i]:
        continue
      elif color[v] != color[i]:
        return False
    else:
      if color[v] == -1:
        color[v] = 0 if color[i] else 1
      elif color[v] == color[i]:
        return False
      elif color[v] != color[i]:
        continue
    dfs(v)
  return True

if __name__ == '__main__':
  n = int(input())
  V = {} # key:vertex, value:[[vertex opposited, wight]]
  color = {} # 0 or 1 or -1
  for i in range(1, n):
    u,v,w = map(int, input().split())
    if not V.get(u, False):
      V[u] = [[v,w]]
    else:
      V[u].append([v,w])

    if not V.get(v, False):
      V[v] = [[u,w]]
    else:
      V[v].append([u,w])
    # 同じ頂点間で複数の辺はないと仮定
  for i in range(1, n+1):
    color[i] = -1

  while True:
    i = 0
    for j in range(1, n+1):
      if color[j] == -1:
        i = j
        color[i] = 0
        break
    if i == 0:
      for j in range(1, n+1):
        print(color[j])
      break
    else:
      if not dfs(i):
        print('No')
        break
        

### FIXED CODE ###

# -*- coding: utf-8 -*-
# https://atcoder.jp/contests/abc126/tasks/abc126_d

import sys
sys.setrecursionlimit(100000)

def dfs(i):
  for v,w in V.get(i, []):
    if (w % 2) == 0:
      if color[v] == -1:
        color[v] = color[i]
      elif color[v] == color[i]:
        continue
      elif color[v] != color[i]:
        return False
    else:
      if color[v] == -1:
        color[v] = 0 if color[i] else 1
      elif color[v] == color[i]:
        return False
      elif color[v] != color[i]:
        continue
    dfs(v)
  return True

if __name__ == '__main__':
  n = int(input())
  V = {} # key:vertex, value:[[vertex opposited, wight]]
  color = {} # 0 or 1 or -1
  for i in range(1, n):
    u,v,w = map(int, input().split())
    if not V.get(u, False):
      V[u] = [[v,w]]
    else:
      V[u].append([v,w])

    if not V.get(v, False):
      V[v] = [[u,w]]
    else:
      V[v].append([u,w])
    # 同じ頂点間で複数の辺はないと仮定
  for i in range(1, n+1):
    color[i] = -1

  while True:
    i = 0
    for j in range(1, n+1):
      if color[j] == -1:
        i = j
        color[i] = 0
        break
    if i == 0:
      for j in range(1, n+1):
        print(color[j])
      break
    else:
      if not dfs(i):
        print('No')
        break