Harryxun/stf_run huggingface dataset:
import itertools
import math


def get_primes(x):
    if x < 2:
        return []

    primes = [i for i in range(x)]
    primes[1] = 0

    for prime in primes:
        if prime > math.sqrt(x):
            break
        if prime == 0:
            continue
        for non_prime in range(2 * prime, x, prime):
            primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]


N = int(input())
primes = get_primes(55555)
ans = []

while len(ans) < N:
    p = primes[i]
    
    if p % 5 == 1:
        ans.append(p)

    i += 1

print(*ans)

### FIXED CODE ###

import itertools
import math


def get_primes(x):
    if x < 2:
        return []

    primes = [i for i in range(x)]
    primes[1] = 0

    for prime in primes:
        if prime > math.sqrt(x):
            break
        if prime == 0:
            continue
        for non_prime in range(2 * prime, x, prime):
            primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]


N = int(input())
primes = get_primes(55555)
ans = []
i = 4

while len(ans) < N:
    p = primes[i]
    
    if p % 5 == 1:
        ans.append(p)

    i += 1

print(*ans)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(200000)

def dfs(v, x, G, X, visited, ans):
    visited[v] = True
    ans[v] = x
    # print(visited)

    for nv in G[v]:
        if visited[nv]:
            continue
        dfs(nv, x+X[nv], G, X, visited, ans)


def main():
    N, Q = map(int, input().split())
    G = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)
    X = [0]*N
    for _ in range(Q):
        p, x = map(int, input().split())
        X[p-1] += x
    # print(G)
    # print(X)
    
    visited = [False]*N
    ans = [0]*N
    dfs(0, X[0], G, X, visited, ans)
    print(' '.join(list(map(str, ans))))
    

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(300000)


def dfs(v, x, G, X, visited, ans):
    visited[v] = True
    ans[v] = x
    # print(visited)

    for nv in G[v]:
        if visited[nv]:
            continue
        dfs(nv, x+X[nv], G, X, visited, ans)


def main():
    N, Q = map(int, input().split())
    G = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)
    X = [0]*N
    for _ in range(Q):
        p, x = map(int, input().split())
        X[p-1] += x
    # print(G)
    # print(X)
    
    visited = [False]*N
    ans = [0]*N
    dfs(0, X[0], G, X, visited, ans)
    print(' '.join(list(map(str, ans))))
    

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

mod = int(1e9+7)

def dfs(i,dp,bad):
    if i == 0:
      return 1
    if i in dp:
      return dp[i]
    dp[i] = 0
    for d in (1,2):
      x = i-d;
      if 0 <= x and x not in bad:
        dp[i] += dfs(x)
        dp[i] %= mod
    return dp[i]

n,m = (int(a) for a in input().split())
bad = set()
for _ in range(m):
  a = int(input())
  bas.add(a)
print(dfs(n,dict(),bad))


### FIXED CODE ###

import sys
sys.setrecursionlimit(200000)

mod = int(1e9+7)

def dfs(i,dp,bad):
    if i == 0:
      return 1
    if i in dp:
      return dp[i]
    dp[i] = 0
    for d in (1,2):
      x = i-d;
      if 0 <= x and x not in bad:
        dp[i] += dfs(x,dp,bad)
        dp[i] %= mod
    return dp[i]

n,m = [int(a) for a in input().split()]
bad = set()
for _ in range(m):
  a = int(input())
  bad.add(a)
print(dfs(n,dict(),bad))
h, n = map(int,input().split())
a = []
b = []
for i in range(n):
    ai, bi = map(int,input().split())
    a.append(ai)
    b.append(bi)

m = 0
minc = 10**9
newi = -1
oldi = -2
cost = 0
while not newi == oldi:
    oldi = newi
    for i in range(len(n)):
        cost = b[i]*int((h-1)/a[i]+1)
        if cost < minc:
            newi = i
    h -= a[newi]*int((h-1)/a[newi])
    m += b[newi]*int((h-1)/a[newi])
    if newi == oldi:
        m += b[newi]

