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

Fixed submission:
N = int(input())
if N == 1:
  print("Hello World")
else:
  print(int(input()) + int(input()))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
if N == 1:
    pritn('Hello World'); exit()
A = ir(); B = ir()
answer = A + B
print(answer)
Problem p03239 (python)

Fixed submission:
n,t=map(int,input().split())
a=[list(map(int, input().split())) for i in range(n)]
a.sort(key=lambda x: x[0])
for i in a:
  if i[1]<=t:
    print(i[0])
    exit()
print('TLE')

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, T = lr()
CT = np.array([lr() for _ in range(N)])
CT = CT[CT[:, 1] <= T]
time = CT[:, 0]
if not time:
    print('TLE')
else:
    answer = time.min()
    print(answer)
Problem p03240 (python)

Fixed submission:
N = int(input())
hxy = []
for _ in range(N):
    x, y, h = map(int, input().split())
    hxy.append((h, x, y))
hxy.sort(reverse=True)
for x in range(101):
    for y in range(101):
        H = abs(hxy[0][1] - x) + abs(hxy[0][2] - y) + hxy[0][0]
        for j in range(1, N):
            if max(0, H - abs(x - hxy[j][1]) - abs(y - hxy[j][2])) == hxy[j][0]:
                continue
            else:
                break
        else:
            print(x, y, H)

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys

N = int(input())
X = np.zeros(N, dtype = np.int64)
Y = np.zeros(N, dtype = np.int64)
H = np.zeros(N, dtype = np.int64)
for i in range(N):
    x, y, h = map(int, input().split())
    X[i] = x
    Y[i] = y
    H[i] = h
node = 10 ** 9
for x in range(101):
    for y in range(101):
        result = (abs(X - x) + abs(Y - y) + H) * (H != 0)
        s = set(result)
        if 0 in s:
            s -= {0}
        if len(s) <= 1:
            height = (abs(X - x) + abs(Y - y) + H).min()
            print(x, y, height)
            sys.exit(0)
Problem p03244 (python)

Fixed submission:
from collections import Counter

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

s1 = Counter(V).most_common(2)[0]
s2 = Counter(V).most_common(2)[0]
V1 = V[0::2]
V2 = V[1::2]
x1, c1 = Counter(V1).most_common(1)[0]
x2, c2 = Counter(V2).most_common(1)[0]
if x1 == x2:
    if c1 > c2:
        x2, c2 = Counter(V2).most_common(2)[1]
    elif c1 < c2:
        x1, c1 = Counter(V1).most_common(2)[1]
    elif c1 == c2 == N // 2:
        c1, c2 = N//2, 0
    else:

        x2, c2 = Counter(V2).most_common(2)[1]
        x3, c3 = Counter(V1).most_common(2)[1]
        c2 = max(c2, c3)

print(N - c1 - c2)

Buggy submission (verdict: Runtime Error):
from collections import Counter

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

s1 = Counter(V).most_common(2)[0]
s2 = Counter(V).most_common(2)[0]
V1 = V[0::2]
V2 = V[1::2]
x1, c1 = Counter(V1).most_common(1)[0]
x2, c2 = Counter(V2).most_common(1)[0]
x3, c3 = Counter(V1).most_common(2)[1]
x4, c4 = Counter(V2).most_common(2)[1]
if x1 == x2:
    a = max(c1+c4, c2+c3)
    print(N-a)
else:
    print(N - c1 - c2)
Problem p03262 (python)

Fixed submission:
import numpy as np
from functools import reduce
from fractions import gcd


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

places = np.array(list(map(int, input().split())))

distances = abs(places - X)

answer = reduce(gcd, distances)
print(answer)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import sys
import numpy as np
from fractions import gcd

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, X = lr()
X = np.array(lr())
Xdiff = np.abs(np.diff(X)).tolist()
g = Xdiff[0]
for i in range(1, N):
    g = gcd(g, Xdiff[1])

answer = g
print(answer)
Problem p03283 (python)

Fixed submission:
import numpy as np

N, M, Q = map(int, input().split())
data = [[0] * (N+1) for _ in range(N+1)]

for i in range(M):
    l, r = map(int, input().split())
    data[l][r] += 1

data = np.array(data)
np.cumsum(data, axis=0, out=data)
np.cumsum(data, axis=1, out=data)
data = data.tolist()
#print(data)
for i in range(Q):
    p, q = map(int, input().split())
    p -= 1
    x = data[q][q]
    x -= data[p][q] + data[q][p]
    x += data[p][p]
    print(x)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# N**2の解法
