Harryxun/stf_run huggingface dataset:
import networkx as nx
from networkx.algorithms.flow import dinitz

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

def inside(x, y):
	if 0 <= x < n and 0 <= y < m:
		return True
	else:
		return False

DI = [1, 0, -1, 0]
DJ = [0, 1, 0, -1]

a = [list(input()) for _ in range(n)]
S, T = n*m, n*m+1
g = nx.DiGraph()
for i in range(n):
	for j in range(m):
		if a[i][j] == "#":
			continue
		if (i+j)%2:
			g.add_edge(i*m+j, T, capacity=1)
		else:
			g.add_edge(S, i*m+j, capacity=1)
			for k in range(4):
				di, dj = i+DI[k], j+DJ[k]
				if inside(di, dj) and a[di][dj] == ".":
					g.add_edge(i*m+j, di*m+dj, capacity=1)
r = dinitz(g, S, T)
print(r.graph["flow_value"])
#print(*r.edges)
for i0 in range(n):
	for j0 in range(m):
		if (i0+j0)%2 or a[i0][j0] != ".":
			continue
		for k in range(4):
			i1, j1 = i0+DI[k], j0+DJ[k]
			if not inside(i1, j1) or a[i1][j1] != ".":
				continue
			#print(i0, j0, i1, j1)
			if r[i0*m+j0][i1*m+j1]["flow"] != 1:
				continue
			if i1 == i0+1:
				a[i0][j0] = "v"
				a[i1][j1] = "^"
			elif i1 == i0-1:
				a[i0][j0] = "^"
				a[i1][j1] = "v"
			elif j1 == j0+1:
				a[i0][j0] = ">"
				a[i1][j1] = "<"
			else:
				a[i0][j0] = "<"
				a[i1][j1] = ">"
print(*["".join(x) for x in a], sep="\n")

### FIXED CODE ###

import networkx as nx
from networkx.algorithms.bipartite import hopcroft_karp_matching

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

def inside(x, y):
	if 0 <= x < n and 0 <= y < m:
		return True
	else:
		return False

DI = [1, 0, -1, 0]
DJ = [0, 1, 0, -1]

a = [list(input()) for _ in range(n)]
g = nx.Graph()
g.add_nodes_from(range(n*m))
zero = True
top = set()
for i in range(n):
	for j in range(m):
		if a[i][j] == "#":
			continue
		if (i+j)%2 == 0:
			for k in range(4):
				di, dj = i+DI[k], j+DJ[k]
				if inside(di, dj) and a[di][dj] == ".":
					zero = False
					g.add_edge(i*m+j, di*m+dj)
					top.add(i*m+j)
if zero:
	print(0)
