Harryxun/stf_run huggingface dataset:
from fractions import gcd


def lcm(x, y):
    return int(x / gcd(x, y) * y)


def greatLCM(a):
    if len(a) < 2:
        return a[0]
    ans = lcm(a[0], a[1])
    p = 2
    while p < len(a):
        ans = lcm(ans, a[p])
        p += 1
    return ans


mod = 10 ** 9 + 7
n = int(input())
arr = list(map(int, input().split()))
g = greatLCM(arr)
answer = 0
for i in arr:
    answer += g / i
    answer %= mod

print(int(answer))


### FIXED CODE ###

import fractions

N = int(input())
A = list(map(int, input().split()))

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def solve():
    memo = A[0]
    for i in range(1, N):
        memo = lcm(memo, A[i])

    ans = 0
    for i in range(N):
        ans += memo // A[i]

    return ans % (10 ** 9 + 7)

print(solve())
a = input()
b = input()
k = input()

a = int(a)
b = int(b)
k = int(k)
print("ans")
if b - a >= k*2:
    for i in range(a,a+k):
        print(i)
    print("ss")
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)


### FIXED CODE ###

# a = input()
# b = input()
# k = input()
str = input()
str = str.split()
#print(str)
a = int(str[0])
b = int(str[1])
k = int(str[2])
#print("ans")
if b - a >= k*2:
    for i in range(a,a+k):
        print(i)
    #print("ss")
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)
# ABC123A

import numpy as np
a = [0] * 5
for i in range(5):
    a[i] = int(input())
k = int(input())
a = np.array(a)
print(":(" if np.sum(abs(np.subtract.outer(a, a)) > k) > 0 else "Yay!")

ABC123A([1,2,4,8,9], 15)
ABC123A([15, 18, 26, 35, 36], 18)


### FIXED CODE ###

# ABC123A

import numpy as np
a = [0] * 5
for i in range(5):
    a[i] = int(input())
k = int(input())
a = np.array(a)
print(":(" if np.sum(abs(np.subtract.outer(a, a)) > k) > 0 else "Yay!")
# https://atcoder.jp/contests/abc105/tasks/abc105_c
# -2進数
# 前に考えたときはわからなかったけど、数式イジイジしたら解けた


N = int(input())

if N == 0:
    print(0)
	exit()
ans = ''
while N != 0:
    if N & 1:  # 奇数ならbitが立つのは共通する性質
        ans += '1'
        N /= -2
        if N > 0:
            N += 1
        N = int(N)
    else:
        ans += '0'
        N //= -2


print(ans[::-1])


### FIXED CODE ###

# https://atcoder.jp/contests/abc105/tasks/abc105_c
# -2進数
# 前に考えたときはわからなかったけど、数式イジイジしたら解けた


N = int(input())

if N == 0:
    print(0)
    exit()

ans = ''
while N != 0:
    if N & 1:  # 奇数ならbitが立つのは共通する性質
        ans += '1'
        N /= -2
        if N > 0:
            N += 1
        N = int(N)
    else:
        ans += '0'
        N //= -2


print(ans[::-1])
n=int(input())
a=list(map(int,input().split()))
a1=[i for i in a if i % 2 == 0]
a1=np.array(a1)
p=np.prod(a1, axis = 0)
k=0
while True:
    if p%2==0:k+=1
    else:break
print(k)

### FIXED CODE ###

#import sys
#input()=sys.stdin.readline()
n=int(input())
a=list(map(int,input().split()))
k=0
for i in range(len(a)):
    while True:
        if a[i]%2==0:
            a[i]/=2
            k+=1
        else:break
print(k)
a,b = map(int,input().split)
print (a -b if a-b <0 else 0)

### FIXED CODE ###

a,b = map(int,input().split())
print (a -b if a-b >0 else 0)
S_input = str(input())
add_str_taple = ("dream", "dreamer", "erase", "eraser")

