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

R,C,K = map(int, input().split())
a = [[0] * (C+1) for i in range(R+1)]
dp = [[[0] * (C+1) for i in range(R+1)] for j in range(4)]
for i in range(K):
  r,c,v = map(int, input().split())
  a[r-1][c-1] = v
  
for i in range(R):
  for j in range(C):
    for k in range(2,-1,-1):
      dp[k+1][i][j] = max(dp[k+1][i][j], dp[k][i][j] + a[i][j])
    for k in range(4):
      dp[0][i+1][j] = max(dp[0][i+1][j], dp[k][i][j])
      dp[k][i][j+1] = max(dp[k][i][j+1], dp[k][i][j])
ans = 0
for k in range(4):
  ans = max(ans, dp[k][R-1][C-1])
print(ans)

### FIXED CODE ###

R,C,K = map(int, input().split())
a = [[0] * (C+1) for i in range(R+1)]
dp = [[[0] * (C+1) for i in range(R+1)] for j in range(4)]
for i in range(K):
  r,c,v = map(int, input().split())
  a[r-1][c-1] = v

for i in range(R):
  for j in range(C):
    for k in range(2, -1, -1):
      dp[k+1][i][j] = max(dp[k+1][i][j], dp[k][i][j]+a[i][j])
    for k in range(4):
      dp[0][i+1][j] = max(dp[0][i+1][j], dp[k][i][j])
      dp[k][i][j+1] = max(dp[k][i][j+1], dp[k][i][j])

    
ans = 0
for k in range(4):
  ans = max(ans, dp[k][R-1][C-1])
print(ans)
### BUGGY CODE ###

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

ans = -1

for i in range(0, n-k+1):
    k_start = i
    k_end = i + k - 1
    sum_exp = 0
    for dice in range(k_start, k_end+1):
        pi = p[dice]
        sum_exp += (pi + 1)/2
    ans = max(sum_exp, ans)

print(ans)

### FIXED CODE ###

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

p_exp = [(p[i] + 1)/2 for i in range(n)]

s = [0]
for i in range(n):
    s.append(s[i] + p_exp[i])

ans = -1

for i in range(0, n-k+1):
    k_start = i
    k_end = i + k
    
    sum_exp = s[k_end] - s[k_start]
    
    ans = max(sum_exp, ans)

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

import heapq
import sys

input = sys.stdin.readline

inf = 10**13

N,M,S = map(int,input().split())

data = [[] for _ in range(N)]

sumA = 0

for i in range(M):
    U,V,A,B = map(int,input().split())
    sumA += A
    U -= 1
    V -= 1
    data[U].append((B,V,A))###(距離, 行き先, 費用)
    data[V].append((B,U,A))###(距離, 行き先, 費用)

P = sumA

C = [0]*N
D = [0]*N

for i in range(N):
    C[i],D[i] = map(int,input().split())

dist = [[inf]*(P+1) for _ in range(N)]
#visit = [[0]*(P+1) for _ in range(N)]
###heapにぶち込んだことがあるかないか

q = [(0,0,min(S,P))]###(仮の最短距離, 頂点番号, 所持金)
heapq.heapify(q)

while q:
    v = heapq.heappop(q)
    if v[0] >= dist[v[1]][v[2]]:
        continue
    dist[v[1]][v[2]] = v[0]

    if v[2] + C[v[1]] <= P:
        heapq.heappush(q,(v[0]+D[v[1]],v[1],v[2]+C[v[1]]))

    for x in data[v[1]]:
        if x[2] > v[2]:
            continue
        heapq.heappush(q,(v[0]+x[0],x[1],v[2]-x[2]))
    
    ###
    #print(P)
    #print(q)
    #print(v)
    ###

for i in range(1,N):
    print(min(dist[i]))
        



### FIXED CODE ###

import heapq
import sys

input = sys.stdin.readline

inf = 10**13

N,M,S = map(int,input().split())

data = [[] for _ in range(N)]

sumA = 0

for i in range(M):
    U,V,A,B = map(int,input().split())
    sumA += A
    U -= 1
    V -= 1
    data[U].append((B,V,A))###(距離, 行き先, 費用)
    data[V].append((B,U,A))###(距離, 行き先, 費用)

P = sumA

C = [0]*N
D = [0]*N

for i in range(N):
    C[i],D[i] = map(int,input().split())

dist = [[inf]*(P+1) for _ in range(N)]
#visit = [[0]*(P+1) for _ in range(N)]
###heapにぶち込んだことがあるかないか

