Harryxun/stf_run huggingface dataset:
import sys
sys.setrecursionlimit(100000)

h, w, k = map(int, input().split())
s = []
ans = [[0] * w for _ in range(h)]
cnt = 0
#prev = 1

for i in range(h):
    s.append(input())

#print(s)

for i in range(h):
    if '#' not in s[i]:
        continue
    shouldCover = False

    for j in range(w):
        if j == 0 and s[i][j] == '.':
            cnt += 1
            ans[i][j] = cnt
            shouldCover = True
        elif s[i][j] == '#' and shouldCover:
            ans[i][j] = cnt
            shouldCover = False
        elif s[i][j] == '#':
            cnt += 1
            ans[i][j] = cnt
            shouldCover = False
        else:
            ans[i][j] = cnt

def solve(cur, nxt, down):
    if down:
        if '#' in s[nxt]:
            for j in range(w):
                ans[cur][j] = ans[nxt][j]
        else:
            solve(cur, nxt+1, down)
    else:
        if '#' in s[nxt]:
            for j in range(w):
                ans[cur][j] = ans[nxt][j]
        else:
            solve(cur, nxt-1, down)


for i in range(h):
    if all(ans[i][j] == 0 for j in range(w)):
        if i == h - 1:
            solve(i, i-1, False)
        else:
            #print('down!')
            solve(i, i+1, True)

for i in range(h):
    print(*ans[i])
#print(ans)





### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)

h, w, k = map(int, input().split())
s = []
ans = [[0] * w for _ in range(h)]
cnt = 0
#prev = 1

for i in range(h):
    s.append(input())

#print(s)

for i in range(h):
    if '#' not in s[i]:
        continue
    shouldCover = False

    for j in range(w):
        if j == 0 and s[i][j] == '.':
            cnt += 1
            ans[i][j] = cnt
            shouldCover = True
        elif s[i][j] == '#' and shouldCover:
            ans[i][j] = cnt
            shouldCover = False
        elif s[i][j] == '#':
            cnt += 1
            ans[i][j] = cnt
            shouldCover = False
        else:
            ans[i][j] = cnt

def solve(cur, nxt, down):
    if nxt < 0 or nxt > h-1:
        return
    if down:
        if '#' in s[nxt]:
            for k in range(cur, nxt):
                for j in range(w):
                    ans[k][j] = ans[nxt][j]
        else:
            solve(cur, nxt+1, down)
    else:
        if '#' in s[nxt]:
            for k in range(cur, nxt, -1):
                for j in range(w):
                    ans[k][j] = ans[nxt][j]
        else:
            solve(cur, nxt-1, down)


for i in range(h):
    if all(ans[i][j] == 0 for j in range(w)):
        if i == h - 1:
            solve(i, i-1, False)
        else:
            #print('down!')
            solve(i, i+1, True)

for i in range(h):
    print(*ans[i])
#print(ans)
n = int(input())
x = 1+n//4
q = ['No','Yes']
s = 0
for a in range(x):
	if (n-a*4)%7==0:
    	s = 1
        
print(q[s])

### FIXED CODE ###

n = int(input())
x = 1+n//4
q = ['No','Yes']
s = 0
for a in range(x):
  if (n-a*4)%7==0:
    s += 1
    break
        
print(q[s])
if __name__ == '__main__':
    INPUT=input()
    ans=[]
    for i in INPUT:
        if i=="0":
            ans.append("0")
        elif i=="1":
            ans.append("1")
        else:
            ans.pop()
    print("".join(ans))

### FIXED CODE ###


if __name__ == '__main__':
    INPUT=input()
    ans=[]
    for i in INPUT:
        if i=="0":
            ans.append("0")
        elif i=="1":
            ans.append("1")
        else:
            if len(ans)>0:
                ans.pop()
    print("".join(ans))
s = input()

s_long = len(s)
first_a_adress = -1
end_z_adress = -1
for var in range(0,s_long):
	if s[var] == 'a':
		first_a_adress = var
		break
				
