Harryxun/stf_run huggingface dataset:
import sys

n=input()
h=list()
count=1
for i in range(n):
  h.append(input());
  if i==1:
    max=h[i]
  else:
    if h[i]>=max:
      max=h[i]
      count++
print(count)
      

### FIXED CODE ###

import sys
 
n=int(input())
h=input().split()
count=0
max=int(h[0])
for i in range(n):
  if int(h[i])>=max:
    max=int(h[i])
    count+=1
print(count)
# coding: utf-8


def main():
    a, b = map(float, input().split())

    a = int(a)
    b = str(b)
    # print(b)
    b = b[0] + b[2] + b[3]
    b = int(b)
    # print(b)
    # exit()
    
    return a*b // 100


print(main())


### FIXED CODE ###

# coding: utf-8


def main():
    a, b = map(str, input().split())
    # print(b)

    a = int(a)
    b = str(b)
    # print(b)
    if len(b) == 1:
        b = b[0] + "00"
    elif len(b) == 3:
        b = b[0] + b[2] + "0"
    else:
        b = b[0] + b[2] + b[3]
    # b = b[0] + b[2] + b[3]
    b = int(b)
    # print(b)
    # exit()
    
    return a*b // 100


print(main())
import numpy as np
N = int(input())
A = input().split() 
A = np.array(A).astype(type(N))

T = np.zeros((N,N))
for i in range(N):
    T[i,i%N] = 1
    T[i,(i+1)%N] = 1
    
inv_T = np.linalg.inv(T)
X = np.dot(inv_T , A.T).astype('int32') *2

for i in X:
    print("{} ".format(i) ,end="")

### FIXED CODE ###

import numpy as np
N = int(input())
A = input().split()
A = np.array(A).astype(type(N))
S = np.sum(A)

SS = np.array([A[i] for i in range(1,A.shape[0],2)])

X = np.zeros((N))
X[0] = S -2*sum(SS)
for i in range(0,N-1):
    X[i + 1] = 2*A[i] - X[i]  

for i in X:
    print("{} ".format(int(i)),end="")
N,M = map(int,input().split())
l = [list(map(int,input().split())) for i
     in range(N)]
for i in range(N):
  del l[i][0]

for i in range(N-1):
  a = set(l[i])&set(l[i+1])
  l[i+1] = a
print(len(a))

### FIXED CODE ###

A,B = map(int,input().split())
if B%A == 0 :
  print(A+B)

else:
  print(B-A)
def pie(A, P):
    P_cra = A*3
 
    P_all = P_cra + P
 
    pie = P_all//2
 
    print(pie)

A = input()
P = input()
pie(int(A), int(P))

### FIXED CODE ###

def pie(A, P):
    P_cra = A*3
 
    P_all = P_cra + P
 
    pie = P_all//2
 
    print(pie)

l = list(map(int, input().split()))
A = int(l[0])
P = int(l[1])
pie(A, P)
N, K = map(int, input().split(" "))
towns = list(map(lambda x: int(x)-1, input().split(" ")))
assert len(towns) == N

# print(towns)

# score = {0: 0}
# current = 0
# move = 0
# while 1:
#   next_town = towns[current]
#   move += 1
#   # print(f"move {current} to {next_town}")
#   if score.get(next_town) is not None:
#     # print(f"find loop!")
#     loop_move = move - score.get(next_town)
#     loop_town = next_town
#     until_loop = score.get(next_town)
#     # print(f"loop start town : ", loop_town)
#     # print(f"cost to start to loop town : ", until_loop)
#     # print(f"loop length : ", loop_move)
#     break
#   score[next_town] = move
#   current = next_town

# if K < until_loop:
#   result = 0
#   for k in range(K):
#     result = towns[result]
# else:
#   result = loop_town
#   for k in range((K - until_loop) % loop_move):
#     result = towns[result]
# print(result + 1)

visited = []
current = 0
while 1:
  if K == 0:
    break
  current = towns[current]
  K -= 1
  if current in visited:
    L = 0
    tcurrent = current
    while 1:
      tcurrent = towns[tcurrent]
      L += 1
      if tcurrent == current:
        break
    break
  visited.append(current)

K = K % L
for _ in range(K):
  current = towns[current]
print(current + 1)


### FIXED CODE ###

N, K = map(int, input().split(" "))
towns = list(map(lambda x: int(x)-1, input().split(" ")))
assert len(towns) == N

# print(towns)

