Harryxun/stf_run huggingface dataset:
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    A=list(mi()) + [0]

    dp = [[0] * (2*10**3+10) for _ in range(N+1)]
    x = 1000//A[0]
    dp[0][x] = 1000 - x * A[0]


    for i in range(x):
        dp[0][i] = 1000 - i * A[0]

    mx = x
    for i in range(N):
        _mx = mx
        for m in range(mx+1):
            for n in range(m+1):
                dp[i+1][m-n] = max(0,dp[i+1][m-n],dp[i][m] + A[i+1] * n)
                assert dp[i+1][m-n] >= 0
            
            if A[i+1] != 0:
                for j in range((dp[i][m] // A[i+1])+1):
                    dp[i+1][m+j] = max(0,dp[i+1][m+j],dp[i][m] - A[i+1] * j)
                    _mx = max(_mx,m+j)
                    
                    assert dp[i+1][m+j] >= 0

        mx = _mx

    ans = 0
    for i in range(len(dp[N-1])):
        if dp[N-1][i] == 0: continue
        ans = max(ans, dp[N-1][i] + A[N-1] * i)

    # print(dp[3][10])
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    _A=list(mi())
    A = []

    for a in _A:
        if len(A) > 0 and A[-1] == a: continue
        A.append(a)
    
    N = len(A)
    bottoms = []
    
    if N < 2:
        print(1000)
        exit()

    if A[0] < A[1]:
        bottoms.append(0)

    for i in range(N-1):
        if not i+2 < len(A): continue
        # print(A[i], A[i+1], A[i+2])
        if A[i] > A[i+1] and A[i+1] < A[i+2]:
            bottoms.append(i+1)
    
    money = 1000
    kabu = 0
    # print(bottoms)
    for bi in bottoms:
        bottom = A[bi]
        i = bi
        while i < N-1 and A[i] < A[i+1]:
            i += 1
        
        top = A[i]

        # print(bi,i)
        # print(bottom,top)
        kabu += money//bottom
        money -= money//bottom * bottom
        
        money += kabu * top
        kabu = 0
        # print("money",money)
    
    print(money)

    

if __name__ == "__main__":
    main()
n = list(int,input())
m = n.sort(reverse=True)
if n == m:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n = list(input())
if n[0] ==n[2]:
    print("Yes")
else:
    print("No")
import math

n, d=map(int, input().split())
x=[]
for i in range(n):
    x.append([int(i) for i in input().split()])

for i in range(n-1): #0-n
  for j in range(i+1,n):
    s = 0
    for k in range(d):
      s += (x[i][k]-x[j][k])**2
    a = math.sqrt(s)
    if a.is_integer():
      ans += 1
print(ans)

### FIXED CODE ###

import math

n, d=map(int, input().split())
x=[]
for i in range(n):
    x.append([int(i) for i in input().split()])

ans=0
for i in range(n-1): #0-n
  for j in range(i+1,n):
    s = 0
    for k in range(d):
      s += (x[i][k]-x[j][k])**2
    a = math.sqrt(s)
    if a.is_integer():
      ans += 1
print(ans)
n = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
else:
    ans = 1
    for i in a:
        ans *= i
        if ans > 10**18:
            print(-1)
            exit()
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
else:
    ans = 1
    for i in a:
        ans *= i
        if ans > 10**18:
            print(-1)
            exit()
    print(ans)
l = input()
t = input().sprit()
c = 0
for i in range(0,3):
  if l[i] == t[i]:
    c = c+1
  else:
    continue

print(c)


### FIXED CODE ###

l = input()
t = input()
c = 0
for i in range(0,3):
  if l[i] == t[i]:
    c = c+1
  else:
    continue

print(c)
import sys
sys.setrecursionlimit(10**9)
class UnionFind:
    def __init__(self,n):
        super().__init__()
        self.par = [-1]*n
        self.rank = [0]*n
        self.tsize = [1]*n

    
    def root(self,x):
        if self.par[x] == -1:
            return x 
        else:
            self.par[x] = root(par[x])
            return self.par[x]

    def unite(self, x, y):
        x_r = self.root(x)
        y_r = self.root(y)
        
        if self.rank[x_r]>self.rank[y_r]:
            self.par[y_r] = x_r

        elif self.rank[x_r]<self.rank[y_r]:
            self.par[x_r] = y_r
            
        elif x_r != y_r:
            self.par[y_r] = x_r
            self.rank[x_r] += 1

    def isSame(self,x,y):
        return self.root(x) == self.root(y)

    def size(self,x):
        return self.tsize[self.root(x)]



def main():
    n,m = tuple([int(t)for t in input().split()])

    bridge = [tuple([int(t)-1 for t in input().split()])for _ in [0]*m]
    bridge = bridge[::-1]

    uf = UnionFind(n)
    ans = [n*(n-1)//2]
    for a_i,b_i in bridge:
        if not uf.isSame(a_i,b_i):
            ans.append(ans[-1]-uf.size(a_i)*uf.size(b_i))
            uf.unite(a_i,b_i)
        else:
            ans.append(ans[-1])
    ans.pop()
    for a in ans[::-1]:
        print(a)



if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
class UnionFind:
    def __init__(self,n):
        super().__init__()
        self.par = [-1]*n
        self.rank = [0]*n
        self.tsize = [1]*n

    
    def root(self,x):
        if self.par[x] == -1:
            return x 
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x_r = self.root(x)
        y_r = self.root(y)
        
        if self.rank[x_r]>self.rank[y_r]:
            self.par[y_r] = x_r

        elif self.rank[x_r]<self.rank[y_r]:
            self.par[x_r] = y_r

        elif x_r != y_r:
            self.par[y_r] = x_r
            self.rank[x_r] += 1

        if x_r != y_r:
            size = self.tsize[x_r]+self.tsize[y_r]
            self.tsize[x_r] = size
            self.tsize[y_r] = size

    def isSame(self,x,y):
        return self.root(x) == self.root(y)

    def size(self,x):
        return self.tsize[self.root(x)]


def main():
    n,m = tuple([int(t)for t in input().split()])

    bridge = [tuple([int(t)-1 for t in input().split()])for _ in [0]*m]
    bridge = bridge[::-1]

    uf = UnionFind(n)
    ans = [n*(n-1)//2]
    for a_i,b_i in bridge:
        if not uf.isSame(a_i,b_i):
            ans.append(ans[-1]-uf.size(a_i)*uf.size(b_i))
            uf.unite(a_i,b_i)
        else:
            ans.append(ans[-1])
    ans.pop()
    for a in ans[::-1]:
        print(a)



if __name__ == "__main__":
    main()
import math
from sys import exit

n=int(input())
primes = {}
i = 2
ans = 0
square = math.floor(math.sqrt(n))

if n == 1:
    print(0)
    exit()

while True:
    if i > square:
        break
    if n % i == 0:
        if i not in primes.keys():
            primes[i] = 1
        else:
            primes[i] += 1
        n = n // i
    else:
        if i == 2:
            i += 1
        else:
            i += 2
        continue

# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])

#     if temp!=1:
#         arr.append([temp, 1])

#     if arr==[]:
#         arr.append([n, 1])

#     return arr

# primes = factorization(n)
if len(primes) == 0:
    print(1)
    exit()

for k,v in primes:
    base = v * 2
    root = math.floor(math.sqrt(base))
    if root * (root + 1) > base:
        root -= 1
    ans += root

print(ans)

### FIXED CODE ###

import math
from sys import exit

n=int(input())
primes = {}
i = 2
ans = 0
square = math.floor(math.sqrt(n))

if n == 1:
    print(0)
    exit()

# while True:
#     if n == 1 or i > square:
#         break
#     if n % i == 0:
#         if i not in primes.keys():
#             primes[i] = 1
#         else:
#             primes[i] += 1
#         n = n // i
#     else:
#         if i == 2:
#             i += 1
#         else:
#             i += 2
#         continue

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

primes = factorization(n)
if len(primes) == 0:
    print(1)
    exit()

for k,v in primes:
    base = v * 2
    root = math.floor(math.sqrt(base))
    if root * (root + 1) > base:
        root -= 1
    ans += root

print(ans)
def main():
  N = int(input())
  Sp = []
  Sm = []
  total = 0
  for i in range(N):
    l = input()
    u = 0
    h = 0
    um = 0
    for j in range(len(l)):
      if l[j] == '(':
        h += 1
      else:
        h -= 1
      u = min(u, h)
    if h == 0:
      um = min(um, u)
    elif h > 0:
      Sp.append([u, h])
    else:
      Sm.append([u-h, -h])
    total += h
  if total != 0:
    print('No')
    exit()
  Sp.sort(key=lambda, x:x[0])
  p = check(Sp)
  if p < 0 or p < -um:
    print('No')
    exit()
  Sm.sort(key=lambda, x:x[0])
  m = check(Sm)
  if m < 0:
    print('No')
    exit()
  print('Yes')

def check(S):
  h = 0
  for i in range(len(S)):
    if h + S[i][0] < 0:
      return -1
    else:
      h += S[i][1]
  return h

if __name__ == '__main__':
  main()

### FIXED CODE ###

import sys
readline = sys.stdin.readline

def main():
  N = int(readline())
  Sp = []
  Sm = []
  total = 0
  bm = 0
  for i in range(N):
    l = readline().strip()
    b = 0
    h = 0
    for j in range(len(l)):
      if l[j] == '(':
        h += 1
      else:
        h -= 1
      b = min(b, h)
    if h == 0 and b != 0:
      bm = min(bm, b)
    elif h > 0:
      Sp.append([b, h])
    elif h < 0:
      Sm.append([b-h, -h])
    total += h
  Sp.append([bm, 0])
  if total != 0:
    print('No')
    exit()
  Sp.sort(key=lambda x:x[0], reverse=True)
  p = check(Sp)
  if p < 0:
    print('No')
    exit()
  Sm.sort(key=lambda x:x[0], reverse=True)
  m = check(Sm)
  if m < 0:
    print('No')
    exit()
  print('Yes')

def check(S):
  h = 0
  for i in range(len(S)):
    if h + S[i][0] < 0:
      return -1
    else:
      h += S[i][1]
  return h

if __name__ == '__main__':
  main()
n,d=map(int,input().split())

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

import math

ans=[]
for a in range(n):
  for b in range(n):
    x=0
    for c in range(d):
      D=(l[a][c]-l[b][c])**2
      x+=D
    y=math.sqrt(x)
    ans.append(y.is_integer())
      
ans=(ans.count(True)-n)//2
print(ans)

### FIXED CODE ###

n,d=map(int,input().split())

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

import math

ans=[]
for a in range(n):
  for b in range(n):
    x=0
    for c in range(d):
      D=(l[a][c]-l[b][c])**2
      x+=D
    y=math.sqrt(x)
    ans.append(y.is_integer())
      
ans=(ans.count(True)-n)//2
print(ans)
import math

N, M = list(map(int, input().split()))
S = str(input())
T = str(input())

if N==M:
    print(int(N*M)) if S==T else print(-1)
else:
    g = math.gcd(N, M)
    if g==1:
        print(int(N*M))
    else:
        flag = False
        s, t = N/g, M/g
        ss = list(map(lambda x: int(x*s), list(range(0,g))))
        tt = list(map(lambda x: int(x*t), list(range(0,g))))
        for i,j in zip(ss,tt):
            if S[i]!=T[j]:
                flag = True
        if flag:
            print(-1)
        else:
            print(int(s*t*g))

### FIXED CODE ###

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

N, M = list(map(int, input().split()))
S = input()
T = input()

if S[0]!=T[0]:
    print(-1)
else:
    if N==M:
        print(int(N*M)) if S==T else print(-1)
    else:
        g = gcd(N, M)
        if g==1:
            print(int(N*M))
        else:
            flag = False
            s, t = N//g, M//g
            ss = list(map(lambda x: int(x*s), list(range(0,g))))
            tt = list(map(lambda x: int(x*t), list(range(0,g))))
            for i,j in zip(ss,tt):
                if S[i]!=T[j]:
                    flag = True
            if flag:
                print(-1)
            else:
                print(int(s*t*g))
import bisect

s = input()
n = len(s)

s2 = [0 for _ in range(n)]

zero = []
one = []
two = []

for i in range(n):
  s2[i] = int(s[i]) % 3

for i in range(1,n):
  s2[i] += s2[i-1]
  s2[i] %= 3

for i in range(n):
  if s2[i] == 0:
    zero.append(i)
  elif s2[i] == 1:
    one.append(i)
  elif s2[i] == 2:
    two.append(i)
ans = 0
length = len(zero)
for i in range(length):
    if int(s[:zero[i]+1]) % 2019 == 0:
      ans += 1
length = len(zero)
for i in range(length-1):
  tmp = s[zero[i]+1:]
  for j in range(i+1,length):
    if int(tmp[:zero[j]-zero[i]]) % 2019 == 0:
      ans += 1

length = len(one)
for i in range(length-1):
  tmp = s[one[i]+1:]
  for j in range(i+1,length):
    if int(tmp[:one[j]-one[i]]) % 2019 == 0:
      ans += 1

length = len(two)
for i in range(length-1):
  tmp = s[two[i]+1:]
  for j in range(i+1,length):
    if int(tmp[:two[j]-two[i]]) % 2019 == 0:
      ans += 1
print(ans)


### FIXED CODE ###

s,w = map(int,input().split())

if s <= w:
  print('unsafe')
else:
  print('safe')
N = int(input())
ps = [list(map(int, input().split())) for _ in range(N)]

prev = None
for x, y in ps:
  mandist = abs(x) + abs(y)
  if prev is not None and mandist % 2 != prev:
    print('-1')
    exit()
  prev = mandist % 2

isodd = mandist % 2
m = 39 if isodd else 40
print(m)
print(' '.join(['1'] * m))
for x, y in ps:
  mandist = abs(x) + abs(y)
  ans = 'RL' * ((m - mandist) // 2)
  if x >= 0:
    ans += 'R' * x
  else:
    ans += 'L' * (-x)
  if y >= 0:
    ans += 'U' * y
  else:
    ans += 'D' * (-y)
  print(ans)

### FIXED CODE ###

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

prev = None
for x, y in ps:
  mandist = abs(x) + abs(y)
  if prev is not None and mandist % 2 != prev:
    print('-1')
    exit()
  prev = mandist % 2

isodd = mandist % 2
ds = [2 ** i for i in range(32)] # 10^9 より大きくなるように適当に
ds = ds[::-1]
if isodd:
  m = 32
else:
  m = 33
  ds += [1]

print(m)
print(' '.join(list(map(str, ds))))
for x, y in ps:
  px = py = 0
  ans = ''
  for d in ds:
    dx = x - px
    dy = y - py
    if abs(dx) >= abs(dy):
      if dx >= 0:
        ans += 'R'
        px += d
      else:
        ans += 'L'
        px -= d
    else:
      if dy >= 0:
        ans += 'U'
        py += d
      else:
        ans += 'D'
        py -= d
  print(ans)
import copy

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

res = 10**8

C = [0] * N
A = [0] * N

for i in range(N):
    L = list(map(int,input().split()))
    C[i] = L[0]
    A[i] = L[1:]

def sum_l(a,b):
    for i in range(len(a)):
        a[i] += b[i]
    return a

def check_x(a):
    for i in range(len(a)):
        if a[i] < X:
            return False
    return True

# n…2^12(12bit)の整数
def calc_money_under(n):
    understand = [0] * M
    money = 0
    for s in range(N):
        if (n >> s) == 1:
            money += C[s]
            #tmp = copy.copy(understand)
            understand = copy.copy([x + y for (x,y) in zip(understand, A[s])])
            print(understand)
    
    if check_x(understand):
        res = min(sum(money), res)
    return

for n in range(2**N):
    calc_money_under(n)

if res == 10**8:
    print(-1)
else:
    print(res)



### FIXED CODE ###

import copy
 
N,M,X = map(int,input().split())
 
res = 10**8
 
C = [0] * N
A = [0] * N
 
for i in range(N):
    L = list(map(int,input().split()))
    C[i] = L[0]
    A[i] = L[1:]
 
def check_x(a):
    for i in range(len(a)):
        if a[i] < X:
            return False
    return True
 
# n…2^12(12bit)の整数
def calc_money_under(n):
    global res

    understand = [0] * M
    money = 0
    for s in range(N):
        if (n >> s) & 1:
            money += C[s]
            for j in range(M):
                understand[j] += A[s][j]
            #print(understand)
    
    if check_x(understand):
        res = min(money, res)
    return
 
for n in range(2**N):
    calc_money_under(n)
 
if res == 10**8:
    print(-1)
else:
    print(res)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

from collections import defaultdict

H, W, D = map(int, input().split())
A = [list(map(int, input().split()))  for _ in range(H)]

dic = defaultdict(list)

for h in range(W):
    for w in range(W):
        dic[A[h][w]] = [h, w]

def calc(l, r):
    return abs(dic[l][0] - dic[r][0]) + abs(dic[l][1] - dic[r][1])

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    ans = 0
    while L != R:
        ans += calc(L, L + D)
        L += D
    print (ans)

### FIXED CODE ###

H, W, D = map(int, input().split())

#盤面を取得
lst = [0] * (H * W + 1)
for i in range(1, H + 1):
    tmp = list(map(int, input().split()))
    for j in range(1, W + 1):
        lst[tmp[j - 1]] = [i, j]
#前処理

#xからyに移動するのにかかるコストを返す関数
def cost(x, y): 
    return abs(lst[x][0] - lst[y][0]) + abs(lst[x][1] - lst[y][1])

check_lst = [False] * (H * W + 1)
cost_lst = [0] * (H * W + 1)
for i in range(1, H * W + 1):
    if check_lst[i]:
        continue
    check_lst[i]  = True
    tmp = i
    while tmp + D <= H * W:
        cost_lst[tmp + D] = cost_lst[tmp] + cost(tmp, tmp + D)
        check_lst[tmp + D] = True
        tmp += D

#出力
Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    print (cost_lst[R] - cost_lst[L])
H, W = map(int, input().split())
s = [["."]*W]
for i in range(H):
    temp = "."
    temp += input()
    temp += "."
    s.append(temp)
s.append(["."]*W)
flag = True
for i in range(1, H+1):
    for j in range(1, W+1):
        if s[i][j] == "#" and s[i-1][j] == "." and s[i+1][j] == "." and s[i][j-1] == "." and s[i][j+1] == ".":
            flag = False
            break
    if not flag:
        break
if flag:
    result = "Yes"
else:
    result = "No"
print(result)

### FIXED CODE ###

H, W = map(int, input().split())
s = ["."*(W+2)]
for i in range(H):
    temp = "."
    temp += input()
    temp += "."
    s.append(temp)
s.append("."*(W+2))
flag = True
for i in range(1, H+1):
    for j in range(1, W+1):
        if s[i][j] == "#" and s[i-1][j] == "." and s[i+1][j] == "." and s[i][j-1] == "." and s[i][j+1] == ".":
            flag = False
            break
    if not flag:
        break
if flag:
    result = "Yes"
else:
    result = "No"
print(result)
n, d = map(int, input().split())
cnt = 0
for ti in n :
  x, y = map(int, input().split())
  dist = (x**2 + y**2)**0.5
  if(dist >= d):
    cnt += 1
    
print(cnt)

### FIXED CODE ###

n, d = map(int, input().split())
cnt = 0
for ti in range(n) :
  x, y = map(int, input().split())
  dist = (x**2 + y**2)**0.5
  if(dist <= d):
    cnt += 1
    
print(cnt)
n,m = map(int,input().split())
t=0
if n==2: t=10
if n==3: t=100
t=str(t)
t=[int(t[0]),int(t[1]),int(t[2])]
f=[0]*len(t)
for i in range(m):
    ans = -1
    s,c = map(int,input().split())
    s-=1
    if c <  t[s]: break
    if c >  t[s]:
        if f[s]==0:
            f[s],t[s]=1,c
        elif f[s]==1:
            break
    ans=t[0]*100+t[1]*10+t[2]
print(ans)

### FIXED CODE ###

n,m = map(int,input().split())
t='000'
if n==2: t='010'
if n==3: t='100'
f=[0]*len(t)
t=[int(t[0]),int(t[1]),int(t[2])]
ans = t[0]*100+t[1]*10+t[2] 
for i in range(m):
    ans = -1
    s,c = map(int,input().split())
    s=s-(n-2)
    if c <  t[s]: break
    if c >  t[s]:
        if f[s]==0:
            f[s],t[s]=1,c
        elif f[s]==1:
            break
    ans=t[0]*100+t[1]*10+t[2]
print(ans)
N, M, X = map(int, input().split())
List = [list(map(int, input().split())) for n in range(N)]
INF = 10**7
ans = INF
C_pro = list(itertools.product([0,1], repeat=N))

for c_pro in C_pro:
    count = 0
    cost = 0
    ans_list = [0 for i in range(M)]
    for c in c_pro:
        if c == 1:
            cost += List[count][0]
            ans_list = [ans+list for ans, list in zip(ans_list,List[count][1:])]
        count += 1
    if ans_list >= [X for i in range(M)]:
        ans = min(ans, cost)
    

if ans == INF:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

import itertools

N, M, X = map(int, input().split())
List = [list(map(int, input().split())) for n in range(N)]
INF = 10**7
ans = INF
C_pro = list(itertools.product([0,1], repeat=N))

for c_pro in C_pro:
    count = 0
    cost = 0
    ans_list = [0 for i in range(M)]
    for c in c_pro:
        if c == 1:
            cost += List[count][0]
            ans_list = [answ+list for answ, list in zip(ans_list,List[count][1:])]
        count += 1
    ok = True
    for i in range(len(ans_list)):
        if ans_list[i] < X:
            ok = False
            break
    if ok:
        ans = min(ans, cost)
    

if ans == 10**7:
    print(-1)
else:
    print(ans)
def p_c():
    N, M = map(int, input().split())
    switch = [0] * N
    light = [0] * (1 << M)
    light[0] = 1
    for i in range(M):
        for s in list(map(int, input().split()))[1:]:
            switch[s - 1] += (1 << i)

    all_value = 0
    for i, p in enumerate(map(int, input().split())):
        all_value += p << (M - i - 1)

    for i in range(N):
        next_light = light.copy()
        for j in range(len(light)):
            next_light[j ^ switch[i]] += light[j]
        light = next_light

    print(light[all_value])
    
p_c()

### FIXED CODE ###

def p_c():
    n, m = map(int, input().split())
    s = [list(map(int, input().split()))[1:] for _ in range(m)]
    *p, = map(int, input().split())
    b = []
    for _s in s:
        bit = 0
        for i in _s:
            bit += (1 << (i - 1))
        b.append(bit)
    ans = 0
    for i in range(1 << n):
        for j, k in enumerate(b):
            if bin(i & k).count("1") & 1 != p[j]:
                break
        else:
            ans += 1
    print(ans)
    
p_c()
import sys
sys.setrecursionlimit(200000)

import numpy as np
import math
n = int(input())
A = np.fromstring(input(),dtype=np.int64,sep=" ")
rng = int(math.log2(np.max(A)))+1
sum = 0
for bit in range(rng):
    c = int((A & 1).sum())
    sum += c *(n-c)*(1<<bit)
    A = A>>1

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


### FIXED CODE ###

import numpy as np
 
 
def solve(string):
    n, *a = map(int, string.split())
    # a = ["{:060b}".format(_a) for _a in a]
    a = np.asarray(a, dtype=np.int64)
    m = 10**9 + 7
    ans = 0
    for i in range(60):
        s = int((a & 1).sum())
        a >>= 1
        # ans += s * (n - s) * pow(2, 59 - i, m)
        ans += s * (n - s) * pow(2, i, m) % m
        ans %= m
    return str(ans)
 
 
if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
X = 0
for i in range(N-1):
  if A[i] == A[i+1]-1 :
    X += (B[i]+C[i+1])
  else:
    X += B[i]
    break
X += B[N-1]  
print(X)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
X = B[A[0]-1]
for i in range(1,N):
  if A[i] == A[i-1]+1 :
    X += (B[(A[i]-1)]+C[(A[i-1]-1)])
  else:
    X += B[(A[i]-1)]
print(X)
# C - Digits in Multiplication
n = int(input())
import math
ans = []
for i in range(1,int(math.sqrt(n))):
    if n%i == 0:
        ans.append(max(len(str(i)),len(str(int(n//i)))))
print(min(ans))

### FIXED CODE ###

n = int(input())
import math
ans = []
for i in range(1,int(math.sqrt(n)+1)):
    if n%i == 0:
        ans.append(max(len(str(i)),len(str(int(n//i)))))
print(min(ans))