for var in reversed(range(0,s_long)):
	if s[var] == 'z':
		end_z_adress = var
		break
print end_z_adress - first_a_adress + 1

### FIXED CODE ###

s = raw_input()

s_long = len(s)
first_a_adress = -1
end_z_adress = -1
for var in range(0,s_long):
	if s[var] == 'A':
		first_a_adress = var
		break
				
for var in reversed(range(0,s_long)):
	if s[var] == 'Z':
		end_z_adress = var
		break
print end_z_adress - first_a_adress + 1
n = int(input())
a = list(map(int, input().split()))

x = 0
for i in range(n):
  while Ture:
    if a[i] > a[i + 1]:
      a[i + 1] += 1
      x += 1
    if a[i] <= a[i + 1]:
      break

print(x)

### FIXED CODE ###

N = int(input())
A = [int(x) for x in input().split()]
ans = 0
for i in range(N-1):
    if A[i]>A[i+1]:
        ans += A[i]-A[i+1]
        A[i+1] = A[i]
print(ans)
print(" YNeos"eval(input()).replace(" ","*")%2::2))

### FIXED CODE ###

print(" YNeos"[eval(input().replace(" ","*"))%2::2])
H = int(input())
A = int(input())

if H%A == 0:
  x = H//A
  else:
    x = (H//A)-1

### FIXED CODE ###

h,a=map(int,input().split())
if h%a==0:
  print(h//a)
else:
  print(h//a+1)
import sys

N = int(input())
A = sys.stdin.readline().rstrip()
lst = [0 for i in range(60)]
q = 0
for i in A:
    a = list(str(format(i, '08b')))
    a.reverse()
    for j in range(len(a)):
        lst[j]+=int(a[j])
for i in range(60):
    k = lst[i]
    l = k*(k-1)
    q+=(2**i)*l
p = sum(A)*(N-1)
print((p-q)%((10**9)+7))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
mod = 10 ** 9 + 7
cnt = [0 for _ in range(60)]
for a in A:
    for i in range(60):
        cnt[i] += a & 1
        a >>= 1
cnt = [x * (N - x) % mod for x in cnt]
power = 1
ans = 0
for i in range(60):
    ans += power * cnt[i]
    power *= 2
    power %= mod
ans %= mod
print(ans)
x = int(input())

for d in range(1, int(x**0.5)+1):
    if x % d == 0:
        for a in range(1,d+1):
            b = a - d
            if a**5 - b**5 == x:
                print(a, b)
                exit()

### FIXED CODE ###

s = input()

if s == 'ABC':
    print('ARC')
else:
    print('ABC')
import sys
sys.setrecursionlimit(10**5)

import math
N, X = map(int, input().split())
Y = list(map(int, input().split()))
ans = abs(Y[0]-X)
for i in range(1,N):
    ans = math.gcd(ans, abs(Y[i]-X))

print(ans)

### FIXED CODE ###

import fractions
N, X = map(int, input().split())
Y = list(map(int, input().split()))
ans = abs(Y[0]-X)
for i in range(1,N):
    ans = fractions.gcd(ans, abs(Y[i]-X))

print(ans)
n,x,t=map(int,input().split())

if n%x=o:
   a=n//x
else:
   a=n//x+1

b=a*t

print(b)


### FIXED CODE ###

n,x,t=map(int,input().split())

if n%x==0:
   a=int(n//x)
else:
   a=int(n//x+1)

b=int(a*t)

print(b)
import sys
input = lambda : sys.stdin.readline().rstrip()

n, m = map(int, input().split(" "))

graph = {}
for node in range(1, n+1):
    graph[node] = []

for i in range(m):
    a, b = map(int, input().split(" "))
    graph[a].append(b)
    graph[b].append(a)

uses = [False] * (n+1)

def check(node):
    uses[node] = True
    kids = graph[node]
    for kid in kids:
        if not uses[kid]:
            check(kid)

next_graph_i = 1
for node in range(1, n+1):
    graph_i = next_graph_i
    if uses[node]:
        continue
    check(node)
    next_graph_i = graph_i + 1

out = graph_i - 1
print(out)

### FIXED CODE ###

import sys
sys.setrecursionlimit(100002)

input = lambda : sys.stdin.readline().rstrip()


def main(a_s, b_s, n, m):
    graph = {}
    for node in range(1, n+1):
        graph[node] = []

    for i in range(m):
        a, b = a_s[i], b_s[i]
        graph[a].append(b)
        graph[b].append(a)

    uses = [False] * (n+1)

    def check(node):
        uses[node] = True
        kids = graph[node]
        for kid in kids:
            if not uses[kid]:
                check(kid)

    next_graph_i = 1
    for node in range(1, n+1):
        if uses[node]:
            continue
        graph_i = next_graph_i
        check(node)
        next_graph_i = graph_i + 1

    out = graph_i - 1
    print(out)

if True:
    n, m = map(int, input().split(" "))
    a_s = []
    b_s = []
    for i in range(m):
        a, b = map(int, input().split(" "))
        a_s.append(a)
        b_s.append(b)
else:
    import random
    n = random.randint(2, 100000)
    m = random.randint(1, 100000)
    
    a_s = []
    b_s = []
    for i in range(m):    
        a = random.randint(1, n-1)
        b = random.randint(a+1, n)
        a_s.append(a)
        b_s.append(b)

main(a_s, b_s, n, m)
import sys
readline = sys.stdin.buffer.readline

from collections import deque
import copy
import numpy as np

def myinput():
    return map(int,readline().split())

def mycol(data,col):
    return [ row[col] for row in data ]

h,w = myinput()
field = [ list(input()) for _ in range(h) ]
# print(field)

d = [ [float("inf")]*w for _ in range(h) ]

q = deque()

for j in range(h):
    for i in range(w):
        a = field[j][i]
        if a=="#":
            q.append([j,i])
            d[j][i] = 0
        else:
            pass

# print(q)

def bfs(d):
    while q:
        y,x = q.popleft()
        for j,i in ([1,0],[0,-1],[-1,0],[0,1]):
            ny = y + j
            nx = x + i
            if ny==-1 or nx==-1 or ny==h or nx==w:
                pass
            elif field[ny][nx]=="#":
                pass
            elif d[ny][nx]!=float("inf"):
                pass
            else:
                field[ny][nx] = "#"
                d[ny][nx] = d[y][x] + 1
                q.append([ny,nx])
    return d

d2 = bfs(d)

# print(d2)

d3 = np.array(d2)
ans = np.max(d3)
print(ans)

### FIXED CODE ###

from collections import deque

h,w = map(int,input().split())
field = [ list(input()) for _ in range(h) ]

visited = [ [0]*w for _ in range(h) ]
q = deque()

for j in range(h):
    for i in range(w):
        a = field[j][i]
        if a=="#":
            q.append([j,i,0])
            visited[j][i] = 1
        else:
            pass

m = 0
while q:
    y,x,d = q.popleft()
    for j,i in ([1,0],[0,-1],[-1,0],[0,1]):
        ny = y + j
        nx = x + i
        if ny==-1 or nx==-1 or ny==h or nx==w:
            pass
        elif visited[ny][nx]==0:
            visited[ny][nx] = 1
            q.append([ny,nx,d+1])
            m = max(m,d+1)   
print(m)
N = int(input())
a = [int(i) for i in input().split(' ')]
b = a
numbers = []
numbers.append(a[0])
for i in a:
    if i != numbers[0] and len(numbers) == 1:
        numbers.append(i)
    if i != a[0] and i != numbers[1]:
        numbers.append(i)
        break

if a.count(numbers[0]) != a.count(numbers[1]):
    print('No')
    exit(1)
if a.count(numbers[0]) != a.count(numbers[2]):
    print('No')
    exit(1)
if len(a) != a.count(numbers[0])+a.count(numbers[1])+a.count(numbers[2]):
    print('No')
    exit(1)
if numbers[0]^numbers[1] == numbers[2]:
    print('Yes')
elif numbers[0]^numbers[2] == numbers[1]:
    print('Yes')
elif numbers[1]^numbers[2] == numbers[0]:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

N = int(input())
a = [int(i) for i in input().split(' ')]
numbers = []
numbers.append(a[0])
for i in a:
    if i != numbers[0] and len(numbers) == 1:
        numbers.append(i)
    if i != numbers[0] and i != numbers[1]:
        numbers.append(i)
        break

if len(numbers) == 1:
    if numbers[0] == 0:
        print('Yes')
        exit(0)
    else:
        print('No')
        exit(0)

if len(numbers) == 3:
    if a.count(numbers[0]) != a.count(numbers[1]):
        print('No')
        exit(0)
    if a.count(numbers[0]) != a.count(numbers[2]):
        print('No')
        exit(0)
    if len(a) != a.count(numbers[0])+a.count(numbers[1])+a.count(numbers[2]):
        print('No')
        exit(0)

    if numbers[0]^numbers[1] == numbers[2]:
        print('Yes')
        exit(0)
    elif numbers[0]^numbers[2] == numbers[1]:
        print('Yes')
        exit(0)
    elif numbers[1]^numbers[2] == numbers[0]:
        print('Yes')
        exit(0)
    else:
        print('No')
else:
    if len(a) != a.count(numbers[0])+a.count(numbers[1]):
        print('No')
        exit(0)
    if numbers[0] == 0 or numbers[1] == 0:
        if numbers[0] == 0:
            if a.count(numbers[1]) != 2*a.count(numbers[0]):
                print('No')
                exit(0)
        elif a.count(numbers[0]) != 2*a.count(numbers[1]):
            print('No')
            exit(0)
        print('Yes')
        exit(0)
    else:
        print('No')
        exit(0)
import math
n=int(input())
A=list(map(int,input().split()))
ans=1
for x in A:
    ans=ans*x//math.gcd(ans,x)
ans-=1
t=0
for x in A:
    t+=ans%x
print(t)

### FIXED CODE ###

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
 
n=int(input())
A=list(map(int,input().split()))
ans=1
for x in A:
    ans=ans*x//gcd(ans,x)
ans-=1
t=0
for x in A:
    t+=ans%x
print(t)
N,K=map(int,input().split())
t=N%K
print(min(t,K-t))

### FIXED CODE ###

X,Y,Z=map(int,input().split())
X,Y=Y,X
X,Z=Z,X
print(X,Y,Z)
a = input()
b = list(int(input()))
x = max(b)-max(a)
print(x)


### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
A.sort()
print(abs(A[0]-A[-1]))
#import numpy as np
N, K= map(int,input().split())
A = list(map(int,input().split()))
a=A[:]
for _ in range(K)
  B=[0]*(N+1)
  for i in range(N):
    t = a[i]
    B[max(i-t,0)] +=1
    B[min(i+t+1,N)] -=1
  for i in range(N):
    B[i+1] += B[i]
    a=B[:N]        
  if min(a)==N:
    break
print(*a)

### FIXED CODE ###

N, K= map(int,input().split())
A = list(map(int,input().split()))
a=A[:]
for _ in range(K):
  B=[0]*(N+1)
  for i in range(N):
    t = a[i]
    B[max(i-t,0)] +=1
    B[min(i+t+1,N)] -=1
  for i in range(N):
    B[i+1] += B[i]
  a=B[:N]        
  if min(a)==N:
    break
print(*a)
n = int(input())
if n % 10 == 3:
  print("bon")
elif n % 10 == 0 or n % 10 == 1 or n % 10 == 6 or n % 10 == 8:
  pritn("pon")
else:
  print("hon")


### FIXED CODE ###

n = int(input())
d = n%10
 
if d in [2, 4, 5, 7, 9]:
  print("hon")
elif d in [0, 1, 6, 8]:
  print("pon")
elif d in [3]:
  print("bon")
from math import gcd

while True:
    a, b, c = map(int, input().split())
    if not a:
        break
    d = (b ** 2 - 4 * a * c) ** 0.5
    if isinstance(d, complex) or d - int(d) > 1e-6:
        print('Impossible')
        continue
    num1, num2 = -b + int(d), -b - int(d)
    den = 2 * a
    cmn1, cmn2 = gcd(num1, den), gcd(num2, den)
    print(den // cmn1, -num1 // cmn1, den // cmn2, -num2 // cmn2)

### FIXED CODE ###

import fractions

while True:
    a, b, c = map(int, input().split())
    if not a:
        break
    d = (b ** 2 - 4 * a * c) ** 0.5
    if isinstance(d, complex) or d - int(d) > 1e-6:
        print('Impossible')
        continue
    num1, num2 = -b + int(d), -b - int(d)
    den = 2 * a
    cmn1, cmn2 = fractions.gcd(num1, den), fractions.gcd(num2, den)
    p, q, r, s = den // cmn1, -num1 // cmn1, den // cmn2, -num2 // cmn2
    if (p, q) < (r, s):
        p, q, r, s = r, s, p, q
    print(p, q, r, s)
def main():
  n=int(input())
  A=[int(input()) for i in range(n)]
  crt=1
  for i in range(n):
    crt = A[crt-1]
    if crt == 2:
      print(len(L))
      break
  else:
    print(-1)
main()

### FIXED CODE ###

def main():
  n=int(input())
  A=[int(input()) for i in range(n)]
  crt=1
  cnt=0
  for i in range(n):
    cnt += 1
    crt = A[crt-1]
    if crt == 2:
      print(cnt)
      break
  else:
    print(-1)
main()
import math

def solve():
    N, K = map(int,input().split())
    A = list(map(int, input().split()))

    state = 1
    chklist = [0] * (N + 1)
    chklist_flag = [False] * (N + 1)
    chkmod = 0

    chklist_flag[0] = True

    for i in range(1, K + 1):
        state = A[state - 1]
        if chklist_flag[state - 1]:
            chkmod = (K - chklist[state - 1]) % (i - chklist[state - 1]) 
            chkrem = chklist[state - 1]
            break
        chklist[state - 1] = i 
        chklist_flag[state - 1] = True
    
    state = 1

    for i in range(chkrem + chkmod):
        state = A[state - 1]
    
    print(state)

if __name__ == "__main__":
    solve()

### FIXED CODE ###

import math

def solve():
    N, K = map(int,input().split())
    A = list(map(int, input().split()))

    state = 1
    chklist = [0] * (N + 1)
    chklist_flag = [False] * (N + 1)
 
    chkmod = 0
    chkrem = K

    chklist_flag[0] = True

    for i in range(1, K + 1):
        state = A[state - 1]
        if chklist_flag[state - 1]:
            chkmod = (K - chklist[state - 1]) % (i - chklist[state - 1]) 
            chkrem = chklist[state - 1]
            break
        chklist[state - 1] = i 
        chklist_flag[state - 1] = True
    
    state = 1

    for i in range(chkrem + chkmod):
        state = A[state - 1]
    
    print(state)

if __name__ == "__main__":
    solve()
import sys
sys.setrecursionlimit(20000)
x = int(input())

def mody(x,n):
	if n == 1:
		return 1
	if x%n == 0:
		return x
	else:
		return mody(x,n-1)

for i in range(0,10**5-x):
	n = mody(x+i,x+i-1)
	if n == 1:
		ans = x+i
		break
print(ans)

### FIXED CODE ###

def is_prime(x):
    if x<= 1: return False
    i=2
    while i*i<=x:
        if x%i==0:
            return False
        i+=1
    return True

ans = int(input())
while not is_prime(ans):
    ans+=1
print(ans)
x=0
while True:
	sousa=input().sprit() #?????????
	sousa=[int(sousa[0]),int(sousa[1])]
	if sousa==[0,0]:break
	yama=[]
	for k in range(sousa[1]):yama.append(k+1)
	yama=yama[::-1]
	for r in range(sousa[1]):
		[p,c]=input().sprit()
		[p,c]=[int(p),int(c)]
		yama[:p+c-1]=yama[p-1:p+c-1]+yama[:p-2]
	print(yama[0])

### FIXED CODE ###

while True:
	sousa=input().split()
	sousa=[int(sousa[0]),int(sousa[1])]
	if sousa==[0,0]:break
	yama=[]
	for k in range(sousa[0]):yama.append(k+1)
	yama=yama[::-1]
	for r in range(sousa[1]):
		[p,c]=input().split()
		[p,c]=[int(p),int(c)]
		yama[:p+c-1]=yama[p-1:p+c-1]+yama[:p-1]
	print(yama[0])
import sys
from heapq import *

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))

countA = [0] * (N + 1)
countB = [0] * (N + 1)
for x in A:
    countA[x] += 1
for x in B:
    countB[x] += 1

q = []
only_A = []
only_B = []
for i in range(N + 1):
    if countA[i] and countB[i]:
        q.append((-countA[i] - countB[i], i))
        continue
    if countA[i]:
        for _ in range(countA[i]):
            only_A.append(i)
    elif countB[i]:
        for _ in range(countB[i]):
            only_B.append(i)
heapify(q)

if q and -q[0][0] > N:
    print('No')
    exit()
raise
print('Yes')

ans = []
while q:
    _, x = heappop(q)
    if q:
        _, y = heappop(q)
        flag = True
    else:
        y = only_B.pop()
        flag = False
    countA[x] -= 1
    countB[y] -= 1
    ans.append((x, y))
    if countA[x]:
        heappush(q, (-countA[x] - countB[x], x))
    else:
        for _ in range(countB[x]):
            only_B.append(x)
    if flag and countB[y]:
        heappush(q, (-countA[y] - countB[y], y))
    if flag and not countB[y]:
        for _ in range(countA[y]):
            only_A.append(y)
while only_A:
    x, y = only_A.pop(), only_B.pop()
    ans.append((x, y))

X, Y = zip(*ans)
print(*Y)

### FIXED CODE ###

import sys
from heapq import *

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))

countA = [0] * (N + 1)
countB = [0] * (N + 1)
for x in A:
    countA[x] += 1
for x in B:
    countB[x] += 1

q = []
only_A = []
only_B = []
for i in range(N + 1):
    if countA[i] and countB[i]:
        q.append((-countA[i] - countB[i], i))
        continue
    for _ in range(countA[i]):
        only_A.append(i)
    for _ in range(countB[i]):
        only_B.append(i)
heapify(q)

if q and -q[0][0] > N:
    print('No')
    exit()
print('Yes')

ans = []
while q:
    _, x = heappop(q)
    if q:
        _, y = heappop(q)
        flag = True
    else:
        y = only_B.pop()
        flag = False
    countA[x] -= 1
    countB[y] -= 1
    ans.append((x, y))
    if countA[x]:
        heappush(q, (-countA[x] - countB[x], x))
    else:
        for _ in range(countB[x]):
            only_B.append(x)
    if flag and countB[y]:
        heappush(q, (-countA[y] - countB[y], y))
    if flag and not countB[y]:
        for _ in range(countA[y]):
            only_A.append(y)
while only_A:
    x, y = only_A.pop(), only_B.pop()
    assert countA[x] > 0
    assert countB[y] > 0
    countA[x] -= 1
    countB[y] -= 1
    ans.append((x, y))

ans.sort()
X, Y = zip(*ans)
print(*Y)
N = input()
hoge = map(int,input().split())
fuga = [bin(i) for i in hoge]
count = 10000000
for i in fuga:
   	tmp = i[::-1]
    for j in range(len(i)):
        if tmp[j] == '1'  and count > j:
            count = j
            break
print(count)  
  

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = [bin(i)[2:] for i in a]
c = [0] * n
for i,v in enumerate(b):
  for j in v[::-1]:
    if j == '0':
      c[i] += 1
    else:
      break
print(min(c))
s,t=map(input().split())
a,b=map(int,input().split())
u  =input()
if s==u:
	print(a-1)
else:
	print(b-1)

### FIXED CODE ###

s,t=input().split()
a,b=map(int,input().split())
u  =input()
if s==u:
	print(a-1,b)
else:
	print(a,b-1)
while True:
    n=int(input())
    a=[]
    for i in range(n):
        a.append(int(input()))
    for i in range(1,n):
        a[i]=max(a[i-1]+a[i],a[i])

    print(max(a))

### FIXED CODE ###

while True:
    n=int(input())
    if n==0:
        break
    a=[]
    for i in range(n):
        a.append(int(input()))
    for i in range(1,n):
        a[i]=max(a[i-1]+a[i],a[i])

    print(max(a))
N = int(input())
a = list(map(int,input().split()))
Kisuu = 0
YonBaisuu = 0
NiBaisuu = 0

for j in range(N):

  if a[j]%2 == 1:
    Kisuu += 1
  elif a[j]%4 == 0:
    YonBaisuu += 1
  else :
    NiBaisuu +=1

  
if Kisuu <= YonBaisuu:
  print('Yes')
else :
  if NiBaisuu == 0:
      if Kissuu+1 == YonBaisuu:
        print('Yes')
  else:
    print('No')

### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
one = 0
four = 0
two = 0

for j in range(N):

  if a[j]%2 == 1:
    one += 1
  elif a[j]%4 == 0:
    four += 1
  else :
    two +=1

print("Yes" if four >= one or (four == one - 1 and two == 0) else "No")
N =int(input())
N,X,T=map(int,input().split())
if N%X ==0:
    print(NT//X)
    else:
        print((N//X+1)*T)

### FIXED CODE ###

N,X,T=map(int,input().split())
if N%X ==0:
    print(N*T//X)
else:
    print(((N//X)+1)*T)
n = int(input())

hlist = input().split()

cnt = 0

for i in range(n):
        if hlist[i] == "Y":
                cnt += 1
if cnt > 0:
        print ('Four')
else:
        print ('Three')
~             

### FIXED CODE ###

n = int(input())

hlist = input().split()

cnt = 0

for i in range(n):
        if hlist[i] == "Y":
                cnt += 1
if cnt > 0:
        print ('Four')
else:
        print ('Three')
in_d = input()
n = int(in_d)

a = [int(i) for i in input().split()]

result = 0
if 0 in a:
    print(0)
else:
    result = 1
    limit = 10 ** 18
    over = 0
    a.sort()
    for v in a:
        result *= v
        if result > limit:
            over = 1
            break
    if over == 1:
        print(-1)
    else:
        print(result)

### FIXED CODE ###

in_d = input()

a, b = in_d.split()
a = int(a)
b = int(b)

c = a * b
print(c)
s = input()
l = s.split(' ')
m = list (map(int, l))
p, q, r = m

def shortest_round(p, q, r):
  list_of_times = [p + q, p + r, q + r]
  return min(list_of_times)

print(shortest_round(s))

### FIXED CODE ###

s = input()
l = s.split(' ')
m = list(map(int, l))
p, q, r = m
list_of_times = [p + q, p + r, q + r]
f = min(list_of_times)
print(f)
N,A=map(int,input().split())
if N%500<=A:
  print ("Yes")
else:
  print("No")

### FIXED CODE ###

a = int(input())
n = int(input())
if((a%500)<=n):
  print("Yes")
else:
  print("No")
import sys
sys.setrecursionlimit(100000)
n = int(input())
a_list = [int(input()) for _ in range(n)]
def calc_ans(start_num, count, max_count, all_list):
    ans = all_list[start_num-1]
    if ans == 2:
        print(count)
    elif count == max_count:
        print('-1')
    else:
        calc_ans(ans, count+1, max_count, all_list)
calc_ans(1, 1, n, a_list)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
n = int(input())
a_list = [int(input()) for _ in range(n)]
def calc_ans(start_num, count, max_count, all_list):
    ans = all_list[start_num-1]
    if ans == 2:
        print(count)
    elif count == max_count:
        print('-1')
    else:
        calc_ans(ans, count+1, max_count, all_list)
calc_ans(1, 1, n, a_list)