Harryxun/stf_run huggingface dataset:
def f(x):
    p=0
    cnt=0
    for i in range(n-1,-1,-1):
        while a[i]+a[p]<x:
            p+=1
            if p==n: return cnt
        cnt+=n-p
    return cnt

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

l,r=a[0]*2,a[n-1]*2

while r-l>0:
    if r-l<=1: md=l;break
    md=(r+l)//2
    k=f(md)
    if k==m: break
    elif k>m: l=md
    else: r=md

p=0
cnt=0
ans=0
for i in range(n-1,-1,-1):
    while a[i]+a[p]<=md:
        p+=1
    if p==n: break
    cnt+=n-p
    ans+=a[i]*(n-p)*2


ans+=(m-cnt)*md
print(ans)

### FIXED CODE ###

import sys

def f(x):
    p=0
    cnt=0
    for i in range(n-1,-1,-1):
        while p<n and a[i]+a[p]<x:
            p+=1
        cnt+=n-p
    return cnt

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

l,r=a[0]*2,a[n-1]*2
md=(r+l)//2
while r-l>0:
    if r-l<=1:
        if f(r)==m: md=r;break 
        else: md=l;break
    md=(r+l)//2
    k=f(md)
    if k==m: break
    elif k>m: l=md
    else: r=md

p=0
cnt=0
ans=0

for q in range(n-1,-1,-1):
    try:
        while p<n and a[q]+a[p]<=md:
            p+=1
    except:
        b=1
        while True:
            b+=1

    if p==n: break
    cnt+=n-p
    ans+=a[q]*(n-p)*2


ans+=(m-cnt)*md
print(ans)
N = int(input())
SP = [list(map(int,input().split()))for _ in range(N)]
SP.sort()
for i in SP.values():
  print(i)
  

### FIXED CODE ###

N = int(input())
SP = []
for i in range(N):
  S,P = input().split()
  P = int(P)
  SP.append((S,-P,i+1))
SP.sort()
for a,b,c in SP:
  print(c)
INF=10**20
N=int(input())
x=[];y=[];h=[]
for i in range(N):
    X,Y,H=map(int,input().split())
    x.append(X);y.append(Y);h.append(H)
for i in range(101):#Cx
    for j in range(101):#Cy
        res=-INF
        T=True
        mli=[]
        for k in range(N):
            tmp=h[k]+abs(x[k]-i)+abs(y[k]-j)
            if(h[k]>0):
                if(res==-INF):
                    res=tmp
                elif(res!=tmp):
                    T=not T
                    break
            elif(h[k]==0):
                mli.append(tmp)
        for x in mli:
            if(x<res):
                T=not T
                break
        if T:
            print(i,j,res)
            exit()

### FIXED CODE ###

INF=10**20
N=int(input())
xyh=[list(map(int,input().split())) for i in range(N)]
xyh=sorted(xyh,key=lambda xyh:xyh[2],reverse=True)
for i in range(101):
    for j in range(101):
        res=-INF
        T=True
        for k in range(N):
            tmp=xyh[k][2]+abs(xyh[k][0]-i)+abs(xyh[k][1]-j)
            if(xyh[k][2]>0):
                if(res==-INF):
                    res=tmp
                elif(res!=tmp):
                    T=not T
                    break
            elif(xyh[k][2]==0):
                if(tmp<res):
                    T=not T
                    break
        if T:
            print(i,j,res)
            exit()
x = list(input())
print(700+x.count(o)*100)

### FIXED CODE ###

x = list(input())
print(700+x.count("o")*100)
X,Y = map(int,input().split())
dp = [[0]*(X+10) for _ in range(Y+10)]
dp[2][1] = 1
dp[1][2] = 1

for i in range(2,X+1):
    for j in range(2,Y+1):
        dp[i][j] = ( dp[i-2][j-1] + dp[i-1][j-2] ) % (10**9+7)

print(dp[X][Y])

### FIXED CODE ###

