Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02658 (python)

Fixed submission:
#!/usr/bin/env python3
n = int(input()) 
A = list(map(int, input().split()))
b = 1
i = 10**18
A = sorted(A)
for a in A:
  if b > i:
    break
  b *= a
print(-1 if b > i else b)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
from decimal import Decimal
a, b = input().split()
a = Decimal(int(a))
b = Decimal(b)
print(int(a * b))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import numpy as np
from decimal import Decimal
n = int(input()) 
A = list(map(Decimal, input().split()))
i = 10 ** 18
ans = int(np.prod(A))
if ans > i:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import numpy as np
n = int(input()) 
A = list(map(int, input().split()))
i = 10 ** 18
ans = np.prod(A)
elif ans > i:
    print(-1)
else:
    print(int(ans))
Problem p02761 (python)

Fixed submission:
import sys
N, M = map(int, input().split())
d = {}
for _ in range(M):
  s, c = input().split()
  if s in d and d[s] != c:
    print("-1")
    sys.exit()
  else:
    d[s] = c
    
if N == 3:
  if "1" in d and d["1"] == "0":
    print("-1")
    sys.exit()
  else:
    if "1" not in d:
      a = "1"
    else:
      a = d["1"]
    if "2" in d:
      b = d["2"]
    else:
      b = "0"
    if "3" in d:
      c = d["3"]
    else:
      c = "0"
  print(a + b + c)
  sys.exit()
  
if N == 2:
  if "1" in d and d["1"] == "0":
    print("-1")
    sys.exit()
  else:
    if "1" in d:
      b = d["1"]
    else:
      b = "1"
    if "2" in d:
      c = d["2"]
    else:
      c = "0"
  print(b + c)
  sys.exit()
  
if N == 1:
  if "1" in d and d["1"] == "0":
    print("0")
    sys.exit()
  else:
    if "1" in d:
      c = d["1"]
    else:
      c = "0"
  print(c)

Buggy submission (verdict: Runtime Error):
import sys
N, M = map(int, input().split())
d = {}
for _ in range(M):
  s, c = input().split()
  if s in d and d[s] != c:
    print("-1")
    sys.exit()
  else:
    d[s] = c
if N == 3:
  if d["1"] == "0":
    print("-1")
    sys.exit()
  else:
    if "1" not in d:
      a = "1"
    else:
      a = d["1"]
    if "2" in d:
      b = d["2"]
    else:
      b = "0"
    if "3" in d:
      c = d["3"]
    else:
      c = "0"
  print(a + b + c)
  sys.exit()
  
if N == 2:
  if d["2"] == "0":
    print("-1")
    sys.exit()
  else:
    if "2" in d:
      b = d["2"]
    else:
      b = "0"
    if "3" in d:
      c = d["3"]
    else:
      c = "0"
  print(b + c)
  sys.exit()
  
if N == 1:
  if d["3"] == "0":
    print("-1")
    sys.exit()
  else:
    if "3" in d:
      c = d["3"]
    else:
      c = "0"
  print(c)
Problem p02885 (python)

Fixed submission:
A, B = map(int, input().split())
if A < B*2:
  print(0)
else:
  print(A-B*2)

Buggy submission (verdict: Runtime Error):
 A, B = map(int, input().split())
if A < B*2:
  print(0)
else:
  print(A-B*2)
Problem p02911 (python)

Fixed submission:
import numpy as np
N, K, Q = map(int, input().split())
p = np.array([K - Q] * N)
for i in range(Q):
  A = int(input())
  p[A-1] = p[A-1] + 1
for s in p:
  if s > 0:
    print('Yes')
  else:
    print('No')

Buggy submission (verdict: Runtime Error):
import numpy as np
N, K, Q = map(int, input().split())
p = np.array([K] * N)
m = np.array([1] * N)
for i in range(Q):
  A = int(input())
  #p = [p[i] - m[i] for i in range(len(p))]
  p = p - m
  p[A-1] = p[A-1] + 1
  if sum(p) == 0:
    break
for s in p:
  if s > 0:
    print('Yes')
  else:
    print('No')
Problem p02947 (python)

Fixed submission:
N, *s = open(0).read().split()
sl = [''.join(sorted(c)) for c in s]
count = 0
dict = {}
for s in sl:
  if s in dict:
    count += dict[s]
    dict[s] += 1
  else:
    dict[s] = 1
print(count)

