Harryxun/stf_run huggingface dataset:
import fractions
 
 
def args():
    N, MA, MB = list(map(int, input().split()))
 
    A, B, C = [], [], []
    for i in range(N):
        a, b, c = list(map(int, input().split()))
        A.append(a)
        B.append(b)
        C.append(c)
 
    # print(N, MA, MB)
    # print(A)
    # print(B)
    # print(C)
 
    return N, MA, MB, A, B, C
 
 
def solve(N, MA, MB, A, B, C):
    def recur(i, a, b):
        if not MEMO[i][a][b] is None:
            return MEMO[i][a][b]
 
        if not i < N:
            if 0 < a and 0 < b:
                g = fractions.gcd(a, b)
                if (MA, MB) == (a / g, b / g):
                    return 0
            return float("inf")
 
        res = min(recur(i + 1, a, b) + 0, recur(i + 1, a + A[i], b + B[i]) + C[i])
        MEMO[i][a][b] = res
        return res
 
    x, y, z = 40 + 10, 10 * 10 + 10, 10 * 10 + 10
    MEMO = [[[None] * z for _ in range(y)] for _ in range(x)]
 
    ans = recur(0, 0, 0)
 
    return ans
 
 
if __name__ == '__main__':
    res = solve(*args())
 
    print(-1) if res == float("inf") else print(res)

### FIXED CODE ###

import fractions


def args():
    N, MA, MB = list(map(int, input().split()))

    A, B, C = [], [], []
    for i in range(N):
        a, b, c = list(map(int, input().split()))
        A.append(a)
        B.append(b)
        C.append(c)

    # print(N, MA, MB)
    # print(A)
    # print(B)
    # print(C)

    return N, MA, MB, A, B, C

def solve(N, MA, MB, A, B, C):
    def recur(i, a, b):
        if not MEMO[i][a][b] is None:
            return MEMO[i][a][b]

        if not i < N:
            if 0 < a and 0 < b:
                g = fractions.gcd(a, b)
                if (MA, MB) == (a / g, b / g):
                    return 0
            return float("inf")

        res = min(recur(i + 1, a, b) + 0, recur(i + 1, a + A[i], b + B[i]) + C[i])
        MEMO[i][a][b] = res
        return res

    x, y, z = N + 1, 10 * N + 1, 10 * N + 1
    MEMO = [[[None] * z for _ in range(y)] for _ in range(x)]

    ans = recur(0, 0, 0)

    return ans


if __name__ == '__main__':
    res = solve(*args())

    print(-1) if res == float("inf") else print(res)
import collections
S = input()
cnt = 0

length = len(S)
mod = [0]
reverse_S = S[::-1]
tens = 1
for i in range(len(S)):
  now = int(reverse_S[i])*tens%2019
  mod.append((now+mod[i])%2019)
  tens *= 10
  tens %= 2019

c = collections.Counter(mod)
hindo = sorted(c.values(),reverse=True)
for i in range(hindo.index(1)):
  n = hindo[i]
  cnt += n*(n-1)/2

print(int(cnt))

### FIXED CODE ###

import collections
S = input()
cnt = 0

mod = [0]
reverse_S = S[::-1]
for i in range(len(reverse_S)):
  now = int(reverse_S[i]) * pow(10,i,2019)
  mod.append((now + mod[i]) % 2019)


c = collections.Counter(mod)
hindo = c.values()
for i in hindo:
  if i != 1:
    cnt += i*(i-1)//2


print(cnt)
s = input()
search="keyence"
idx=0
flg = False
ans="NO"
for c in s:
    if c == search[idx]:
        idx += 1
    if idx >= 7:
        flg=True
        break
if flg:
    idx = -1
    for i in range(7):
        x=s.find(search[0:i])
        #print("ps=%s, ns=%s, reduce=%s" %(search[0:i], search[i+1:], s[x+i+i:]))
        if s[x+i+1:].find(search[i+1:]):
            ans = "YES"
            break
    print(ans)
else:
    print(ans)
~              

### FIXED CODE ###

s = input()
search="keyence"
idx=0
flg = False
ans="NO"
n = len(s)
if s[0:7] == search:
    print("YES")
elif (s[-7:] == search):
    print("YES")
else:
    for i in range(7):
        if s[0:i+1] == search[0:i+1]:
            #print(s[(-7+i+1):])
            #print(search[i+1:])
            if (s[(-7+i+1):] == search[i+1:]):
                ans = "YES"
                break
    print(ans)