X,Y = map(int,input().split())

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def combi(n,r,mod=10**9+7):
    fac = [0]*(n+1)
    fac[0] = 1
    fac[1] = 1
    for i in range(2,n+1):
        fac[i] = fac[i-1] * i % mod
    return( ( fac[n] * modinv(fac[r]) )%mod * modinv(fac[n-r]) % mod)

if (X+Y) % 3 != 0 or X > 2*Y or Y > 2*X:
    print(0)
else:
    n = X - (X + Y)//3
    m = (X + Y)//3 - n
    print(combi(n+m,m))
n = int(input())
a_ls = list(map(int, input().split()))
hats_person = [1,0,0]
ans = 3
mod = 10**9+7
for i in range(1,n):
    same = a_ls[i]
    n_choices = 0
    #choice_ind = -1
    for j,person in enumerate(hats_person):
        if person == same:
            n_choices += 1
            choice_ind = j
    #if choice_ind == -1:
        #ans = 0
    hats_person[choice_ind] += 1
    ans *= n_choices
    ans %= mod
print(ans)

### FIXED CODE ###

import sys
n = int(input())
a_ls = list(map(int, input().split()))
hat_nperson = [0,0,1]
ans = 3
mod = 10**9+7

if a_ls[0] != 0 or (n != 1 and a_ls[1] == 2):
    print(0)
    sys.exit()

for i in range(1,n):
    n_same = a_ls[i]
    n_choices = 0
    choice_ind = -1
    for j,person in enumerate(hat_nperson):
        if person == n_same:
            n_choices += 1
            choice_ind = j
    if choice_ind == -1:
        print(0)
        sys.exit()
    hat_nperson[choice_ind] += 1
    ans *= n_choices
    ans %= mod
print(ans%mod)
n , m = map(int,input().split())
 
g = [[] for i in range(n)]
 
dp = [-1] *n
for _ in range(m):
  v1 , v2 = map(int,input().split())
  v1 -=1; v2 -=1
  g[v1].append(v2)
def dfs(i):
  if dp[i]!=-1:
    return dp[i]
  temp = 0
  for nv in g[i]:
    temp = max(temp, dfs(nv)+1)
  dp[i]=temp
  return temp
res = 0  
for i in range(n):
  res = max(res, dfs(i))
  
print(res)

### FIXED CODE ###

import sys

sys.setrecursionlimit(10**9)

n , m = map(int,input().split())

g = [[] for i in range(n)]

dp = [-1] *n
for _ in range(m):
  v1 , v2 = map(int,input().split())
  v1 -=1; v2 -=1
  g[v1].append(v2)
  
# finding longest path for vertice i
def dfs(i):
  if dp[i]!=-1:
    return dp[i]
  temp = 0
  for nv in g[i]:
    temp = max(temp, dfs(nv)+1)
  
  dp[i]=temp
  return temp
  
# finding overall longest path  
res = 0  
for i in range(n):
  res = max(res, dfs(i))
  
print(res)
from decimal import Decimal
round=lambda x:(x*2+1)//2
a,b,c=[int(i) for i in input().split()]
num1=round(Decimal(b)/Decimal(c))
if(a%c==0):
    num2=round(a/c)-1
else:
    num2=round(a/c)

print(num1-num2)

### FIXED CODE ###

from decimal import Decimal
# round=lambda x:(x*2+1)//2
a,b,c=[int(i) for i in input().split()]
num1=(Decimal(b)/Decimal(c))
if(a%c==0):
    num2=int(Decimal(a)/Decimal(c))-1
else:
    num2=int(Decimal(a)/Decimal(c))

print(int(num1-num2))
a = int(input())
print (ans = 3*a*a)

### FIXED CODE ###

a = int(input())
print(a*a*3)
n, q = map(int, input().split()) # input:"2 2"
s = str(input())
Row=q
L=[]
R=[]
for i in range(Row):
    l,r=input().split()
    L.append(int(l))
    R.append(int(r))
#どこにACがあるかを計算しておいて、あとからL,Rでsplitする
ans=[0]*n
for i in range(n):
  if s[i]=='A' and s[i+1]=='C':
    ans[i]=1