print(m)


### FIXED CODE ###

import numpy as np

h, n = map(int,input().split())
a = np.zeros(n, dtype = int)
b = np.zeros(n, dtype = int)
for i in range(n):
    a[i], b[i] = map(int,input().split())

dp = np.zeros(10001, dtype = int)

for i in range(1,10001):
    dp[i] = (dp[i-a]+b).min()

print(dp[h])
n,m = map(int,input().split())
p = [[int(i) for i in input().split()] for _ in range(m)]
p.sort()

np = list(map(tuple,p))
np = list(set(np))
np.sort()
d = len(np)

np = list(map(list,np))


a = True

if [1,0] in np:
  a = False
  
for x in range(d-1):
  if np[x][0] == np[x+1][0]:
    if np[x][1] != np[x+1][1]:
      a = False
      break
ans = 0
if a:
  if np[0][0] != 1:
    ans = 10 ** (n-1)
    for z in range(d):
      ans += 10 ** (n-np[z][0]) * np[z][1]
    print(ans)
  else:
    for r in range(d):
      ans += 10 ** (n-np[r][0]) * np[r][1]
    print(ans)
    
else:
  print(-1)
  
      

### FIXED CODE ###

#nは桁数　 (1,0)が含まれてる時と、(2,4),(2,7)みたいな入力の時はだめ
n,m = map(int,input().split())
s = [0]*m
c = [0]*m
d = dict()
ans = 0

for x in range(m):
    s[x],c[x] = map(int,input().split())
    if s[x] not in d:
        d[s[x]] = c[x]
    elif d[s[x]] != c[x]:
        ans = -1
        break

else:
    ans = ""
    for x in range(1,n+1):
        if x in d :
            if x != 1:
                ans += str(d[x])
            elif x == 1 and d[x] != 0:
                ans += str(d[x])
            elif n == 1 and d[x] == 0:
                ans += "0"
            else:
                ans = -1
                break
        else:
            if m != 0:
                if x == 1:
                    ans += str(1)
                else:
                    ans += str(0)
            else:
                if n == 1:
                    ans = str(0)
                else:
                    ans = "1" + ("0"*(n-1))

print(ans)
m=int(input())
d=[]
c=[]
z=0
for i in range(m):
    a,b=map(int,input().split())
    d.append(a)
    c.append(b)
    z+=c*d
