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

Fixed submission:
import sys
X = int(input())
MOD = 10**9+7
M = [i*m for i in range(0, 10**4) for m in [-1, 1]]
for i in range(0, 10**4):
  for j in M:
    if i == j:
      break
    if X%(i-j)==0:
      if i**5-j**5==X:
        print(i, j)
        sys.exit(0)

Buggy submission (verdict: Runtime Error):
import sys
X = int(input())
MAX = 10**9
M = [0]
i = 1
while i**5 < MAX:
  M.append(i**5)
  M.append(-i**5)
  i += 1
#print(M)
  
for i in M:
  for j in M:
    if (i%MAX - j%MAX)%MAX == X%MAX:
      if j < 0:
        print(int(i**(1/5)), -int((-j)**(1/5)))
      else:
        print(int(i**(1/5)), int(j**(1/5)))
      sys.exit(0)

Buggy submission (verdict: Runtime Error):
import sys
X = int(input())
MAX = 10**9
M = [0]
i = 1
while i**5 < MAX:
  M.append(i**5)
  M.append(-i**5)
  i += 1
#print(M)
  
for i in M:
  for j in M:
    if (i%MAX - j%MAX)%MAX == X%MAX:
      if j < 0:
        print(int(i**(1/5)), -int((-j)**(1/5)))
      else:
        print(int(i**(1/5)), int(j**(1/5)))
      sys.exit(0)

Buggy submission (verdict: Runtime Error):
import sys
X = int(input())
MAX = 10**9
M = [0]
i = 1
while i**5 < MAX:
  M.append(i**5)
  M.append(-i**5)
  i += 1
#print(M)
  
for i in M:
  for j in M:
    if i - j == X:
      if j < 0:
        print(int(i**(1/5)), -int((-j)**(1/5)))
      else:
        print(int(i**(1/5)), int(j**(1/5)))
      sys.exit(0)

Buggy submission (verdict: Runtime Error):
import sys
X = int(input())
MAX = 10**9
M = [1, -1]
i = 1
while i**5 < MAX:
  i += 1
  M.append(i**5)
  M.append(-i**5)
  
for i in M:
  for j in M:
    if i - j == X:
      if j < 0:
        print(int(i**(1/5)), -int((-j)**(1/5)))
      else:
        print(int(i**(1/5)), int(j**(1/5)))
      sys.exit(0)
Problem p02713 (python)

Fixed submission:
import math
N = int(input())
all_gcd = []
for i in range(1, N+1):
  for j in range(1, N+1):
    x = math.gcd(i, j) if i != j else i
    for m in range(1, N+1):
      y = math.gcd(x, m) if x != m else x
      all_gcd.append(y)

print(sum(all_gcd))

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
GCD = [[math.gcd(i, j) for i in range(1, 10)] for j in range(1, 10)]
all_gcd = [GCD[GCD[i][j]][m] for i in range(1, N+1) for j in range(1, N+1) for m in range(1, N+1)]
print(sum(all_gcd))
Problem p02731 (python)

Fixed submission:
N = int(input())
print((N/3)**3)

Buggy submission (verdict: Runtime Error):
N = list(map(int, input().split()))
print((N/3)**3)
Problem p02742 (python)

Fixed submission:
N = list(map(int, input().split()))
if N[0] == 1 or N[1] == 1:
  print(1)
