Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)


def dfs(s):
    for t in g[s]:
        if dist[t] > -1:
            if (dist[s] + 1 - dist[t]) % 2 == 1:
                print(-1)
                exit()
            continue
        dist[t] = dist[s] + 1
        dfs(t)


n = int(input())
s = [list(input()) for _ in range(n)]
g = [[] for _ in range(n)]
mat = [[10**9] * n for _ in range(n)]
for i in range(n):
    mat[i][i] = 0
    for j in range(i + 1, n):
        if s[i][j] == '1':
            g[i].append(j)
            g[j].append(i)
            mat[i][j] = mat[j][i] = 1
dist = [-1] * n
dist[0] = 0
dfs(0)

for k in range(n):
    for i in range(n):
        for j in range(n):
            mat[i][j] = min(mat[i][j], mat[i][k] + mat[k][j])
ans = 0
for i in range(n):
    for j in range(n):
        ans = max(ans, mat[i][j])
print(ans + 1)


### FIXED CODE ###

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)


def dfs(s):
    for t in g[s]:
        if dist[t] > -1:
            if (dist[s] + 1 - dist[t]) % 2 == 1:
                print(-1)
                exit()
            continue
        dist[t] = dist[s] + 1
        dfs(t)


n = int(input())
s = [list(input()) for _ in range(n)]
g = [[] for _ in range(n)]
mat = [[10**9] * n for _ in range(n)]
for i in range(n):
    mat[i][i] = 0
    for j in range(i + 1, n):
        if s[i][j] == '1':
            g[i].append(j)
            g[j].append(i)
            mat[i][j] = mat[j][i] = 1
dist = [-1] * n
dist[0] = 0
dfs(0)

for k in range(n):
    for i in range(n):
        for j in range(n):
            mat[i][j] = min(mat[i][j], mat[i][k] + mat[k][j])
ans = 0
for i in range(n):
    for j in range(n):
        ans = max(ans, mat[i][j])
print(ans + 1)
### BUGGY CODE ###

n, m = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(n)]
AB.sort(key=lambda ab: -ab[1])
counts = [0] * m
cands = [0] * m
total = 0
for a, b in AB:
    if a <= m:
        for i in range(a - 1 + counts[a - 1], m):
            if cands[i] > 0:
                continue
            cands[i] = b
            counts[a - 1] += 1
            total += 1
            break
    if total == m:
        break
print(sum(cands))


### FIXED CODE ###

import heapq

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

cands = [[] for _ in range(m)]
for _ in range(n):
    a, b = map(int, input().split())
    if a <= m:
        cands[a - 1].append(-b)

heapq.heapify(cands[0])
total = 0
for i in range(m):
    if len(cands[0]) > 0:
        total -= heapq.heappop(cands[0])
    if i < m - 1:
        for c in cands[i + 1]:
            heapq.heappush(cands[0], c)

print(total)
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()
LR = [list(map(int, input().split())) for _ in range(Q)]

ans = [S[LR[i][0]-1:LR[i][1]].count('AC') for i in range(Q)]

print(*ans, sep='\n')

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
LR = [list(map(int, input().split())) for _ in range(Q)]

t = [0] * (N+1)
for i in range(N):
    t[i+1] = t[i] + (1 if S[i: i+2] == 'AC' else 0)
ans = [t[LR[i][1] - 1] - t[LR[i][0] - 1] for i in range(Q)]    

print(*ans, sep='\n')
### BUGGY CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, H: "List[int]"):

    result = 0
    while len(H) >= 2:
        count = 0
        for i in range(len(H) - 1):
            if H[i] >= H[i + 1]:
                count += 1
            else:
                break
        result = max(result, count)

        H = H[count + 1 :]

    print(result)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, H)


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, H: "List[int]"):

    result = 0
    count = 0
    for i in range(N - 1):
        if H[i] >= H[i + 1]:
            count += 1
        else:
            result = max(result, count)
            count = 0
    result = max(result, count)
    print(result)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, H)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

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

if k > n:
    k == n

if n == 2:
    print(abs(costs[-1] - costs[-2]))
