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

def parse(A):
    R=len(A)
    C=len(A[0])
    grid=[[1 for j in range(C)]  for i in range(R)]
    for i in range(R):
        for j in range(C):
            if A[i][j]=='.':
                grid[i][j]=0
                
    return grid

def find(grid):
    black={}
    R=len(grid)
    C=len(grid[0])
    new=[]
    for i in range(R):
        for j in range(C):
            if grid[i][j]==1:
                black[(i,j)]=0
                new+=[(i,j)]
    time=0        
    
    while len(black)<R*C:
        time+=1
        new_black=[]
        for X in new:
            x,y=X
            check=[(x-1,y),(x+1,y),(x,y-1),(x,y+1)]
            for Y in check:
                y1,y2=Y[0],Y[1]
                if y1>R-1 or y1<0 or y2>C-1 or y2<0:
                    continue
                if grid[y1][y2]==0:
                    new_black+=[(y1,y2)]
                    
                    black[(y1,y2)]=1
                else:
                    continue
        for X in new_black:
            grid[X[0]][X[1]]=1

        new=new_black
    return time    

H,W=list(map(int,input().strip().split(' ')))
A=[]
for _ in range(H):
    A+=[input()]
grid=parse(A)
print(find(grid))
    
                    
                                
                    
                
            
            

        


### FIXED CODE ###

# Enter your code here. Read input from STDIN. Print output to STDOUT
def parse(A):
    R=len(A)
    C=len(A[0])
    grid=[[1 for j in xrange(C)]  for i in xrange(R)]
    for i in xrange(R):
        for j in xrange(C):
            if A[i][j]=='.':
                grid[i][j]=0
                
    return grid

def find(grid):
    black={}
    R=len(grid)
    C=len(grid[0])
    new=[]
    for i in xrange(R):
        for j in xrange(C):
            if grid[i][j]==1:
                black[(i,j)]=0
                new+=[(i,j)]
    time=0        
    
    while len(black)<R*C:
        
        time+=1
        new_black=set([])
        
        for X in new:
            x,y=X
            check=[(x-1,y),(x+1,y),(x,y-1),(x,y+1)]
            for Y in check:
                y1,y2=Y[0],Y[1]
                if y1>R-1 or y1<0 or y2>C-1 or y2<0:
                    continue
                if grid[y1][y2]==0:
                    new_black.add((y1,y2))
                    
                    black[(y1,y2)]=1
                else:
                    continue
        for X in new_black:
            grid[X[0]][X[1]]=1
        new=[]
        new=new_black
        #print(new_black)
    return time    

H,W=list(map(int,raw_input().strip().split(' ')))
A=[]
for _ in xrange(H):
    A+=[raw_input()]
grid=parse(A)
print(find(grid))
### BUGGY CODE ###

def main():
    N=int(input())
    A=[input() for i in range(N)]
    NA=[A.count(A[i]) for i in range(N)]
    NIN=[i for i, v in enumerate(NA) if v == max(NA)]
    NM=[A[NIN[i]] for i in range (len(NIN))]
    NM=sorted(list(set(NM)))
    for i in range (len(NM)):
        print(NM[i])
if __name__ == '__main__':
    main()

### FIXED CODE ###

N = int(input())
L = [input() for i in range(N)]
L = sorted(L)
D = {}

for i in L:
    if i in D:
        V = D.get(i) + 1
    else:
        V = 1
    D[i] = V

D = sorted(D.items(),key=lambda x:x[1],reverse=True)

Ans = []

Ans.append(D[0][0])

for i in range(len(D)-1):
    if D[i][1] == D[i+1][1]:
        Ans.append(D[i+1][0])
    else:
        break

Ans = sorted(Ans)

for i in Ans:
    print(i)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

import numpy as np

n = int(input())
a = list(map(int, input().split()))
q = int(input())
b = [list(map(int,input().split())) for i in range(q)]

l = np.array([0] * 100000)
m = np.array(list(range(1,100001)))

for i in range(n):
  l[a[i]-1] += 1
  
for j in range(q):
  l[b[j][1]-1] += l[b[j][0]-1]
  l[b[j][0]-1] = 0
  print(sum(l*m))


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
q = int(input())
ans = sum(a)