score = {0: 0}
current = 0
move = 0
while 1:
  next_town = towns[current]
  move += 1
  # print(f"move {current} to {next_town}")
  if score.get(next_town) is not None:
    # print(f"find loop!")
    loop_move = move - score.get(next_town)
    loop_town = next_town
    until_loop = score.get(next_town)
    # print(f"loop start town : ", loop_town)
    # print(f"cost to start to loop town : ", until_loop)
    # print(f"loop length : ", loop_move)
    break
  score[next_town] = move
  current = next_town

if K < until_loop:
  result = 0
  for k in range(K):
    result = towns[result]
else:
  result = loop_town
  for k in range((K - until_loop) % loop_move):
    result = towns[result]
print(result + 1)
while True:
    x,y = map(int,raw_input().split(" "))
    if (x,y) == (0,0): 
        break
    elif (x < y):
        print x, y
    else :
        print y, x


### FIXED CODE ###

while True:
    x,y = map(int,input().split())
    if x == 0 and y == 0:
        break
    if x > y:
        x,y = y,x
    print("%d %d" %(x,y))
while 1:
????????T,U,N,E,W,S=1,6,5,3,4,2
????????n=input()
????????if n==0:
        break
????????ans=T
????????for i in range(n):
????????????????di=raw_input()
????????????????if di=="North":
????????????????????????N,T,S,U=T,S,U,N
????????????????elif di=="East":
????????????????????????E,U,W,T=T,E,U,W
????????????????elif di=="South":
????????????????????????T,S,U,N=N,T,S,U
????????????????elif di=="West":
????????????????????????T,E,U,W=E,U,W,T
????????????????elif di=="Left":a
????????????????????????E,S,W,N=S,W,N,E
????????????????elif di=="Right":
????????????????????????S,W,N,E=E,S,W,N
????????????????ans+=T
????????print ans

### FIXED CODE ###

while(1):
    num=int(raw_input())
    if num==0:
        break
    else:
        d=[0,1,2,3,4,5,6]
        sum=1
        for i in range(num):
            dir=num=raw_input()
            if dir=="North":
                d=[0,d[2],d[6],d[3],d[4],d[1],d[5]]
            elif dir=="East":
                d=[0,d[4],d[2],d[1],d[6],d[5],d[3]]
            elif dir=="West":
                d=[0,d[3],d[2],d[6],d[1],d[5],d[4]]
            elif dir=="South":
                d=[0,d[5],d[1],d[3],d[4],d[6],d[2]]
            elif dir=="Right":
                d=[0,d[1],d[3],d[5],d[2],d[4],d[6]]
            else:
                d=[0,d[1],d[4],d[2],d[5],d[3],d[6]]
            sum=sum+d[1]
        print sum
N = int(input())
S = input()

ct = 0
if S[0] != S[1]:
    ct += 1

for i in range(N):
    if i % 4 <= 1:
        if S[i] != S[1]:
            ct += 1
    else:
        if S[i] == S[1]:
            ct += 1

print(ct)

### FIXED CODE ###

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

left_black = 0
right_white = S.count('.')
ans = right_white

for i in range(N):
    if S[i] == '#':
        left_black += 1 
    else:
        right_white -= 1
    ans = min(ans, left_black + right_white)
print(ans)
K=int(input())
s=input()
S=len(s)
mod=10**9+7
MAX_N=10**6
fact=[1]
fact_inv=[0]*(MAX_N+4)
for i in range(MAX_N+3):
  fact.append(fact[-1]*(i+1)%mod)

fact_inv[-1]=pow(fact[-1],mod-2,mod)
for i in range(MAX_N+2,-1,-1):
  fact_inv[i]=fact_inv[i+1]*(i+1)%mod

def mod_comb_k(n,k,mod):
  return fact[n]*fact_inv[k]%mod*fact_inv[n-k] %mod

cnt=0
for i in range(K+1):
  a=(pow(26,i,mod)*pow(25,K-i,mod))*(mod_comb_k(K+S-i-1,S-1,mod))
  a%=mod
  cnt+=a
  cnt%=mod
print(cnt)

### FIXED CODE ###

K=int(input())
s=input()
S=len(s)
mod=10**9+7
MAX_N=10**7
fact=[1]
fact_inv=[0]*(MAX_N+4)
for i in range(MAX_N+3):
  fact.append(fact[-1]*(i+1)%mod)

fact_inv[-1]=pow(fact[-1],mod-2,mod)
for i in range(MAX_N+2,-1,-1):
  fact_inv[i]=fact_inv[i+1]*(i+1)%mod