else:
    dp = [float("inf") for i in range(n)]
    dp[-1] = 0

    for i in range(1, k + 1):
        curr_min = float("inf")
        for j in range(i):
            curr_min = min(abs(costs[n - i - 1] - costs[n - j - 1]) + dp[n - j - 1], curr_min)
        dp[n - i - 1] = curr_min    

    for i in range(n - k - 2, -1, -1):
        curr_min = float("inf")
        for j in range(1, k + 1):
            curr_min = min(curr_min, abs(costs[i] - costs[i + j]) + dp[i + j]) 
        dp[i] = curr_min

    print(dp[0])


### FIXED CODE ###

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

if k > n:
    k == n

if n == 2:
    print(abs(costs[-1] - costs[-2]))
else:
    dp = [float("inf") for i in range(n)]
    dp[-1] = 0

    for i in range(1, k + 1):
        curr_min = float("inf")
        for j in range(i):
            curr_min = min(abs(costs[n - i - 1] - costs[n - j - 1]) + dp[n - j - 1], curr_min)
        dp[n - i - 1] = curr_min    

    for i in range(n - k - 2, -1, -1):
        curr_min = float("inf")
        for j in range(1, k + 1):
            curr_min = min(curr_min, abs(costs[i] - costs[i + j]) + dp[i + j]) 
        dp[i] = curr_min

    print(dp[0])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)

def main():
    N = int(input())
    S = input()


    dict = {}
    seen = set()

    def count(val,x,y):
        if val in seen:
            dict[val].append((x,y))
        else:
            dict[val] = [(x,y)]
            seen.add(val)

    for i in range(N):
        for j in range(N-i):
            count(S[i:i+j+1],i,i+j)

    # print(dict,seen)
    ans = 0
    for s in seen:
        poss = dict[s]
        if not len(poss) > 1: continue

        poss.sort()
        pre_pos = poss.pop()
        while len(poss) > 0:
            pos = poss.pop()
            if pos[1] < pre_pos[0]:
                # print("s",s,pos[1]-pos[0]+1)
                ans = max(ans,pos[1]-pos[0]+1)

            pre_pos = pos


    print(ans)






if __name__ == "__main__":
  main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)


class RollingHash:

    def __init__(self,string):
        base1 = 1007
        mod1 = 10**9+7

        base2 = 2009
        mod2 = 10**9+9

        self.string = string
        n = len(string)
        hash1 = [0]*(n+1)
        power1 = [1]*(n+1)

        hash2 = [0]*(n+1)
        power2 = [1]*(n+1)
        for i,e in enumerate(string):
            hash1[i+1] = (hash1[i]*base1 + ord(e))%mod1
            power1[i+1] = (power1[i]*base1)%mod1
            hash2[i+1] = (hash2[i]*base2 + ord(e))%mod2
            power2[i+1] = (power2[i]*base2)%mod2

        self.hash1 = hash1
        self.power1 = power1
        self.hash2 = hash2
        self.power2 = power2
        self.base1 = base1
        self.mod1 = mod1
        self.base2 = base2
        self.mod2 = mod2

    def calc(self,i,j):
        ans = ((self.hash1[j]-self.hash1[i]*self.power1[j-i]%self.mod1)%self.mod1)*(10**10)
        ans += (self.hash2[j]-self.hash2[i]*self.power2[j-i]%self.mod2)%self.mod2
        return ans

def main():
    N = int(input())
    S = input()

    rh = RollingHash(S)


    ans = 0
    l = 0
    r = N


    while r-l > 1:
        mid = (l+r)//2
        seen = set()
        dic = {}
        found = False
        for i in range(N-mid+1):
            if not i < i+mid-1: continue

            hash = rh.calc(i,i+mid-1)
            # print(hash,i,i+mid-1,mid)
            if hash in seen:
                for _i,j in dic[hash]:
                    if j < i and S[_i:j+1] == S[i:i+mid]:
                        ans = max(ans,mid)
                        found = True
                        break
                else: continue

                dic[hash].append((i,i+mid-1))
                break
            else:
                dic[hash] = [(i,i+mid-1)]
                seen.add(hash)


        if found:
            l = mid
        else:
            r = mid

    print(ans)



if __name__ == "__main__":
  main()
### BUGGY CODE ###

import itertools
n,m,R = map(int,input().split())
r = list(map(int,input().split()))
cost = [[1000000]*n for i in range(n)]
for i in range(m):
    a,b,c = map(int,input().split())
    cost[a-1][b-1] = c
    cost[b-1][a-1] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            cost[i][j] = min(cost[i][j], cost[i][k]+cost[k][j])