q = [(0,0,min(S,P))]###(仮の最短距離, 頂点番号, 所持金)
heapq.heapify(q)

while q:
    v = heapq.heappop(q)
    if v[0] >= dist[v[1]][v[2]]:
        continue
    dist[v[1]][v[2]] = v[0]

    if v[2] + C[v[1]] <= P:
        if dist[v[1]][v[2]+C[v[1]]] == inf:
            heapq.heappush(q,(v[0]+D[v[1]],v[1],v[2]+C[v[1]]))

    for x in data[v[1]]:
        if x[2] > v[2]:
            continue
        if dist[x[1]][v[2]-x[2]] == inf:
            heapq.heappush(q,(v[0]+x[0],x[1],v[2]-x[2]))
    
    ###
    #print(P)
    #print(q)
    #print(v)
    ###

for i in range(1,N):
    print(min(dist[i]))
### BUGGY CODE ###

from collections import deque
import sys

sys.setrecursionlimit(10**7)
H,W=map(int,input().split())
sy,sx=map(int,input().split())
gy,gx=map(int,input().split())

sx,sy=sx-1,sy-1
gx,gy=gx-1,gy-1

maze=[[i for i in input()] for _ in range(H)]

visited = [[-1]*W for _ in range(H)]
queue = deque([])
queue.append((sx,sy))
visited[sy][sx] = 0
def bfs(v,queue,gx,gy,maze):
    check=deque([])



    while len(queue) != 0:
        n = queue.popleft()
        x,y = n[0], n[1]
        flag=0

        if n == (gx,gy):
            print(v)
            exit()

        for i, j in [(1,0), (0,1), (-1,0), (0,-1)]:
            if (x+i < 0) or (x+i >=W) or (y+j < 0) or (y+j >=H):
                continue
            if maze[y+j][x+i] == '.' and visited[y+j][x+i] == -1:
                queue.append((x+i,y+j))
                visited[y+j][x+i] = v
            elif maze[y+j][x+i] == '#':
                flag=1
        if flag==1:
            check.append((x,y))

    while len(check) != 0:
        n=check.popleft()
        x,y=n[0],n[1]
        for i in range(-2,3):
            for j in range(-2,3):
                if (x+i < 0) or (x+i >=W) or (y+j < 0) or (y+j >=H):
                    continue
                if maze[y+j][x+i] == '.' and visited[y+j][x+i] == -1:
                    queue.append((x+i,y+j))
                    visited[y+j][x+i] = v+1

    if len(queue)!=0:
        bfs(v+1,queue,gx,gy,maze)



bfs(0,queue,gx,gy,maze)
print(-1)

### FIXED CODE ###

from collections import deque
import sys

sys.setrecursionlimit(10**7)
H,W=map(int,input().split())
sy,sx=map(int,input().split())
gy,gx=map(int,input().split())

sx,sy=sx-1,sy-1
gx,gy=gx-1,gy-1

maze=[[i for i in input()] for _ in range(H)]

visited = [[-1]*W for _ in range(H)]
queue = deque([])
queue.append((sx,sy))
visited[sy][sx] = 0
def bfs(v,queue,gx,gy,maze):
    check=deque([])



    while len(queue) != 0:
        n = queue.popleft()
        x,y = n[0], n[1]
        flag=0

        if n == (gx,gy):
            print(v)
            exit()

        for i, j in [(1,0), (0,1), (-1,0), (0,-1)]:
            if (x+i < 0) or (x+i >=W) or (y+j < 0) or (y+j >=H):
                continue
            if maze[y+j][x+i] == '.' and visited[y+j][x+i] == -1:
                queue.append((x+i,y+j))
                visited[y+j][x+i] = v
            elif maze[y+j][x+i] == '#':
                flag=1
        if flag==1:
            check.append((x,y))

    while len(check) != 0:
        n=check.popleft()
        x,y=n[0],n[1]
        for i in range(-2,3):
            for j in range(-2,3):
                if (x+i < 0) or (x+i >=W) or (y+j < 0) or (y+j >=H):
                    continue
                if maze[y+j][x+i] == '.' and visited[y+j][x+i] == -1:
                    queue.append((x+i,y+j))
                    visited[y+j][x+i] = v+1

    if len(queue)!=0:
        bfs(v+1,queue,gx,gy,maze)



bfs(0,queue,gx,gy,maze)
print(-1)
### BUGGY CODE ###