N, M, Q = lr()
graph = np.array([[0] * (501) for _ in range(501)], dtype=np.int32)  # 1-indexed
for i in range(M):
    l, r = lr()
    graph[l][r] += 1

for i in range(M):
    graph[i] = graph[i].cumsum()

graph = np.cumsum(graph, axis=0)
for _ in range(Q):
    p, q = lr()
    answer = graph[q][q] - graph[q][p-1] - graph[p-1][q] + graph[p-1][p-1]
    print(answer)

# 30

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# N**2の解法
N, M, Q = lr()
graph = np.array([[0] * (501) for _ in range(501)])  # 1-indexed
for i in range(M):
    l, r = lr()
    graph[l][r] += 1

for i in range(M):
    graph[i] = graph[i].cumsum()

graph = np.cumsum(graph, axis=0)
for _ in range(Q):
    p, q = lr()
    answer = graph[q][q] - graph[q][p-1] - graph[p-1][q] + graph[p-1][p-1]
    print(answer)

# 30

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# N**2の解法
N, M, Q = lr()
graph = np.array([[0] * (N+1) for _ in range(N+1)])  # 1-indexed
for i in range(M):
    l, r = lr()
    graph[l][r] += 1

for i in range(M):
    graph[i] = graph[i].cumsum()

graph = np.cumsum(graph, axis=0)
for _ in range(Q):
    p, q = lr()
    answer = graph[q][q] - graph[q][p-1] - graph[p-1][q] + graph[p-1][p-1]
    print(answer)

# 30
Problem p03309 (python)

Fixed submission:
import numpy as np
import statistics

N = int(input())
A = np.array(list(map(int, input().split())))
R = np.array([x+1 for x in range(N)])

med = int(np.median((A-R)))
print(abs(A-R-med).sum())

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.array(lr())
A -= np.arange(1, N+1)
A.sort()

def check(i):
    ret = np.abs(A - A[i]).sum()
    return ret

answer = min(check(0), check(-1))
left = 0; right = N-1
while abs(right-left) > 2:
    l_mid = (left*2 + right) // 3
    r_mid = (left + right*2) // 3
    if check(l_mid) < check(r_mid):
        right = r_mid
    else:
        left = l_mid

cand = min(check(l_mid), check(r_mid))
answer = min(answer, cand)
print(answer)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.array(lr())
A -= np.arange(1, N+1)
answer = 10 ** 15
B = np.abs(np.subtract.outer(A, A))
answer = np.min(B.sum(axis=1))
print(answer)
Problem p03312 (python)

Fixed submission:
# coding: utf-8
import sys
from itertools import accumulate

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()
Acum = list(accumulate(A))
l_cut = [None] * N  # 左のリストで2つに切り分けるindex
l_cut[1] = 0
l = A[0]; r = A[1]
for i in range(2, N):
    r += A[i]
    diff = abs(r-l)
    index = l_cut[i-1]
    while index < i - 1:
        temp = abs(l + A[index+1] - (r - A[index+1]))
        if temp < diff:
            index += 1
            l += A[index]
            r -= A[index]
            diff = temp
        else:
            break
    l_cut[i] = index

r_cut = [None] * N
r_cut[-2] = N-2
l = A[-2]; r = A[-1]
for i in range(N-3, 0, -1):
    l += A[i]
    diff = abs(r-l)
    index = r_cut[i+1]
    while index > i:
        temp = abs(r + A[index] - (l - A[index]))
        if temp < diff:
            index -= 1
            r += A[index+1]
            l -= A[index+1]
            diff = temp
        else:
            break
    r_cut[i] = index

answer = 10 ** 17
for i in range(1, N-2):
    a = Acum[l_cut[i]]
    b = Acum[i] - a
    c = Acum[r_cut[i+1]] - Acum[i]
    d = Acum[-1] - (a + b + c)
    temp = max(a, b, c, d) - min(a, b, c, d)
    if temp < answer:
        answer = temp

print(answer)
# 27r

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import sys
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()

def min_max(arr):
    """リストの中を二つに分けて、総和の小さい方と大きい方を返す"""
    left = 0; right = len(arr)-1
    l_total = arr[left]
    r_total = arr[right]
    while left + 1 < right:
        if l_total <= r_total:
            left += 1
            l_total += arr[left]
        else:
            right -= 1
            r_total += arr[right]
    mi, ma = min(l_total, r_total), max(l_total, r_total)
    return mi, ma

