Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

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

for i in range(m):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b - 1].append(a - 1)

memo = [0 for i in range(n)]
color = [-1 for i in range(n)]
black = 0
white = 0
flag = 0


def search(v):
    for i in graph[v]:
        if memo[i] == 0:
            memo[i] = 1
            color[i] = (color[v] + 1) % 2
            if color[i] == 0:
                global black
                black += 1
            else:
                global white
                white += 1
            search(i)
        else:
            if color[v] == color[i]:
                global flag
                flag = 1

memo[0] = 1
color[0] = 0
black += 1
search(0)

if flag == 1:
    print(n*(n-1)//2 - m)
else:
    print(black * white - m)

Fixed submission:
import sys
sys.setrecursionlimit(10**8)
n, m = map(int, input().split())

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

for i in range(m):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b - 1].append(a - 1)

memo = [0 for i in range(n)]
color = [-1 for i in range(n)]
black = 0
white = 0
flag = 0


def search(v):
    for i in graph[v]:
        if memo[i] == 0:
            memo[i] = 1
            color[i] = (color[v] + 1) % 2
            if color[i] == 0:
                global black
                black += 1
            else:
                global white
                white += 1
            search(i)
        else:
            if color[v] == color[i]:
                global flag
                flag = 1

memo[0] = 1
color[0] = 0
black += 1
search(0)

if flag == 1:
    print(n*(n-1)//2 - m)
else:
    print(black * white - m)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())

graph = [[0 for i in range(n)] for j in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    graph[a-1][b-1] = 1
    graph[b-1][a-1] = 1

memo = [0 for i in range(n)]
color = [-1 for i in range(n)]
black = 0
white = 0
flag = 0


def search(v):
    for i in range(n):
        if graph[v][i] == 1:
            if memo[i] == 0:
                memo[i] = 1
                color[i] = (color[v]+1) % 2
                if color[i] == 0:
                    global black
                    black += 1
                else:
                    global white
                    white += 1
                search(i)
            else:
                if color[v] == color[i]:
                    global flag
                    flag = 1

memo[0] = 1
color[0] = 0
black += 1
search(0)

if flag == 1:
    print(n*(n-1)//2 - m)
else:
    print(black * white - m)

Fixed submission:
import sys
sys.setrecursionlimit(10**8)
n, m = map(int, input().split())

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

for i in range(m):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b - 1].append(a - 1)

memo = [0 for i in range(n)]
color = [-1 for i in range(n)]
black = 0
white = 0
flag = 0


def search(v):
    for i in graph[v]:
        if memo[i] == 0:
            memo[i] = 1
            color[i] = (color[v] + 1) % 2
            if color[i] == 0:
                global black
                black += 1
            else:
                global white
                white += 1
            search(i)
        else:
            if color[v] == color[i]:
                global flag
                flag = 1

memo[0] = 1
color[0] = 0
black += 1
search(0)

if flag == 1:
    print(n*(n-1)//2 - m)
else:
    print(black * white - m)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

graph = [[0 for i in range(n)] for j in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    graph[a][b] = 1
    graph[b][a] = 1

memo = [0 for i in range(n)]
color = [-1 for i in range(n)]
black = 0
white = 0
flag = 0


def search(v):
    for i in range(n):
        if graph[v][i] == 1:
            if memo[i] == 0:
                memo[i] = 1
                color[i] = (color[v]+1) % 2
                if color[i] == 0:
                    global black
                    black += 1
                else:
                    global white
                    white += 1
                search(i)
            else:
                if color[v] == color[i]:
                    global flag
                    flag = 1

memo[0] = 1
color[0] = 0
search(0)

if flag == 1:
    print(n*(n+1)/2 - m)
else:
    print(black * white - m)

Fixed submission:
import sys
sys.setrecursionlimit(10**8)
n, m = map(int, input().split())

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

for i in range(m):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b - 1].append(a - 1)

memo = [0 for i in range(n)]
color = [-1 for i in range(n)]
black = 0
white = 0
flag = 0


def search(v):
    for i in graph[v]:
        if memo[i] == 0:
            memo[i] = 1
            color[i] = (color[v] + 1) % 2
            if color[i] == 0:
                global black
                black += 1
            else:
                global white
                white += 1
            search(i)
        else:
            if color[v] == color[i]:
                global flag
                flag = 1

memo[0] = 1
color[0] = 0
black += 1
search(0)

if flag == 1:
    print(n*(n-1)//2 - m)
else:
    print(black * white - m)