ans = 10000000
for p in itertools.permutations(r):
    c = 0
    for i in range(R-1):
        c += cost[p[i]-1][p[i+1]-1]
    ans = min(c, ans)
print(ans)

### FIXED CODE ###

import itertools
n,m,R = map(int,input().split())
r = list(map(int,input().split()))
cost = [[-1]*n for i in range(n)]
for i in range(m):
    a,b,c = map(int,input().split())
    cost[a-1][b-1] = c
    cost[b-1][a-1] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            if k == i or k == j or cost[i][k] == -1 or cost[k][j] == -1:
                continue
            if cost[i][j] == -1:
                cost[i][j] = cost[i][k]+cost[k][j]
            else:
                cost[i][j] = min(cost[i][j], cost[i][k]+cost[k][j])

ans = -1
for p in itertools.permutations(r):
    c = 0
    for i in range(R-1):
        c += cost[p[i]-1][p[i+1]-1]
    if ans == -1:
        ans = c
    else:
        ans = min(c, ans)
print(ans)
### BUGGY CODE ###

n,k=map(int,input().split())
a=[]
for i in range(n+1):
    a.append(i)
d=0
for i in range(k,n+2):
    b=sum(a[:i])
    c=sum(a[-i:])
    d+=(c-b+1)
print(d)

### FIXED CODE ###

n,k=map(int,input().split())
d=0
for i in range(k,n+2):
    b=i*(i-1)/2
    c=i*(2*n-i+1)/2
    d+=(c-b+1)
print(int(d)%(10**9+7))
### BUGGY CODE ###

S = input()
mod = 10 ** 9 + 7
count = 0
leftA = (1 if S[0] == "A" else 0)
leftQ = (1 if S[0] == "?" else 0)
rightC = S[1:].count("C")
rightQ = S[1:].count("?")

for i in range(1,len(S)-1):
    if S[i] == "B" or S[i] == "?":
        rightQ -= (1 if S[i] == "?" else 0)
        if leftQ >= 1:
            leftpatt = leftA * (3 ** leftQ) + leftQ * (3 ** (leftQ - 1))
        else:
            leftpatt = leftA
        if rightQ >= 1:
            rightpatt = rightC * (3 ** rightQ) + rightQ * (3 ** (rightQ - 1))
        else:
            rightpatt = rightC
        leftQ += (1 if S[i] == "?" else 0)
        count += (leftpatt * rightpatt) % mod
        count %= mod
    else:
        leftA += (1 if S[i] == "A" else 0)
        rightC -= (1 if S[i] == "C" else 0)
print(int(count))

### FIXED CODE ###

S = input()
mod = 10 ** 9 + 7
count = 0
leftA = (1 if S[0] == "A" else 0)
leftQ = (1 if S[0] == "?" else 0)
rightC = S[1:].count("C")
rightQ = S[1:].count("?")

def mult(a, b, mod):
    if b == 0:
        return a
    else:
        return ((3*a + b) * pow(3, b-1, mod))

for i in range(1,len(S)-1):
    if S[i] == "B" or S[i] == "?":
        rightQ -= (1 if S[i] == "?" else 0)
        count += mult(leftA, leftQ, mod) * mult(rightC, rightQ, mod)
        count %= mod
        leftQ += (1 if S[i] == "?" else 0)
    elif S[i] == "A":
        leftA += 1 
    else:
        rightC -= 1
print(count)
### BUGGY CODE ###

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

def kitaiti(n):
    return 0.5*n + 0.5

ans = 0
index = 0
for i in range(N-K+1):
    if ans < sum(p[i:i+K]):
        ans = sum(p[i:i+K])
        index = i

print(kitaiti(ans)+0.5*(K-1))


### FIXED CODE ###

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

def kitaiti(n):
    return 0.5*n + 0.5

ans = 0

s=[0]*(N+1)
for i in range(N):
    s[i+1] = s[i] + p[i]

for i in range(N-K+1):
    val = s[K+i] - s[i]
    if ans<val:
        ans = val

print(kitaiti(ans)+0.5*(K-1))
### BUGGY CODE ###

