Problem:


Score : 100 points

Problem Statement

There are two buttons, one of size A and one of size B.

When you press a button of size X, you get X coins and the size of that button decreases by 1.

You will press a button twice. Here, you can press the same button twice, or press both buttons once.

At most how many coins can you get?

Constraints

All values in input are integers.

3 \leq A, B \leq 20

Input

Input is given from Standard Input in the following format:

A B

Output

Print the maximum number of coins you can get.

Sample Input 1

5 3

Sample Output 1

9

You can get 5 + 4 = 9 coins by pressing the button of size 5 twice, and this is the maximum result.

Sample Input 2

3 4

Sample Output 2

7

Sample Input 3

6 6

Sample Output 3

12



Sample input:
5 3


Sample output:
9

Submission status: Runtime Error

Solution code:
n=int(input())
h=list(input().split())
x=1
 
h_max=h[0]
 
if n == 1:
    print("1")
 
else:
  for i in range(1,n):
    if h[i]>=h_max:
      x += 1
      h_max=h[i]
  
  print(x)

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
if a=b:
  print(a*2)
else:
  print(1)

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
if a = b:
  print(a*2)
else:
  print(max([a,b])*2-1)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
S = input().replace('\n', '')


def solve(S, K):
    record = []
    temp = []
    for i in range(len(S) - 1):
        if S[i:i+2] == '01':
            temp.append(i + 1)
        elif S[i:i+2] == '10':
            if not temp: temp = [0, i]
            else: temp.append(i)
            record.append(temp)
            temp = []
    if len(temp) > 0:
        temp.append(len(S) - 1)
        record.append(temp)
    if S[0] == '0':
        record = [[0, record[0][0] - 1]] + record
    if S[-1] == '0':
        record = record + [[record[-1][-1] + 1, len(S) - 1]]
    if len(record) <= K + 1: return(len(S))
    else:
        cnt = 0
        for i in range(len(record) - K):
            cnt = max(cnt, record[i + K][1] - record[i][0] + 1)
        return(cnt)
print(solve(S, K))

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())

def Buttons(x, y):
  if x > y:
    return 2x+1
  elif x < y:
    return 2y+1
  elif x==y:
    return x+y


Buttons(a,b)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())

def Bottuns(x, y):
  if x > y:
    return 2x+1
  elif x < y:
    return 2y+1
  elif x==y:
    return x+y


Buttons(a,b)

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
s=input()
lst=[1]
for i in range(1,n):
    if s[i]!=s[i-1]:
        lst.append(1)
    else:
        lst[-1]=lst[-1]+1
p=2*k
L=[0]
for i in lst:
  L.append(L[-1]+i)
l=len(L)
ans=0
if s=='1'*n:
    ans=n
else:
    if s[0]=='1':
        if l%2==0:
            q=(l-p)//2
            for i in range(q):
                ans=max(ans,L[2*i+p+1]-L[2*i])
        else:
            L.append(0)
            q=(l-p+1)//2
            for i in range(q):
                ans=max(ans,L[2*i+p+1]-L[2*i])
    else:
        L.insert(0,0)
        if l%2==1:
            L.insert(0,0)
            q=(l-p+1)//2
            for i in range(q):
                ans=max(ans,L[2*i+p+1]-L[2*i])
        else:
            L.append(0)
            q=(l-p+2)//2
            for i in range(q):
                ans=max(ans,L[2*i+p+1]-L[2*i])
print(ans)

Submission status: Runtime Error

Solution code:
def rec(n):
    if n == 1:
        return 1
    return rec(n-1) + 1

print(rec(2000))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(1000000000)

def rec(n):
    if n == 1:
        return 1
    return rec(n-1) + 1


print(rec(800000))

Submission status: Runtime Error

Solution code:
a=input()
b=input()
sum=0
a=int(a)
b=int(b)
 
if a>=b:
  sum+=a
  if a-1>=b:
  	sum+=a-1
  else:
    sum+=b
else:
  sum+=b
  if b-1>=a:
  	sum+=b-1
  else:
    sum+=a
    
print(sum)

Submission status: Runtime Error

Solution code:
import numpy as np

a=input()
b=input()
sum=0

if a>=b:
  sum+=a
  if a-1>=b:
  	sum+=a-1
  else:
    sum+=b
