Harryxun/stf_run huggingface dataset:
def main():
	n, m = map(int, input().split())
    a = set(int(input()) for i in range(m))
    mod = 1000000007
 
    # フィボナッチ数列を作る要領で行う
    d = [0] * (n+1)
    # 2回0が続く状況aに連番があったら即座に終了する
    cnt = 0 
    # d[0]とd[1]を規定。aに1が含まれていることを考慮して場合分けしておく
    d[0] = 1
    if 1 not in a:
        d[1] = 1
    # else:
    #     d[1] = 1
    # 階段番号は2~nまでを見る必要がある
    for i in range(2, n+1):
        if i in a:
            d[i] = 0
            cnt += 1
            if cnt == 2:
                print('0')
                exit()
        else:
            d[i] = (d[i-1] + d[i-2]) % mod
            cnt = 0
    # print(d)  
    ans = d[n]        
    print(ans)
 
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

def main():
    # n, m = map(int, input().split())
    # a = [int(input()) for i in range(m)]
    n, m = map(int, readline().split())
    a = set(map(int, read().split()))
    mod = 1000000007

    # フィボナッチ数列を作る要領で行う
    d = [0] * (n+1)
    # 2回0が続く状況aに連番があったら即座に終了する
    cnt = 0 
    # d[0]とd[1]を規定。aに1が含まれていることを考慮して場合分けしておく
    d[0] = 1
    if 1 not in a:
        d[1] = 1
    # else:
    #     d[1] = 1
    # 階段番号は2~nまでを見る必要がある
    for i in range(2, n+1):
        if i in a:
            d[i] = 0
            cnt += 1
            if cnt == 2:
                print('0')
                exit()
        else:
            d[i] = (d[i-1] + d[i-2]) % mod
            cnt = 0
    # print(d)  
    ans = d[n]        
    print(ans)

if __name__ == '__main__':
    main()
N,K = map(int,input().split())
cnt = [0]*(N-K+2)

cnt_all = 0
mod = 1000000007

for i in range(K,N+2):
    cnt[i] = (i+1)*N - i^2

for i in range(N-K+2):
    cnt_all += cnt[i]

print(cnt_all % mod)

### FIXED CODE ###

N,K = map(int,input().split())
cnt = [0]*(N-K+2)

cnt_all = 0
mod = 1000000007

for i in range(K,N+2):
    cnt[i-K] = i*N - i*(i-1) + 1

for i in range(N-K+2):
    cnt_all += cnt[i]

print(cnt_all % mod)
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]
dpx = 10**4+1
for i in range(1,K+1):
  for j in range(0,i):
      dpx = min(dpx, abs(h[i]-h[j]))
  dp.append(dpx)
print(dp[-1])

### FIXED CODE ###

def main():
    N,K = map(int,input().split())
    h = list(map(int,input().split()))
    dp = [0]*N
    for i in range(1,N):
        dp[i]= min(abs(h[i]-h[j])+dp[j] for j in range(max(0,i-K),i))
    print(dp[-1])
main()
n = int(input())
a = list(map(int, input().split()))
#
# a.sort()
# ans = a[0]
# for i in range(1, n - 1):
#     ans += a[i] * (-1)
#
# print(a[-1] - ans)
# key = a[0]
# for i in range(1, n - 1):
#     print(key, a[i])
#     key = key - a[i]
# print(a[-1], key)

a.sort()
plusa = []
minusa = []
for i in a[1:-1]:
    if i < 0:
        minusa.append(i)
    else:
        plusa.append(i)
#
# print(minusa, plusa)
anslist = []
if len(plusa) == 0:
    plusa.append(minusa[-1])
    del minusa[-1]

for i in minusa:
    # print(plusa[0], i)
    anslist.append([plusa[0], i])
    plusa[0] -= i

for i in plusa:
    # print(a[0], i)
    anslist.append([a[0], i])
    a[0] -= i
# print(a[0])
print(a[-1] - a[0])
for i, j in anslist:
    print(i, j)