answer = 10 ** 15
mid = N // 2
used = set()

def F(l, mid, r):
    global answer, used
    used.add(mid)
    l_min, l_max = min_max(A[:mid])
    r_min, r_max = min_max(A[mid:])
    temp = max(l_max, r_max) - min(l_min, r_min)
    if temp < answer:
        answer = temp
    if l_min <= r_min:
        m = (mid+r)//2
        if m not in used:
            F(mid, m, r)
    else:
        m = (mid+l)//2
        if m not in used:
            F(l, m, mid)
    if l_max >= r_max:
        m = (mid+l)//2
        if m not in used:
            F(l, m, mid)
    else:
        m = (mid+r)//2
        if m not in used:
            F(mid, m, r)

F(0, mid, N-1)
print(answer)
# 08
Problem p03386 (python)

Fixed submission:
A, B, K = map(int, input().split())
K = min(K, B - A + 1)
print(*sorted(set([i for i in range(A, A+K)] + [i for i in range(B-K+1, B+1)])), sep='\n')

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
l = list(range(A, B+1))
print(*sorted(set(l[:K] + l[-K:])), sep='\n')

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
l = list(range(A, B+1))
print(*sorted(set(l[:K] + l[-K:])), sep='\n')
Problem p03394 (python)

Fixed submission:
import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
if N == 3:
    print('2 5 63')
    exit()
l = np.array([3, 9, 2, 10, 4, 8, 6, 12]).astype('int32')
l2 = np.array([6, 3, 9, 2, 10, 4, 8, 12]).astype('int32')
time = N // 8
answer = np.array([])
for i in range(time):
    answer = np.append(answer, l + 12 * i)
remain = N % 8
if remain%2 == 0:
    answer = np.append(answer, l[:remain] + 12 * time)
else:
    answer = np.append(answer, l2[:remain] + 12 * time)

answer = [int(x) for x in answer]
print(*answer)
# 48

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
if N == 3:
    print('2 5 63')
    exit()
l = np.array([3, 9, 2, 10, 4, 8, 6, 12]).astype('int32')
l2 = np.array([6, 3, 9, 2, 10, 4, 8,12]).astype('int32')
time = N // 12
answer = np.array([])
for i in range(time):
    answer = np.append(answer, l + 12 * i)
remain = N % 12
if remain%2 == 0:
    answer = np.append(answer, l[:remain] + 12 * time)
else:
    answer = np.appen(answer, l2[:remain] + 12 * time)

answer = [int(x) for x in answer]
print(*answer)
# 48

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
if N == 3:
    print('2 5 63')
    exit()
l = np.array([3, 9, 2, 10, 4, 8, 6, 12]).astype('int32')
l2 = np.array([6, 3, 9, 2, 10, 4, 8,12]).astype('int32')
time = N // 12
answer = np.array([])
for i in range(time):
    answer = np.append(answer, l + 12 * i)
remain = N % 12
if remain%2 == 0:
    answer = np.append(answer, l[:remain] + 12 * time)
else:
    answer = np.appen(answer, l2[:remain] + 12 * time)

answer = [int(x) for x in answer]
print(*answer)
# 48

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
if N == 3:
    print('2 5 63')
    exit()
l = np.array([3, 9, 2, 10, 4, 8, 6, 12]).astype('int32')
l2 = np.array([6, 3, 9, 2, 10, 4, 8,12]).astype('int32')
time = N // 12
answer = np.array([])
for i in range(1, time+1):
    answer = np.append(answer, l + 12 * i)
remain = N % 12
if remain%2 == 0:
    answer = np.append(answer, l[:remain])
else:
    answer = np.appen(answer, l2[:remain])

answer = [int(x) for x in answer]
print(*answer)
# 48
Problem p03404 (python)

Fixed submission:
import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

A, B = rl()
grid = [['.'] * 100 for _ in range(50)] + [['#'] * 100 for _ in range(50)]
for i in range(B-1):
    row, column = divmod(i, 50)
    row *= 2
    column *= 2
    grid[row][column] = '#'

for i in range(A-1):
    row, column = divmod(i, 50)
    row *= 2
    column *= 2
    grid[99-row][column] = '.'
print(100,100)
for x in grid:
    print(*x, sep='')
#56

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

A, B = rl()
grid = [['.'] * 10 for _ in range(5)] + [['#'] * 10 for _ in range(5)]
for i in range(B-1):
    row, column = divmod(i, 5)
    row *= 2
    column *= 2
    grid[row][column] = '#'