else:
  sum+=b:
  if b-1>=a:
  	sum+=b-1
  else:
    sum+=a
    
print(sum)

Submission status: Runtime Error

Solution code:
A,B = (int(i) for i in input().split)
a = max(A,B)
b = min(A,B)
t = a - b
if t <= 1:
  print(a + a - 1)
else:
  print(a + b)

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
s=list(input())
s=list(map(int,s))
stack=[]
tmp=1
flag=True
for i in range(1,len(s)):
  if s[i]!=s[i-1]:
    stack.append(tmp)
    tmp=1
  else:
    tmp+=1
stack.append(tmp)
left=[0]
right=[0]
tmp=0
if s[0]==0:
  flag=False
  if len(stack)%2==1:
    stack.append(0)
  if len(stack)//2<=k:
    print(len(s))
    exit()
else:
  flag=True
  if len(stack)%2==0:
    stack.append(0)
  if len(stack)//2<=k:
    print(len(s))
    exit()
for i in range(len(stack)):
  tmp+=stack[i]
  if i%2==0:
    if flag:
      right.append(tmp)
    else:
      left.append(tmp)
  else:
    if flag:
      left.append(tmp)
    else:
      right.append(tmp)
ans=0
for i in range(len(right)-k):
  ans=max(ans,right[i+k]-left[i])
print(ans)

Submission status: Runtime Error

Solution code:
A,B = map(int,input().split())

if A>B:
	print(A*2-1)
elif A=B:
	print(A+B)
else:
	print(B*2-1)

Submission status: Runtime Error

Solution code:
if __name__ == "__main__":
    p, q = input().split()
    if p > q:
        answer = p
        p = p - 1
    else:
        answer = q
        q = q - 1
    if p > q:
        answer += p
    else:
        answer += q
	print(answer)

Submission status: Runtime Error

Solution code:
if __name__ == "__main__":
    p, q = input().split()
    if p > q:
        answer = p
        p = p - 1
    else:
        answer = q
        q = q - 1
    if p > q:
        answer += p
    else:
        answer += q

Submission status: Runtime Error

Solution code:
import sys
stdin = sys.stdin 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
N,K=na();S=ns()
l=[]
N=len(S)
if(S[0]=="0"):
    l.append(0)
b=S[0]
ct=1
for i in S[1:]:
    if(b!=i):
        l.append(ct)
        ct=1
        b=i
    else:
        ct+=1
l.append(ct)