import sys
input = sys.stdin.readline


def cmb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

n=int(input())
A=list(map(int,input().split()))
v=[-1]*n
for i,a in enumerate(A):
    #print(i,a)
    if v[a-1]!=-1:
        s=v[a-1]
        f=i
    if v[a-1]==-1:
        v[a-1]=i

#print(s,f)
mod=10**9+7
for i in range(1,n+1):
    sousuu=cmb(n+1,i,mod)
    tyouhuku=cmb(s+n-f,i-1,mod)
    print(sousuu-tyouhuku)
print(1)


### FIXED CODE ###

import sys
input = sys.stdin.readline
########   modあり modは素数  ###############
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+1
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 )


n=int(input())
A=list(map(int,input().split()))
v=[-1]*n
for i,a in enumerate(A):
    #print(i,a)
    if v[a-1]!=-1:
        s=v[a-1]
        f=i
    if v[a-1]==-1:
        v[a-1]=i

#print(s,f)
mod=10**9+7
for i in range(1,n+1):
    sousuu=cmb(n+1,i,mod)
    tyouhuku=cmb(s+n-f,i-1,mod)
    """if i==1:
        sousuu=n+1
        tyouhuku=1
    else:
        sousuu*=(n+2-i)
        sousuu//=i
        tyouhuku*=(s+n-f+1-i+1)
        tyouhuku//=(i-1)"""
    #print(sousuu,tyouhuku)
    print((sousuu-tyouhuku)%mod)
print(1)
### BUGGY CODE ###

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

ans = 0

for x in range(0, k+1):
    for y in range(x, k+1):
        for z in range(y, k+1):
            if x+y+z == s:
                if x == y == z:
                    ans += 1
                elif x != y != z != x:
                    ans += 6
                else:
                    ans += 3

print(ans)


### FIXED CODE ###

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

ans = 0

for x in range(k+1):
    for y in range(k+1):
        if 0 <= s-x-y <= k:
            ans += 1

print(ans)
### BUGGY CODE ###

import bisect
def inpl(): return [int(i) for i in input().split()]
N = int(input())
a = inpl()
b = [0 for _ in range(N)]
for i in range(N):
    b[a[i]-1] = i+1
rng = [0, N+1]
ans = 0
for i, v in enumerate(b):
    x = bisect.bisect_left(rng, v)
    st = rng[x-1]
    en = rng[x]
    ans += (i+1)*(v-st)*(en-v)
    rng = rng[:x] + [v] + rng[x:]
print(ans)

### FIXED CODE ###

def inpl(): return [int(i) for i in input().split()]
N = int(input())
a = inpl()
b = {a[i]: i for i in range(N)}

left = list(range(N+2))
right = list(range(N+2))

ans = 0
for i in range(N,0,-1):
    x = b[i]
    ans += i*(right[x]-x +1)*(x-left[x] +1)
    right[left[x] - 1] = right[x]
    left[right[x] + 1] = left[x]
print(ans)
### BUGGY CODE ###

