Harryxun/stf_run huggingface dataset:
import sys
def main():
	sys.setrecursionlimit(10**9)
	x, y, z, k = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = [0]*x*y*z
	for i in range(x):
		for j in range(y):
			for l in range(z):
				d[i*y*z+j*z+l] = a[i]+b[j]+c[l]
	d.sort(reverse=True)
	for i in range(k):
		print(d[i])


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
	x, y, z, k = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = [0]*x*y
	for i in range(x):
		for j in range(y):
			d[i*y+j] = a[i]+b[j]
	d.sort(reverse=True)
	c.sort(reverse=True)

	c_len = min(k, z)
	d_len = min(k, x*y)
	e = [0]*d_len*c_len
	for i in range(d_len):
		for j in range(c_len):
			e[i*c_len+j] = d[i] + c[j]
	e.sort(reverse=True)
	for i in range(k):
		print(e[i])


if __name__ == '__main__':
    main()
import sys
fin = sys.stdin.readline


N, M = [int(elem) for elem in fin().split()]
adj = [[] for _ in range(N)]
for _ in range(M):
    x, y = [int(elem) - 1 for elem in fin().split()]
    adj[x].append(y)

visited = [False] * N
topo_order = []
# topological sort by DFS
def dfs_visit(node):
    for neighbor in adj[node]:
        if not visited[neighbor]:
            dfs_visit(neighbor)
    topo_order.append(node)


for node in range(N):
    dfs_visit(node)
topo_order = topo_order[::-1]

dp = [0] * N
for node in topo_order[:-1]:
    for neighbor in adj[node]:
        dp[neighbor] = max(dp[neighbor], dp[node] + 1)

print(max(dp))


### FIXED CODE ###

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


N, M = [int(elem) for elem in fin().split()]
adj = [[] for _ in range(N)]
for _ in range(M):
    x, y = [int(elem) - 1 for elem in fin().split()]
    adj[x].append(y)

visited = [False] * N
topo_order = []
# topological sort by DFS
def dfs_visit(node):
    visited[node] = True
    for neighbor in adj[node]:
        if not visited[neighbor]:
            dfs_visit(neighbor)
    topo_order.append(node)


for node in range(N):
    dfs_visit(node)
topo_order = topo_order[::-1]

dp = [0] * N
for node in topo_order[:-1]:
    for neighbor in adj[node]:
        dp[neighbor] = max(dp[neighbor], dp[node] + 1)

print(max(dp))
N = input()
remainder = N % 1000
print(remainder)

### FIXED CODE ###

N = int(input())
remainder = N % 1000
if remainder == 0:
  print(0)
else:
  print(1000 - remainder)
N, T = map(int, input().split())
t = list(map(int, input().split()))
s, e = 0, 0
ans = 0
for i in range(N):
  if t[i] <= e:
    e = t[i] + T
    else:
      ans += e - s
      s = t[i]
      e = t[i] + T
ans += e - s
print(ans)




### FIXED CODE ###

n,t = (int(i) for i in input().split())
ni = [int(i) for i in input().split()]

total = 0

for i in range(1,len(ni)) :
  delta = ni[i] - ni[i-1]
  if delta < t :
    total += delta
  else :
    total += t

    
print(total+t)
r = [0] * n
for i in range(q):
    p, x = map(int, input().split())
    r[p - 1] += x
stack = [0]
used = [False] * n    
while stack:
    i = stack.pop()
    used[i] = True
    for to in l[i]:
        if not used[to]:
            stack.append(to)
            r[to] += r[i]
for t_r in r:
    print(t_r) 

### FIXED CODE ###

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

l = [[] for i in range(N)]

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

used = [False] * N
r = [0] * N

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

stack = [0]
while stack:
  i = stack.pop()
  used[i] = True
  for to in l[i]:
    if not used[to]:
      stack.append(to)
      r[to] += r[i]

print(*r)
n = int(input())
tree = [[] for i in range(n-1)]
d_list = [0]*n

