Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
N,M=list(map(int,raw_input().split()))

nl=[[] for i in range(N+1)]
for i in range(M):
	x,y=map(int,raw_input().split())
	nl[x].append(y)
	nl[y].append(x)	
#print nl


def dfs(v):
	F[v]=1
	for i in nl[v]:
		if color[v]=="w" and color[i]==0:
			color[i]="b"
		elif color[v]=="b" and color[i]==0:
			color[i]="w"				
		elif color[v]==color[i]:
			#２部グラフではない
			print N*(N-1)/2-M
			sys.exit()
		else:
			continue
		#print v,i,color,F
		
		if F[i]==0:
			dfs(i)


F=[0]*(N+1)
color=[0]*(N+1)
color[1]="w"
dfs(1)

#２部グラフの場合
print color.count("b")*color.count("w")-M




Fixed submission:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**7)
N,M=list(map(int,raw_input().split()))

nl=[[] for i in range(N+1)]
for i in range(M):
	x,y=map(int,raw_input().split())
	nl[x].append(y)
	nl[y].append(x)	
#print nl


def dfs(v):
	F[v]=1
	for i in nl[v]:
		if color[v]=="w" and color[i]==0:
			color[i]="b"
		elif color[v]=="b" and color[i]==0:
			color[i]="w"				
		elif color[v]==color[i]:
			#２部グラフではない
			print N*(N-1)/2-M
			sys.exit()
		else:
			continue
		#print v,i,color,F
		
		if F[i]==0:
			dfs(i)


F=[0]*(N+1)
color=[0]*(N+1)
color[1]="w"
dfs(1)

#２部グラフの場合
print color.count("b")*color.count("w")-M

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
N,M=list(map(int,raw_input().split()))

nl=[[] for i in range(N+1)]
for i in range(M):
	x,y=map(int,raw_input().split())
	nl[x].append(y)
	nl[y].append(x)	
#print nl


def dfs(v):
	F[v]=1
	for i in nl[v]:
		if color[v]=="w" and color[i]==0:
			color[i]="b"
		elif color[v]=="b" and color[i]==0:
			color[i]="w"				
		elif color[v]==color[i]:
			#２部グラフではない
			print N*(N-1)/2-M
			sys.exit()
		#print v,i,color,F
		
		if F[i]==0:
			dfs(i)


F=[0]*(N+1)
color=[0]*(N+1)
color[1]="w"
dfs(1)

#２部グラフの場合
print color.count("b")*color.count("w")-M




Fixed submission:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**7)
N,M=list(map(int,raw_input().split()))

nl=[[] for i in range(N+1)]
for i in range(M):
	x,y=map(int,raw_input().split())
	nl[x].append(y)
	nl[y].append(x)	
#print nl


def dfs(v):
	F[v]=1
	for i in nl[v]:
		if color[v]=="w" and color[i]==0:
			color[i]="b"
		elif color[v]=="b" and color[i]==0:
			color[i]="w"				
		elif color[v]==color[i]:
			#２部グラフではない
			print N*(N-1)/2-M
			sys.exit()
		else:
			continue
		#print v,i,color,F
		
		if F[i]==0:
			dfs(i)


F=[0]*(N+1)
color=[0]*(N+1)
color[1]="w"
dfs(1)

#２部グラフの場合
print color.count("b")*color.count("w")-M

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
N,M=list(map(int,raw_input().split()))

nl=[[] for i in range(N+1)]
for i in range(M):
	x,y=map(int,raw_input().split())
	nl[x].append(y)
	nl[y].append(x)	
#print nl


def dfs(v,p):
	F[v]=1
	for i in nl[v]:
		if color[v]=="w" and color[i]==0:
			color[i]="b"
		elif color[v]=="b" and color[i]==0:
			color[i]="w"				
		elif color[v]==color[i]:
			#２部グラフではない
			print N*(N-1)/2-M
			sys.exit()
		#print v,i,color,F
		
		if F[i]==0:
			#DFS(次の頂点i, 次に親となる頂点v)
			#print "dfs::"+str(i)
			dfs(i,v)


F=[0]*(N+1)
color=[0]*(N+1)
color[1]="w"
dfs(1,-1)

#２部グラフの場合
print color.count("b")*color.count("w")-M


Fixed submission:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**7)
N,M=list(map(int,raw_input().split()))

nl=[[] for i in range(N+1)]
for i in range(M):
	x,y=map(int,raw_input().split())
	nl[x].append(y)
	nl[y].append(x)	
#print nl


def dfs(v):
	F[v]=1
	for i in nl[v]:
		if color[v]=="w" and color[i]==0:
			color[i]="b"
		elif color[v]=="b" and color[i]==0:
			color[i]="w"				
		elif color[v]==color[i]:
			#２部グラフではない
			print N*(N-1)/2-M
			sys.exit()
		else:
			continue
		#print v,i,color,F
		
		if F[i]==0:
			dfs(i)


F=[0]*(N+1)
color=[0]*(N+1)
color[1]="w"
dfs(1)