Buggy submission (verdict: Runtime Error):
from math import factorial
import collections
N, *s = open(0).read().split()
s_sorted = [''.join(sorted(c)) for c in s]
c = collections.Counter(s_sorted)
res = list(set(s_sorted))
count = 0
for s in res:
  if c[s] > 2:
    count += factorial(c[s]) / factorial(2) / factorial(c[s] - 2)
  elif c[s] == 2:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
from math import factorial
import collections
N, *s = open(0).read().split()
s_sorted = [''.join(sorted(c)) for c in s]
c = collections.Counter(s_sorted)
res = list(set(s_sorted))
count = 0
for s in res:
  if c[s] > 2:
    count += factorial(c[s]) / factorial(2) / factorial(c[s] - 2)
  elif c[s] == 2:
    count += 1
print(int(count))

Buggy submission (verdict: Runtime Error):
from math import factorial
import collections
N, *s = open(0).read().split()
s_sorted = [''.join(sorted(c)) for c in s]
c = collections.Counter(s_sorted)
res = list(set(s_sorted))
count = 0
for s in res:
  if c[s] > 2:
    count += factorial(c[s]) / factorial(2) / factorial(c[s] - 2)
  elif c[s] == 2:
    count += 1
print(int(count))

Buggy submission (verdict: Runtime Error):
from math import factorial
import collections
import itertools
N, *s = open(0).read().split()
s_sorted = [''.join(sorted(c)) for c in s]
c = collections.Counter(s_sorted)
res = list(set(s_sorted))
count = 0
for s in res:
  if c[s] > 2:
    #count += len(list(itertools.combinations(range(c[s]), 2)))
    count += factorial(c[s]) / factorial(2) / factorial(c[s] - 2)
  elif c[s] == 2:
    count += 1
print(int(count))

Buggy submission (verdict: Runtime Error):
N, *s = open(0).read().split()
s_sorted = []
s_sorted = ''.join(sorted(c)) for c in s:
count = 0
for s in s_sorted:
  count += s_sorted.count(s)-1
  s_sorted.pop(0)
print(count)
Problem p02971 (python)

Fixed submission:
N = int(input())

a_list = []
for i in range(N):
    a_list.append(int(input()))

max_value = max(a_list)

if a_list.count(max_value) > 1:
  for i in range(N):
    print(max_value)
else:
  for i in range(N):
    if a_list[i] == max_value:
      print(sorted(a_list)[-2])
    else:
      print(max_value)

Buggy submission (verdict: Runtime Error):
import copy

N = int(input())

a_list = []
for i in range(N):
    a_list.append(int(input()))
    
for i in range(N):
    tmp_list = copy.copy(a_list)
    if len(tmp_list) > 2:
        tmp_list = list(sorted(set(tmp_list), key=tmp_list.index))
        tmp_list.pop(i)
        print(max(tmp_list))
    else:
        tmp_list.pop(i)
        print(max(tmp_list))
Problem p02993 (python)

Fixed submission:
s_code = list(map(int, input()))

num_1 = s_code[0]
num_2 = s_code[1]
num_3 = s_code[2]
num_4 = s_code[3]

if num_1 == num_2:
  print('Bad')
elif num_2 == num_3:
  print('Bad')
elif num_3 == num_4:
  print('Bad')
else:
  print('Good')

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
 
cnt = 0
for i in range(a, b+1):
  if i % c != 0 and i % d != 0:
    cnt += 1
    
print(cnt)
Problem p03001 (python)

Fixed submission:
import sys

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

W = list[0]
H = list[1]
x = list[2]
y = list[3]

if x == W/2 and y == H/2:
  print((W*H)/2, 1)
else:
  print((W*H)/2, 0)

Buggy submission (verdict: Runtime Error):
import sys

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

N = list[0]
X = list[1]

i = 1
total = 0

for len in length_list:
  total = total + len
  if total <= X:
    i = i + 1
    if i == N + 1:
      print(i)
  else:
    print(i)
    sys.exit()
Problem p03029 (python)

Fixed submission:
a, p = map(int, input().split())
print((a*3+p) // 2)

Buggy submission (verdict: Runtime Error):

apple = A
part = P
all_part = A*3 + P

pie = all_part / 2

print(pie)
Problem p03035 (python)

Fixed submission:
A, B = map(int, input().split())

if A >= 13:
  print(B)
elif A >= 6 and A <= 12:
  print(int(B/2))
elif A <= 5:
  print(0)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())

if A >= 13:
  print(B)
elif A >= 6 and A <= 12:
  print(int(B/2))
elif A <= 5
  print(0)