stack = []
for i in range(n-1):
  u,v,w = map(int,input().split())
  tree[u-1].append((u-1,v-1,w))
while len(tree[0]) > 0:
  stack.append(tree[0].pop())
while len(stack) > 0:
  u,v, w = stack.pop()
  d_list[v] = d_list[u]+w
  while len(tree[v]) > 0:
    stack.append(tree[v].pop())
    
for v in d_list:
  if v % 2 == 0:
    print(0)
  else:
    print(1)

### FIXED CODE ###

n = int(input())
tree = [[] for i in range(n)]
d_list = [0]*n

stack = []
for i in range(n-1):
  u,v,w = map(int,input().split())
  tree[u-1].append((u-1,v-1,w))
  tree[v-1].append((v-1,u-1,w))
while len(tree[0]) > 0:
  e = tree[0].pop()
  stack.append(e)
#print(stack)
while len(stack) > 0:
  u,v, w = stack.pop()
  if d_list[v] == 0:
    d_list[v] = d_list[u]+w
  while len(tree[v]) > 0:
    e = tree[v].pop()
    stack.append(e)
  #print(stack)
for v in d_list:
  if v % 2 == 0:
    print(0)
  else:
    print(1)
from math import *

K = int(input())

sum = 0
for i in range(K):
  for j in range(K):
    for k in range(K):
      sum += gcd(i,gcd(j,k))

print(sum)
return

### FIXED CODE ###

from math import *

K = int(input())

sum = 0
for i in range(K):
  for j in range(K):
    for k in range(K):
      sum += gcd((i+1),gcd((j+1),(k+1)))

print(sum)
import Math
a, b = map(int, input().split())
print(Math.ceil((a+b)/2))


### FIXED CODE ###

import math
a, b = map(int, input().split())
print(math.ceil((a+b)/2))
a=input()
b=map(int,input().split())
ans=[]
max_b=max(b)
d=0
for i in b
 while i%2=0
   i=i/2
   d+=1
 ans.append(d)
print(ans)

### FIXED CODE ###

b=[]
a=input()
b=map(int,input().split())
ans=[]
f_ans=0
for i in b:
 d=0
 while i % 2 == 0:
   i=i/2
   d+=1
 ans.append(d)
 f_ans=min(ans)
print(f_ans)
#!/usr/bin/env python3
# N = int(input())
# S = input()
A, B = map(int, input().split())
# A = list(map(int, input().split()))
if (A + B) % 2 == 0:
    print((A + B)) // 2)
else:
    print("IMPOSSIBLE")

### FIXED CODE ###

#!/usr/bin/env python3
# N = int(input())
# S = input()
A, B = map(int, input().split())
# A = list(map(int, input().split()))
if (A + B) % 2 == 0:
    print((A + B) // 2)
else:
    print("IMPOSSIBLE")
from math import sprt
a,b=map(int,input().split())
c=sqrt(int(a+b))
if c==int(c):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

from math import sqrt
a,b=input().split()
c=sqrt(int(a+b))
if c==int(c):
  print("Yes")
else:
  print("No")
N = int(input())
A = []
for i in range(N):
   A.append(input())
S = 0
for i in range(N-1):
    if A[i][-1] == A[i+1][0]:
        S += 1
B = 0
for i in range(N):
    for j in range(N):
        if A[i] == A[j]:
            B += 1
            else:
                B += 0

if S == N-1 and B == N:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

import fractions
from functools import reduce


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


N, X = (int(i) for i in input().split())
A = [int(i) for i in input().split()]


def aho(x):
  return x - X


B = list(map(aho, A))

C = gcd_list(B)

print(abs(C))
import math

N, Ma, Mb = map(int,input().split())
rate = Ma / Mb
a = [0] * N
b = [0] * N
c = [0] * N
MA = 0
MB = 0
for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())
    MA += a[i]
    MB += b[i]

dp = [[[math.inf for i in range(MB+1)] for j in range(MA+1)] for k in range(N+1)]
dp[0][0][0] = 0

