TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate.  You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds.  It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.

Submission attempts (in order):
import sys

sys.setrecursionlimit(10**8)

def find(x):	
	global table
	global diff_weight
	
	if table[x] == x:
		return x
	else:
		diff_weight[x] += diff_weight[table[x]] 
		table[x] = find(table[x])	
		return table[x]

def union(x,y,w):	
	w = w - weight(y) + weight(x) 
	x = find(x)	
	y = find(y)
	
	if x == y:
		return
	
	if rank[x] < rank[y]:
		x,y = y,x
		w = -w
	
	table[y] = x
	diff_weight[y] = w
	
	if rank[x] == rank[y]:
			rank[y] += 1

def check(x,y): 
	if find(x) == find(y):
		return True
	else:
		return False

def weight(x):
	find(x)	
	return diff_weight[x]
		
def diff(x,y): 
	return (weight(y) - weight(x))

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

table = [i for i in range(N)]	
rank  = [1 for i in range(N)]	
diff_weight = [0 for i in range(N)]


for i in range(M):
	a,b,D = (map(int,input().split()))
	a -= 1
	b -= 1
	if check(a,b):
		if diff(a,b) != D:
			print ('table',table)
			print ('weight',diff_weight)
			print('No')
			sys.exit()
	else:
		union(a,b,D)
	print ('table',table)
	print ('weight',diff_weight)
	
	
print ('Yes')

import sys

sys.setrecursionlimit(10**8)

def find(x):	
	global table
	global diff_weight
	
	if table[x] == x:
		return x
	else:
		root = find(table[x])
		diff_weight[x] += diff_weight[table[x]] 
		table[x] = root	
		return table[x]

def union(x,y,w):	
	w = w - weight(y) + weight(x) 
	x = find(x)	
	y = find(y)
	
	if x == y:
		return
	
	if rank[x] < rank[y]:
		x,y = y,x
		w = -w
	
	table[y] = x
	diff_weight[y] = w
	
	if rank[x] == rank[y]:
			rank[y] += 1

def check(x,y): 
	if find(x) == find(y):
		return True
	else:
		return False

def weight(x):
	find(x)	
	return diff_weight[x]
		
def diff(x,y): 
	return (weight(y) - weight(x))

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

table = [i for i in range(N)]	
rank  = [1 for i in range(N)]	
diff_weight = [0 for i in range(N)]


for i in range(M):
	a,b,D = (map(int,input().split()))
	a -= 1
	b -= 1
	if check(a,b):
		if diff(a,b) != D:
			print('No')
			sys.exit()
	else:
		union(a,b,D)
	
	
print ('Yes')

Verdicts: Runtime Error

Accepted
Problem: There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate.  You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds.  It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.

Submission attempts (in order):
import sys
from collections import deque

n,m = map(int, input().split())
adj_list = [[] for i in range(n)]
for i in range(m):
    l, r, d = map(int, input().split())
    adj_list[l-1].append((r-1, d))
    adj_list[r-1].append((l-1, -d))
def search(start, dist_all):
    q = deque([[start]])
    q_d = deque([0])
    while(len(q) > 0):
        path = q.popleft()
        dist = q_d.popleft()
        w = path[len(path) - 1]
        for x in adj_list[w]:
            if dist_all[x[0]] is None:
                dist_all[x[0]] = dist + x[1]
                new_path = path[:]
                new_path.append(x[0])
            elif dist_all[x[0]] != dist + x[1]:
                return False
            q.append(new_path)
            q_d.append(dist + x[1])
    return True
dist_all = [None for i in range(n)]
for i in range(n):
    if dist_all[i] is None:
        if not search(i, dist_all):
            print('No')
            exit(0)
print('Yes')

import sys
from collections import deque

n,m = map(int, input().split())
adj_list = [[] for i in range(n)]
for i in range(m):
    l, r, d = map(int, input().split())
    adj_list[l-1].append((r-1, d))
    adj_list[r-1].append((l-1, -d))
