Harryxun/stf_run huggingface dataset:
import sys

icase=0
if icase==0:
    n,m=map(int,input().split())
#    ab=[[0]*2 for i in range(n)]
    ab=[]
    for i in range(n):
        ai,bi=map(int,input().split())
        if m-ai>=0:
            ab.append([m-ai,-bi])
#        ab[i][0]=m-ai
#        ab[i][1]=-bi
elif icase==1:
    n,m=3,4
    ab=[[2, -2], [0, -1], [0, -3]]    
elif icase==2:
    n,m=5,3
    ab=[[1, -3], [1, -1], [2, -4], [2, -3], [2, -2]]
elif icase==3:
    n,m=1,1
    ab=[]

from heapq import heappop,heappush
#heappush(H,l) 
#print(heappop(H)) #2

#ab.sort(reverse=True)
if len(ab)==0:
    print(0)
    sys.exit()
ab.sort()

m=len(ab)
a0=ab[0][0]
h=[]
asum=0
idx=0
for i in range(m):
    while ab[idx][0]<m-i:
        heappush(h,ab[idx][1])
#        print("i:",i,"idx:",idx,h)
        idx+=1
        if idx>=n:
            asum+=heappop(h)
#            print("1:",idx,asum,h)
            break
    if idx>=n:
        asum+=heappop(h)
#        print("2:",idx,asum,h)
        break

if idx>=n:
    asum+=heappop(h)
#    print("3:",idx,asum,h)

print(-asum)
    


### FIXED CODE ###

import sys

icase=0
if icase==0:
    n,m=map(int,input().split())
    ab=[[] for i in range(m)]
    for i in range(n):
        ai,bi=map(int,input().split())
        if m-ai>=0:
            ab[m-ai].append(-bi)
elif icase==1:
    n,m=3,4
    ab=[[-3, -1], [], [-2], []]    
elif icase==2:
    n,m=5,3
    ab=[[], [-1, -3], [-2, -3, -4]]
elif icase==3:
    n,m=1,1
    ab=[[]]

from heapq import heappop,heappush

if len(ab)==0:
    print(0)
    sys.exit()

n=len(ab)
h=[]
asum=0
for i in range(m-1,-1,-1):
    if len(ab[i])>0:
        for abi in ab[i]:
            heappush(h,abi)
#    print(i,h,asum)
    if len(h)>0:
        asum+=heappop(h)

print(-asum)
n = int(input())
MOD = 1000000007

def power_func(a,n,p):
    bi = str(format(n,"b"))#2進表現に
    res = 1
    for i in range(len(bi)):
        res = (res*res) %p
        if bi[i] == "1":
            res = (res*a) %p
    return res

if(n == 1):
    print(0)
elif (n == 2):
    print(2)
else:
    kotae = 0
    a = power_func(10,n,MOD)
    b = power_func(9,n,MOD)
    c = power_func(8,n,MOD)

    kotae = a + c - ( 2 * b)
    kotae = kotae % MOD

print(kotae)

### FIXED CODE ###

n = int(input())
MOD = 1000000007

def power_func(a,n,p):
    bi = str(format(n,"b"))#2進表現に
    res = 1
    for i in range(len(bi)):
        res = (res*res) %p
        if bi[i] == "1":
            res = (res*a) %p
    return res

if(n == 1):
    print(0)
elif (n == 2):
    print(2)
else:
    kotae = 0
    a = power_func(10,n,MOD)
    b = power_func(9,n,MOD)
    c = power_func(8,n,MOD)

    kotae = a + c - ( 2 * b)
    kotae = kotae % MOD
    print(kotae)
print(str(a*b) + ' ' str((a+b)*2))

### FIXED CODE ###

#!usr/bin/env python3

def string_two_numbers_spliter():
    a, b = [int(i) for i in input().split()]
    return a, b


def main():
    a, b = string_two_numbers_spliter()
    print(str(a*b) + ' ' + str((a+b) * 2))


if __name__ == '__main__':
    main()
def read():
	return [int(i) for i in input().split(' ')]
