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

Fixed submission:
from bisect import bisect
a,b,q = map(int, input().split())
s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]

inf = float('INF')
for _ in range(q):
    x = int(input())
    # print('x', x)
    ss = bisect(s, x)
    tt = bisect(t, x)
    ans = inf
    for i in range(max(ss-1,0),min(ss+1,a)):
        for j in range(max(tt-1,0),min(tt+1,b)):
            ii,jj = abs(s[i] - x) + abs(s[i] - t[j]), abs(t[j] - x) + abs(s[i] - t[j])
            tmp = min(ii,jj)
            if ans > tmp:
                ans = tmp
    print(ans)

Buggy submission (verdict: Runtime Error):
from bisect import bisect
# import numpy as np
a,b,q = map(int, input().split())
s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]
inf = float('INF')

for _ in range(q):
    x = int(input())
    # print('x', x)
    ss = bisect(s, x)
    tt = bisect(t, x)
    ans = inf
    # print(s[min(ss,a-1)], t[min(tt,b-1)], x)
    j,l = abs(t[max(tt-1,0)] - x), abs(t[min(b-1,tt)] - x)
    if ss :
        i = abs(s[ss-1] - x)
        if tt :
            if sorted([s[ss-1], x, t[tt-1]]).index(x) == 1:
                if ans > i+j+min(i,j):
                    ans = i+j+min(i,j)
            else:
                if ans > max(i,j):
                    ans = max(i,j)
        if tt < b:
            if sorted([s[ss-1], x, t[tt]]).index(x) == 1:
                if ans > i+l+min(i,l):
                    ans = i+l+min(i,l)
            else:
                if ans > max(i,l):
                    ans = max(i,l)
    if ss < a:
        k = abs(s[ss] - x)
        if tt:
            if sorted([s[ss], x, t[tt-1]]).index(x) == 1:
                if ans > i+j+min(k,j):
                    ans = i+j+min(k,j)
            else:
                if ans > max(k,j):
                    ans = max(k,j)
        elif tt < b:
            if sorted([s[ss], x, t[tt]]).index(x) == 1:
                if ans > i+j+min(k,l):
                    ans = i+j+min(k,l)
            else:
                if ans > max(k,l):
                    ans = max(k,l)
    print(ans)
Problem p03164 (python)

Fixed submission:
n,W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
inf = float('INF')
bag = [inf for _ in range(10**5+1)]
bag[0] = 0

ans = 0
for w,v in a:
  for i in range(min(v,10**5+1), 10**5+1)[::-1]:
    if bag[i-v] + w < min(bag[i],W+1):
        bag[i] = bag[i-v] + w
        ans = max(ans, i)
print(ans)

Buggy submission (verdict: Runtime Error):
n,W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
inf = float('INF')
bag = [inf for _ in range(10**5+1)]
bag[0] = 0

ans = 0
for w,v in a:
    left = v if v < 100001 else 100001
    right = left + ans + 1 if left + ans + 1 < 100001 else 100001
    for i in range(left, right)[::-1]:
        if bag[i-v] + w < bag[i] and bag[i-v] + w < W+1):
            bag[i] = bag[i-v] + w
            if i > ans:
                ans = i
print(ans)
Problem p03212 (python)

Fixed submission:
from collections import deque
N = int(input())
memo = {i:1 for i in [357, 375, 537, 573, 735, 753]}
ans = 0
queue = deque()
mod = [10**i for i in range(10)]
for key in memo.keys():
  if key <= N:
    ans += 1
    queue.append(key)
