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

Fixed submission:
from itertools import permutations

INF = float('inf')
n, m, R = list(map(int, input().split()))
r = list(map(int, input().split()))
dist = [[INF]*(n+1) for _ in range(n+1)]
for i in range(1, n+1):
    dist[i][i] = 0
for i in range(m):
    a, b, c = map(int, input().split())
    dist[a][b] = c
    dist[b][a] = c

from scipy.sparse import csgraph
dist = csgraph.floyd_warshall(dist)
# for k in range(n):
#     for i in range(n):
#         for j in range(n):
#             dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])
# for d in dist: print(d)

ans = INF
for p in permutations(r):
    ans_ = 0
    for i in range(R-1):
        ans_ += dist[p[i]][p[i+1]]
    ans = min(ans, ans_)
print(int(ans))

Buggy submission (verdict: Runtime Error):
from itertools import permutations

INF = float('inf')
n, m, R = list(map(int, input().split()))
r = list(map(int, input().split()))
dist = [[INF]*(n+1) for _ in range(n+1)]
for i in range(1, n+1):
    dist[i][i] = 0
for i in range(m):
    a, b, c = map(int, input().split())
    dist[a][b] = c
    dist[b][a] = c

for k in range(1, n+1):
    for i in r:
        for j in r:
            dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])
# for d in dist: print(d)

ans = INF
for p in permutations(r):
    ans_ = 0
    for i in range(R-1):
        ans_ += dist[p[i]][p[i+1]]
    ans = min(ans, ans_)
print(int(ans))

Buggy submission (verdict: Runtime Error):
from itertools import permutations

INF = float('inf')
n, m, R = list(map(int, input().split()))
r = list(map(int, input().split()))
dist = [[INF]*(n+1) for _ in range(n+1)]
for i in range(1, n+1):
    dist[i][i] = 0
for i in range(m):
    a, b, c = map(int, input().split())
    dist[a][b] = c
    dist[b][a] = c

for k in range(n):
    for i in r:
        for j in r:
            dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])
# for d in dist: print(d)

ans = INF
for p in permutations(r):
    ans_ = 0
    for i in range(R-1):
        ans_ += dist[p[i]][p[i+1]]
    ans = min(ans, ans_)
print(int(ans))
Problem p03674 (python)

Fixed submission:
MOD = 10**9+7
facts = [1]
for i in range(1, 10**5+2):
    facts.append((i*facts[i-1])%MOD)
def nCk(n, k):
    if n < k: return 0
    return (facts[n]*pow(facts[k], MOD-2, MOD)%MOD * pow(facts[n-k], MOD-2, MOD))%MOD

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

# Search doubling number and its indexes
indexes = [[] for _ in range(n+1)] # 0 to n:max(a)
for i in range(n+1):
    indexes[a[i]].append(i)
for idx in indexes:
    if len(idx) == 2: idxs = sorted(idx)

for k in range(1, n+1+1):
    p_all = nCk(n+1, k)
    p_double = nCk(n+1-(idxs[1]-idxs[0]+1), k-1)
    print((p_all-p_double)%MOD)

Buggy submission (verdict: Runtime Error):
MOD = 10**9+7
facts = [1]
for i in range(1, 10**5+1):
    facts.append((i*facts[i-1])%MOD)
def nCk(n, k):
    if n < k or n == 0: return 0
    return (facts[n]*pow(facts[k], MOD-2, MOD)%MOD * pow(facts[n-k], MOD-2, MOD))%MOD

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

# Search doubling number and its indexes
indexes = [[] for _ in range(n+1)] # 0 to n:max(a)
for i in range(n+1):
    indexes[a[i]].append(i)
for idx in indexes:
    if len(idx) == 2: idxs = sorted(idx)

for k in range(1, n+1+1):
    p_all = nCk(n+1, k)
    p_double = nCk(n+1-(idxs[1]-idxs[0]+1), k-1)
    print((p_all-p_double)%MOD)
Problem p03695 (python)

Fixed submission:
import copy
n = int(input())
a = list(map(int, input().split()))