W, H, N = read()
x = [0] * N
y = [0] * N
a = [0] * N
for i in range(N):
	x[i], y[i], a[i] = read()
new_x = [0] + x + [W]
new_y = [0] + y + [H]
for inx in range(N):
	if(a[inx] == 1):
		new_x = [num for num in new_x if num >= x[inx]] 
	elif(a[inx] == 2):
		new_x = [num for num in new_x if num <= x[inx]] 
	elif(a[inx] == 3):
		new_y = [num for num in new_y if num >= y[inx]] 
	else:
		new_y = [num for num in new_y if num <= y[inx]] 
area = (max(new_x) - min(new_x)) * (max(new_y) - min(new_y))
print(area)


### FIXED CODE ###

def read():
	return [int(i) for i in input().split(' ')]
W, H, N = read()
x = [0] * N
y = [0] * N
a = [0] * N
for i in range(N):
	x[i], y[i], a[i] = read()
new_x = [0] + x + [W]
new_y = [0] + y + [H]
for inx in range(N):
	if(a[inx] == 1):
		new_x = [num for num in new_x if num >= x[inx]] 
	elif(a[inx] == 2):
		new_x = [num for num in new_x if num <= x[inx]] 
	elif(a[inx] == 3):
		new_y = [num for num in new_y if num >= y[inx]] 
	else:
		new_y = [num for num in new_y if num <= y[inx]] 
if(not(new_x) or not(new_y)):
	print(0)
	exit()
area = (max(new_x) - min(new_x)) * (max(new_y) - min(new_y))
print(area)
from fractions import gcd
N = int(input())
array = list(map(int,input().split()))
gcd_arr = [array[0]]

for i in range(N-1):
  gcd_arr.append(gcd(gcd_arr[-1],array[i+1]))
  
gcd_arr.reverse()

for i in range(N):
  if gcd_arr[i+1] > gcd_arr[i]:
    break
    
if (N-i-1) == 1:
  new_gcd1 = array[1]
  for i in range(N-2):
    new_gcd1 = gcd(new_gcd1,array[i+2])
  array.pop(1)
  new_gcd2 = array[0]
  for i in range(N-2):
    new_gcd2 = gcd(new_gcd2,array[i+1])
  print(max(new_gcd1,new_gcd2))
  
else:
  array.pop(N-i-1)  
  new_gcd = array[0]
  for i in range(N-2):
    new_gcd = gcd(new_gcd,array[i+1])

  print(new_gcd)


### FIXED CODE ###

from fractions import gcd
N = int(input())
array = list(map(int,input().split()))
all_gcd = [0]*N
#calc from start to end
gcd_L = [array[0]]
for i in range(N-1):
  gcd_L.append(gcd(gcd_L[-1],array[i+1]))
  
#calc from end to start
gcd_R = [array[-1]]
for j in range(N-1,0,-1):
  gcd_R.append(gcd(gcd_R[-1],array[j-1]))
  
gcd_arr = []
  
for idx in range(N):
  if idx==0:
    gcd_arr.append(gcd_R[-2])
  elif idx==N-1:
    gcd_arr.append(gcd_L[-2])
  else:
    gcd_arr.append(gcd(gcd_L[idx-1],gcd_R[N-1-idx-1]))
print(max(gcd_arr))
n,m=map(int,input().split())
if m%2==1:
    for i in range(m):
        print(i+1,n-i)
else:
    x


### FIXED CODE ###