else:
  print((N[0]*N[1]+1)//2)

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <cmath>
using namespace std;

int main(void){
  long long int a, b;
  cin >> a >> b;
  if(a % 2 == 1 && b % 2 == 1){
    cout << (long long int)((long long int)(b*a)/(long long int)2 + 1) << endl;
  }
  else{
    cout << (long long int)((long long int)(b*a)/(long long int)2) << endl;
  }
  
  return 0;
}
Problem p02899 (python)

Fixed submission:
N = int(input())
S = list(map(int, input().split()))
indexed_S = sorted([[i,s] for i,s in enumerate(S)], key = lambda x: x[1])
print(" ".join([str(iS[0]+1) for iS in indexed_S]))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(map(int, input().split()))
indexed_S = sorted([i,s for i,s in enumerate(S)], key = lambda x: x[1])
print(" ".join([iS[0] for iS in indexed_S])
Problem p02921 (python)

Fixed submission:
S = input()
T = input()
print(len([1 for i in range(3) if S[i]==T[i]]))

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
print(len([1 for i in range(3) if S[i]==T[i]])
Problem p02945 (python)

Fixed submission:
A, B = list(map(int, input().split()))
print(max([A+B, A-B, A*B]))

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))
info = [list(map(int, input().split())) for i in range(N)]
info = sorted(info, key=lambda x:(x[0], x[1]), reverse=True)
#print(info)

result = 0
for j in range(len(info)):
    if info[j][0] <= M:
      #print(info[j], i)
      result += info[j][1]
      M -= 1
    if M == 0:
      break
print(result)
Problem p02963 (python)

Fixed submission:
L = 10 ** 9
N = int(input())
y = (N - 1) // L + 1
x = (L - N) % L
print(0, 0, L, 1, x, y)

Buggy submission (verdict: Runtime Error):
N = int(input())
for i in range(N//2, N+1):
  if N % i == 0:
    print(0, 0, 0, N//i, i, 0)
    break
Problem p03043 (python)

Fixed submission:
import math
N, K = list(map(int, input().split()))

i = 1
result = 0
for i in range(1, N+1):
  temp = 1 / N
  now = i
  while now < K:
    now *= 2
    temp *= 0.5
  result += temp
  
print(result)

Buggy submission (verdict: Runtime Error):
import math
N, K = list(map(int, input().split()))
result = 0
for i in range(1, N+1):
  result += (1/N) * 0.5 ** (math.floor(math.log(K//i, 2))+1)
print("{:.12}".format(result))
Problem p03050 (python)

Fixed submission:
N = int(input())

result = 0
for i in range(1, int(N**0.5)+1):
  if N % i == 0:
    for j in set([i, N//i]):
      num = j - 1
      if num != 0 and N // num == N % num:
        result += num

print(int(result))

Buggy submission (verdict: Runtime Error):
N = int(input())
 
result = 0
for i in range(1, int(N**0.5)+1):
  # 偽物が通ってしまう．sample 2 の時，999999ずれる
  if (N - i) % i == 0:
    temp = (N - i) // i
    if N // temp == N % temp:
      result += temp

print(int(result))
Problem p03069 (python)

Fixed submission:
N = int(input())
S = input()
 
arr = [0] if S[0] == "." else []
b, w = 0, 0
for i in range(len(S)):
  if S[i] == ".":
    w += 1
  else:
    b += 1
  if S[i:i+2] == "#.":
    arr.append(b)
  if S[i:i+2] == ".#":
    arr.append(w)
if S[-1] == ".":
  arr.append(w)
#print(arr)
 
result = w
for i in range(0, len(arr), 2):
  result = min([arr[i]+w-arr[i+1], result])

print(result)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
 
arr = [0] if S[0] == "." else []
b, w = 0, 0
for i in range(len(S)):
  if S[i] == ".":
    w += 1
  else:
    b += 1
  if S[i:i+2] == "#.":
    arr.append(b)
  if S[i:i+2] == ".#":
    arr.append(w)
if S[-1] == ".":
	arr.append(w)
#print(arr)
 
result = arr[-1]+arr[1]
for i in range(0, len(arr), 2):
  result = min([arr[i]+arr[-1]-arr[i+1], result])

print(result)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
 
arr = [0] if S[0] == "." else []
count = 0
for i in range(len(S)):
  count += 1
  if S[i:i+2] == "#.":
    arr.append(count)
    count = 0  
  if S[i:i+2] == ".#":
    arr.append(count)
    count = 0
if S[-1] == ".":
  arr.append(count)
#print(arr)
 
result = sum([min(arr[i:i+2]) for i in range(0, len(arr)+1, 2)])
print(result)
Problem p03078 (python)

Fixed submission:
N = list(map(int, input().split()))[-1]
A = sorted(list(map(int, input().split())), reverse=True)[:N]
B = sorted(list(map(int, input().split())), reverse=True)[:N]
C = sorted(list(map(int, input().split())), reverse=True)[:N]

first = [i+j for i in A for j in B]
first = sorted(first, reverse=True)[:N]
second = [i+j for i in first for j in C]
result = sorted(second, reverse=True)[:N]

[print(i) for i in result]

Buggy submission (verdict: Runtime Error):
N = list(map(int, input().split()))[-1]
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

first = [i+j for i in A for j in B]
first = sorted(first)[::-1]
second = [i+j for i in first for j in C if i >= first[N]]

print("\n".join([str(value) for value in sorted(second)[::-1][:N]]))
Problem p03086 (python)

Fixed submission:
inp = input()
res = 0
for i in range(len(inp)+1):
  for j in range(i+1, len(inp)+1):
    if len([w for w in inp[i:j] if w in ["A", "C", "G", "T"]]) == (j-i):
      res = max(res, j-i)
print(res)

Buggy submission (verdict: Runtime Error):
inp = input()
res = 0
for i in range(len(inp)):
	for j in range(i, len(inp)):
    	if len([w for w in inp[i:j] if w in ["A", "C", "G", "T"]]) == (j-i):
        	res = max(res, j-i)
print(res)

Buggy submission (verdict: Runtime Error):
import numpy as np
inp = input()
ACGT = ["", "A", "C", "G", "T"]
sentences = [j+K+m+n for j in ACGT for k in ACGT for m in ACGT for n in ACGT]
length = [len(sent) for sent in sentences if sent in inp]
print(np.max(length))
Problem p03087 (python)

Fixed submission:
import numpy as np
N, Q = list(map(int, input().split()))
S = input()
t = [0] * N
for j in range(1, N):
  t[j] = t[j-1] + 1 if S[j-1:j+1] == "AC" else t[j-1]
for i in range(Q):
  l, r = list(map(int, input().split()))
  print(t[r-1]-t[l-1])

Buggy submission (verdict: Runtime Error):
import numpy as np
N, Q = list(map(int, input().split()))
S = input()
for i in range(Q):
  l, r = list(map(int, input().split()))
  print(np.sum([1 for i in range(len(S)) if S[i:i+1] == "AC"])

Buggy submission (verdict: Runtime Error):
N, Q = list(map(int, input().split()))
S = input()
for i in range(Q):
  l, r = list(map(int, input().split()))
  print(np.sum([1 for i in range(len(S)) if S[i:i+1] == "AC"])
Problem p03101 (python)

Fixed submission:
H, W = list(map(int, input().split()))
h, w = list(map(int, input().split()))
 
print(int((H-h)*(W-w)))

Buggy submission (verdict: Runtime Error):
H, W = list(map(int, input()))
h, w = list(map(int, input()))

print(int((H-h)*(W-w)))
Problem p03102 (python)

Fixed submission:
import numpy as np
N, M, C = list(map(int, input().split()))
B = np.asarray(input().split(), dtype=np.int)
A = []
for i in range(N):
  A.append(list(map(int, input().split())))
A = np.asarray(A, dtype=np.int)
 
print(np.sum(np.dot(A, B.T) > (-1*C)))

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M, C = list(map(int, input().split()))
B = np.asarray(input().split(), dtype=np.int)
A = []
for i in range(N):
  A.append(list(map(int, input().split())))
A = np.asarray(A, dtype=np.int)

np.sum(A @ B.T > (-1*C))
Problem p03112 (python)

Fixed submission:
import bisect
import numpy as np
 
hint = list(map(int, input().split()))
s = [int(input()) for i in range(sum(hint))]
# print(s)

def search_min_pos(arr, target):
  index = bisect.bisect_left(arr, target)
  if 0 == index:
    dist = arr[index]
  else:
    dist = arr[index-1:index+1]
  if not isinstance(dist, list):
    dist = [dist]
  return dist

a_arr = s[:hint[0]]
b_arr = s[hint[0]:-hint[2]]
sum = 0
for t in s[-hint[2]:]:
  a_pos = search_min_pos(a_arr, t)
  b_pos = search_min_pos(b_arr, t)
  #print(t, a_pos, b_pos)
  min_dist = 10 ** 11
  for a in a_pos:
    b_against_a = search_min_pos(b_arr, a)
    for ba in b_against_a:
      min_dist = min([min_dist, abs(t-a)+abs(ba-a)])
  for b in b_pos:
    a_against_b = search_min_pos(a_arr, b)
    for ab in a_against_b:
      min_dist = min([min_dist, abs(t-b)+abs(ab-b)])
  print(min_dist)

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

hint = list(map(int, input().split()))
s = [int(input()) for i in range(sum(hint))]
# print(s)

a = np.asarray(s[:hint[0]])
b = np.asarray(s[hint[0]:-hint[2]])
sum = 0
for t in s[-hint[2]:]:
    a_dis = np.argmin(np.abs(a - t)[a > t-1000 and a < t+1000])
    b_dis = np.argmin(np.abs(b - t))
    print(np.min([np.abs(b[b_dis] - t) + np.min(np.abs(a[np.max([a_dis-1,0]):a_dis+1] - b[b_dis])), np.abs(a[a_dis] - t) + np.min(np.abs(b[np.max([b_dis-1,0]):b_dis+1] - a[a_dis]))]))
Problem p03149 (python)

Fixed submission:
s = list(map(int, input().split()))
if sorted(s) == [1, 4, 7, 9]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
s = list(map(int, input()))
if list(sorted(s)) == [1, 4, 7, 9]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
s = list(map(int, input()))
if sorted(s) == [1, 4, 7, 9]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
s = list(map(int, input()))
if s == [1, 4, 7, 9]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
s = list(map(int, input()))
t = [1, 4, 7, 9]
[t.pop() for i in sorted(s) if i in t]
if len(t) == 4:
  print("YES")
else:
  print("NO")
Problem p03230 (python)

Fixed submission:
K = int(input())

def calc_n(K):
  for n in range(1, int(K/2)+2):
    if n*(n+1)/2 == K:
      return n
  return "No"

N = calc_n(K)
if not isinstance(N, int):
  print(N)
else:
  print("Yes")
  print(N+1)
  last = [i for i in range(1, N+1)]
  count = 2
  first_set = [str(i) if i == 1 else str(sum(last[:i-1])+1) for i in range(1, N+1)]
  print(N, " ".join(first_set))
  last_set = [str(sum(last[:i])) for i in range(1,N+1)]
  print(N, " ".join(last_set))
  while count != N+1:
    first_number = sum(last[:count-1])+1
    other_set = [i for i in range(first_number, first_number+count)]
    other_set.extend([first_number+count*(i+1)-1+sum(last[:i-1]) for i in range(1, N-count+1)])
    count += 1
    other_set = [str(i) for i in other_set]
    print(N, " ".join(other_set))

Buggy submission (verdict: Runtime Error):
K = int(input())

def calc_n(K):
  for n in range(1, int(K/2)+2):
    if n*(n+1)/2 == K:
      return n
  return "NO"

N = calc_n(K)
if not isinstance(N, int):
  print(N)
print(N+1)
all_num = {i:2 for i in range(1, K+1)}
remain = K * 2
#print(all_num)
pair = []
for i in range(1, K+1):
  if all_num[i] == 2:
    pair.append(i)
    all_num[i] -= 1
    remain -= 1
    if len(pair) == N:
      break
print(N, " ".join([str(i) for i in pair]))

while remain != N:
  pair = []
  for i in range(1, K+1):
    if all_num[i] == 1 and len(pair) == 0:
      pair.append(i)
      all_num[i] -= 1
      remain -= 1
    if all_num[i] == 2 and len(pair) != 0:
      pair.append(i)
      all_num[i] -= 1
      remain -= 1
      if len(pair) == N:
        break
  print(N, " ".join([str(i) for i in pair]))

pair = []
for i in range(1, K+1):
  if all_num[i] == 1:
    pair.append(i)
    all_num[i] -= 1
    remain -= 1
    if len(pair) == N:
      break
print(N, " ".join([str(i) for i in pair]))
Problem p03251 (python)

Fixed submission:
N, K, A, B = list(map(int, input().split()))
A_max = max(list(map(int, input().split())))
B_min = min(list(map(int, input().split())))

if A_max > A and B_min <= B and A_max < B_min:
  print("No War")
else:
  print("War")

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

XY = np.asarray(input().split(), dtype=int)
X = np.asarray(input().split(), dtype=int)
Y = np.asarray(input().split(), dtype=int)

if np,sum(X==XY[2]) == 1 or np,sum(Y==XY[3]) == 1:
    print("no war")
elif np.max(X) <= np.min(Y):
    print("no war")
else:
    print("war"
Problem p03408 (python)

Fixed submission:
from collections import defaultdict
N = int(input())
bd = defaultdict(lambda: 0)
for i in range(N):
  bd[input()] += 1
N = int(input())
for i in range(N):
  bd[input()] -= 1

print(max([max(bd.values()), 0]))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
N = int(input())
bd = defaultdict(lambda: 0)
for i in range(N):
  bd[input()] += 1
N = int(input())
for i in range(N):
  bd[input()] -= 1

print(max([max(bd.values()), 0])
Problem p03695 (python)

Fixed submission:
N = int(input())
X = list(map(int, input().split()))
X = [x//400 for x in X]
min_X = len(set([x for x in X if x < 8]))
max_X = min_X + len([x for x in X if x >= 8])
# この max は気づかないなあ
print(max([min_X, 1]), max_X)

Buggy submission (verdict: Runtime Error):
N = int(input())
X = list(map(int, input().split()))
X = [x//400 for x in X]
min_X = len(set([x for x in X if x < 8]))
max_X = min_X + len([x for x in X if x >= 8])
# この max は気づかないなあ
print(max([min_X, 1], max_X)
Problem p02909 (python)

Fixed submission:
s=input()
if s[0]=='S':
   print('Cloudy')
elif s[0]=='C':
   print('Rainy')
else:
   print('Sunny')

Buggy submission (verdict: Runtime Error):
s=input()
if s[0]=='S':
   print('Cloudy')
else if s[0]=='C':
   print('Rainy')
else:
   print('Sunny')
Problem p03085 (python)

Fixed submission:
b = input()
if b == 'A':
  print('T')
elif b == 'T':
  print('A')
elif b == 'C':
  print('G')
else:
  print('C')

Buggy submission (verdict: Runtime Error):
import re
N, Q = map(int,input().split())
S = input()

for i in range(Q):
  l, r = map(int,input().split())
  Si = S[l-1:r]
  
  m = re.match('AC',Si)
  print(len(m.group())
Problem p03087 (python)

Fixed submission:
N, Q = map(int,input().split())
S = input()
t=[0]*(N+1)
for i in range(N):
  t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])

Buggy submission (verdict: Runtime Error):
N, Q = map(int,input().split())
S = input()
count = 0

for i in range(Q):
  l, r = map(int,input().split())
  Si = S[l-1:r]
  
  len_Si = len(Si)
  for i in range(len_Si-1):
    if Si[i:i+2] == 'AC'
      count += 1
  print(count)
  count = 0
Problem p03238 (python)

Fixed submission:
n = int(input())
if n == 1:
  print('Hello World')
else:
  a = int(input())
  b = int(input())
  print(a+b)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = int(input())
b = int(input())
if n == 1:
  print('Hello World')
else:
  print(a+b)
Problem p03287 (python)

Fixed submission:
import sys 
input = sys.stdin.readline

n, m = map(int,input().split())
s = [0] #累積和
a = list(map(int,input().split()))
for i in range(n):
    s.append(s[i]+a[i])

mod = {} 
for i in s:
    if i%m in mod:
        mod[i%m] += 1
    else:
        mod[i%m] = 1

ans = 0
for i in mod:
    j = mod[i]
    ans += j*(j-1)//2

print(ans)

Buggy submission (verdict: Runtime Error):
import sys 
input = sys.stdin.readline

n, m = map(int,input().split())
s = [0] #累積和
a = list(map(int,input().split()))
for i in range(n):
    s.append(s[i]+a[i])

mod = [0]*m
for i in s:
    mod[i%m] += 1

ans = 0
for i in mod:
    ans += i*(i-1)//2

print(ans)
Problem p03323 (python)

Fixed submission:
a, b = map(int,input().split())
if a <= 8 and b <= 8:
    print('Yay!')
else:
    print(':(')

Buggy submission (verdict: Runtime Error):
a, b = int(intput())
if a <= 8 and b <= 8:
    print('Yay!')
else:
    print(':(')
Problem p03474 (python)

Fixed submission:
a,b=map(int,input().split())
s=input()
f=1
for i in range(a):
   if s[i]=='-':
      f=0
if s[a]!='-':
   f=0
for j in range(b):
   if s[a+1+j]=='-':
      f=0
if f:
   print('Yes')
else:
   print('No')

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())print(3)
s=input()
f=1
for i in range(a):
   if s[i]=='-':
      f=0
if s[a]!='-':
   f=0
for j in range(b):
   if s[a+1+j]=='-':
      f=0
if f:
   print('Yes')
else:
   print('No')
Problem p03623 (python)

Fixed submission:
x, a, b = map(int,input().split())
if abs(x-a)<abs(x-b):
    print('A')
else:
    print('B')

Buggy submission (verdict: Runtime Error):
x, a, b - map(int,input().split())
if abs(x-a)<abs(x-b):
    print(a)
else:
    print(b)
Problem p03645 (python)

Fixed submission:
n,m=map(int,input().split())
li = []
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    li.append(b)
  elif b==n:
    li.append(a)

if len(set(li))==len(li): print('IMPOSSIBLE')
else: print('POSSIBLE')

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
flag=false
one = []
enu = []
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    one.append(b)
  elif b==n:
    enu.append(a)

for i in one:
  if i in enu:
    flag=true

if flag: print('POSSIBLE')
else: print('IMPOSSIBLE')
Problem p03680 (python)

Fixed submission:
n=int(input())
a=[]
for i in range(n):
    ai=int(input())
    a.append(ai)
finish=False
for i in range(n):
    if a[0]==2:
        print(1)
        finish=True
        break
    if i==0:
        next=a[a[0]-1]
    else:
        next=a[next-1]
    if next==2:
        print(i+2)
        finish=True
        break
if not finish:
    print(-1)

Buggy submission (verdict: Runtime Error):
=int(input())
a=[]
for i in range(n):
    ai=int(input())
    a.append(ai)
finish=False
for i in range(n):
    if i==0:
        next=a[a[0]-1]
    else:
        next=a[next-1]
    if next==2:
        print(i+2)
        finish=True
        break
if not finish:
    print(-1)
Problem p03719 (python)

Fixed submission:
a,b,c=map(int,input().split())
if a<=c<=b:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a,b,c=mqp(int,input().split())
if a<=c<=b:
  print('Yes')
else:
  print('No')
Problem p03162 (python)

Fixed submission:
from sys import stdin,stdout
inp = stdin.readline
out = stdout.write
n = int(inp())
dp = [[0 for _ in range(3)] for _ in range(n)]
dp[0] = list(map(int,inp().split()))
for i in range(1,n):
    a,b,c = map(int,inp().split())
    dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a
    dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b
    dp[i][2] = max(dp[i-1][1],dp[i-1][0])+c
out(str(max(dp[n-1])))

Buggy submission (verdict: Runtime Error):
from sys import stdin,stdout
inp = stdin.readline
out = stdout.write
n = int(inp())
dp = [[0 for _ in range(3)] for _ in range(n)]
dp[0] = map(int,inp().split())
for i in range(1,n):
    a,b,c = map(int,inp().split())
    dp[i][0] = max(dp[i][1]+b[i],dp[i][2]+c[i])
    dp[i][1] = max(dp[i][0]+a[i],dp[i][2]+c[i])
    dp[i][2] = max(dp[i][1]+b[i],dp[i][0]+a[i])
out(str(max(dp[n-1])))
Problem p02924 (python)

Fixed submission:
if __name__ == '__main__':
    n = int(input())
    t = (1 + n) * n // 2
    print(t - n)

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    n = int(input())
    print(sum(list(range(1, n + 1))) - n)
Problem p02947 (python)

Fixed submission:
from scipy.misc import comb
n = int(input())
s = sorted([''.join(sorted(list(input()))) for i in range(n)])
ans = 0
tmp = 1
for i in range(1, n):
    if s[i] == s[i - 1]:
        tmp += 1
    else:
        ans += comb(tmp, 2, exact = True)
        tmp = 1
ans += comb(tmp, 2, exact = True)
print(ans)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
n = int(input())
s = sorted([''.join(sorted(list(input()))) for i in range(n)])
ans = 0
tmp = 1
for i in range(1, n):
    if s[i] == s[i - 1]:
        tmp += 1
    else:
        ans += comb(tmp, 2, exact = True)
        tmp = 1
ans += comb(tmp, 2, exact = True)
print(ans)
Problem p03061 (python)

Fixed submission:
from operator import itemgetter
from functools import reduce
import fractions as f
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
rev_a = list(reversed(a))
ans = 0
accumulation_gcd = [0] * n
rev_accumulation_gcd = [0] * n
accumulation_gcd[0] = a[0]
rev_accumulation_gcd[0] = rev_a[0]

for i in range(1, n):
    accumulation_gcd[i] = f.gcd(a[i], accumulation_gcd[i-1])
    rev_accumulation_gcd[i] = f.gcd(rev_a[i], rev_accumulation_gcd[i-1])

rev_accumulation_gcd.reverse()


for i in range(n):
    if i == 0:
        ans = max(ans, rev_accumulation_gcd[1])
    elif i == (n - 1):
        ans = max(ans, accumulation_gcd[n-2])
    else:
        ans = max(ans, f.gcd(accumulation_gcd[i-1], rev_accumulation_gcd[i+1]))

print(ans)

Buggy submission (verdict: Runtime Error):
import functools
import math
n = int(input())
a = list(map(int,input().split()))
odd_tmp = []
ans = 1
oddcnt = 0
a.sort()

for i in range(n):
    if a[i] % 2 != 0:
        oddcnt += 1
        odd_tmp.append(int(a[i]))
if oddcnt < 2:
    if oddcnt == 1:
        a.remove(odd_tmp[0])
    print(functools.reduce(math.gcd, a))
    exit()
for i in range(oddcnt):
    tmp = [] + a
    tmp.remove(odd_tmp[i])
    ans = max(functools.reduce(math.gcd, tmp), ans)

print(ans)
Problem p03076 (python)

Fixed submission:
import math

a = []
b = []
ans = 0
for i in range(5):
    a.append(int(input()))
ans = sum(a)
for i in range(5):
    tmp = a[i] % 10
    if tmp != 0:
        b.append(10 - tmp)
if len(b) == 0:
    print(ans)
else:
    print(ans + sum(b) - max(b))

Buggy submission (verdict: Runtime Error):
import math

a = []
b = []
ans = 0
for i in range(5):
    a.append(int(input()))
ans = sum(a)
for i in range(5):
    tmp = a[i] % 10
    if tmp != 0:
        b.append(10 - tmp)
print(ans + sum(b) - max(b))