Problem p03037 (python)

Fixed submission:
N,M = map(int,input().split())
L = []
R = []
for i in range(M):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)
ans = list(range(max(L),min(R)+1))
print(len(ans))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
L = [0] * M
R = [0] * M
L, R = map(int, input().split())
for i in range(M-1):
  l, r = map(int, input().split())
print(R-l+1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
L = [0] * M
R = [0] * M
L, R = map(int, input().split())
ans = set(list(range(L, R+1)))
for i in range(M-1):
  L, R = map(int, input().split())
  ans = ans & set(list(range(L, R+1)))
  if len(ans) == 0:
    print(0)
print(len(ansN, M = map(int, input().split())
L = [0] * M
R = [0] * M
L, R = map(int, input().split())
for i in range(M-1):
  l, r = map(int, input().split())
print(R-l+1)
Problem p03076 (python)

Fixed submission:
#!/usr/bin/env python3
l = [input() for _ in range(5)]
m = 11
ans = 0
for i in range(len(l)):
    n = int(l[i][-1])
    if n == 0: n = 10
    if n < m:
        m = n
        ind = i
for t in range(len(l)):
    if t == ind:
        ans += int(l[t])
    else:
        n = int(l[t][-1])
        if n == 0: n = 10
        ans += (int(l[t]) + 10 - n)
print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
l = [input() for _ in range(5)]
m = 9
ans = 0
for i in range(len(l)):
    n = int(l[i][-1])
    if n == 0: n = 10
    if n < m:
        m = n
        ind = i
for t in range(len(l)):
    if t == ind:
        ans += int(l[t])
    else:
        n = int(l[t][-1])
        if n == 0: n = 10
        ans += (int(l[t]) + 10 - n)
print(ans)
Problem p02718 (python)

Fixed submission:
n,m = list(map(int,input().split()));
a = list(map(int,input().split()));

ans = 0;
for i in range(n) :
    if a[i] >= sum(a)/(4*m):
        ans += 1;

if ans >= m :
    print('Yes');
else :
    print('No');

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

a.sort(reverse = True);

i = 0;
while a[i] >= sum(a)/(4*m) and i < n:
    i += 1;

if i >= m :
    print('Yes');
else :
    print('No');

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

a.sort(reverse = True);

i = 0;
while a[i] >= sum(a)/(4*m) :
    i += 1;

if i >= m :
    print('Yes');
else :
    print('No');
Problem p02803 (python)

Fixed submission:
import queue
import copy

vx = [0,1,0,-1];
vy = [1,0,-1,0];
q = queue.Queue()

hw = input().split(' ');
h = int(hw[0]);
w = int(hw[1]);
s = [ [0]*w for i in range(h)];
for i in range(h) :
	si = input();
	for j in range(w) :
		s[i][j] = si[j];

s_alt = copy.deepcopy(s);
ans = 0;
for sy in range(h) :
	for sx in range(w) :
		s = copy.deepcopy(s_alt);
		if s[sy][sx] == '.' :
			q_a = [0]*2;
			q_a[0] = sy;
			q_a[1] = sx;
			q.put(q_a);
			s[sy][sx] = 0;
			while not q.empty() :
				q_a = q.get();
				for i in range(4):
					ny = q_a[0] + vy[i];
					nx = q_a[1] + vx[i];
					if ny >= 0 and ny < h and nx >= 0 and nx < w and s[ny][nx] == '.':
						s[ny][nx] = s[q_a[0]][q_a[1]] + 1;
						q_b = [0]*2;
						q_b[0] = ny;
						q_b[1] = nx;
						q.put(q_b);
			max_path = 0;
			for i in range(h) :
				for j in range(w) :
					if s[i][j] == '#' :
						continue;
					elif s[i][j] > max_path :
						max_path = s[i][j];
			if max_path > ans :
				ans = max_path;

print(ans);

Buggy submission (verdict: Runtime Error):
import queue
import copy

vx = [0,1,0,-1];
vy = [1,0,-1,0];
q = queue.Queue()

hw = input().split(' ');
h = int(hw[0]);
w = int(hw[1]);
s = [ [0]*w for i in range(h)];
for i in range(h) :
	si = input();
	for j in range(w) :
		s[i][j] = si[j];

s_alt = copy.deepcopy(s);
ans = 0;
for sy in range(h) :
	for sx in range(w) :
		s = copy.deepcopy(s_alt);
		q_a = [0]*2;
		q_a[0] = sy;
		q_a[1] = sx;
		q.put(q_a);
		s[sy][sx] = 0;
		while not q.empty() :
			q_a = q.get();
			for i in range(4):
				ny = q_a[0] + vy[i];
				nx = q_a[1] + vx[i];
				if ny >= 0 and ny < h and nx >= 0 and nx < w and s[ny][nx] == '.':
					s[ny][nx] = s[q_a[0]][q_a[1]] + 1;
					q_b = [0]*2;
					q_b[0] = ny;
					q_b[1] = nx;
					q.put(q_b);
		max_path = 0;
		for i in range(h) :
			for j in range(w) :
				if s[i][j] == '#' :
					continue;
				elif s[i][j] > max_path :
					max_path = s[i][j];
		if max_path > ans :
			ans = max_path;

print(ans);
Problem p02947 (python)

Fixed submission:
import math

n = int(input());
s = [0]*n;
for i in range(n) :
	s_pre = list(input());
	s_pre.sort();
	s[i] = s_pre;


s.sort(key=lambda x:(x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9]));

ans = 0;
ren = 0;
for i in range(1,n) :
	ok = 1;
	if s[i-1]==s[i]:
		ans += 1;
		ans += ren;
		ren += 1;
	else :
		ren = 0;

print(ans);

Buggy submission (verdict: Runtime Error):
n = int(input());
s = [0]*n;
for i in range(n) :
	s_pre = list(input());
	s_pre.sort();
	s[i] = s_pre;


s.sort(key=lambda x:(x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9]));

ans = 0;
for i in range(1,n) :
	ok = 1;
	k = 1;
	while s[i-k][9]==s[i][9] :
		#for j in range(10) :
			#if s[i-k][j] != s[i][j] :
				#ok = 0;
		if  s[i-k]==s[i]:
			ans += 1;
		k += 1;

print(ans);

Buggy submission (verdict: Runtime Error):
n = int(input());
s = [0]*n;
for i in range(n) :
	s_pre = list(input());
	s_pre.sort();
	s[i] = s_pre;


s.sort(key=lambda x:(x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9]));