def recur_add(T):
    if T == S_input:
        print("YES")
        exit()
    else:
        if S_input.startswith(T):
            for word in add_str_taple:
                recur_add(T+word)
        else:
            return None

recur_add("")
print("NO")

### FIXED CODE ###

import re
print("YES" if re.match("^(dream|dreamer|erase|eraser)+$", input()) else "NO")
import numpy
n,k=map(int,input().split())
a=list(map(int,input().split()))
d=max(a)
def p(x):
    return len(bin(x))-2
e=p(k)
f=p(d)
h=[]
if e>=f:
    for i in range(n):
        l=bin(a[i])
        h.append(list("0"*(e-len(l)+2)+l[2:]))
else:
    for i in range(n):
        l=bin(a[i])
        h.append(list("0"*(f-len(l)+2)+l[2:]))
p=numpy.array(h)
p=p.T
p=p.tolist()
c=0
if k==0:
    print(sum(a))
else:
    ans=0
    for i in range(len(p)):
        o=p[i].count("1")
        if o<n/2 and k>=2**(len(p)-i-1)
            c+=(n-o)*(2**(len(p)-i-1))
            k-=2**(len(p)-i-1)
        else:
            c+=o*(2**(len(p)-i-1))
    print(c)

### FIXED CODE ###

import numpy
n,k=map(int,input().split())
a=list(map(int,input().split()))
d=max(a)
def p(x):
    return len(bin(x))-2
e=p(k)
f=p(d)
h=[]
if e>=f:
    for i in range(n):
        l=bin(a[i])
        h.append(list("0"*(e-len(l)+2)+l[2:]))
else:
    for i in range(n):
        l=bin(a[i])
        h.append(list("0"*(f-len(l)+2)+l[2:]))
p=numpy.array(h)
p=p.T
p=p.tolist()
c=0
if k==0:
    print(sum(a))
else:
    ans=0
    for i in range(len(p)):
        o=p[i].count("1")
        if o<n/2 and k>=2**(len(p)-i-1):
            c+=(n-o)*(2**(len(p)-i-1))
            k-=2**(len(p)-i-1)
        else:
            c+=o*(2**(len(p)-i-1))
    print(c)
import sys
from collections import deque
input = sys.stdin.readline

MOD = 1000000007

class Node:
    def __init__(self):
        self.check = False
        self.link = []

    def color(self, K):
        self.check = True
        ret = 1
        # 子の塗り分け方を計算
        for i in range(len(self.link)-1):
            ret *= (K - 2) - i
            ret %= MOD
        # 子の子の塗り分け方を掛ける
        for node in self.link:
            if not node.check:
                ret *= node.color(K)
                ret %= MOD
        return ret

def main():
    N, K = map(int, input().split())
    nodes = [Node() for i in range(N+1)]
    for i in range(N-1):
        a, b = map(int, input().split())
        a -= 1; b -= 1;
        nodes[a].link.append(nodes[b])
        nodes[b].link.append(nodes[a])
    root = nodes[0]
    ans = K * (K - 1)
    ans *= root.color(K)
    ans %= MOD
    print(ans)

if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from collections import deque
sys.setrecursionlimit(1000000007)
input = sys.stdin.readline

MOD = 1000000007

class Node:
    def __init__(self):
        self.check = False
        self.link = []

    def color(self, K):
        self.check = True
        ret = 1
        # 子の塗り分け方を計算
        for i in range(len(self.link)-1):
            ret *= (K - 2) - i
            ret %= MOD
        # 子の子の塗り分け方を掛ける
        for node in self.link:
            if not node.check:
                ret *= node.color(K)
                ret %= MOD
        return ret