for i in range(q):
  print(sum(ans[L[i]-1:R[i]-1]))

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  if S[i : i + 2] == 'AC':
    t[i + 1] = t[i] + 1
  else:
    t[i + 1] = t[i]
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])
N,x=map(int,input().split())
a=list(input().split())

a.sort()

ans=0
tmp=0
for i in  range(len(a)):
  tmp+=int(a[i])

if tmp==x:
  print(N)
  exit()

for i in range(0,N):
  if x-int(a[i])>=0:
    ans+=1
    x-=int(a[i])
  else:
    print(ans)
    break

if a[0]>x:
  print(0)

### FIXED CODE ###

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

a.sort()

ans=0

if x==sum(a):
  print(N)
  exit()
  
for i in range(N):
  x-=a[i]
  if x<0:
    print(i)
    exit()
else:
  print(N-1)
4
1 3 1 1

### FIXED CODE ###

n = int(input())
w = [int(i) for i in input().split()]
s = sum(w)
for t in range(1, n):
  s = min(s, abs(sum(w[:t]) - sum(w[t:])))
print(s)
A,B,T = list(map(float,input().split()))
T += 0.5 
T -= A
while T > 0:
  SUM += B
  T -= A
print(int(B))

### FIXED CODE ###

A,B,T = list(map(float,input().split()))
T += 0.5
print(int(T // A * B))
x, y= list(map(int, input().split()))
#a,b,c = list(input().split())
if x+y　< 24:
    print(x+y)
else:
    print(x+y-24)

### FIXED CODE ###

x, y= list(map(int, input().split()))
#a,b,c = list(input().split())
if x+y < 24:
    print(x+y)
else:
    print(x+y-24)
a=input();b=a[1:].replace('C','');print('WAAC'[a[0]=="A"and1==a[2:-1].count("C")and b.lower()==b::2])

### FIXED CODE ###

a=input();b=a[1:].replace('C','');print('WAAC'[a[0]=="A"and 1==a[2:-1].count("C")and b.lower()==b::2])
s = input()
n = len(s)
count = 0
halfn = int((n-1) / 2)
whalfn = int((n-1) / 4)
half = s[0:halfn]

for i in range(len(s)):
    if s[i] != s[-i-1]:
      count += 1
      break
    else:
      pass

if len(half) % 2 == 0:
  for i in range(len(half)+1):
    if half[i] != half[-i-1]:
      count += 1
      break
    else:
      pass
else:
  for i in range(len(half)):
    if half[i] != half[-i-1]:
      count += 1
      break
    else:
      pass
  
if count == 0:
  print('Yes')
else:
  print('No')
  

### FIXED CODE ###

s = input()
n = len(s)
count = 0
halfn = int((n-1) / 2)
whalfn = int((n-1) / 4)
half = s[0:halfn]

for i in range(len(s)):
    if s[i] != s[-i-1]:
      count += 1
      break
    else:
      pass

for i in range(len(half)):
  if half[i] != half[-i-1]:
    count += 1
    break
  else:
    pass

if count == 0:
  print('Yes')
else:
  print('No')
n = int(input())
a = list(map(int, input().split()))

for i in range(n):
 if a[i] & 1: break
 a[i] = x//2
print(i)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
cnt = 0
while True:
 for i in range(n):
  if a[i] & 1:
    print(cnt)
    __import__("sys").exit(0)
  a[i] //= 2
 cnt += 1
x = input().split()¥a, b,t = int(x[0]),int(x[1]),int(x[2])
t += 0.5
num = t//a
sum = int(num * b)
print(num)

### FIXED CODE ###

x = input().split()
a, b,t = int(x[0]),int(x[1]),int(x[2])
t += 0.5
num = t//a
sum = int(num * b)
print(sum)
h, w, k = map(int, input().split())
grid = [[int(v) for v in input()] for _ in range(h)]

print(grid)

def count_ones(i):
    cnt = 0
    while i:
        if i & 1:
            cnt += 1
        i >>= 1
    return cnt

ans = h + w

for state in range(1 << h):
    j = 0
    vcnt = 0
    counters = [0] * (h + 1)
    is_ok = True
    while j < w:
        hi = 0
        i = 0
        local_counters = [0] * (h + 1)
        while i < h:
            if (1 << i) & state:
                hi = i
            # print(hi, i, j)
            # print(grid[i])
            local_counters[hi] += grid[i][j]
            i += 1
        for i, v in enumerate(local_counters):
            if v > k:
                is_ok = False
                break
            counters[i] += local_counters[i]
        if not is_ok:
            break
        if max(counters) > k:
            counters = local_counters.copy()
            vcnt += 1

        j += 1


    if is_ok and ans > count_ones(state) + vcnt:
        ans = count_ones(state) + vcnt
print(ans)



### FIXED CODE ###

import sys
def ass(v):
    if not v:
        print(-1)
        sys.exit(0)

h, w, k = map(int, input().split())
grid = [[1 if v == '1' else 0 for v in input()] for _ in range(h)]


ass(h > 0 and w > 0 and k > 0)
for row in grid:
    ass(len(row) == w)


def count_ones(i):
    cnt = 0
    while i:
        if i & 1:
            cnt += 1
        i >>= 1
    return cnt

ans = h + w

for state in range(1 << h):
    j = 0
    vcnt = 0
    counters = [0] * (h + 1)
    is_ok = True
    while j < w:
        hi = 0
        i = 0
        local_counters = [0] * (h + 1)
        ass(len(counters) == len(local_counters))
        while i < h:
            if (1 << i) & state:
                hi = i
            # print(hi, i, j)
            # print(grid[i])
            ass(len(local_counters) > hi)
            ass(i < h and j < w)
            ass(len(grid) > i)
            ass(len(grid[i]) > j)
            local_counters[hi] += grid[i][j]
            i += 1
        for i, v in enumerate(local_counters):
            if v > k:
                is_ok = False
                break
            counters[i] += local_counters[i]
        if not is_ok:
            break
        # ass(len(counters))
        # ass(k)
        if max(counters) > k:
            counters = local_counters[:]
            vcnt += 1

        j += 1


    if is_ok and ans > count_ones(state) + vcnt:
        ans = count_ones(state) + vcnt
print(ans)
import sys
# sys.stdin = open('input.txt')

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

n = int(input())
a = [i for i in map(int, input().split())]

cnt = {}
for i in a:
    if i not in cnt.keys():
        cnt[i] = 1
    else:
        cnt[i] += 1

total = 0

for i in cnt.values():
    if i >= 2:
        total += cmb(i, 2)

for i in range(n):
    ans = total
    x = cnt[a[i]]
    if x >= 2:
        ans = total - cmb(x, 2)
    if x-1 >= 2:
        ans += cmb(x-1, 2)
    print(ans)

### FIXED CODE ###

import sys
# sys.stdin = open('input.txt')

nCr = {}
def cmb2(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


n = int(input())
a = [i for i in map(int, input().split())]

cnt = {}
for i in a:
    if i not in cnt.keys():
        cnt[i] = 1
    else:
        cnt[i] += 1

total = 0

for i in cnt.values():
    if i >= 2:
        total += cmb(i, 2)

ansDic = {}

for i in range(n):
    if a[i] in ansDic.keys():
        print(ansDic[a[i]])
    else:
        x = cnt[a[i]]
        ans = total
        if x >= 2:
            ans = total - cmb(x, 2)
        if x-1 >= 2:
            ans += cmb(x-1, 2)
        ansDic[a[i]] = ans
        print(ans)
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
        
a = input().split()
N = int(a[0])
M = int(a[1])
tm = int(0)
tmp = int(0)


k = [input().split() for i in range(M)]

uf = UnionFind(N)

for i in range(M):
    tm = int(k[i][0])
    tmp = int(k[i][1])
    uf.union(tm, tmp)
    tm = 0
    tmp = 0

print(int(uf.group_count()) - 1)


### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
        
a = input().split()
N = int(a[0])
M = int(a[1])
tm = int(0)
tmp = int(0)


k = [input().split() for i in range(M)]

uf = UnionFind(N+1)

for i in range(M):
    tm = int(k[i][0])
    tmp = int(k[i][1])
    uf.union(tm, tmp)
    tm = 0
    tmp = 0

print(int(uf.group_count()) - 2)
A, B, K = map(int, input().split())

L = list(range(A, B+1))
ans = L[:K] or L[-K:]
print(*ans, sep="\n")

### FIXED CODE ###

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

L = list(range(A, min(B, A+K))) + list(range(max(A, B-K+1), B+1))
L_no_duplication = set(L)
print(*sorted(L_no_duplication), sep="\n")
# -*- coding: utf-8 -*-
# Nの取得
index = int(input())

# n回ループして配列に入れる
max = 0
other = 0
for i in range(n):
  tmp = input()
  max = tmp if tmp > max else other = other +  tmp

 if max < tmp  :
   print("Yes")
else : 
print("No")



### FIXED CODE ###

# -*- coding: utf-8 -*-
# Nの取得
index = int(input())

# n回ループして配列に入れる
maximum = 0
other = 0
inputList = input().split()
for i in range(index):
    tmp = int(inputList[i])
    if tmp > maximum:
        maximum = tmp
        other = other + maximum
    else:
        other = other + tmp

if maximum < other - maximum:
    print("Yes")
else:
    print("No")
n,m = map(int,input().split())
p = list(map(int, input().split()))
g = [[] for _ in range(0,n+1)]
visit = [None] * (n+1)
ans = 0
for _ in range(0,m):
    x,y = map(int, input().split())
    g[x].append(y)
    g[y].append(x)
for i in range(1,n+1):
    if visit[i] is not None:
        continue
    stack = [i]
    part = [i]
    visit[i] = 0
    while len(stack) > 0:
        q = stack.pop()
        for qq in g[q]:
            if visit[qq] is None:
                visit[qq] = 0
                part.append(qq)
                stack.append(qq)
    if len(part) >= 2:
        part2 = []
        for i in part:
            part2.append(p[i-1])
        for i in part:
            if i in part2:
                ans += 1
    else:
        if(i == p[i] - 1):
            ans += 1
print(ans)


### FIXED CODE ###

n,m = map(int,input().split())
p = list(map(int, input().split()))
g = [[] for _ in range(0,n+1)]
visit = [None] * (n+1)
ans = 0
for _ in range(0,m):
    x,y = map(int, input().split())
    g[x].append(y)
    g[y].append(x)
for i in range(1,n+1):
    if visit[i] is not None:
        continue
    stack = [i]
    part = [i]
    visit[i] = 0
    while len(stack) > 0:
        q = stack.pop()
        for qq in g[q]:
            if visit[qq] is None:
                visit[qq] = 0
                part.append(qq)
                stack.append(qq)
    part2 = []
    for i in part:
        part2.append(p[i-1])
    ans += len(list(set(part) & set(part2)))
print(ans)
x = int(input())
year = 0
yen = 100
while x > yen:
  yen = int(yen*1.01)
  year+=
  
print(year)

### FIXED CODE ###

x = int(input())
year = 0
yen = 100

while x>yen:
  yen = int(yen*1.01)
  year+=1

print(year)
import math
a,b=[int(i) for i in input().split()]
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))

### FIXED CODE ###

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

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)
  