while queue:
    key = queue.popleft()
    len_key = len(str(key))
    for i in range(len_key):
        for j in [3,5,7]:
            tmp = (key // mod[i]) * mod[i+1] + j * mod[i] + key % mod[i]
            if tmp not in memo and tmp <= N:
                ans += 1
                memo[tmp] = 1
                queue.append(tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc114/submissions/6262572

from itertools import product
N = input()
n = int(N)
ans = 0
for i in range(len(N)+1):
    for s in product(["3","5","7"],repeat=i):
        if int("".join(s)) <= n and "3" in s and "5" in s and "7" in s:
            ans += 1
print(ans)
Problem p03239 (python)

Fixed submission:
N, T = map(int, input().split())
mn = 1001
for i in range(N):
  c,t = map(int, input().split())
  if t <= T:
    mn = min(c,mn)
print(mn if mn < 1001 else 'TLE')

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().split())
mn = 1000
for i in range(N):
  c,t = map(int, input().split())
  if t <= T:
	mn = min(c,mn)
print(mn)
Problem p03240 (python)

Fixed submission:
N = int(input())

A = []
for i in range(N):
    x,y,h = map(int, input().split())
    A.append([x,y,h])
H = max([h for x,y,h in A])
while True:
    for i in range(100+1):
        for j in range(100+1):
            for x,y,h in A:
                tx, ty = abs(x-i), abs(y-j)
                if max(H - tx - ty, 0) != h:
                    break
            else:
                print(i,j,H)
                exit()
    H += 1

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

A = []
for i in range(N):
    x,y,h = map(int, input().split())
    A.append([x,y,h])
for i in range(100+1):
    for j in range(100+1):
        lst = {}
        for x,y,h in A:
            if h == 0:
                continue
            tx, ty = abs(x-i), abs(y-j)
            H = h + tx + ty
            if H not in lst:
                lst[H] = 1
            else :
                lst[H] += 1
        if len(lst) == 1 and lst.keys()[0] != 0:
            print(i,j,H)
Problem p03241 (python)

Fixed submission:
N, M = map(int, input().split())
ceil = M // N
for i in range(1,ceil+1)[::-1]:
    tmp = M - i * (N - 1)
    if tmp > 0 and tmp % i == 0:
        print(i)
        break

Buggy submission (verdict: Runtime Error):
import math
N, M = map(int, input().split())
mx = 0
for i in range(1, math.floor(math.sqrt(M))+1):
    if M % i == 0:
        if M // i >= N:
            mx = max(mx, i)
    	else:
            mx = max(mx, M//i)
print(mx)

Buggy submission (verdict: Runtime Error):
import math
N, M = map(int, input().split())
mx = 0
for i in range(1, math.floor(math.sqrt(M))+1):
    if M % i == 0:
        if M // i >= N:
            mx = max(mx, i)
    	if i >= N:
        	mx = max(mx, M//i)
print(mx)
Problem p03282 (python)

Fixed submission:
S = input()
K = int(input())

#go = 5000000000000000
C = '1'
for i in range(len(S)):
    if S[i] != '1' or i+1 == K:
        C = S[i]
        break
print(C)

Buggy submission (verdict: Runtime Error):
def resolve():
    s = input()
    k = int(input())
    cnt = -1
    for i in range(len(s)):
        if s[i] != '1':
            break
        cnt = i + 1
    if cnt > k:
        print(1)
    else:
        print(s[cnt] if cnt > -1 else s[0])

if __name__ == '__main__':
    resolve()
Problem p03289 (python)

Fixed submission:
S = input()
flag = True
if S[0] != 'A' or S[2:-1].count('C') != 1 or S[1].lower() != S[1] or S[-1].lower() != S[-1]:
  flag = False
for i in range(2,len(S)-1):
  if S[i] != 'C' and S[i].lower() != S[i]:
    flag = False
print('AC' if flag else 'WA')

Buggy submission (verdict: Runtime Error):
S = input()
flag = True
if S[0] != 'A' or S[2:-2].count('C') != 1 or S[1].lower() != S[1] or S[-1].lower() != S[-1]:
  flag = False
for i in range(2,len(S)-1):
  if s[i] != 'C' and s[i].lower() != s[i]:
    flag = False
print('AC' if flag else 'WA')

Buggy submission (verdict: Runtime Error):
S = input()
flag = True
if S[0] != 'A' or S[2:-2].count('C') != 1 or S[1].lower() != S[1] or S[-1].lower() != S[-1]:
  flag = False
for i in range(2,len(S)-1):
  if s != 'C' and s.lower() != s:
    flag = False
print('AC' if flag else 'WA')
Problem p03292 (python)

Fixed submission:
s = "100 10 25"
list = list(map(int, input().split()))
#list = list(map(int, s.split()))

a = abs(list[1]-list[0])
b = abs(list[1]-list[2])
c = abs(list[2]-list[0])
if (a < b):
	print(b if b>c else c)
else :
	print(a if c<a else c)

Buggy submission (verdict: Runtime Error):
s = "11 5 5"
list = list(map(int, input().split()))

a = abs(list[1]-list[0])
b = abs(list[1]-list[2])
c = abs(list[2]-list[0])
if (a < b):
	if (b < c)
		print(a+b)
	else :
		print(a+c)
else :
	if (a < c)
		print(b+a)
	else :
		print(b+c)

Buggy submission (verdict: Runtime Error):
s = "11 5 5"
list = list(map(int, input().split()))

a = abs(list[1]-list[0])
b = abs(list[1]-list[2])
c = abs(list[2]-list[0])
l = a+b
m = b + c
n = a+c
if (l < m):
	if (l < n)
		print(l)
	else :
		print(n)
else :
	if (m < n)
		print(m)
	else :
		print(n)
Problem p03294 (python)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
print(sum(A)-N)

Buggy submission (verdict: Runtime Error):

def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y)

N = int(input())
A = list(map(int, input().split()))
#N = 7
#A = [994, 518, 941, 851, 647, 2, 581]
t = A[0]
for i in range(1,N):
	if (t % A[i] == 0):
		continue
	t = t * A[i] / gcd(t, A[i])
sum = 0
t -= 1
for i in range(N):
	sum += t % A[i]
print(int(sum))

Buggy submission (verdict: Runtime Error):

def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y)

N = int(input())
A = list(map(int, input().split()))
#N = 7
#A = [994, 518, 941, 851, 647, 2, 581]
t = A[0]
for i in range(1,N):
	if (t % A[i])
		continue
	t = t * A[i] / gcd(t, A[i])
sum = 0
t -= 1
for i in range(N):
	sum += t % A[i]
print(int(sum))

Buggy submission (verdict: Runtime Error):

def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y)