for it_N in range(N):
    for it_MA in range(MA+1):
        for it_MB in range(MB+1):
            if it_MA >= a[it_N] and it_MB >= b[it_N]:
                if dp[it_N][it_MA-a[it_N]][it_MB-b[it_N]] != math.inf:
                    dp[it_N+1][it_MA][it_MB] = min(dp[it_N][it_MA-a[it_N]][it_MB-b[it_N]] + c[it_N], dp[it_N][it_MA][it_MB])
            else:
                dp[it_N+1][it_MA][it_MB]=dp[it_N][it_MA][it_MB]

    for it_MA in range(MA+1):
        for it_MB in range(MB+1):
#            print(it_N+1,it_MA,it_MB,dp[it_N+1][it_MA][it_MB])

#中身確認
ans = -1
for a in range(1, MA+1):
    for b in range(1, MB+1):
        print(a,b,dp[N][a][b])
        if a/b == rate and dp[N][a][b] != math.inf:
            if ans == -1:
                ans = dp[N][a][b]
            else:
                ans = min([dp[N][a][b], ans])
print(ans)


### FIXED CODE ###


N, Ma, Mb = map(int,input().split())
rate = Ma / Mb
a = [0] * N
b = [0] * N
c = [0] * N
MA = 0
MB = 0
MC = 0
for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())
    MA += a[i]
    MB += b[i]
    MC += c[i]
    
dp = [[[MC for i in range(MB+1)] for j in range(MA+1)] for k in range(N+1)]
dp[0][0][0] = 0

for it_N in range(N):
    for it_MA in range(MA+1):
        for it_MB in range(MB+1):
            if it_MA >= a[it_N] and it_MB >= b[it_N]:
                if dp[it_N][it_MA-a[it_N]][it_MB-b[it_N]] != MC:
                    dp[it_N+1][it_MA][it_MB] = min(dp[it_N][it_MA-a[it_N]][it_MB-b[it_N]] + c[it_N], dp[it_N][it_MA][it_MB])
                else:
                    dp[it_N+1][it_MA][it_MB]=dp[it_N][it_MA][it_MB]
            else:
                dp[it_N+1][it_MA][it_MB]=dp[it_N][it_MA][it_MB]

ans = -1
for a in range(1, MA+1):
    for b in range(1, MB+1):
        if a/b == rate and dp[N][a][b] != MC:
            if ans == -1:
                ans = dp[N][a][b]
            else:
                ans = min(dp[N][a][b], ans)
print(ans)
n=int(input())
s=[input() for i in range(n)]
t=[input() for j in range(n)]
s.reverse()
l=0
for k  in range(n):
    while s[k]==t[k]:
        l+=1
print(l)

### FIXED CODE ###

N = int(input())
s = input()
t = input()
ans = 2*N
for i in range(N):
    if s[i:] == t[:N-i]:
        ans -= N - i
        break
print(ans)
#コピペです。
n = int(input())
a = list(map(int,input().split()))
cnt = 0

def ers(a,cnt,n):
    if len(a) == 0:
        cnt = -1
        return cnt
    for i in range(n):
        if i+1 != a[i]:
            a.pop(i)
            cnt+=1
            n -= 1
            return ers(a,cnt,n)
    return cnt

res = ers(a,cnt,n)

print(res)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(N):
    if A[i] != i+1-cnt:
        cnt += 1
if cnt == N:
    print(-1)
else:
    print(cnt)
s=input()
d={}
for i in s:
  d.get(i,0)+=1
for i in set(s):
  if d[i]%2==1:
    print("No")
    break
else:
  print("Yes")


### FIXED CODE ###

s=input()
d={}
for i in s:
  d[i]=d.get(i,0)+1
for i in set(s):
  if d[i]%2==1:
    print("No")
    break
else:
  print("Yes")
N,Y = map(int, input().split())
for i in range(N + 1):
    for l in range(N - i):
            ans = 10000*i + 5000*l + 1000*(N - i - l)
            if ans == Y:
                print("{} {} {} ".format(i ,l  ,(N - i - l)))
                exit()