else:
	h = hopcroft_karp_matching(g, top_nodes=top)
	print(len(h)//2)
	for fr, to in h.items():
		i0, j0 = fr//m, fr%m
		i1, j1 = to//m, to%m
		if a[i0][j0] != ".":
			continue
		if i1 == i0+1:
			a[i0][j0] = "v"
			a[i1][j1] = "^"
		elif i1 == i0-1:
			a[i0][j0] = "^"
			a[i1][j1] = "v"
		elif j1 == j0+1:
			a[i0][j0] = ">"
			a[i1][j1] = "<"
		else:
			a[i0][j0] = "<"
			a[i1][j1] = ">"
print(*["".join(x) for x in a], sep="\n")
a,b = map(int,input().split())

if((a+b)%2 == 1):
    print((a+b)//2+1)
else:
    print((a+b)//)

### FIXED CODE ###

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

if((a+b)%2 == 1):
    print((a+b)//2+1)
else:
    print((a+b)//2)
the_string = raw_input()
S, T = the_string.split()
print(T.strip()+S.strip())



### FIXED CODE ###

the_string = raw_input()
S, T = the_string.split()
print(T.strip()+S.strip())
# coding: utf-8
# 整数の入力
#a = int(raw_input())
# スペース区切りの整数の入力
import numpy as np

N, MaxTotalWeight = map(int, raw_input().split())

def getWeightValuePair(W,Values,WeightValuePair):
    totalValue = 0
    WeightKeys = WeightValuePair.keys()
    WeightValuePairCopy = WeightValuePair.copy()
    for i in range(len(Values)):
        totalValue += Values[i]
        for totalWeight in WeightKeys:
            if (totalWeight + W * (i+1)) <= MaxTotalWeight:
                if (totalWeight + W * (i+1)) not in WeightValuePair:
                    WeightValuePair[totalWeight + W * (i+1)] = WeightValuePairCopy[totalWeight] +  totalValue
                elif WeightValuePairCopy[totalWeight] +  totalValue > WeightValuePairCopy[totalWeight + W * (i+1)]:
                    WeightValuePair[totalWeight + W * (i+1)] = WeightValuePairCopy[totalWeight] +  totalValue
    return WeightValuePair

Weights = []
WeightsValues = []

for i in xrange(N):
    tempData = map(int, raw_input().split())        
    if i == 0:
        Weights.append(tempData[0])
        Weights.append(tempData[0]+1)
        Weights.append(tempData[0]+2)
        Weights.append(tempData[0]+3)
        WeightsValues.append([tempData[1]])
        WeightsValues.append([])
        WeightsValues.append([])
        WeightsValues.append([])
    else:
        WeightsValues[tempData[0] - Weights[0]].append(tempData[1])

for data in WeightsValues:
    data.sort(reverse=True)

returnWeightValuePair = {0:0}
for i in range(4):
    returnWeightValuePair = getWeightValuePair(Weights[i],WeightsValues[i],returnWeightValuePair)

print long(max(returnWeightValuePair.values()))

### FIXED CODE ###

N, W = map(int, raw_input().split())
X = [map(int, raw_input().split()) for _ in range(N)]
 
dp = {}
dp[0] = 0
 
for w, v in X:
    d = dp.copy()
    for k in d:
        if k + w > W:
            continue
        if k + w in dp:
            dp[k + w] = max(dp[k + w], d[k] + v)
        else:
            dp[k + w] = d[k] + v
 
print max(dp.values())
A = list(input())
B = round(len(A) / 2)
A.pop(B - 1)
R = 0
C = A[0:B-1]
D = A[-(B - 1):]
D.sort(reverse=True)
count = 0
for i in range(B - 1):
	if C[count] != D[count]:
	R += 1
	count += 1
print(str(R))

### FIXED CODE ###

A = list(input())
import math
B = math.ceil(len(A) / 2)
R = 0
C = A[0:B]
D = A[-B:]
D = D[::-1]
count = 0
for i in range(B):
	if C[count] != D[count]:
		R += 1
	count += 1
print(str(R))
import pysnooper
import tabulate

n = int(input())
initial_vals = list(map(int, input().split(" ")))


@pysnooper.snoop()
def calculate_paths(vals):

    if len(vals) == 3:
        return min(abs(vals[0] - vals[2]), abs(vals[0] - vals[1]))
    elif len(vals) == 2:
        return abs(vals[0] - vals[1])
    elif len(vals) > 3:
        return min(
            calculate_paths(vals[:-1]) + abs(vals[-2] - vals[-1]),
            calculate_paths(vals[:-2]) + calculate_paths(vals[-3:-1]),
        )
    else:
        print("weird:" + str(vals))


table = [[None for x in range(n)] for x in range(n)]

for i in range(n - 1):
    table[i][i + 1] = abs(initial_vals[i] - initial_vals[i + 1])
    if len(initial_vals) > i + 2:
        table[i][i + 2] = abs(initial_vals[i] - initial_vals[i + 2])


def calc(from_stone, to_stone):
    if (to_stone - from_stone) == 1:
        return table[from_stone][to_stone]
    elif (to_stone - from_stone) == 2:
        return min(
            table[from_stone][to_stone],
            table[from_stone][to_stone - 1] + table[to_stone - 1][to_stone],
        )
    else:
        table[from_stone][to_stone] = min(
            calc(from_stone, to_stone - 1) + table[to_stone - 1][to_stone],
            calc(from_stone, to_stone - 2) + table[to_stone - 2][to_stone],
        )
        return table[from_stone][to_stone]


print(calc(0, n - 1))


### FIXED CODE ###

n = int(input())
initial_vals = list(map(int, input().split(" ")))


# print(calc(0, n - 1))


arr = [0 for x in range(n)]

arr[1] = abs(initial_vals[0] - initial_vals[1])

for i in range(2, len(arr)):
    arr[i] = min(
        arr[i - 1] + abs(initial_vals[i - 1] - initial_vals[i]),
        arr[i - 2] + abs(initial_vals[i - 2] - initial_vals[i]),
    )

print(arr[n - 1])
import numpy as np
from numpy.random import *

def quicksort(array):
    if len(array) < 2:
        return array
    else:
        pivot = array[0]
        less = [i for i in array[1:] if i <= pivot]

        greater = [i for i in array[1:] if i > pivot]

        return quicksort(less) + [pivot] + quicksort(greater)


array = randint(1, 1000, 10) 
sorted_array = quicksort(array)
print(sorted_array[2])
print(sorted_array[1])
print(sorted_array[0])

### FIXED CODE ###

array = []
for _ in range(10):
    array.append(int(input()))

sorted_array = sorted(array,reverse=True)
for i in range(3):
    print(sorted_array[i])
import sympy
n = int(input())
ans=0
for i in range(1,n):
    ans+=len(sympy.divisors(n-i))
print(ans)

### FIXED CODE ###

n = int(input())
ans=0
for i in range(1,n):
    ans+=int((n-1)/i)
print(ans)
S=input()
L=len(S)
for i in range(100):
    S=S.replace("01","")
    S=S.replace("10","")
print(L-L2)


### FIXED CODE ###

S=input()
print(len(S)-abs(S.count("1")-S.count("0")))
n,k = map(int, input().split())
s = list(map(str, input().split()))
k = k-1

for i in range(n):
  if i != k:
    print(s[i],end="")
  else:
    s[i].upper()
    print(s[i],end="")


### FIXED CODE ###

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

k = k-1

for i in range(n):
  if i == k:
    x = s[i].lower()
    print(x,end="")
  else:
    print(s[i],end="")
r,g,b, = map(str, raw_input())
s = int(r+g+b)
print 'YES' if s % 4 == 0 else 'NO'

### FIXED CODE ###

r,g,b, = map(str, raw_input().split())
s = int(r+g+b)
print 'YES' if s % 4 == 0 else 'NO'
import itertools

n,m,k = map(int,input().split())
a = list(map(int,('0 '+input()).split()))
b = list(map(int,('0 '+input()).split()))

asum = list(itertools.accumulate(a))
bsum = list(itertools.accumulate(b))

ans = 0
for i in range(n+1):
    for j in range(m,(ans-i)-1,-1):
        if asum[i]+bsum[j]<=k:
            ans = max(ans,i+j)
            break

print(ans)

### FIXED CODE ###

import itertools

n,m,k = map(int,input().split())
a = list(map(int,('0 '+input()).split()))
b = list(map(int,('0 '+input()).split()))

asum = list(itertools.accumulate(a))
bsum = list(itertools.accumulate(b))

ans = 0
j=m
for i in range(n+1):
    if asum[i]>k:
        break
    
    while asum[i]+bsum[j]>k:
        j-=1
        
    ans = max(ans,i+j)

print(ans)
a,b=map(int,input().split())
aa=[a,b]
if a<b:
  aa+=list(range(a+1,b))
z=aa.count(0)
n=sum([1 for i in aa if i<0])%2
if z>0:
  print('Zero')
elif n==0:
  print("Positive")
else:
  print("Negative")

### FIXED CODE ###

a,b=map(int,input().split())
a=min(1,a)
b=min(1,b)
if b==1 and a<=0:
  print('Zero')
elif b==0:
  print('Zero')
elif (b-a)%2==0 and b<0:
  print("Negative")
else:
  print("Positive")
x1, y1, x2, y2 = map(float, input().split())
import math
print("{0???.8???}".format(math.sqrt(x1*x2 + y1*y2)))

### FIXED CODE ###

x1, y1, x2, y2 = map(float, input().split())
import math
ans = math.sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2))
print("{0:.8f}".format(ans))
n = int(input())

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

ans = 1

for a in alis:
  	ans *= a
	if ans > 10**18:
		ans = -1
		break

print(ans)


### FIXED CODE ###

n = int(input())

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

ans = 1

if 0 in alis:
  print(0)
  exit()

for a in alis:
	ans *= a
	if ans > 10**18:
		ans = -1
		break

print(ans)
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=sum(a)
for i in range(n):
    if a[i]>=b/(4*m):
        a[i]=x
if a.count(x)>=m:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
b=sum(a)
for i in range(n):
    if a[i]>=b/(4*m):
        a[i]=-1
if a.count(-1)>=m:
    print('Yes')
else:
    print('No')
a,b,c,d = map(int,input().split())
print(max(a,b)*max(c,d))


### FIXED CODE ###

x = int(input())
if x == 0:
    print('1')
else:
    print('0')
l=list(map(int, input().split()))
print(max(l[0]*l[1],l[2]*l[3])


### FIXED CODE ###

l=list(map(int, input().split()))
print(max(l[0]*l[1],l[2]*l[3]))
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
S = input()[:-1]

if S[0]=='W':
    print(0)
    exit()
    
l = [0]
ans = 1
MOD = 10**9+7

for i in range(1, 2*N):
    if S[i]==S[i-1]:
        l.append(1^l[-1])
    else:
        l.append(l[-1])

if l.count(0)!=n:
    print(0)
    exit()
    
zero = 0

for li in l:
    if li==0:
        zero += 1
    else:
        ans *= zero
        ans %= MOD
        zero -= 1
        
for i in range(1, N+1):
    ans *= i
    ans %= MOD

print(ans)

### FIXED CODE ###

N = int(input())
S = list(input())

for i in range(2*N):
    if (2*N-i)%2==1:
        S[i] = 'B' if S[i]=='W' else 'W'
        
if S.count('B')!=N:
    print(0)
    exit()

ans = 1
MOD = 10**9+7
B = 0

for Si in S:
    if Si=='B':
        B += 1
    else:
        ans *= B
        ans %= MOD
        B -= 1

fact = [1]

for i in range(1, N+1):
    fact.append(fact[-1]*i%MOD)

ans *= fact[N]
ans %= MOD

print(ans)
def kaibunCheck(s):
  flag = True
    n = len(s)
    for i in range((n + 1) // 2):
      if s[i] != s[(i + 1) * (-1)]:
        flag = False
    
  return flag
        
S = input()
N = len(S)

S1 = S[:(N - 1) // 2]
S2 = S[(N + 1) // 2 :]

if kaibunCheck(S) == True and kaibunCheck(S1) == True and kaibunCheck(S2) == True:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

def kaibunCheck(s):
  flag = True
  n = len(s)
  for i in range((n + 1) // 2):
    if s[i] != s[(i + 1) * (-1)]:
      flag = False

  return flag
        
S = input()
N = len(S)

S1 = S[:(N - 1) // 2]
S2 = S[(N + 1) // 2 :]

if kaibunCheck(S) == True and kaibunCheck(S1) == True and kaibunCheck(S2) == True:
  print("Yes")
else:
  print("No")
N, M = map(int, input().split())

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

Bs_and_Cs_lst = []

for _ in range(M):
    B, C = map(int, input().split())

    Bs_and_Cs_lst.append((C, B))


As_lst.sort()
Bs_and_Cs_lst.sort(reverse=True)


p = 0
finish = False
for C, B in Bs_and_Cs_lst:
    for i in range(B):
        if As_lst[p+i] < C:
            As_lst[p+i] = C
        else:
            finish = True
            break
    if finish:
        break
    p += B


max_count = 0
for i in range(N):
    max_count += As_lst[i]

print(max_count)

### FIXED CODE ###


N, M = map(int, input().split())

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

Bs_and_Cs_lst = []

for _ in range(M):
    B, C = map(int, input().split())

    Bs_and_Cs_lst.append((C, B))


As_lst.sort()
Bs_and_Cs_lst.sort(reverse=True)


p = 0
finish = False
for C, B in Bs_and_Cs_lst:
    for i in range(B):
        if p + i >= N:
            finish = True
            break

        if As_lst[p+i] < C:
            As_lst[p+i] = C
        else:
            finish = True
            break
    if finish:
        break
    p += B


max_count = 0
for i in range(N):
    max_count += As_lst[i]

print(max_count)
import math
r=int(input())
S=r*r*math.pi
L=2*r*math.pi
print('%.6f %.6f'%(S,L))

### FIXED CODE ###

import math
r=float(input())
S=r*r*math.pi
L=2*r*math.pi
print('%.5f %.5f'%(S,L))
h,w=map(int,input().split())
a,l=[list(input())for i in range(h)],[0]*26
for i in a:
 for j in i:l[ord(j)-97]+=1
o,t,f=(h//2)*(w//2),(h//2)*(w%2)+(w//2)*(h%2),(h%2)*(w%2)
for i in l:
 while o and i>3:o-=1;i-=4
 while t and i>1:t-=1i-=2
 f-=i
print("Yes"if o==t==f==0else"No")

### FIXED CODE ###

h,w=map(int,input().split())
a,l=[list(input())for i in range(h)],[0]*26
for i in a:
 for j in i:l[ord(j)-97]+=1
o,t,f=(h//2)*(w//2),(h//2)*(w%2)+(w//2)*(h%2),(h%2)*(w%2)
for i in l:
 while o and i>3:o-=1;i-=4
 while t and i>1:t-=1;i-=2
 f-=i
print("Yes"if o==t==f==0else"No")
from collections import Counter
n=int(input())
x=[]
y=[]
for i in range(n):
  X,Y=map(int,input().split())
  x.append(X)
  y.append(Y)
z=[]
for j in range(n):
  for k in range(j+1,n):
    z.append((x[j]-x[k],y[j]-y[k]))
m=z.most_common()[0][1]
print(n-m)


    
    
    

### FIXED CODE ###

from collections import Counter
import sys
n=int(input())
lst=[]
for i in range(n):
  X,Y=map(int,input().split())
  lst.append([X,Y])
lst_2=sorted(lst,key=lambda x: x[0])
lst_3=sorted(lst,key=lambda x: x[1])
z=[]
if n==1:
  print(1)
  sys.exit()
else:
  for j in range(n):
    for k in range(j+1,n):
      z.append((lst_2[j][0]-lst_2[k][0],lst_2[j][1]-lst_2[k][1]))
u=[]
if n==1:
  print(1)
  sys.exit()
else:
  for j in range(n):
    for k in range(j+1,n):
      u.append((lst_3[j][0]-lst_3[k][0],lst_3[j][1]-lst_3[k][1]))
Z=Counter(z)
U=Counter(u)
m=max(Z.most_common()[0][1],U.most_common()[0][1])
print(n-m)
import math
 
a,b,n = map(int,input().split())
cnt = 0
t = 0
if n<=b:
    #print(math.floor(a*n/b))
    exit()
for i in range(math.floor(n/b)):
    t = math.floor(a*(b(i+1))/b)-a*i
    #print("a")
    if cnt <= t:
        cnt=t
            
print(cnt)

### FIXED CODE ###

import math
 
a,b,n = map(int,input().split())
cnt = 0
t = 0
if n<=b-1:
    print(math.floor(a*n/b))
#    exit()
else:
    print(math.floor(a*(b-1)/b))
A, B = map(int, input().split())
1 <= B <= A <= 20
 
if A % B == 0：
    print(A+B)
else:
    print(A-B)

### FIXED CODE ###

A, B = map(int, input().split())
 
if B % A == 0:
    print(A + B)
else:
    print(B - A)
import time
N=int(input())
H_list=[int(thing) for thing in input().split(" ")]
def is0(num):
    if num==0:
        time.sleep(3)
    else:pass


### FIXED CODE ###

N=int(input())
if N==0:
    print(0)
else:
    ret=int(N*(N-1)//2)
    print(ret)
n=int(input())
l=list(map(int,input.split()))
lis=l.sorted()
lis.reverse()
ans=0
for i ,j in zip(l,lis):
    if i!=j:
        ans+=1
if ans==2:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
lis=sorted(l)

ans=0
for i ,j in zip(l,lis):
   
    if i!=j:
        ans+=1
if ans<=2:
    print("YES")
else:
    print("NO")
A = int(input())
B = input()
b = int(B.replace(".",""))
print(A * b // 100)

### FIXED CODE ###

a, b = map(str, input().split())
a = int(a)
b = int(b.replace('.', ''))
print(a*b//100)
(S,W)=input()
if S<=W:
  print("unsafe")
else:
  print("safe")

### FIXED CODE ###

(S,W)=input().split()
S=int(S)
W=int(W)
if S<=W:
  print("unsafe")
else:
  print("safe")
s=input()
for i in range(len(s)):
	if s[i].islower():
		s[i]=s[i].upper()
	elif s[i].isupper():
		s[i]=s[i].lower()
print(s)

### FIXED CODE ###

s=list(input())
for i in range(len(s)):
	if s[i].isalnum():
		if s[i].islower():
			s[i]=s[i].upper()
		elif s[i].isupper():
			s[i]=s[i].lower()
print("".join(s))
A,B,C,D = map( int, input().split() )
while A > 0 and c > 0:
    C -= B
    if C <= 0:
        print( 'Yes' )
        exit()
    A -= D 
    if A <= 0:
        print( 'No' )
        exit()


### FIXED CODE ###

A,B,C,D = map(int, input().split())

while A > 0 and C > 0:
    C -= B
    if C <= 0:
        print("Yes")
        exit()
    A -= D
    if A <= 0:
        print("No")
        exit()
from math import gcd
n = int(input())
yakusuu = set()
ans = set()
for i in range(1, int((n-1)**(1/2))+1):
    if (n-1) % i == 0:
        yakusuu.add(i)
        yakusuu.add((n-1)//i)

for i in range(1, int(n**(1/2))+1):
    if n % i == 0:
        yakusuu.add(i)
        yakusuu.add(n//i)
yakusuu.remove(1)



for i in yakusuu:
    k = n
    if gcd(i, k) == 1:
        if k % i == 1:
            ans.add(i)
        continue

    k = n
    while k >= i:
        if k % i == 0:
            k //= i
        else:
            if k % i == 1:
                k = 1
            else:
                k = 0
    if k == 1:
        ans.add(i)

print(len(ans))


### FIXED CODE ###

from fractions import gcd
n = int(input())
yakusuu = set()
ans = set()
for i in range(1, int((n-1)**(1/2))+1):
    if (n-1) % i == 0:
        yakusuu.add(i)
        yakusuu.add((n-1)//i)

for i in range(1, int(n**(1/2))+1):
    if n % i == 0:
        yakusuu.add(i)
        yakusuu.add(n//i)
yakusuu.remove(1)



for i in yakusuu:
    k = n
    if gcd(i, k) == 1:
        if k % i == 1:
            ans.add(i)
        continue

    k = n
    while k >= i:
        if k % i == 0:
            k //= i
        else:
            if k % i == 1:
                k = 1
            else:
                k = 0
    if k == 1:
        ans.add(i)

print(len(ans))
s = string(input())

if (s=="Sunny"):
    print("Cloudy")
else if	(s=="Cloudy"):
    print("Rainy")
else if (s=="Rainy"):
    print("Sunny")

### FIXED CODE ###

s = str(raw_input())

if s=="Sunny":
    print ("Cloudy")
if s=="Cloudy":
    print ("Rainy")
if s=="Rainy":
    print ("Sunny")
i=int
k=input
N = i(k())
l = list(map(i,k().split()))
for j in range(n):
 lis[j] -= (j+1)
l.sort()
print(sum(list(map(lambda x: abs(x - l[N//2]),l))))

### FIXED CODE ###

N = int(input())
lis = list(map(int,input().split()))
for i in range(len(lis)):
  lis[i] -= (i+1)
lis.sort()
m = N // 2
c = lis[m]
print(sum(list(map(lambda x: abs(x - c), lis))))
from collections import deque
import testcase
H,W = map(int,input().split())
lst1 = [list(list(input())) for i in range(H)]

def dfs(maze,visited, sh, sw):
    a = 0
    stack = deque([[sh, sw]])
    visited[sh][sw] = 0
    while stack:
        h, w = stack.popleft()
        print(visited)
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]): #4近傍について探索
            new_h, new_w = h+j, w+k
            if new_h < 0 or new_h >= H or \
               new_w < 0 or new_w >= W: #リスト外でないならelif条件へ
                continue
            elif maze[new_h][new_w] != "#" and \
                visited[new_h][new_w] == 0: #行ったことがないかつ、壁でないなら
                visited[new_h][new_w] = visited[h][w]+1
                stack.append([new_h, new_w])
    a = 0
    for s in range(H):
        for x in range(W):
            a = max(a,visited[s][x])
    return a

ans = 0

for i in range(H):
    for q in range(W):
        visited = [[0]*W for _ in range(H)]
        if lst1[i][q] == ".":
            ans = max(ans,dfs(lst1,visited,i,q))
print(ans)


### FIXED CODE ###

from collections import deque
H,W = map(int,input().split())
lst1 = [list(list(input())) for i in range(H)]

def dfs(maze,visited, sh, sw):
    a = 0
    stack = deque([[sh, sw]])
    visited[sh][sw] = 1
    while stack:
        h, w = stack.popleft()
        #print(visited)
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]): #4近傍について探索
            new_h, new_w = h+j, w+k
            if new_h < 0 or new_h >= H or \
               new_w < 0 or new_w >= W: #リスト外でないならelif条件へ
                continue
            elif maze[new_h][new_w] != "#" and \
                visited[new_h][new_w] == 0: #行ったことがないかつ、壁でないなら
                visited[new_h][new_w] = visited[h][w]+1
                stack.append([new_h, new_w])
    a = 0
    for s in range(H):
        for x in range(W):
            a = max(a,visited[s][x])
    return a

ans = 0

for i in range(H):
    for q in range(W):
        visited = [[0]*W for _ in range(H)]
        if lst1[i][q] == ".":
            ans = max(ans,dfs(lst1,visited,i,q))
print(ans-1)
n,m=map(int,input().split())
l_list=[]
r_list=[]

for i in range(m):
    l,r=map(int,input().split())
    l_list.append(l)
    r_list.append(r)

n_card=min(r_list)-max(l_list)+1

if n_card<=0:
    print(0)
else:
    print(n_card)


### FIXED CODE ###

n,k = map(int, input().split())
x=0
i=0
pro=0.0
ans=0.0

for i in range(1,n+1):
    x=i
    j=0
    while x<k:
        j=j+1
        x=x*2
    pro=(1/n)*((1/2)**j)
    ans=ans+pro

print(ans)
a = input("日本語で文を入力してください -> ")
b = input("調べたい文字は -> ")
print(a.find(b))

### FIXED CODE ###

a = input()
if a == "Sunny":
    print("Cloudy")
elif a == "Cloudy":
    print("Rainy")
else :
    print("Sunny")
list = [int(x) for x in input().split()]
print(list[0] - list[1] + 1]

### FIXED CODE ###

list = [int(x) for x in input().split()]
print(list[0] - list[1] + 1)
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
print(1.0/sum(list(map(lambda x: 1.0 / x, a))))


### FIXED CODE ###

n = int(input())
v = list(map(int, input().split()))
#n = 3
#v = list(map(int, "500 300 200".split()))
v.sort()
ans = v[0]
for i in range(1,n):
    ans = (v[i] + ans)/2
print(ans)
hu

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
MOD=10**9+7
def findProductSum(A, n): 
    array_sum = 0
    for i in range(0, n, 1): 
        array_sum=array_sum+A[i]
    array_sum_square = array_sum * array_sum 
    individual_square_sum = 0
    for i in range(n): 
        individual_square_sum += A[i] * A[i]
    return (array_sum_square - individual_square_sum)//2

print(findProductSum(a,n)%MOD)