def search(start, dist_all):
    q = deque([start])
    dist_all[i] = 0
    while(len(q) > 0):
        w = q.popleft()
        for x in adj_list[w]:
            if dist_all[x[0]] is None:
                dist_all[x[0]] = dist_all[w] + x[1]
                q.append(x[0])
            elif dist_all[x[0]] != dist_all[w] + x[1]:
                return False
    return True
dist_all = [None for i in range(n)]
for i in range(n):
    if dist_all[i] is None:
        if not search(i, dist_all):
            print('No')
            exit(0)
print('Yes')

Verdicts: Wrong Answer

Accepted
Problem: There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate.  You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds.  It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.

Submission attempts (in order):
from collections import deque
N, M = map(int, input().split())
Inf = 10000000000
Edge = [[] for i in range(N)]
for i in range(M):
    l, r, d = map(int, input().split())
    Edge[l-1].append((r-1, d))
    Edge[r-1].append((l-1, -d))
 
Node = [Inf for i in range(N)]
Possible = True
for i in range(N):
    if not Possible:
        break
    elif Node[i] == Inf:
        Node[i] = 0
        Q = [i]
        while Q:
            now = deque.popleft(Q)
            for e in Edge[now]:
                if Node[e[0]] == Inf:
                    Node[e[0]] = Node[now] + e[1]
                    Q.append(e[0])
                elif Node[now] + e[1] != Node[e[0]]:
                    Possible = False
                    break
print("Yes" if Possible else "No")

from collections import deque
N, M = map(int, input().split())
Inf = 10000000000
Edge = [[] for i in range(N)]
for i in range(M):
    l, r, d = map(int, input().split())
    Edge[l-1].append((r-1, d))
    Edge[r-1].append((l-1, -d))
 
Node = [Inf for i in range(N)]
Possible = True
for i in range(N):
    if not Possible:
        break
    elif Node[i] == Inf:
        Node[i] = 0
        Q = deque([i])
        while Q:
            now = Q.popleft()
            for e in Edge[now]:
                if Node[e[0]] == Inf:
                    Node[e[0]] = Node[now] + e[1]
                    Q.append(e[0])
                elif Node[now] + e[1] != Node[e[0]]:
                    Possible = False
                    break
print("Yes" if Possible else "No")

Verdicts: Runtime Error

Accepted
Problem: There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate.  You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds.  It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.

Submission attempts (in order):
import heapq

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

C=[0 for i in range(N+1)]
L=[[]for i in range(N+1)]
A=[0 for i in range(N+1)]
B=[]

for i in range(M):
    l,r,d=map(int,input().split())
    B.append([l,r,d])
    C[r]=1
    L[l].append([l,r,d])
for i in range(N+1):
    if C[i]==0:
        A[i]=0
for i in range(1,N+1):
    if A[i]==0:
        if len(L[i])>0:
            Q=[]
            for l,r,d in L[i]:
                Q.append([A[i]+d,r,l])
            #print(Q)
            heapq.heapify(Q)
            for j in range(10**6):
                if len(Q)==0:
                    break
                else:
                    q=Q[0]
                    if A[q[1]]>=q[0]:
                        A[q[1]]=q[0]
                        for k in L[q[1]]:
                            heapq.heappush(Q,[q[0]+k[2],k[1],k[0]])
                heapq.heappop(Q)
#print(C)
#print(A)
for i in range(M):

    if A[B[i][1]]!=A[B[i][0]]+B[i][2]:
        print("No")
        exit()
print("Yes")

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

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

L=[[]for i in range(N+1)]
D=dict()
for i in range(M):
    l,r,d=map(int,input().split())
    L[l].append([r,d])
    L[r].append([l,-d])
    D[i]=(l,r,d)
    
C=["N" for i in range(N+1)]

def dfs(x):
    for i,j in L[x]:
        if C[i]=="N":
            C[i]=C[x]+j
            dfs(i)

for i in range(1,N+1):
    if C[i]=="N":
        C[i]=0
        dfs(i)