ans = 0;
for i in range(1,n) :
	ok = 1;
	k = 1;
	while s[i-k]==s[i] :
		#for j in range(10) :
			#if s[i-k][j] != s[i][j] :
				#ok = 0;
		if bool(ok) :
			ans += 1;
		k += 1;

print(ans);

Buggy submission (verdict: Runtime Error):
n = int(input());
s = [0]*n;
for i in range(n) :
	s_pre = list(input());
	s_pre.sort();
	s[i] = s_pre;


s.sort(key=lambda x:(x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9]));

ans = 0;
for i in range(1,n) :
	ok = 1;
	k = 1;
	while s[i-k]==s[i] :
		for j in range(10) :
			if s[i-k][j] != s[i][j] :
				ok = 0;
		if bool(ok) :
			ans += 1;
		k += 1;

print(ans);

Buggy submission (verdict: Runtime Error):
n = int(input());
s = [0]*n;
for i in range(n) :
	s_pre = list(input());
	s_pre.sort();
	s[i] = s_pre;


s.sort(key=lambda x:(x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9]));

ans = 0;
for i in range(1,n) :
	ok = 1;
	k = 1;
	while s[i-k]==s[i] :
		for j in range(10) :
			if s[i-k][j] != s[i][j] :
				ok = 0;
		if bool(ok) :
			ans += 1;
		k += 1;

print(ans);
Problem p02995 (python)

Fixed submission:
import fractions
#import math
def lcm(x, y):
	return (x * y) // fractions.gcd(x, y);
	#return (x * y) // math.gcd(x, y);

s = input().split(" ");
a = int(s[0]);
b = int(s[1]);
c = int(s[2]);
d = int(s[3]);
num_c = b//c - (a-1)//c;
num_d = b//d - (a-1)//d; 
num_cd = b//lcm(c, d) - (a-1)//lcm(c,d);
print(b - a + 1 -(num_c + num_d - num_cd))

Buggy submission (verdict: Runtime Error):
import fractions
#import math
def lcm(x, y):
	return int((x * y) / fractions.gcd(x, y));
	#return (x * y) // math.gcd(x, y);

s = input().split(" ");
a = int(s[0]);
b = int(s[1]);
c = int(s[2]);
d = int(s[3]);
num_c = int(b/c) - int((a-1)/c);
num_d = int(b/d) - int((a-1)/d); 
num_cd = int(b/lcm(c, d)) - int((a-1)/lcm);
print(b - a + 1 -(num_c + num_d - num_cd))

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
	return (x * y) // math.gcd(x, y);