def mod_comb_k(n,k,mod):
  return fact[n]*fact_inv[k]%mod*fact_inv[n-k] %mod

cnt=0
for i in range(K+1):
  a=(pow(26,i,mod)*pow(25,K-i,mod))*(mod_comb_k(K+S-i-1,S-1,mod))
  a%=mod
  cnt+=a
  cnt%=mod
print(cnt)
a,b,k=map(int,input().split())
r1=[i for i in range(a,min(b+1,a+k))]
r2=[i for i in range(max(a,b-k+1),b+1)]
r1.extend(r2)
result=set(r1)
for i in sorted(result):
    print(i)

### FIXED CODE ###

S=str(input())
if 'a' in S and 'b' in S and 'c' in S:
    print('Yes')
else:
    print('No')
s = list(map(int,input().split()))
N = s[0]
X = s[1]
L = list(map(int,input().split()))
a = 0
d = 0
while d <= X:
  if a >= N+1:
    a = N+1
    break
  d += L[a]
  a += 1 

print(a)
  

### FIXED CODE ###

s = list(map(int,input().split()))
N = s[0]
X = s[1]
L = list(map(int,input().split()))
a = 0
d = 0
while d <= X:
  if a >= N:
    a = N+1
    break
  else:
    d += L[a]
    a += 1 

print(a)
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n,m =I2()
    h = Intl()
    l = [[] for i in range(n)]
    cnt = 0
    for i in range(m):
        a,b = I2()
        l[a-1].append(b)
        l[b-1].append(a)
    for i in range(n):
        if len(l[i]) == 0:cnt +=1
        for j in l[i]:
            if h[i] > h[j-1]:
                f = True
            else:
                f = False
                break
        if f:cnt += 1
    print(cnt)

### FIXED CODE ###

import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n,m =I2()
    h = Intl()
    l = [[] for i in range(n)]
    cnt = 0
    for i in range(m):
        a,b = I2()
        l[a-1].append(b)
        l[b-1].append(a)
    #print(l)
    for i in range(n):
        if len(l[i]) == 0:
            cnt +=1
            continue
        #print(cnt)
        for j in l[i]:
            if h[i] > h[j-1]:
                f = True
            else:
                f = False
                break
        if f:cnt += 1
    print(cnt)
S = input()

a = 10*int(S[0])+int(S[1])
b = 10*int(S[2])+int(S[3])

if a>12 and b>12:
    print('NA')
elif a>12 and 1<=b<=12:
    print('YYMM')
elif 1<=a<=12 and b>12:
    print('MMYY')
else:
    print('AMBIGUOUS')


### FIXED CODE ###

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

p = input()

print(p[:k-1] + p[k-1].lower() + p[k:])
N = int(input())
V = list(map(int, input().split()))