n,m=map(int,input().split())
if n%2==1:
    l=n//2
    for i in range(m):
        if i%2==1:
            print(i//2+1,l-i//2)
        else:
            print(l+i//2+1,n-i//2)
else:
    l=n//2
    for i in range(m):
        if i%2==0:
            print(i//2+1,l-i//2)
        else:
            print(l+i//2+2,n-i//2)
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
f=int(input())
ans=0
arr=[b,c,d,e,f]
amari=0
gurupu=0
syou=0

for i in range(6):
    if i == 1:
        amari=a % b
        gurupu=a // b + 1
        syou=b
    elif arr[i-1]<arr[i]:
        if amari>arr[i]:
            amari=amari % arr[i]
            gurupu=syou // arr[i] + 1
        else:
            gurupu=syou // arr[i] + 1
            

print(gurupu + 4)

### FIXED CODE ###

a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
f=int(input())
 
print((a-1) // min(b,c,d,e,f) + 5)
n,m,k=input2()
A=input_array()
B=input_array()

ca=0
cb=0
count=0
SUM=0
for i in range(10**5):
	if A[ca]<=B[cb]:
		SUM+=A[ca]
		ca+=1
	else:
		SUM+=B[cb]
		cb+=1

	if SUM >=k:
		break
	else:
		count+=1
print(count)

### FIXED CODE ###

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
n,m,k=input2()
A=input_array()
B=input_array()
acc_A=[0]
acc_B=[0]

for i in range(n):
	acc_A.append(A[i]+acc_A[i])
for i in range(m):
	acc_B.append(B[i]+acc_B[i])

ans=0
tmp_m=m
for i in range(n+1):
	if acc_A[i]>k:
		break
	for j in range(tmp_m,-1,-1):
		if acc_B[j]<=k-acc_A[i]:
			ans=max(i+j,ans)
			tmp_m=j #探索開始地点の更新
			break
print(ans)
import sys
for i in range(1000):
    for j in range(1000):
        if i**5+j**5 == x:
            print(i, -j)
            sys.exit()
        if i**5-j**5 == x:
            print(i, j)
            sys.exit()




### FIXED CODE ###

import sys
x = int(input())
for i in range(1000):
    for j in range(1000):
        if i**5+j**5 == x:
            print(i, -j)
            sys.exit()
        if i**5-j**5 == x:
            print(i, j)
            sys.exit()
a = int(input())
b = int(input())
print(a-1 * b-1)

### FIXED CODE ###

a,b = map(int,input().split())
print((a-1) * (b-1))
import collections

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

list_e = [list[i] for i in range(0,n-1,2)]
list_o = [list[i] for i in range(1,n,2)]
e = collections.Counter(list_e)
o = collections.Counter(list_o)
mode_e=e.most_common(2)
mode_o=o.most_common(2)
if mode_e[0][0]==mode_o[0][0]:
    if mode_e[0][1]>mode_o[0][1]:
        mode_e_value=mode_e[0][1]
        mode_o_value=mode_o[1][1]
    else:
        mode_e_value=mode_e[1][1]
        mode_o_value=mode_o[0][1]
else:
    mode_e_value = mode_e[0][1]
    mode_o_value = mode_o[0][1]
print(n-mode_e_value-mode_o_value)


### FIXED CODE ###

import collections

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

list_e = [list[i] for i in range(0,n-1,2)]
list_o = [list[i] for i in range(1,n,2)]
e = collections.Counter(list_e)
o = collections.Counter(list_o)
mode_e=e.most_common(2)
mode_o=o.most_common(2)
mode_e.append((-1,0))
mode_o.append((-1,0))
if mode_e[0][0]==mode_o[0][0]:
    print(n-max(mode_e[0][1]+mode_o[1][1],mode_e[1][1]+mode_o[0][1]))
    # if mode_e[0][1]>mode_o[0][1]:
    #     mode_e_value=mode_e[0][1]
    #     mode_o_value=mode_o[1][1]
    # else:
    #     mode_e_value=mode_e[1][1]
    #     mode_o_value=mode_o[0][1]
else:
    mode_e_value = mode_e[0][1]
    mode_o_value = mode_o[0][1]
    print(n-mode_e_value-mode_o_value)
a, b, c, d = map(int, input().split())
if abs(a - c) <= d:
    print("Yes")
elif abs(a - c) <= d * 2 and ((a <= b and b <= c) or (a >= b and b >= c):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a, b, c, d = map(int, input().split())
if abs(a - c) <= d or (abs(a - b) <= d and abs(b - c) <= d):
    print("Yes")
else:
    print("No")
import sys
n = int(input())
an = list(map(int,input().split()))
l = 1
r = 1
ans = 1
tmpsum=an[0]
while r<n:
  while tmpsum^an[r]==tmpsum+an[r]and r<n:
    tmpsum+=an[r]
    r += 1
    ans += r-l+1
  tmpsum -= an[l-1]
  l +=1
  if l>r:
    r=l
    tmpsum=an[l-1]
    ans += 1
print(ans)

### FIXED CODE ###

import sys
n = int(input())
an = list(map(int,input().split()))
l = 1
r = 1
ans = 1
tmpsum=an[0]
while True:
  if r == n:
    print(ans)
    sys.exit()
  while tmpsum^an[r]==tmpsum+an[r]:
    tmpsum+=an[r]
    r += 1
    ans += r-l+1
    if r == n:
      print(ans)
      sys.exit()
  tmpsum -= an[l-1]
  l +=1
  if l>r:
    r=l
    tmpsum=an[l-1]
    ans += 1
K = int(input)
A, B = map(int, input().split())

for i range (A, B+1):
  if i % K == 0:
    print("OK")
    break

print("NG")

### FIXED CODE ###

K = int(input())
A, B = map(int, input().split())
C = 0

for i in range(A,B+1):
    if i%K == 0:
        C += 1
        break


if C == 1:
    print("OK")
else:
    print("NG")
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

def dist(A, B):
	return abs(A[0]-B[0]) + abs(A[1]-B[1])

N = INT()
xy = [LIST()+[i] for i in range(N)]

xy1 = [[xy[i][0]+xy[i][1], i] for i in range(N)]
xy1.sort(key=lambda x:x[0])
idx_a = xy1[0][1]
idx_b = xy1[-1][1]
a = xy[idx_a]
b = xy[idx_b]

xy2 = [[-xy[i][0]+xy[i][1], i] for i in range(N)]
xy2.sort(key=lambda x:x[0])
idx_c = xy2[0][1]
idx_d = xy[-1][1]
c = xy[idx_c]
d = xy[idx_d]

print(max(dist(a, b), dist(a, c), dist(a, d), dist(b, c), dist(b, d), dist(c, d)))

### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

def dist(A, B):
	return abs(A[0]-B[0]) + abs(A[1]-B[1])

N = INT()
xy = [LIST()+[i] for i in range(N)]

xy1 = [[xy[i][0]+xy[i][1], i] for i in range(N)]
xy1.sort(key=lambda x:x[0])
idx_a = xy1[0][1]
idx_b = xy1[-1][1]
a = xy[idx_a]
b = xy[idx_b]

xy2 = [[-xy[i][0]+xy[i][1], i] for i in range(N)]
xy2.sort(key=lambda x:x[0])
idx_c = xy2[0][1]
idx_d = xy2[-1][1]
c = xy[idx_c]
d = xy[idx_d]

print(max(dist(a, b), dist(a, c), dist(a, d), dist(b, c), dist(b, d), dist(c, d)))
n = int(input)
for i in range(1, 10):
    for j in range(1, 10):
        if n == i * j:
            print('Yes')
            exit()

print('No')

### FIXED CODE ###

n = int(input())
for i in range(1, 10):
    for j in range(1, 10):
        if n == i * j:
            print('Yes')
            exit()

print('No')
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,q = mi()
b = [[] for i in range(n)]
ans = [0]*n
for i in range(n-1):
    a,c = mi()
    b[a-1].append(c-1)
    b[c-1].append(a-1)


def chil_pop(l):
    for i in b[l]:
        b[i].pop(b[i].index(l))
        chil_pop(i)

chil_pop(0)

def chil_add(z,x):
    ans[z] += x
    for i in b[z]:
        chil_add(i,x)

for i in range(q):
    p,x = mi()
    chil_add(p-1,x)

for i in range(n):
    print(ans[i],end=' ')


### FIXED CODE ###

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

import sys
sys.setrecursionlimit(40000000)

n,q = mi()
b = [[] for i in range(n)]
ans = [0]*n

# O(2n)
for i in range(n-1):
    a,c = mi()
    b[a-1].append(c-1)
    b[c-1].append(a-1)

# jun = []
# O(2n)
# def chil_pop(l,p):
#     jun.append(l)
#     for i in b[l]:
#         if i == p:
#             continue
#         chil_pop(i,l)
#     b[l] = p

# chil_pop(0,-1)


# O(q)
for i in range(q):
    p,x = mi()
    ans[p-1] += x


count = 0
q = [(0,-1)]
while q:
    c,p = q.pop()
    for i in b[c]:
        if i == p:
            continue
        ans[i] += ans[c]
        q.append((i,c))
    
    

# for i in jun[1:]:
#     ans[i] += ans[b[i]]

# ans_str = ''
# for i in range(n):
#     print(ans[i],end=' ')
#     # ans_str = ans_str + str(ans[i]) + ' '
print(*ans)
# -*- coding: utf-8 -*-

c = []
for i in range(3):
    c.append(input().split())

for i in range(3):
    print(c[i][i], end='')

### FIXED CODE ###

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

c = []
for i in range(3):
    c.append(list(input()))

for i in range(3):
    print(c[i][i], end='')
a,b,x=map(int,input().split())
cnt=0
for i in range(1,11):
  if x-i*b>=0 and (x-i*b)//a>=10**(i-1):
    cnt+=1
if cnt==0 or x-i*b<0:
  print(0)
else:
  print(((x-cnt*b)-(x-cnt*b)%a)//a)


### FIXED CODE ###

s=input()
if s=='SUN':
  print(7)
elif s=='MON':
  print(6)
elif s=='TUE':
  print(5)
elif s=='WED':
  print(4)
elif s=='THU':
  print(3)
elif s=='FRI':
  print(2)
else:
  print(1)
n, m = map(int,input().split())
students = [None]*n
points = [None]*m
students[i] = [tuple(map(int, input.split())) for _ in range(n)]
points[i] = [tuple(map(int, input.split())) for _ in range(m)]

ans = []
for s in students:
  tmp = []
  for p in points:
    tmp.append(abs(s[0] - p[0]) + abs(s[1] - p[1]))
  ans.append(tmp.index(min(tmp)) + 1)
for i in range(n):
  print(ans[i])


### FIXED CODE ###

A, B = map(int, input().split())
r = (A + B) % 24
print(int(r))
n=int(input())
a=[]
a.append(2)
k=2
for i in range(55):
	while k < 55555 :
    	k += 1
    	b = k
		for j in a:
            if k % j == 0:
                b = 0
        if b == k:
            a.append(k)
            break
anss=[]
for j in range(len(a)):
    if len(anss) < n:
        if a[j] % 5 == 1:
            anss.append(a[j])   
print(*anss)        

### FIXED CODE ###

def main():
    n=int(input())
    a=[]
    s=[]
    t=0
    for k in range(3,55556):
        b=k
        for j in s:
            if k%j==0:
                b=0
        if b==k:
            s.append(k)
            if k % 5 == 1:
                if t < n:
                    a.append(k)
                    t += 1
                else:
                    break
     
    print(*a)
    
    
    
main()
N=int(input())
S=input()
n=N//2
s1=S[:n]
s2=S[n:]
if s1==s2:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

r=int(input())
print(r**2)
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under

N, K = map(int, input().split())
ma = (N-1)*(N-2)/2

if ma == K:
  print('-1')
else:
  cmb_val = cmb(N-1,2)
  a =[(1, i) for i in range(2, N+1)]
  b = [(i, j) for i in range(2, N+1) for j in range(i+1, N+1)]
  a.extend(b[:cmb_val-K])
      
  print(len(a))
  for i in range(len(a)):
    print(a[i][0], a[i][1])
  
  

### FIXED CODE ###

from operator import mul
from functools import reduce

def cmb(n,r):
  if n < r:
    return 0
  else:
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under

N, K = map(int, input().split())
ma = (N-1)*(N-2)/2

if ma < K:
  print('-1')
else:
  cmb_val = cmb(N-1,2)
  a =[(1, i) for i in range(2, N+1)]
  b = [(i, j) for i in range(2, N+1) for j in range(i+1, N+1)]
  a.extend(b[:cmb_val-K])
      
  print(len(a))
  for i in range(len(a)):
    print(a[i][0], a[i][1])
import sys; readline = sys.stdin.readline
from deque import deque

A = int(readline())
B = int(readline())

print(set([1,2,3]) - set([A, B]))

### FIXED CODE ###

import sys; readline = sys.stdin.readline
from collections import deque

A = int(readline())
B = int(readline())

ans = list(set([1,2,3]) - set([A, B]))
print(ans[0])
N, A, B, K = map(int, input().split())
M = 998244353

X = set()
for n in range(0, K//A+1):
    m = (K - n * A) // B
    if n <= N and m <= N and n * A + m * B == K:
        X.add((n, m))

comb = [0]*(N+1)
comb[0] = 1
comb[N] = 1
for i in range(1, N//2+1):
    comb[i] = comb[i-1]*(N-i+1)//i
    comb[i] = comb[i]
    comb[N-i] = comb[i]

ans = 0
for n, m in X:
    ans += comb[n] * comb[m]
    ans = ans % M
print(ans)


### FIXED CODE ###

N = int(input())

def digit_sum(X):
    s = 0
    while(X > 0):
        s += X % 10
        X = int(X / 10)
    return s

min_ = 10 ** 5
for A in range(1, int(N/2)+1):
    B = N - A
    val = digit_sum(A) + digit_sum(B)
    min_ = min(min_, val)

print(min_)
n = int(input())
T = [0] + [None] * n
X = [0] + [None] * n
Y = [0] + [None] * n
for i in range(1, n + 1):
  T[i], X[i], Y[i] = map(int, input().split())

for i in range(len(T) - 1):
  dt = T[i + 1] - T[i]
  dx = X[i + 1] - X[i]
  dy = Y[i + 1] - Y[i]
  if (dt % 2 == (dx + dy) % 2 and (dx + dy) <= dt):
    res = res and True
  else:
    res = False

if (res):
  print('Yes')
else:
  print('No')


### FIXED CODE ###

n = int(input())
T = [0] + [None] * n
X = [0] + [None] * n
Y = [0] + [None] * n
for i in range(1, n + 1):
  T[i], X[i], Y[i] = map(int, input().split())

for i in range(len(T) - 1):
  dt = T[i + 1] - T[i]
  dx = abs(X[i + 1] - X[i])
  dy = abs(Y[i + 1] - Y[i])
  if (dt % 2 == (dx + dy) % 2 and (dx + dy) <= dt):
    res = True
  else:
    print('No')
    exit()

print('Yes')
N=int(input())
a=[]
for n in range(1,N,1):
  count=0
  while n%2 == 0:
    count+=1
    n/=2
  a.append(count)

Nmax=a.index(max(a))+1
Tmax=max(a)

### FIXED CODE ###

N=int(input())
a=[]
for b in range(1,N+1,1):
  count=0
  while b%2 == 0:
    count+=1
    b/=2
  a.append(count)

print(a.index(max(a))+1)
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    import queue
    mod=10**9+7
    N,K=MI()

    #0~Nまで逆元などを事前計算

    def calc(n, r, mod):
        if (r < 0) or (n < r):
            return 0
        return (fact[n] * factinv[n-r])%mod

    fact=[1,1]
    factinv=[1,1]
    inv=[0,1]

    for i in range(2, N+5 + 1):
        fact.append((fact[-1] * i) % mod)
        inv.append((-inv[mod % i] * (mod // i)) % mod)
        factinv.append((factinv[-1] * inv[-1]) % mod)
    
    adj=[[]for _ in range(N)]
    for i in range(N-1):
        a,b=MI()
        a-=1
        b-=1
        adj[a].append(b)
        adj[b].append(a)
    
    #子要素を全部いっぺんに塗る
    ans=K#根の塗り方
    
    q=queue.Queue()
    q.put((0,0,-1))
    
    while not q.empty():
        v,d,p=q.get()
        cnt=0#子の個数
        for nv in adj[v]:
            if nv!=p:
                cnt+=1
                q.put((nv,d+1,v))
            
        if cnt!=0:#葉以外の場合は計算
            np=2#親方向で気にすべき個数
            if d==0:
                np=1#根の親はいない
                
        ans=(ans*calc(K-np,cnt,mod))%mod
        
    print(ans)

        
    

main()


### FIXED CODE ###

#頂点を見た時に，枝分かれの本数に応じてansを更新
#permutationのリストを先に作っておく

import sys
input = sys.stdin.readline

mod=10**9+7


N,K=map(int,input().split())
ab=[list(map(int, input().split())) for _ in range(N - 1)]
adj=[[] for _ in range(N)]

for a,b in ab:
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)
    
    
#順列(K-2)Piを先に
P=[1]
for i in range(N):
    P.append((P[-1]*(K-2-i))%mod)
    

q=[(0,-1,0)]#node,parent,depth

ans=1
while q!=[]:
    v,p,d=q.pop()
    #深さ0or1で塗ることができる色数は異なる
    l=len(adj[v])
    if d==0:
        ans*=(K-1)
    ans*=(P[l-1])
    ans%=mod
    for i in range(l):
        next_v=adj[v][i]
        #葉は追加しない
        if next_v!=p and len(adj[next_v])!=1:
            q.append((next_v,v,d+1))
if N==1:
    ans=1
print((ans*K)%mod)
x = int(input())
 
if x < 1200:
  print(ABC)
  
else:
  print(ARC)
  

### FIXED CODE ###

x = int(input())
 
if x < 1200:
  print("ABC")
  
else:
  print("ARC")
n, a = map(int, input().split())
Max = -10000000
Min = a
for i in range(n):
    x = int(input())
    if (Max < (x-Min)):
        Max = x-Min
    if (x < Min):
        Min = x
print(Max)

### FIXED CODE ###

n = int(input())
a = int(input())
Max = -10 ** 9
Min = a
for i in range(n-1):
    x = int(input())
    if (Max < x - Min):
        Max = x - Min
    if (x < Min):
        Min = x
print(Max)
h,w,k=map(int, input().split())
L=[]
for i in range(h):
	S=list(input())
	for j in range(w):
		L.append(S[j])
import itertools
import copy
t=[1,0]
cnt=0

for v in itertools.product(t, repeat=h+w):
	LL=copy.copy(L)
	for i in range(h+w):
		if v[i]==1 and i<h:
			for j in range(w):
				LL[h*i+j]='r'
		if v[i]==1 and i>=h:
			for j in range(h):
				LL[w*j+(i-h)]='r'
	s=LL.count('#')
	if s==k:
		cnt+=1
print(cnt)

### FIXED CODE ###

h,w,k=map(int, input().split())
L=[]
for i in range(h):
	S=list(input())
	for j in range(w):
		L.append(S[j])
import itertools
import copy
t=[1,0]
cnt=0

for v in itertools.product(t, repeat=h+w):
	LL=copy.copy(L)
	for i in range(h+w):
		if v[i]==1 and i<h:
			for j in range(w):
				LL[w*i+j]='r'
		if v[i]==1 and i>=h:
			for j in range(h):
				LL[w*j+(i-h)]='r'
	s=LL.count('#')
	if s==k:
		cnt+=1
print(cnt)
31415 9265

### FIXED CODE ###

n,k=map(int,input().split())
if k%2==1:
  print((n//k)**3)
else:
  m=n*2//k
  if m%2==1:
    print(((m-1)//2)**3+((m+1)//2)**3)
  else:
    print((m**3)//4)
N = input()
K = input()
ans = [1]*N

for i in range(0,K):
  d = int(input())
  table  = list(map(int, input().split()))
  for j in range(0,N):
    if table.count(j) != 0:
      ans[j] = 0
print(sum(ans))

### FIXED CODE ###

NK = list(map(int, input().split()))
ans = [0]*NK[0]

for i in range(0,NK[1]):
  d = int(input())
  table  = list(map(int, input().split()))
  for j in range(1,NK[0]+1):
    if table.count(j) != 0:
      ans[j-1] = 1
print(NK[0]-sum(ans))