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

Fixed submission:
s = list(input())

g = []

g.append(0)
g.append(1)
if len(s) > 1:
    if s[0] == s[1]:
        g.append(1)
    else:
        g.append(2)

    for i in range(3,len(s)+1):
        if s[i-1] != s[i-2]:
            g.append(g[i-1]+1)
        else:
            g.append(g[i-3]+2)

print(g[len(s)])

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

k1 = 0
k2 = 0
zure = 0

for i in range(len(s)-1):

    if i + zure >= len(s) - 2:
        if s[i + zure] != s[i + 1 + zure]:
            #print(s[i+zure])
            k1 += 1
        k1 += 1
        break

    if s[i + zure] == s[i+1+zure]:
        #print(s[i+zure])
        #print(s[i+1+zure]+s[i+2+zure])
        k1 += 1
        zure += 2
    else:
        #print(s[i+zure])

    k1 += 1
    if i + zure >= len(s)-1:
        if i + zure == len(s)-1:
            k1 += 1
        break

print(k1)

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

k1 = 0
zure = 0

for i in range(len(s)-1):

    if i + zure >= len(s) - 2:
        if s[i + zure] != s[i + 1 + zure]:
            k1 += 1
        k1 += 1
        break

    if s[i + zure] == s[i+1+zure]:
        k1 += 1
        zure += 2
    else:

    k1 += 1
    if i + zure >= len(s)-1:
        if i + zure == len(s)-1:
            k1 += 1
        break

print(k1)
Problem p02573 (python)

Fixed submission:
def abc177d():
    n, m = map(int, input().split())
    if m ==0:
        print(1)
        return 
    check = [-1] * n
    group_no = 0
    group = {}
    for i in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        if check[a] == check[b] != -1: continue
        if check[a] == check[b] == -1:
            group[group_no] = {a, b}
            check[a] = check[b] = group_no
            group_no += 1
        elif check[a] == -1 or check[b] == -1:
            max_g = max(check[a],check[b])
            group[max_g] |= {a,b}
            check[b] = check[a] = max_g
        else:
            re = min(check[a], check[b])
            de = max(check[a], check[b])
            for v in group[de]:
                check[v] = re
            group[re] |= group[de]
            del group[de]
    max_val = max(map(len, group.values()))
    print(max(1,max_val))


abc177d()

Buggy submission (verdict: Runtime Error):
def abc177d():
    n, m = map(int, input().split())
    check = [-1] * n
    group_no = 0
    group = {}
    for i in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        if check[a] == check[b] != -1: continue
        if check[a] == check[b] == -1:
            group[group_no] = {a, b}
            check[a] = check[b] = group_no
            group_no += 1
        elif check[a] == -1 or check[b] == -1:
            max_g = max(check[a],check[b])
            group[max_g] |= {a,b}
            check[b] = check[a] = max_g
        else:
            re = min(check[a], check[b])
            de = max(check[a], check[b])
            for v in group[de]:
                check[v] = re
            group[re] |= group[de]
            del group[de]
    max_val = max(map(len, group.values()))
    print(max(1,max_val))


abc177d()
Problem p02584 (python)

Fixed submission:
import math

def abc175c_walking_takahashi():
    x, k, d = map(int, input().split())
    x = -x if x < 0 else x
    num = math.ceil(x / d)
    if num > k:
        print(x-k*d)
        return
    else:
        k -= num
        x -= num*d
        if k % 2 == 0:
            print(abs(x))
        else:
            print(x+d)
abc175c_walking_takahashi()

Buggy submission (verdict: Runtime Error):
def abc175c_walking_takahashi():
    x, k, d = map(int, input().split())
    x = -x if x < 0 else x
    num = math.ceil(x / d)
    if num > k:
        print(x-k*d)
        return
    else:
        k -= num
        x -= num*d
        if k % 2 == 0:
            print(abs(x))
        else:
            print(x+d)
abc175c_walking_takahashi()
Problem p02641 (python)

Fixed submission:
import bisect


def abc170c_forbidden_list():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    if n == 0:
        print(x)
        return
    p.sort()
    for i in range(100):
        idx = bisect.bisect_left(p, x - i)
        if idx >= n or p[idx] != x - i:
            print(x - i)
            return
        idx = bisect.bisect_left(p, x + i)
        if idx >= n or p[idx] != x + i:
            print(x + i)
            return