#２部グラフの場合
print color.count("b")*color.count("w")-M

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
N,M=list(map(int,raw_input().split()))

nl=[[] for i in range(N+1)]
for i in range(M):
	x,y=map(int,raw_input().split())
	nl[x].append(y)
	nl[y].append(x)	
#print nl


def dfs(v,p):
	F[v]=1
	global bip_graph
	for i in nl[v]:
		if color[v]=="w" and color[i]==0:
			color[i]="b"
		elif color[v]=="b" and color[i]==0:
			color[i]="w"				
		elif color[v]==color[i]:
			#二分木ではない
			print N*(N-1)/2-M
			sys.exit()
		#print v,i,color,F
		
		if F[i]==0:
			#DFS(次の頂点i, 次に親となる頂点v, d+ 頂点vと頂点iの間の辺のコスト)
			dfs(i,v)


bip_graph="YES"
F=[0]*(N+1)
color=[0]*(N+1)
color[1]="w"
dfs(1,-1)


print color.count("b")*color.count("w")-M





Fixed submission:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**7)
N,M=list(map(int,raw_input().split()))

nl=[[] for i in range(N+1)]
for i in range(M):
	x,y=map(int,raw_input().split())
	nl[x].append(y)
	nl[y].append(x)	
#print nl


def dfs(v):
	F[v]=1
	for i in nl[v]:
		if color[v]=="w" and color[i]==0:
			color[i]="b"
		elif color[v]=="b" and color[i]==0:
			color[i]="w"				
		elif color[v]==color[i]:
			#２部グラフではない
			print N*(N-1)/2-M
			sys.exit()
		else:
			continue
		#print v,i,color,F
		
		if F[i]==0:
			dfs(i)


F=[0]*(N+1)
color=[0]*(N+1)
color[1]="w"
dfs(1)

#２部グラフの場合
print color.count("b")*color.count("w")-M

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N,M=list(map(int,raw_input().split()))

nl=[[] for i in range(N+1)]
for i in range(M):
	x,y=map(int,raw_input().split())
	nl[x].append(y)
	nl[y].append(x)	
#print nl


def dfs(v,p):
	F[v]=1
	global bip_graph
	for i in nl[v]:

		if color[v]=="w" and color[i]==0:
			color[i]="b"
		elif color[v]=="b" and color[i]==0:
			color[i]="w"				
		elif color[v]==color[i]:
			#二分木ではない
			bip_graph="NO"
		#print v,i,color,F
		
		if bip_graph!="NO" and F[i]==0:
			#DFS(次の頂点i, 次に親となる頂点v, d+ 頂点vと頂点iの間の辺のコスト)
			dfs(i,v)


bip_graph="YES"
F=[0]*(N+1)
color=[0]*(N+1)
color[1]="b"
dfs(1,-1)
#print nl
#print color
#print bip_graph


if bip_graph=="YES":
	print color.count("b")*color.count("w")-M
elif bip_graph=="NO":
	print N*(N-1)/2-M




Fixed submission:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**7)
N,M=list(map(int,raw_input().split()))

nl=[[] for i in range(N+1)]
for i in range(M):
	x,y=map(int,raw_input().split())
	nl[x].append(y)
	nl[y].append(x)	
#print nl


def dfs(v):
	F[v]=1
	for i in nl[v]:
		if color[v]=="w" and color[i]==0:
			color[i]="b"
		elif color[v]=="b" and color[i]==0:
			color[i]="w"				
		elif color[v]==color[i]:
			#２部グラフではない
			print N*(N-1)/2-M
			sys.exit()
		else:
			continue
		#print v,i,color,F
		
		if F[i]==0:
			dfs(i)


F=[0]*(N+1)
color=[0]*(N+1)
color[1]="w"
dfs(1)

#２部グラフの場合
print color.count("b")*color.count("w")-M

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N,M=list(map(int,raw_input().split()))

nl=[[] for i in range(N+1)]
for i in range(M):
	x,y=map(int,raw_input().split())
	nl[x].append(y)
	nl[y].append(x)	
#print nl


def dfs(v,p):
	F[v]=1
	global bip_graph
	for i in nl[v]:
		#print v,i,color
		if color[v]=="w" and color[i]==0:
			color[i]="b"
		elif color[v]=="b" and color[i]==0:
			color[i]="w"				
		elif color[v]==color[i]:
			#二分木ではない
			bip_graph="NO"

		if bip_graph!="NO" and F[i]==0:
			#DFS(次の頂点i, 次に親となる頂点v, d+ 頂点vと頂点iの間の辺のコスト)
			dfs(i,v)


bip_graph="YES"
F=[0]*(N+1)
color=[0]*(N+1)
color[1]="b"
dfs(1,-1)
#print color
#print bip_graph

if bip_graph=="YES":
	print color.count("b")*color.count("w")-M
elif bip_graph=="NO":
	print N*(N-1)/2-M




Fixed submission:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**7)
N,M=list(map(int,raw_input().split()))