N = int(input())
A = list(map(int, input().split()))
#N = 7
#A = [994, 518, 941, 851, 647, 2, 581]
t = A[0]
for i in range(1,N):
	t = t * A[i] / gcd(t, A[i])
sum = 0
t -= 1
for i in range(N):
	sum += t % A[i]
print(int(sum))

Buggy submission (verdict: Runtime Error):

def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y)

N = int(input())
A = list(map(int, input().split()))
#N = 3
#A = [3,4,6]

t = A[0]
for i in range(1,N):
	t = t * A[i] / gcd(t, A[i])
sum = 0
t -= 1
#print(t)
for i in range(N):
	sum += t % A[i]
print(sum)
Problem p03309 (python)

Fixed submission:
from math import floor, ceil
N = int(input())
A = []
for i,a in enumerate(input().split()):
  A.append(int(a)-(i+1))
A.sort()
if N % 2 :
    print(-1*sum(A[:N//2]) + sum(A[N//2+1:]))
else:
    print(-1*sum(A[:N//2]) + sum(A[N//2:]))

Buggy submission (verdict: Runtime Error):
9
1 2 3 4 5 6 7 8 9
Problem p03337 (python)

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

Buggy submission (verdict: Runtime Error):
A,B = map(int, input().split())
print(max(A+B,A−B,A*B))
Problem p03351 (python)

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

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
print('Yes' if abs(a-c) <= d or (abs(a-b)<=d and abs(b-c)<=d else 'No')
Problem p03385 (python)

Fixed submission:
S = input()
print('Yes' if 'a' in S and 'b' in S and 'c' in S else 'No')

Buggy submission (verdict: Runtime Error):
S = input()
pritn('Yes' if 'a' in S and 'b' in S and 'c' in S else 'No')
Problem p03408 (python)

Fixed submission:
from collections import Counter as cnt

N = int(input())
counter = {}
for i in range(N):
  s = input()
  if s not in counter:
    counter[s] = [1,0]
  else:
    counter[s][0] += 1
N = int(input())
for i in range(N):
  s = input()
  if s not in counter:
    counter[s] = [0,1]
  else:
    counter[s][1] += 1
counter[0] = [0,0]

print(max([b-r for b,r in counter.values()]))

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

N = int(input())
blue = []
for i in range(N):
  blue.append(int(input()))
blue = cnt(blue)
N = int(input())
red = []
for i in range(N):
  red.append(int(input()))
red = cnt(red)

p = blue - red
print(p.most_common()[0][1])
Problem p03425 (python)

Fixed submission:
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
S = [s[0] for s in S if s[0] in 'MARCH']
counter = Counter(S)
if len(counter) < 3:
  print(0)
else:
  cnt = 0
  mar = 'MARCH'
  for a in range(0,3):
    if mar[a] not in counter:
      continue
    for b in range(a+1, min(a+1+3, 5-1)):
      if mar[b] not in counter:
        continue
      for c in range(b+1, min(b+1+3, 5)):
        if mar[c] not in counter:
          continue
        # print(mar[a], mar[b], mar[c])
        cnt += counter[mar[a]] * counter[mar[b]] * counter[mar[c]]
  print(cnt)

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
S = [s[0] for s in S if s[0] in 'MARCH']
counter = Counter(S)
if len(counter) < 3:
  print(0)
else:
  cnt = 0
  mar = 'MARCH'
  for a in range(0,3):
    if mar[a] not in counter:
      continue
    for b in range(a+1, min(a+1+3, N-1)):
      if mar[b] not in counter:
        continue
      for c in range(b+1, min(b+1+3, N)):
        if mar[c] not in counter:
          continue
        # print(mar[a], mar[b], mar[c])
        cnt += counter[mar[a]] * counter[mar[b]] * counter[mar[c]]
  print(cnt)

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
S = [s[0] for s in S if s[0] in 'MARCH']
counter = Counter(S)
if len(counter) < 3:
  print(0)
else:
  cnt = 0
  mar = 'MARCH'
  for a in range(0,3):
    if mar[a] not in counter:
      continue
    for b in range(a+1, min(a+1+3, N)):
      if mar[b] not in counter:
        continue
      for c in range(b+1, min(b+1+3, N)):
        if mar[c] not in counter:
          continue
        cnt += counter[mar[a]] * counter[mar[b]] * counter[mar[c]]
  print(cnt)
Problem p03434 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
if len(A) & 1:
  A.append(0)
A.sort()
print(sum([A[i+1]-A[i] for i in range(0, len(A), 2)]))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
if len(A) & 1:
  A.append(0)
A.sort()
print(sum([A[i+1]-A[i] for i in range(0, A, 2)]))
Problem p03456 (python)

Fixed submission:
s = int(input().replace(' ', ''))
for i in range(s):
  if i * i > s:
    print('No')
    break
  elif i**2 == s:
    print('Yes')
    break

Buggy submission (verdict: Runtime Error):
a = int(input().replace(" ", ""))
for i in range(101):
  if i == (a / i):
    print("Yes")
    break
else:
  print("No")
Problem p03470 (python)

Fixed submission:
N = int(input())

lst = []
for i in range(N):
  lst.append(int(input()))
print(len(set(lst)))

Buggy submission (verdict: Runtime Error):
N = int(input())
X = [int(input()) for i in range(N)]
cnt = 0
lst = []
X.sort()
for i in range(N-1):
  if X[i] < X[i+1] :
    cnt += 1
  else:
    lst.append(cnt)
    cnt = 0
print(min(lst))
Problem p03471 (python)

Fixed submission:
N, X = map(int, input().split())

flag = False
result = [-1,-1,-1]
for i in range(min(N, X // 10**4) + 1):
  for j in range(min(N-i, (X-10**4*i) // 5000) + 1):
    if (X - 10**4*i - 5000*j) // 1000 == N - i - j:
      result = (i,j,N-i-j)
      flag = True
      break
  if flag:
    break
print(*result)

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split()))

for i in range(min(N, X // 10*4) + 1):
  for j in range(min(N-i, (X-10*4*i) // 5000) + 1):
    if (X - 10*4*i - 5000*j) // 1000 == N - i - j:
      print(i,j,N-i-j)
      break
else:
  print(-1,-1,-1)
Problem p03485 (python)

Fixed submission:
import math
A,B = map(int, input().split())
print(math.ceil((A+B)/2))

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

Fixed submission:
N = int(input())
x = list(map(int, input().split()))
mn_lst = []
for i in x:
    cnt = 0
    while i % 2 == 0:
        cnt += 1
        i >>= 1
    mn_lst.append(cnt)
    
print(min(mn_lst))

Buggy submission (verdict: Runtime Error):
N = int(input())
x = list(map(int, input().split()))
mn_lst = []
for i in x:
    cnt = 0
    while i % 2 == 0:
        cnt += 1
        i >>= 1
    mn_lst.append(cnt)
    
print(min(mn_list))

Buggy submission (verdict: Runtime Error):
N = int(input())
x = list(map(int, input().split()))
mn_lst = [0 for i in range(N)]
for i in x:
    cnt = 0
    while i % 2 == 0:
        cnt += 1
        i >>= 1
    mn_lst.append(cnt)
    
print(min(mn_list))

Buggy submission (verdict: Runtime Error):
N = int(input())
x = list(map(int, input().split())
cnt = 0
mn_lst = []
for i in x:
    cnt = 0
    while i % 2 == 0:
        cnt += 1
        i <<= 1
    mn_lst.append(cnt)
print(min(mn_lst))
Problem p03497 (python)

Fixed submission:
from collections import Counter
N, K = map(int, input().split())
A = list(map(int, input().split()))
dA = Counter(A)
if len(dA) - K <= 0:
  print(0)
  exit()
print(sum(sorted(dA.values())[:len(dA)-K] ))

Buggy submission (verdict: Runtime Error):
from collections import Counter
N, K = map(int, input().split())
A = list(map(int, input().split()))
dA = Counter(A)
if len(dA) - K <= 0:
  print(0)
  exit()
print(sum(sorted(dA.values())[:len(dA)-K])))
Problem p03545 (python)

Fixed submission:
def main():
    s = [int(i) for i in input()]
    op = {'+':1, '-':-1}
    for a in op:
        for b in op:
            for c in op:
                if s[0] + op[a] * s[1] + op[b] * s[2] + op[c] * s[3] == 7:
                    return (str(s[0]) + a + str(s[1]) + b + str(s[2]) + c + str(s[3]) + '=7')

        
if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
s = [int(i) for i in input()]
op = {'+':1, '-':-1}
for a in op:
  for b in op:
    for c in op:
      if s[0] + op['a'] * s[1] + op['b'] * s[2] + op['c'] * s[3] == 7:
        print(str(s[0]) + op['a'] + str(s[1]) + op['b'] + str(s[2]) + op['c'] + str(s[3]) + '=7')
Problem p03550 (python)

Fixed submission:
n,z,w= map(int, input().split())
a = list(map(int, input().split()))
print( max(abs(a[-1] - w), abs(a[-2] - a[-1]) if n > 1 else 0))

Buggy submission (verdict: Runtime Error):
n,z,w= map(int, input().split())
a = list(map(int, input().split())
print(max(abs(a[-1] - w), abs(a[-2] - a[-1]) if n > 1 else 0))
Problem p03575 (python)

Fixed submission:
from collections import deque

def dfs(graph, start, goal):
    stack = deque()
    push, pop = stack.append, stack.pop
    push(start)
    visited = [False for i in range(N+1)]
    visited[start] = True
    
    while stack:
        a = pop()
        for b in graph[a].keys():
            if a in [start, goal] and b in [start, goal]:
                continue
            elif b == goal:
                return True
            elif not visited[b]:
                push(b)
                visited[b] = True
    return False

N,M = map(int, input().split())
graph = {}
bridge = []
for i in range(M):
    a,b = map(int, input().split())
    if a not in graph:
        graph[a] = {}
    if b not in graph:
        graph[b] = {}
    graph[a][b] = graph[b][a] = 1
    bridge.append([a,b])

ans = 0
for a,b in bridge:
    ans += not dfs(graph, a, b)
print(ans)

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

def dfs(graph, start, goal):
    stack = deque()
    push, pop = stack.append, stack.pop
    push(start)
    visited = [False for i in range(N)]
    visited[start] = True
    
    while stack:
        a = pop()
        for b in graph[a].keys():
            if a in [start, goal] and b in [start, goal]:
                continue
            elif b == goal:
                return True
            elif not visited[b]:
                push(b)
                visited[b] = True
    return False

N,M = map(int, input().split())
graph = {}
bridge = []
for i in range(M):
    a,b = map(int, input().split())
    if a not in graph:
        graph[a] = {}
    if b not in graph:
        graph[b] = {}
    graph[a][b] = graph[b][a] = 1
    bridge.append([a,b])

ans = 0
for a,b in bridge:
    ans += not dfs(graph, a, b)
print(ans)
Problem p03600 (python)

Fixed submission:
def warshall(d, n):
    e = copy.deepcopy(d)
    for k in range(n):
        for i in range(n):
            for j in range(n):
                # print(d[i][k], d[k][j], d[i][j])
                if i == k or k == j:
                    continue
                if d[i][k] + d[k][j] < d[i][j]:
                    return []
                if d[i][k] + d[k][j] == d[i][j]:
                    # print(d[i][k], d[k][j], d[i][j], i,j,k)
                    e[i][j] = 0
                    e[j][i] = 0
    return e
    
import copy
n = int(input())
edges = []

graph = [list(map(int, input().split())) for i in range(n)]
e = warshall(graph, n)
if e == []:
    print(-1)
    exit()
# print(e)
edge_list = [[] for _ in range(n)]
ans = 0
for i in range(n):
    for j in range(n):
        if e[i][j] > 0:
            edge_list[i].append((e[i][j], j))
        if j > i and e[i][j]:
            ans += e[i][j]

print(ans)

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import dijkstra as di
n = int(input())
grid = [list(map(int, input().split())) for i in range(n)]
dgrid = di(grid)

ans = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
    for j in range(n):
        if grid[i][j] != dgrid[i][j]:
            print(-1)
            exit()

ans = 0
for i in range(n):
    for j in range(n):
        for k in range(n):
            if i == j or j == k or k == i:
              continue
            if grid[i][k] + grid[k][j] == grid[i][j]:
                dgrid[i][j] = 0

ans = 0
for i in range(n):
    for j in range(i+1, n):
        ans += dgrid[i][j]
print(int(ans))
Problem p03609 (python)

Fixed submission:
x,t = map(int,input().split())
print(max(0, x-t))

Buggy submission (verdict: Runtime Error):
x,t = map(int,input().split())
print(max(0, x=t))
Problem p03614 (python)

Fixed submission:
from math import ceil

n = int(input())
ans = 0
tmp = 0
for i,p in enumerate(map(int,input().split())):
    if i + 1 == p:
        tmp += 1
    elif tmp:
        ans += ceil(tmp / 2)
        tmp = 0
print(ans + ceil(tmp / 2))

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 0
for i,p in enumerate(map(int,input().split())):
  if i + 1 == p:
    ans += 1
print(max(ans-1), 0)
Problem p03623 (python)

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

Buggy submission (verdict: Runtime Error):
x,a,b = map(int,input().split())
print(min(abs(x-a, x-b))

Buggy submission (verdict: Runtime Error):
x,a,b = map(int,input().split())
print(min(abs(x-a, x-b)))
Problem p03626 (python)

Fixed submission:
n = int(input())
s1 = input()
s2 = input()
mod = 10**9+7
dp = [-1] * (n)
if s1[0] == s2[0]:
    dp[0] = 1 
else:
    dp[0] = 2
for i in range(n-1):
    if dp[i] == -1:
        continue
    if s1[i] == s2[i]:
        dp[i+1] = (dp[i] * 2) % mod
        continue
    if i+2 >= n:
        break
    if s1[i+2] == s2[i+2]:
        dp[i+2] = dp[i]
    else:
        dp[i+2] = (dp[i] * 3) % mod

ans = dp[-1] if dp[-1] != -1 else dp[-2]
print((ans * 3) % mod)
# print(dp)

Buggy submission (verdict: Runtime Error):
n = int(input())
s1 = input()
s2 = input()
mod = 10**9+7
dp = [-1] * (n)
if s1[0] == s2[0]:
    dp[0] = 1 
else:
    dp[0] = 2
for i in range(n-1):
    if dp[i] == -1:
        continue
    if s1[i] == s2[i]:
        dp[i+1] = (dp[i] * 2) % mod
        continue
    if i+2 > n:
        continue
    if s1[i+2] == s2[i+2]:
        dp[i+2] = dp[i]
    else:
        dp[i+2] = (dp[i] * 3) % mod

ans = dp[-1] if dp[-1] != -1 else dp[-2]
print((ans * 3) % mod)
# print(dp)
Problem p03635 (python)

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

Buggy submission (verdict: Runtime Error):
a,b= map(input().split())
print((a-1)*(b-1))
Problem p03694 (python)

Fixed submission:
N = input()
A = list(map(int, input().split()))
A.sort()
print(A[-1] - A[0])

Buggy submission (verdict: Runtime Error):
N = input()
A = list(map(int, input().split()))
A.sort()
pritn(A[-1] - A[0])
Problem p03699 (python)

Fixed submission:
n = int(input())
ten = []
notten = []
for _ in range(n):
  s = int(input())
  if s % 10:
    notten.append(s)
  else:
    ten.append(s)
ans = sum(notten) + sum(ten)
if notten and sum(notten) % 10 == 0:
  print(ans - min(notten))
elif ans % 10 == 0:
  print(0)
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ten = []
notten = []
for _ in range(n):
  s = int(input())
  if s % 10:
    notten.append(s)
  else:
    ten.append(s)
ans = sum(notten) + sum(ten)
if sum(notten) % 10 == 0:
  print(ans - min(notten))
elif ans % 10 == 0:
  print(0)
else:
  print(ans)