l = [0] * 100001

for i in a:
  l[i] += 1
  
for j in range(q):
  b, c = map(int,input().split())
  l[c] += l[b]
  ans += l[b] * (c-b)
  l[b] = 0
  print(ans)
### BUGGY CODE ###

import sys

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N, M = read_int()
AB = [read_int() for _ in range(N)]
Done = [False] * N


def solve():
    AB.sort(key=lambda x: x[0], reverse=True)
    AB.sort(key=lambda x: x[1], reverse=True)

    ans = 0
    for i in range(M):
        for j in range(N):
            if AB[j][0] <= M - i and not Done[j]:
                ans += AB[j][1]
                Done[j] = True
                break
    return ans

if __name__ == "__main__":
    print(solve())

### FIXED CODE ###

# from collections import defaultdict
import sys, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N, M = read_int()

jobs = [[] for _ in range(M + 1)]
for i in range(N):
    d, r = read_int()
    if d <= M:
        jobs[d].append(-r)


hq = []
heapq.heapify(hq)

def solve():
    ans = 0
    for i in range(1, M + 1):
        for j in jobs[i]:
            heapq.heappush(hq, j)
        if hq:
            ans += - heapq.heappop(hq)
    return ans

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

import itertools
N = int(input())
L = list(map(int, input().split()))
ans = 0
#for i in range(N):
#  for j in range(i + 1, N):
#    for k in range(j + 1, N):
#      #print(str(i) + str(j) + str(k))
#      if L[i] < L[j] + L[k] and abs(L[j] - L[k]) < L[i]:
#        ans += 1
#print(ans)
comb = list(itertools.combinations(L, 3))
comb = list(map(list, comb))
for i in range(len(comb)):
  if comb[i][0] < comb[i][1] + comb[i][2] and abs(comb[i][1] - comb[i][2]) < comb[i][0]:
    ans += 1
print(ans)



### FIXED CODE ###

import bisect
N = int(input())
#ソートしておく
L = sorted(list(map(int, input().split())))
ans = 0

#短い2辺を総当たりで選択
for i in range(N - 2):
  for j in range(i + 1, N - 1):
    #小さい順に並べた時の成立条件
    # l1 + l2 > l3
    l12 = L[i] + L[j]
    #l2の隣から　l12以下のところまで全部が対象、成立しない場合
    #ans += max(bisect.bisect_left(L, l12) - j - 1, 0)
    ans += bisect.bisect_left(L, l12) - j - 1
print(ans)
### BUGGY CODE ###


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

tree_1=[]
tree_2=[]
tree_3=[]

for i in range(0,N):
    for e2 in tree_2:
        if len(tree_3)!=0:
            if (e2+S[i] in tree_3)!=True:
                tree_3.append(e2+S[i])
        else:
            tree_3.append(e2+S[i])
    for e1 in tree_1:
        if len(tree_2)!=0:
            if (e1+S[i] in tree_2)!=True:
                tree_2.append(e1+S[i])
        else:
            tree_2.append(e1+S[i])
    if len(tree_1)!=0:
        if (S[i] in tree_1)!=True:
            tree_1.append(S[i])
    else:
        tree_1.append(S[i])
print(len(tree_3))

### FIXED CODE ###


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

tree_1=[]
tree_2=[]
tree_3=[]

for i in range(0,N):
    for e2 in tree_2:
        tree_3.append(e2+S[i])
    for e1 in tree_1:
        if len(tree_2)!=0:
            if (e1+S[i] in tree_2)!=True:
                tree_2.append(e1+S[i])
        else:
            tree_2.append(e1+S[i])
    if len(tree_1)!=0:
        if (S[i] in tree_1)!=True:
            tree_1.append(S[i])
    else:
        tree_1.append(S[i])
print(len(set(tree_3)))
### BUGGY CODE ###