#print(C)
#print(D)
for i in range(M):
    l,r,d=D[i]
    if C[r]-C[l]!=d:
        print("No")
        exit()
print("Yes")

Verdicts: Wrong Answer

Accepted
Problem: There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate.  You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds.  It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.

Submission attempts (in order):
class WeightedUnionFind():
    def __init__(self, n):
        self.parents = [-1] * n
        self.par_weight = [0] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            root = self.find(self.parents[x])
            self.par_weight[x] += self.par_weight[self.parents[x]]
            self.parents[x] = root
            return self.parents[x]

    def union(self, x, y, w):
        w = w + self.weight(x) - self.weight(y)
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            self.parents[y] += self.parents[x]
            self.parents[x] = y
            self.par_weight[x] = -w
        else:
            self.parents[x] += self.parents[y]
            self.parents[y] = x
            self.par_weight[y] = w

    def weight(self, x):
        if self.parents[x] < 0:
            return 0
        else:
            return self.par_weight[x] + self.weight(self.parents[x])

    def diff(self, x, y):
        if self.find(x) != self.find(y):
            raise Exception('"{}" belongs to a different tree from "{}"'.format(x, y))
        return self.find_position(y) - self.find_position(x)


N, M = map(int, input().split())
uf = WeightedUnionFind(N)
for i in range(M):
    L, R, D = map(int, input().split())
    L -= 1
    R -= 1
    if uf.find(L) == uf.find(R):
        if uf.diff(L, R) != D:
            res = 'No'
            break
    else:
        uf.union(L, R, D)
else:
    res = 'Yes'

print(res)


import sys
sys.setrecursionlimit(10 ** 6)


def dfs(p):
    for edge in G[p]:
        if X[edge[0]] is not None:
            if X[edge[0]] - X[p] != edge[1]:
                print('No')
                exit()
        else:
            X[edge[0]] = X[p] + edge[1]
            dfs(edge[0])


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

for i in range(M):
    L, R, D = map(int, input().split())
    L -= 1
    R -= 1
    G[L].append((R, D))
    G[R].append((L, -D))

X = [None] * N
for i in range(N):
    if X[i] is None:
        X[i] = 0
        dfs(i)

print('Yes')


Verdicts: Runtime Error

Accepted
Problem: There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate.  You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds.  It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.

Submission attempts (in order):
N,M = map(int,input().split())
es = [[] for i in range(N)]
for i in range(M):
    l,r,d = map(int,input().split())
    l,r = l-1,r-1
    es[l].append((r,d))
    es[r].append((l,-d))

for i in range(N):
    if dist[i] is not None: continue
    dist = [None] * N
    dist[i] = 0
    stack = [i]
    while stack:
        v = stack.pop()
        for to,d in es[v]:
            if dist[to] is None:
                dist[to] = dist[v] + d
                if not checked[to]:
                    stack.append(to)
            else:
                if dist[to] != dist[v] + d:
                    print('No')
                    exit()
print('Yes')


N,M = map(int,input().split())
es = [[] for i in range(N)]
for i in range(M):
    l,r,d = map(int,input().split())
    l,r = l-1,r-1
    es[l].append((r,d))
    es[r].append((l,-d))

dist = [None] * N
for i in range(N):
    if dist[i] is not None: continue
    dist[i] = 0
    stack = [i]
    while stack:
        v = stack.pop()
        for to,d in es[v]:
            if dist[to] is None:
                dist[to] = dist[v] + d
                stack.append(to)
            else:
                if dist[to] != dist[v] + d:
                    print('No')
                    exit()
print('Yes')


Verdicts: Runtime Error

Accepted
Problem: AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.  If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.

Submission attempts (in order):
n=int(input())
txy=[input().split() for i in range(n)]
if n!=1:
  for i in range(n-1):
    subX=int(txy[i+1][1])-int(txy[i][1])
    subY=int(txy[i+1][2])-int(txy[i][2])
    subT=int(txy[i+1][0])-int(txy[i][0])
    t=[]
    p=subT-subX-subY
    t.append(p)
    s=[]
  for i in range(len(t)):
      if t[i]<0 or t[i]%2==1:
        s.append(t[i])
        if s==[]:
          print('Yes')
        else:
          print('No')
      