# print(anslist)
print(a[-1], a[0])

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort()
anslist = []
for i in range(1, n - 1):
    if a[i] >= 0:
        anslist.append([a[0], a[i]])
        a[0] -= a[i]
    else:
        anslist.append([a[-1], a[i]])
        a[-1] -= a[i]

anslist.append([a[-1], a[0]])
ans = a[-1] - a[0]
print(ans)
for i, j in anslist:
    print(i, j)
#
# a.sort()
# ans = a[0]
# for i in range(1, n - 1):
#     ans += a[i] * (-1)
#
# print(a[-1] - ans)
# key = a[0]
# for i in range(1, n - 1):
#     print(key, a[i])
#     key = key - a[i]
# print(a[-1], key)

# a.sort()
# plusa = []
# minusa = []
# for i in a[1:-1]:
#     if i < 0:
#         minusa.append(i)
#     else:
#         plusa.append(i)
# #
# # print(minusa, plusa)
# anslist = []
# # if len(a) == 2:
# #     print(max(a) - min(a))
# #     print(max(a), min(a))
# # if min(a) >= 0:
# #     for i in range(1, n - 1):
# #         anslist.append([a[0], a[i]])
# #         a[0] -= a[i]
# #     anslist.append([a[-1], a[0]])
# #     print(a[-1] - a[0])
# #     for i, j in anslist:
# #         print(i, j)
# # else:
# #     if len(plusa) == 0:
# #         plusa.append(minusa[-1])
# #         del minusa[-1]
# #
# #     for i in minusa:
# #         # print(plusa[0], i)
# #         anslist.append([plusa[0], i])
# #         plusa[0] -= i
# #
# #     for i in plusa:
# #         # print(a[0], i)
# #         anslist.append([a[0], i])
# #         a[0] -= i
# #     # print(a[0])
# #     print(a[-1] - a[0])
# #     for i, j in anslist:
# #         print(i, j)
# #     # print(anslist)
# #     print(a[-1], a[0])
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math
n=int(input())
l = []
for i in range(0,n):
  l.append(int(input()))
  

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

res=l[0]
for i in range(1,n):
  res=lcm(res,l[i])
print(res)



### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n=int(input())
l = []
for i in range(0,n):
  l.append(int(input()))
  

def gcd(x, y):
  while y:
    x, y = y, x % y
  return x
def lcm(x, y):
  return (x * y) // gcd(x, y)

res=l[0]
for i in range(1,n):
  res=lcm(res,l[i])
print(res)
x = int(input())

b = 0
while (x + b**5)**0.2 != int((x + b**5)**0.2) and b < 60:
    b += 1

if (x + b**5)**0.2 != int((x + b**5)**0.2):
    b = -1
    while (x + b**5)**0.2 != int((x + b**5)**0.2) and b > -60:
        b -= 1

a = int((x + b**5)**0.2)
print(a, b)

### FIXED CODE ###

x = int(input())

for a in range(-200, 200):
    for b in range(-200, 200):
        if a**5 - b**5 == x:
            print(a, b)
            quit()
def twoSum(self, k, x) -> str:        
        if k * 500 >= x:
          return "Yes"
        else:
          return "No"


### FIXED CODE ###

a, b= map(int, input().split())
if a*500>=b:
    print("Yes")
else :
    print("No")
import sys

hs = list(map(int, sys.stdin.read().strip().splitlines()[1].split(" ")))
if len(hs) == 1:
  print("Yes")
  sys.exit(0)

def solver(pre, i):
  for v in (hs[i]-1, hs[i]):
    if v >= pre:
      if i == len(hs)-1:
        return True

      if solver(v, i+1):
        return True
  return False

if solver(hs[0], 1) or solver(hs[0]-1, 1):
  print("Yes")
else:
  print("No")


### FIXED CODE ###

import sys

hs = list(map(int, sys.stdin.read().strip().splitlines()[1].split(" ")))
if len(hs) == 1:
  print("Yes")
  sys.exit(0)