print(lcm(A,B))
import math
N, X = map(int, input().split())
xlist =[X]
xlist.extend(list(map(int, input().split())))
dlist =[]
for i in range(N):
    dlist.append(abs(xlist[i+1]-xlist[i]))
g = max(dlist)
for d in dlist:
    g = math.gcd(g, d)
print(g)


### FIXED CODE ###

def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
N, X = map(int, input().split())
xlist =[X]
xlist.extend(list(map(int, input().split())))
dlist =[]
for i in range(N):
    dlist.append(abs(xlist[i+1]-xlist[i]))
g = max(dlist)
for d in dlist:
    g = gcd(g, d)
print(g)
# s = input()
# n = int(input())
# A = list(map(int, input().split()))
H, W = map(int, input().split())
S = []
vertical = []
horizontal = []

for _ in range(H):
    s = list(input())
    S.append(s)
    vertical.append([-1]*W)
    horizontal.append([-1]*W)

def search_vertical(i, j, current):
    if i == H-1 or S[i+1][j] == '#':
        vertical[i][j] = current
        return current
    vertical[i][j] = search_vertical(i+1, j, current+1)
    return vertical[i][j]

def search_horizontal(i, j, current):
    if j == W-1 or S[i][j+1] == '#':
        horizontal[i][j] = current
        return current
    horizontal[i][j] = search_horizontal(i, j+1, current+1)
    return horizontal[i][j]