# coding: utf-8

S = input()
Q = int(input())

query = []

for i in range(Q):
    query.append(input().split())


left = True
for i in query:
    if len(i) == 1:
        left = not left

    else:
        if i[1]=="1":
            if left:
                S = i[2]+S
            else:
                S += i[2]
        else:
            if left:
                S += i[2]
            else:
                S = i[2]+S

print(S) if left else print(S[::-1])


### FIXED CODE ###

# coding: utf-8

S = input()
Q = int(input())

query = []

for i in range(Q):
    query.append(input().split())


bool = True
pre =''
suf =''

for i in query:
    if len(i) == 1:
        bool = not(bool)

    else:
        if i[1]=="1":
            if bool:
                pre = i[2]+pre
            else:
                suf += i[2]
        else:
            if bool:
                suf += i[2]
            else:
                pre = i[2]+pre

S = pre+ S +suf
print(S) if bool else print(S[::-1])
### BUGGY CODE ###

N,Q=[int(s) for s in input().split()]
e_list=[[int(s) for s in input().split()] for i in range(N-1)]
q_list=[[int(s) for s in input().split()] for i in range(Q)]
#########深さ優先探索DFS
#########到達可能なもののうち新しく追加されたものを見る
#########訪れた順番を出力
def euler_tour(edge_list,start):
  reach=[[start,1,0]]
  ans=[start]
  path=[start]
  e_list=[[e[0],e[1],0] for e in edge_list]
  vertex=start
  endflag=0
  depth=1
  while True :
    ###まずvertexから到達可能なものをすべてreachに入れる
    #辺の始点がvertexであるもの
    for e in e_list:
      if (e[0]==vertex and e[2]==0):
        reach.append([e[1],0,depth])
        e[2]=1
      elif (e[1]==vertex and e[2]==0):
        reach.append([e[0],0,depth])
        e[2]=1
    ###起点になっていないもののうち最後にreachに入ったものを、次の起点とする
    for i in range(len(reach)+1):
      if reach[-i][1]==0 :
        vertex=reach[-i][0]
        #####depthが戻ったか？
        if reach[-i][2]<depth:
           ##戻った分だけpathをansに追加
          for j in range(1,depth-reach[-i][2]+1):
            path.remove(path[-1])
            ans.append(path[-1])
        ans.append(vertex)
        path.append(vertex)
        depth=reach[-i][2]+1
        #####ここでprint(vertex)などを入れる
        reach[-i][1]=1
        break
      if i==len(reach):  ####全ての場所に行っていれば終了
        for j in range(len(path)-1):
            path.remove(path[-1])
            ans.append(path[-1])
        return ans
        break
euler=euler_tour(e_list,1)
def eu(num):
  if num==1:
    return [i+1 for i in range(N)]
  ans=[]
  i=-1
  while True :
    i+=1
    if euler[i]==num:
      ii=euler[i-1]
      break
  while True:
    if euler[i]==ii:
      break
    ans.append(euler[i])
    i+=1
  return list(set(ans))
answer=[0 for i in range(N)]
for q in q_list:
  for v in eu(q[0]):
    answer[v-1]+=q[1]
print(*answer)

### FIXED CODE ###

N,Q=[int(s) for s in input().split()]
#辺でつながれた場所をすべてリストアップ
con_list=[set() for s in range(N+1)]
for i in range(N-1):
  a,b=[int(s) for s in input().split()]
  con_list[a].add(b)
  con_list[b].add(a)

v_list=[0 for s in range(N+1)]
for i in range(Q):
  x,y=[int(s) for s in input().split()]
  v_list[x]+=y

position=1 #現在位置
counter=v_list[1] #カウンター
ans_list=[0 for s in range(N+1)] #答え
ans_list[1]=counter 
vertex_num=1 #訪れた場所の数
oya_list=[-1 for s in range(N+1)] #親に戻るためのリスト

while vertex_num<N:
  #まだ行っていない子があるか？
  if len(con_list[position])>0:
    x=con_list[position].pop()
    con_list[x].remove(position) #xの行先から親を消す
    oya_list[x]=position
    position=x
    counter+=v_list[position] #カウンターの更新
    ans_list[position]=counter
    vertex_num+=1
  else: #行き先がないなら戻る
    position=oya_list[position]
    counter=ans_list[position] #カウンターを戻す
print(*ans_list[1:])
### BUGGY CODE ###