if hs[0] > hs[1]:
  hs[0] -= 1

for i in range(1, len(hs)):
  pre = hs[i-1]
  diff = hs[i] - pre
  if diff >= 1:
    hs[i] -= 1
  elif diff < 0:
    print("No")
    sys.exit(0)
print("Yes")
import bisect

N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=[list(map(int,input().split())) for i in range(M)]

A.sort()
BC.sort(key=lambda x: x[1],reverse=True) 
ans=0
for j in range(M):
    if A[0]>=BC[j][1]:
        break
    else:
        b=BC[j][0]
        c=BC[j][1]
        R=bisect.bisect_left(A,c)
        n=len(A)
        if R>=b:
            del A[0:b]
            ans+=b*c
        else:
            del A[0:R]
            ans+=R*c
print(sum(A)+ans)

### FIXED CODE ###

import bisect

N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=[list(map(int,input().split())) for i in range(M)]

A.sort()
BC.sort(key=lambda x: x[1],reverse=True) 
ans=0
for j in range(M):
    if A[0]>=BC[j][1]:
        break
    else:
        b=BC[j][0]
        c=BC[j][1]
        R=bisect.bisect_left(A,c)
        n=len(A)
        if R>b:
            if n<=b:
                A=[]
                ans+=n*c
                break
            else:
                del A[0:b]
                ans+=b*c
        else:
            del A[0:R]
            ans+=R*c
    if len(A)==0:
        break        
print(sum(A)+ans)
import sys

n = int(input())
dn = list(map(int, input().split()))
m = int(input())
tn = list(map(int, input().split()))

d_num = [0 for i in range(200001)]
t_num = [0 for i in range(200001)]

for i in range(len(dn)):
    d_num[dn[i]] += 1

for i in range(len(tn)):
    t_num[tn[i]] += 1
    
for i in range(len(t_num)):
    if d_num[i] < t_num[i]:
        print("NO")
        sys.exit()
print("yes")

### FIXED CODE ###

import sys

n = int(input())
dn = list(map(int, input().split()))
m = int(input())
tn = list(map(int, input().split()))

num_dict = {}

for i in range(n):
    if str(dn[i]) in num_dict.keys():
        num_dict[str(dn[i])] += 1
    else:
        num_dict[str(dn[i])] = 1

for i in range(m):
    if str(tn[i]) in num_dict.keys():
        num_dict[str(tn[i])] += -1
    else:
        print("NO")
        sys.exit()

result_list = list(num_dict.values())
for i in range(len(result_list)):
    if result_list[i] < 0:
        print("NO")
        sys.exit()
print("YES")
n = int(input())
i = 1
ret = ""
while True:
    x = i
    if  x % 3 == 0:
        ret += " " + str(i)
    elif x % 10 == 3:
        ret += " " + str(i)
    else:
        while x /= 10 > 0:
        if x % 10 == 3:
            ret += " " + str(i)
    i+=1
    if i > n:
        break

print(ret)



### FIXED CODE ###

#
# 5d
#

def main():
    n = int(input())
    s = ""
    for i in range(1, n+1):
        x = i
        if x % 3 == 0 or x % 10 == 3:
            s += " " + str(i)
        else:
            x //= 10
            while x:
                if x % 10 == 3:
                    s += " " + str(i)
                    break
                x //= 10
    print(s)


if __name__ == '__main__':
    main()