def m():
    first = V[0::2]
    second = V[1::2]
    fdic = {}
    sdic = {}
    for i in range(N//2):
        if fdic.get(first[i], 0) == 0:
            fdic[first[i]] = 1
        else:
            fdic[first[i]] +=1

        if sdic.get(second[i], 0) == 0:
            sdic[second[i]] = 1
        else:
            sdic[second[i]] +=1
    flist = list(fdic.items())
    slist = list(sdic.items())

    flist.sort(reverse=True, key=lambda x:x[1])
    slist.sort(reverse=True, key=lambda x:x[1])

    if flist[0][0] != slist[0][0] and len(flist) == 1 and len(slist) == 1:
        return 0

    if flist[0][0] != slist[0][0]:
        ans = 0
        for k, v in flist[1:]:
            ans += v
        for k, v in slist[1:]:
            ans += v
        return ans

    if flist[0][1] > slist[0][1]:
        ans = 0
        for k, v in flist[1:]:
            ans += v
        for k, v in slist[2]:
            ans += v
        ans += slist[0][0]
        return ans
    else:
        ans = 0
        for k, v in slist[1:]:
            ans += v
        for k, v in flist[2]:
            ans += v
        ans += flist[0][0]
        return ans

print(m())

### FIXED CODE ###

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


def m():
    first = V[0::2]
    second = V[1::2]
    fdic = {}
    sdic = {}
    for i in range(N//2):
        if fdic.get(first[i], 0) == 0:
            fdic[first[i]] = 1
        else:
            fdic[first[i]] +=1

        if sdic.get(second[i], 0) == 0:
            sdic[second[i]] = 1
        else:
            sdic[second[i]] +=1
    flist = list(fdic.items())
    slist = list(sdic.items())

    flist.sort(reverse=True, key=lambda x:x[1])
    slist.sort(reverse=True, key=lambda x:x[1])

    if len(flist) == 1 and len(slist) == 1:
        if flist[0][0] == slist[0][0]:
            return N//2
        return 0
    if len(flist) == 1:
        return N//2 - slist[0][1]
    if len(slist) == 1:
        return N//2 - flist[0][1]

    if flist[0][0] != slist[0][0]:
        ans = 0
        for k, v in flist:
            if k != flist[0][0]:
                ans += v
        for k, v in slist:
            if k != slist[0][0]:
                ans += v
        return ans

    fans = 0
    sans = 0
    for k, v in flist:
        if k != flist[0][0]:
            fans += v
    for k, v in slist:
        if k != slist[1][0]:
            fans += v

    for k, v in flist:
        if k != flist[1][0]:
            sans += v
    for k, v in slist:
        if k != slist[0][0]:
            sans += v
    return min(fans,sans)

print(m())
from functools import lru_cache
L = int(input(),2)
MOD = 10**9+7
@lru_cache(None)
def f(n):
  if n==1:
    return 3
  elif n==0:
    return 1
  a = n>>1
  if n%2==1:
    return (f(a)*3)%MOD
  return (f(a)+f(a-1)*2)%MOD

print(f(L))

### FIXED CODE ###

L = input()
MOD = 10**9+7

pow_3=[1]
for _ in range(2*10**5):
  pow_3.append((pow_3[-1]*3)%MOD)
  
pow_2=[1]
for _ in range(2*10**5):
  pow_2.append((pow_2[-1]*2)%MOD)
  
count = L.count('1')
ans = pow_2[count]

for i in range(len(L)-1,-1,-1):
  if L[i]=='1':
    count -= 1
    m = pow_3[len(L)-i-1]*pow_2[count]
    ans += m
    ans %= MOD
print(ans)
n,m = map(int,input().split())

if m==0:
  print(0)
  exit()

s = []
c = []
for i in range(m):
  sc = input().replace(' ','')
  s.append(int(sc[-2]))
  c.append(int(sc[-1]))

s1 = []
s2 = []
s3 = []
c1 = []
c2 = []
c3 = []
for i in range(m):
  if s[i] == 1 and not s1:
    s1.append(s[i])
    c1.append(c[i])
  elif s[i] == 1 and s1 and c[i] == c1[0]:
    next
  elif s[i] == 1 and s1 and c[i] != c1[0]:
    print(-1)
    exit()
  elif s[i] == 2 and not s2:
    s2.append(s[i])
    c2.append(c[i])
  elif s[i] == 2 and s2 and c[i] == c2[0]:
    next
  elif s[i] == 2 and s2 and c[i] != c2[0]:
    print(-1)
    exit()
  elif s[i] == 3 and not s3:
    s3.append(s[i])
    c3.append(c[i])
  elif s[i] == 3 and s3 and c[i] == c3[0]:
    next
  elif s[i] == 3 and s3 and c[i] != c3[0]:
    print(-1)
    exit()
ans = 0
if c1[0]==0:
  print(-1)
  exit()
elif not c1:
  next
else:
  ans+=c1[0]*100

if not c2:
  next
else:
  ans+=c2[0]*10

if not c3:
  next
else:
  ans+=c3[0]

print(ans)

### FIXED CODE ###

n,m = map(int,input().split())
c1 = []
c2 = []
c3 = []
for i in range(m):
  sc = list(map(int,input().split()))
  if sc[0] == 1:
    c1.append(sc[1])
  elif sc[0] == 2:
    c2.append(sc[1])
  else:
    c3.append(sc[1])

if len(set(c1)) <= 1 and len(set(c2)) <= 1 and len(set(c3)) <= 1:
  if 0 in list(set(c1)):
    if n == 1 and len(set(c1)) == 1 and len(set(c2)) == 0 and len(set(c3)) == 0:
      print('0')
      exit()
    else:
      print('-1')
      exit()
  elif not c1 and not c2 and not c3:
    if n == 1:
      print('0')
      exit()
    elif n == 2:
      print('10')
      exit()
    else:
      print('100')
      exit()
  else:
    if list(set(c1)):
      ans_c1 = list(set(c1))[0]
    else:
      ans_c1 = 1
    if list(set(c2)):
      ans_c2 = list(set(c2))[0]
    else:
      ans_c2 = 0
    if list(set(c3)):
      ans_c3 = list(set(c3))[0]
    else:
      ans_c3 = 0
else:
  print('-1')
  exit()

if n == 1:
  print(ans_c1)
elif n == 2:
  print(ans_c1*10 + ans_c2)
else:
  print(ans_c1*100 + ans_c2*10 + ans_c3)
import copy


class Line:
    def __init__(self, a, b):
        self.a = a
        self.b = b


def generate_patterns(remains, current_pattern, patterns):
    if len(remains) == 0:
        patterns.append(current_pattern)
        return
    for remain in remains:
        _current_pattern = copy.copy(current_pattern)
        _current_pattern.append(remain)
        _remains = copy.copy(remains)
        _remains.remove(remain)
        generate_patterns(_remains, _current_pattern, patterns)
    return patterns


N, M = map(int, input().split())
lines = []
for _ in range(N):
    a, b = map(int, input().split())
    lines.append(Line(a, b))

m = {}
for i in range(1, N+1):
    m[i] = {}
    for j in range(1, N+1):
        m[i][j] = False

for line in lines:
    m[line.a][line.b] = True
    m[line.b][line.a] = True

remains = []
for i in range(2, N+1):
    remains.append(i)
patterns = generate_patterns(remains, [1], [])

cnt = 0
for pattern in patterns:
    countable = True
    for i in range(len(pattern)-1):
        current = pattern[i]
        next = pattern[i+1]
        if not(m[current][next]):
            countable = False
            break
    if countable:
        cnt += 1

print(cnt)


### FIXED CODE ###

import copy


class Line:
    def __init__(self, a, b):
        self.a = a
        self.b = b


def generate_patterns(remains, current_pattern, patterns):
    if len(remains) == 0:
        patterns.append(current_pattern)
        return
    for remain in remains:
        _current_pattern = copy.copy(current_pattern)
        _current_pattern.append(remain)
        _remains = copy.copy(remains)
        _remains.remove(remain)
        generate_patterns(_remains, _current_pattern, patterns)
    return patterns


N, M = map(int, input().split())
lines = []
for _ in range(M):
    a, b = map(int, input().split())
    lines.append(Line(a, b))

m = {}
for i in range(1, N+1):
    m[i] = {}
    for j in range(1, N+1):
        m[i][j] = False

for line in lines:
    m[line.a][line.b] = True
    m[line.b][line.a] = True

remains = []
for i in range(2, N+1):
    remains.append(i)
patterns = generate_patterns(remains, [1], [])

cnt = 0
for pattern in patterns:
    countable = True
    for i in range(len(pattern)-1):
        current = pattern[i]
        next = pattern[i+1]
        if not(m[current][next]):
            countable = False
            break
    if countable:
        cnt += 1

print(cnt)
import sys


def root(x):
    if parent[x] == x:
        return x
    else:
        r = parent[x] = root(parent[x])
        return r


def unite(x, y):
    x = root(x)
    y = root(y)
    if x != y:
        parent[x] = y
        new_size = size_list[x] + size_list[y]
        size_list[x] = new_size
        size_list[y] = new_size


if __name__ == '__main__':
    input = sys.stdin.readline
    n, m = map(int, input().split())
    input_list = [list(map(int, input().split())) for _ in range(m)]
    parent = [i for i in range(n)]
    size_list = [1] * n
    ans_list = []
    ans = int(n*(n-1)/2)
    for a, b in input_list[::-1]:
        ans_list.append(ans)
        if root(a-1) != root(b-1):
            ans -= size_list[a-1] * size_list[b-1]
            unite(a-1, b-1)
    for ans in ans_list[::-1]:
        print(ans)


### FIXED CODE ###

import sys


def root(x):
    if parent[x] < 0:
        return x
    else:
        parent[x] = root(parent[x])
        return parent[x]


def unite(x, y):
    x = root(x)
    y = root(y)
    if x == y:
        return False
    else:
        if y > x:
            x, y = y, x
        parent[x] += parent[y]
        parent[y] = x
        return True


def size(node):
    return -parent[root(node)]

if __name__ == '__main__':
    input = sys.stdin.readline
    n, m = map(int, input().split())
    input_list = [list(map(int, input().split())) for _ in range(m)]
    parent = [-1] * n
    ans_list = []
    ans = int(n*(n-1)/2)
    for a, b in input_list[::-1]:
        ans_list.append(ans)
        tmp = size(a-1) * size(b-1)
        if unite(a-1, b-1):
            ans -= tmp

    for ans in ans_list[::-1]:
        print(ans)
def gcd(a,b):
    if(b==0): 
        return a 
    else: 
        return gcd(b,a%b)

n = int(input())
a = list(map(int,input().split()))
res = []
for i in range(0,n):
    for j in range(0,n):
        if i != j:
            res.append(gcd(a[i],a[j]))
print(max(res))

### FIXED CODE ###

a,b,t=map(int,input().split());print(int(t/a)*b)
N = int(input())
h = tuple(map(int, input().split()))
cost = [None]*N

def DP(n):
    if cost[n] != None:
        return cost[n]
    
    if n==0:
        return 0
    elif(n > 1):
        cost[n] = min(DP(n-1) + abs(h[n] - h[n-1]), DP(n-2) + abs(h[n] - h[n-2]))
        return cost[n]
    else:
        cost[n] = DP(n-1) + abs(h[n] - h[n-1])
        return cost[n]


print(DP(N-1))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

N = int(sys.stdin.readline())
h = tuple(map(int, sys.stdin.readline().split()))
cost = [None]*N

def DP(n):
    if cost[n] != None:
        return cost[n]
    
    if n==0:
        return 0
    elif(n > 1):
        cost[n] = min(DP(n-1) + abs(h[n] - h[n-1]), DP(n-2) + abs(h[n] - h[n-2]))
        return cost[n]
    else:
        cost[n] = DP(n-1) + abs(h[n] - h[n-1])
        return cost[n]


print(DP(N-1))
n,k = map(int,input().split())
h = sorted(list(map(int, [input() for i in range(n)])))
ans = h[n-1]
for j in range(n-k+1):
    ans = min(ans, (h[j+k]-h[j]))
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
h = [int(input()) for i in range(N)]
h.sort()
print(min(h[i+K-1] - h[i] for i in range(N-K+1)))
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sum_A = [0]
for i,a in enumerate(A, 1):
    tmp = sum_A[i-1] + a
    if tmp <= K:
        sum_A.append(tmp)
        mark_A = i
    else:
        break
    
sum_B = [0]
for i,b in enumerate(B, 1):
    tmp = sum_B[i-1] + b
    if tmp <= K:
        sum_B.append(tmp)
        mark_B = i
    else:
        break
    
ans = 0
    
for i,a in enumerate(sum_A):
    for j in range(mark_B, -1, -1):
        if a + sum_B[j] > K:
            pass
        else:
            ans = max(ans, i+j)
            break
            
print(ans)

### FIXED CODE ###

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

sum_A = [0]
for i,a in enumerate(A, 1):
    tmp = sum_A[i-1] + a
    if tmp <= K:
        sum_A.append(tmp)
        mark_A = i
    else:
        break
    
sum_B = [0]
for i,b in enumerate(B, 1):
    tmp = sum_B[i-1] + b
    if tmp <= K:
        sum_B.append(tmp)
        mark_B = i
    else:
        break
    
ans = 0
j = len(sum_B) - 1

for i,a in enumerate(sum_A):
    while sum_B[j] > K - a:
        j -= 1
        
    ans = max(ans, i+j)
    
print(ans)
n = int(input())
if n == 1:
    print(1)
else:
    edge=[[] for _ in range(n)]
    for _ in range(n-1):
        u,v,w = map(int,input().split())
        edge[u-1].append((v-1,w%2))
        edge[v-1].append((u-1,w%2))

    color =[-1]*n
    def dfs(node,edge):
        for next_node,w in edge[node]:
            if color[next_node] != -1:
                continue
            if w == 1:
                color[next_node] = color[node]^1
            elif w == 0:
                color[next_node] = color[node]
            dfs(next_node,edge)
        
        
    color[0] = 0
    dfs(0,edge)
    print(*color,sep="\n")

### FIXED CODE ###

import sys

sys.setrecursionlimit(10**6)

n = int(input())
if n == 1:
    print(1)
else:
    edge=[[] for _ in range(n)]
    for _ in range(n-1):
        u,v,w = map(int,input().split())
        edge[u-1].append((v-1,w%2))
        edge[v-1].append((u-1,w%2))
 
    color =[-1]*n
    def dfs(node,edge):
        for next_node,w in edge[node]:
            if color[next_node] != -1:
                continue
            if w == 1:
                color[next_node] = color[node]^1
            elif w == 0:
                color[next_node] = color[node]
            dfs(next_node,edge)
        
        
    color[0] = 0
    dfs(0,edge)
    print(*color,sep="\n")