for i in range(H):
    for j in range(W):
        if vertical[i][j] == -1 and S[i][j] == '.':
            search_vertical(i, j, 1)
        if horizontal[i][j] == -1 and S[i][j] == '.':
            search_horizontal(i, j, 1)


print(max(vertical[i][j] + horizontal[i][j] -1 for i in range(H) for j in range(W)))


### FIXED CODE ###


# s = input()
# n = int(input())
# A = list(map(int, input().split()))
H, W = map(int, input().split())
S = []
vertical = []
horizontal = []

for _ in range(H):
    s = input()
    S.append(s)
    vertical.append([-1]*W)
    horizontal.append([-1]*W)

def search_vertical(i, j, current):
    i2 = i

    while not (i2 == H-1 or S[i2+1][j] == '#'):
        i2 += 1
        current += 1

    for i3 in range(i, i2+1):
        vertical[i3][j] = current

def search_horizontal(i, j, current):
    j2 = j

    while  not (j2 == W-1 or S[i][j2+1] == '#'):
        j2 += 1
        current += 1

    for j3 in range(j, j2+1):
        horizontal[i][j3] = current


res = -2
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        if vertical[i][j] == -1:
            search_vertical(i, j, 1)
        if horizontal[i][j] == -1:
            search_horizontal(i, j, 1)
        res = max(res, vertical[i][j] + horizontal[i][j] -1)

