Harryxun/stf_run huggingface dataset:
def abc(d, down_text, up_text):
    d[down_text] -= 1
    d[up_text] += 1


def main():
    n, a, b, c = map(int, input().split())
    ans_list = []
    dct = {"A": a, "B": b, "C": c}

    b_txt = input()
    if dct[b_txt[0]] == dct[b_txt[1]]:
        print('No')
        exit()

    for _ in range(n - 1):
        a_txt = input()
        l_txt = b_txt[0]
        r_txt = b_txt[1]

        if dct[l_txt] < dct[r_txt]:
            abc(dct, r_txt, l_txt)
            ans_list.append(l_txt)

        elif dct[l_txt] > dct[r_txt]:
            abc(dct, l_txt, r_txt)
            ans_list.append(r_txt)

        else:
            if dct[l_txt] == dct[r_txt] == 0:
                print('No')
                break
            else:
                if l_txt in a_txt:
                    abc(dct, r_txt, l_txt)
                    ans_list.append(l_txt)
                else:
                    abc(dct, l_txt, r_txt)
                    ans_list.append(r_txt)
        b_txt = a_txt
    else:
        if dct[a_txt[0]] == dct[a_txt[1]] == 0:
            print('No')
            exit()
        elif dct[a_txt[0]] < dct[a_txt[1]]:
            ans_list.append(a_txt[0])
        else:
            ans_list.append(a_txt[1])
        print('Yes')
        print(*ans_list, sep='\n')


if __name__ == "__main__":
    main()


### FIXED CODE ###

def abc(d, down_text, up_text):
    d[down_text] -= 1
    d[up_text] += 1


def main():
    n, a, b, c = map(int, input().split())
    ans_list = []
    dct = {"A": a, "B": b, "C": c}

    abc_list = [input() for _ in range(n)]
    abc_list.append('AB')

    for i in range(n):
        # a_txt = input()
        l_txt = abc_list[i][0]
        r_txt = abc_list[i][1]

        if dct[l_txt] < dct[r_txt]:
            abc(dct, r_txt, l_txt)
            ans_list.append(l_txt)

        elif dct[l_txt] > dct[r_txt]:
            abc(dct, l_txt, r_txt)
            ans_list.append(r_txt)

        else:
            if dct[l_txt] == dct[r_txt] == 0:
                print('No')
                break
            else:
                if l_txt in abc_list[i + 1]:
                    abc(dct, r_txt, l_txt)
                    ans_list.append(l_txt)
                elif r_txt in abc_list[i + 1]:
                    abc(dct, l_txt, r_txt)
                    ans_list.append(r_txt)
    else:
        print('Yes')
        print(*ans_list, sep='\n')


if __name__ == "__main__":
    main()
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    H, W, K = map(int, input().split())
    grid = [[_ for _ in input()] for _ in range(H)]

    ans = [[0] * W for _ in range(H)]
    cnt = 0
    for h in range(H):
        for w in range(W):
            if grid[h][w] == '#':
                ans[h][w] = cnt
                cnt += 1

    now=0
    for h in range(H):
        for w in range(W):
            if ans[h][w] != 0:
                now = ans[h][w]
            if ans[h][w] == 0:
                ans[h][w] = now

    now=0
    for h in reversed(range(H)):
        for w in range(W):
            if ans[h][w] != 0:
                now = ans[h][w]
            if ans[h][w] == 0:
                ans[h][w] = now
    
    for h in range(H):
        if ans[h][0] == 0:
            for w in range(W):
                ans[h][w] = ans[h - 1][w]

    for h in reversed(range(H)):
        if ans[h][0] == 0:
            for w in range(W):
                ans[h][w] = ans[h + 1][w]

    for a in ans:
        print(*a)



resolve()

### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    H, W, K = map(int, input().split())
    grid = [[_ for _ in input()] for _ in range(H)]

    ans = [[0] * W for _ in range(H)]
    cnt = 0
    for h in range(H):
        for w in range(W):
            if grid[h][w] == '#':
                cnt += 1
                ans[h][w] = cnt

    now = -1
    for h in range(H):
        for w in range(W):
            if ans[h][w] != 0:
                now = ans[h][w]
            if ans[h][w] == 0:
                if now != -1:
                    ans[h][w] = now
        now = -1

    now = -1
    for h in range(H):
        for w in reversed(range(W)):
            if ans[h][w] != 0:
                now = ans[h][w]
            if ans[h][w] == 0:
                if now != -1:
                    ans[h][w] = now
        now = -1

    for h in range(1,H):
        if ans[h][0] == 0:
            for w in range(W):
                ans[h][w] = ans[h - 1][w]

    for h in reversed(range(H-1)):
        if ans[h][0] == 0:
            for w in range(W):
                ans[h][w] = ans[h + 1][w]

    for a in ans:
        print(*a)


resolve()
a,b=map(int,input().split())
print(max(a+b,a=b,a*b))

### FIXED CODE ###

a,b=map(int,input().split())
print(max(a+b,a-b,a*b))
if not N==100:
    print(N*pow(100, D))
else:
    print(101*pow(100, D))

### FIXED CODE ###

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

if not N==100:
    print(N*pow(100, D))
else:
    print(101*pow(100, D))
import numpy as np

[H, W, M] = map(int, input().split())
mp = np.zeros((H+1, W+1), dtype=np.int64)
for i in range(M):
    [h, w] = map(int, input().split())
    mp[h][w] = 1

colsum = np.sum(mp, axis=0)
rowsum = np.sum(mp, axis=1)

maxcol = max(colsum)
maxrow = max(rowsum)

colchk = np.where(colsum==maxcol)
rowchk = np.where(rowsum==maxrow)

for i in range(len(rowchk[0])):
    for j in range(len(colchk[0])):
        if mp[rowchk[0][i]][colchk[0][j]] == 0:
            print(int(max(colsum)+max(rowsum)))
            quit()

print(int(max(colsum)+max(rowsum))-1)


### FIXED CODE ###

import numpy as np

[H, W, M] = map(int, input().split())
colsum = np.zeros(W+1)
rowsum = np.zeros(H+1)
bombs = []
rowbombs = [set() for i in range(H+1)]
for i in range(M):
    [h, w] = map(int, input().split())
    rowsum[h] += 1
    colsum[w] += 1
    bombs.append([h, w])
    rowbombs[h].add(w)

maxcol = max(colsum)
maxrow = max(rowsum)

colchk = np.where(colsum==maxcol)
rowchk = np.where(rowsum==maxrow)

for i in range(len(rowchk[0])):
    for j in range(len(colchk[0])):
        if colchk[0][j] not in rowbombs[rowchk[0][i]]:
            print(int(max(colsum)+max(rowsum)))
            quit()

print(int(max(colsum)+max(rowsum))-1)
N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]

sabun = []
for i in range(N):
    for j in range(N-i-1):
        p = xy[i][0] - xy[j+i+1][0]
        q = xy[i][1] - xy[j+i+1][1]
        # print(p,q)
        sabun.append([p,q])
count = [sabun.count(i) for i in sabun]
# print(sabun)
print(N-max(count))


### FIXED CODE ###

N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]


sabun = []
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        else:
            p = xy[i][0] - xy[j][0]
            q = xy[i][1] - xy[j][1]
            sabun.append([p,q])
count = [sabun.count(i)+sabun.count([-i[0],-i[1]]) for i in sabun]

if count == []:
    print("1")
else:
    print(int(N-(max(count))/2))
N=int(input())
chars="Xabcdefghijklmnopqrstuvwxyz")
N_rem=N
res=""
while True:
  x=N_rem%26
  if x==0:
    x=26
  res+=chars[x]
  N_rem-=x
  if N-rem==0:
    break
  N_rem//=26
print(res[::-1])
  

### FIXED CODE ###