abc170c_forbidden_list()

Buggy submission (verdict: Runtime Error):
import bisect


def abc170c_forbidden_list():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    if n == 0:
        print(x)
        return
    p.sort()
    for i in range(100):
        idx = bisect.bisect_left(p, x - i)
        if p[idx] != x - i:
            print(x - i)
            return
        idx = bisect.bisect_left(p, x + i)
        if p[idx] != x + i:
            print(x + i)
            return

abc170c_forbidden_list()
Problem p02683 (python)

Fixed submission:
import itertools

def abc167c_skill_up():
    n, m, x = map(int, input().split())
    c = []
    a = []
    for _ in range(n):
        v = list(map(int, input().split()))
        c.append(v[0])
        a.append(v[1:])
    pattern = itertools.product([0,1], repeat=n)
    best = float('inf')
    for p in pattern:
        cost = 0
        skill = [0] * m
        for i, v in enumerate(p):
            if v == 1:
                cost += c[i]
                if cost > best: break
                check = True
                for j in range(m):
                    skill[j] += a[i][j]
                    if skill[j] < x:
                        check = False
                if check:
                    best = cost
                    break
    if best == float('inf'):
        print('-1')
    else:
        print(best)
abc167c_skill_up()

Buggy submission (verdict: Runtime Error):
import itertools

def abc167c_skill_up():
    n, m, x = map(int, input().split())
    c = []
    a = []
    for _ in range(n):
        v = list(map(int, input().split()))
        c.append(v[0])
        a.append(v[1:])
    pattern = itertools.product([0,1], repeat=n)
    best = float('inf')
    for p in pattern:
        cost = 0
        skill = [0] * n
        for i, v in enumerate(p):
            if v == 1:
                cost += c[i]
                if cost > best: break
                check = True
                for j in range(m):
                    skill[j] += a[i][j]
                    if skill[j] < x:
                        check = False
                if check:
                    best = cost
                    break
    if best == float('inf'):
        print('-1')
    else:
        print(best)
abc167c_skill_up()
Problem p02803 (python)

Fixed submission:
import heapq


def abc151d_maze_master():
    h, w = map(int, input().split())
    s = []
    max_val = 0
    for i in range(h):
        s.append(input())
    for hi in range(h):
        for wi in range(w):
            if s[hi][wi] == '#': continue
            flg = [[-1] * w for _ in range(h)]
            flg[hi][wi] = 0
            q = [(0, hi, wi)]
            heapq.heapify(q)
            while len(q) > 0:
                d, hj, wj = heapq.heappop(q)
                for dh, dw in zip([0, 0, 1, -1], [1, -1, 0, 0]):
                    if 0 <= hj + dh < h and 0 <= wj + dw < w and s[hj + dh][wj + dw] != '#' and \
                            (flg[hj + dh][wj + dw] == -1 or flg[hj + dh][wj + dw] > flg[hj][wj] + 1):
                        heapq.heappush(q, (d + 1, hj + dh, wj + dw))
                        flg[hj + dh][wj + dw] = flg[hj][wj] + 1
                # print(q)
            max_val = max(max_val, max([max(v) for v in flg]))
    print(max_val)


abc151d_maze_master()

Buggy submission (verdict: Runtime Error):
def abc151d_maze_master():
    h, w = map(int, input().split())
    s = []
    max_val = 0
    for i in range(h):
        s.append(input())
    for hi in range(h):
        for wi in range(w):
            if s[hi][wi] == '#': continue
            flg = [[-1] * w for _ in range(h)]
            flg[hi][wi] = 0
            q = [(0, hi, wi)]
            heapq.heapify(q)
            while len(q) > 0:
                d, hj, wj = heapq.heappop(q)
                for dh, dw in zip([0, 0, 1, -1], [1, -1, 0, 0]):
                    if 0 <= hj + dh < h and 0 <= wj + dw < w and s[hj + dh][wj + dw] != '#' and \
                            (flg[hj + dh][wj + dw] == -1 or flg[hj + dh][wj + dw] > flg[hj][wj] + 1):
                        heapq.heappush(q, (d + 1, hj + dh, wj + dw))
                        flg[hj + dh][wj + dw] = flg[hj][wj] + 1
                # print(q)
            max_val = max(max_val, max([max(v) for v in flg]))
    print(max_val)