def main():
    import sys
    input = sys.stdin.readline
    
    R,C,N = map(int,input().split())
    P = []
    X = {0,R}
    Y = {0,C}
    M = 0
    for i in range(N):
        x1,y1,x2,y2 = map(int,input().split())
        if (x1 in X or y1 in Y) and  (x2 in X or y2 in Y):
            if y1==0:
                L1 = x1
            elif x1==R:
                L1 = R+y1
            elif y1==C:
                L1 = 2*R + C - x1
            else:
                L1 = 2*(R+C) - y1
            
            if y2==0:
                L2 = x2
            elif x2==R:
                L2 = R+y2
            elif y2==C:
                L2 = 2*R + C - x2
            else:
                L2 = 2*(R+C) - y2
                
            P.append([min(L1,L2), max(L1,L2)])
    P = sorted(P, key = lambda a:a[0])
    M = len(P)
    
    flag = 0
    Q = []
    for i in range(M):
        x1,x2 = P[i]
        if Q == []:
            Q.append([x1,x2])
        else:
            while Q[-1][1] < x1 and Q!=[]:
                Q.pop()
            if Q==[]:
                Q.append([x1,x2])
            else:
                y1,y2 = Q[-1]
                if y2 < x2:
                    flag = 1
                    break
                else:
                    Q.append([x1,x2])
    if flag == 1:
        print("NO")
    else:
        print("YES")
    
main()

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    
    R,C,N = map(int,input().split())
    P = []
    X = {0,R}
    Y = {0,C}
    M = 0
    for i in range(N):
        x1,y1,x2,y2 = map(int,input().split())
        if (x1 in X or y1 in Y) and  (x2 in X or y2 in Y):
            if y1==0:
                L1 = x1
            elif x1==R:
                L1 = R+y1
            elif y1==C:
                L1 = 2*R + C - x1
            else:
                L1 = 2*(R+C) - y1
            
            if y2==0:
                L2 = x2
            elif x2==R:
                L2 = R+y2
            elif y2==C:
                L2 = 2*R + C - x2
            else:
                L2 = 2*(R+C) - y2
                
            P.append([min(L1,L2), max(L1,L2)])
    P = sorted(P, key = lambda a:a[0])
    M = len(P)
    
    flag = 0
    Q = []
    for i in range(M):
        x1,x2 = P[i]
        if Q == []:
            Q.append([x1,x2])
        else:
            while Q!=[] and Q[-1][1] < x1:
                Q.pop()
            if Q==[]:
                Q.append([x1,x2])
            else:
                y1,y2 = Q[-1]
                if y2 < x2:
                    flag = 1
                    break
                else:
                    Q.append([x1,x2])
    if flag == 1:
        print("NO")
    else:
        print("YES")
    
main()
def func_rfindr(str, start):
    return str.rfind('R')

def func_lfindw(str, start):
    return str.find('W')

def func_replace(target, pos, str):
    ret = ""
    if pos != 0:
        ret = target[0:pos]
    ret = ret + str
    if len(target) - 1 != pos:
        ret = ret + target[pos + 1:]
    return ret

N = int(input())
C = input()
ans = 0

posrr = func_rfindr(C)
poslw = func_lfindw(C)

while poslw != -1 and posrr != -1 and posrr > poslw:
    C = func_replace(C, posrr, "W")
    C = func_replace(C, poslw, "R")
    ans = ans + 1
    posrr = func_rfindr(C, posrr)
    poslw = func_lfindw(C, poslw)

print(ans)

### FIXED CODE ###

def func_rfindr(str):
    return str.rfind('R')

def func_lfindw(str):
    return str.find('W')

def func_replace(target, pos, str):
    ret = ""
    if pos != 0:
        ret = target[0:pos]
    ret = ret + str
    if len(target) - 1 != pos:
        ret = ret + target[pos + 1:]
    return ret

N = int(input())
C = input()
ans = 0

posrr = func_rfindr(C)
poslw = func_lfindw(C)

while poslw != -1 and posrr != -1 and posrr > poslw:
    #C = func_replace(C, posrr, "W")
    #C = func_replace(C, poslw, "R")
    C = C[poslw + 1:posrr]
    ans = ans + 1
    posrr = func_rfindr(C)
    poslw = func_lfindw(C)

print(ans)
W,H,N=map(int,input().split())
x=[]
y=[]
a=[]
w=[i for i in range(W+1)]
h=[i for i in range(H+1)]
S=W*H

for _ in range(N):
    X, Y, A = map(int, input().split())
    x.append(X)
    y.append(Y)
    a.append(A)