color = [0]*9
for i in range(n):
    rate = min(a[i]//400, 8)
    color[rate] += 1

ans_min = 0
color_min = copy.deepcopy(color)
for c in color_min[:-1]:
    if c > 0:
        ans_min += 1
ans_min = max(1, ans_min)

ans_max = 0
color_max = copy.deepcopy(color)
for c in color_max[:-1]:
    if c > 0:
        ans_max += 1
ans_max += color_max[-1]

print(ans_min, ans_max)

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

rates = [0]*9
for i in range(n):
  rates[a[i]//400] += 1

n_min, n_max = 0, 0
if max(rates[:-1]) > 0:
  for i in range(8):
    n_min += 1 if rates[i] > 0 else 0
  n_max = n_min+rates[-1]
else:
  n_min = 1
  n_max = rates[-1]

print(n_min, n_max)

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

rates = [0]*9
for i in range(n):
  rates[a[i]//400] += 1

n_min, n_max = 0, 0
if min(rates[:-1]) > 0:
  for i in range(8):
    n_min += 1 if rates[i] > 0 else 0
  n_max = n_min+rates[-1]
else:
  n_min = 1
  n_max = rates[-1]

print(n_min, n_max)
Problem p03696 (python)

Fixed submission:
n = int(input())
s = input()

ans = s
n_left, n_right = 0, 0
for ss in s:
    if ss == '(':
        n_left += 1
    else:
        if n_left > 0:
            n_left -= 1
        else:
            ans = '('+ans
if n_left > 0:
    for _ in range(n_left): ans += ')'

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()

n_left = 0
ans = s
for i in range(n):
  if s[i] == '(':
    n_left += 1
  elif s[i] == ')':
	if n_left == 0:
      ans = '(' + ans
    else:
      n_left -= 1
for i in range(n_left):
  ans += ')'
print(ans)
Problem p03722 (python)

Fixed submission:
INF = float('inf')
n, m = list(map(int, input().split()))
a, b, c = [], [], []
for _ in range(m):
    abc = list(map(int, input().split()))
    a.append(abc[0])
    b.append(abc[1])
    c.append(-abc[2]) # convert pos-neg

dist = [INF]*(n+1)
dist[1] = 0
for loop in range(n-1):
    for i in range(m):
        if dist[a[i]] == INF:
            continue
        if dist[b[i]] > dist[a[i]] + c[i]:
            dist[b[i]] = dist[a[i]] + c[i]
ans = dist[-1]

negative = [False]*(n+1) # negative closed path
for loop in range(n):
    for i in range(m):
        if dist[a[i]] == INF:
            continue
        if dist[b[i]] > dist[a[i]] + c[i]:
            dist[b[i]] = dist[a[i]] + c[i]
            negative[b[i]] = True
        if negative[a[i]] is True:
            negative[b[i]] = True

    if negative[-1] is True:
        break
# print(dist, negative)
if negative[-1] is True:
    print('inf')
else:
    print(-ans)

Buggy submission (verdict: Runtime Error):
from math import inf
n, m = list(map(int, input().split()))
a, b, c = [], [], []
for _ in range(m):
    abc = list(map(int, input().split()))
    a.append(abc[0])
    b.append(abc[1])
    c.append(-abc[2]) # convert pos-neg

dist = [inf]*(n+1)
dist[1] = 0
for loop in range(n-1):
    for i in range(m):
        if dist[a[i]] == inf:
            continue
        if dist[b[i]] > dist[a[i]] + c[i]:
            dist[b[i]] = dist[a[i]] + c[i]
ans = dist[-1]

negative = [False]*(n+1) # negative closed path
for loop in range(n):
    for i in range(m):
        if dist[a[i]] == inf:
            continue
        if dist[b[i]] > dist[a[i]] + c[i]:
            dist[b[i]] = dist[a[i]] + c[i]
            negative[b[i]] = True
        if negative[a[i]] is True:
            negative[b[i]] = True

# print(dist, negative)
if negative[-1] is True:
    print('inf')
else:
    print(-ans)

Buggy submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
paths = {}
for _ in range(m):
    a, b, c = list(map(int, input().split()))
    if not a in paths.keys():
        paths[a] = {b:c}
    else:
        paths[a][b] = c
# print(paths)

score = [None]*(n+1)
score[1] = 0
stack = [(k, [1]) for k in paths[1].keys()]
is_inf = False
while len(stack) > 0 and not is_inf:
    node, path = stack[-1]
    node_before = path[-1]
    stack = stack[:-1]
    if score[node] is None:
        score[node] = score[node_before] + paths[node_before][node]
    elif score[node_before] + paths[node_before][node] > score[node]:
        score[node] = score[node_before] + paths[node_before][node]
    else:
        continue

    if node == n and not n in paths.keys():
        continue

    for node_next in paths[node].keys():
        if node_next in path:
            is_inf = True
            break
        else:
            stack.append((node_next, path+[node]))
    # print(stack, score)

if is_inf:
    print('inf')
else:
    print(score[-1])
Problem p03846 (python)

Fixed submission:
MOD = 10**9+7
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)

if n%2 == 0:
    valid = True
    for i in range(n):
        if i%2 == 0: v = i+1
        else: v = i
        if a[i] != v:
            valid = False
            print(0)
            break
    if valid:
        print(2**(n//2)%MOD)

else:
    valid = True
    for i in range(n):
        if i%2 != 0: v = i+1
        else: v = i
        if a[i] != v:
            valid = False
            print(0)
            break
    if valid:
        print(2**(n//2)%MOD)

Buggy submission (verdict: Runtime Error):
MOD = int(10**9+7)
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)

if n%2 == 0:
    valid = True
    for i in range(n):
        if i%2 == 0: v = i+1
        else: v = i
        if a[i] != v:
            valid = False
            print(0)
            break
    if valid:
        print(int((2**(n/2))%MOD))

else:
    valid = True
    for i in range(n):
        if i%2 != 0: v = i+1
        else: v = i
        if a[i] != v:
            valid = False
            print(0)
            break
    if valid:
        print(int(2**((n-1)/2))%MOD)

Buggy submission (verdict: Runtime Error):
MOD = int(10**9+7)
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)

if n%2 == 0:
    a_valid = []
    for i in range(1, n, 2):
        a_valid += [i, i]
    if a == a_valid:
        print(int((2**(n/2))%MOD))
    else:
        print(0)
else:
    a_valid = [0]
    for i in range(2, n, 2):
        a_valid += [i, i]
    if a == a_valid:
        print(int((2**int(n/2))%MOD))
    else:
        print(0)
Problem p03855 (python)

Fixed submission:
from collections import deque

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

def get_groups(n, m):
    road = [[] for _ in range(n+1)]
    for _ in range(m):
        p, q = list(map(int, input().split()))
        road[p].append(q)
        road[q].append(p)

    groups = [0]*(n+1)
    group_idx = 1
    connect = deque()
    for i in range(1, n+1):
        if groups[i] == 0:
            groups[i] = group_idx
            connect.clear()
            connect.append(i)
            while len(connect) > 0:
                cnct = connect.popleft()
                for c in road[cnct]:
                    if groups[c] == 0:
                        groups[c] = group_idx
                        connect.append(c)
            group_idx += 1
            
    return groups

road_groups = get_groups(n, k)
train_groups = get_groups(n, l)
# print(road_groups, train_groups)
pairs = {}
for c in range(1, n+1):
    key = (road_groups[c], train_groups[c])
    if not key in pairs.keys():
        pairs[key] = 1
    else:
        pairs[key] += 1

ans = []
for c in range(1, n+1):
    key = (road_groups[c], train_groups[c])
    ans.append(str(pairs[key]))
print(' '.join(ans))

Buggy submission (verdict: Runtime Error):
n, k, l = list(map(int, input().split()))

def get_groups(n, m):
    road = [[] for _ in range(n+1)]
    for _ in range(m):
        p, q = list(map(int, input().split()))
        road[p].append(q)
        road[q].append(p)

    groups = [0]*(n+1)
    group_idx = 1
    for i in range(1, n+1):
        if groups[i] == 0:
            groups[i] = group_idx
            connect = [i]
            while len(connect) > 0:
                cnct = connect[0]
                connect = connect[1:]
                for c in road[cnct]:
                    if groups[c] == 0:
                        groups[c] = group_idx
                        connect.append(c)
            group_idx += 1
            
    return groups

road_groups = get_groups(n, k)
train_groups = get_groups(n, l)
# print(road_groups, train_groups)
pairs = {}
for c in range(1, n+1):
    key = (road_groups[c], train_groups[c])
    if not key in pairs.keys():
        pairs[key] = 1
    else:
        pairs[key] += 1

ans = ''
for c in range(1, n+1):
    key = (road_groups[c], train_groups[c])
    ans += f'{pairs[key]} '
print(ans)
Problem p03946 (python)

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

remain_max = [a[-1]]*n
for i in range(1, n):
    remain_max[-(i+1)] = max(a[-i], remain_max[-i])

diffs1 = [0]*n
for i in range(n):
    diffs1[i] = remain_max[i] - a[i]

max_diff1 = 0
ans1 = 0
for i in range(n):
    if diffs1[i] > max_diff1:
        max_diff1 = diffs1[i]
        ans1 = 1
    elif diffs1[i] == max_diff1:
        ans1 += 1
# print(diffs1, ans1)

remain_min = [a[0]]*n
for i in range(1, n):
    remain_min[i] = min(a[i-1], remain_min[i-1])

diffs2 = [0]*n
for i in range(n):
    diffs2[i] = a[i] - remain_min[i]

max_diff2 = 0
ans2 = 0
for i in range(n):
    if diffs2[i] > max_diff2:
        max_diff2 = diffs2[i]
        ans2 = 1
    elif diffs2[i] == max_diff2:
        ans2 += 1
# print(diffs2, ans2)

print(min(ans1, ans2))

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

remain_max = [a[-1]]*n
for i in range(1, n):
    remain_max[-(i+1)] = max(a[-i], remain_max[-i])

diffs = [0]*n
for i in range(n):
    diffs[i] = remain_max[i] - a[i]

max_diff = 0
ans = 0
for i in range(n):
    if diffs[i] > max_diff:
        max_diff = diffs[i]
        ans = 1
    elif diffs[i] == max_diff:
        ans1 += 1

print(ans)
Problem p03109 (python)

Fixed submission:
s = list(map(int, input().split('/')))
if s[0] == 2019 and s[1] > 4:
  print("TBD")
elif s[0] >2019:
  print("TBD")
else : print("Heisei")

Buggy submission (verdict: Runtime Error):
s = list(map(int, input().split('/')))
if s[0] = 2018 and s[1] > 4:
  print("TBD")
elif s[0] >2018:
  print("TBD")
else : print("Heisei")
Problem p03125 (python)

Fixed submission:
A,B = map(int, input().split())
b = []
for i in range(1,21):
    if B % i == 0:
        b.append(i)
if A in b:
    print(A+B)
else:
    print(B-A)

Buggy submission (verdict: Runtime Error):
from fractions import gcd

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

a = sorted(A)
B = [a[0]]
C = []
for i in range(1,N):
    x = a[i]%a[0]
    if x != 0:
        B.append(x)
b =sorted(B)
for i in range(len(b)-1):
    y = math.gcd(b[i],b[-1])
    C.append(y)
    
if len(b) == 1:
    print(b[0])
else:
    print(min(C))
Problem p03244 (python)

Fixed submission:
from collections import Counter
 
n = int(input())
V =list(map(int,input().split()))

V1 = V[::2]
V2 = V[1::2]
 
V1c = Counter(V1).most_common()
V2c = Counter(V2).most_common()

k1, v1 = V1c[0][0], V1c[0][1]
k2, v2 = V2c[0][0], V2c[0][1]

ans = 0
if k1 == k2:
    ans = n - v1
    m = 0
    if len(V1c) >= 2:
        m = max(m, V1c[1][1])
    if len(V2c) >= 2:
        m = max(m, V2c[1][1])
    ans = ans - m
else:
    ans = n - v1 - v2
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
 
n = int(input())
V =list(map(int,input().split()))

V1 = V[::2]
V2 = V[1::2]
 
V1c = Counter(V1).most_common()
V2c = Counter(V2).most_common()

k1, v1 = V1c[0][0], V1c[0][1]
k2, v2 = V2c[0][0], V2c[0][1]

ans = 0
if k1 == k2:
    ans = n - v1
    m = 0
    if len(V1c) >= 2:
        m = max(m, V1c[1][1])
    if len(V2c) >= 2:
        m = max(m, vVc[1][1])
    ans = ans - m
else:
    ans = n - v1 - v2
print(ans)
Problem p03043 (python)

Fixed submission:
import math
 
n, k = list(map(int, input().split()))
 
ans = 0
 
"i点の時、k点以上になるためにはlog2(k/i)回連続で表を出す必要がある"
for i in range (1, n + 1):
  if i < k:
    omote = math.ceil(math.log(k/i, 2))
    ans += (1/2) **(omote)
  else :
    ans += 1
print(ans/n)

Buggy submission (verdict: Runtime Error):
import math

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

ans = 0

"i点の時、k点以上になるためにはlog2(k/i)回連続で表を出す必要がある"
for i in range (1:n + 1):
  if i < k:
    omote = math.ceil(math.log(k/i, 2))
    ans += (1/2) **(omote)
  else :
    ans += 1
print(ans/n)
Problem p03095 (python)

Fixed submission:
N = int(input())
S = list(input())

sum = 1
for s in set(S):
    sum *= S.count(s) + 1
    sum %= 10**9 + 7
sum -= 1
sum %= 10**9 + 7
print(sum)

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

C = A^B
c = format(A^B, 'b')
p = list()
p.append(A)
for i in range(len(c)):
    if int(c[len(c)-1-i]) == 1:
        tmp = p[-1] ^ (C & (1 << i))
        p.append(tmp)
for i in range(2**N-len(p)):
    p.append(p[-2])
if B == p[2**N-1]:
    print('YES')
    for i in range(len(p)):
        print(p[i], end=' ')
else:
    print('NO')
Problem p03085 (python)

Fixed submission:
enki = input()
if enki == "A":
  print("T")
elif enki == "T":
  print("A")
elif enki == "C":
  print("G")
elif enki == "G":
  print("C")

Buggy submission (verdict: Runtime Error):
ATCG

enki = input()
if enki == "A":
  return "T"
elif enki == "T":
  return "A"
elif enki == "C":
  return "G"
elif enki == "G":
  return "C"
Problem p03674 (python)

Fixed submission:
INF = 10**9+7 

n = int(input())
a = list(map(int, input().split()))
s = set()
result = [x for x in a if x in s or s.add(x)]
indexes = [i for i, x in enumerate(a) if x == result[0]]
l0 = indexes[0]+1
l1 = indexes[1] +1

def bin_pow(a,n):
    ans = 1
    mag = a
    while(n>0):
        if n%2==0:
            mag = (mag*mag)%INF
            n /= 2
        else:        
            ans = ans* mag%INF
            n -= 1
    return ans

factorial = [0]*(n+2)
inverse_factorial = [0] * (n+2)

factorial[0] = 1
for i in range(1, n+2):
    factorial[i] = factorial[i-1] * i % INF

inverse_factorial[n+1] = bin_pow(factorial[n+1], INF-2)
for i in range(n,-1,-1):
    inverse_factorial[i] = (inverse_factorial[i+1]*(i+1))%INF

def combi(n, r):
    if n < 0 or r < 0 or n < r:
        return 0
    return (factorial[n] * inverse_factorial[r] )%INF * (inverse_factorial[n-r]% INF)

for i in range(1,n+2):
    print((combi(n+1,i)-combi(n-(l1-l0), i-1) )%INF)

Buggy submission (verdict: Runtime Error):
INF = 10**9+7 
import scipy.misc as scm

n = int(input())
a = list(map(int, input().split()))
s = set()
result = [x for x in a if x in s or s.add(x)]

indexes = [i for i, x in enumerate(a) if x == result[0]]
l0 = indexes[0]+1
l1 = indexes[1] +1

for i in range(1,n+2):
        print(int((scm.comb(n+1,i)-scm.comb(n-(l1-l0), i-1))%INF))

Buggy submission (verdict: Runtime Error):
INF = 10e9+7 
import scipy.misc as scm
n = int(input())
a = list(map(int, input().split()))
s = set()
result = [x for x in a if x in s or s.add(x)]
indexes = [i for i, x in enumerate(a) if x == result[0]]
l0 = indexes[0]+1
l1 = indexes[1] +1

for i in range(1,n+2):
        print(int((scm.comb(n+1,i)-scm.comb(n-(l1-l0), i-1))%INF))
Problem p03014 (python)

Fixed submission:
from functools import reduce
import sys
import numpy as np
MOD = 1000000007

buffer = sys.stdin.buffer
H, W = list(map(int,buffer.readline().split()))
S = np.frombuffer(buffer.read(H*(W+1)), dtype="B") == ord(".")
S = S.reshape((H,W+1))[:,:-1]
L = np.empty((H,W), dtype="i4")
R = np.empty((H,W), dtype="i4")
U = np.empty((H,W), dtype="i4")
D = np.empty((H,W), dtype="i4")
 
L[:,0] = S[:,0]
for i in range(1,W):
    L[:,i] = (L[:,i-1] + 1) * S[:,i]
 
R[:,-1] = S[:,-1]
for i in range(1,W):
    R[:,-1-i] = (R[:,-i] + 1) * S[:,-1-i]
 
U[0] = S[0]
for i in range(1,H):
    U[i] = (U[i-1] + 1) * S[i]
 
D[-1] = S[-1]
for i in range(1,H):
    D[-1-i] = (D[-i] + 1) * S[-1-i]
 
score = L + R + U + D - 3
print(int(score.max()))

Buggy submission (verdict: Runtime Error):
from functools import reduce
import sys
import numpy as np
MOD = 1000000007

buffer = sys.stdin.buffer
H, W = list(map(int,buffer.readline().split()))
S = np.frombuffer(buffer.read(H*(W+2)), dtype="B") == ord(".")
S = S.reshape((H,W+2))[:,:-2]
L = np.empty((H,W), dtype="i4")
R = np.empty((H,W), dtype="i4")
U = np.empty((H,W), dtype="i4")
D = np.empty((H,W), dtype="i4")
 
L[:,0] = S[:,0]
for i in range(1,W):
    L[:,i] = (L[:,i-1] + 1) * S[:,i]
 
R[:,-1] = S[:,-1]
for i in range(1,W):
    R[:,-1-i] = (R[:,-i] + 1) * S[:,-1-i]
 
U[0] = S[0]
for i in range(1,H):
    U[i] = (U[i-1] + 1) * S[i]
 
D[-1] = S[-1]
for i in range(1,H):
    D[-1-i] = (D[-i] + 1) * S[-1-i]
 
score = L + R + U + D - 3
print(int(score.max()))
Problem p03597 (python)

Fixed submission:

a=int(input())
b=int(input())

print(a*a-b)

Buggy submission (verdict: Runtime Error):
a=input()
b=input()

print(a*a-b)
Problem p03359 (python)

Fixed submission:
a, b = map(int, input().split())
if a <= b:
  print(a)
else:
  print(a-1)

Buggy submission (verdict: Runtime Error):
import std.stdio, std.conv, std.string, std.algorithm;

void main()
{
auto ip = readln.split.to!(int[]);
auto x = 0;
if(ip[0] <= ip[1]){
  x += ip[0];
} else {
  x += ip[0] - 1;
}
  writeln(x);
}
Problem p03485 (python)

Fixed submission:
import math

a, b = map(int, input().split())
print(math.ceil((a + b) / 2))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(ceil((a + b) / 2))
Problem p03238 (python)

Fixed submission:
N=int(input())
if   (N==1):
            print('Hello World')
            
if   (N==2):
    A=int(input())
    B=int(input())
    if((A>=1)&(A<=9)):
        if((B>=1)&(B<=9)):
            print(A+B)

Buggy submission (verdict: Runtime Error):
N=input()
if   (N=='1'):
            print('Hello word')
            
if   (N=='2'):
    A=input()
    B=input()
            print(A+B)
Problem p03030 (python)

Fixed submission:
print('\n'.join([l[2] for l in sorted(sorted([[l[1][0], int(l[1][1]), str(l[0] + 1)] for l in enumerate(input().split() for _ in range(int(input())))], key=lambda l: l[1], reverse=True), key=lambda l: l[0])]))

Buggy submission (verdict: Runtime Error):
print('\n'.join([s[2] for s in sorted([input().split() + [i + 1] for i in range(int(input()))], key=lambda x:(x[0], -int(x[1])))]))

Buggy submission (verdict: Runtime Error):
print('\n'.join([l[2] for l in sorted(sorted([[l[1][0], int(l[1][1]), l[0] + 1] for l in enumerate(input().split() for _ in range(int(input())))], key=lambda l: l[1], reverse=True), key=lambda l: l[0])]))
Problem p03069 (python)

Fixed submission:
n = int(input())
s = list(input())

p = s.count('.')
q = 0
r = p

for i in range(n):
    if s[i] == '#':
        q += 1
    else:
        p -= 1
    r = min(r, p + q)
    # r = r if r < p + q else p + q

print(r)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(input())

p = s.count('.')
q = 0
r = p

for i in range(n):
    if s[i] == '#':
        q += 1
    else:
        p -= 1
    # r = min(r, p + q)
   	r = r if r < p + q else p + q

print(r)