def main():
    N, K = map(int, input().split())
    if N == 1:
        print(K)
    else:
        nodes = [Node() for i in range(N+1)]
        for i in range(N-1):
            a, b = map(int, input().split())
            a -= 1; b -= 1;
            nodes[a].link.append(nodes[b])
            nodes[b].link.append(nodes[a])
        root = nodes[0]
        root.check = True
        ans = K
        for i in range(1, len(root.link)+1):
            ans *= (K-i)
            ans %= MOD
        for node in root.link:
            ans *= node.color(K)
            ans %= MOD
        print(ans)

if __name__ == "__main__":
    main()
n, k = map(int, input().split())
s = input()

print(s.replace(s[k], s[k].lower()))


### FIXED CODE ###

n,k=map(int,input().split())
s=input()
print(s[:k-1]+s[k-1].lower()+s[k:])
n,k= map(int,input().split())
a = input().split()
cost = [0]*n
c1 = 0
c2 =0
for i in range(n):
    a[i] = int(a[i])
    if(i==0):
        cost[i] =0
    elif(k>i):
        
        mini = 10**5
        change = 0
        for j in range(i):
            change = abs(a[i] - a[j]) + cost[j]
            # print(change)
            if(mini > change):
                mini = change

        cost[i] = mini
    else:
       
        mini = 10**5
        change = 0
        for j in range(1,k+1):
            change = abs(a[i] - a[i-j]) + cost[i-j]
            if(mini > change):
                mini = change
            # print(change)
        cost[i] = mini


# print(a)
# print(cost)
print(cost[n-1])

### FIXED CODE ###

n= int(input())
a = input().split()
cost = [0]*n
c1 = 0
c2 =0
for i in range(n):
    a[i] = int(a[i])
i = 0
for i in range(1,n):
    if(i==1):
        cost[i] = abs(a[i] - a[i-1])
    else:
        c1 = abs(a[i] - a[i-1]) + cost[i-1]
        c2 = abs(a[i] - a[i-2]) + cost[i-2]
        cost[i] = min(c1,c2)

print(cost[n-1])
cnt = 0
def s(start, end):
    print(start, end)
    global cnt
    if(start==len(S)-1):
        return cnt
    numS = int(S[start:end+1])
    if(numS%2019==0):
        cnt += 1
    if(end==len(S)-1):
        end = start+2
        s(start+1, end)
        return
    s(start, end+1)

if __name__ == '__main__':
    S = input()
    s(0, 1)
    print(cnt)

### FIXED CODE ###

S = list(map(int, list(input())))[::-1]
N = len(S)
CNT = [0]*2019
CNT[0] = 1
num = 0
d = 0
for i in range(N):
    num += S[i]*pow(10, d, 2019)
    num %= 2019
    CNT[num] += 1
    d += 1
ans = 0 
for cnt in CNT:
    ans += (cnt*(cnt - 1)) // 2
print(ans)
N = int(input())
li = list(map(int,input().split()))

L = [0] * 10**6

import math
from functools import reduce

if reduce(math.gcd,li)!=1:
    print('not coprime')
    exit()

if 1 in li:
    print('setwise coprime')
    exit()

for i in li:
    L[i] = 1