for i in range(len(x)):
    if a[i]==1 and x[i] > w[0]:
        for j in range(x[i]):
            w.remove(j)
    if a[i]==2 and x[i] < w[-1]:
        for j in reversed(range(x[i]+1,w[-1]+1)):
            w.remove(j)
    if a[i]==3 and y[i] > h[0]:
        for j in range(y[i]):
            h.remove(j)
    if a[i]==4 and y[i] < h[-1]:
        for j in reversed(range(y[i]+1,h[-1]+1)):
            h.remove(j)

if len(w)==0 or len(h)==0:
    print(0)
else:
    S_f = (w[-1]-w[0]) * (h[-1]-h[0])
    print(S_f)


### FIXED CODE ###

W,H,N=map(int,input().split())
x=[]
y=[]
a=[]
w=[i for i in range(W+1)]
h=[i for i in range(H+1)]
S=W*H

for _ in range(N):
    X, Y, A = map(int, input().split())
    x.append(X)
    y.append(Y)
    a.append(A)

for i in range(len(x)):
    if a[i]==1 and len(w)!=0:
        for j in range(x[i]):
            if j in w: w.remove(j)
    if a[i]==2 and len(w)!=0:
        for j in reversed(range(x[i]+1,w[-1]+1)):
            if j in w: w.remove(j)
    if a[i]==3 and len(h)!=0:
        for j in range(y[i]):
            if j in h: h.remove(j)
    if a[i]==4 and len(h)!=0:
        for j in reversed(range(y[i]+1,h[-1]+1)):
            if j in h: h.remove(j)
if len(w)==0 or len(h)==0:
    print(0)
else:
    S_f = (w[-1]-w[0]) * (h[-1]-h[0])
    print(S_f)
import sys


def solve(a, b, h):
    return (a + b) * h / 2


a = sys.stdin.readline().rstrip()
int(a)
b = sys.stdin.readline().rstrip()
int(b)
h = sys.stdin.readline().rstrip()
int(h)
ans = solve(a, b, h)
print ans


### FIXED CODE ###

def solve(a, b, h):
    return (a + b) * h / 2


a = raw_input()
a = int(a)
b = raw_input()
b = int(b)
h = raw_input()
h = int(h)
ans = solve(a, b, h)
print ans
N = int(input())
W = [input() for _ in range(N)]

from collections import Counter

dic = Counter(W)
flg = 0
for i in range(N):
    if dic[W[i]]!=1:
        flg=1
        

for j in range(N-1):
    if W[j][-1]!=W[j+1][1]:
        flg = 1

if flg!=1:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

N = int(input())
W = [input() for _ in range(N)]

from collections import Counter

dic = Counter(W)
flg = 0
for i in range(N):
    if dic[W[i]]!=1:
        flg=1
        

for j in range(N-1):
    if W[j][-1]!=W[j+1][0]:
        flg = 1

if flg!=1:
    print('Yes')
else:
    print('No')
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def combination_mod_initialize(n, MOD=10**9+7):
    fac = [1]*(n+1)
    inv = [1]*(n+1)
    for i in range(1, n+1):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = inv[i-1] * pow(i, -1, MOD) % MOD
    return fac, inv

# 二項係数　高速
def combination_mod(n, r, fac, inv, mod=10**9+7):
    return fac[n] * inv[r] * inv[n-r]


