Harryxun/stf_run huggingface dataset:
import sys
input=sys.stdin.readline
import copy
def knapsack(N,W,weight,value):
  dp=[[999999999999 for i in range(W+1)] for j in range(N+1)]
  dp2=[[() for i in range(W+1)] for j in range(N+1)]
  for i in range(W+1): dp[0][i]=0

  for i in range(N):
    for w in range(W+1):
      if weight[i]<=w:
        if dp[i][w-weight[i]]+value[i]>dp[i][w]:
          dp[i+1][w]=dp[i][w-weight[i]]+value[i]
          x=copy.copy(dp2[i][w-weight[i]])
          x.append(i)
          dp2[i+1][w]=x
        else:
          dp[i+1][w]=dp[i][w]
          dp2[i+1][w]=dp2[i][w]
        
      else:
        dp[i+1][w]=dp[i][w]
        dp2[i+1][w]=dp2[i][w]
  return [dp[N][W],dp2[N][W]]

n,t=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
a=[];b=[]
for i in range(n):
  a.append(l[i][0])
  b.append(l[i][1])
z=knapsack(n,t-1,a,b)
x=z[0];y=z[1]
L=[0 for i in range(n)]
m=0
for i in range(len(y)):
  L[y[i]]=1
M=[]
for i in range(n):
  if L[i]==0:
    M.append(b[i])
if len(M)==0:
  print(x)
else:
  print(x+max(M))

### FIXED CODE ###

import sys
input=sys.stdin.readline
import copy
def knapsack(N,W,weight,value):
  dp=[[999999999999 for i in range(W+1)] for j in range(N+1)]
  for i in range(W+1): dp[0][i]=0
 
  for i in range(N):
    for w in range(W+1):
      if weight[i]<=w:
        if dp[i][w-weight[i]]+value[i]>dp[i][w]:
          dp[i+1][w]=dp[i][w-weight[i]]+value[i]
        else:
          dp[i+1][w]=dp[i][w]
      else:
        dp[i+1][w]=dp[i][w]
  return dp
 
n,t=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
l.sort()
a=[];b=[]
for i in range(n):
  a.append(l[i][0])
  b.append(l[i][1])
dp=knapsack(n,t-1,a,b)
ans=[]
for i in range(n):
  if i!=n:
    ans.append(dp[i][t-1]+b[i])
  else:
    ans.append(dp[n][t-i])
print(max(ans))
N, K = map(int, input().split())
x = list(map(int, input().split()))
ans = 10**9

for i in range(N-K+1):
    ans1 = abs(x[i])+abs(x[i]-x[i+N-K])
    ans2 = abs(x[i+N-K])+abs(x[i]-x[i+N-K])
    ans = min(ans, ans1, ans2)
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
x = list(map(int, input().split()))
ans = 3*10**8

for i in range(N-K+1):
    ans1 = abs(x[i])+abs(x[i]-x[i+K-1])
    ans2 = abs(x[i+K-1])+abs(x[i]-x[i+K-1])
    ans = min(ans, ans1, ans2)
print(ans)
import.math
A, B = map(int, input().split())
ans = math.floor(A*B)
print(ans)

### FIXED CODE ###

def resolve():
    A, B = input().split()
    ans = int(A)*int(B[0])*100+int(A)*int(B[2:])
    print(str(ans)[:-2] if len(str(ans)) >= 3 else "0")
resolve()
N,M=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
dict={1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}
dp=[0]*(N+1)
for j in l:
   nu,val=j,dict[j]
   dp[val]=max(dp[val],int(nu))
for i in range(N):
   if dp[i]!=0:
      for j in l:
         nu,val=j,dict[j]
         if i+val<=N:
            dp[i+val]=max(dp[i+val],int(str(dp[i])+str(nu)))
print(dp[N])

### FIXED CODE ###

N,M=map(int,input().split())
l=list(map(int,input().split()))
w=[2,5,5,4,5,6,3,7,6]
l.sort()
dp=[0]*(max(N+1,8))
for j in l:
   dp[w[j-1]]=j
for i in range(N):
   if dp[i]!=0:
      for j in l:
         if w[j-1]+i<=N:
            dp[i+w[j-1]]=max(dp[i+w[j-1]],dp[i]*10+j)
print(dp[N])
n=int(input())
a=int(input())
b=int(input())
if n == 1:
    print("Hello World")