s = input().split(" ");
a = int(s[0]);
b = int(s[1]);
c = int(s[2]);
d = int(s[3]);
if a % c == 0 :
	min_c = int(a/c) - 1;
else :
	min_c = int(a/c);
if a % d == 0 :
	min_d = int(a/d) - 1;
else :
	min_d = int(a/d);
if a % lcm(c, d) == 0 :
	min_cd = int(a/lcm(c, d)) - 1;
else :
	min_cd = int(a/lcm(c, d));
num_c = int(b/c) - min_c;
num_d = int(b/d) - min_d; 
num_cd = int(b/lcm(c, d)) - min_cd;
print(b - a + 1 -(num_c + num_d - num_cd))
Problem p03290 (python)

Fixed submission:
dg = input().split(' ');
d = int(dg[0]);
g = int(dg[1]);
p = [0]*d;
c = [0]*d;
for i in range(d) :
    s = input().split(' ');
    p[i] = int(s[0]);
    c[i] = int(s[1]);

ans = sum(p);
for i in range(2**d) :
    sumpoint = 0;
    luck = -1;
    point = 0;
    for j in range(d-1,-1,-1) :
        if((i & 2**j)>>j) :
            sumpoint += (j+1)*100*p[j] + c[j];
            point += p[j];
        elif(luck<0) :
            luck = j
    k = 0;
    while k < p[luck] and sumpoint < g :
        sumpoint += (luck+1)*100;
        point += 1;
        k+= 1;
    if sumpoint >= g and point < ans :
        ans = point;

print(ans);

Buggy submission (verdict: Runtime Error):
dg = input().split(“ “);
d = int(dg[0]);
g = int(dg[1]);
p = [0]*d;
c = [0]*d;
for i in range(d) :
    s = input().split(“ “);
    p[i] = int(s[0]);
    c[i] = int(s[1]);

ans = 0;
for i in range(sum(p)) :
    sump = 0;
    for j in range(len(p)) :
        all = 0;
        for m in range(p[j]) :
            if(i & 2**(sump+m)>>(sump+m)) :
                ans += (j+1)*100;
                all += 1;
        if(all == p[j]) :
            ans += c[j];
        sump += p[i];
print(ans);
Problem p03361 (python)

Fixed submission:
hw = input().split(" ");
h = int(hw[0]);
w = int(hw[1]);
pic = [['.']*(w+2) for i in range(h+2)];
can = 0;
for i in range(1,h+1) :
	s = list(input().rstrip('\n'));
	for j in range(1,w+1) :
		pic[i][j] = s[j-1];
for i in range(1,h+1) :
	for j in range(1,w+1) :
		if pic[i][j] == '#' and pic[i][j-1] == '.' and pic[i-1][j] == '.' and pic[i][j+1] == '.' and pic[i+1][j] == '.' :
			can = can + 1;
if can == 0 :
	print('Yes');
else :
	print('No');

Buggy submission (verdict: Runtime Error):
hw = input().split(" ");
h = int(hw[0]);
w = int(hw[1]);
pic = [['.']*(h+2) for i in range(w+2)];
can = 0;
for i in range(1,h+1) :
	s = list(input().rstrip('\n'));
	for j in range(1,w+1) :
		pic[i][j] = s[j-1];
for i in range(1,h+1) :
	for j in range(1,w+1) :
		if pic[i][j] == '#' and pic[i][j-1] == '.' and pic[i-1][j] == '.' and pic[i][j+1] == '.' and pic[i+1][j] == '.' :
			can = can + 1;
if can == 0 :
	print('Yes');
else :
	print('No');

Buggy submission (verdict: Runtime Error):
hw = input().split(" ");
h = int(hw[0]);
w = int(hw[1]);
pic = [[.]*h+2 for i in range(w+2)];
can = 0;
for i in range(1,h+1) :
	s = list(input().rstrip('\n'));
	for j in range(1,w+1) :
		pic[i][j] = s[j-1];
for i in range(1,h+1) :
	for j in range(1,w+1) :
		else :
			if pic[i][j] == '#' and pic[i][j-1] == '.' and pic[i-1][j] == '.' and pic[i][j+1] == '.' and pic[i+1][j] == '.' :
				can = can + 1;
if can == 0 :
	print('Yes');
else :
	print('No');
Problem p03573 (python)

Fixed submission:
s = input().split(" ");
a = int(s[0]);
b = int(s[1]);
c = int(s[2]);
if a == b :
	print(c);