def main():
    S = NI()
    fac, inv = combination_mod_initialize(10000, MOD)
    ans = 0
    if S <= 2:
        print(0)
        exit()
    for n in range(1, S//3+1):
        t = S - 3 * n
        ans += combination_mod(t+n-1, t, fac, inv, MOD)
    print(ans%MOD)



if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def combination_mod_initialize(n, MOD=10**9+7):
    fac = [1]*(n+1)
    inv = [1]*(n+1)
    for i in range(1, n+1):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = inv[i-1] * pow(i, -1, MOD) % MOD
    return fac, inv

# 二項係数　高速
def combination_mod(n, r, fac, inv, mod=10**9+7):
    return fac[n] * inv[r] * inv[n-r]


def main():
    S = NI()
    fac, inv = combination_mod_initialize(10000, MOD)
    ans = 0
    if S <= 2:
        print(0)
        exit()
    for n in range(1, S//3+1):
        t = S - 3 * n
        ans += combination_mod(t+n-1, t, fac, inv, MOD)
    print(ans%MOD)



if __name__ == "__main__":
    main()
import bisect

N,M = [int(x) for x in input().split()]

l = [[int(x) for x in input().split()] for _ in range(M)]



def do(l):
    l1 = [v1 for (v1,_) in l]
    l2 = [v2 for (_,v2) in l]
    l1.sort()
    l2.sort()

    count = 1

    l.sort()

    h = 0
    
    for i in range(len(l)):
        nx = l2[h]
        if l[i][0] >= nx:
            count+=1
            h+=1
            while l2[h] != l2[h+1]:
                if h+1 >= len(l2):
                    break
                h+=1
    return count




result = do(l)
print(result)

### FIXED CODE ###

import bisect

N,M = [int(x) for x in input().split()]

l = [[int(x) for x in input().split()] for _ in range(M)]



def do(l):

    count = 1

    l.sort()
    right = l[0][1]


    for i in range(len(l)):
        if l[i][0] >= right:
            right = l[i][1]
            count+=1
            continue
        if l[i][1] < right:
            right = l[i][1]
    return count

testl = [[x,x+1] for x in range(1)]

result = do(l)
print(result)
n,r=int(input().split())
if n <10:
  print(r-100*(10-2))
else:
  print(r)

### FIXED CODE ###

n,r=map(int, input().split())
if n <10:
  print(r+100*(10-n))
else:
  print(r)
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if (e - a <= f):
    print("Yay!")
else:
    print(":(")

### FIXED CODE ###

a = int(input())
for _ in range(3):
    input()
e = int(input())
k = int(input())
if e-a > k:
    print(':(')
else:
    print('Yay!')
n = int(input())
s = input()
ans = ''
i = 0
prev = ''
while i < n - 1:
    if prev != s[i]:
        ans += s[i]
    prev = s[i]
    if s[i] == s[i+1]:
        i += 2
    else:
        i += 1
if prev != s[i]:
    ans += s[i] 
print(len(ans))

### FIXED CODE ###

n = int(input())
s = input()
ans = ''
i = 0
prev = ''
while i < n - 1:
    if prev != s[i]:
        ans += s[i]
    prev = s[i]
    if s[i] == s[i+1]:
        i += 2
    else:
        i += 1
if not(i > n - 1):
    if prev != s[i]:
        ans += s[i] 
print(len(ans))
n=int(input());d=[0]*20001;a=1;b=-1
for i in range(n):
    c=int(input())
    if b!=c:
        a+=d[c]
        d[c]=a
    b=c
print(a%(10**9+9))

### FIXED CODE ###

n=int(input());d=[0]*200001;a=1;b=0
for i in range(n):
    c=int(input())
    if b!=c:
        a+=d[c]
        d[c]=a
    b=c
print(a%(10**9+7))
import sys.stdin

s = stdin.readline().strip()
sl = len(s)

cnt = 0
for i in range(sl//2):
  if s[i]!=s[sl-1-i]:
    cnt += 1

print(cnt)

### FIXED CODE ###

#!/usr/bin/env python3
from sys import stdin

s = stdin.readline().strip()
sl = len(s)

cnt = 0
for i in range(sl//2):
  if s[i]!=s[sl-1-i]:
    cnt += 1

print(cnt)
S = input()

ans = 0
pre = ''

while True:
    flag = 1
    for i, c in enumerate(S):
        if pre == '':
            pre = c
            continue

        if (pre == '1' and c == '0') or (pre == '0' and c == '1'):
            if i + 1 != len(S):
                S = S[:i - 1] + S[i + 1:]
            else:
                S = S[:i - 1]
            ans += 2
            flag = 0
            break
    if flag:
        break
print(ans)


### FIXED CODE ###

S = input()

# while True:
#     flag = 1
#     for i, c in enumerate(S):
#         if pre == '':
#             pre = c
#             continue

#         if (pre == '1' and c == '0') or (pre == '0' and c == '1'):
#             if i + 1 != len(S):
#                 S = S[:i - 1] + S[i + 1:]
#             else:
#                 S = S[:i - 1]
#             ans += 2
#             flag = 0
#             break
#         pre = c
#     if flag:
#         break
a = S.count("1")
b = S.count("0")
print(min(a, b) * 2)
s = input()
n = int(input())

count = 0
for i in s:
  	count += 1
    if i != "1" or (count == n):
        print(i)
        break
else:
    print(1)

### FIXED CODE ###

s = input()
n = int(input())
 
count = 0
for i in s:
    count+=1
    if i != "1" or count == n:
        print(i)
        break
else:
    print(1)
# coding: utf-8
    import sys

     
    def solve(a,begin,end,queue):
      if begin>=end:
        return
      maxx = sorted(list(map(abs,a[begin:end+1])),reverse=True)[0]
      if maxx in a:
        m = a.index(maxx)
      else:
        m = a.index(-1*maxx)
        maxx = -1*maxx
      if maxx==0:
        return []
      if maxx>0:
        solve(a,begin,m-1,queue)
        for i in range(max(0,m-1),end):
          if a[i+1]>=a[i]:
            continue
          else:
            a[i+1]+=a[i]
            queue.append((i,i+1))
            if a[i+1]<a[i]:
              a[i+1]+=a[i]
              queue.append((i,i+1))
        return queue
      if maxx<0:
        solve(a,m+1,end,queue)
        for i in reversed(range(begin,min(len(a)-1,m+1))):
          if a[i]<=a[i+1]:
            continue
          else:
            a[i]+= a[i+1]
            queue.append((i+1,i))
            if a[i]>a[i+1]:
              a[i]+=a[i+1]
              queue.append((i+1,i))
        return queue
     
    if __name__ == '__main__':
      n = int(input())
      a = list(map(int,input().split()))
      queue = solve(a,0,len(a)-1,[])
      print(len(queue))
      for i in range(len(queue)):
        print(queue[i][0]+1,queue[i][1]+1)

### FIXED CODE ###

# coding: utf-8

def solve(a,begin,end,queue):
  if begin>=end:
    return
  maxx = sorted(list(map(abs,a[begin:end+1])),reverse=True)[0]
  if maxx in a[begin:end+1]:
    m = a[begin:end+1].index(maxx)+begin
  else:
    m = a[begin:end+1].index(-1*maxx)+begin
    maxx = -1*maxx
  if maxx==0:
    return []
  if maxx>0:
    solve(a,begin,m-1,queue)
    for i in range(max(0,m-1),end):
      if a[i+1]>=a[i]:
        continue
      else:
        a[i+1]+=a[i]
        queue.append((i,i+1))
        if a[i+1]<a[i]:
          a[i+1]+=a[i]
          queue.append((i,i+1))
    return queue
  if maxx<0:
    solve(a,m+1,end,queue)
    for i in reversed(range(begin,min(len(a)-1,m+1))):
      if a[i]<=a[i+1]:
        continue
      else:
        a[i]+= a[i+1]
        queue.append((i+1,i))
        if a[i]>a[i+1]:
          a[i]+=a[i+1]
          queue.append((i+1,i))
    return queue

if __name__ == '__main__':
  n = int(input())
  a = list(map(int,input().split()))
  queue = solve(a,0,len(a)-1,[])
  print(len(queue))
  for i in range(len(queue)):
    print(queue[i][0]+1,queue[i][1]+1)
i = input().split()
a = input(x[1])
b = input(x[-1])
print(a*b, (a+b)*2)

### FIXED CODE ###

x = input().split()
a = int(x[0])
b = int(x[1])
print(a*b, (a+b)*2)