else:
  subby=int(txy[0][0])-int(txy[0][1])-int(txy[0][2])
  if subby>=0 and subby%2==0:
    print('Yes')
  else:
    print('No')


n=int(input())
txy=[input().split() for i in range(n)]
if n!=1:
  for i in range(n-1):
    subX=abs(int(txy[i+1][1])-int(txy[i][1]))
    subY=abs(int(txy[i+1][2])-int(txy[i][2]))
    subT=int(txy[i+1][0])-int(txy[i][0])
    t=[]
    p=subT-subX-subY
    t.append(p)
  for i in range(len(t)):
      if t[i]<0 or t[i]%2==1:
        print('No')
      else:
        print('Yes')
else:
  subby=int(txy[0][0])-int(txy[0][1])-int(txy[0][2])
  if subby>=0 and subby%2==0:
    print('Yes')
  else:
    print('No')

Verdicts: Wrong Answer

Accepted
Problem: AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.  If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.

Submission attempts (in order):
import sys
n = int(input())
pt, px, py = 0, 0, 0
for _ in range(n):
    t, x, y = map(int,input().split())
    dt = abs(t-pt)
    dx = abs(x-px)
    dy = abs(y-py)
    if dt<dx+dy or dt%2!=(dx+dy)%2:
        print('No')
        sys.exit()    
    pt,px,py = t,x,y
print('Yes'

import sys
n = int(input())
pt, px, py = 0, 0, 0
for _ in range(n):
    t, x, y = map(int,input().split())
    dt = abs(t-pt)
    dx = abs(x-px)
    dy = abs(y-py)
    if dt<dx+dy or dt%2!=(dx+dy)%2:
        print('No')
        sys.exit()    
    pt,px,py = t,x,y
print('Yes')

Verdicts: Runtime Error

Accepted
Problem: AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.  If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.

Submission attempts (in order):
from collections import deque

num = int(input())

to_num = lambda x : [int(i) for i in input().split(' ')]

masume = {}
for i in range(num):
    line = to_num(1)
    for l in range(len(line)):
        masume[line[0]] = (line[1], line[2])

masume_deque = deque(list(masume.keys()))
pre_pos = (0, 0)
pre_times = 0
for index in range(num):
    k = masume_deque[index]
    cur_pos = masume[k]
    distance = sum([abs(cur_pos[i]-pre_pos[i]) for i in [0, 1]])
    times = abs(k - pre_times)
    if distance % 2 != times % 2 or distance > times:
        ans = False
        break
    else:
        ans = True
    pre_pos = cur_pos
    pre_times = masume_deque[i]
    
if ans:
    print('Yes')
else:
    print('No')
        

from collections import deque

num = int(input())

to_num = lambda x : [int(i) for i in input().split(' ')]

masume = {}
for i in range(num):
    line = to_num(1)
    for l in range(len(line)):
        masume[line[0]] = (line[1], line[2])

masume_deque = deque(list(masume.keys()))
pre_pos = (0, 0)
pre_times = 0
for index in range(num):
    cur_times = masume_deque[index]
    cur_pos = masume[cur_times]
    distance = sum([abs(cur_pos[i]-pre_pos[i]) for i in [0, 1]])
    times = abs(cur_times - pre_times)
    if distance % 2 != times % 2 or distance > times:
        ans = False
        break
    else:
        ans = True
    pre_pos = cur_pos
    pre_times = cur_times
    
if ans:
    print('Yes')
else:
    print('No')
        

Verdicts: Wrong Answer

Accepted
Problem: AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.  If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.

Submission attempts (in order):
n=int(input())
s=[list(map(int,input().split()))for i in range(n)]
s.insert(0,[0,0,0])
p=0
for i in range(n):
    c=s[i+1][0]-s[i][0]
    d=abs(s[i+1][1]-s[i][1])+abs(s[i+1][2]-s[i][2])
    if c<=d or (c-d)%2==1:
        p=1
        break
print("No" if p==1 else "Yes")

n=int(input())
s=[list(map(int,input().split()))for i in range(n)]
s.insert(0,[0,0,0])
p=0
for i in range(n):
    c=s[i+1][0]-s[i][0]
    d=abs(s[i+1][1]-s[i][1])+abs(s[i+1][2]-s[i][2])
    if c<d or (c-d)%2==1:
        p=1
        break
print("No" if p==1 else "Yes")

Verdicts: Wrong Answer

Accepted
Problem: AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.  If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.

Submission attempts (in order):
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

n = ini()
ans = True
prevt = 0
prevx = 0
prevy = 0
for _ in range(n):
    t, x, y = inm()
    totalt = t - prevt
    totald = abs(x - prevx) + abs(y - prevy)
    if totald > totalt or (totald % 2) != (totalt % 2):
        ans = False
        break
    prevt = t
    prevx = x
    prevy = y
print("YES" if ans else "NO")

import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))
 