def get_divisor(n: int) -> list:
    divisor = []
    for i in range(1, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            divisor.append(i)
            if n // i != i:
                divisor.append(n // i)
    # divisor.sort() # if you want sorted divisors
    return divisor


x = int(input())
cand = get_divisor(x)
# print(cand)
for d in cand:
    a = d
    b = 0
    while a**5 - b**5 < x:
        a += 1
        b += 1
    if a**5 - b**5 == x:
        print(a, b)
        break

    is_found = False
    for i in range(1, d):
        a = i
        b = i - d
        if a**5 - b**5 == x:
            print(a, b)
            is_found = True
            break
    if is_found:
        break

    a = 0
    b = -d
    while a**5 - b**5 < x:
        a -= 1
        b -= 1
    if a**5 - b**5 == x:
        print(a, b)
        break


### FIXED CODE ###

def get_divisor(n: int) -> list:
    divisor = []
    for i in range(1, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            divisor.append(i)
            if n // i != i:
                divisor.append(n // i)
    # divisor.sort() # if you want sorted divisors
    return divisor


x = int(input())
cand = get_divisor(x)
# print(cand)
for d in cand:
    if d**5 == x:
        print(d, 0)
    elif d**5 < x:
        a = d
        b = 0
        while a**5 - b**5 < x:
            a += 1
            b += 1
        if a**5 - b**5 == x:
            print(a, b)
            break

        a = 0
        b = -d
        while a**5 - b**5 < x:
            a -= 1
            b -= 1
        if a**5 - b**5 == x:
            print(a, b)
            break
    else:
        if d % 2 == 0 and (d // 2)**5 + (d // 2)**5 > x:
            continue
        if d % 2 == 1 and ((d + 1) // 2)**5 + (d // 2)**5 > x:
            continue
        a = d
        b = 0
        while a**5 - b**5 > x:
            a -= 1
            b -= 1
            # print(a, b, a**5 - b**5)
        if a**5 - b**5 == x:
            print(a, b)
            break

        a = 0
        b = -d
        while a**5 - b**5 > x:
            a += 1
            b += 1
        if a**5 - b**5 == x:
            print(a, b)
            break
### BUGGY CODE ###

n=int(input())

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

ans = 1

for i in t:
  ans *= i

if 10**18 < ans:
  print(-1)
else:
  print(ans)

### FIXED CODE ###

n=int(input())

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

t.sort()

ans = 1

for i in t:
  ans *= i
  if 10**18 < ans:
    print(-1)
    exit()

print(ans)
### BUGGY CODE ###

def main():
  f=lambda:map(int,input().split())
  n,k=f()
  la=sorted(f())
  INF=10**18+1
  import bisect
  tl=bisect.bisect_left(la,0)
  tr=bisect.bisect(la,0)
  tm,tz,tp=tl,tr-tl,n-tr
  cm=tm*tp
  cz=tz*(n*2-tz-1)//2
  cp=(tm*(tm-1)+tp*(tp-1))//2
  if 0<k-cm<=cz:
    print(0)
  elif k<=cm:
    l,r=-INF,0
    while r-l>1:
      m=(l+r)//2
      s=0
      for i in range(tp):
        i=la[tr+i]
        li,ri=-1,tm
        while ri-li>1:
          mi=(li+ri)//2
          if i*la[mi]<m: li=mi
          else: ri=mi
        s+=ri
      if s<k: l=m
      else: r=m
    print(l)
  else:
    l,r=0,INF
    while r-l>1:
      m=(l+r)//2
      s=0
      for i in range(tm):
        i=la[i]
        li,ri=-1,tm
        while ri-li>1:
          mi=(li+ri)//2
          if i*la[mi]<m: ri=mi
          else: li=mi
        s+=tm-ri
        if i*i<m: s-=1
      for i in range(tp):
        i=la[tr+i]
        li,ri=-1,tp
        while ri-li>1:
          mi=(li+ri)//2
          if i*la[tr+mi]<m: li=mi
          else: ri=mi
        s+=ri
        if i*i<m: s-=1
      if cm+cz+s//2<k: l=m
      else: r=m
    print(l)
if __name__ == "__main__":
  main()

### FIXED CODE ###

f=lambda:map(int,input().split())
n,k=f()
lm,lp=[],[]
for i in f():
  if i<0: lm.append(-i)
  else: lp.append(i)
lm.sort()
lp.sort()
cm=len(lm)
cp=len(lp)
def cnt(x):
  c=0
  if x<0:
    r=cp
    for i in lm:
      while r and i*lp[r-1]>=-x: r-=1
      c+=cp-r
    return c
  r=cm
  for i in lm:
    while r and i*lm[r-1]>x: r-=1
    c+=r
    if i*i<=x: c-=1
  r=cp
  for i in lp:
    while r and i*lp[r-1]>x: r-=1
    c+=r
    if i*i<=x: c-=1
  return cm*cp+c//2
INF=10**18+1
l,r=-INF,INF
while r-l>1:
  m=l+r>>1
  if cnt(m)<k: l=m
  else: r=m
print(r)
### BUGGY CODE ###

H,W = list(map(int,input().split()))
A = [list(str(input())) for i in range(H)]

white = []
black = []

length = sum([a.count(".") for a in A])
cnt = 0

for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            black.append([i,j])
        else:
            white.append([i,j])

while (length > 0):
    gray = []
       
    for l in black:
        c1 = [l[0],l[1]-1]
        if c1 in white and c1 not in gray:
            gray.append(c1)
        c2 = [l[0],l[1]+1]
        if c2 in white and c2 not in gray:
            gray.append(c2)
        c3 = [l[0]-1,l[1]]
        if c3 in white and c3 not in gray:
            gray.append(c3)
        c4 = [l[0]+1,l[1]]
        if c4 in white and c4 not in gray:
            gray.append(c4)
    
    for l in gray:
        black.append(l)
        white.remove(l)
        
    cnt += 1
    length = len(white)
    
print(cnt)

### FIXED CODE ###

H,W = list(map(int,input().split()))
A = [list(str(input())) for i in range(H)]
 
black = []
 
cnt = 0
 
for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            black.append([i,j])
 
length = len(black)
            
while (length < H*W):
    gray = []
    for l in black:
        if l[1] != 0:
            c1 = (l[0],l[1]-1)
            if A[c1[0]][c1[1]] == ".":
                gray.append(c1)
                A[c1[0]][c1[1]] = "#"
        if l[1] != W-1:
            c2 = (l[0],l[1]+1)
            if  A[c2[0]][c2[1]] == ".":
                gray.append(c2)
                A[c2[0]][c2[1]] = "#"
        if l[0] != 0:
            c3 = (l[0]-1,l[1])
            if  A[c3[0]][c3[1]] == ".":
                gray.append(c3)
                A[c3[0]][c3[1]] = "#"
        if l[0] != H-1:
            c4 = (l[0]+1,l[1])
            if  A[c4[0]][c4[1]] == ".":
                gray.append(c4)
                A[c4[0]][c4[1]] = "#"
    
    gray = list(set(gray))
    black = [l for l in gray]
    
    cnt += 1
    length += len(black)
    
print(cnt)
### BUGGY CODE ###

from itertools import combinations


def abs_sum(xyz_list):
    s1 = abs(sum([xyz[0] for xyz in xyz_list]))
    s2 = abs(sum([xyz[1] for xyz in xyz_list]))
    s3 = abs(sum([xyz[2] for xyz in xyz_list]))
    return s1 + s2 + s3


n, m = list(map(int, input().split(" ")))
xyz_list = []
for _ in range(n):
    xyz_list.append(list(map(int, input().split(" "))))

combs = combinations(xyz_list, m)
print(max([abs_sum(comb) for comb in combs]))


### FIXED CODE ###

from itertools import product

import numpy as np

n, m = list(map(int, input().split(" ")))
if m == 0:
    print(0)
    exit()
xyz_list = []
for _ in range(n):
    xyz_list.append(np.array(list(map(int, input().split(" ")))))
arrs = [np.array(x) for x in product([1, -1], repeat=3)]
ans = max([sum(sorted([sum(arr * xyz) for xyz in xyz_list])[-m:]) for arr in arrs])
print(ans)
### BUGGY CODE ###

N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0
for ai in range(N):
  for bi in range(ai+1,N):
    for ci in range(bi+1,N):
      if L[ci] < L[ai] + L[bi]:      
        ans += 1
      else:break
print(ans)


### FIXED CODE ###

import bisect 
N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    idx = bisect.bisect(L,L[i]+L[j]-1)
    ans += idx-j-1
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)

n,m=map(int,input().split())
root=[-1]*(n+1)
def r(x):
    if root[x]<0:
        return x
    else:

        return r(root[x])
def unite(x,y):
    x=r(x)
    y=r(y)
    if x==y:
        return
    if x>y:
        x,y=y,x

    root[x]+=root[y]
    root[y]=x
def size(x):
    x=r(x)
    return -root[x]
for i in range(m):
    x,y=map(int,input().split())

    unite(x,y)
ans=0
for i in range(n):
    ans=max(ans,size(i+1))
print(ans)







### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
n,m=map(int,input().split())
root=[-1]*n
def r(x):
    if root[x]<0:
        return x
    else:
        root[x]=r(root[x])
        return root[x]
def unite(x,y):
    x=r(x)
    y=r(y)
    if x==y:
        return
    root[x]+=root[y]
    root[y]=x
def size(x):
    x=r(x)
    return -root[x]
for i in range(m):
    x,y=map(int,input().split())
    x-=1
    y-=1
    unite(x,y)
ans=0
for i in range(n):
    ans=max(ans,size(i))
print(ans)