N, X, Y = map(int, input().split())
X -= 1
Y -= 1
if X > Y:
    X, Y = Y, X

ans = [0] * (N - 1)
for i in range(N - 1):
    for j in range(i + 1, N):
        ij = j - i
        ix = abs(i - X)
        iy = abs(i - Y)
        jx = abs(j - X)
        jy = abs(j - Y)

        minn = ij
        minn = min(minn, ix + 1 + jy)
        minn = min(minn, iy + 1 + jx)

        ans[minn - 1] += 1

for i in ans:
    print(i)

### FIXED CODE ###

N, X, Y = map(int, input().split())
X -= 1
Y -= 1
if X > Y:
    X, Y = Y, X

ans = [0] * (N - 1)
for i in range(N - 1):
    for j in range(i + 1, N):
        ij = j - i
        ix = abs(i - X)
        iy = abs(i - Y)
        jx = abs(j - X)
        jy = abs(j - Y)

        minn = ij
        minn = min(minn, ix + 1 + jy)
        minn = min(minn, iy + 1 + jx)

        ans[minn - 1] += 1

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

import sys,math,collections,itertools
input = sys.stdin.readline

N,M,R=list(map(int,input().split()))
r=list(map(int,input().split()))
ABC = [[float('inf')]*(N+1) for _ in range(N+1)]
#条件のうち、重複経路は最短のみ残す
for _ in range(M):
    a,b,c = map(int,input().split())
    if ABC[a][b]>c:
        ABC[a][b]=c
        ABC[b][a]=c
#整理
road = [[] for _ in range(N+1)]
for i in range(1,N+1):
    for j in range(1,N+1):
        if ABC[i][j] != float('inf'):
            road[i].append((j,ABC[i][j]))
#各頂点間の最小距離
dist = [[float('inf')]*(N+1) for _ in range(N+1)]
q=collections.deque([])
q.append(1)
while q:
    now = q.popleft()
    for goto,cost in road[now]:
        if dist[now][goto]>cost:
            dist[now][goto] = cost
            dist[goto][now] = cost
            q.append(goto)

rotate = itertools.permutations(range(1,N+1))
ans = float('inf')
for rot in rotate:
    tmp = 0
    rset = set(r)
    for i in range(len(rot)-1):
        if tmp == 0 and rot[i] not in rset:
            break
        tmp +=dist[rot[i]][rot[i+1]]
        rset.discard(rot[i])
        rset.discard(rot[i+1])
        if tmp>ans:
            break
        if len(rset) == 0:
            ans = min(ans,tmp)
            break
print(ans)
        
        



### FIXED CODE ###

import sys,math,collections,itertools
input = sys.stdin.readline

N,M,R=list(map(int,input().split()))
r=list(map(int,input().split()))
ABC = [[float('inf')]*(N+1) for _ in range(N+1)]
#条件のうち、重複経路は最短のみ残す
for _ in range(M):
    a,b,c = map(int,input().split())
    if ABC[a][b]>c:
        ABC[a][b]=c
        ABC[b][a]=c

#各頂点間の最小距離 Warshall-Floyd
dist = [[float('inf')]*(N+1) for _ in range(N+1)]
for k in range(1,N+1):
    for i in range(1,N+1):
        for j in range(1,N+1):
            ABC[i][j] = min(ABC[i][j],ABC[i][k] + ABC[k][j])

rotate = itertools.permutations(r)
ans = float('inf')
for rot in rotate:
    tmp = 0
    flag = 0
    for i in range(len(rot)-1):
        tmp +=ABC[rot[i]][rot[i+1]]
        if tmp>ans:
            flag = 1
            break
    if flag==0:
        ans = min(ans,tmp)
print(ans)
### BUGGY CODE ###

import bisect
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
Query = []
for _ in range(m):
    b,c = map(int,input().split())
    Query.append([c,b])
Query.sort(reverse=True)
for i in range(m):
    b,c = Query[i][1],Query[i][0]
    if min(A) >= c:
        break
    else:
        A.sort()
        index = bisect.bisect_left(A,c)
        if b <= index:
            for i in range(b):
                A[i] = c
        else:
            for i in range(index):
                A[i] = c
print(sum(A))

### FIXED CODE ###

import sys
input = sys.stdin.readline
import bisect
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

minA = A[0]
Query = []
for _ in range(m):
    b,c = map(int,input().split())
    if c > minA:
        Query.append([b,c])
Query = sorted(Query, key=lambda x:(x[1], x[0]), reverse=True)