abc151d_maze_master()
Problem p03166 (python)

Fixed submission:
import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
def f(i, e, dp):
    if dp[i] is not None:
        return dp[i]
    val = 0
    for nxt in e[i]:
        val = max(val, f(nxt, e, dp) + 1)
    dp[i] = val
    return dp[i]


def edu_dp_g_longest_path():
    n, m = map(int, input().split())
    e = [[] for _ in range(n)]
    for _ in range(m):
        x, y = map(int, input().split())
        e[x - 1].append(y - 1)
    dp = [None] * n
    result = 0
    for i in range(n):
        result = max(result, f(i, e, dp))
    print(result)

edu_dp_g_longest_path()

Buggy submission (verdict: Runtime Error):
def f(i, e, dp):
    if dp[i] is not None:
        return dp[i]
    val = 0
    for nxt in e[i]:
        val = max(val, f(nxt, e, dp) + 1)
    dp[i] = val
    return dp[i]


def edu_dp_g_longest_path():
    n, m = map(int, input().split())
    e = [[] for _ in range(n)]
    for _ in range(m):
        x, y = map(int, input().split())
        e[x - 1].append(y - 1)
    dp = [None] * n
    result = 0
    for i in range(n):
        result = max(result, f(i, e, dp))
    print(result)

edu_dp_g_longest_path()

Buggy submission (verdict: Runtime Error):
def f(i, e, dp):
    if dp[i] is not None:
        return dp[i]
    val = 0
    for nxt in e[i]:
        val = max(val, f(nxt, e, dp) + 1)
    dp[i] = val
    return val


def edu_dp_g_longest_path():
    n, m = map(int, input().split())
    e = [[] for _ in range(n)]
    for _ in range(m):
        x, y = map(int, input().split())
        e[x - 1].append(y - 1)
    dp = [None] * n
    result = [f(i, e, dp) for i in range(n)]
    print(max([0]+[r for r in result if r is not None]))
edu_dp_g_longest_path()

Buggy submission (verdict: Runtime Error):
def f(i, e, dp):
    if dp[i] is not None:
        return dp[i]
    val = 0
    for nxt in e[i]:
        val = max(val, f(nxt, e, dp) + 1)
    dp[i] = val
    return val


def edu_dp_g_longest_path():
    n, m = map(int, input().split())
    e = [[] for _ in range(n)]
    for _ in range(m):
        x, y = map(int, input().split())
        e[x - 1].append(y - 1)
    dp = [None] * n
    result = [f(i, e, dp) for i in range(n)]
    print(max([0]+[r for r in result if r is not None]))
edu_dp_g_longest_path()

Buggy submission (verdict: Runtime Error):
def f(i, e, dp):
    if dp[i] is not None:
        return dp[i]
    val = 0
    for nxt in e[i]:
        val = max(val, f(nxt, e, dp) + 1)
    dp[i] = val
    return val


def edu_dp_g_longest_path():
    n, m = map(int, input().split())
    e = [[] for _ in range(n)]
    for _ in range(m):
        x, y = map(int, input().split())
        e[x - 1].append(y - 1)
    dp = [None] * n

    print(max([f(i, e, dp) for i in range(n)]))
edu_dp_g_longest_path()
Problem p02615 (python)