n = ini()
ans = True
prevt = 0
prevx = 0
prevy = 0
for _ in range(n):
    t, x, y = inm()
    if (abs(x - prevx) + abs(y - prevy)) > (t - prevt) or (t - prevt) % 2 != (abs(x - prevx) + abs(y - prevy)) % 2:
        ans = False
        break
    prevt = t
    prevx = x
    prevy = y
print("Yes" if ans else "No")

Verdicts: Wrong Answer

Accepted
Problem: AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.  If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.

Submission attempts (in order):
#  --*-coding:utf-8-*--


def f(poss):
    lastPos = (0, 0, 0)

    for pos in poss:
        t = pos[0] - lastPos[0]
        d = abs(pos[1] - lastPos[1]) + abs(pos[2] - lastPos[2])
        lastPos = pos

        if t < d or (t-d)%2 != 0:
            return False

    return True



def main():
    n = int(input())
    poss = [tuple(map(int, input().split())) for i in range(n)]

    print('YES' if f(poss) else 'NO')


if __name__ == '__main__':
    main()


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


def f(poss):
    lastPos = (0, 0, 0)

    for pos in poss:
        t = pos[0] - lastPos[0]
        d = abs(pos[1] - lastPos[1]) + abs(pos[2] - lastPos[2])

        if t < d or (t-d)%2 != 0:
            return False

    return True



def main():
    n = int(input())
    poss = [tuple(map(int, input().split())) for i in range(n)]

    print('YES' if f(poss) else 'NO')


if __name__ == '__main__':
    main()


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


def f(poss):
    lastPos = (0, 0, 0)

    for pos in poss:
        t = pos[0] - lastPos[0]
        d = abs(pos[1] - lastPos[1]) + abs(pos[2] - lastPos[2])
        lastPos = pos

        if t < d or (t-d)%2 != 0:
            return False

    return True



def main():
    n = int(input())
    poss = [tuple(map(int, input().split())) for i in range(n)]

    print('Yes' if f(poss) else 'No')


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.  If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.

Submission attempts (in order):
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque




# inf = float("inf")



def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))



##### main #####

def main():
	cx = 0; cy = 0
	prev_t = 0

	for i in range(I()):
		t, dist_x, dist_y = LI()

		diff = abs(dist_x - cx) + abs(dist_y - cy)		
		t -= prev_t


		if t > diff and (t - diff)%2 == 0:
			f = True
		else:
			f = False
			break

		prev_t = t
		cx = dist_x
		cy = dist_y
	
	if f:
		print("Yes")
	else:
		print("No")

if __name__ == '__main__':
	main()

import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque




# inf = float("inf")



def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))



##### main #####