print(-1 ,-1 ,-1)

### FIXED CODE ###

s = str(input())
l = s.replace("2017", "2018")
print(l)
N, M = map(int, input().split())
erase = {}
for i in range(N):
    a = list(map(int, input().split()))
    
    if i == 0:
        food = a[1:]
    else:
        for j in range(len(food)): 
            if food[j] not in a[1:]:
                erase.add(food[j])
print(len(food)-len(erase))      


### FIXED CODE ###

N, M = map(int, input().split())
erase = set()
for i in range(N):
    a = list(map(int, input().split())) 
    
    if i == 0:
        food = a[1:]
    for j in range(len(food)): 
        
        if food[j] not in a[1:]:
            erase.add(j)

print(len(food)-len(erase))
N, K = map(int, input().split())
A = list(map(int, input().split()))

center = A.index(1)
left_block = center + 1
right_block = len(A) - center

left_num = 0
if left_block > K:
    tmp = left_block
    while tmp > 0:
        tmp = tmp - K + 1
        left_num += 1
        if tmp == K:
            left_num -= 1
elif 2 <= left_block <= K:
    left_num = 1

right_num = 0
if right_block > K:
    tmp = right_block
    while tmp > 0 :
        tmp = tmp - K + 1
        right_num += 1
        if tmp == K:
            right_num -= 1
elif 2 <= right_block <= K:
    right_num = 1

print(left_num + right_num)

# D
K = int(input())

### FIXED CODE ###

import math

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

print(math.ceil((N-1)/(K-1)))
def frog2(N,h,k):
    dp=[sys.maxsize-1]*N
    dp[0]=0
    for i in range(N):
        for j in range(i+1,i+k+1):
            if j<N:
                dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]))
    return dp[N-1]

N,k=map(int,input().split())
h=list(map(int,input().split()))
print(frog2(N,h,k))

### FIXED CODE ###

import sys
def frog2(N,h,k):
    dp=[sys.maxsize-1]*N
    dp[0]=0
    for i in range(N):
        for j in range(i+1,i+k+1):
            if j<N:
                dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]))
    return dp[N-1]

N,k=map(int,input().split())
h=list(map(int,input().split()))
print(frog2(N,h,k))
h, w = map(int, input().split())
s = []
s_conn = []
for i in range(h):
  s.append(input())
  s_conn.append([[0]*2 for j in range(w)])

# 縦にみる
for x in range(w):
  start = 0
  count = 0
  for y in range(h):
    if s[y][x] = '.':
      count += 1
      if y == h-1:
        for i in range(start, y):
          s_conn[i][x][0] = count
    else:
      for i in range(start, y):
        s_conn[i][x][0] = count
      count = 0
      start = y+1

# 横にみる
for y in range(h):
  start = 0
  count = 0
  for x in range(w):
    if s[y][x] = '.':
      count += 1
      if x == w-1:
        for i in range(start, x):
          s_conn[y][i][0] = count
    else:
      for i in range(start, x):
        s_conn[y][i][0] = count
      count = 0
      start = x+1

max_all = 0
for i in range(h):
  max_tmp = max(map(sum, s_conn[i]))
  if max_tmp > max_all:
    max_all = max_tmp
print(max_all - 1)

### FIXED CODE ###

h, w = map(int, input().split())
s = []
l = []
r = []
u = []
d = []
for i in range(h):
  s.append(input())
  l.append([0 for j in range(w)])
  r.append([0 for j in range(w)])
  u.append([0 for j in range(w)])
  d.append([0 for j in range(w)])
  
# lみる
for x in range(w):
  for y in range(h):
    if s[y][x] == '.':
      if x == 0:
        l[y][x] = 1
      else:
        l[y][x] = l[y][x-1] + 1
 