elif a == c :
	print(b);
else :
	print(a);

Buggy submission (verdict: Runtime Error):
l = map(int, raw_input().split( ))
if l[0] == l[1]:
	print(l[2])
elif l[0] == l[2] :
	print(l[1])
else:
	print(l[0])
Problem p03579 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10**6)

def dfs(G, v, cur):
    color[v] = cur;

    for next_v in G[v] :
        if not(color[next_v] == -1) :
            if color[next_v] == cur :
                return 0;
            continue;
        if not(dfs(G,next_v,1-cur)):
            return 0;
    return 1;

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

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

color = [-1]*n;

if dfs(G,0,0) :
    print(sum(color)*(n-sum(color))-m);
else :
    print(n*(n-1)//2-m);

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10000)

def dfs(G, v, cur):
    color[v] = cur;

    for next_v in G[v] :
        if not(color[next_v] == -1) :
            if color[next_v] == cur :
                return 0;
            continue;
        if not(dfs(G,next_v,1-cur)):
            return 0;
    return 1;

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

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

color = [-1]*n;

if dfs(G,0,0) :
    print(sum(color)*(n-sum(color))-m);
else :
    print(n*(n-1)//2-m);

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(5000)

def dfs(G, v, cur):
    color[v] = cur;

    for next_v in G[v] :
        if not(color[next_v] == -1) :
            if color[next_v] == cur :
                return 0;
            continue;
        if not(dfs(G,next_v,1-cur)):
            return 0;
    return 1;

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

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

color = [-1]*n;

if dfs(G,0,0) :
    print(sum(color)*(n-sum(color))-m);
else :
    print(n*(n-1)//2-m);

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(3000)

def dfs(G, v, cur):
    color[v] = cur;

    for next_v in G[v] :
        if not(color[next_v] == -1) :
            if color[next_v] == cur :
                return 0;
            continue;
        if not(dfs(G,next_v,1-cur)):
            return 0;
    return 1;

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

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

color = [-1]*n;

if dfs(G,0,0) :
    print(sum(color)*(n-sum(color))-m);
else :
    print(n*(n-1)//2-m);

Buggy submission (verdict: Runtime Error):
def dfs(G, v, cur):
    color[v] = cur;

    for next_v in G[v] :
        if not(color[next_v] == -1) :
            if color[next_v] == cur :
                return 0;
            continue;
        if not(dfs(G,next_v,1-cur)):
            return 0;
    return 1;

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

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

color = [-1]*n;

if dfs(G,0,0) :
    print(sum(color)*(n-sum(color))-m);
else :
    print(n*(n-1)//2-m);
Problem p02690 (python)

Fixed submission:
def main():
    from builtins import int, map, list, print, len
    import sys
    sys.setrecursionlimit(10 ** 6)

    X = int(input())
    t = []
    i = 0
    while True:
        x = i ** 5
        t.append(x)
        if x > 10 ** 12:
            break
        i += 1
    d = {}
    for i in range(len(t)):
        for j in range(len(t)):
            d[t[i] - t[j]] = [i, j]
            d[t[i] + t[j]] = [i, -j]
            d[-t[i] - t[j]] = [-i, j]
            d[-t[i] + t[j]] = [-i, -j]
    print(d[X][0], d[X][1])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    from builtins import int, map, list, print, len
    import sys
    sys.setrecursionlimit(10 ** 6)

    X = int(input())
    t = []
    i = 0
    while True:
        x = i ** 5
        t.append(x)
        if x > 10 ** 9:
            break
        i += 1
    d = {}
    for i in range(len(t)):
        for j in range(len(t)):
            d[t[i] - t[j]] = [i, j]
            d[t[i] + t[j]] = [i, -j]
            d[-t[i] - t[j]] = [-i, j]
            d[-t[i] + t[j]] = [-i, -j]
    print(d[X][0], d[X][1])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    from builtins import int, map, list, print, len
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    X = input_number()
    t = []
    i = 0
    while True:
        x = i ** 5
        t.append(x)
        if x > 10 ** 9:
            break
        i += 1
    d = {}
    for i in range(len(t)):
        for j in range(len(t)):
            d[t[i] - t[j]] = [i, j]
            d[t[i] + t[j]] = [i,-j]
            d[-t[i] - t[j]] = [-i, j]
            d[-t[i] + t[j]] = [-i, -j]
    print(d[X][0],d[X][1])

if __name__ == '__main__':
    main()