Harryxun/stf_run huggingface dataset:
from math import gcd
from collections import defaultdict

n = int(input())
AB = [list(map(int, input().split())) for _ in range(n)]

MOD = 1000000007

box = defaultdict(int)
zeros = 0
for a, b in AB:
  if a == b == 0:
    zeros += 1
  else:
    if a != 0 and b == 0:
      box[(-1, 1, 0)] += 1
    elif a == 0 and b != 0:
      box[(1, 0, 1)] += 1
    else:
      g = gcd(a, b)
      ga = a // g
      gb = b // g
      if (a // b) < 0:
        s = -1
      else:
        s = 1
    box[(s, abs(ga), abs(gb))] += 1

nakawaru = dict()
others = 0

for (s, i, j), v in box.items():
    if (-s, j, i) in box.keys():
        if (s, i, j) not in nakawaru.keys() and (-s, j, i) not in nakawaru.keys():    
            nakawaru[(s, i, j)] = (box[(s, i, j)], box[(-s, j, i)])
    else:
        others += v

seed = 1
for i, j in nakawaru.values():
    seed *= (pow(2, i, MOD) + pow(2, j, MOD) - 1)
    seed %= MOD

ans = zeros + pow(2, others, MOD) * seed - 1
ans %= MOD

print(ans)


### FIXED CODE ###

from math import gcd
from collections import defaultdict

n = int(input())
AB = [list(map(int, input().split())) for _ in range(n)]

MOD = 1000000007

box = defaultdict(int)
zeros = 0
for a, b in AB:
  if a == b == 0:
    zeros += 1
  else:
    if a != 0 and b == 0:
      box[(-1, 1, 0)] += 1
    elif a == 0 and b != 0:
      box[(1, 0, 1)] += 1
    else:
      g = gcd(a, b)
      ga = a // g
      gb = b // g
      if (a // b) < 0:
        s = -1
      else:
        s = 1
      box[(s, abs(ga), abs(gb))] += 1
   
nakawaru = dict()
others = 0

for (s, i, j), v in box.items():
    if (-s, j, i) in box.keys():
        if (s, i, j) not in nakawaru.keys() and (-s, j, i) not in nakawaru.keys():    
            nakawaru[(s, i, j)] = (box[(s, i, j)], box[(-s, j, i)])
    else:
        others += v

seed = 1
for i, j in nakawaru.values():
    seed *= (pow(2, i, MOD) + pow(2, j, MOD) - 1)
    seed %= MOD

ans = zeros + pow(2, others, MOD) * seed - 1
ans %= MOD

print(ans)
import sys
input = sys.stdin.readline
from collections import deque

S = input().rstrip()
S = deque(S)
Q = int(input())
Que = (input().rstrip() for _ in range(Q))

flag = 0 #0:そのまま 1:反転
for elem in Que:
  if elem[0] == '1':
    flag ^= 1
  else:
    s = int(elem[2])
    if s == 1 and flag == 0:
      S.appendleft(elem[4])
    elif s == 2 and flag == 0:
      S.append(elem[4])
    elif s == 1 and flag == 1:
      S.append(elem[4],0)
    else:
      S.appendleft(elem[4])

if flag == 1:
  S.reverse()
print(''.join(S))

### FIXED CODE ###

import sys
input = sys.stdin.readline
from collections import deque

S = input().rstrip()
S = deque(S)
Q = int(input())
Que = (input().rstrip() for _ in range(Q))

flag = 0 #0:そのまま 1:反転
for elem in Que:
  if elem[0] == '1':
    flag ^= 1
  else:
    s = int(elem[2])
    if s == 1 and flag == 0:
      S.appendleft(elem[4])
    elif s == 2 and flag == 0:
      S.append(elem[4])
    elif s == 1 and flag == 1:
      S.append(elem[4])
    else:
      S.appendleft(elem[4])

if flag == 1:
  S.reverse()
print(''.join(S))
def find(x):
    global set_list
    return x if set_list[x] == x else find(set_list[x])


n, q = map(int, input().split())
set_list = list(range(n))

while q:
    op, x, y = map(int, input().split())
    if op:
        print(1 if find(x) == find(y) else 0)
    else:
        if x > y:
            x, y = y, x
        set_list[find(y)] = find(x)

    q -= 1

### FIXED CODE ###

def find(x):
    global set_list
    if set_list[x] == x:
        return x
    result = set_list[x] = find(set_list[x])
    return result


n, q = map(int, input().split())
set_list = list(range(n))

while q:
    op, x, y = map(int, input().split())
    if op:
        print(1 if find(x) == find(y) else 0)
    else:
        set_list[find(y)] = find(x)
    q -= 1
def main():
    N = int(input())
    A = input()
    Q = int(input())

    answer = sum(list(map(int, A.split())))
    numNumberList = [0] * 10
    
    for i in range(10):
        numNumberList[i] = A.count(str(i))
        
    for i in range(Q):
        B, C = list(map(int, input().split()))
        answer = answer + (int(C) - int(B)) * numNumberList[B]

        numNumberList[C] = numNumberList[C] + numNumberList[B]
        numNumberList[B] = 0

        print(answer)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys

def main():
    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())

    answer = sum(A)
    setA = set(A)
    numNumberList = [0] * 100001

    for Ai in A:
        numNumberList[Ai] = numNumberList[Ai] + 1    

    for i in range(Q):
        B, C = list(map(int, sys.stdin.readline().split()))
        answer = answer + (int(C) - int(B)) * numNumberList[B]

        numNumberList[C] = numNumberList[C] + numNumberList[B]
        numNumberList[B] = 0

        print(answer)

if __name__ == "__main__":
    main()
import math
   
n = input()
   
px = float(0)
py = float(0)
qx = float(100)
qy = float(0)
   
def koch(n, px, py, qx, qy):
 if n == 0:
  return
    
 s.x = (px*2+qx*1)/3
 s.y = (py*2+qy*1)/3
 t.x = (px*1+qx*2)/3
 t.y = (py*1+qy*2)/3
 u.x = (t.x-s.x)*math.cos(pi/3) - (t.y-s.y)*math.sin(pi/3) + s.x
 u.y = (t.x-s.x)*math.sin(pi/3) + (t.y-s.y)*math.cos(pi/3) + s.y
   
 koch(n-1, px, py, s.x, s.y)
 print s.x, s.y
 koch(n-1, s.x, s.y, u.x, s.y)
 print u.x, u.y
 koch(n-1, u.x, u.y, t.x, t.y)
 print t.x, t.y
 koch(n-1, t.x, t.u, qx, qy)
   
print px, py
koch(n, px, py, qx, qy)
print qx, qy

### FIXED CODE ###

import math
          
def koch(n, h, i, j, k):
 if n == 0:
  return
           
 sx = (h*2+j)/3
 sy = (i*2+k)/3
 tx = (h+j*2)/3
 ty = (i+k*2)/3
 ux = (tx-sx)*math.cos(math.pi/3) - (ty-sy)*math.sin(math.pi/3) + sx
 uy = (tx-sx)*math.sin(math.pi/3) + (ty-sy)*math.cos(math.pi/3) + sy
          
 koch(n-1, h, i, sx, sy)
 print sx, sy
 koch(n-1, sx, sy, ux, uy)
 print ux, uy
 koch(n-1, ux, uy, tx, ty)
 print tx, ty
 koch(n-1, tx, ty, j, k)
   
n = input()
          
px = float(0)
py = float(0)
qx = float(100)
qy = float(0)
          
print px, py
koch(n, px, py, qx, qy)
print qx, qy
a = input()
b = input()
if(a==b[:-1]):
  print("Yes")
else:
  print("No)

### FIXED CODE ###

a = input()
b = input()
if(a==b[:-1]):
  print("Yes")
else:
  print("No")
N = int(input())
A = list(map(int, input().split()))

ans = 0
r = 0
xor_A = 0
for l in range(N):
    while (r < N and (xor_A ^ A[r]) == (xor_A + A[r])):
        r += 1
        xor_A += A[r]
    ans += r - l
    if l == r:
        r += 1
    else:
        xor_A -= A[l]
print(ans)

### FIXED CODE ###

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

ans = 0
r = 0
xor_A = 0
for l in range(N):
    while (r < N and (xor_A ^ A[r]) == (xor_A + A[r])):
        xor_A += A[r]
        r += 1
    ans += r - l
    if l == r:
        r += 1
    else:
        xor_A -= A[l]
print(ans)
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
    

b = list(set(a))

for i in b:
    if a.count(i) % 2 == 0:
        b.remove(i)
    else:
        None
        
print(len(list(b))

### FIXED CODE ###

n = int(input())

nlll = {}
    
for i in range(n):
    aaa = int(input())
    if aaa in nlll:
        del nlll[aaa]
    else:
        nlll.update({aaa:1})

sums = 0
for i in nlll.values():
    sums = sums + i
print(sums)
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数

N,K,S = imn()
cnt = 0
A = []
for i in range(N):
    
    cnt += 1
    if cnt <= K: 
        A.append(str(S))
    else:
        if S != 10**9:
            A.append(str(10**9)) 
        else:
            A.append(1)
print(join(A, ' '))



### FIXED CODE ###

import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数

N,K,S = imn()
cnt = 0
A = []
for i in range(N):
    
    cnt += 1
    if cnt <= K: 
        A.append(str(S))
    else:
        if S != 10**9:
            A.append(str(10**9)) 
        else:
            A.append(str(1))
print(join(A, ' '))
line = input().split()
x = int(line[1])
ans = 0
 
a = sorted(input().split())
map(int, a)
 
for i in range(len(a)):
  if a[i] > x:
    print(ans)
    break
  else:
    x-=a[i]
    if i!=(len(a)-1):
      ans+=1
    else:
      if x==0:
        ans+=1
      print(ans)

### FIXED CODE ###

line = input().split()
N = int(line[0])
x = int(line[1])
ans = 0

a = input().split()
a = [int(i) for i in a]
a.sort()

for i in range(N):
    if a[i] > x:
        print(ans)
        break
    else:
        x -= a[i]
        if i != (N - 1):
            ans += 1
        else:
            if x == 0:
                ans += 1
            print(ans)
while 1:
    e = int(input())
    if not e :break
    m = e
    for z in range(e):
        for y in range(e):
            if  e-y**2-z**3+y+z < 0 or e - y**2 -z**3 <0:break
            if m > e-y**2-z**3+y+z: m =  e-y**2-z**3+y+z
    print(m)



### FIXED CODE ###

import math
while 1:
    e = int(input().strip())
    if e ==0:break
    m=e
    z =0
    while z**3 <= e:
        y = int(math.sqrt(e-z**3))
        x = e - y**2- z**3 
        if x < 0:break
        if m > x+y+z: m = x+y+z    
        z+=1
    print(m)
n = int(input())
A = tuple(map(int, input().split()))
def p(n):
    is_prime = [True if i%2 == 1 else False for i in range(0, n+1) ]
    is_prime[0] = False
    is_prime[1] = False
    is_prime[2] = True # 2は素数
    # 3からの奇数について
    for i in range(3, int(n**0.5) + 1, 2):
        # 既に素数の倍数であればスキップ
        if not is_prime[i]:
            continue
        # iの倍数は素数ではないとする
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

primes = p(max(A))

fact_counts = dict()
for a in A:
    for p in primes:
        if a%p == 0:
            fact_counts.setdefault(p, 0)
            fact_counts[p] += 1

pairwise = True
for c in fact_counts.values():
    if c > 1:
        pairwise = False
        break

if pairwise:
    print('pairwise coprime')
else:
    if max(fact_counts.values()) == n:
        print('not coprime')
    else:
        print('setwise coprime')


### FIXED CODE ###

N = int(input())
A = tuple(map(int, input().split()))
maxa = max(A)
min_facts = [0] * (maxa+1)
def p(n):
    """ """
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if not is_prime[i]:
            continue
        min_facts[i] = i
        
        for j in range(i*2, n+1, i):
            is_prime[j] = False
            if min_facts[j] == 0:
                min_facts[j] = i
p(maxa)
fact_counts = dict()
for a in A:
    while min_facts[a] > 0:
        f = min_facts[a]
        fact_counts.setdefault(f, 0)
        fact_counts[f] += 1
        while a%f == 0:
            a //= f

pairwise = True
for c in fact_counts.values():
    if c > 1:
        pairwise = False
        break

if pairwise:
    print('pairwise coprime')
else:
    if max(fact_counts.values()) == N:
        print('not coprime')
    else:
        print('setwise coprime')
N, K = map(int, input().split())
h_list = list(map(int, input().split()))

import numpy as np
dp_list = [np.inf] * N
dp_list[0] = 0
dp_list[1] = abs(h_list[1] - h_list[0])
for n in range(1, N):
    for k in range(1, K+1):
        dp_list[n] = chmin(dp_list[n], dp_list[n-k] + abs(h_list[n-k] - h_list[n]))
        if n-k == 0:
            break
print(dp_list[-1])

### FIXED CODE ###

N, K = map(int, input().split())
h_list = list(map(int, input().split()))
def chmin(a, b):
    if a > b:
        return b
    else:
        return a
dp_list = [1000000000] * N
dp_list[0] = 0
dp_list[1] = abs(h_list[1] - h_list[0])
for n in range(1, N):
    for k in range(1, K+1):
        dp_list[n] = chmin(dp_list[n], dp_list[n-k] + abs(h_list[n-k] - h_list[n]))
        if n-k == 0:
            break
print(dp_list[-1])
def isP(n):
	for i in prime:
		if i >= n:
			break
		if n%i == 0:
			return False
	return True

r = int(10000001**0.5)
s = int(r**0.5)
p = [1]*r
p[0] = p[1] = 0
for i in range(2,s):
	if p[i]:
		p[2*i::i] = [0 for x in range(2*i,r,i)]
prime = []
for i in range(r):
	if p[i]:
		prime.append(i)

while 1:
	n = input()
	if n == 0: break
	i = n-(1-n%2)
	while i > 12:
		p6 = isP(i-6)
		if not isP(i-8) or not isP(i-2):
			if not p6:
				i -= 10
			else:
				i -= 4
			continue
		if isP(i) and p6:
			print i
			break
		i -= 2

### FIXED CODE ###

ref = [[[10,8],[4,4]],[[10,2],[4,2]]]
r =10000001
p = [1]*r
p[0]= p[1] = 0
for i in range(int(r**0.5)):
	if p[i]:
		p[2*i::i] = [0]*len(p[2*i::i])
		
while 1:
	try:
		n = input()
		if n == 0: break
		n -= 1-n%2
		while any(not p[n-i] for i in [0,2,6,8]):
			n -= ref[p[n-2]][p[n-6]][p[n-8]]
		print n
	except:
		pass
input = int(input())

hour = math.floor(input/3600)
input -= hour*3600

min = math.floor(input/60)
input -= min*60

sec = math.floor(input)

print(hour+":"+min+":"sec)


### FIXED CODE ###

import math

input = int(input())

hour = math.floor(input/3600)
input -= hour*3600

min = math.floor(input/60)
input -= min*60

sec = math.floor(input)

print(str(hour)+":"+str(min)+":"+str(sec))
f=list(map(int,input().split()))
k=f[0];n=f[1]
dists=list(map(int,input().split()))
prev=0
maxdist=0
for d in range(1,len(dists)):
  maxdist=max(maxdist,abs(prev-dists[d]))
  prev=dists[d]
a=max(maxdist,maxdist-dists[len(dists)]+dists[0])  
ans=k-a
print(ans)

### FIXED CODE ###

k,n = map(int, input().split())
a = list(map(int, input().split()))
max_dis = 0
for i in range(n):
    if i == n-1:
        max_dis = max(max_dis,a[0]+k-a[i])
    else:
        max_dis = max(max_dis,a[i+1]-a[i])
print(k-max_dis)
K=int(sys.stdin.readline().rstrip())

def gcd(a,b):

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

cnt1 = 0
cnt2 = 0
cnt3 = 0
for n1 in range(K):
    for n2 in range(K):
        temp = gcd(n1+1, n2+1)
        for n3 in range(K):
            cnt3 += gcd(temp, n3+1)
        

ans = cnt1 + cnt2 + cnt3
print(ans)

### FIXED CODE ###

import sys

K=int(sys.stdin.readline().rstrip())
 
def gcd(a,b):

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

cnt1 = 0
cnt2 = 0
cnt3 = 0
for n1 in range(0,K):
    cnt1 += n1+1
    for n2 in range(n1+1, K):
        temp = gcd(n1+1, n2+1)
        cnt2 += temp*6
        for n3 in range(n2+1, K):
            cnt3 += gcd(temp, n3+1)*6
        

ans = cnt1 + cnt2 + cnt3
print(ans)
n=input()
ck=0
for _ in range(n//2):
  if not n[_]==n[-1-_]:
    ck+=1
if ck==0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n=input()
ck=0
for i in range(len(n)//2):
  if not n[i]==n[-1-i]:
    ck+=1
if ck==0:
  print('Yes')
else:
  print('No')
A = map(int, input().split())
print(max(A)-min(A))

### FIXED CODE ###

A = list(map(int, input().split()))
print(max(A)-min(A))
s = input()
l = []
for i in range(len(s)-1, -1, -1):
    if s[i] == 'B':
        l.append(0)
    else:
        l.append(1)
cnt = 0

for j in range(len(s)**0.5):
    for i in range(j, len(s) - 1, 2):
        if l[i] == 1 and l[i+1] == 0:
            l[i] = 0
            l[i+1] = 1
            cnt += 1

print(cnt)


### FIXED CODE ###

s = input()

left = 0
ans = 0

for x in s:
    if x == 'B':
        left += 1
        continue
    ans += left

print(ans)
while True:
    card = raw_input()
    if card == "-"
        break
    m = int(raw_input())
    for shuffle in range(m):
        h =int(raw_input())
        card = card[h:] + card[:h]
    print card

### FIXED CODE ###

while True:
    card = raw_input()
    if card == "-":
        break
    m = int(raw_input())
    for shuffle in range(m):
        h =int(raw_input())
        card = card[h:] + card[:h]
    print card
s = (1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)
 k = input()
 k = int(K)
 print(s[k+1])

### FIXED CODE ###

s=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(s[int(input())-1])
N, T = list(map(int, input().split()))
push_list = list(map(int, input().split()))
print(push_list)

dabaaaaa = 0

for i in range(len(dabaaaaa)-1):
    if push_list[i + 1] - push_list[i] < 5:
        dabaaaaa += push_list[i + 1] - push_list[i]
    else:
        dabaaaaa += 5

print(dabaaaaa)


### FIXED CODE ###

N, T = list(map(int, input().split()))
push_list = list(map(int, input().split()))


dabaaaaa = 0

for i in range(len(push_list)-1):
    if push_list[i + 1] - push_list[i] < T:
        dabaaaaa += push_list[i + 1] - push_list[i]
    else:
        dabaaaaa += T

    # 最後の人が押した後のT秒も加算

print(dabaaaaa+T)
S = int(input())
W = int(input())
if S > W print("safe")
 else print("unsafe")

### FIXED CODE ###

S, W = map(int, input().split())
if S > W:
  print("safe")
else:
  print("unsafe")
w, h, n = map(int, input().split())
coord_list = [list(map(int, input().split())) for i in range(n)]

x_list = [i for i in range(w + 1)]
y_list = [i for i in range(h + 1)]

for a in coord_list:
    if a[-1] == 1:
        x_list = [i for i in x_list if i >= a[0]]
    elif a[-1] == 2:
        x_list = [i for i in x_list if i <= a[0]]
    elif a[-1] == 3:
        y_list = [i for i in y_list if i >= a[1]]
    elif a[-1] == 4:
        y_list = [i for i in y_list if i <= a[1]]

print((max(x_list) - min(x_list)) * (max(y_list) - min(y_list)))

### FIXED CODE ###

w, h, n = map(int, input().split())
coord_list = [list(map(int, input().split())) for i in range(n)]

x_min = 0
y_min = 0
x_max = w
y_max = h
for a in coord_list:
    if a[2] == 1:
        x_min = max(a[0], x_min)
    elif a[2] == 2:
        x_max = min(a[0], x_max)
    elif a[2] == 3:
        y_min = max(a[1], y_min)
    elif a[2] == 4:
        y_max = min(a[1], y_max)

ans = max((x_max - x_min), 0) * max((y_max - y_min), 0)
print(ans)
N=int(input())
result=1
A=input().split()
for j in range(N):
  result=result*int(A[j])
  if(result>10**18):
    print(-1)
    return
print(result)

### FIXED CODE ###

def main():
    N = int(input())
    A = list(map(int,input().split()))
    if 0 in A:
      print(0)
      return
    prod = 1
    for a in A:
      prod *= a
      if prod > 1000000000000000000:
        print(-1)
        return
    print(prod)

main()
from collections import Counter
def rec(union_id, i, j):
    symbol = S[i][j]
    if union_white[i][j] != 0:
        return
    if symbol == '.':
        union_white[i][j] = union_id
        next_symbol = '#'
    else:
        union_white[i][j] = -1
        next_symbol = '.'
        union_black[union_id] += 1

    if i >= 1 and S[i-1][j] == next_symbol:
        rec(union_id, i-1, j)
    if i < H-1 and S[i+1][j] == next_symbol:
        rec(union_id, i+1, j)
    if j >= 1 and S[i][j-1] == next_symbol:
        rec(union_id, i, j-1)
    if j < W-1 and S[i][j+1] == next_symbol:
        rec(union_id, i, j+1)

    return
H, W = map(int, input().split())
S = [input() for h in range(H)]
ans = 0
union_white = [[0 for w in range(W)]for h in range(H)]
union_black = Counter()
count_black = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '.' or union_white[i][j] != 0:
            continue
        count_black += 1
        rec(count_black, i, j)

counter = Counter([x for Si in union_white for x in Si])
ans = 0
# print(counter)
# print(union_black)
# print(union_white)
for i in union_black.keys():
    ans += counter[i] * union_black[i]

print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(400*400*1000)
from collections import Counter
def rec(union_id, i, j):
    symbol = S[i][j]
    if union_white[i][j] != 0:
        return
    if symbol == '.':
        union_white[i][j] = union_id
        next_symbol = '#'
    else:
        union_white[i][j] = -1
        next_symbol = '.'
        union_black[union_id] += 1

    if i >= 1 and S[i-1][j] == next_symbol:
        rec(union_id, i-1, j)
    if i < H-1 and S[i+1][j] == next_symbol:
        rec(union_id, i+1, j)
    if j >= 1 and S[i][j-1] == next_symbol:
        rec(union_id, i, j-1)
    if j < W-1 and S[i][j+1] == next_symbol:
        rec(union_id, i, j+1)

    return
H, W = map(int, input().split())
S = [input() for h in range(H)]
ans = 0
union_white = [[0 for w in range(W)]for h in range(H)]
union_black = Counter()
count_black = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '.' or union_white[i][j] != 0:
            continue
        count_black += 1
        rec(count_black, i, j)

counter = Counter([x for Si in union_white for x in Si])
ans = 0
# print(counter)
# print(union_black)
# print(union_white)
for i in union_black.keys():
    ans += counter[i] * union_black[i]

print(ans)
A, op, B = input().split()
if op == '-':
  print(int(A) - int(B))
else:
  print(int(A) + (B))

### FIXED CODE ###

A, op, B = input().split()
if op == '-':
  print(int(A) - int(B))
else:
  print(int(A) + int(B))
import sys
from collections import *
import heapq
import math

import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
a=list(map(int,input().split()))
rlst=ruiseki(a)
# print(rlst)
lst=[]
for i in range(n+1):
    for j in range(i+1,n+1):
        lst.append(rlst[j]-rlst[i])
# print(lst)
tmp=math.log2(rlst[-1])
now=int(tmp)

while now>=0:
    anslst=[]
    for i in range(len(lst)):
        if 1&(lst[i]>>now)==1:
            anslst.append(lst[i])
    if len(anslst)>=k:
        lst=anslst
    now-=1
# print(lst)
ans=lst[0]
for i in range(k):
    ans=ans&lst[i]
print(ans)

### FIXED CODE ###

import sys
from collections import *
import heapq
import math
# from math import gcd
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
# def input():
#     return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
a=list(map(int,input().split()))
rlst=ruiseki(a)
# print(rlst)
lst=[]
for i in range(n+1):
    for j in range(i+1,n+1):
        # print(i,j)
        lst.append(rlst[j]-rlst[i])
# print(lst)
tmp=math.log(rlst[-1],2)
now=int(tmp)

while now>=0:
    anslst=[]
    for i in range(len(lst)):
        if 1&(lst[i]>>now)==1:
            anslst.append(lst[i])
    if len(anslst)>=k:
        lst=anslst
    now-=1
# print(lst)
ans=lst[0]
for i in range(k):
    ans=ans&lst[i]
print(ans)