# rみる
for x in range(w-1, -1, -1):
  for y in range(h-1, -1, -1):
    if s[y][x] == '.':
      if x == w-1:
        r[y][x] = 1
      else:
        r[y][x] = r[y][x+1] + 1
 
# uみる
for y in range(h):
  for x in range(w):
    if s[y][x] == '.':
      if y == 0:
        u[y][x] = 1
      else:
        u[y][x] = u[y-1][x] + 1
 
# dみる
for y in range(h-1, -1, -1):
  for x in range(w-1, -1, -1):
    if s[y][x] == '.':
      if y == h-1:
        d[y][x] = 1
      else:
        d[y][x] = d[y+1][x] + 1
 
 
max_all = 0
for y in range(h):
  for x in range(w):
    max_tmp = l[y][x] + r[y][x] + u[y][x] + d[y][x]
    if max_tmp > max_all:
      max_all = max_tmp
      
print(max_all - 3)
import math

a,b=map(int,input().split())
def lcm(x,y):
    return (x*y)//math.gcd(x,y)

print(lcm(a,b))

### FIXED CODE ###

import fractions

a,b=map(int,input().split())
def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)

print(lcm(a,b))
# -*- coding: utf-8 -*-
X = int(input())

num_500 = int(X / 500)
num_5 = int((X - (num_500*500)) / 5)

print((num_500*1000) + (num_5)*5)

### FIXED CODE ###

# -*- coding: utf-8 -*-
string = input()

if string[2] == string[3] and string[4] == string[5]:
  print('Yes')
else:
  print('No')
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if e-a <= k:
  print("Yay!")
  else:
    print(":(")

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if e-a <= k:
  print("Yay!")
else:
  print(":(")