nl=[[] for i in range(N+1)]
for i in range(M):
	x,y=map(int,raw_input().split())
	nl[x].append(y)
	nl[y].append(x)	
#print nl


def dfs(v):
	F[v]=1
	for i in nl[v]:
		if color[v]=="w" and color[i]==0:
			color[i]="b"
		elif color[v]=="b" and color[i]==0:
			color[i]="w"				
		elif color[v]==color[i]:
			#２部グラフではない
			print N*(N-1)/2-M
			sys.exit()
		else:
			continue
		#print v,i,color,F
		
		if F[i]==0:
			dfs(i)


F=[0]*(N+1)
color=[0]*(N+1)
color[1]="w"
dfs(1)

#２部グラフの場合
print color.count("b")*color.count("w")-M

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
N,M=list(map(int,raw_input().split()))

nl=[[0]*(N+1) for i in range(N+1)]
a=[0]*M
for i in range(M):
	x,y=map(int,raw_input().split())
	nl[x][y]=1
	nl[y][x]=1	
#print nl

def dfs(v,p):
	#print v,p,color
	global bip_graph
	F[v]=1

	for j in range(N+1):

		#色塗り
		if nl[v][j]!=0:
			#print v,j,color
			if color[v]=="w" and color[j]==0:
				color[j]="b"
			elif color[v]=="b" and color[j]==0:
				color[j]="w"				
			elif color[v]==color[j]:
				#二分木ではない
				bip_graph="NO"


		#頂点 v に隣接しているかつ未訪問
		if bip_graph!="NO" and nl[v][j]!=0 and F[j]==0:
			#DFS(次の頂点i, 次に親となる頂点v, d+ 頂点vと頂点iの間の辺のコスト)
			
			dfs(j,v)


bip_graph="YES"
color=[0]*(N+1)
F=[0]*(N+1)
color[1]="b"
dfs(1,-1)
#print bip_graph
#print color

if bip_graph=="YES":
	print color.count("b")*color.count("w")-M
elif bip_graph=="NO":
	print N*(N-1)/2-M



Fixed submission:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**7)
N,M=list(map(int,raw_input().split()))

nl=[[] for i in range(N+1)]
for i in range(M):
	x,y=map(int,raw_input().split())
	nl[x].append(y)
	nl[y].append(x)	
#print nl


def dfs(v):
	F[v]=1
	for i in nl[v]:
		if color[v]=="w" and color[i]==0:
			color[i]="b"
		elif color[v]=="b" and color[i]==0:
			color[i]="w"				
		elif color[v]==color[i]:
			#２部グラフではない
			print N*(N-1)/2-M
			sys.exit()
		else:
			continue
		#print v,i,color,F
		
		if F[i]==0:
			dfs(i)


F=[0]*(N+1)
color=[0]*(N+1)
color[1]="w"
dfs(1)

#２部グラフの場合
print color.count("b")*color.count("w")-M

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
N,M=list(map(int,raw_input().split()))

nl=[[0]*(N+1) for i in range(N+1)]
a=[0]*M
for i in range(M):
	x,y=map(int,raw_input().split())
	nl[x][y]=1
	nl[y][x]=1	
#print nl

def dfs(v,p):
	global bip_graph
	F[v]=1

	for j in range(N+1):

		#色塗り
		if nl[v][j]!=0:
			#print v,j,color
			if color[v]=="w" and color[j]==0:
				color[j]="b"
			elif color[v]=="b" and color[j]==0:
				color[j]="w"				
			elif color[v]==color[j]:
				#二分木ではない
				bip_graph="NO"


		#頂点 v に隣接しているかつ未訪問
		if nl[v][j]!=0 and F[j]==0:
			#DFS(次の頂点i, 次に親となる頂点v, d+ 頂点vと頂点iの間の辺のコスト)
			
			dfs(j,v)


bip_graph="YES"
color=[0]*(N+1)
F=[0]*(N+1)
color[1]="b"
dfs(1,-1)
#print bip_graph
#print color

if bip_graph=="YES":
	print color.count("b")*color.count("w")-M
elif bip_graph=="NO":
	print N*(N-1)/2-M



Fixed submission:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**7)
N,M=list(map(int,raw_input().split()))

nl=[[] for i in range(N+1)]
for i in range(M):
	x,y=map(int,raw_input().split())
	nl[x].append(y)
	nl[y].append(x)	
#print nl


def dfs(v):
	F[v]=1
	for i in nl[v]:
		if color[v]=="w" and color[i]==0:
			color[i]="b"
		elif color[v]=="b" and color[i]==0:
			color[i]="w"				
		elif color[v]==color[i]:
			#２部グラフではない
			print N*(N-1)/2-M
			sys.exit()
		else:
			continue
		#print v,i,color,F
		
		if F[i]==0:
			dfs(i)


F=[0]*(N+1)
color=[0]*(N+1)
color[1]="w"
dfs(1)

#２部グラフの場合
print color.count("b")*color.count("w")-M