ans=0
print(sum(d)-1+z//9)
exit()
def ika(x,y):
    ret=0
    z=x*y
    ret+=y-1
    while z>9:
        s=list(str(z))
        ret+=len(s)-1
        i5=0
        for i in range(len(s)):
            s[i]=int(s[i])
        g=0
        while g<len(s)-1:
            if s[g]+s[g+1]>=10:
                #ret+=1
                g+=2
            else:
                g+=1
        z=sum(s)
        ret+=(z-10)//10
    return [ret,z]
ka=[]
for i in range(m):
    f=ika(d[i],c[i])
    ans+=f[0]
    ka.append(f[1])
print(ans+ika(sum(ka),1)[0]+len(ka)-1)


### FIXED CODE ###

m=int(input())
d=[]
c=[]
z=0
for i in range(m):
    a,b=map(int,input().split())
    d.append(a)
    c.append(b)
    z+=a*b
ans=0
print(sum(c)-1+(z-1)//9)
exit()
def ika(x,y):
    ret=0
    z=x*y
    ret+=y-1
    while z>9:
        s=list(str(z))
        ret+=len(s)-1
        i5=0
        for i in range(len(s)):
            s[i]=int(s[i])
        g=0
        while g<len(s)-1:
            if s[g]+s[g+1]>=10:
                #ret+=1
                g+=2
            else:
                g+=1
        z=sum(s)
        ret+=(z-10)//10
    return [ret,z]
ka=[]
for i in range(m):
    f=ika(d[i],c[i])
    ans+=f[0]
    ka.append(f[1])
print(ans+ika(sum(ka),1)[0]+len(ka)-1)
#import itertools
import collections

def op(v):
    count = collections.Counter(v).most_common() 

    #v_ = itertools.groupby(sorted(v))
    #count = sorted([(k, len(list(g))) for k, g in v_], key = lambda x:x[1])
    return count

n = int(input())
V = [int(n) for n in input().split()]

if len(set(V)) == 1:
    ans = len(V) // 2
else:
    vp_ = [v for i, v in enumerate(V) if i%2 == 0] 
    vn_ = [v for i, v in enumerate(V) if i%2 != 0] 

    vp = op(vp_)
    vn = op(vn_)    

    if vp[-1][0] != vn[-1][0]:
        gp = vp[-1][1]
        gn = vn[-1][1]
    else:
        if vp[-1][1] > vn[-1][1]:
            gp = vp[-1][1]
            gn = vn[-2][1]
        else:
            gp = vp[-2][1]
            gn = vn[-1][1]

    #ans_p = sum([g for k, g in vp]) - gp
    #ans_n = sum([g for k, g in vn]) - gn

    #ans  = ans_p + ans_n
    ans = n - gp - gn

print(ans)



### FIXED CODE ###

n = input()
#print(n)
new = []
for i in n:
    if i == '1':
        new.append('9')
    elif i =='9':
        new.append('1')
    else:
        new.append(i)
print(''.join(new))
import collections

N = int(input())
V = list(int(i) for i in input().split())
even = V[0::2]
odd =  V[1::2]
all_length = len(V)
even = collections.Counter(even).most_common(2)
odd = collections.Counter(odd).most_common(2)
if (even[0][0] != odd[0][0]):
    print(all_length - even[0][1] - odd[0][1])
else:
    out1 = all_length - even[0][1] - odd[0][2]
    out2 = all_length - even[0][2] - odd[0][1]
    if(out1 > out2):
        print(out2)
    else:
        print(out1)

### FIXED CODE ###

import collections

N = int(input())
V = list(int(i) for i in input().split())
even = V[0::2]
odd =  V[1::2]
all_length = len(V)
even = collections.Counter(even).most_common(2)
odd = collections.Counter(odd).most_common(2)
if (even[0][0] != odd[0][0]):
    print(all_length - even[0][1] - odd[0][1])
else:
    if(len(even) == 1 and len(odd) == 1):
        print(all_length // 2)
    elif(len(even)==1):
        print(all_length // 2 - odd[1][1])
    elif(len(odd)==1):
        print(all_length // 2 - even[1][1])    
    else:
        print(min(all_length - even[0][1] - odd[1][1], all_length - even[1][1] - odd[0][1]))
N,K = map(int,input().split())
A = list(map(int,input().split()))
dp = [0] * (N+10)
dp[2] = abs(A[1] - A[0])
for i in range(2,N):
    res = []
    if K+1 > i:
        K = i + 1
    for j in range(1,K):
        res.append(abs(A[i] - A[i-j])+dp[i-j+1])
    dp[i+1] = min(res)
 
print(dp[N])

### FIXED CODE ###

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    dp = [0] * (N+10)
    dp[2] = abs(A[1] - A[0])
    for i in range(2,N):
        res = []
        if K > i:
            kk = i+1
        else:
            kk = K + 1
        for j in range(1,kk):
            res.append(abs(A[i] - A[i-j])+dp[i-j+1])
        dp[i+1] = min(res)
    
    print(dp[N])
if __name__ == "__main__":
    main()
N,M = list(map(int,input().split()))
lis = []
for i in range(N):
    lis.append([i+1])
for i in range(M):
    a,b = list(map(int,input().split()))
    lis[a-1].append(b)
    lis[b-1].append(a)
for i in range(N):
    print(len(lis[i])-1)


### FIXED CODE ###

N,M = list(map(int,input().split()))
lis = []
for i in range(N):
    lis.append([i+1])
for i in range(M):
    a,b = list(map(int,input().split()))
    lis[a-1].append(b)
    lis[b-1].append(a)
for i in range(N):
    print(len(lis[i])-1)
n, x = map(int, input().split())
a = [int(i) for i in input().split()]

a.sort()
temp_x = x
for i in range(n):
  if temp_x > 0:
    temp_x += -a[i]
  else:
    ans = i
    break
  if i == n-1 and temp_x > 0:
    ans = n-1
print(ans)

### FIXED CODE ###

n, x = map(int, input().split())
a = [int(i) for i in input().split()]

a.sort()
temp_x = x
for i in range(n):
  temp_x += -a[i]
  if i == n-1 and temp_x > 0:
    ans = n-1
  elif temp_x > 0:
    continue
  elif temp_x == 0:
    ans = i+1
  else:
    ans = i
    break

print(ans)
def e_bullet(MOD=10**9 + 7):
    from math import gcd
    from collections import defaultdict
    N = int(input())

    zero_all = 0
    pair = defaultdict(int)
    for _ in range(N):
        a, b = [int(i) for i in input().split()]
        if a == 0 and b == 0:
            zero_all += 1
            continue

        # 既約分数にしておきたい
        g = gcd(a, b) * a // abs(a)
        pair[(a // g, b // g)] += 1  # 既約分数 a/b とみなす

    done = set()
    total = 1
    for (a, b), v in list(pair.items()):
        if (b, -a) in done or (-b, a) in done:
            continue  # a/b に対応するものがあるかはすでに調べた
        done.add((a, b))

        # a/b に対応する b/(-a) か (-b)/a に注目する
        w = pair[(b, -a)] + pair[(-b, a)]
        # それらを選ぶと仲が悪いので、a/b となるものだけ選ぶか b/(-a) か (-b)/a
        # となるものだけ選ぶか、どちらか一方だけ選択したときに仲が悪くならない
        # これまでの選び方に対して仲が悪くならない選び方を決めるので、total は積を取る
        # ただし、両方とも 1 つも選ばないということはできないため、-1 する
        total *= pow(2, v, MOD) + pow(2, w, MOD) - 1
        total %= MOD

    ans = (total + zero_all - 1) % MOD
    return ans

print(e_bullet())

### FIXED CODE ###

def e_bullet(MOD=10**9 + 7):
    from math import gcd
    from collections import defaultdict
    N = int(input())

    zero_all = 0
    pair = defaultdict(int)
    for _ in range(N):
        a, b = [int(i) for i in input().split()]
        if a == 0 and b == 0:
            zero_all += 1
            continue

        # 既約分数にしておきたい
        if a != 0 and b != 0:
            g = gcd(a, b) * a // abs(a)
        elif a != 0:
            g = a
        else:
            g = b
        pair[(a // g, b // g)] += 1  # 既約分数 a/b とみなす

    done = set()
    total = 1
    for (a, b), v in list(pair.items()):
        if (b, -a) in done or (-b, a) in done:
            continue  # a/b に対応するものがあるかはすでに調べた
        done.add((a, b))

        # a/b に対応する b/(-a) か (-b)/a に注目する
        w = pair[(b, -a)] + pair[(-b, a)]
        # それらを選ぶと仲が悪いので、a/b となるものだけ選ぶか b/(-a) か (-b)/a
        # となるものだけ選ぶか、どちらか一方だけ選択したときに仲が悪くならない
        # これまでの選び方に対して仲が悪くならない選び方を決めるので、total は積を取る
        # ただし、両方とも 1 つも選ばないということはできないため、-1 する
        total *= pow(2, v, MOD) + pow(2, w, MOD) - 1
        total %= MOD

    ans = (total + zero_all - 1) % MOD
    return ans

print(e_bullet())
n = int(input())
ga, sa, ba = map(int, input().split())
gb, sb, bb = map(int, input().split())

# init N
# A    Donguri
# B    Donguri and metal -> N -> Donguri and metal
# A    Donguri

# first DP
dp = [0] * (n + 1)
for i in range(1, n+1):
    dp[i] = max(i, dp[i-ga] + gb, dp[i-sa] + sb, dp[i-ba] + gb)
print(dp[n])



### FIXED CODE ###

n = int(input())
ga, sa, ba = map(int, input().split())
gb, sb, bb = map(int, input().split())

dp1 = [0] * (n + 1)
if n > 5001:
    for i in range(1, 5001):
        feat = [i]
        if i - ga >= 0:
            feat.append(dp1[i-ga]+gb)
        if i - sa >= 0:
            feat.append(dp1[i-sa]+sb)
        if i - ba >= 0:
            feat.append(dp1[i-ba]+bb)
        dp[i] = max(feat)
    for i in range(5001, n+1):
        dp1[i] = max(i, dp1[i-ga]+gb, dp1[i-sa]+sb, dp1[i-ba]+bb)
else:
    for i in range(1, n+1):
        feat = [i]
        if i - ga >= 0:
            feat.append(dp1[i-ga]+gb)
        if i - sa >= 0:
            feat.append(dp1[i-sa]+sb)
        if i - ba >= 0:
            feat.append(dp1[i-ba]+bb)
        dp1[i] = max(feat)

B = dp1[-1]
dp2 = [0] * (B + 1)
if B > 5001:
    for i in range(1, 5001):
        feat = [i]
        if i - gb >= 0:
            feat.append(dp2[i-gb]+ga)
        if i - sb >= 0:
            feat.append(dp2[i-sb]+sa)
        if i - bb >= 0:
            feat.append(dp2[i-bb]+ba)
        dp2[i] = max(feat)

    for i in range(5001, B+1):
        dp2[i] = max(i, dp2[i-gb]+ga, dp2[i-sb]+sa, dp2[i-bb]+ba)
else:
    for i in range(1, B+1):
        feat = [i]
        if i - gb >= 0:
            feat.append(dp2[i-gb]+ga)
        if i - sb >= 0:
            feat.append(dp2[i-sb]+sa)
        if i - bb >= 0:
            feat.append(dp2[i-bb]+ba)
        dp2[i] = max(feat)

print(dp2[-1])
H, W = map(int, input().split())
q = []
a = {}
for i in range(H):
    l = input()
    for j in range(W):
        a[j, i] = l[j]
        if l[j] == '#':
            q.append((i,j))
ans = 0
for i in range(100000000):
    if len(q) == 0:
        break
    ans+=1
    tq = []
    for qq in q:
        if qq[0] > 0:
            if a[qq[0]-1, qq[1]] == '.':
                a[qq[0] - 1, qq[1]] = '#'
                tq.append((qq[0] - 1, qq[1]))
        if qq[0] < (W-1):
            if a[qq[0]+1, qq[1]] == '.':
                a[qq[0] + 1, qq[1]] = '#'
                tq.append((qq[0] + 1, qq[1]))
        if qq[1] > 0:
            if a[qq[0], qq[1]-1] == '.':
                a[qq[0], qq[1]-1] = '#'
                tq.append((qq[0], qq[1]-1))
        if qq[1] < (H-1):
            if a[qq[0], qq[1]+1] == '.':
                a[qq[0], qq[1]+1] = '#'
                tq.append((qq[0], qq[1]+1))
    q = tq
print(ans-1)

### FIXED CODE ###

h,w= map(int, input().split())
a = []
x = []
for i in range(h):
    li = input()
    aa = []
    for j in range(w):
        aa.append(li[j])
        if aa[j] == '#':
            x.append((i, j))
    a.append(aa)
ans = 0
while True:
    xx = []
    for p in x:
        pp = [(p[0]-1, p[1]), (p[0]+1, p[1]), (p[0], p[1]-1), (p[0], p[1]+1)]
        for ppp in pp:
            if (0 <= ppp[0] < h) and (0 <= ppp[1] < w):
                if a[ppp[0]][ppp[1]] == '.':
                    a[ppp[0]][ppp[1]] = '#'
                    xx.append((ppp[0], ppp[1]))
    x = xx
    if len(x) == 0:
        break
    ans += 1
    # print(x)
print(ans)
intxt = input()
p = ""
ok = 0
for i in range(0,3):
  if intxt[i] != p:
    ok += 1
  p = intxt[i]
if ok == 1:
  print("Yes")
else:
  print("No)

### FIXED CODE ###

s = input()
if s[0] == s[1] and s[1] == s[2]:
  print("No")
else:
  print("Yes")
from bisect import insort_left

n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()

d = []

for i in range(m):
    b,c = map(int,input().split())
    
    for j in range(b):
        d.append(c)        

d.sort()
d.reverse()

#print(a)
#print(d)

for i in range(n):
    if a[i] < d[i]:
        a[i] = d[i]
    else:
        break

#print(a)

sum = 0
for v in a:
    sum += v

print(sum)


### FIXED CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()

d = []

bc = []
for i in range(m):
    b,c = map(int,input().split())
    bc.append([b,c])

bc = sorted(bc,key=lambda x:x[1],reverse=True)

for elm in bc:
    for i in range(elm[0]):
        d.append(elm[1])
        if len(d) >= n:
            break
    if len(d) >= n:
        break

d.sort()
d.reverse()

#print(a)
#print(d)

sum = 0
ln = len(d)
for i in range(n):
    if i < ln:
        if a[i] < d[i]:
            sum += d[i]
        else:
            sum += a[i]
    else:
        sum += a[i]

print(sum)
n = input()

for _ in range(0, n):
    t, x, y = map(int(), n.split())
    if x + y > t or (t - x - y) % 2:
        print("No")
        exit()
print("Yes")

### FIXED CODE ###

n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]

x = y = t = 0
for i in range(n):
    dx, dy, dt = l[i][1], l[i][2], l[i][0]
    dist = abs((dx - x) + (dy - y))

    if abs(dt - t) < dist:
        print("No")
        exit()
    if abs(dt - t) % 2:
        if dist % 2 == 0:
            print("No")
            exit()
    else:
        if dist % 2 == 1:
            print("No")
            exit()
    x, y, t = dx, dy, dt
print("Yes")
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]

count_num=0
for i in l[0]:
    count_num += l[1][i-1]
for j in range(n-1):
    if (l[0][j])+1 == l[0][j+1]:
        count_num += l[2][(l[0][j])-1]
    
print(count_num)

### FIXED CODE ###

n=int(input())
l=[list(map(int,input().split())) for _ in range(3)]

count_num=0
for i in l[0]:
    count_num += l[1][i-1]
for j in range(n-1):
    if (l[0][j])+1 == l[0][j+1]:
        count_num += l[2][(l[0][j])-1]
    
print(count_num)
H = input()
A = input()
count = 0


while H > A:
    H -= A
    count +=1
else:
    print(count)

### FIXED CODE ###

H,A = map(int,input().split())


count = 0

while H > 0:
    H -= A
    count +=1

print(count)
N, Q = map(int, input().split())
A = []
B = []

for i in range(N - 1):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

P = []
X = []
for i in range(Q):
    p, x = map(int, input().split())
    P.append(p)
    X.append(x)

T = {}
for i in range(len(A)):
    a = A[i]
    b = B[i]
    if a in T:
        T[a].append(b)
    else:
        T[a] = [b]

d = [0] * N

def inctree(p, x):
    d[p - 1] += x
    if p in T:
        l = T[p]
        for p2 in l:
            inctree(p2, x)

for i in range(len(P)):
    p = P[i]

    x = X[i]
    inctree(p, x)


print(' '.join(map(str, d)))


### FIXED CODE ###

from sys import stdin,setrecursionlimit
input = stdin.readline
setrecursionlimit(1000000) 

N, Q = map(int, input().split())
T = [[] for _ in range(2 * (10 ** 5))]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    T[a].append(b)
    T[b].append(a)

d = [0] * N

for _ in range(Q):
    p, x = map(int, input().split())
    d[p - 1] += x

def dfs(u, v):
    global d
    for p in T[u]:
        if p == v:
            continue
        d[p] += d[u]
        dfs(p, u)

dfs(0, -1)

for v in d:
    print(v)
S = str(input()).split()
ans = 'Good'
for i in range(3):
  if S[i] == S[i+1]:
    ans = 'Bad'
Print(ans)
  


### FIXED CODE ###

S = str(input())
ans = 'Good'
for i in range(3):
    if S[i] == S[i+1]:
        ans = 'Bad'
print(ans)
n = int(input())
travel_plan = [tuple(map(int, input().split())) for i in range(n)]
travel_plan = [(0, 0, 0)] + travel_plan

for i in range(n+1):
    t1 = travel_plan[i][0]
    x1 = travel_plan[i][1]
    y1 = travel_plan[i][2]
    t2 = travel_plan[i+1][0]
    x2 = travel_plan[i+1][1]
    y2 = travel_plan[i+1][2]
    x = abs(x1 - x2)
    y = abs(y1 - y2)
    t = t2 - t1
    if x + y < t or (x + y + t) % 2:
        print("No")
        exit()
print("Yes")

### FIXED CODE ###

n = int(input())
travel_plan = []
for i in range(n):
    travel_plan.append(tuple(map(int, input().split())))
travel_plan = [(0, 0, 0)] + travel_plan

for i in range(n):
    t1 = travel_plan[i][0]
    x1 = travel_plan[i][1]
    y1 = travel_plan[i][2]
    t2 = travel_plan[i+1][0]
    x2 = travel_plan[i+1][1]
    y2 = travel_plan[i+1][2]
    x = abs(x1 - x2)
    y = abs(y1 - y2)
    t = t2 - t1
    if x + y > t or (x + y) % 2 != t % 2:
        print("No")
        exit()
print("Yes")
N, M = map(int, input().split())
L = [0] * M
R = [0] * M
for i in range(M):
    L[i], R[i] = map(int, input().split())

all_lists = [list(range(L[i], R[i] + 1)) for i in range(M)]

new_set = set(all_lists[0])
for i in range(len(all_lists) - 1):
    if len(new_set) == 0:
        break
    new_set = new_set & set(all_lists[i + 1])

print(len(new_set))

### FIXED CODE ###

import sys
A, B = map(int, input().split(' '))
if A >= 13:
    print(B)
elif A <= 12 and A >= 6:
    print(int(B / 2))
else:
    print(0)
s=input()
sento=0
matubi
for i in range(s):
  if s[i] == "A":
    sento=i
    break
for i in range(s):
  if s[i] == "Z" and i > sento:
    matubi=i
    break
print(s[sento:matubi+1])

### FIXED CODE ###

s=input()
sento=2000000
matubi=0

for i in range(len(s)):
  if s[i] == "A":
    sento=min(i,sento)
for i in range(len(s)):
  if s[i] == "Z" and i > sento:
    matubi=max(i,matubi)
print(matubi-sento+1)
def main():
    n =int(input())
    al = list(map(int,input().split()))

    res = 0
    bits = [[0]*2 for _ in range(60)]
    for a in al:
        i = 0
        while a > 0:
            bits[i][a&1] += 1
            a == a >> 1
            d += 1

    res = 0

    for i in range(60):
        res += bits[i][0] * bits[i][1]  * (2 ** i)

    print(res % (10 ** 9 + 7))

if __name__ == "__main__":
    main()

### FIXED CODE ###


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

res = 0
bits = [0]*60
for a in al:
    i = 0
    b = a
    while b:
        bits[i] += b&1
        b = b >> 1
        i += 1

res = 0

for j in range(60):
    res += bits[j] * (n - bits[j])  * (2 ** j)

print(res % (10 ** 9 + 7))