#a以上b以下の整数のうちcでもdでも割り切れないものの個数を求めてください
#1以上b以下の整数の条件を満たすものから1以上a-1以下のもので条件を満たすものを取り除くようにすればいい
import math
x=c*d//math.gcd(c,d)
a,b,c,d=map(int,input().split())
n=b-((b//c)+(b//d)-b//(x))
m=(a-1)-((a-1)//c+(a-1)//d-(a-1)//(x))
print(n-m)

### FIXED CODE ###

#a以上b以下の整数のうちcでもdでも割り切れないものの個数を求めてください
#1以上b以下の整数の条件を満たすものから1以上a-1以下のもので条件を満たすものを取り除くようにすればいい
import fractions

a,b,c,d=map(int,input().split())
x=c*d//fractions.gcd(c,d)
n=b-((b//c)+(b//d)-b//(x))
m=(a-1)-((a-1)//c+(a-1)//d-(a-1)//(x))
print(n-m)
a,b=(int(x) for x in input().split())
lista=[]
listb=[]
for numa in range(a+1):
  lista.append(numa*2)
for numb in range(a+1)
  listb.append(numb*4)
listb.reverse()
count=0
combined1 = [x*y for (x, y) in (lista, listb)]
for num in combined1:
  if num==b:
    count+=1
if count>0:
  print("Yes")
else: 
  print("No")

### FIXED CODE ###

a,b=(int(x) for x in input().split())
lista=[]
listb=[]
for numa in range(a+1):
  lista.append(numa*2)
for numb in range(a+1):
  listb.append(numb*4)
listb.reverse()
count=0
combined1 = [x+y for (x, y) in zip(lista, listb)]
for num in combined1:
  if num==b:
    count+=1
if count>0:
  print("Yes")
else: 
  print("No")
def solve(string):
    a, b = map(int, string.split())
    if b == 0:
        return "0"
    bin_a = "{:040b}".format(a)
    bin_b = "{:040b}".format(b)
    aa = [-1 if _a == "0" else int(bin_a[i + 1:] or "0", 2) for i, _a in enumerate(bin_a)]
    bb = [-1 if _b == "0" else int(bin_b[i + 1:] or "0", 2) for i, _b in enumerate(bin_b)]
    index = 0
    while True:
        if bb[index] != -1:
            break
        index += 1
    ans = []
    for i in range(index, 40):
        tmp = 0
        tmp += (bb[i] + 1) % 2 if bb[i] >= 0 else 0
        tmp += aa[i] % 2 if aa[i] > 0 else 0
        ans.append(str(tmp % 2))
    ans[-1] = (b - a) // 2 % 2
    ans[-1] = str(ans[-1]) if a % 2 == b % 2 == 0 else str(ans[-1] + 1)
    return str(int("".join(ans), 2))


if __name__ == '__main__':
    print(solve(input()))


### FIXED CODE ###

def solve(string):
    a, b = map(int, string.split())
    if b == 0:
        return "0"
    bin_a = "{:040b}".format(a)
    bin_b = "{:040b}".format(b)
    aa = [-1 if _a == "0" else int(bin_a[i + 1:] or "0", 2) for i, _a in enumerate(bin_a)]
    bb = [-1 if _b == "0" else int(bin_b[i + 1:] or "0", 2) for i, _b in enumerate(bin_b)]
    index = 0
    while True:
        if bb[index] != -1:
            break
        index += 1
    ans = []
    while index < 40:
        if aa[index] == bb[index] == -1:
            ans.append("0")
        elif aa[index] == -1:
            ans.append(str((bb[index] + 1) % 2))
        elif bb[index] == -1:
            ans.append(str(aa[index] % 2))
        else:
            ans.append(str((bb[index] + 1 - aa[index]) % 2))
        index += 1
    ans[-1] = str((b - a) // 2 % 2) if a % 2 == b % 2 == 0 else str(((b - a) // 2 + 1) % 2)
    return str(int("".join(ans), 2))


if __name__ == '__main__':
    print(solve(input()))
S = int(input())
in = divmod(S,3600)
h = in[0] 
in = divmod(int[1],60)
m = int[0]
s = int[1]

### FIXED CODE ###

S = int(input())
h, mod = divmod(S,3600)
m, mod = divmod(mod,60)
s = mod
print(h,m,s, sep=":")
from re import sub
LIST = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
K = int(input())
return sub(r"[,\s]", "", LIST)[K+1]

### FIXED CODE ###

from re import sub
LIST = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
K = int(input())
print(sub(r"[\s]", "", LIST).split(",")[K-1])
cnt = 10
top3 = [0,0,0]

for x in xrange(cnt):
    n = int( raw_input() )

    if top3[2] > n: continue
    top3[2] = n

    if top3[1] > top3[2]: continue
    top3[1], top3[2] = top3[2], top3[1]

    if top3[0] > top3[1]: continue
    top3[0], top3[1] = top3[1], top3[0]

print top[0], top[1], top[2]



### FIXED CODE ###


cnt = 10
top3 = [0,0,0]

for x in xrange(cnt):
    n = int( raw_input() )

    if top3[2] > n: continue
    top3[2] = n

    if top3[1] > top3[2]: continue
    top3[1], top3[2] = top3[2], top3[1]

    if top3[0] > top3[1]: continue
    top3[0], top3[1] = top3[1], top3[0]

print top3[0]
print top3[1]
print top3[2]
def wa(h, w, f):
    if not (0 <= h <= H-1 and 0 <= w <= W-1):
        return
    elif mapp[h][w] != f:
        return
    else:
        mapp[h][w] = '$'
        wa(h, w+1, f)
        wa(h-1, w, f)
        wa(h, w-1, f)
        wa(h+1, w, f)
        
while True:
    H, W = map(int, raw_input().split(' '))
    if H == 0 and W == 0: break
    line = raw_input()
    mapp = [list(line[i*W:i*W+W]) for i in range(H)]
    count = 0
    for h in range(H):
        for w in range(W):
            if mapp[h][w] == '@':
                wa(h, w, '@')
            elif mapp[h][w] == '#':
                wa(h, w, '#')
            elif mapp[h][w] == '*':
                wa(h, w, '*')
            else:
                continue
            count += 1
    else:
        print count

### FIXED CODE ###

import sys
sys.setrecursionlimit(20000)
def wa(h, w, f):
    if not (0 <= h < H and 0 <= w < W):
        return
    elif mapp[h][w] != f:
        return
    else:
        mapp[h][w] = '$'
        wa(h, w+1, f)
        wa(h-1, w, f)
        wa(h, w-1, f)
        wa(h+1, w, f)

while True:
    H, W = map(int, raw_input().split())
    if H == 0 and W == 0: break
    mapp = [list(raw_input()) for i in range(H)]
    count = 0
    for h in range(H):
        for w in range(W):
            if mapp[h][w] == '@':
                count += 1
                wa(h, w, '@')
            elif mapp[h][w] == '#':
                count += 1
                wa(h, w, '#')
            elif mapp[h][w] == '*':
                count += 1
                wa(h, w, '*')
    else:
        print count
n=int(input())
h=list(map(int,input(),split()))
a=0
max=0
for i in range(1,n):
    if h[i]<=h[i-1]:
        a+=1
    else :
        max=a
        a=0
print(max)


### FIXED CODE ###

n=int(input())
h=list(map(int,input().split()))
a=0
max=0
for i in range(1,n):
    if h[i]<=h[i-1]:
        a+=1
        if i==n-1 and a>max:
            max=a
    elif a>max:
        max=a
        a=0
    else:
        a=0
print(max)
a, b = map(int, input().split())
m,n=max(a,b),min(m,n)
while m%n!=0:
    m%=n
    m,n=max(m,n),min(m,n)
print(int(a*b/n))

### FIXED CODE ###

a, b = map(int, input().split())
m,n=max(a,b),min(a,b)
if m%n==0:
    print(m)
else:
    while m%n!=0 and n!=1:
        m%=n
        m,n=max(m,n),min(m,n)
    print(int(a*b/n))
def comb_mod(n,r):
    mod = 10**9+7
    ans = 1
    for i in range(r):
        ans *= n-i
        ans %= mod
    for i in range(1,r+1):
        ans *= pow(i,-1,mod)
        ans %= mod
    return ans

def solve():
    n, a, b = map(int, input().split())
    mod = 10**9+7
    ans = pow(2,n,mod)-comb_mod(n,a)-comb_mod(n,b)-1
    ans %= mod
    return ans
print(solve())


### FIXED CODE ###

import math
n,a,b = [int(i) for i in input().split()]
mod = 10**9+7
  
def comb(n,k):
  ans = 1
  for i in range(k):
    ans = ans*(n-i)%mod
  for i in range(1,k+1):
    ans = ans*pow(i,mod-2,mod)%mod
  return ans

print((pow(2,n,mod)-1-comb(n,a)-comb(n,b))%mod)
# print(comb(n,a))
a,b,c=map(int,input()split())
sum=a+b+c

if sum >=22:
  print("bust")
else:
  print("win")

### FIXED CODE ###

a,b,c=map(int,input().split())
sum=a+b+c
 
if sum >=22:
  print("bust")
else:
  print("win")
n, k = map(int, input().split())
p = list(map(int, input().split()))
l = [0] * n
ans = []
l[0] = (p[0] + 1) / 2
for i in range(1, n):
    l[i] = l[i - 1] + (p[i] + 1) / 2
print(l)
for i in range(n - k):
    ans.append(l[i + k] - l[i])
print(max(ans))

### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
l = [0] * (n + 1)
ans = []
for i in range(n):
    l[i + 1] = l[i] + (p[i] + 1) / 2
for i in range(n - k + 1):
    ans.append(l[i + k] - l[i])
print(max(ans))
n=int(input())
c=10**9
for i in range(1,n**0.5):
    if n%i==0:
        j=n/i
        if i+j < c:
            c=int(i+j)

print(c-2)

### FIXED CODE ###

n=int(input())
c=10**13
for i in range(1,int(n**0.5)+1):
    if n%i==0:
        j=int(n/i)
        if i+j < c:
            c=int(i+j)

print(c-2)