import math
def cal_lcm(x, y):
    return (x * y) // math.gcd(x, y)

a,b,c,d = map(int,input().split()) 

cd = cal_lcm(c,d)
b_c = b // c
b_d = b // d
b_cd = b // cd
a_c = a // c
a_d = a // d
a_cd = a // cd

ans = b - b_c - b_d + b_cd - a + a_c + a_d - a_cd

if a % c != 0 and a % d!= 0:
    ans += 1

print(ans)


### FIXED CODE ###

import fractions

a,b,c,d = map(int,input().split()) 

cd = (c * d) // fractions.gcd(c, d)
b_c = b // c
b_d = b // d
b_cd = b // cd
a_c = a // c
a_d = a // d
a_cd = a // cd

ans = b - b_c - b_d + b_cd - a + a_c + a_d - a_cd

if a % c != 0 and a % d!= 0:
    ans += 1

print(ans)
import numpuy as np
dishes = [int(input()) for _ in range(5)]
dishes = sorted(dishes, key=lambda x: x % 10)
minutes = 0
first = True
for i in dishes:
    if i % 10 == 0:
        minutes += i
    else:
        if first:
            minutes += i
            first = False
        else:
            minutes += int(np.ceil(i/10)*10)
print(minutes)

### FIXED CODE ###

import numpy as np
dishes = [int(input()) for _ in range(5)]
dishes = sorted(dishes, key=lambda x: x % 10)
minutes = 0
first = True
for i in dishes:
    if i % 10 == 0:
        minutes += i
    else:
        if first:
            minutes += i
            first = False
        else:
            minutes += int(np.ceil(i/10)*10)
print(minutes)
a,b,c=(int(x) for x in input().split())
if a < b < c:
    print( 'A' )
elif a < c < b:
    print( 'A' )
elif b < a < c:
    print( 'B' )
elif b < c < a:
    print( 'B' )
elif c < a < b:
    print( 'C' )
elif c < b < a

### FIXED CODE ###

x, a, b = (int(x) for x in input().split())
if abs(a-x) < abs(b-x):
    print("A")
else:
    print("B")
A=int(input())
B=int(input())

K=(A+B)/2

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

if is_integer_num(K)==False:
  print(IMPOSSIBLE)
else:
  print(K)

### FIXED CODE ###

A,B = map(int,input().split())
 
K=(A+B)/2
 
def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False
 
if is_integer_num(K)==False:
  print("IMPOSSIBLE")
else:
  print(int(K))
N = int(input())
a = [[] for _ in range(N)]
ans = [0]*N
for _ in range(N-1):
  u, v, w = map(int, input().split())
  a[u-1].append([v-1, w])
  a[v-1].append([u-1, w])
def calc(u, b):
  print(u)
  for v, w in a[u]:
    if not b == v:
      ans[v]=(ans[u] + w)
      calc(v, u)