n,a=int(input()),list(map(int,input().split()))
c=[0]*3
for i in a:c[i-1]+=1
x=[1/i for i in range(1,n+1)]
dp=[[[0]*(n+2) for i in range(n+2)]for i in range(n+2)]
for k in range(n+1):
  for j in range(n+1):
    for i in range(n+1):
      if not n+1>i+j+k>0:continue
      dp[i][j][k]=(n+dp[i-1][j][k]*i+dp[i+1][j-1][k]*j+dp[i][j+1][k-1]*k)*x[i+j+k-1]
print(dp[c[0]][c[1]][c[2]])

### FIXED CODE ###

n,a=int(input()),map(int,input().split());c=[0]*3
for i in a:c[i-1]+=1
x,y,z=c;dp=[[[None]*(z+2) for i in range(n-x+2)]for i in range(n+2)];dp[0][0][0]=0
for k in range(z+1):
  for j in range(n-x-k+1):
    for i in range(n-k-j+1):
      if i+j+k:dp[i][j][k]=((dp[i-1][j][k]*i if i else 0)+(dp[i+1][j-1][k]*j if j else 0)+(dp[i][j+1][k-1]*k if k else 0)+n)/(i+j+k)
print(dp[x][y][z])
### BUGGY CODE ###

def main():
    from itertools import accumulate as ac
    from bisect import bisect_left as bl
    from bisect import bisect_right as br
    from sys import stdin
    input=stdin.readline

    def check(k):
        dist=a[-k-1]-ini
        if dist<0:
            dist=abs(dist)
            return k>=br(a,ini+dist)-bl(a,ini-dist)-1
        else:
            return k>=br(a,ini+dist)-bl(a,ini-dist)
    
    n,q=map(int,input().split())
    nn=n//2+1
    a=list(map(int,input().split()))
    x=[int(input()) for _ in [0]*q]
    ix=sorted([[i,j] for i,j in enumerate(x)],key=lambda x:x[1])
    ans=[0]*q
    aac=[0]+list(ac(a))
    aac2=[0]+list(ac(a[(n+1)%2::2]))
    k=nn

    for i,ini in ix:
        l=1
        u=k
        while l+1<u:
            med=(l+u)//2
            if check(med):u=med
            else:l=med+1
        if check(l):k=l
        else:k=u
        ans[i]=aac[-1]-aac[-k-1]+aac2[-k-1]
    for i in ans:
        print(i)
main()

### FIXED CODE ###

def main():
    from itertools import accumulate as ac
    from bisect import bisect_left as bl
    from bisect import bisect_right as br
    from sys import stdin
    input=stdin.readline

    def check(k):
        dist=a[-k-1]-ini
        if dist<0:
            dist=abs(dist)
            return k>=br(a,ini+dist)-bl(a,ini-dist)-1
        else:
            return k>=br(a,ini+dist)-bl(a,ini-dist)
    
    n,q=map(int,input().split())
    nn=n//2+1
    a=list(map(int,input().split()))
    x=[int(input()) for _ in [0]*q]
    ix=sorted([[i,j] for i,j in enumerate(x)],key=lambda x:x[1])
    ans=[0]*q
    aac=[0]+list(ac(a))
    aac2=[0]+list(ac(a[(n+1)%2::2]))
    k=nn

    for i,ini in ix:
        l=1
        u=k
        while l+1<u:
            med=(l+u)//2
            if check(med):u=med
            else:l=med+1
        if check(l):k=l
        else:k=u
        ans[i]=aac[-1]-aac[-k-1]+aac2[-k-1]
    for i in ans:
        print(i)
main()
### BUGGY CODE ###

import numpy as np

def get_expect(p):
    return 1.0 * (p + 1) / 2

def main():
    N, K = map(int, input().split(" "))
    P = np.array(list(map(int, input().split(" "))))

    e = np.frompyfunc(get_expect, 1, 1)(P)

    t = np.ones((K))

    print(np.max(
        np.convolve(
            e,
            t
        )
    ))

if __name__ == "__main__":
    main()

### FIXED CODE ###

import numpy as np
from scipy import signal

def main():
    N, K = map(int, input().split(" "))
    P = np.array(list(map(int, input().split(" "))))

    e = (P + 1) / 2

    t = np.ones((K))

    print(np.amax(
        signal.fftconvolve(
            e,
            t
        )
    ))

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