for i in range(A-1):
    row, column = divmod(i, 5)
    row *= 2
    column *= 2
    grid[9-row][column] = '.'
print(100,100)
for x in grid:
    print(*x, sep='')
#56

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

A, B = rl()
grid = [['.'] * 10 for _ in range(5)] + [['#'] * 10 for _ in range(5)]
for i in range(B-1):
    row, column = divmod(i, 5)
    row *= 2
    column *= 2
    grid[row][column] = '#'

for i in range(A-1):
    row, column = divmod(i, 5)
    row *= 2
    column *= 2
    grid[9-row][column] = '.'
print(100,100)
for x in grid:
    print(*x, sep='')
#56
Problem p03433 (python)

Fixed submission:
n=int(input())
a=int(input())
print('Yes' if n%500<=a else 'No')

Buggy submission (verdict: Runtime Error):
n=int(input())
a=int(input())
print('Yes' if n%500<==a else 'No')
Problem p03455 (python)

Fixed submission:
a,b=map(int,input().split())
print('Even' if a*b%2==0 else 'Odd')

Buggy submission (verdict: Runtime Error):
print('Even' if int(input())*int(input())%2==0 else 'Odd')
Problem p03472 (python)

Fixed submission:
import math
N, H = map(int, input().split())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
amax = max(A)
B = list(filter(lambda x: x > amax, B))
B.sort()
ans = 0
while H > 0:
    if B:
        H -= B.pop()
    else:
        ans += math.ceil(H / amax)
        break
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, H = map(int, input().split())
sword_list = [list(map(int, input().split())) for i in range(N)]
a_list = [i[0] for i in sword_list]
b_list = [i[1] for i in sword_list]
b_list.sort()
a_max = max(a_list)
index1 = 0
# Aの攻撃がBのいくつかの攻撃より強い場合、どの場所のBかを知っておく
for i in range(0, len(b_list)):
    if b_list[i] <= a_max and b_list[i + 1] > a_max:
        index1 = i + 1
ans = 0
# 全てBの攻撃で倒す場合    
if H - sum(b_list[index1:]) <= 0:
    count = 0
    for j in range(N - 1, -1, -1):
        count += b_list[j]   
        if count >= H:          
            ans = N - j
            break
# Aの攻撃を使う    
else:   
    ans = ((H - sum(b_list[index1:])) + a_max - 1) // a_max + N - index1

print(ans)
Problem p03493 (python)

Fixed submission:
print(sum(map(int,input())))

Buggy submission (verdict: Runtime Error):
print(sum(int(input())))
Problem p03494 (python)

Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))

min_a = min(a_list)
count = 0
while min_a % 2 == 0:
    min_a /= 2
    count += 1
#print(count)
for a in a_list:
    if a % 2 ** count != 0:
        a_count = 0
        while a % 2 == 0:
            a /= 2
            a_count += 1
        count = a_count

print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(l) for l in input().split()]

count = 0
while True:
    for i in range(N):
        if A[i]/2** k % 2 !=0:
            break
    else:
        count += 1    
        continue
    break

print(count)
Problem p03525 (python)

Fixed submission:
import numpy as np

N = int(input())
D = list(map(int, input().split()))
if N > 23:
    print(0)
    exit()
for i in range(13):
    if D.count(i) >= 3:
        print(0)
        exit()
    elif D.count(i) == 2 and D.count(i+1) == 2:
        print(1)
        exit()

# 深さ優先探索で全通りを探索できるのでは curは０からスタート
def dfs(cur, times):
    global answer
    if cur == N:
        times.sort()
        arr = np.array(times)
        result = (arr[1:] - arr[:-1]).min()
        if result > answer:
            answer = result
    else:
        x = D[cur]
        dfs(cur+1, times + [x])
        dfs(cur+1, times + [24-x])

answer = 0
dfs(0, [0, 24])
print(answer)

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())
D = list(map(int, input().split()))
if N > 23:
    print(0)
    exit()
for i in range(13):
    if D.count(i) >= 3:
        print(0)
        exit()
for i in range(13)
    elif D.count(i) == 2 and D.count(i+1) >= 1:
        print(1)
        exit()

# 深さ優先探索で全通りを探索できるのでは curは０からスタート
def dfs(cur, times):
    global answer
    if cur == N:
        times.sort()
        arr = np.array(times)
        result = (arr[1:] - arr[:-1]).min()
        if result > answer:
            answer = result
    else:
        x = D[cur]
        dfs(cur+1, times + [x])
        dfs(cur+1, times + [24-x])