def main():
	cx = 0; cy = 0
	prev_t = 0

	for i in range(I()):
		t, dist_x, dist_y = LI()

		diff = abs(dist_x - cx) + abs(dist_y - cy)		
		spend_time = t - prev_t


		if spend_time >= diff and (spend_time - diff)%2 == 0:
			f = True
		else:
			f = False
			break

		prev_t = t
		cx = dist_x
		cy = dist_y
	
	if f:
		print("Yes")
	else:
		print("No")

if __name__ == '__main__':
	main()

Verdicts: Wrong Answer

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
n,a,b=map(int,input().split())

if (a-b) % 2 == 0:
  print("Aliice")
else:
  print("Borys")

n,a,b=map(int,input().split())

if (a-b) % 2 == 0:
  print("Alice")
else:
  print("Borys")

Verdicts: Wrong Answer

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
n,a,b=map(int,input().split())
if(b-a %2==0):
    print("Alice")
else:
    print("Borys")

n,a,b=map(int,input().split())
if((b-a) %2==0):
    print("Alice")
else:
    print("Borys")

Verdicts: Wrong Answer

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
n , a , b = map(int,input().split())
if (n - b) % 2 == 0 and n-b >= 0 or a+b != n or n+a == b:
  print("Borys")
else :
  print("Alice")

n , a , b = map(int,input().split())
if (a- b) % 2 == 0 :
  print("Alice")
else:
  print("Borys")

Verdicts: Wrong Answer

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
n,a,b = iim()

if (b-a)%2 == 1:
    if a == 1:
        print('Borys')
    else:
        print('Alice')
else:
    print('Borys')

def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
n,a,b = iim()
if (b-a)%2 == 0:
    if b-a == 1:
        print('Borys')
    else:
        print('Alice')
else:
    print('Borys')

Verdicts: Wrong Answer

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
N, A, B = map(int, input().split())
if A==1 and B==N:
    print('Borys')
else:
    if B-A == 2:
        print('Draw')
    elif (B-A)%2 == 0:
        print('Alice')
    else:
        print('Borys')

N, A, B = map(int, input().split())
if A==1 and B==A+1:
    print('Borys')
else:
    if (B-A)%2 == 0:
        print('Alice')
    elif (B-A)%2 == 1:
        print('Borys')
    else:
        print('Draw')

Verdicts: Wrong Answer

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
N,A,B=map(int,input().split())
print("Borys" if (B-A)%2 == 0 else "Alice")

N,A,B=map(int,input().split())
print("Borys" if (B-A)%2 == 1 else "Alice")

Verdicts: Wrong Answer

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
import sys
K = int(input())
A = [int(x) for x in input().split()]
A.reverse()
jmax, jmin = 2,2

if A[0] != 2:
    print(-1)
    sys.exit()


"""max"""
for i in range(0,K-1):
    drop_num = []
    for j in range(0,A[i]):  
        if ( jmax + j ) % A[i+1] == 0:
            drop_num.append(j)

        if drop_num == []:  
            print(-1)
            sys.exit()

    max_drop = max(drop_num)
    jmax = jmax + max_drop

jmax = jmax + A[K-1] -1


"""min"""
for i in range(0,K-1):
    drop_num = []
    for j in range(0,A[i]):  
        if ( jmin + j ) % A[i+1] == 0:
            drop_num.append(j)

        if drop_num == []:  
            print(-1)
            sys.exit()

    min_drop = min(drop_num)
    jmin = jmin + min_drop


print(jmin, jmax)

N, A, B = map(int,input().split())
if (B-1-A) % 2 == 0:
    print("Borys")
else:
    print("Alice")

Verdicts: Runtime Error

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
n,a,b = map(int, input().split())
if b - a % 2 == 0:
  print("Alice")
elif b - a % 2 == 1
  print("Borys")

n,a,b = map(int, input().split())
if b - a % 2 == 0:
  print("Alice")
elif b - a % 2 == 1
  print("Borys")

n,a,b = map(int, input().split())
if b - a % 2 == 0:
  print("Alice")
elif b - a % 2 == 1:
  print("Borys")

n,a,b = map(int, input().split())
c = b-a
if c % 2 == 0:
  print("Alice")