for k in range(2,10**6//2+1):
    t = 0
    for j in range(0,10**6,k):
        t += L[j]
    if t > 1:
        print('setwise coprime')
        exit()
print('pairwise coprime')

### FIXED CODE ###

N = int(input())
li = list(map(int,input().split()))

S = max(li)
L = [0] * (S+1)

import math
from functools import reduce

if reduce(math.gcd,li) != 1:
    print('not coprime')
    exit()

for i in li:
    L[i] = 1

for k in range(2,S+1):
    t = 0
    for j in range(0,S+1,k):
        t += L[j]
    if t > 1:
        print('setwise coprime')
        exit()
print('pairwise coprime')
import numpy as np


n = int(input())
a = [int(_) for _ in input().split()]
M = max(a)
p = len(format(M, 'b'))
l = [[0 for _ in range(n)] for _ in range(p)]
ans = 0
for i in range(n):
    a_s = format(a[i], '0' + str(p) + 'b')
    for c in range(p):
        l[c][i] = int(a_s[c])
arr = np.array(l)
for i in range(p):
    c1 = np.count_nonzero(arr[i])
    ans += (2**(p - i - 1)) * c1 * (n - c1)
    ans %= (10**9 + 7)
print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline


def main():
    n = int(input())
    a = [int(_) for _ in input().split()]
    M = max(a)
    p = len(format(M, 'b'))
    l = [0 for _ in range(p)]
    ans = 0
    for i in range(n):
        a_s = format(a[i], '0' + str(p) + 'b')
        for c in range(p):
            if a_s[c] == '1':
                l[c] += 1
    for i in range(p):
        c1 = l[i]
        ans += (2**(p - i - 1)) * c1 * (n - c1)
        ans %= (10**9 + 7)
    print(ans)

if __name__ == '__main__':
    main()
import collections
import sys
from functools import lru_cache
sys.setrecursionlimit(20000)
n, m  = [int(i) for i in input().split(' ')] 
edges = collections.defaultdict(list)
for i in range(m):
    s,d = [int(i) for i in input().split(' ')] 
    edges[s-1].append(d-1) 
# dp = [-1]*n
maxPath = 0 
@lru_cache(None)
def dfs(node): 
    # global dp
    ans = 0 
    for i in edges[node]:
        ans = max(ans,dfs(i)+1)
    # dp[node] = ans
    return ans
for i in range(n):
    maxPath = max(dfs(i), maxPath) 
print(maxPath)


### FIXED CODE ###

import collections
import sys
from functools import lru_cache
sys.setrecursionlimit(int(10**9))
n, m  = [int(i) for i in input().strip().split(' ')] 
edges = collections.defaultdict(list)
for i in range(m):
    s,d = [int(i) for i in input().strip().split(' ')]
    edges[s-1].append(d-1) 
# dp = [-1]*n
maxPath = 0 
@lru_cache(None)
def dfs(node): 
    ans = 0 
    for i in edges[node]:
        ans = max(ans,dfs(i)+1)
    return ans

for i in range(n):
    maxPath = max(dfs(i), maxPath) 
print(maxPath)
a,b,k=map(int,input().split())
if a>=k:
  print(a-k,b)
elif b>=(k-a):
  print(0,b-k+a)
else:
  print(0,0)


### FIXED CODE ###

s,t=input().split()
print(t+s)
N, T = map(int, input.split())
c_max = 1001

for i in range(N):
  c,t = map(int, input.split())
  if t <=T:
    c_max=min(c_max, c)
print("TLE" if c_max==1001 else c)

### FIXED CODE ###

N,T=map(int,input().split())
m=1001
for i in range(N):
    c,t=map(int,input().split())
    if t<=T:m=min(m,c)
print("TLE" if m==1001 else m)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    def f(i):
        n = 0
        if i == N:
            return 0
        if B[i] >= A[i]:
            B[i] -= A[i]
            n += A[i]
            A[i] = 0
            n += min(A[i+1], B[i])
            A[i] -= min(A[i+1], B[i])
            B[i] -= min(A[i+1], B[i])
            return n + f(i+1)
        else:
            n += B[i]
            A[i] -= B[i]
            return n + f(i+1)

    n = f(0)
    print(n)

main()


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    n = 0
    for i in range(N):
        m = min(A[i], B[i])
        n += m
        A[i] -= m
        B[i] -= m
        m = min(A[i+1], B[i])
        n += m
        A[i+1] -= m
        B[i] -= m

    print(n)

main()
N = int(input())

input_1 = input()
input_2 = input_1.split()

A = map(int, input_2)

def equal(num):
    return num
A = [equal(x) for x in A]

ans = 0

for l in range(N):
    ans += A.count(A[l]) - 1

ans = ans / 2
re = ans

for k in range(N):
    ans -= A.count(A[k]) - 1

    print(int(ans))

    ans = re

### FIXED CODE ###

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

ans = (N * (N - 1) + M * (M - 1)) / 2

print(int(ans))
N = int(input())
c = input()

d = list(c)

i = 0
j = N - 1
result = 0
while i != j:
    if d[i] == 'W':
        while d[j] != 'R' and i != j:
            j -= 1
        d[i] = 'R'
        d[j] = 'W'
        result += 1
    i += 1
print(result)


### FIXED CODE ###

N = int(input())
c = input()

d = list(c)

i = 0
j = N - 1
result = 0
while True:
    while i < N and d[i] != 'W':
        i += 1
    while j > 0 and d[j] != 'R':
        j -= 1
    if i == N or j == -1 or i >= j:
        break
    d[i] = 'R'
    d[j] = 'W'
    result += 1
print(result)
N, M = map(int, input().split())
S = [0]*M
C = [0]*M
SC = {1: set([]), 2: set([]), 3: set([])}
for m in range(M):
    S[m], C[m] = map(int, input().split())
    SC[S[m]].add(C[m])

ANS = [0]*N
out = 0
for i in range(1, 4):
    if len(SC[i]) >= 2:
        out = 1
if out == 1:
    print(-1)
else:
    for i in range(N):
        if i == 0:
            if list(SC[1])[0] == 0:
                out = 1
            elif len(SC[1]) == 0:
                ANS[0] = 1
            else:
                ANS[0] = list(SC[1])[0]
        else:
            if len(SC[i+1]) == 0:
                ANS[i] = 0
            else:
                ANS[i] = list(SC[i+1])[0]

    if ANS[0] == 0:
        print(-1)
    else:

        ans = 0
        for i in range(N):
            ans += ANS[i]*10**(N-i-1)

        print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
S = [0]*M
C = [0]*M
SC = {}
SC = {1: set([]), 2: set([]), 3: set([])}
for m in range(M):
    S[m], C[m] = map(int, input().split())
    SC[S[m]].add(C[m])

ANS = [0]*N
out = 0
for i in range(1, 4):
    if len(SC[i]) >= 2:
        out = 1
if out == 1:
    print(-1)

else:
    out = 0
    if N == 1:
        if len(SC[1]) == 0:
            ANS[0] = 0
        else:
            ANS[0] = list(SC[1])[0]

    else:
        for i in range(N):
            if i == 0:
                if len(SC[i+1]) == 0:
                    ANS[0] = 1
                elif list(SC[i+1])[0] == 0:
                    out = 1
                else:
                    ANS[0] = list(SC[i+1])[0]
            else:
                if len(SC[i+1]) == 0:
                    ANS[i] = 0
                else:
                    ANS[i] = list(SC[i+1])[0]
    if out == 1:
        print(-1)
    else:
        ans = 0
        for i in range(N):
            ans += ANS[i]*10**(N-i-1)
        print(ans)
A = int(input())
B = int(input())

if A % B == 0:
    print(B // A)
else:
    print(A // B + 1)

### FIXED CODE ###

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

ans = 0
outlet = 1
while outlet < B:
    outlet -= 1
    outlet += A
    ans += 1
print(ans)
a,b,k = map(int, input().split())
for i in sorted(set(list(range(a,b+1))[:k]+list(range(a,b+1))[-k:])):
    print(i)

### FIXED CODE ###

a,b,k = map(int, input().split())
if b-a+1>k*2:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)
A,B,C,D = map(int, input().split())
print(sum(500*i+100*j+50*k==D for i in range(A+1) for j in range(B+1) for k in range(C+1)))

### FIXED CODE ###

A, B, C, D = [int(input()) for i in range(4)]
print(sum([500*a+100*b+50*c == D for a in range(A+1) for b in range(B+1) for c in range(C+1)]))
import sys
sys.setrecursionlimit(2147483647)


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

a.sort()
nn=a[-1]

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
p = 998244353
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
#cmb(n-1, pair, p)

result=0
for i in range(1,len(a)):
    if a[i-1]<nn//2 and a[i]>=nn//2:
        if a[i]==nn:
            print(nn,a[i-1])
            exit()
        if cmb(nn,a[i-1],1)>cmb(nn,a[i],1):
            print(nn,a[i-1])
        else:
            print(nn,a[i])

        exit()
  
  


### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)

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

if n==2:
    print(aa[0],aa[1])
    exit()

aa.sort()

nn=max(aa)

c=0
tmp=10**9

for a in aa:
    if abs(nn/2.0-a)<tmp:
        tmp=abs(nn/2.0-a)
        c=a

print(nn,c)
import itertools

n,m=list(map(int,input().split()))
path=[[False]*m for _ in range(m)]
for i in range(m):
  a,b=list(map(int,input().split()))
  path[a-1][b-1]=True

ans=0
for i in itertools.permutations(list(range(n))):
  if i[0]!=0:
    continue
  flg=True
  for j in range(len(i)-1):
    if path[min(i[j],i[j+1])][max(i[j],i[j+1])]==False:
      flg=False
      break
  if flg:
    ans+=1
print(ans)

### FIXED CODE ###

import itertools

n,m=list(map(int,input().split()))
path=[[False]*n for _ in range(n)]
for i in range(m):
  a,b=list(map(int,input().split()))
  path[a-1][b-1]=True

ans=0
for i in itertools.permutations(list(range(n))):
  if i[0]!=0:
    continue
  flg=True
  for j in range(len(i)-1):
    if path[min(i[j],i[j+1])][max(i[j],i[j+1])]==False:
      flg=False
      break
  if flg:
    ans+=1
print(ans)
import sys
x = input()
x1 = list(x)
h = len(x)
x = int(x)

if x>2000:
  print('1')
  sys.exit()

a1 = int(x1[h-1])
a2 = int(x1[h-2])

if 0 < a1 < 5:
  c1 = 1
elif a1 == 0:
  c1 = 0
else:
  c1 = 2

c2 = a2*2
if int(x1[0])+int(x1[1]) < c1+c2:
  print('0')
else:
  print('1')

### FIXED CODE ###

import sys
x = input()
x1 = list(x)
h = len(x)
x = int(x)

if x>2000:
  print('1')
  sys.exit()

a1 = int(x1[h-1])
a2 = int(x1[h-2])

if 0 < a1 <= 5:
  c1 = 1
elif a1 == 0:
  c1 = 0
else:
  c1 = 2

c2 = a2*2
#print(x1[0],x1[1])
if h>3:
  if 10*int(x1[0])+int(x1[1]) < c1+c2:
    print('0')
  else:
    print('1')
else:
  if int(x1[0]) < c1+c2:
    print('0')
  else:
    print('1')
dic = {i:list(input()) for i in 'abc'}
while len(dic[key]) != 0:
  key = 'a'
  key = dic.pop(key)
print(key.upper())

### FIXED CODE ###

S = {i: list(input()) for i in 'abc'}
s = 'a'
while S[s]:
  s = S[s].pop(0)
print(s.upper())
import math
A, B, N = list(map(int, input().split()))
ans = 0
if B+1 < N:
    C = B+1
else:
    C = N
if B//A == 0:
    D = 1
else:
    D = B//A
for i in range(1, C+1, D-1):
    val = math.floor(A*i/B) - A*math.floor(i/B)
    #print("i", i, "val", val)
    ans = max(ans, val)

print(ans)

### FIXED CODE ###

import math
A, B, N = list(map(int, input().split()))
ans = 0
if B+1 < N:
    C = B+1
else:
    C = N
if B//A == 0:
    D = 1
elif B//A > 1:
  	D = B//A-1
else:
    D = B//A
for i in range(1, C+1, D):
    val = math.floor(A*i/B) - A*math.floor(i/B)
    #print("i", i, "val", val)
    ans = max(ans, val)

print(ans)
a = input()
if a < 1200:
	print("ABC")
elif a < 2800:
	print("ARC")
else:
	print("AGC")

### FIXED CODE ###

a = int(input())
if a < 1200:
 print("ABC")
elif a < 2800:
 print("ARC")
else:
 print("AGC")
import sys
from collections import defaultdict, Counter
def input(): return sys.stdin.readline().rstrip()

def main():
    H, W, K = map(int, input().split())
    choco = [input() for _ in range(H)]

    ans = 10 ** 9
    for i in range(2 ** (H-1)):
        opt = 0
        memoCounter = Counter({})
        for j in range(W):
            c = 0
            memo = defaultdict(int)
            for k in range(H):
                if i & 1 << k:
                    c += 1
                memo[c] += int(choco[k][j])
            if max(memo) > K:
                    break
            memoCounter += memo
            if memoCounter.most_common()[0][1] > K:
                opt += 1
                memoCounter = Counter(memo)
        else:
            opt += format(i, 'b').count('1')
            if ans > opt:
                ans = opt
    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from collections import defaultdict
def input(): return sys.stdin.readline().rstrip()

def main():
    H, W, K = map(int, input().split())
    S = [input() for _ in range(H)]

    ans = 10 ** 9

    for bit in range(1 << (H-1)):
        canSolve = True
        ord = defaultdict(int)
        N = 0
        for i in range(H):
            if bit & 1 << i:
                ord[i+1] = ord[i] + 1
                N += 1
            else:
                ord[i+1] = ord[i]
        add = 0
        nums = defaultdict(int)
        for w in range(W):
            one = defaultdict(int)
            ok = True
            for h in range(H):
                one[ord[h]] += int(S[h][w])
                nums[ord[h]] += int(S[h][w])
                if one[ord[h]] > K:
                    canSolve = False
                if nums[ord[h]] > K:
                    ok = False
            if not ok:
                add += 1
                nums = one
        if canSolve and ans > N + add:
            ans = N + add
    print(ans)

if __name__ == '__main__':
    main()
def inc(tree, point, p, x):
    # 自分
    point[p] += x
    if tree[p] == -1:
        return

    for child in tree[p]:
        inc(tree, point, child, x)


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

tree = [-1] * (N+1)
point = [0] * (N+1)

for i in range(N-1):
    a, b = map(int, input().split())
    if tree[a] == -1:
        tree[a] = [b]
    else:
        tree[a] += [b]

for i in range(Q):
    p, x = map(int, input().split())

    inc(tree, point, p, x)

point.pop(0)
print(*point)

### FIXED CODE ###


import sys
input = sys.stdin.readline #for input speed
sys.setrecursionlimit(10**6) #for deep recursion
n, q = map(int, input().split())

tree_index = [[] for _ in range(n)]
for i in range(n-1):
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  tree_index[a].append(b) # a<bとは限らないため、双方向にする
  tree_index[b].append(a)

#print(tree_index)


ans = [0] * n
for i in range(q):
  p, x = map(int, input().split())
  ans[p-1] += x

def dfs(cur, par):
    for chl in tree_index[cur]:
      if chl == par: #parentとchildが等しい時はスキップ
        continue
      ans[chl] += ans[cur]
      dfs(chl, cur)
dfs(0, -1)
print(*ans)
集会は数直線上の任意の 整数値の座標 で開くことができ、座標 


### FIXED CODE ###

N = int(input())
X = list(map(int, input().split()))
sum_min = 10**8

for i in range(min(X), max(X)+1):
    s = 0
    for j in range(N):
        s += (X[j] - i)**2
    
    if s < sum_min:
        sum_min = s

print(sum_min)
N,R=input(int(x) for x in input().split())
if N>=10:
    print(R)
else:
    print(R+100*(10-N))

### FIXED CODE ###

N,R=(int(x) for x in input().split())
if N>=10:
    print(R)
else:
    print(R+100*(10-N))