calc(0, -1)
print(ans)
for i in ans:
  if i % 2 == 0:
    print(0)
  else:
    print(1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
N = int(input())
a = [[] for _ in range(N)]
ans = [0]*N
for _ in range(N-1):
  u, v, w = map(int, input().split())
  a[u-1].append([v-1, w])
  a[v-1].append([u-1, w])
def calc(u, b):
  for v, w in a[u]:
    if not b == v:
      ans[v]=(ans[u] + w)%2
      calc(v, u)
calc(0, -1)
for i in ans:
  if i % 2 == 0:
    print(0)
  else:
    print(1)
n,m,l=map(int,input().split())

#基本的にワーシャルフロイドの場合、行列式のリストで距離を保管する
from scipy.sparse import csr_matrix
from scipy.sparse import csgraph 

d = [[10**12 for i in range(n+1)] for i in range(n+1)]

for i in range(m):
    x,y,z = map(int,input().split())
    #有向グラフか無向グラフかによってここで場合わけが生じる
    d[x][y] = z
    d[y][x] = z
    
for i in range(n+1):
    d[i][i] = 0 #自身のところに行くコストは０
q=int(input())
que=[]
for _ in range(q):
    s,t=map(int,input().split())
    que.append((s,t))
       
csr=csr_matrix(d)
K=csgraph.shortest_path(csr,method="FW",directed=True)
e = [[10**12 for i in range(n+1)] for i in range(n+1)]

for i in range(1,n+1):
    for j in range(1,n+1):
        if K[i][j]<=l:
            e[i][j]=1
            
for i in range(n+1):
    e[i][i]=0
    

A=csr_matrix(e)
ANS=csgraph.shortest_path(A,method="FW",directed=True)

for some in que:
    s,t=some[0],some[1]
    if int(ANS[s][t])<10**12:
        print(int(ANS[s][t])-1)
    else:
        print(-1)



### FIXED CODE ###

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

#基本的にワーシャルフロイドの場合、行列式のリストで距離を保管する
from scipy.sparse import csr_matrix
from scipy.sparse import csgraph 
d = [[10**12 for i in range(n+1)] for i in range(n+1)]
for i in range(m):
    x,y,z = map(int,input().split())
    #有向グラフか無向グラフかによってここで場合わけが生じる
    d[x][y] = z
    d[y][x] = z
    
for i in range(n+1):
    d[i][i] = 0 #自身のところに行くコストは０
q=int(input())
que=[]
for _ in range(q):
    s,t=map(int,input().split())
    que.append((s,t))
       
csr=csr_matrix(d)
K=csgraph.shortest_path(csr,method="FW",directed=True)
e = [[10**12 for i in range(n+1)] for i in range(n+1)]

for i in range(1,n+1):
    for j in range(1,n+1):
        if K[i][j]<=l:
            e[i][j]=1
            
for i in range(n+1):
    e[i][i]=0
    

A=csr_matrix(e)
ANS=csgraph.shortest_path(A,method="FW",directed=True)

for some in que:
    s,t=some[0],some[1]
    if int(ANS[s][t])<10**12:
        print(int(ANS[s][t])-1)
    else:
        print(-1)
N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=list(set([abs(inputcities[i]-X) for i in range(N)]))
N=len(cities)
count=0
flag=0
minimum=min(cities)
for j in range(minimum+1)[::-1]:
  for i in range(N):
    if cities[i]%j==0:
      count+=1
    else:
      count=0
      i=N
    if count==N:
      print(j)
      flag=1
      break
    if i==N:
      for k in range(2,j)
        if j%k==0:
          j=k
          break
  if flag==1:
    break

### FIXED CODE ###

def gcd(a,b):
    if a < b:
        a,b = b,a
    if a % b == 0:
        return b
    else:
        return gcd(b,(a % b))
 
N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=[abs(inputcities[i]-X) for i in range(N)]
cities.sort()
D=cities[0]
for i in range(N):
  D=gcd(D,cities[i])
print(D)
n=input()
a=0
for i in range(1,10**5):
  a+=i
  if a>=n:
    break
print(i)

### FIXED CODE ###

n=int(input())
a=0
for i in range(1,10**5):
  a+=i
  if a>=n:
    break
print(i)
# -*- coding: utf-8 -*-

from collections import OrderedDict

n = int(input())
dic = OrderedDict()

for i in range(n):
    l,d = list(map(str,input().split()))
    dic[l] = d

a = str(input())

flag = False
time = 0

for key,value in dic.items():
    if flag == False:
        if key == a:
            flag = True
    else:
        time += int(value)

print(time)

### FIXED CODE ###

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

a = str(input())

alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

print(alpha[alpha.index(a)+1])
import math as m

s=N/X
s=m.ceil(s)
s=int(s)
i=s*T
print(i)

### FIXED CODE ###

import math as m

LIST=list(map(int,input().split()))

N=LIST[0]
X=LIST[1]
T=LIST[2]

s=N/X
s=m.ceil(s)
s=int(s)
i=s*T
print(i)
def sura_backsura():
    import collections

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

    fp = collections.Counter(a[0::2]).most_common()
    sp = collections.Counter(a[1::2]).most_common()

    if fp[0] != sp[0]:
        count = N - fp[0][1] - sp[0][1]
    else:
        count = min(N - fp[0][1] - sp[1][1], N - fp[1][1] - sp[0][1])

    print(count)
    
if __name__ == "__main__":
    sura_backsura()

### FIXED CODE ###

def sura_backsura():
    import collections

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

    fp = collections.Counter(a[0::2]).most_common()
    sp = collections.Counter(a[1::2]).most_common()

    fp.append((0, 0))
    sp.append((0, 0))

    if fp[0] != sp[0]:
        count = N - fp[0][1] - sp[0][1]
    else:
        count = min(N - fp[0][1] - sp[1][1], N - fp[1][1] - sp[0][1])

    print(count)
    
if __name__ == "__main__":
    sura_backsura()
#!/usr/bin/env python3
import sys

def show():
    for i in range(100):
        print(i, i**5)

def solve(X: int):
    A = [(i ** 5, i) for i in range(100)]
    for a, b in A:
        for aa, bb in A:
            if a  - aa == X:
                return b, -bb
            if a + aa == X:
                return b, bb
    raise


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    print(*solve(X))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()
    #show()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

def show():
    for i in range(100):
        print(i, i**5)

def solve(X: int):
    A = [(i ** 5, i) for i in range(1000)]
    for a, b in A:
        for aa, bb in A:
            if a  - aa == X:
                return b, bb
            if a + aa == X:
                return b, -bb
    raise


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    print(*solve(X))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()
    #show()
import numpy as np
X,N = map(int, input().split())
p = list(map(int, input().split()))
p = sorted(p)
lista = list(range(1,101))
for i in p:
    if i in lista:
        lista.remove(i)
lista = np.array(lista)
def find_nearest(array, value):
    array = np.asarray(array)
    idx = (np.abs(array - value)).argmin()
    print(array[idx])
find_nearest(lista,X)

### FIXED CODE ###

import numpy as np
X,N = map(int, input().split())
p = list(map(int, input().split()))
p = sorted(p)
lista = list(range(-100,200))
for i in p:
    if i in lista:
        lista.remove(i)
def getNearestValue(list, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """
    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    print(list[idx])
if N == 0:
    print(X)
else:
    getNearestValue(lista, X)
import sys
h,w,a,b = map(int,input().split())
tempa = 0
tempb = [0]*w

list_tb = [[0 for i in range(w)] for j in range(h)]
if w % a != 0 or h % b != 0:
  print("No")
  sys.exit()

if h > 2:
  for i in range(h):
    tempa = 0
    for j in range(w):
      if tempa < a and tempb[j] < b:
        list_tb[i][j] = 1
        tempa += 1
        tempb[j] += 1
    if a != 0 and tempa == 0:
      print("No")
      sys.exit()
else:
  for j in range(w):
    if tempa < a:
      list_tb[0][j] = 1
      tempa += 1

for i in list_tb:
    print(*i,sep="")

### FIXED CODE ###

h,w,a,b  = map(int,input().split())
lst_a  = [[1]*a + [0] * (w-a) for i in range(b)]
lst_b  = [[0]*a + [1] * (w-a)] * (h-b)
for i in lst_a:
 print(*i,sep="")
for i in lst_b:
 print(*i,sep="")
N = int(input())
A = list(range(1,N+1))
P = [A[len(A)-1]]
P.extend(A[:len(A)-1])
s = 0
for i,p in enumerate(P):
    s += p%(i+1)
print(s)

### FIXED CODE ###

N = int(input())
n = N -1
print(n*(n+1)//2)
def main():
  a, b = map(str, input().split())
  print(int(a)*floar(b))
 
main()

### FIXED CODE ###

a, b = map(str, input().split())
a = int(a)
b1, b2 = b.split('.')
b = int(b1) * 100 + int(b2)
ans = a * b
print(ans//100)
import math

A, B, C, D = map(int, input().split())

c_st = (A-1) // C
c_end = B // C
c_num = c_end - c_st

d_st = (A-1) // D
d_end = B // D
d_num = d_end - d_st

E = (C * D) // math.gcd(C, D)
e_st = (A-1) // E
e_end = B // E
e_num = e_end - e_st

ans = B - A - c_num - d_num + e_num + 1
print(ans)


### FIXED CODE ###

def gcd(a, b):
    if a < b:
        temp = a
        a = b
        b = temp

    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b

    return b


A, B, C, D = map(int, input().split())

c_st = (A-1) // C
c_end = B // C
c_num = c_end - c_st

d_st = (A-1) // D
d_end = B // D
d_num = d_end - d_st

E = (C * D) // gcd(C, D)
e_st = (A-1) // E
e_end = B // E
e_num = e_end - e_st

ans = B - A - c_num - d_num + e_num + 1

print(ans)
import sys
input = sys.stdin.readline
# import numpy as np

S = input().rstrip()

MOD = 10 ** 9 + 7
n = len(S)

# dp = np.zeros((100005, 13), dtype=np.uint64)

dp = [[0]*100005]*13

dp[0][0] = 1

for i in range(n):
    if S[i] == '?':
        c = -1
    else:
        c = int(S[i])
    
    for j in range(10):
        if c != -1 and c != j:
            continue
        for ki in range(13):
            dp[i+1][(ki * 10 + j) %13] += dp[i][ki]
            
    for j in range(13):
        dp[i+1][j] %= MOD
        
    res = dp[n][5]
    
print(res)

### FIXED CODE ###

import sys
input = sys.stdin.readline
# import numpy as np

S = input().rstrip()

MOD = 10 ** 9 + 7
n = len(S)

# dp = np.zeros((100005, 13), dtype=np.uint64)

dp = [[0 for i in range(13)] for j in range(100005)]

dp[0][0] = 1

for i in range(n):
    if S[i] == '?':
        c = -1
    else:
        c = int(S[i])
    
    for j in range(10):
        if c != -1 and c != j:
            continue
        for ki in range(13):
            dp[i+1][(ki * 10 + j) %13] += dp[i][ki]
            
    for j in range(13):
        dp[i+1][j] %= MOD
        
        
    res = dp[n][5]
    
print(res)
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    # Python3で出すことに注意！
    # floyd_warshall

    # https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csgraph.floyd_warshall.html
    # ↑を見ながら細部を埋める
    from scipy.sparse import csr_matrix
    from scipy.sparse.csgraph import floyd_warshall

    # (i, j)成分はiからjへの直接経路のコスト
    N=int(input())
    graph = [[0]*N for i in range(N)]
    for i in range(N-1):
        a,b,c=map(int,input().split())
        graph[a-1][b-1]=c


    graph = csr_matrix(graph)

    dist_matrix = floyd_warshall(csgraph=graph, directed=False, return_predecessors=False)
    # (i, j)成分はiからjへの最短コスト
    Q,K=map(int,input().split())
    for i in range(Q):
        x,y=map(int,input().split())
        print(int(dist_matrix[x-1][K-1]+dist_matrix[K-1][y-1]))


resolve()

### FIXED CODE ###

import sys
from collections import deque

def solve():
    input = sys.stdin.readline
    N = int(input())
    Edge = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b, c = map(int, input().split())
        Edge[a-1].append((b-1, c))
        Edge[b-1].append((a-1, c))
    Q, K = map(int, input().split())
    q = deque()
    Dist = [-1] * N
    q.append((K-1, K-1, 0))
    while q:
        nowN, preN, nD = q.popleft()
        if Dist[nowN] == -1:
            Dist[nowN] = nD
            for e, add in Edge[nowN]:
                if e != preN: q.append((e, nowN, nD + add))
    Ans = [None] * Q
    for i in range(Q):
        x, y = map(int, input().split())
        Ans[i] = str(Dist[x-1] + Dist[y-1])
    print("\n".join(Ans))

    return 0

if __name__ == "__main__":
    solve()
S = raw_input()
print(max(map(len, S.split('S'))))

### FIXED CODE ###

S = input()
print(max(map(len, S.split('S'))))
import itertools
f = lambda n:n*(n+1)//2

def sol():
    res = 0
    while q:
        x0 = q.popleft()
        x1 = q.popleft()
        res += f(max(x0, x1)) + f(min(x0, x1) -1)
    return res

s = input().rstrip("\n")

q = collections.deque()
for k, g in itertools.groupby(s):
    q.append(len(list(g)))
if len(q) % 2:
    q.append(1)

print(sol())


### FIXED CODE ###

def main():
  s = input().rstrip('\n')
  n = len(s)
  dp = [0] * (1 + n)
  for i,c in enumerate(s):
    if c == '<':
      dp[i+1] = dp[i] + 1
  for i in range(n-1, -1, -1):
    if s[i] == '>':
      dp[i] = max(dp[i], dp[i+1] + 1)
  return sum(dp)

print(main())
b = str(input()).split()
h = int(b[0])
w = int(b[1])
d = int(b[2])
c =[]

def abs(a,b):
    if a > b:
        return(a-b)
    else:
        return(b-a)

for i in range(0,h):
    c.append(str(input()).split())

q = int(input())
lr = []
energy = 0



for i in range(0,q):
    lr.append(str(input()).split())

for i in range(0,q):
    l = int(lr[i][0])
    r = int(lr[i][1])
    for j in range(0,h):
        for k in range(0,w):
            if int(c[j][k]) == l:
                li = j
                lj = k
            if int(c[j][k]) == l + d:
                di = j
                dj = k
        if l != r:
            energy += abs(li,di) + abs(lj,dj)
            l += d
        else:
            print(energy)
            break


### FIXED CODE ###

def list_1d(d,v):
    return [ v for i in range(d)]

def abs(c): 
    if c > 0: 
        return c 
    else: 
        return -c

def distance_2d(a,b):
    return(abs(a[0]-b[0])+abs(a[1]-b[1]))

h,w,d = [int(i) for i in input().split()]
sa = list_1d(h*w+1,[])
da = list_1d(h*w+1,0)
for i in range(h):
    a = [int(k) for k in input().split()]
    for j in range(w):
        sa[a[j]] = [i,j]
q = int(input())
lr = [[int(i) for i in input().split()] for i in range(q)]

for i in range(d+1,h*w+1):
    da[i] = da[i-d] + distance_2d(sa[i],sa[i-d])

for i in range(0,q):
    print(da[lr[i][1]]-da[lr[i][0]])
n,q=map(int,input().split())
ki=[[] for i in range(n+1)]
ki[0]="null"
 
for i in range(n-1):
    a,b=map(int,input().split())
    ki[a].append(b)
 
scores=[0 for i in range(n+1)]
scores[0]="null"
for i in range(q):
    p,x=map(int,input().split())
    scores[p]+=x
 
 
ans=[0 for i in range(n+1)]
ans[0]="null"
point=0
 
 
def tansa(n,point):
    point+=scores[n]
    for p in ki[n]:
        try:
            tansa(p,point)
        except:
            pass
    else:
        ans[n]=point
        
tansa(1,0)
 
ans=ans[1:]
ans=[str(i) for i in ans]
print(" ".join(ans))


### FIXED CODE ###

n,q=map(int,input().split())
L=[[] for i in range(n+1)]
S=[0 for i in range(n+1)]
V=[0 for i in range(n+1)]

for _ in range(n-1):
    a,b=map(int,input().split())
    L[a].append(b)   
    L[b].append(a)

for _ in range(q):
    p,x=map(int,input().split())
    S[p]+=x


que=[1]
head=0
V[1]=1
while len(que)>head:
    now=que[head]
    head+=1
    for nex in L[now]:
        if V[nex]==0:
            V[nex]=1
            que.append(nex)
            S[nex]+=S[now]

print(" ".join([str(i) for i in S[1:]]))
a, b = map(int, split())
print(str(a*b )+ str(a*2 + b*2 ))


### FIXED CODE ###

c= input()
a, b = map(int, c.split())
print(str(a*b) +" "+str(a*2 + b*2))
n=int(input())
2.i=int(n**0.5)
3.while i<n:
4.  if n%i==0:
5.    break
6.  else:
7.    i+=1
8.if i==n:
9.  print(i-1)
10.else:
11.  print(int(i+n/i)-2)


### FIXED CODE ###

n=int(input())
i=int(n**0.5)+1
while i>0:
  if n%i==0:
    break
  else:
    i-=1
if i==n:
  print(i-1)
else:
  print(int(i+n/i)-2)
sec = int(input())
tmp = [sec // 3600, (sec // 60) % 60, sec % 60]
print(':'.join(tmp))


### FIXED CODE ###

sec = int(input())
tmp = map(str, [sec // 3600, (sec // 60) % 60, sec % 60])
print(':'.join(tmp))
import numpy as np
n = int(input())
a = list(map(int, input().split()))
A = []
for i in range(n):
    c = [0] * n
    if i != n-1:
        c[i], c[i+1] = 0.5, 0.5
    else:
        c[0], c[n-1] = 0.5, 0.5
    A.append(c)

A = np.array(A)
b = np.array(a)
ans = list(np.linalg.solve(A, b))
ans = map(int, ans)
ans = map(str, ans)
print(" ".join(ans))


### FIXED CODE ###

n = int(input())
a = [int(x) for x in input().split()]
s = sum(a)
ans = [0] * n
even_a = 0
for i in a[1::2]:
    even_a += i
ans[0] = s - 2 * even_a
for i in range(1, n):
    ans[i] = 2 * a[i-1] - ans[i-1]
print(" ".join(map(str, ans)))
a = input()
b = input()
count = int(a)

num = map(int, b.split())
division = True
result = 0
while division:
    div = 0
    for i in range(count):
        if num[i]%2 == 0:
            div += 1
    if div == count:
        for j in range(count):
            num.append(num.pop(0)/2)
        result += 1
    else:
        division = False

print(result)


### FIXED CODE ###


a = input()
b = input()
count = int(a)
num = []

for k in range(count):
    num.append(int(b.split()[k]))

result = 0
division = True
while division:
    div = 0
    for i in range(count):
        if num[i]%2 == 0:
            div += 1
    if div == count:
        for j in range(count):
            num.append(num.pop(0)/2)
        result += 1
    else:
        division = False

print(result)