import sys
sys.setrecursionlimit(10**9)
n, q = map(int, input().split())
d = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    d[a].append(b)
    d[b].append(a)
d2 = [0 for _ in range(n)]
for _ in range(q):
    p, x = map(int, input().split())
    p -= 1
    d2[p] += x

ans = [0] * n

def dfs(cur, pre, point):
    point += d2[cur]
    ans[cur] = point
    for e in d[cur]:
        if e != pre:
            dfs(e, cur, point)
dfs(0, -1, 0)
print(" ".join([str(item) for item in ans]))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
n, q = map(int, input().split())
d = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    d[a].append(b)
    d[b].append(a)
d2 = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    d2[p-1] += x

ans = [0] * n

def dfs(cur, pre, point):
    point += d2[cur]
    ans[cur] = point
    for e in d[cur]:
        if e != pre:
            dfs(e, cur, point)
dfs(0, -1, 0)
print(" ".join(map(str, ans)))
### BUGGY CODE ###

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

for i in range(Q):
    B,C = (int(x) for x in input().split())

    idx_list = [i for i, x in enumerate(A) if x == B]
    for idx in idx_list:
        A[idx]=C
    
    print(sum(A))


### FIXED CODE ###

# 371 ms, 27032 KB
n = int(input())
a = list(map(int, input().split()))
q = int(input())
b = []
c = []
 
bc = [map(int, input().split()) for _ in range(q)]
b, c = [list(i) for i in zip(*bc)]
 
dic = {}
for aa in a:
    dic[aa] = dic.get(aa, 0) + 1
 
s = sum(a)
for i in range(q):
    if b[i] not in dic:
        print (str(s))
        continue
    s += (c[i]-b[i]) * dic[b[i]]
    dic[c[i]] = dic.get(c[i], 0) + dic[b[i]]
    del dic[b[i]]
    print(s)
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()

a = []
for _ in range(q):
    l, r = map(int, input().split())
    a.append(s[l-1:r])

print(*(x.count('AC') for x in a), sep='\n')


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n, q = map(int, input().split())
s = input()

score = [0]*n
for i in range(n-1):
    score[i+1] = score[i]
    if s[i]+s[i+1] == 'AC':
        score[i+1] += 1

for _ in range(q):
    l, r = map(int, input().split())
    print(score[r-1]-score[l-1])
### BUGGY CODE ###