# print(vertical)
print(res)
#D
from collections import deque
n,k=map(int,input().split())
s=input()

a=deque([])
if s[0]=="1":
    a.append([0])
for i in range(1,n):
    if s[i-1:i+1]=="01":
        a.append([i])
    elif s[i-1:i+1]=="10":
        a[-1].append(i-1)
if s[n-1]=="1":
    a[-1].append(n-1)

if a[0][0]!="0":
    a.appendleft([0,0])
if a[-1][1]!="n-1":
    a.append([n-1,n-1])

if len(a)-1<=k:
    print(n)
else:
    t=0
    for i in range(len(a)-k):
        t=max(t,a[i+k][1]-a[i][0]+1)
    print(t)

### FIXED CODE ###

#D
from collections import deque
n,k=map(int,input().split())
s=input()
if n==1:
    print(1)
elif "1" not in s:
  	print(len(s))
else:
    a=deque([])
    if s[0]=="1":
        a.append([0])
    for i in range(1,n):
        if s[i-1:i+1]=="01":
            a.append([i])
        elif s[i-1:i+1]=="10":
            a[-1].append(i-1)
    if s[n-1]=="1":
        a[-1].append(n-1)
    if a[0][0]!=0:
        a.appendleft([0,0])
    if a[-1][1]!=n-1:
        a.append([n-1,n-1])
    if len(a)-1<=k:
        print(n)
    else:
        t=0
        for i in range(len(a)-k):
            t=max(t,a[i+k][1]-a[i][0]+1)
        print(t)
N=int(input())
list=[int(input()) for i in range(N)]
print(len(set(ist)))

### FIXED CODE ###

N=int(input())
list=[int(input()) for i in range(N)]
print(len(set(list)))
a, b, k = map(int, input().split())

if a > k:
    c = a - k
elif a + b > k:
    c = 0
    d = a + b - k
else:
    c = 0
    d = 0

print(c, d)

### FIXED CODE ###

a, b, k = map(int, input().split())

if a > k:
    c = a - k
    d = b
elif a + b > k:
    c = 0
    d = a + b - k
else:
    c = 0
    d = 0

print(c, d)