len_l=len(l)
if(len_l//2 <= K):
    print(sum(l))
    exit()
res = sum(l[:2*K+1])
ans=res
if(len_l%2==0):
    l.append(0)
    len_l+=1
g = K * 2 + 1
for i in range(K*2+1,len_l-1,2):
    ans -= l[i-g] + l[i+1-g]
    ans += l[i] + l[1+i]
    res = max(ans,res)
#print(l)
print(res)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
return max(a+b,2*a-1,2*b-1)

Submission status: Runtime Error

Solution code:
n = int(input())
h = list(map(int, input().split()))
c = 1
for i in range(1,n):
    if h[i] >= max(h[j] for j in range(i)):
        c += 1
print(c)

Submission status: Runtime Error

Solution code:
l = list(map(int, input().split()))

a = l[0]
b = l[1]

int c = 0

if a <= b:
  c += b
  b -= 1
else a > b:
  c += b
  b -= 1

if a <= b:
  c += b
  b -= 1
else a > b:
  c += b
  b -= 1
  
print(c)

Submission status: Runtime Error

Solution code:
def main():
    n, k = map(int, input().split())
    s = input()
    
    arr = []
    if s[0] == '0':
        arr.append(0)
    cnt = 1
    i = 1
    while i != n:
        if s[i] != s[i - 1]:
            arr.append(cnt)
            cnt = 1
        else:
            cnt += 1
        i += 1
    arr.append(cnt)
    if s[-1] == '0':
        arr.append(0)
    
    ans = 0
    curr = arr[0]
    j = 1
    if len(arr) - 1 <= 2 * k:
        print(n)
        return 0
    for i in range(1, len(arr), 2):
        curr += arr[i] + arr[i + 1]
        if i - j == 2 * k:
            curr -= arr[j] + arr[j - 1]
            j += 2
        ans = max(ans, curr)
    print(ans)
    return 0
main()

Submission status: Runtime Error

Solution code:
N, K = list(map(int, input().split()))
S = input()

# 終端を追加
S = S + 'E'
ans = -1

# standは利用した命令の数であるのでS[0] == '0'のときstand = 1になる
if (S[0] == '0'):
    stand = 1
else:
    stand = 0

L = 0
R = 0

# 尺取り法　(two pointers というみたい)
while(R < N):
    if (stand <= K):
        # 0からはじまる連続列が見つかったらstandを増やす
        if (S[R] == '1' and S[R+1] == '0'):
            stand+=1
        ans = max(ans, R - L + 1)
        R += 1
    elif L == R:
        L += 1
        R += 1
    else:
        if (S[L] == '0' and S[L+1] == '1'):
            stand -= 1
        L += 1

print(ans)

Submission status: Runtime Error

Solution code:
a,b = map(int,input.split())
c = 0
for i in range(2):
  c += max(a,b)
  max(a,b) -= 1
print(c)

Submission status: Runtime Error

Solution code:
def check_max_coin(a,b):
  max_coin = 0
  for i in range(1:3):
    if a < b :
      max_coin += b 
    else:
      max_coin += a      
  print(max_coin)
  
a, b = map(int, input().split())
check_max_coin(a,b)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
s = list(input())

# 部分文字列の和を算出
array = []
now_num = 1
count = 0
for i in s:
  if now_num == int(i):
    count += 1
  else:
    array.append(count)
    count = 1
    now_num = 1 - now_num

if count != 0:
  array.append(count)

if len(array) % 2 == 0:
  array.append(0)

res = 0
add = 2 * k + 1
ans = 0
left = 0
right = 0
tmp = 0

for i in range(len(array))[::2]:
    next_left = i
    next_right = min(i+add, len(array))
    # 尺取法
    while next_left > left:
        tmp -= array[left]
        left += 1
    while next_right > right:
        tmp += array[right]
        right += 1
    ans = max(tmp,ans)

print(ans)

Submission status: Runtime Error

Solution code:
AB = int(stdin.readline().rstrip().split())
x = max(AB)
y = max(x-1, min(AB))
print(x + y)

Submission status: Runtime Error

Solution code:
S = list(map(int, input()))

count = 0
tmp = S[0]
for ii in S:
    if ii != tmp:
        count += 1
    tmp = abs(tmp-1)

print(count)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
S = str(input())
S_list = []
cum_list = [0]
tmp = 1
count = 0
if "0" not in S:
    print(len(S))
else:
    for i in range(N):
        if i == 0:
            if int(S[i]) == tmp:
                count += 1
            else:
                S_list.append(count)
                count = 1
        else:
            if S[i] == S[i - 1]:
                count += 1
                if i == N - 1:
                    S_list.append(count)
            else:
                S_list.append(count)
                count = 1


    if S[-1] == "0":
        S_list.append(0)




    now = 0
    for i in range(len(S_list)):
        now += S_list[i]
        cum_list.append(now)
    def check(x,K):
        answer_list = []
        i = 0
        if i + 2 * K + 1 < len(x):
            while i + 2 * K + 1 < len(x):
                answer_list.append(x[i + 2 * K + 1] - x[i])
                i += 2
            return answer_list
        elif K > 0:
            check(x,K-1)
    answer_list = check(cum_list,K)

    answer = max(answer_list)
    print(answer)

Submission status: Runtime Error

Solution code:
#include<algorithm>
#include<iostream>
int main(argc, **argv) {
	int a, b;
  	cin>>a;
  	cin>>b;
  	int ans = 0;
  	ans = max(ans, a + a-1);
  	ans = max(ans, a + b);
  	ans = max(ans, b + b-1);
  	cout << asn << endl;
}

Submission status: Runtime Error

Solution code:
line = trim(input(STDIN))
line = line.split(' ')
A = line[0]
B = line[1]
ans = 0
ans = max(ans, A + A - 1)
ans = max(ans, A + B)
ans = max(ans, B + B - 1)
print(ans)

Submission status: Runtime Error

Solution code:
line = trim(input(STDIN))
line = ' '.split(line)
A = line[0]
B = line[1]
ans = 0
ans = max(ans, A + A - 1)
ans = max(ans, A + B)
ans = max(ans, B + B - 1)
print(ans)

Submission status: Runtime Error

Solution code:
A, B = map(int, input().split())
if A > B:
    result = A + (A - 1)
elif A < B:
    reuslt = B + (B - 1)
else:
    result = A + B
print(result)

Submission status: Runtime Error

Solution code:
from itertools import accumulate

N,K=list(map(int,input().split(" ")))
S=input()

def solve():
    cnt=0
    l=[]
    prev = "1"
    for i in S:
        if prev ==i:
            cnt += 1
        else:
            l.append(cnt)
            cnt = 1
        prev =i
    l.append(cnt)
    if prev=="0":
        l.append("0")
    
    w = 2 * K + 1
    
    if len(l) <=w:
        return N
    
    acc=[0]+list(accumulate(l))
    ans = 0
    for i in range(0,len(l) - w+ 1,2):
        ans = max(ans, acc[w+i] - acc[i])

    return ans
print(solve())

Submission status: Runtime Error

Solution code:
from itertools import accumulate

n, k = list(map(int, input().split()))
s = input()


def solve():
    l = []
    prev = '1'
    cnt = 0
    for c in s:
        if prev == c:
            cnt += 1
        else:
            l.append(cnt)
            cnt = 1
        prev = c
    l.append(cnt)
    if prev == '0':
        l.append(0)

    w = 2 * k + 1

    if len(l) <= w:
        return n

    acc = [0] + list(accumulate(l))
    ans = 0
    for i in range(0, len(l) - w + 1, 2):
        ans = max(ans, acc[i + w] - acc[i])
    return ans


print(solve())

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
max1 = max(a,b)
max2 = max(min(a,b),max(a,b)-1)
print(max1 + max2)

Submission status: Runtime Error

Solution code:
a = input()
b = input()
max1 = max(a,b)
max2 = max(min(a,b),max(a,b)-1)
print(max1 + max2)

Submission status: Runtime Error

Solution code:
a = input()
b = input()
max1 = max(a,b)
max2 = max(min(a,b),max(a,b)-1)
 
print(max1 + max2)

Submission status: Runtime Error

Solution code:
a = input()
b = input()
max1 = max(a,b)
max2 = max(min(a,b),max(a,b)-1)

return max1 + max2

Submission status: Runtime Error

Solution code:
a=map(int,input().split())
print(max([2*a[0]-1,2*a[1]-1,a[0]+a[1]]))

Submission status: Runtime Error

Solution code:
a=map(int,input().split())
print(max([2*a[0]-1,2*a[1]-1,a[0]+a[1]])

Submission status: Runtime Error

Solution code:
a, b = map(int(input()))

l = [2*a-1, a+b, 2b-1]

print(max(l))

Submission status: Runtime Error

Solution code:
import sys
N, K = map(int, input().split())
s = input()
  
group = []
sign = s[0]
curr = 0
for i in range(N):
  curr += 1
  if s[i] != sign: 
    group += [curr-1]
    curr = 1
    sign = s[i]
else:group += [curr]

if s[0] == '0' :
  if s[N-1] == '0':
    m = (len(group)+1)//2
    if K >= m:
      print(N)
      sys.exit()
    score = [sum(group[:2*K])]
    for i in range(m-K):
      score += [score[-1] - group[2*i] + group[2*i+2*K]]
  else :
    m = (len(group)+1)//2
    if K >= m:
      print(N)
      sys.exit()
    score = [sum(group[:2*K])]
    for i in range(m-K):
      score += [score[-1] - group[2*i] + group[2*i+2*K]]
    score[-1] += group[-1]
else:
  0/0
  m = len(group)//2
  group += [0]
  if K >= m:
    print(N)
    sys.exit()
  score = [sum(group[:2*K+1])]
  for i in range(m-K):
    score += [score[-1] - group[2*i] - group[2*i+1] + group[2*i+2*K+1]+group[2*i+2*K +2]]

print(max(score))

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
S = input()
a = []
if S[0] == '0':
    a.append(0)
cnt = 1
for i in range(1, N):
    if S[i] != S[i - 1]:
        a.append(cnt)
        cnt = 1
    else:
        cnt += 1

a.append(cnt)
a.append(0)
a.append(0)

ans = s = sum(a[:2*K + 1])
for i in range(2*K + 2, len(a), 2):
    s += a[i] + a[i - 1] - a[i - 2*K - 1] - a[i - 2*K - 2]
    ans = max(ans, s)
print(ans)

Submission status: Runtime Error

Solution code:
A,B = int(input())
if A == B:
    print(A*2)
elif A > B:
    print(A*2-1)
else:
    print(B*2-1)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
S = list(map(int, input()))

Z = [j for j, s in enumerate(S) if (j > 0 and s == 0 and S[j] != S[j-1]) or (j == 0 and s == 0)] + [N]
Y = [j for j, s in enumerate(S) if (j > 0 and s == 1 and S[j] != S[j-1]) or (j == 0 and s == 1)]
result = 0
if len(Z) <= K:
  print(N)
else:
  for i in range(len(Z)-K):
    if i == 0:
      result = Z[i+K]
    else:
      result = max(result, Z[i+K] - Y[i if Y[0] < Z[0] else i-1])
    print(result)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
S = list(map(int, input()))

Z = [j for j, s in enumerate(S) if (j > 0 and s == 0 and S[j] != S[j-1]) or (j == 0 and s == 0)] + [N]
Y = [j for j, s in enumerate(S) if (j > 0 and s == 1 and S[j] != S[j-1]) or (j == 0 and s == 1)]
result = 0
if len(Z) <= K:
  print(N)
else:
    for i in range(len(Z)-K):
      if i == 0:
        result = Z[i+K]
      else:
        result = max(result, Z[i+K] - Y[i if Y[0] < Z[0] else i-1])
    print(result)

Submission status: Runtime Error

Solution code:
A = input(int(A)) 
B = input(int(B))
sum = 0

for i in range(2):
    if A > B:
        sum = A + sum
        A = A - 1
    else:
        sum = B + sum
        B = B -1 
print(sum)

Submission status: Runtime Error

Solution code:
A = input()
A = int(A)
B = input()
B = int(B)
sum = 0

for i in range(2):
    if A > B:
        sum = A + sum
        A = A - 1
    else:
        sum = B + sum
        B = B -1 

print(sum)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
v1, v2 = map(int, input().split())

if v1 < v2:
    t = v1
    v1 = v2
    v2 = t

v3 = v1 - v2

if v3 = 0:
    print(v1*2)

if v3 <= 2:
    print(v1*2-1)

if v1 == 1:
    print(v1*2+1)

Submission status: Runtime Error

Solution code:
n = int(input())
h = list(map(int, input().split()))
high = h[0]
ans = 1
for i in range(1,n):
    if high <= h[i]:
        ans += 1
        high = h[i]

print(ans)

Submission status: Runtime Error

Solution code:
if a>=b:
    k=a
    a=a-1
else:
    k=b
    b=b-1

if a>=b:
    k=k+a
else:
    k=k+b

print(k)

Submission status: Runtime Error

Solution code:
N = int(input())
H = list(map(int, input().split()))

cnt = 0
for i in range(len(H)):
    if (max(H[0:i]) <= H[i]):
        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
a = input()
b = input()

def MaxCoinCount(A,B):
  ans = 0
  if A > B:
    ans = A + (A - 1)
  elif A < B:
    ans = B + (B + 1)
  else:
    ans = A + B


MaxCoinCount(a, b)

Submission status: Runtime Error

Solution code:
A = input('A = ')
A = int(A)
B = input('B = ')
B = int(B)
sum = 0

for i in range(2):
    if A > B:
        sum = A + sum
        A = A - 1
    else:
        sum = B + sum
        B = B -1 

print(sum)

Submission status: Runtime Error

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = LIST()
S = input()

# stand = []
# reverse = []
# state = None
# count = 0
# tmp = None
# for i in S:
# 	if i == "0":
# 		state = "stand"
# 	else:
# 		state = "reverse"
# 	if tmp == "stand" and state == "reverse":
# 		stand.append(count)
# 		count = 1
# 	elif tmp == "reverse" and state == "stand":
# 		reverse.append(count)
# 		count = 1
# 	else: # 状態が前と同じ
# 		count += 1
# 	tmp = state
# if state == "stand":
# 	stand.append(count)
# else:
# 	reverse.append(count)

# if "0" not in S:
# 	print(len(S))
# else:
# 	if K >= len(stand): # 全員逆立ちにできる
# 		print(len(S))
# 	else:
# 		if len(stand) > len(reverse):
# 			reverse.append(0)
# 			reverse.insert(0, 0)
# 		if len(stand) == len(reverse) and S[0] == "0":
# 			reverse.insert(0, 0)
# 		if len(stand) == len(reverse) and S[0] == "1":
# 			reverse.append(0)
# 		# print(stand)
# 		# print(reverse)
# 		max_ = 0
# 		for i in range(max(1, 1+len(reverse)-(K+1))):
# 			# print(reverse[i:i+K+1],stand[i:i+K])
# 			tmp = sum(reverse[i:i+K+1]+stand[i:i+K])
# 			if tmp > max_:
# 				max_ = tmp
# 		print(max_)

indexes = []
tmp = ""
for i in range(len(S)):
	if S[i] == "0":
		state = "stand"
	else:
		state = "reverse"
	if tmp != state:
		indexes.append(i)
	else: # 状態が前と同じ
		pass
	tmp = state
indexes.append(N)
ans = []
# print(indexes)
for i in range(len(indexes)):
	# print(i)
	if S[indexes[i]] == "0":
		if i+2*K >= len(indexes):
			pass
		ans.append(indexes[i+2*K]-indexes[i])
	else:
		if i+2*K+1 >= len(indexes):
			pass
		ans.append(indexes[i+2*K+1]-indexes[i])
if ans == []:
	print(len(S))
else:
	print(max(ans))

Submission status: Runtime Error

Solution code:
def MaxCoinCount(A,B):
  ans = 0
  if A > B:
    ans = A + (A - 1)
  elif A < B:
    ans = B + (B + 1)
  else:
    ans = A + B

MaxCoinCount(A, B)

Submission status: Runtime Error

Solution code:
N = int(input())
H = list(map(int, input().split()))

ans = 0
for i in range(len(H)):
  chkflg = True
  if i >= 1:
    for j in range(i): 
      if H[j] > H[i]:
        chkflg = False
        break

  if chkflg: ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
H = list(map(int, input().split()))

cnt = 1
for i in range(len(H)):
    if (max(H[0:i+1]) == H[i]):
        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
N = int(input())
H = list(map(int, input().split()))

cnt = 0
for i in range(1:N+1):
    if (max(H[0:i+1]) == H[i]):
        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
N = int(input())
H = list(map(int, input().split()))

cnt = 0
for i in range(len(H)):
    if (max(H[0:i+1]) == H[i]):
        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:

N, K = (int(i) for i in input().split())
S = list(str(input()))

L0 = []
L1 = []

pre = -1
now = -1
count = 1

for i in range(1,len(S)):
    pre = int(S[i-1])
    now = int(S[i])
    
    if pre != now:
        if pre == 1:
            L1.append(count)
        else:
            L0.append(count)
        count = 1
        continue
    
    count += 1
        
    
if now  == 1:
    L1.append(count)
else:
    L0.append(count)


if int(S[0]) == 0 and int(S[-1]) == 0:
    L1.append(0)
    L1.insert(0,0)

if int(S[0]) == 1 and int(S[-1]) == 0:
    L1.append(0)

if int(S[0]) == 0 and int(S[-1]) == 1:
    L1.insert(0,0)        

maxi = 0


for i in range(len(L1)-1):
    sum1 = sum(L1[i:i+K+1])
    sum0 = sum(L0[i:i+K])
    sum_ = sum0 + sum1
    if maxi < sum_ :
        maxi = sum_
        
if maxi == 0:
    maxi = 1
    
print(maxi)

Submission status: Runtime Error

Solution code:
def MaxCoinCount(A,B):
  ans = 0
  if A > B:
    ans = A + (A - 1)
    A = A - 1
  else if A < B:
    ans = B + (B + 1)
  else:
    ans = A + B

Submission status: Runtime Error

Solution code:
import math
tile=int(input())
if len(str(tile))==1:
    print(0)
    exit()
if len(str(tile))%2==1:
    tile1=int("01"*int(math.ceil(len(str(tile))/2)),2)
    tile2=int("10"*int(math.ceil(len(str(tile))/2)),2)
else:
    tile1=int("01"*int(len(str(tile))/2),2)
    tile2=int("10"*int(len(str(tile))/2),2)

tile_10=int(str(tile),2)
convert1=format(tile_10^tile1,'b').zfill(len(str(tile)))
convert2=format(tile_10^tile2,'b').zfill(len(str(tile)))
if convert1.count("1")<=convert2.count("1"):
    print(convert1.count("1"))
else:
    print(convert2.count("1"))

Submission status: Runtime Error

Solution code:
import math                                                                                            

n,k = raw_input().split()
s = list(raw_input())


cnt = 0

prev = ''
tmp = ''
ar = []
for i in s:
    if i == '0' and prev !=  1:
        tmp += '0'
        prev = 0
    elif i == '0' and prev == 1:
        prev = 0
        ar.append(tmp)
        tmp = '0'
    elif i == '1' and prev != 0:
        tmp += '1'
        prev = 1
    elif i == '1' and prev == 0:
        prev = 1
        ar.append(tmp)
        tmp = '1'

ar.append(tmp)
k = int(k)


j = 0
cnt = 0
total = 0
m = 0

for i in ar:
    total += len(i)
    if '0' in i:
        cnt += 1
    if '0' in i and cnt == k + 1:
        total = total - (len(ar[j-2*k]) + len(ar[j-2*k-1]))                                            
        cnt = k                                    
    m = max(m, total)
    j += 1

print m

Submission status: Runtime Error

Solution code:
a = input().split()
b = int(d[0])
c = int(d[1])
if b > c:
	first = b
    b = b - 1
else:
	first = c
	c = c - 1
if b > c:
	second = b
else:
	second = c
answer = first + second
print(str(answer))

Submission status: Runtime Error

Solution code:
def main():
	N = int(input())
	HeightList = list(map(int, input().split()))

	numOfOceanView = 1
	max = HeightList[0] # 0origin
	for i in range(1, N):
		if max < HeightList[i]:
			max = HeightList[i]
			numOfOceanView += 1
	print(numOfOceanView)

main()

Submission status: Runtime Error

Solution code:
N, K = list(map(int, input().split(' ')))
S = list(input())

size = []

now = S[0]
cnt = 1

END = False

for i in range(1,N,1):
  before = now
  now = S[i]
  if now == before:
    cnt += 1
  else:
    size.append(cnt)
    cnt = 1

size.append(cnt)

if 3*K > len(size):
  print(sum(size))
  END = True

max_sum = 0
max_sum2 = 0

if  S[0] == '0':
  start = 1
else:
  start = 0
  
if END:
  pass
else:
  for i in range(start,len(size),2):
    try:
      now_sum = sum(size[i:i+3*K])
      now_sum2 = sum(size[i+1:i+1+3*(K-1)])
      if max_sum < now_sum:
          max_sum = now_sum
      if max_sum2 < now_sum2:
          max_sum2 = now_sum2
    except:
      pass
  
  if max_sum2 > max_sum:
  	print(max_sum2)
  else:
    print(max_sum)

Submission status: Runtime Error

Solution code:
input=[A,B]
results=[]
for i in range(2):
    for j in range(2):
        result=0
        A=input[i]
        B=input[j]
        result+=A
        A-=1
        result+=B
        B-=1
        results.append(result)
return max(results)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
s = input()
s = list(s)
ans = s
len = []
for i in range(n):
  l = 0
  if s[i] == '0':
    l += 1
    j = i
    while s[j+1] != '0':
      l += 1
  len.append(l)
print(len)

Submission status: Runtime Error

Solution code:
input=[A,B]
results=[]
for i in range(2):
    for j in range(2):
        result=0
        A=input[i]
        B=input[j]
        result+=A
        A-=1
        result+=B
        B-=1
        results.append(result)
max(results)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

n,k = map(int,input().split())
s = list(input())
s = list(map(int,s))

def array_count(arr):
    arr_target = [[]]
    cnt = 1
    for i in range(1,len(arr)):
        if arr[i] == arr[i-1]:
            cnt += 1
        else:
            arr_target.append([arr[i-1],cnt])
            cnt = 1
    arr_target.append([arr[len(arr)-1],cnt])
    del arr_target[0]
    return arr_target

ss = array_count(s)

if ss[0][0] == 0:
    ss = [[1,0]] + ss

if ss[-1][0] == 1:
    ss.append([0,0])

ss_sum = []
temp = 0
for i in range(len(ss)):
    temp += ss[i][1]
    ss_sum.append(temp)

ans = -1
for i in range(len(ss_sum)):
    temp = 0
    if i % 2 == 0:
        if i + k * 2 < len(ss_sum):
            temp = ss_sum[i+k*2] - ss_sum[i]
    else:
        if i + k * 2 + 1 < len(ss_sum):
            temp = ss_sum[i+k*2+1] -  ss_sum[i]
    ans = max(temp,ans)

if k * 2 >= len(ss):
    ans = ss_sum[-1]

print(ans)

Submission status: Runtime Error

Solution code:
N, K = [int(i) for i in input().split()]
s = input()
S = [int(s[i]) for i in range(len(s))]

for i in range(K):
    pair = []
    temp = 0
    for i in range(N):
        if i <= N-1:
            if (S[i]==0 and S[i+1]==0):
                temp += 1
            elif(S[i]==0):
                pair.append([i-temp,temp])
                temp = 0
        else:
            if(S[i]==0):
                pair.append([i,temp])
                temp = 0
    max_m = 0
    max_s = []
    for i in range(len(pair)):
        temp = S.copy()
        s, l = pair[i]
        for j in range(l+1):
            temp[s+j]=1
        m = cal_l(temp, N)
        if (m > max_m):
            max_m = m
            max_s = temp.copy()
    S = max_s.copy()
print (max_m)

Submission status: Runtime Error

Solution code:
N = int(input())
num = list(map(int, input().split()))
tmp = 0
state_tmp = 0
result = 1
#i番目を比べる
for i in range(N):
    if i != 0 and 1<= num[i] <= 200:
        for j in range(N):
            if num[j] <= num[i]:
                state_tmp +=1
        if state_tmp ==  N and tmp <= num[i]:
                result +=1
        tmp = num[i]
        state_tmp = 0
    else:
        tmp = num[i]
    
print(result)

Submission status: Runtime Error

Solution code:
results=[]
for i in range(2):
    for j in range(2):
        result=0
        A=input[i]
        B=input[j]
        result+=A
        A-=1
        result+=B
        B-=1
        results.append(result)
return max(results)

Submission status: Runtime Error

Solution code:
a,b=map(list(int,inpu().split()))

if a>b:
  x=a+a-1
elif a<b:
  x=b+b-1
else:
  x=a+b
  
print(x)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# 文字列の入力
S = str(input())

ans=0

if len(S)==1:
  ans=0
elif len(S)==2:
  if S[0]==S[1]:
    ans=1
  else:
    ans=0
else: #3枚以上はちゃんと読み込む
  strint=[]
  original_string=[]
  
  for i in range(len(S)):
    string.append(S[i])
    original_string.append(S[i])
    
  for i in range(len(S)-2):
    gramed = str(string[i])+str(string[i+1])+str(string[i+2])
    
    if gramed=="000":
      string[i+1]="1"
    if gramed=="001":
      string[i]="1"
    if gramed=="011":
      string[i+2]="0"
    if gramed=="110":
      string[i]="0"
    if gramed=="100":
      string[i+2]="1"
    if gramed=="111":
      string[i+1]="1"
  
  #print(string)
  #print(original_string)
  
  for i in range(len(S)):
    if original_string[i]!=string[i]:
      ans=ans+1
  
print(ans)

Submission status: Runtime Error

Solution code:
aa

Submission status: Runtime Error

Solution code:
a,b=map(list(int,input().split()))

if a>b:
  print(a+a-1)
elif b>a:
  print(b+b-1)
else a+b:
  print(a+b)

Submission status: Runtime Error

Solution code:
N, K = (input().split())
N=int(N)
K=int(K)
S = list(input())

tmpu = []

count = 0
onecount = 0
for i in S:
    if i == '0':
        count += 1
    if i == '1':
        tmpu.append(count)
        count=0
        onecount += 1


tmpu=tmpu.sort(reverse=True)

for n in range(K):
    onecount += tmpu[n]

print(onecount)