else:
    print(a+b)

### FIXED CODE ###

n=int(input())
if n == 1:
    print("Hello World")
else:
    a=int(input())
    b=int(input())
    print(a+b)
import sys
n = int(input())
lst = list(map(int, input().split()))
res = 0
for p in range(200):
  for i in range(n):
    if lst[i] % 2 == 1:
      print(res)
      sys.exit()
  lst = [int(j / 2) for j in lst]
  res += 1

### FIXED CODE ###

lst = [int(i) for i in str(input())]
print(sum(lst))
a = lsit(map(int,input().split()))

print(a[0]*a[1])

### FIXED CODE ###

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

print(a[0]*a[1])
import math
import numpy as np
N,M=map(int,input().split())
A=list(map(int,input().split()))
c=0
test=A[0]
l=0

while test%2 == 0:
  test=int(test/2+0.5)
  c+=1
d=2**c
 
for i in np.arange(N-1):
  if A[i+1]%d!=0:
    print(0)
    l=1
    break
  elif A[i+1]%(d*2)==0:
    print(0)
    l=1
    break
  else:
    k=int(A[i+1]/d+0.5)
    test=int(test*k/math.gcd(test,k)+0.5)
if l==0:
  k=int(test*d/2+0.5)
  print(M//k//2 + M//k%2)

### FIXED CODE ###

import math
import numpy as np
N,M=map(int,input().split())
A=list(map(int,input().split()))
c=1
test=A[0]
l=0

while test%2 == 0:
  test=test//2
  c*=2

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
  
for i in np.arange(N-1):
  if A[i+1]%c!=0:
    print(0)
    l=1
    break
  elif A[i+1]%(c*2)==0:
    print(0)
    l=1
    break
  else:
    k=A[i+1]//c
    test=lcm_base(test, k)
if l==0:
  k=test*c//2
  print(M//k//2 + M//k%2)
N, Y = map(int, input().split())
# Nマイ，Y縁
s, g, i

for s in N+1:
  for g in (N-s):
    i = N - s - g
    if 1000*s + 5000*g + i*10000 == Y:
      print(s, g, i, sep=" ")
      exit()
print(-1, -1, -1, sep=" ")


### FIXED CODE ###

N, Y = map(int, input().split())
 
for s in range(N+1):
  for g in range(N-s+1):
    i = N - s - g
    if 1000*s + 5000*g + i*10000 == Y:
      print(i, g, s, sep=" ")
      exit()
print(-1, -1, -1, sep=" ")
N = int(input())
A = input().split(' ')

for i in range(N):
    A[i] = int(A[i])

A.sort()
A.reverse()

max = A[0]
min = A[-1]

flag = 0
for term in A:

    count = 0

    for i in range(N):
        if(A[i] % term != 0):
            count += 1
        if(count == 2):
            break

    if(count <= 1):
        flag = 1
        break

if(flag == 1):
    print(term)

for term in reversed(range(0, A[-1])):

    count = 0

    for i in range(N):
        if(A[i] % term !=0):
            count += 1
        if(count == 2):
            break

    if(count <= 1):
        break

print(term)

### FIXED CODE ###

def gcd(a, b):
    if(a == 0):
        return b
    if(b == 0):
        return a

    if(a < b):
        a, b = b, a
    r = a % b
    while(r != 0):
        a, b = b, r
        r = a % b
    return b

def L(end_i, A):
    if(end_i == 0):
        return 0
    
    a = 0
    for i in range(end_i):
        a = gcd(a, A[i])
    return a


def R(start_i, A, N):
    if(start_i == N - 1):
        return 0

    a = 0
    for i in range(start_i + 1, N):
        a = gcd(a, A[i])
    return a


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

left = [0] * N
right = [0] * N

for i in range(1, N):
    left[i] = gcd(left[i - 1], A[i - 1])
#print(left)

for i in reversed(range(0, N - 1)):
    right[i] = gcd(A[i + 1], right[i + 1])
#print(right)

M = []
for i in range(N):
    M.append(gcd(left[i], right[i]))
#print(M)

print(max(M))
A,B = map(input().split())
print(A + B) if B % A == 0 else print(B - A)

### FIXED CODE ###

A,B = map(int, input().split())
print(A + B) if B % A == 0 else print(B - A)
a1 = int(input())
a2 = int(input())
a3 = int(input())
 
A = a1 + a2 + a3
 
if A >= 22:
  print('bust')
 else:
    print('win')

### FIXED CODE ###

a1, a2, a3 = map(int, input().split())
 
if a1 + a2 + a3 >= 22:
  print('bust')
else:
  print('win')
N, Q = map(int, input().split())
A = [[] for _ in range(N)]
for _ in range(N-1):
    i, k = map(int, input().split())
    A[i-1].append(k-1)
P = [0] * N
for _ in range(Q):
    k, n = map(int, input().split())
    P[k-1] += n
ans = [0] * N
n_P = [100, 10, 1,0]
visited = []
def make(num, A, p):
    for i in A[num]:
        visited.append(i)
        n_P[i] += p
        make(i, A, n_P[i])
    return
for i in range(N):
    if i not in visited:
        make(0, A, n_P[0])
print(*n_P)

### FIXED CODE ###

import sys
sys.setrecursionlimit(2*10**9)
N, Q = map(int, input().split())
A = [[] for _ in range(N)]
for _ in range(N-1):
    i, k = map(int, input().split())
    A[i-1].append(k-1)
    A[k-1].append(i-1)
n_P = [0] * N
for _ in range(Q):
    k, n = map(int, input().split())
    n_P[k-1] += n
ans = [0] * N
visited = [0] * N
def make(num, p):
    ans[num] += n_P[num] 
    ans[num] += p
    visited[num] = 1
    for i in A[num]:
        if visited[i] == 0:
            make(i,ans[num])
    return
make(0, ans[0])
print(*ans)
from collections import defaultdict
def log2(n):
  if n < 2:
    return 0
  else:
    return 1 + log2(n // 2)

n = int(input())
a_list = list(map(int, input().split()))
d = defaultdict(int)
a_list.sort()

for a in a_list:
  d[a] += 1

a_list = list(set(a_list))
c = 0
for a in a_list:
  m = log2(a, 2)
  x = 2 ** (m+1) - a
  if x == a:
    c += d[a] // 2
    d[a] -= d[a] // 2
  else:
    c += min(d[x], d[a])
    d[x] -= min(d[x], d[a])

print(c)
    

### FIXED CODE ###

from collections import defaultdict
import math

n = int(input())
a_list = list(map(int, input().split()))
d = defaultdict(int)

for a in a_list:
  d[a] += 1

a_list = reversed(sorted(list(set(a_list))))
c = 0
for a in a_list:
  m = int(math.log(a, 2))
  x = 2 ** (m+1) - a
  if x == a:
    c += d[a] // 2
    d[a] -= d[a] // 2
  else:
    c += min(d[x], d[a])
    d[x] -= min(d[x], d[a])

print(c)
n, m = map(int, input().split())
left, right = 1, n
for _ in range(m):
  l, r = map(int, input().split())
  if l > left:
    left = l
  if r < right:
    right = r
  if l > r:
    print(0)
    quit()
if right > n:
  
print(right - left + 1)

### FIXED CODE ###

n, m = map(int, input().split())
left, right = 1, n
for _ in range(m):
  l, r = map(int, input().split())
  if l > left:
    left = l
  if r < right:
    right = r
  if left > right:
    print(0)
    quit()
print(right - left + 1)
import math
r = int(input())
print(r**2*math.pi, r*2*math.pi)


### FIXED CODE ###

import math
r = float(input())
print('{} {}'.format(r**2*math.pi, r*2*math.pi))
n, q = list(map(int, input().split()))
s = input()
tmp = "g"
acc = []
for c in s:
  if tmp = "A":
    if c == "C":
      acc.append(acc[-1] + 1)
      tmp = "G"
    elif c == "A":
      tmp = "A"
    else;
		tmp = "G"
  else:
    if c == "A":
      tmp = "A"
      
for i in range(q):
  l,r = list(map(int, input().split()))
  print(acc[r-1] - acc[l-1])
    

### FIXED CODE ###

def getN():
    return int(input())


def getNM():
    return map(int, input().split())


def getList():
    return list(map(int, input().split()))


from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left, bisect_right
from heapq import *
import sys

# sys.setrecursionlimit(1000000)
INF = 10 ** 17
MOD = 1000000007

from fractions import *


def inverse(f):
    # return Fraction(f.denominator,f.numerator)
    return 1 / f


def combmod(n, k, mod=MOD):
    ret = 1
    for i in range(n - k + 1, n + 1):
        ret *= i
        ret %= mod

    for i in range(1, k + 1):
        ret *= pow(i, mod - 2, mod)
        ret %= mod

    return ret

MOD = 998244353
def solve():
    n, q = getList()
    s = input().strip()
    acc = [0]
    tmp = 0
    pred = ""
    for c in s:
        if pred == "A" and c == "C":
            tmp += 1
        acc.append(tmp)
        pred = c

    for i in range(q):
        l, r = getList()
        print(acc[r] - acc[l])

def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    solve()
mod = 10 ** 9 + 7
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
ans = 0
for i in range(N):
    now_A = A[i]
    tmp = 1
    count = 1
    for k in range(i+K-1, N):
        ans += (A[k] - now_A) * tmp
        ans %= mod
        tmp *= (K - 2 + count) / count
        tmp = int(tmp)
        count += 1
        ##print(ans, tmp, count)

print(ans)

### FIXED CODE ###

# 組み合わせ(高速，フェルマーの小定理を利用)
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
N = 10 ** 5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

mod = 10 ** 9 + 7
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
ans_max = 0
ans_min = 0
# ans_minを求める
for i in range(N-K+1):
    ans_min += A[i] * cmb(N-1-i, K-1, mod)
    ans_min %= mod
for i in range(K-1, N):
    ans_max += A[i] * cmb(i, K-1, mod)
    ans_max %= mod
##print(ans_max, ans_min)
print((ans_max - ans_min + mod)%mod)
S=input()
new=S.split('2017')
print('2018'+new)

### FIXED CODE ###

s=input()
s=s[:3]+"8"+s[4:]
print(s)
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    s = str(input().rstrip('\n'))
    t = s
    while True:
        l_len = len(s)
        while True
            s = s.replace("()", "")
            if len(s) == l_len:
                break
            else:
                l_len = len(s)
        if len(s) == 0:
            print(t)
            exit()
        else:
            if s[0] == ")":
                s = "".join((list("(") + list(s)))
                t = "".join((list("(") + list(t)))
            else:
                s = "".join((list(s)) + list(")"))
                t = "".join((list(t)) + list(")"))


if __name__ == '__main__':
    slove()


### FIXED CODE ###

def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    s = str(input().rstrip('\n'))
    t = s
    while True:
        l_len = len(s)
        while True:
            s = s.replace("()", "")
            if len(s) == l_len:
                break
            else:
                l_len = len(s)
        if len(s) == 0:
            print(t)
            exit()
        else:
            if s[0] == ")":
                s = "".join((list("(") + list(s)))
                t = "".join((list("(") + list(t)))
            else:
                s = "".join((list(s)) + list(")"))
                t = "".join((list(t)) + list(")"))


if __name__ == '__main__':
    slove()
# Official House

n = int(input())
houses = 4
floors = 3
rooms = 10

official = [[[0 for k in range(rooms)] for j in range(floors)] for i in range(houses)]
print(official)

for a in range(n):
    info = [int(x) for x in input().rstrip().split()]
    b = info[0] - 1
    f = info[1] - 1
    r = info[2] - 1
    v = info[3]
    currentFloor = official[b][f]
    print(currentFloor)
    currentFloor[r] += v

print(official)

for i in range(houses):
    for j in range(floors):
        for k in range(rooms):
            print(' ' + official[i][j][k], end = '')
    if i < houses - 1:
        print('#' * 20)



### FIXED CODE ###

# Official House

n = int(input())
houses = 4
floors = 3
rooms = 10

official = [[[0 for k in range(rooms)] for j in range(floors)] for i in range(houses)]
# print(official)

for a in range(n):
    info = [int(x) for x in input().rstrip().split()]
    b = info[0] - 1
    f = info[1] - 1
    r = info[2] - 1
    v = info[3]
    currentFloor = official[b][f]
    # print(currentFloor)
    currentFloor[r] += v

# print(official)

for i in range(houses):
    for j in range(floors):
        for k in range(rooms):
            print(' ' + str(official[i][j][k]), end = '')
        print()
    if i < houses - 1:
        print('#' * 20)
import sys
from io import StringIO
import unittest

a = input().rstrip().split(" ")

H = int(a[0])  # 行
W = int(a[1])  # 列
K = int(a[2])  # 操作後に残る黒いマスの数

m = []
for i in range(H):
    n = list(input())
    m.append(n)

# print(m)
ans = 0

for maskR in range(1 << H):
    for maskC in range(1 << W):
        black = 0
        for i in range(H):
            for j in range(W):
                if (maskR >> i & 1) == 0 and (maskL >> j & 1) == 0 and m[i][j] == '#':
                    black += 1
        if black == k:
            ans += 1
print(ans)


### FIXED CODE ###

a = input().rstrip().split(" ")
 
H = int(a[0])   #行
W = int(a[1])   #列
K = int(a[2])   #操作後に残る黒いマスの数
 
m = []
for i in range(H):
    n = list(input())
    m.append(n)
 
#print(m)
ans = 0
 
#2進数のyes/no(赤く塗るか否か)列を作る
for maskR in range(1 << H):
    for maskC in range(1 << W):
        black = 0
        
        for i in range(H):
            for j in range(W):
                if (maskR >> i & 1) == 0 and (maskC >> j & 1) == 0 and m[i][j] == "#":
                    black += 1
    
        if black == K:
            ans += 1
 
print(ans)
n=str(input())
f=0
for i in range(len(l)):
  f+=n[i]
if int(n)%f==0:
  print('Yes')
else:
  print('No')
  

### FIXED CODE ###

n=int(input())
f=sum(list(map(int,str(n))))
if n%f==0:
  print('Yes')
else:
  print('No')
import math

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


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

lcm_cd = lcm(c,d)

min_a_c = (a-1)//c
min_a_d = (a-1)//d
min_a_lcm = (a-1)//lcm_cd
max_b_c = b//c
max_b_d = b//d
max_b_lcm = b//lcm_cd

ans=(b-a+1)-((max_b_c-min_a_c)+(max_b_d-min_a_d)-(max_b_lcm-min_a_lcm))


print(ans)


### FIXED CODE ###

import fractions

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


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

lcm_cd = lcm(c,d)

min_a_c = (a-1)//c
min_a_d = (a-1)//d
min_a_lcm = (a-1)//lcm_cd
max_b_c = b//c
max_b_d = b//d
max_b_lcm = b//lcm_cd

ans=(b-a+1)-((max_b_c-min_a_c)+(max_b_d-min_a_d)-(max_b_lcm-min_a_lcm))


print(ans)
import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
from fractions  import gcd

#input=sys.stdin.readline
h,w=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(h)]
d=[]
for i in range(h):
    for j in range(w):
        if a[i][j]%2==1:
             d.append((i,j))
n=len(d)
d_s=set(d)
i=0
ans=[]
f=False
y=d[i][0]
x=d[i][1]
xp=x+1
yp=y
while i<n:
    if y%2==0:
      xp=x+1
    else:
      xp=x-1
   
    yp=y
    if (y,x) in d_s:
      while True:
          if (yp,xp) not in d_s and -1<xp<w and yp<h:
              if y%2==0:
                  ans.append([y+1,x+1,yp+1,xp+1])
                  x=xp
                  xp+=1
              else:
                  ans.append([y+1,x+1,yp+1,xp+1])
                  x=xp
                  xp-=1
          elif (yp,xp) not in d_s and xp>w-1:
              xp=w-1
              yp+=1
          elif (yp,xp) not in d_s and xp<0:
              xp=0
              yp+=1
          elif (yp,xp) in d_s:
              ans.append([y+1,x+1,yp+1,xp+1])
              if yp%2==0:
                x=xp+1
                y=yp
              else:
                x=xp-1
                y=yp
              break
          elif yp>h-1:
            f=True
            break
      if f:
        break
    else:
      if y%2==0:
        x+=1
      else:
        x-=1
      if x>w-1:
        x=w-1
        y+=1
      elif x<0:
        x=0
        y+=1
    if y>h-1:
      break
print(len(ans))
for i in ans:
  print(*i)

### FIXED CODE ###

import sys

#input=sys.stdin.readline
h,w=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(h)]
d=[]
for i in range(h):
    for j in range(w):
        if a[i][j]%2==1:
             d.append((i,j))
n=len(d)
if n==0:
  print(0)
  exit()
d_s=set(d)
ans=[]
f=False
y=d[0][0]
x=d[0][1]
xp=x+1
yp=y
while True:
    if y%2==0:
      xp=x+1
    else:
      xp=x-1
    yp=y
    if (y,x) in d_s:
      while True:
          if (yp,xp) not in d_s and -1<xp<w and yp<h:
              if yp%2==0:
                  ans.append([y+1,x+1,yp+1,xp+1])
                  x=xp
                  xp+=1
              else:
                  ans.append([y+1,x+1,yp+1,xp+1])
                  x=xp
                  xp-=1
              y=yp
          elif (yp,xp) not in d_s and xp>w-1:
              xp=w-1
              yp+=1
          elif (yp,xp) not in d_s and xp<0:
              xp=0
              yp+=1
          elif (yp,xp) in d_s:
              ans.append([y+1,x+1,yp+1,xp+1])
              if yp%2==0:
                x=xp+1
                y=yp
              else:
                x=xp-1
                y=yp
              break
          elif yp>h-1:
            f=True
            break
      if f:
        break
    else:
      if y%2==0:
        x+=1
      else:
        x-=1
      if x>w-1:
        x=w-1
        y+=1
      elif x<0:
        x=0
        y+=1
    if y>h-1:
      break
print(len(ans))
for i in ans:
  print(*i)
def main():
    N, M = map(int, input().split())
    connect_list = [0] * N

    for i in range(M):
        A, B = map(int, input().split())
        
        A_road_num = connect_list[A]
        B_road_num = connect_list[B]

        if A_road_num == 0 and B_road_num == 0:
            max_road_num = max(connect_list)
            connect_list[A] = max_road_num
            connect_list[B] = max_road_num
        elif A_road_num != 0 and B_road_num == 0:
            connect_list[B] = connect_list[A]
        elif A_road_num == 0 and B_road_num != 0:
            connect_list[A] = connect_list[B]
        else:
            connect_list = [A_road_num if B_road_num == road_num else road_num for road_num in connect_list]

    answer = 0
    set_connect_list = set([i for i in connect_list if i > 0])
    if len(set_connect_list) != 1:
        answer = len(set_connect_list) - 1

    print(answer + connect_list.count(0))

if __name__ == "__main__":
    main()

### FIXED CODE ###

def root(list_parent, x):
    if(list_parent[x] == x):
        return x
    else:
        list_parent[x] = root(list_parent, list_parent[x])
        return list_parent[x]

def unite(list_parent, x, y):
    x = root(list_parent, x)
    y = root(list_parent, y)

    if(x == y):
        return list_parent

    if x > y:
        list_parent[y] = x
    else:
        list_parent[x] = y

    return list_parent

def main():
    N, M = map(int, input().split())

    list_parent = []
    for i in range(N):
        list_parent.append(i)

    for i in range(M):
        A, B = map(int, input().split())
        list_parent = unite(list_parent, A-1, B-1)

    set_root = set()
    for i in list_parent:
        root_i = root(list_parent, i)
        if root_i not in set_root:
            set_root.add(root_i)

    print(len(set_root) - 1)

if __name__ == "__main__":
    main()
H,W=map(int, input().split())
field=[[0]*(W+1) for i in range(H+1)]
List=[list(input()) for i in range(H)]

for k in range(1,H):
    for j in range(1,W):
        field[k][j] = List[k-1][j-1]

#print(field)

flag=1

for k in range(1,W):
    for j in range(1,H):
        if field[k][j]=='#' and field[k-1][j]!='#' and field[k+1][j]!='#' and field[k][j-1]!='#' and field[k][j+1]!='#':
            flag=0

if flag==1:     
    print('Yes')
else:
    print('No')

### FIXED CODE ###

H,W=map(int,input().split())
S=["."+input()+"." for i in range(H)]
field=["."*(W+2)]+S+["."*(W+2)]

flag=0

for k in range(1,H+1):
    for j in range(1,W+1):
        if field[k][j]=='#' and field[k-1][j]!='#' and field[k+1][j]!='#' and field[k][j-1]!='#' and field[k][j+1]!='#':
            flag=1

if flag==1:
    print('No')
else:     
    print('Yes')
a,b = map(int, input().split())
x = a*b
y = 2a + 2b

### FIXED CODE ###

a,b = map(int, input().split())
x = a*b
y = 2*a + 2*b
print(x ,y)