import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
from collections import deque, defaultdict
def resolve():
    N, P = lr()
    S = sr()
    if P == 2 or P == 5:
        ans = 0
        for i in range(N):
            if int(S[i])%P == 0:
                ans += i+1
        print(ans)
        return
    lp = defaultdict(int)
    S = deque(S)
    for i in range(N):
        lp[int(''.join(S))%P] += 1
        S.popleft()
    ans = lp[0]
    for i in range(P):
        ans += max(lp[i]*(lp[i]-1)//2, 0)
    print(ans)
resolve()

### FIXED CODE ###

import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, P = lr()
    S = list(map(int, list(sr())))
    if P == 2 or P == 5:
        ans = 0
        for i in range(N):
            if S[i]%P == 0:
                ans += i+1
        print(ans)
        return
    S = S[::-1]
    lp = [0]*P
    c = 0
    for i in range(N):
        d = S[i]*pow(10,i,P)
        c = (c+d)%P
        lp[c] += 1
    ans = lp[0]
    for i in range(P):
        ans += lp[i]*(lp[i]-1)//2
    print(ans)
resolve()
### BUGGY CODE ###

n,p=map(int,input().split())
 
if n==1:
  print(p)
else:
  ans=1
  anskohomax=int(p**(1/n))
  for i in range(1,anskohomax+1+1):
    if p%i**n == 0:
     ans=i
  print(ans)

### FIXED CODE ###

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

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

kekka=factorize(p)

ans=1
for i in range(len(kekka)):
    ans=ans* kekka[i][0] ** (kekka[i][1]//n)
print(ans)
### BUGGY CODE ###

a=input()
x = list(map(int, input().split()))
sum=1
for i in x:
  sum*=i
if sum>10**18:
  print(-1)
else: print(sum)

### FIXED CODE ###

a=input()
x = list(map(int, input().split()))
x.sort(reverse=True)
if x[-1]==0:
  print(0)
else:
  sum=1
  for i in x:
    sum*=i
    if sum>10**18:
      print(-1)
      break
  if sum<=10**18: print(sum)
### BUGGY CODE ###

from itertools import combinations

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

# check
case = []
append = case.append
for i in range(1, len(s) + 1):
    for c in combinations(list(s), i):
        if "".join(c) in s and "".join(c) not in case:
            append("".join(c))
case.sort(reverse=True)

print(case[-K])

### FIXED CODE ###

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

# check
case = []
append = case.append
for i in range(1, K + 1):
    for idx in range(0, len(s) - (i - 1)):
        if s[idx:idx + i] not in case:
            append(s[idx:idx + i])
case.sort(reverse=True)

print(case[-K])
### BUGGY CODE ###

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

max_set = [0]
for i in range(n-k+1):
    pair = []
    for j in range(k):
        pair.append(p[i+j])
    if sum(max_set) < sum(pair):
        max_set = copy.copy(pair)

ans = 0
for i in max_set:
    ans += (i+1)/2
print(ans)

### FIXED CODE ###

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

max_set = sum(p[:k])
pair = sum(p[:k])
for i in range(n-k):
    pair -= p[i]
    pair += p[i+k]
    if max_set < pair:
        max_set = pair

print((max_set+k)/2)
### BUGGY CODE ###

import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
to = defaultdict(list)
V = 100005
X = []
for i in range(N):
	x, y = rl()
	X.append(x)
	y += V
	to[x].append(y)
	to[y].append(x)

visited = set()
nx, ny = 0, 0
def dfs(n):
	global nx, ny
	if n in visited: return
	visited.add(n)
	if n < V:
		nx += 1
	else:
		ny += 1
	for m in to[n]:
		dfs(m)

ans = 0
for x in X:
	if x in visited: continue
	nx, ny = 0, 0
	dfs(x)
	ans += nx*ny
print(ans-N)



### FIXED CODE ###

import sys, math
from collections import defaultdict, deque, Counter
# from bisect import bisect_left, bisect_right
# from itertools import combinations, permutations, product
# from heapq import heappush, heappop
# from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
to = defaultdict(list)
V = 100005
X = []
for i in range(N):
	x, y = rl()
	X.append(x)
	y += V
	to[x].append(y)
	to[y].append(x)

ans = 0
visited = {}
for x in X:
	if x in visited: continue
	nx, ny = 0, 0
	queue = deque()
	queue.append(x)
	visited[x] = 1
	while queue:
		n = queue.pop()
		if n < V:
			nx += 1
		else:
			ny += 1
		for m in to[n]:
			if m in visited:
				continue
			visited[m] = 1
			queue.append(m)
	ans += nx*ny
print(ans-N)
### BUGGY CODE ###

import sys
from collections import defaultdict
import bisect
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
len_S = len(S)
T = sr()
dict_S = defaultdict(list)
dict_T = defaultdict(list)
for i, s in enumerate(S):
    dict_S[s].append(i)

for i, t in enumerate(T):
    dict_T[t].append(i)

answer = 0
cur = -1
for t in T:
    if not dict_S[t]:
        print(-1)
        exit()
    indexes = dict_S[t] + [len_S]
    i = bisect.bisect_right(indexes, cur)
    next = indexes[i]
    if next == len_S:
        answer = (-(-answer//len_S)) * len_S
        cur = -1
        answer += indexes[0] - cur
        cur = indexes[0]
    else:
        answer += next - cur
        cur = next

print(answer)
# 32

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

from collections import defaultdict
from bisect import bisect_left

S = input().rstrip()
T = input().rstrip()

LS = len(S)

index = defaultdict(list)

for i,s in enumerate(S):
    index[s].append(i)

x = -1
for t in T:
    arr = index[t]
    if len(arr) == 0:
        x = -2
        break
    y = (x+1) % LS
    i = bisect_left(arr,y)
    if i < len(arr):
        next_x = (x+1) + arr[i] - y
    else:
        next_x = (x+1) + arr[0] - y + LS
    x = next_x

print(x + 1)
### BUGGY CODE ###

import operator
import functools
mod = 10**18
a = int(input())
s = list(map(int,input().split()))
result = functools.reduce(operator.mul,s)
if result > (mod):
    print(-1)
    exit()
else:
    print(result)

### FIXED CODE ###

a = int(input())
s =list(map(int,input().split()))
mod = 10 **18
ans = 1
if 0 in s:
    print(0)
    exit()
for i in s:
    ans = ans *i
    if ans > 1e18:
      print(-1)
      exit()
print(ans)
### BUGGY CODE ###

K=int(input())
N=0 #現在のルンルン数の数
i=0
while N<K:
    i+=1
    s=str(i)
    #ルンルン数のチェック
    t=0
    for j in range(len(s)-1):
        if abs(int(s[j])-int(s[j+1]))<=1:
            t+=1
        else:
            break
    if t==len(s)-1: #すべてのケタが条件を満たしていれば
        N+=1

print(i)


### FIXED CODE ###

K=int(input())
N=0 #現在のルンルン数の数
lun=list(range(1,10))
while 1:
    N+=1
    x=lun[N-1]
    if x%10 != 0:
        lun.append(10*x+x%10-1)
    lun.append(10*x+x%10)
    if x%10 != 9:
        lun.append(10*x+x%10+1)
    if N==K:
        break
print(lun[N-1])
### BUGGY CODE ###

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

sc = [0]*(n-k+1)
sc[0] = 1

for i in range(k):
    sc[0] *= A[i]

for i in range(1,n-k+1):
    sc[i] = (sc[i-1]/A[i-1])*A[k-1+i]
    if sc[i] > sc[i-1]:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

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

for i in range(n-k):
    if A[i] < A[k+i]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

N = int(input())
T = [0]*100000
X= [0]*100000
Y= [0]*100000
x = 0
y = 0

for n in range(N):
        T[n],X[n],Y[n] = (map(int, input().split()))

flag = 1
for n in range(N):
    #print(n)
    if flag == 0:
        break


    if n == 0:
        count = T[n]
    else:
        count = T[n] - T[n-1]
        x = X[n-1]
        y = Y[n-1]
    c = 0
    end = 0
    while True:
        if end == 1:
            break
        s_x = X[n] - x
        s_y = Y[n] - y
        #print(str(x)+' '+str(y))

        if ((s_x >= 0 or s_y >= 0) )and (c!=count):
            if s_x >0:
                x +=1
                c += 1
            elif s_x < 0:
                x -= 1
                c+=1
            elif s_y > 0:
                y +=1
                c += 1
            elif s_y < 0:
                y -= 1
                c+=1
            elif s_x==0:
                x +=1
                c +=1
        elif c==count:
            if (x == X[n] and y ==Y[n]):
                flag = 1
                end=1
            else:
                flag=0
                end =1


if flag == 1:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

N = int(input())
T = [0]*100000
X= [0]*100000
Y= [0]*100000
x = 0
y = 0

for n in range(N):
        T[n],X[n],Y[n] = (map(int, input().split()))

flag = 1
for n in range(N):
    #print(n)
    if flag == 0:
        continue


    if n == 0:
        count = T[n]
    else:
        count = T[n] - T[n-1]
        x = X[n-1]
        y = Y[n-1]
    c = 0
    end = 0
    while True:
        if end == 1:
            break
        s_x = X[n] - x
        s_y = Y[n] - y
    #    print(str(s_x)+' '+str(s_y))

        if ((s_x != 0 or s_y !=0) )and (c!=count):
            if s_x >0:
                x +=1
                c += 1
            elif s_x < 0:
                x -= 1
                c+=1
            elif s_y > 0:
                y +=1
                c += 1
            elif s_y < 0:
                y -= 1
                c+=1
        elif  ((s_x == 0 and s_y == 0) )and (c!=count):
                x +=1
                c +=1
        elif c==count:
            if (x == X[n] and y ==Y[n]):
                flag = 1
                end=1
            else:
                flag=0
                end =1



if flag == 1:
    print('Yes')
else:
    print('No')