Fixed submission:
n=int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
score = a.pop(0)
if n%2==1:
  score += sum(a[:(n-1)//2-1])*2 + a[(n-1)//2-1]
else:
  score += sum(a[:(n-1)//2])*2
print(score)

Buggy submission (verdict: Runtime Error):
n=int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
score = a.pop(0)
score += a.pop(0)
if n%2==1:
  score += sum(a[:(n-3)//2])*2
else:
  score += sum(a[:(n-3)//2])*2 + a[(n-3)//2]
print(score)
Problem p02814 (python)

Fixed submission:
from fractions import gcd

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

a=list(map(lambda x: x//2, a))

def lcm(q):
  x = q[0]
  for i in range(1, len(q)):
    x = (x * q[i]) // gcd(x, q[i])
  return x

lcma=lcm(a)

if (lcma//a[0])%2==0:
  print(0)
else:
  flg=0
  for i in range(1,len(a)):
    if (lcma//a[i])%2==0:
      print(0)
      flg=1
      break
  if flg==0:
    temp=m//lcma
    print(temp//2 if temp%2==0 else temp//2+1)

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

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

a=list(map(lambda x: x//2, a))

def lcm(q):
  x = q[0]
  for i in range(1, len(q)):
    x = (x * q[i]) // gcd(x, q[i])
  return x

lcma=lcm(a)

if (lcma//a[0])%2==0:
  print(0)
  
else:
  flg=0
  for i in range(1,n):
    if (lcma//a[i])%2==0:
      print(0)
      flg=1

  if flg==0:
    temp=m//lcma
    print(temp//2 if temp%2==0 else temp//2+1)
Problem p02861 (python)

Fixed submission:
import itertools
from math import *
n=int(input())
ps=[list(map(int,input().split())) for _ in range(n)]
perms = list(itertools.permutations(ps, n))
dists = []
for i in range(len(perms)):
  dist = 0
  cur = perms[i][0]
  for j in range(1,len(perms[i])):
    d = sqrt((perms[i][j][0]-cur[0]) ** 2 + (perms[i][j][1]-cur[1])**2)
    cur = perms[i][j]
    dist += d

  dists.append(dist)
print(sum(dists)/len(perms))

Buggy submission (verdict: Runtime Error):
from math import sqrt
from itertools import permutations
N=int(input())
xy=[list(map(int,input().split())) for _ in range(N)]
ans=0
cnt=0
for i in permutations(range(3)):
  d=0
  for j in range(N-1):
    dx=xy[i[j+1]][0]-xy[i[j]][0]
    dy=xy[i[j+1]][1]-xy[i[j]][1]
    d+=sqrt(dx**2+dy**2)
  ans+=d
  cnt+=1
print(ans/cnt)
Problem p02928 (python)

Fixed submission:
MOD=10**9+7
N,K=map(int,input().split())
A=list(map(int,input().split()))
ans=0
for i in range(N-1):
  for j in range(i+1,N):
    if A[i]>A[j]:
      ans+=((K+1)*K//2)%MOD
    elif A[i]<A[j]:
      ans+=(K*(K-1)//2)%MOD

print(ans%MOD)

Buggy submission (verdict: Runtime Error):
import sys
from functools import lru_cache
sys.setrecursionlimit(10**9)
MOD=10**9+7
n,m=map(int,input().split())
a=set([int(input()) for _ in range(m)])
if 1 in a:
  ans=[1,0]
else:
  ans=[1,1]

@lru_cache(maxsize=None)
def cnt(x):
  if x<2:
    return ans[x]
  if x in a:
    return 0
  else:
    return (cnt(x-1)+cnt(x-2))%MOD

print(cnt(n))
Problem p02939 (python)

Fixed submission:
s=list(input())
D=[s[0]]
i=0
while i < len(s) - 1:
  if s[i+1] == D[-1]:
    D.append(s[i+1:i+3])
    i+=2
  else:
    D.append(s[i + 1])
    i+=1

print(len(D)-(1 if i == len(s) else 0))

Buggy submission (verdict: Runtime Error):
s=list(input())
D=[s[0]]
i=0
while i < len(s) - 1:
  if s[i+1] == D[-1]:
    D.append(s[i+1]+s[i+2])
    i+=2
  else:
    D.append(s[i + 1])
    i+=1

print(len(D)-(1 if i == len(s) else 0))

Buggy submission (verdict: Runtime Error):
s=list(input())
n=len(s)
D=[s[-1]]
s.pop()
while len(s)>0:
  if len(D[-1])==2 or (D[-1]!=s[-1] and (len(s)==1 or s[-1]!=s[-2])):
    D.append(s[-1])
    s.pop()
  else:
    D.append(s[-2]+s[-1])
    s.pop()
    s.pop()

print(len(D))

Buggy submission (verdict: Runtime Error):
s=list(input())
n=len(s)
D=[s[0]]
s.pop(0)
while len(s)>0:
  if len(D[-1])==2 or (D[-1]!=s[0] and (len(s)==1 or s[0]!=s[1])):
    D.append(s[0])
    s.pop(0)
  else:
    D.append(s[0]+s[1])
    s.pop(0)
    s.pop(0)

print(len(D))
Problem p03282 (python)

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

ans = '1'
for i in range(k):
  if s[i] != '1':
    ans = s[i]
    break

print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
s = list(reversed(s))
cnt =0
while cnt < k and s[-1] == '1':
  cnt +=1
  s.pop()

print(s[-1])
Problem p03353 (python)

Fixed submission:
s = input()
K = int(input())
w = []
for i in range(len(s)):
  for j in range(i,i+K):
    temp = s[i:j+1]
    if temp not in w:
      w.append(temp)
      
w.sort()
print(w[K-1])

Buggy submission (verdict: Runtime Error):
s = input()
K = int(input())
w = []
for i in range(len(s)-K+1):
  for j in range(i,i+K):
    temp = s[i:j+1]
    if temp not in w:
      w.append(temp)
      
w.sort()
print(w[K-1])
Problem p03450 (python)

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

N,M = map(int,input().split())
G = [[] for _ in [0]*N]

for _ in [0]*M:
  a, b, d = map(int, input().split())
  a -= 1
  b -= 1
  G[a].append((b, d))
  G[b].append((a, -d))

X = [None]*N

def dfs(i, x=0):
  for j, d in G[i]:
    if X[j] is None:
      X[j] = x+d
      dfs(j, x+d)
    elif X[j] != x+d:
      print('No')
      exit()

for i in range(N):
  if X[i] is not None:
    continue
  X[i] = 0
  dfs(i)
print('Yes')

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
pos=["-"]*N
if M==0:
  print("Yes")
  exit()
elif N==1:
  print("Yes")
  exit()
else:
  l,r,d=map(int,input().split())
pos[l-1]=0
pos[r-1]=pos[l-1]+d
for i in range(1,M):
  l,r,d=map(int,input().split())
  if pos[r-1]=="-":
    pos[r-1] = pos[l-1]+d
  elif pos[r-1]==pos[l-1]+d:
    continue
  else:
    print("No")
    exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
pos=["-"]*N
if M==0:
  print("Yes")
  exit()
elif n==1:
  print("Yes")
  exit()
else:
  l,r,d=map(int,input().split())
pos[l-1]=0
pos[r-1]=pos[l-1]+d
for i in range(1,M):
  l,r,d=map(int,input().split())
  if pos[r-1]=="-":
    pos[r-1] = pos[l-1]+d
  elif pos[r-1]==pos[l-1]+d:
    continue
  else:
    print("No")
    exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
pos=["-"]*N
if M==0:
  print("Yes")
  exit()
else:
  l,r,d=map(int,input().split())
pos[l-1]=0
pos[r-1]=pos[l-1]+d
for i in range(1,M):
  l,r,d=map(int,input().split())
  if pos[r-1]=="-":
    pos[r-1] = pos[l-1]+d
  elif pos[r-1]==pos[l-1]+d:
    continue
  else:
    print("No")
    exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
pos=["-"]*N
l,r,d=map(int,input().split())
pos[l-1]=0
pos[r-1]=pos[l-1]+d
for i in range(1,M):
  l,r,d=map(int,input().split())
  if pos[r-1]=="-":
    pos[r-1] = pos[l-1]+d
  elif pos[r-1]==pos[l-1]+d:
    continue
  else:
    print("No")
    exit()
print("Yes")
Problem p03455 (python)

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

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if (a % 2 != 0) and (b % 2 != 0):
  return "Odd"
else:
  return "Even"

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if (a % 2 != 0) and (b % 2 != 0):
  return "Odd"
else:
  return "Een"
Problem p03494 (python)

Fixed submission:
n = input()
a = list(map(int, input().split()))
 
counter = 0
while sum(list(map(lambda x: x % 2, a))) == 0:
    a = list(map(lambda x: x / 2, a))
    counter += 1
 
print(counter)

Buggy submission (verdict: Runtime Error):
n = input()
a = list(map(int, input().split()))
 
counter = 0
while sum(list(map(lambda x: x % 2, a))) == 0:
	a = list(map(lambda x: x / 2, a))
	counter += 1
 
prrint(counter)

Buggy submission (verdict: Runtime Error):
n = input()
a = list(map(int, input().split()))
 
counter = 0
while sum(list(map(lambda x: x % 2, a))) == 0:
	a = list(map(lambda x: x / 2, a))
  	counter += 1
 
prrint(counter)

Buggy submission (verdict: Runtime Error):
n = input()
a = list(map(int(i) for i in input().split()) 
 
counter = 0
while sum(list(map(lambda x: x % 2, a))) == 0:
	a = list(map(lambda x: x / 2, a))
  	counter += 1
 
prrint(counter)

Buggy submission (verdict: Runtime Error):
n = input()
a = [int(i) for i in input().split()] 
 
counter = 0
while sum(list(map(lambda x: x % 2, a))) == 0:
	a = list(map(lambda x: x / 2, a))
  	counter += 1
 
prrint(counter)

Buggy submission (verdict: Runtime Error):
n = input()
a = [int(i) for i in input().split()] 

counter = 0
while sum(list(map(lambda x: x % 2, a))) == 0:
	a = list(map(lambda x: x / 2, a))
  	counter += 1

return counter
Problem p03550 (python)

Fixed submission:
N,Z,W=map(int,input().split())
a=list(map(int,input().split()))
print(abs(W-a[0])if N==1 else max(abs(W-a[-1]),abs(a[-1]-a[-2])))

Buggy submission (verdict: Runtime Error):
N,Z,W=map(int,input().split())
a=list(map(int,input().split()))
print(abs(W-a[0])if n==1 else max(abs(W-a[-1]),abs(a[-1]-a[-2])))

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

Fixed submission:
import collections
N = int(input())
a = list(map(int, input().split()))
cand = collections.Counter(a)
cand_list = cand.most_common(len(set(a)))
ans = 0
for i in range(len(set(a))):
  num = cand_list[i][0]
  count = cand[num] + cand[num + 1] + cand[num - 1]
  ans = max(ans,count)

print(ans)

Buggy submission (verdict: Runtime Error):
import collections
N = int(input())
a = list(map(int, input().split()))
cand = collections.Counter(a)
cand_list = cand.most_common(len(set(a)))
ans = 0
n = min(len(a),5)
for i in range(n):
  num = cand_list[i][0]
  count = cand[num]
  if num + 1 in a:
    count += cand[num + 1]
  if num - 1 in a:
    count += cand[num - 1]
  if ans < count:
    ans = count

print(ans)
Problem p03612 (python)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(n-1):
  if p[i]==i+1:
    p[i], p[i+1]=p[i+1],p[i]
    cnt+=1

if p[-1]==n:
  cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(n):
  if p[i]==i+1:
    p[i], p[i+1]=p[i+1],p[i]
    cnt+=1
print(cnt)
Problem p03637 (python)

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

o = 0
f = 0
t = 0
for i in a:
  if i % 2 == 1:
    o += 1
  if i % 4 == 0:
    f += 1
  if i % 4 == 2:
    t += 1
if f >o-1:
  print('Yes')
elif f == o-1 and t==0:
  print('Yes')
else:
  print('No')

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

o = 0
f = 0
t = 0
for i in a:
  if i % 2 == 1:
    o += 1
  if i % 4 == 0:
    f += 1
  if i % 4 == 2:
    t += 1
if f >=0 o-1 and t == 0:
  print('Yes')
else:
  print('No')
Problem p03853 (python)

Fixed submission:
h,w=map(int,input().split())
c=[input() for _ in range(h)]
for i in range(h):
  print(c[i])
  print(c[i])

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
c=[list(map(int,input().split())) for _ in range(h)]
for i in range(h):
  print(c[i])
  print(c[i])
Problem p03060 (python)

Fixed submission:
N = int(input())

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

import copy

flag = [0]*N
def dfs(x, y):
    if y==1:
        flag[x] = 1
    else:
        flag[x] = 0
    if x==N-1:
        value = 0
        cost = 0
        for i in range(N):
            if flag[i] == 1:
                value += V[i]
                cost += C[i]
        # print(flag)
        # for i in range(N):
        #     flag[i] = 0
        return value - cost

    
    return max(dfs(x+1, 0),dfs(x+1, 1))

print(dfs(-1,0))

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

V = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
for i in range(2**N):
    X = 0
    Y = 0
    for j in range(N):
        if ((i >> j) & 1):
            X += V[j]
            Y += C[i]
    ans = max(ans, X-Y)

print(ans)
Problem p03331 (python)

Fixed submission:
N = input()

ans = 0
for n in N:
    ans += int(n)

if ans == 1:
    ans = 10

print(ans)

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

ans = 0
for n in N:
    ans += n

print(ans)