n = int(input())
chars = "Xabcdefghijklmnopqrstuvwxyz"  # x番目がほしいときにchars[x-1]としたくないので、chars[0]は使わないことにします

n_rem = n  # 入力を直接操作すると、もし後々必要になったときに面倒なので
res = ""

while True:
    x = n_rem % 26
    # 余りが0、つまりzの場合は、26にします
    if x == 0:
        x = 26
    res += chars[x]

    # xを引いて、26で割ります
    n_rem -= x

    # 0なら終了します
    if n_rem == 0:
        break

    n_rem //= 26

# 0桁目が先頭で、最後の桁が末尾になっているので、反転させます
print(res[::-1])
import sys
input = sys.stdin.readline
#-------------------------------------
import math

a,b,c,d = map(int,input().split())
cd = c*d
bcnt = b-(b//c+b//d-b//(cd//math.gcd(c,d)))
acnt = 0
if a>1:
        a -= 1
        acnt = a-(a//c+a//d-a//(cd//math.gcd(c,d)))

print(bcnt-acnt)

### FIXED CODE ###

import sys
input = sys.stdin.readline
#-------------------------------------
def gcd( x, y ):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

a,b,c,d = map(int,input().split())
cd = c*d
bcnt = b-(b//c+b//d-b//(cd//gcd(c,d)))
acnt = 0
if a>1:
        a -= 1
        acnt = a-(a//c+a//d-a//(cd//gcd(c,d)))

print(bcnt-acnt)
MOD = 10**9+7
def inv_mod(a,p=MOD):
    def inv_mod_sub(a,p):
        if a == 1:
            return 1,0
        else:
            d,r = p//a,p%a
            x,y = inv_mod_sub(r,a)
            return y-d*x,x
    if p < 0: p = -p
    a %= p
    return inv_mod_sub(a,p)[0] % p

def comb_mod(n,k):
    if k < 0 or k > n:
        return 0
    else:
        return f_mod[n]*f_mod_inverse[k]*f_mod_inverse[n-k] % MOD

def f(a,b):
  return comb_mod(a+b,b)

r1,c1,r2,c2 = map(int,input().split())
f_mod=[1]*(10**6)
f_mod_inverse=[1]*(10**6)
for i in range(1,10**6):
  f_mod[i]=f_mod[i-1]*i%MOD
  f_mod_inverse[i]=f_mod_inverse[i-1]*inv_mod(i)%MOD
print((f(r2+1,c2+1)-f(r1,c2+1)-f(r2+1,c1)+f(r1,c1))%MOD)

### FIXED CODE ###

MOD = 10**9+7
def inv_mod(a,p=MOD):
    def inv_mod_sub(a,p):
        if a == 1:
            return 1,0
        else:
            d,r = p//a,p%a
            x,y = inv_mod_sub(r,a)
            return y-d*x,x
    if p < 0: p = -p
    a %= p
    return inv_mod_sub(a,p)[0] % p

def comb_mod(n,k):
    if k < 0 or k > n:
        return 0
    else:
        return f_mod[n]*f_mod_inverse[k]*f_mod_inverse[n-k] % MOD

def f(a,b):
  return comb_mod(a+b,b)

r1,c1,r2,c2 = map(int,input().split())
f_mod=[1]*(3*10**6)
f_mod_inverse=[1]*(3*10**6)
for i in range(1,3*10**6):
  f_mod[i]=f_mod[i-1]*i%MOD
  f_mod_inverse[i]=f_mod_inverse[i-1]*inv_mod(i)%MOD
print((f(r2+1,c2+1)-f(r1,c2+1)-f(r2+1,c1)+f(r1,c1))%MOD)
L = index()
print(L[::2]) 

### FIXED CODE ###

L = input()
print(L[::2])
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n = readi()
t = readl()

left = 0
right = 1
tt = [0] * (n + 1)
index = 0
mx = 0
current = 0
while(1):
    if t[left] >= t[right]:
        current += 1
        mx = max(current, mx)
    else:
        current = 0
    left += 1
    right += 1
    if left >= n or right >= n:
        break
print(mx)


### FIXED CODE ###

# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n = readi()
t = readl()

left = 0
right = 1
mx = 0
current = 0
if n == 1:
    print(0)
    exit()
while(1):
    if t[left] >= t[right]:
        current += 1
        mx = max(current, mx)
    else:
        current = 0
    left += 1
    right += 1
    if left >= n or right >= n:
        break
print(mx)
n=int(input())
A=list(map(int,input().split()))
cnt=0
if any(A%2==0):
    cnt+=1
print(cnt)





### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
cnt=0
for a in A:
    while a%2 == 0:
        cnt += 1
        a = a//2
print(cnt)
x = int(input())

a = 100
i = 0

while a < x:
  i += 1
  a += a // 100
  
  
print(math.floor(i))
  



### FIXED CODE ###

x = int(input())

a = 100
i = 0

while a < x:
  i += 1
  a += a // 100
  
  
print(i)
N = int(nput())
S, T = input().split()
ans = ""
for i in range(N):
  ans = ans + S[i:i+1] + T[i:i+1]
  
print(ans)

### FIXED CODE ###

N = int(input())
S, T = input().split()
ans = ""
for i in range(N):
  ans = ans + S[i:i+1] + T[i:i+1]
  
print(ans)
A, P = raw_input().split()
P += A*3
pi = int(P/3)
print (pi)

### FIXED CODE ###

A, P = map(int, input().split())
P += A*3
pi = int(P/2)
print (pi)
N = int(input())
 
A = [int(s) for s in input().split(" ")]
ABI = sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True)
prev = [0]
for k, (a,i) in enumerate(ABI):
  curr = [0]*(k+2)
  for l in range(k+1):
    curr[l] = max(curr[l], prev[l]+abs(N-i-k+l)*a)
    curr[l+1] = prev[l]+abs(i-l-1)*a
    print(curr,k,i)
  prev = curr
 
print(max(prev))

### FIXED CODE ###

N = int(input())
A = [int(s) for s in input().split(" ")]
ABI = sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True)
prev = [0]
for k, (a,i) in enumerate(ABI):
  curr = [0]*(k+2)
  for l in range(k+1):
    curr[l] = max(curr[l], prev[l]+abs(N-i-k+l)*a)
    curr[l+1] = prev[l]+abs(i-l-1)*a
    
  prev = curr
 
print(max(prev))
n,m = map(int,input().split())
a = list(map(int,input().split()))
a = a.sort()
for i in range(m):
  a[-1] = a[-1]*0.5
  a = a.sort()
sum( i//1 for i in a)

### FIXED CODE ###

def main():
  import heapq
  n,m = map(int,input().split())
  a =sorted(list(map(lambda x: int(x)*(-1),input().split())))
  heapq.heapify(a)
  for _ in range(m):
    x=heapq.heappop(a)/2
    heapq.heappush(a,x) 
  print(int(sum((-1)*i//1 for i in a)))
if __name__=='__main__':
  main()
s=str(input())
n=int(len(s))
a=int(((n-1)/2)+1)
b=int(((n+3)/2)+1)
if s[0]==s[a] and s[b]==s[n-1]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

s=str(input())
n=len(s)//2
f=s[:n]
if f==f[::-1] and f==s[n+1:]:
    print("Yes")
else:
    print("No")
input = input().split()

a = input[0] * input[1]

if (a%2 == 0):
	print("Even")
else:
	print("Odd")


### FIXED CODE ###

input = input().split()

a = int(input[0]) * int(input[1])

if (a%2 == 0):
	print("Even")
else:
	print("Odd")
import numpy as np
N, K = map(int, input().split())
# H = np.array([int(h) for h in input().split()])
H = np.array(list(map(int, input.split())))

dp = np.zeros(N, dtype=int)
k = np.array([i for i in range(1, K+1)])

for n in range(1, N):
    start = np.maximum(n-k, 0)
    if n < K:
        dp[n] = np.amin(dp[start] + np.abs(H[n]-H[start]))
    else:
        dp[n] = np.min(dp[n - k] + np.abs(H[n] - H[n - k]))


print(dp[N-1])



### FIXED CODE ###

import numpy as np
N, K = map(int, input().split())
# H = np.array([int(h) for h in input().split()])
H = np.array(list(map(int, input().split())))

dp = np.zeros(N, dtype=int)
k = np.array([i for i in range(1, K+1)])

for n in range(1, N):
    start = max(n-K, 0)
    #if n < K:
    #   dp[n] = np.amin(dp[start] + np.abs(H[n]-H[start]))
    #else:
    #   dp[n] = np.min(dp[n - k] + np.abs(H[n] - H[n - k]))
    dp[n] = np.min(dp[start:n] + np.abs(H[n]-H[start:n]))

print(dp[N-1])
N = int(input())
A = int(input())
print("No" if ((N % 500)>=A else "Yes")

### FIXED CODE ###

p = int(input())
one = int(input())
if (p%500)<=one:
  print("Yes")
else:
  print("No")
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
a = a.sort()
a = a[:3]
b = []
for i in [0,1,2]:
  for j in [0,1,2]:
    if i != j:
      b.append(int(str(a[i] + a[j])))
b.sort()
print(b[2])



### FIXED CODE ###

n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
a.sort()
a = a[:4]
b = []
for i in [0,1,2,3]:
  for j in [0,1,2,3]:
    if i != j:
      b.append(int(str(a[i]) + str(a[j])))
b.sort()
print(b[2])
def management(N,array):
	res = [0]
	for i in range(N):
      res[array[i]] += 1
    for j in range(len(res)):
      print(res[j])
     
    
    
N = int(input())
array = list(map(int,input().split())
managememt(N,array))

### FIXED CODE ###

import math
 
def round(R):
  return 2*R*math.pi
 
R = int(input())
print(round(R))
n = input()
h = input().split()
hl = [0]*n
 
for i in range(n):
  hi = h[i]
  hl[i] = int(hi)
 
ans = 1
m = n - 1
high = hl[0]
 
for i in range(m):
  if hl[i+1] >= high:
    ans += 1
    high = hl[i+1]
   else:
    continue
 
print(ans)

### FIXED CODE ###

n = int(input())
h = input().split()
 
ans = 1
m = n-1
high = int(h[0])
 
for i in range(m):
    if int(h[i+1]) >= high:
        ans += 1
        high = int(h[i+1])
    else:
        continue
        
 
print(ans)
N,Y=map(int,input().split())

flag=False

for i in range(N+1):
  for j in range(N+1):
    if(9000*i+4000*j==Y-1000*N):
      flag=True
      x=i
      y=j
      z=N-i-j
      
if(flag=True and z>=0):
  print(str(x)+" "+str(y)+" "+str(z))
else:
  print("-1 -1 -1")

### FIXED CODE ###

N,Y=map(int,input().split())

flag=False

for i in range(N+1):
  for j in range(N+1):
    if(9000*i+4000*j==Y-1000*N):
      flag=True
      x=i
      y=j
      z=N-i-j
      
if(flag==True and z>=0):
  print(str(x)+" "+str(y)+" "+str(z))
else:
  print("-1 -1 -1")
import networkx as nx
N,M = map(int, input().split())
E = [list(map(int,input().split())) for i in range(M)]

G = nx.Graph() 
G.add_edges_from(E)
di = nx.predecessor(G, source = 1)

print("Yes")
for i in range(2,N+1):
  print(di[i][0])


### FIXED CODE ###

def solve(n):
    p = n % 10
    if p in [2,4,5,7,9]:
        return "hon"
    elif p in [0,1,6,8]:
        return "pon"
    else:
        return "bon"

n = int(input())
print(solve(n))
def read():
    N, K = list(map(int, input().strip().split()))
    A = list(map(int, input().strip().split()))
    return N, K, A


def binary_digits(x):
    digit = 0
    while x > 0:
        x >>= 1
        digit += 1
    return digit


def maximum_X(N, K, A):
    digitK = binary_digits(K)
    counts = []
    bitmask = 1
    for d in range(digitK):
        count = 0
        for i in range(N):
            if A[i] & bitmask == bitmask:
                count += 1
        counts.append(count)
        bitmask <<= 1

    X = 0
    bitmask = 1
    for d in range(digitK):
        if counts[d] * 2 <= N:
            if K & bitmask == bitmask:
                X += bitmask
        bitmask <<= 1
    return X


def f(x, A):
    y = 0
    for a in A:
        y += (x ^ a)
    return y


def solve(N, K, A):
    X = maximum_X(N, K, A)
    return f(X, A)


if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))


### FIXED CODE ###

def read():
    T, X = map(int, input().strip().split())
    return T, X


def solve(T, X):
    return T / X


if __name__ == '__main__':
    inputs = read()
    print("%f" % solve(*inputs))
h,w = map(int, input().split())
s = []
for i in range(h):
    s.append(input())
dx = [0,0,1,-1]
dy = [1,-1,0,0]
def dfs(y,x):
    global check
    global was
    was[y][x] = 1
    if s[y][x] == "#":
        check[0] += 1
    else:
        check[1] += 1
    for k in range(4):
        nx = x + dx[k]
        ny = y + dy[k]
        if ny >= 0 and nx >= 0 and nx < w and ny < h and s[ny][nx] != s[y][x] and not was[ny][nx]:
            dfs(ny,nx)
ans = 0
was = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    for j in range(w):
        if not was[i][j]:
            check = [0,0]
            dfs(i,j)
            ans += check[0] * check[1]
print(ans)

### FIXED CODE ###

h,w = map(int, input().split())
s = []
for i in range(h):
    s.append(input())
import sys
sys.setrecursionlimit(200000)
dy = [0,0,1,-1]
dx = [1,-1,0,0]
def dfs(y,x):
    global check
    global was
    was[y][x] = 1
    if s[y][x] == "#":
        check[0] += 1
    else:
        check[1] += 1
    for k in range(4):
        nx = x + dx[k]
        ny = y + dy[k]
        if nx >= 0 and ny >= 0 and nx < w and ny < h and s[ny][nx] != s[y][x] and not was[ny][nx]:
            dfs(ny,nx)
ans = 0
was = [[0 for i in range(w)] for j in range(h)]
for i in range(w):
    for j in range(h):
        if not was[j][i]:
            check = [0,0]
            dfs(j,i)
            ans += check[0] * check[1]
print(ans)
n,m = map(int,input().split())
mod = 10**9 + 7
a = [-1] * (n+1)
a[0]=0
for i in range(1,m+1):
    b = int(input())
    a[b] = 0

if a[1] == 0:
    a[2] = 1
else:
    a[1] = 1
    if a[2] != 0:
        a[2] = 2
        
for i in range(3,n+1):
    if a[i] != 0:
        a[i] = a[i-1] + a[i-2]
#print(a)
print(a[n] % mod)

### FIXED CODE ###

n,m = map(int,input().split())
mod = 10**9 + 7
a = [1] * (n+1)
for i in range(m):
    b = int(input())
    a[b] = 0

        
for i in range(2,n+1):
    if a[i] != 0:
        a[i] = a[i-1] + a[i-2]
#print(a)
print(a[n] % mod)
n,m=map(int,imput().split())
if n==m:
	print('Yes')
else:
	print('No')

### FIXED CODE ###

n,m=map(int,input().split())
if n==m:
	print('Yes')
else:
	print('No')
n=int(input())
T,X,Y=0,0,0


for i in range(n):
    t,x,y=map(int,input().split())
    if abs(s-X)+abs(y-Y)>t-T or t%2!=(x+y)%2:
        print('No')
        exit()
    T,X,Y=t,x,y
print('Yes')

### FIXED CODE ###

N = int(input())
count = 0
T, X, Y = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    if abs(x-X)+abs(y-Y) <= t-T and t % 2 == (x+y) % 2:
        count += 1
    T, X, Y = t, x, y
if count==N:
    print('Yes')
else:
    print('No')
a,b=map(int,input().split())
print(100,100)
for i in range(50):
    for j in range(100):
        if a-1and (i+j)%2:
            print('.',end='')
            a-=1
        else:
            print('#',end='')
    print()
print('.'*100)
for i in range(49):
    for j in range(100):
        if b-1and (i+j)%2:
            print('#',end='')
            b-=1
        else:
            print('.',end='')
    print()
a,b=map(int,input().split())
print(100,100)
for i in range(50):
    for j in range(100):
        if a-1and (i+j)%2:
            print('.',end='')
            a-=1
        else:
            print('#',end='')
    print()
print('.'*100)
for i in range(49):
    for j in range(100):
        if b-1and (i+j)%2:
            print('#',end='')
            b-=1
        else:
            print('.',end='')
    print()
a,b=map(int,input().split())
print(100,100)
for i in range(50):
    for j in range(100):
        if a-1and (i+j)%2:
            print('.',end='')
            a-=1
        else:
            print('#',end='')
    print()
print('.'*100)
for i in range(49):
    for j in range(100):
        if b-1and (i+j)%2:
            print('#',end='')
            b-=1
        else:
            print('.',end='')
    print()
a,b=map(int,input().split())
print(100,100)
for i in range(50):
    for j in range(100):
        if a-1and (i+j)%2:
            print('.',end='')
            a-=1
        else:
            print('#',end='')
    print()
print('.'*100)
for i in range(49):
    for j in range(100):
        if b-1and (i+j)%2:
            print('#',end='')
            b-=1
        else:
            print('.',end='')
    print()

### FIXED CODE ###

a,b=map(int,input().split())
print(100,100)
for i in range(50):
    for j in range(100):
        if a-1and i%2and j%2:
            print('.',end='')
            a-=1
        else:
            print('#',end='')
    print()
for i in range(50):
    for j in range(100):
        if b-1and i%2and j%2:
            print('#',end='')
            b-=1
        else:
            print('.',end='')
    print()
import fractions
n,k=map(int,input().split())
if k==1:print(0)
else:print(gcd(n,k))

### FIXED CODE ###

n,k=map(int,input().split())
if n%k==0:print(0)
else:print(min(k-n%k,n%k))
import itertools
 
N, M = map(int, input().strip().split())
cakes = []
 
for _ in range(N):
  cake = list(map(int, input().strip().split()))
  cakes.append(abs(cake[0]) + abs(cake[1]) + abs(cake[2]))
  
print(sum(list(sorted(cakes, key=lambda x: -x)))[:M])

### FIXED CODE ###

n, m = map(int, input().split())
xyz = [tuple(map(int, input().split())) for _ in range(n)]

s1 = abs(sum(sorted([x+y+z for x, y, z in xyz])[:m]))
s2 = abs(sum(sorted([x+y-z for x, y, z in xyz])[:m]))
s3 = abs(sum(sorted([x-y+z for x, y, z in xyz])[:m]))
s4 = abs(sum(sorted([x-y-z for x, y, z in xyz])[:m]))
s5 = abs(sum(sorted([-x+y+z for x, y, z in xyz])[:m]))
s6 = abs(sum(sorted([-x+y-z for x, y, z in xyz])[:m]))
s7 = abs(sum(sorted([-x-y+z for x, y, z in xyz])[:m]))
s8 = abs(sum(sorted([-x-y-z for x, y, z in xyz])[:m]))

print(max(s1, s2, s3, s4, s5, s6, s7, s8))