elif c % 2 == 1:
  print("Borys")

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
N = input()
A = input()
B = input()

res = ""

if ((int)(B) - (int)(A))%2 == 0:
    res = "Alice"
else:
    res = "Borys"

print(res)


moji = input()
moji = moji.split(" ")
N = moji[0]
A = moji[1]
B = moji[2]

res = ""

if ((int)(B) - (int)(A))%2 == 0:
    res = "Alice"
else:
    res = "Borys"

print(res)


Verdicts: Runtime Error

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
n,a,b=map(int,input().split())
bet=abs(b-a)
if bet%2==0:
  winner='ALice'
  else:
    winner='Borys'
    
print(winner)

n,a,b=map(int,input().split())
bet=abs(b-a)
if bet%2==0:
  winner='Alice'
else:
    winner='Borys'
    
print(winner)

Verdicts: Runtime Error

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
N, A, B = map(int, input().split())
 
if (B - A) % 2 == 0:
  print('Borys')
else:
  print('Alice')

N, A, B = map(int, input().split())
 
if (B - A - 1) % 2 == 0:
  print('Borys')
else:
  print('Alice')

Verdicts: Wrong Answer

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
n, a, b = list(map(int(), input().split()))
print("Borys" if (b - a) % 2 == 1 else "Alice")

n, a, b = list(map(int, input().split()))
print("Borys" if (b - a) % 2 == 1 else "Alice")

Verdicts: Runtime Error

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
N, A, B = map(int, input().split())
if (A-B) % 2 == 0:
    print("Alice)
else:
    print("Borys")

N, A, B = map(int, input().split())
if (A-B) % 2 == 0:
    print("Borys")
else:
    print("Alice")

N, A, B = map(int, input().split())
if (A-B) % 2 == 0:
    print("Bolice")
else:
    print("Alice")

N, A, B = map(int, input().split())
if (A-B) % 2 == 0:
    print("Alice")
else:
    print("Borys")

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
def getinputdata():

    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()


n = int(arr_data[0][0])

a = int(arr_data[0][1])

b = int(arr_data[0][2])

print("Alice" if b-a%2==0 else "Borys")


def getinputdata():

    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()


n = int(arr_data[0][0])

a = int(arr_data[0][1])

b = int(arr_data[0][2])

print("Alice" if (b-a)%2==0 else "Borys")


Verdicts: Wrong Answer

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
n,a,b=map(int,input().split())
if (b-a)%2==1:
  print('Alice')
else:
  print('Borys')

n,a,b=map(int,input().split())
if (b-a)%2==0:
  print('Alice')
else:
  print('Borys')

Verdicts: Wrong Answer

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
print("Borys")

n, a, b = map(int, input().split())
if (b-a)%2:
  print("Borys")
else:
  print("Alice")

Verdicts: Wrong Answer

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
n,a,b=map(int,input.split())
if (a-b)%2==0:print('Alice')
else:print('Borys')

n,a,b=map(int,input().split())
if (a-b)%2==0:print('Alice')
else:print('Borys')

Verdicts: Runtime Error

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
s=input().split()
if int(s[2])-int(s[1])==1:
    print('Borys')
elif int(s[2])-int(s[1])%2==0:
    print('Alice')
else:
    print('Borys')

s=input().split()
if int(s[2])-int(s[1])%2==0:
    print('Alice')
else:
    print('Borys')

a = input().split()
if (int(a[2]) - int(a[1])) % 2 == 0:
    print('Alice')
else:
    print('Borys')

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
n, a, b = list(map(int, input().split()))
print(['Borys','Alice'][(b-a)%2])

n, a, b = list(map(int, input().split()))
print(['Alice','Borys'][(b-a)%2])

Verdicts: Wrong Answer

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
n,a,b = map(int,input().split())
t = b-a
if t%2==0:
  print("Borys")
else:
  print("Alice")

n,a,b = map(int,input().split())
t = b-a
if t%2==0:
  print("Alice")
else:
  print("Borys")

Verdicts: Wrong Answer

Accepted