answer = 0
dfs(0, [0, 24])
print(answer)
Problem p03569 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)
S = input()

answer = 0
left = 0
right = len(S) - 1
while left < right:
    if S[left] == S[right]:
        left += 1
        right -= 1
    elif S[left] == 'x':
        left += 1
        answer += 1
    elif S[right] == 'x':
        right -= 1
        answer += 1
    else:
        print(-1)
        exit()
print(answer)

Buggy submission (verdict: Runtime Error):
S = input()

answer = 0

def F(s):
    global answer
    if len(s) <= 1:
        return
    if s[0] == 'x':
        if s[-1] == 'x':
            F(s[1:-1])
        else:
            answer += 1
            F(s[1:])
    else:
        if s[-1] == 'x':
            answer += 1
            F(s[:-1])
        elif s[0] == s[-1]:
            F(s[1:-1])
        else:
            print(-1)
            exit()

F(S)
print(answer)
Problem p03576 (python)

Fixed submission:
import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
XY = [lr() for _ in range(N)]
XY.sort()
answer = float('inf')
# 端の4点、まずはx軸の2点を選ぶ
for left,right in itertools.combinations(range(N),2):
  width = XY[right][0] - XY[left][0]
  pts = sorted(XY[left:right+1], key = lambda xy: xy[1])
  for D in range(len(pts)):
    if D + K - 1 >= len(pts):
      break
    y_max = pts[D+K-1][1]
    y_min = pts[D][1]
    area = (y_max - y_min) * width
    if area < answer:
      answer = area
    
print(answer)

Buggy submission (verdict: Runtime Error):
import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
XY = [lr() for _ in range(N)]
answer = float('inf')
# 端の4点、まずはx軸の2点を選ぶ
for i, j in itertools.permutations(list(range(N)), repeat=2):
    xleft = XY[i][0]
    xright = XY[j][0]
    if xright < xleft: xleft, xright = xright, xleft
    candidate = [(x, y) for x, y in XY if xleft <= x <= xright]
    if len(candidate) < K:
        continue
    candidate.sort(key=lambda z: z[1])
    for s in range(len(candidate) - K + 1):
        yup = candidate[s+K-1][1]
        ylow = candidate[s][1]
    area = (xright - xleft) * (yup - ylow)
    if area < answer:
        answer = area

print(answer)
# 31
Problem p03579 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)

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

for a, b in AB:
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

# 二部グラフかどうかの判定
color = [None] * N
color[0] = 0
q = [0]
while q:
    x = q.pop()
    for y in graph[x]:
        if color[y] is None:
            color[y] = 1 - color[x]
            q.append(y)

# 二部グラフかどうか
is_bg = all(color[a-1] != color[b-1] for a, b in AB)

if is_bg:
    # 完全二部グラフにする
    x = sum(color)
    y = N - x
    answer = x*y - M
else:
    # 完全グラフにする(奇数長のパスがある場合は必ず2ずつ減らしていけば長さが3になる)
    answer = N*(N-1)//2 - M

print(answer)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 7)

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

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

graph = [[] for _ in range(N)]
for a,b in AB:
    graph[a−1].append(b-1)
    graph[b-1].append(a-1)

# 二部グラフかどうかの判定
color = [None] * N
color[0] = 0
q = [0]
while q:
    x = q.pop()
    for y in graph[x]:
        if color[y] is None:
            color[y] = 1 - color[x]
            q.append(y)

# 二部グラフかどうか
bg = all(color[a] != color[b] for a, b in AB)

if bg:
    # 完全二部グラフにする
    x = sum(color)
    y = N - x
    answer = x*y - M
else:
    # 完全グラフにする(奇数長のパスがある場合は必ず2ずつ減らしていけば長さが3になる)
    answer = N*(N-1)//2 - M

print(answer)
Problem p03611 (python)

Fixed submission:
import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N = ri()
A = np.array(rl())
c = np.bincount(A)
answer = c[0]

for i in range(1, len(c)-1):
    result = c[i-1] + c[i] + c[i+1]
    if result > answer:
        answer = result

print(answer)
# 32

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N = ri()
A = np.array(rl())
answer = 0
c = np.bincount(A)

for i in range(1, len(c)):
    result = c[i-1] + c[i] + c[i+1]
    if result > answer:
        answer = result

print(answer)
# 32
Problem p03643 (python)

Fixed submission:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())

print('ABC' + str(N))

Buggy submission (verdict: Runtime Error):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())

print('ABC' + N)