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

import numpy as np
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=np.array(a)
a=np.sort(a)
for i in range(m):
  a[-1]=a[-1]//2
  a=np.sort(a)
print(sum(a))

### FIXED CODE ###

import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=list(map(lambda x:x*(-1),a))
heapq.heapify(a)
for i in range(m):
  mini=heapq.heappop(a)
  mini=(-1)*((-mini)//2)
  heapq.heappush(a,mini)
print(sum(a)*(-1))
### BUGGY CODE ###

S=input()
N=len(S)
from collections import defaultdict
O=[defaultdict(int) for i in range(N+1)]
O[0][5]=1
mod=10**9+7
for i in range(N):
    for o in O[i].keys():
        if S[N-1-i]!='?':
            n=int(S[N-1-i])
            for j in range(10):
                x=13*j+o
                if x%10==n:
                    O[i+1][x//10]=O[i][o]
                    break
        else:
            for j in range(10):
                x=13*j+o
                O[i+1][x//10]=(O[i+1][x//10]+O[i][o])%mod
print(O[N][0])

### FIXED CODE ###

S=input()
N=len(S)
from collections import defaultdict
O=[defaultdict(int) for i in range(N+1)]
O[0][5]=1
mod=10**9+7
for i in range(N):
    for o in O[i].keys():
        if S[N-1-i]!='?':
            n=int(S[N-1-i])
            for j in range(10):
                x=13*j+o
                if x%10==n:
                    O[i+1][x//10]=O[i][o]
                    break
        else:
            for j in range(10):
                x=13*j+o
                O[i+1][x//10]=(O[i+1][x//10]+O[i][o])%mod
print(O[N][0])
### BUGGY CODE ###

s = input()
q = int(input())

sei_or_gyaku = 1
mae = ''
ato = ''

for i in range(q):
    sirei = input()
    if len(sirei) == 1:
        ti = int(sirei)
        sei_or_gyaku *= -1
    else:
        ti, fi, ci = map(str, sirei.split())
        ti, fi = int(ti), int(fi)
        if fi == 1:
            if sei_or_gyaku == 1:
                mae = ci + mae
            else:
                ato = ato + ci
        else:
            if sei_or_gyaku == 1:
                ato = ato + ci
            else:
                mae = ci + mae

ans = mae + s + ato
if sei_or_gyaku == 1:
    print(ans)
else:
    print(ans[::-1])

### FIXED CODE ###

s = input()
q = int(input())

sei_or_gyaku = 1
mae = ''
ato = ''

for i in range(q):
    sirei = input()
    if len(sirei) == 1:
        ti = int(sirei)
        sei_or_gyaku *= -1
    else:
        ti, fi, ci = map(str, sirei.split())
        ti, fi = int(ti), int(fi)
        if fi == 1:
            if sei_or_gyaku == 1:
                mae += ci
            else:
                ato += ci
        else:
            if sei_or_gyaku == 1:
                ato += ci
            else:
                mae += ci

mae = mae[::-1]
ans = mae + s + ato
if sei_or_gyaku == 1:
    print(ans)
else:
    print(ans[::-1])
### BUGGY CODE ###

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

dp = [10**9+7]*N
dp[0] = 0

# 足場 i までにたどり着くまでに最小のコスト
for i in range(1,N):
    #for j in range(max(i-K,0),i)はジャンプして位置iまで行ける足場の範囲
    for j in range(max(i-K,0),i):
        dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]))

print(dp[-1])

### FIXED CODE ###

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

dp = [0]*N

#iは知りたいdp[i]
for i in range(1,N):
    #for j in range(max(i-K,0),i)はジャンプできる段数
    dp[i] = min(dp[j]+abs(h[j]-h[i]) for j in range(max(i-K,0),i))
print(dp[N-1])
### BUGGY CODE ###

#coding: utf-8
import sys
import math
N, M = map(int, input().split())
if abs(N-M) > 1:
    print(0)
    sys.exit()
elif N == M:
    ans = math.factorial(N) * math.factorial(M) * 2
else:
    ans = math.factorial(N) * math.factorial(M)
print(ans)


### FIXED CODE ###

#coding: utf-8
import sys

memo = {1:1}
def factorial(n):
    for i in range(len(memo)+1,n+1):
        if n not in memo:
            memo[i] = memo[i-1] * i % int(1e9+7)
    return memo[n]

N, M = map(int, input().split())
if abs(N-M) > 1:
    print(0)
    sys.exit()
elif N == M:
    ans = factorial(N) * factorial(M) * 2
else:
    ans = factorial(N) * factorial(M)
ans = ans % int(1e9+7)
print(ans)
### BUGGY CODE ###

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

dp = [[[0]*(3*n+1) for _ in range(n)] for _ in range(n)]

w1,v1 = map(int,input().split())
for i in range(3*n+1):
    dp[0][0][i] = v1

for i in range(1,n):
    w,v = map(int,input().split())
    w -= w1
    for j in range(n):
        for k in range(3*n+1):
            if j>0 and k>=w:
                dp[i][j][k] = max(dp[i-1][j][k], dp[i-1][j-1][k-w] + v)
            elif k>=w:
                dp[i][0][k] = max(dp[i-1][0][k], v)
            else:
                dp[i][j][k] = dp[i-1][j][k]

ans = 0
for i in range(n):
    for j in range(3*n+1):
        if w1*(i+1) + j>W: continue
        ans = max(ans,dp[-1][i][j])

print(ans)

### FIXED CODE ###

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

dp = [[[0]*(3*n+1) for _ in range(n)] for _ in range(n)]

w1,v1 = map(int,input().split())
for i in range(3*n+1):
    dp[0][0][i] = v1

for i in range(1,n):
    w,v = map(int,input().split())
    w -= w1
    for j in range(min(i+1,n)):
        for k in range(3*n+1):
            if j>0 and k>=w:
                dp[i][j][k] = max(dp[i-1][j][k], dp[i-1][j-1][k-w] + v)
            elif k>=w:
                dp[i][0][k] = max(dp[i-1][0][k], v)
            else:
                dp[i][j][k] = dp[i-1][j][k]

ans = 0
for i in range(n):
    for j in range(3*n+1):
        if w1*(i+1) + j>W: continue
        ans = max(ans,dp[-1][i][j])

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

import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline

sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    K = int(readline())
    if K%2==0:
        print(-1)
    else:
        seven = 7
        amari = [7]
        ans = 1
        while True:
            seven = seven%K
            if seven==0:
                print(ans)
                break
            else:
                seven = seven*10+7

                if seven in amari:
                    print(-1)
                    break
                ans += 1
                amari.append(seven)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline

sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    K = int(readline())
    if K%2==0:
        print(-1)
    else:
        seven = 7
        amari = set([7])
        ans = 1
        while True:
            seven = seven%K
            if seven==0:
                print(ans)
                break
            else:
                seven = seven*10+7
                if seven in amari:
                    print(-1)
                    break
                ans += 1
                amari.add(seven)


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

import functools
n = int(input())
a_list = list(map(int,input().split()))

def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            x,y = y,x%y
        return y

res = []
tmp = []
for _ in range(n):
    e = a_list.pop(0)
    if e in tmp:
        continue
    res.append(functools.reduce(gcd, a_list))
    a_list.append(e)
    tmp.append(e)

print(max(res))

### FIXED CODE ###

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

def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if y==0:
        return x
    else:
        while x%y!=0:
            x,y = y,x%y
        return y

res = []
l_gcd = [0]*(n+2)
r_gcd = [0]*(n+2)
for i in range(n+1):
    if i ==0:
        l_gcd[i] = 0
        r_gcd[n-i+1] = 0
        continue
    l_gcd[i] = gcd(l_gcd[i-1], a_list[i-1])
    r_gcd[n-i] = gcd(r_gcd[n-i+1], a_list[n-i])

for i in range(n+1):
    res.append(gcd(l_gcd[i],r_gcd[i+1]))

print(max(res))
### BUGGY CODE ###

A, B = map(int, input().split())
 
i=0
while i<10000:
  if A*0.08==i and B*0.1==i:
    print(i)
    quit()
print(-1)

### FIXED CODE ###

A,B = map(int,input().split())
i=1
while i<=10000:
  if (int(i * 0.08) == A) & (int(i * 0.10) == B):
    print(i)
    exit()
  i+=1
print(-1)
### BUGGY CODE ###

from collections import deque
 
h,w=[int(x) for x in input().rstrip().split()]
l=[[s for s in input()]for i in range(h)]

black=sum(s.count("#") for s in l)
dist=[[False for j in range(w)] for i in range(h)]
done=[[float('inf') for j in range(w)] for i in range(h)]
move=[[1,0],[-1,0],[0,1],[0,-1]]

def bfs():
  stack=deque([[0,0]])
  done[0][0]=0
  while(stack):
    x,y=stack.popleft()
    dist[y][x]=True

    if y==h-1 and x==w-1:
        return done[h-1][w-1]

    for dx,dy in move:
      mx,my=x+dx,y+dy
      if (0<=my<=h-1) and (0<=mx<=w-1) and l[my][mx]=="." and dist[my][mx]==False:
        done[my][mx]=done[y][x]+1
        stack.append([mx,my])
  return done[h-1][w-1]
 
if bfs()!=float('inf'):print(h*w-done[h-1][w-1]-black-1)
else:print(-1)


### FIXED CODE ###

import sys
 
h,w=[int(x) for x in input().rstrip().split()]
l=[]
black=0
for i in range(h):
  s=[x for x in input()]
  l.append(s)
  black+=sum(j.count("#") for j in s)
 
done=[[float('inf')]*w for i in range(h)]
def bfs():
  stack=[[0,0]]
  done[0][0]=0
  while(stack):
    x,y=stack.pop(0)
    move=[[x+1,y],[x-1,y],[x,y+1],[x,y-1]]
 
    for mx,my in move:
      if not(0<=my<=h-1) or not(0<=mx<=w-1) or l[my][mx]=="#" or done[my][mx]!=float('inf'):
        continue

      done[my][mx]=done[y][x]+1
      stack.append([mx,my])
      
      if my==h-1 and mx==w-1:
        print(h*w-done[my][mx]-black-1)
        sys.exit()
  print(-1)
 
if __name__=="__main__":
  bfs()
### BUGGY CODE ###

n,m,k=map(int,input().split())
fr=[input() for i in range(m)]
bl=[input() for i in range(k)]
relfr=[[] for i in range(n)]
relbl=[[] for i in range(n)]
for l in fr:
  a,b=map(int,l.split())
  relfr[a-1].append(b-1)
  relfr[b-1].append(a-1)
for l in bl:
  a,b=map(int,l.split())
  relbl[a-1].append(b-1)
  relbl[b-1].append(a-1)
cand=[0]
searched=set()
gr=[]
all_gr={i for i in range(n)}
ans=['']*n
while all_gr!=searched:
  while len(cand)!=0:
    now=cand.pop()
    gr.append(now)
    for point in relfr[now]:
      if not point in gr and not point in cand:
        cand.append(point)
  for i in gr:
    ans[i]=str(len(gr)-len(relfr[i])-len([0 for _ in relbl[i] if _ in gr])-1)
    searched.add(i)
  gr=[]
  if all_gr!=searched:
    cand.append(list(all_gr-searched)[0])
print(' '.join(ans))

### FIXED CODE ###

n,m,k=map(int,input().split())
relfr={i:set() for i in range(n)}
relbl={i:set() for i in range(n)}
for i in range(m):
  a,b=map(int,input().split())
  relfr[a-1].add(b-1)
  relfr[b-1].add(a-1)
for i in range(k):
  a,b=map(int,input().split())
  relbl[a-1].add(b-1)
  relbl[b-1].add(a-1)
blsiz=[0 for i in range(n)]
ans=[0]*n
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
uf=UnionFind(n)
for i in range(n):
  for j in relfr[i]:
    uf.Unite(i,j)
for i in range(n):
  for j in relbl[i]:
    if uf.isSameGroup(i,j):
      blsiz[i]+=1
for i in range(n):
  ans[i]=uf.Count(i)-len(relfr[i])-blsiz[i]-1

print(' '.join(map(str,ans)))
### BUGGY CODE ###

K = int(input())
queue = []
for i in range(1, 10):
  queue.append(i)

while K != 0:
  num = queue.pop(0)
  K -= 1

  if K == 0:
    print(num)
    exit(0)

  o = int(str(num)[-1])
  for n in [o-1, o, o+1]:
    if n == -1 or n == 10: continue
    queue.append( int(str(num)+str(n)) )

### FIXED CODE ###

K = int(input())
queue = []
for i in range(1, 10):
  queue.append(i)

while K != 0:
  if K <= len(queue):
    print(queue[K-1])
    exit(0)

  K -= 1
  num = queue.pop(0)

  if K == 0:
    print(num)
    exit(0)

  o = int(str(num)[-1])
  for n in [o-1, o, o+1]:
    if n == -1 or n == 10: continue
    queue.append( int(str(num)+str(n)) )
### BUGGY CODE ###

n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort() ; B.sort() ; C.sort()
def isOK(A,mid,target):
    #条件を満たす領域とそうでない領域の境目！
    return target<A[mid]   #条件を満たす中で最小
    #return A[mid]<=target  #条件を満たす中で最大
def aa(A,target):
    ng=-1 ; ok=n  #okはその条件を満たしていることが大前提
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if isOK(A,mid,target): ok=mid
        else: ng=mid
    return ok

ans=0

for i in A:
    t=aa(B,i) 
    for q in range(t,n):
        ans+=n-aa(C,B[q])
        
print(ans)

### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort() ; B.sort() ; C.sort()
import bisect as bi

ans=0

for i in B:
    ans+= bi.bisect_left(A,i) * (n-bi.bisect_right(C,i))
print(ans)
### BUGGY CODE ###

from collections import deque

def bfs(graph, start, goal):
    visited = {start: None}
    unvisited = deque()
    unvisited.append(start)
    while unvisited:
        now = unvisited.popleft()
        if now == goal or goal in graph[now]:
            graph[start].add(goal)
            graph[goal].add(start)
            return "yes"
        for next in graph[now]:
            if not (next in visited):
                unvisited.append(next)
                visited[next] = now
    return "no"

n, m = map(int, input().split())
g = [set() for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    g[a].add(b)
    g[b].add(a)

q = int(input())

for i in range(q):
    s, t = map(int, input().split())
    print(bfs(g, s, t))

### FIXED CODE ###

from collections import deque

def bfs(graph, start):
    visited = {start: None}
    unvisited = deque()
    unvisited.append(start)
    while unvisited:
        now = unvisited.popleft()
        for next in graph[now]:
            if not (next in visited):
                unvisited.append(next)
                visited[next] = now
    return visited

n, m = map(int, input().split())
g = [set() for i in range(n)]
group = []

for i in range(m):
    a, b = map(int, input().split())
    g[a].add(b)
    g[b].add(a)

q = int(input())

for i in range(q):
    s, t = map(int, input().split())
    for j in range(len(group)):
        if s in group[j] and t in group[j]:
            print("yes")
            break
        elif s in group[j]:
            print("no")
            break
    else:
        group_tmp = set(bfs(g, s).keys())
        if t in group_tmp:
            print("yes")
        else:
            print("no")
        group.append(group_tmp)
### BUGGY CODE ###

from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()

for i in range(n, m+1):
    if m % i == 0:
        print(m//i)
        exit()

### FIXED CODE ###

from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

n, m = MAP()
a = sorted(divisor(m))
print(m//a[bisect_left(a,n)])
### BUGGY CODE ###

N = int(input())
D = [int(a) for a in input().split()]

num_at_dist = [1] + [0] * (N-1) + [0] # extra 0 at the end for index -1

if D[0] != 0:
    ans = 0
else:
    ans = 1
    D.sort()
    for i in range(1, N):
        dist = D[i]
        num_at_dist[dist] += 1
        ans *= num_at_dist[dist - 1]

print(ans % 998244353)

### FIXED CODE ###

import numpy as np

N = int(input())
D = np.array([int(a) for a in input().split()])

num_at_dist = np.array([1] + [0] * (N-1) + [0]) # extra 0 at the end for index -1

if D[0] != 0:
    ans = 0
else:
    ans = 1
    D = np.sort(D)
    for i in range(1, N):
        dist = D[i]
        num_at_dist[dist] += 1
        ans = ( ans * num_at_dist[dist - 1] ) % 998244353

print(ans % 998244353)
### BUGGY CODE ###

import bisect
w=20000000001
a,b,q=map(int,input().split())
s=[int(input()) for i in range(a)]
t=[int(input()) for i in range(b)]
#bisect.bisect_left

for i in range(q):
    x=int(input())
    ans=w
    tmp=x
    ls=bisect.bisect_left(s,tmp)
    lt=bisect.bisect_left(t,tmp)
    if (s[ls-1]<=tmp and t[lt-1]<=tmp): ans=min(ans,tmp-min(s[ls-1],t[lt-1]))
    if (s[ls-1]<=tmp and lt<b and t[lt]>=tmp): ans=min(ans,(tmp-s[ls-1])+(t[lt]-s[ls-1]),(t[lt]-tmp)+(t[lt]-s[ls-1]))
    if (ls<a and s[ls]>=tmp and t[lt-1]<=tmp): ans=min(ans,(tmp-t[lt-1])+(s[ls]-t[lt-1]),(s[ls]-tmp)+(s[ls]-t[lt-1]))
    if (ls<a and lt<b and s[ls]>=tmp and t[lt]>=tmp): ans=min(ans,max(s[ls],t[lt])-tmp)
    print(ans)

### FIXED CODE ###

import bisect
w=20000000001
a,b,q=map(int,input().split())
s=[int(input()) for i in range(a)]
t=[int(input()) for i in range(b)]
#bisect.bisect_left

for i in range(q):
    x=int(input())
    ans=w
    tmp=x
    ls=bisect.bisect_left(s,tmp)
    lt=bisect.bisect_left(t,tmp)
    if (s[ls-1]<=tmp and t[lt-1]<=tmp): ans=min(ans,tmp-min(s[ls-1],t[lt-1]))
    if (s[ls-1]<=tmp and lt<b and t[lt]>=tmp): ans=min(ans,(tmp-s[ls-1])+(t[lt]-s[ls-1]),(t[lt]-tmp)+(t[lt]-s[ls-1]))
    if (ls<a and s[ls]>=tmp and t[lt-1]<=tmp): ans=min(ans,(tmp-t[lt-1])+(s[ls]-t[lt-1]),(s[ls]-tmp)+(s[ls]-t[lt-1]))
    if (ls<a and lt<b and s[ls]>=tmp and t[lt]>=tmp): ans=min(ans,max(s[ls],t[lt])-tmp)
    print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline


def main():
    N, P = map(int, input().split())
    x = ans = 1
    if N == 1:
        print(P)
        return
    while True:
        y = x**N
        if y > P:
            break
        if P % y == 0:
            ans = x
        x += 1
    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def main():
    N, P = map(int, input().split())
    p = prime_factorize(P)
    import collections
    ans = 1
    for k, v in collections.Counter(p).most_common():
        while v >= N:
            ans *= k
            v -= N
    print(ans)


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

import numpy as np


def main():
    S = input()
    S = S[::-1]
    T = 'dreamer', 'dream', 'eraser', 'erase'
    while 1:
        temp = []
        for t in T:
            t = t[::-1]
            temp.append(t in S)
        if any(temp) == False:
            break
        for t in T:
            t = t[::-1]
            if ''.join(S[:len(t)]) == t:
                S = S[len(t):]

    if len(S) > 0:
        print('NO')
    else:
        print('YES')


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    S = input()
    S = S[::-1]
    _T = 'dreamer', 'dream', 'eraser', 'erase'
    T = []
    for t in _T:
        T.append(t[::-1])
    i = 0
    while 1:
        temp = []
        bool = True
        for t in T:
            if S[i:len(t) + i] == t:
                i += len(t)
                bool = False
        if bool:
            break
    if len(S) != i:
        print('NO')
    else:
        print('YES')


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

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Created: Jul, 12, 2020 08:04:43 by Nobody
# $Author$
# $Date$
# $URL$
__giturl__ = "$URL$"


from sys import stdin
input = stdin.readline


def main():
  N = int(input())
  G = [[] for _ in range(N+1)]
  for i in range(N-1):
    u, v, w = map(int, input().split())
    G[u].append((v, w))
    G[v].append((u, w))

  color = [-1 for _ in range(N+1)]
  color[1] = 0
  S = [1]
  while len(S):
    now = S[-1]
    for next_, w in G[now]:
      if not color[next_] == -1:
        continue
      S.append(next_)
      # white, odd
      if color[now]:
        color[next_] = 0 if w % 2 else 1
      # black, even
      else:
        color[next_] = 1 if w % 2 else 0
      break
    else:
      S.pop()

  for i in range(1, N+1):
    print(color[i])


if(__name__ == '__main__'):
  main()


### FIXED CODE ###

import sys
from collections import defaultdict, deque

def main():
    input = sys.stdin.readline
    N = int(input())
    d = defaultdict(list)
    for _ in range(N-1):
        u, v, w = map(int, input().split())
        d[u-1].append((v-1, w))
        d[v-1].append((u-1, w))

    dist = [0] * N
    q = deque()
    q.append((0, 0))
    visited = set()

    while len(q) > 0:
        q_ = deque()
        while len(q) > 0:
            node1, cost1 = q.popleft()

            dist[node1] = cost1
            visited.add(node1)

            for node2, cost2 in d[node1]:
                if node2 in visited:
                    continue

                q_.append((node2, cost1 + cost2))

        q = q_

    for d in dist:
        print(d % 2)


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

def gcd(a,b):
	if(a==0):
		return b
	return gcd(b % a,a)
n=int(input())
sum1=0
for i in range(1,n+1):
	for j in range(1,n+1):
		for k in range(1,n+1):
			gcd1=gcd(i,j)
			gcd2=gcd(gcd1,k)
			sum1+=gcd2
print(sum1)

### FIXED CODE ###

from math import gcd
n=int(input())
sum1=0
for i in range(1,n+1):
	for j in range(1,n+1):
		gcd1=gcd(i,j)
		for k in range(1,n+1):
			gcd2=gcd(gcd1,k)
			sum1+=gcd2
print(sum1)
### BUGGY CODE ###

def calc(l, k):
  res = 1
  for i in range(k):
    res = res*l[i]
  return res

n, k = map(int, input().split())
a = tuple(map(int, input().split()))
i = 1
prev = calc(a[:k], k)

while i+k <= n:
  tmp = calc(a[i:i+k], k)
  if tmp > prev:
    print('Yes')
  else:
    print('No')
  prev = tmp
  i += 1


### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = [0]*(n-k)
for i in range(k, n):
  ans[i-k] = (a[i]>a[i-k])
for i in range(0, n-k):
  print('Yes' if ans[i] else 'No')