ans = 0
index = 0
for b,c in Query:
    if index >= n:
        break
    #print("----")
    cnt = 0
    Flag = True
    while Flag:
        #print(A,b,c,index)
        if A[index] < c:
            A[index] = c
            cnt += 1
            index += 1
            if (cnt >= b) or (index >= n):
                Flag = False
        else:
            Flag = False
    '''
    #A.sort()
    if A[0] >= c:
        break
    else:
        index = min(bisect.bisect_left(A,c),b)
        if index > len(A):
            ans += c * len(A)
            break
        else:
            ans += c * index
            A = A[index:]
    print(A)
    '''
print(sum(A))
### BUGGY CODE ###

import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    X = il()
    S = sorted(X)
    for x in X:
        idx = S.index(x)
        if idx < N // 2:
            print(S[N // 2])
        else:
            print(S[N // 2 - 1])


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    X = il()
    S = sorted(X)
    l = S[N // 2 - 1]
    r = S[N // 2]
    for x in X:
        if x <= l:
            print(r)
        else:
            print(l)


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

nums = list(map(int, input().split()))
n = nums[0]
k = nums[1]

def absolute(n,k):
    return abs(n-k)

x = absolute(n, k)
if n % k == 0:
    print(0)
elif n < x:
    print(n)
else:
    while absolute(x, k) < x:
        x = absolute(x, k)

    print(x)



### FIXED CODE ###

nums = list(map(int, input().split()))
n = nums[0]
k = nums[1]

def absolute(n,k):
    return abs(n-k)

x = absolute(n, k)
if n % k == 0:
    print(0)
elif n < x:
    print(n)
else:
    while absolute(x, k) < x:
        x = x % k
        x = absolute(x, k)

    print(x)
### BUGGY CODE ###

H,W = (int(x) for x in input().split())
a = []
que = []
dis =[]
longDis = 0

for i in range(H):
    a += list(input().split())

h = -1
w = 0

for _ in range(H*W):
    k = 0
    dis = [k]
    l = 0

    if h < H-1:
        h += 1
    else:
        h = 0
        w += 1

    if a[h][w] != '.':
        continue

    que += [[h,w]]
    i = h
    j = w
    
    while True:
        k = dis[l] + 1

        #上
        if i-1 >= 0 and a[i-1][j] =='.':
            if [i-1,j] not in que:
                que += [[i-1,j]]
                dis += [k]

        #下
        if i+1 < H and a[i+1][j] == '.':
            if [i+1,j] not in que:
                que += [[i+1,j]]
                dis += [k]

        #左
        if j-1 >= 0 and a[i][j-1] == '.':
            if [i,j-1] not in que:
                que += [[i,j-1]]
                dis += [k]

        #右
        if j+1 < W and a[i][j+1] == '.':
            if [i,j+1] not in que:
                que += [[i,j+1]]
                dis += [k]

        l += 1

        if l == len(que):
            break
        
        i = que[l][0]
        j = que[l][1]


    for i in range(len(dis)):
        if dis[i] > longDis:
            longDis = dis[i]

    dis.clear()
    que.clear()

print(longDis)


### FIXED CODE ###

H,W = (int(x) for x in input().split())
a = []
que = []
dis =[]
longDis = 0

for i in range(H):
    a += list(input().split())

h = -1
w = 0

for _ in range(H*W):
    com = [[0 for i in range(W)] for j in range(H)]
    k = 0
    dis = [k]
    l = 0

    if h < H-1:
        h += 1
    else:
        h = 0
        w += 1

    if a[h][w] != '.':
        continue

    que += [[h,w]]
    com[h][w] = 1
    i = h
    j = w
    
    while True:
        k = dis[l] + 1

        #上
        if i-1 >= 0 and a[i-1][j] == '.':
            if com[i-1][j] == 0:
                que += [[i-1,j]]
                dis += [k]
                com[i-1][j] = 1

        #下
        if i+1 < H and a[i+1][j] == '.':
            if com[i+1][j] == 0:
                que += [[i+1,j]]
                dis += [k]
                com[i+1][j] = 1

        #左
        if j-1 >= 0 and a[i][j-1] == '.':
            if com[i][j-1] == 0:
                que += [[i,j-1]]
                dis += [k]
                com[i][j-1] = 1 

        #右
        if j+1 < W and a[i][j+1] == '.':
            if com[i][j+1] == 0:
                que += [[i,j+1]]
                dis += [k]
                com[i][j+1] = 1

        l += 1

        if l == len(que):
            break
        
        i = que[l][0]
        j = que[l][1]

    for i in range(len(dis)):
        if dis[i] > longDis:
            longDis = dis[i]

    dis.clear()
    que.clear()

print(longDis)
### BUGGY CODE ###

def test():
    n = int(input())
    t = [0 for _ in range(n+1)]
    x = [0 for _ in range(n+1)]
    y = [0 for _ in range(n+1)]
    for i in range(n):
        t[i+1], x[i+1], y[i+1] = [int(z) for z in input().split()]
        # print(t,x,y)
    dt = [t[i+1] - t[i] for i in range(n)]
    dist = [abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]) for i in range(n)]
    # print(dt, dist)
    result = "Yes"

    for i in range(len(t)):
        if not t[i] % 2 == (abs(x[i])+abs(y[i])) % 2:
            result = "No"

    for i in range(len(dt)):
        if dt < dist:
            result = "No"

    print(result)


test()


### FIXED CODE ###

n = int(input())
t = [0 for _ in range(n+1)]
x = [0 for _ in range(n+1)]
y = [0 for _ in range(n+1)]
for i in range(n):
    t[i+1], x[i+1], y[i+1] = [int(z) for z in input().split()]
    if t[i+1] - t[i] < abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]) or (t[i+1] % 2 != (abs(x[i+1]) + abs(y[i+1])) % 2):
        print('No')
        exit()
print('Yes')
### BUGGY CODE ###

N, M = [int(x) for x in input().split()]
AB = [[int(x) for x in input().split()] for _ in range(N)]

AB_dict = {}
for i in range(M):
    AB_dict[i + 1] = []
for i in range(N):
    if AB[i][0] > M:
        continue
    AB_dict[AB[i][0]].append(AB[i][1])

Job = []
ans = 0
for i in range(M):
    Job = Job + AB_dict[i + 1]
    if len(Job) != 0:
        ans += max(Job)
        Job.remove(max(Job))

print(ans)

### FIXED CODE ###

N, M = [int(x) for x in input().split()]
AB = [[int(x) for x in input().split()] for _ in range(N)]

import heapq
AB_dict = {}
for i in range(M):
    AB_dict[i + 1] = []
for i in range(N):
    if AB[i][0] > M:
        continue
    AB_dict[AB[i][0]].append(-AB[i][1])

Job = []
ans = 0
for i in range(M):
    for j in range(len(AB_dict[i + 1])):
        heapq.heappush(Job, AB_dict[i + 1][j])
    if len(Job) != 0:
        ans -= heapq.heappop(Job)
        
print(ans)
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()

for _ in range(Q):
    tmp = 0
    cnt = 0
    l, r = map(int,input().split())
    for i in list(S[l-1:r]):
        if 'A' == i:
            tmp = 1
        elif tmp == 1 and 'C' == i:
            cnt += 1
            tmp = 0
        else:
            tmp = 0

    print(cnt)

### FIXED CODE ###

n,q=map(int,input().split())
s=input()
a=[0]*n

for i in range(n-1):
  a[i+1]=a[i]+(1 if s[i:i+2]=='AC' else 0)

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

# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
from operator import itemgetter

# なんこか入力
n,m = map(int, input().split())


# n行の複数列ある数値を二次元配列へ。x[n][?]
x = [[int(i) for i in input().split()] for i in range(n)] 

z = sorted(x,key=itemgetter(0))
x = sorted(z,key=itemgetter(1), reverse=True)

#x = sorted(z, key=lambda z: -z[1])
y = [0]*m
#print(x)


for i in range(n):
    for j in range(x[i][0]-1,m):
        if y[j] == 0:
            y[j] = x[i][1]
            break
#    print(y)

answer=0
for i in range(m):
    answer += y[i]
print(answer)






### FIXED CODE ###

# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import heapq
from operator import itemgetter

# なんこか入力
n,m = map(int, input().split())

# n行の複数列ある数値を二次元配列へ。x[n][?]
x = [[int(i) for i in input().split()] for i in range(n)] 

x = sorted(x,key=itemgetter(1),reverse = True)
x = sorted(x,key=itemgetter(0))

work = []
j = 0
answer = 0
for i in range(1,m+1,1):
    while j < n and x[j][0] == i:
        heapq.heappush(work,-x[j][1])
#        print(work)
        j += 1
    if work:
        answer -= heapq.heappop(work)

print(answer)