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

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

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
Max=0
for i in range(N):
  if A[i]>=B[i]:
    Max+=B[i]
  else:
    B[i]-=A[i]
    if A[i+1]>=B[i]:
      A[i+1]-=B[i]
      Max+=A[i]+B[i]
    else:
      A[i+1]=0
      Max+=A[i]+A[i+1]
print(Max)
Problem p03260 (python)

Fixed submission:
a,b=map(int,input().split())
if a%2==0 or b%2==0:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a%2==0 or b%2==0:
  print("No")
else:
  priint("Yes")
Problem p03424 (python)

Fixed submission:
n=int(input())
a=list(input().split())
if len(set(a))==3:
  print("Three")
else:
  print("Four")

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
if len(set(a))==3:
  print("Three")
else:
  print("Four")
Problem p03548 (python)

Fixed submission:
x,y,z=map(int,(input().split()))
ans=1
x-=(y+2*z)
print(ans+x//(y+z))

Buggy submission (verdict: Runtime Error):
x,y,z=map(int(input().split()))
ans=1
x-=(y+2*z)
print(ans+x//(y+z))
Problem p03555 (python)

Fixed submission:
c=input()
d=input()
if c[0]==d[2] and c[1]==d[1] and c[2]==d[0]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
c=input()
d=input()
if c[0]==d[3] and c[1]==d[1] and c[2]==d[0]:
  print("YES")
else:
  print("NO")
Problem p03637 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
cnt_odd=0
cnt_even=0
cnt_4=0
for i in range(n):
  if a[i]%2!=0:
    cnt_odd+=1
  else:
    cnt_even+=1
    if a[i]%4==0:
      cnt_4+=1
if cnt_even-cnt_4==0:
  if cnt_4+1>=cnt_odd:
    print("Yes")
  else:
    print("No")
else:
  if cnt_4>=cnt_odd:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
cnt_4=0
for i in range(n):
  if a[i]%2!=0:
    cnt_odd+=1
  else:
    cnt_even+=1
    if a[i]%4==0:
      cnt_4+=1
if cnt_even-cnt_4==0:
  if cnt_4+1>=cnt_odd:
    print("Yes")
  else:
    print("No")
else:
  if cnt_4>=cnt_odd:
    print("Yes")
  else:
    print("No")
Problem p02684 (python)

Fixed submission:
n,k=map(int,input().split())
A=tuple(map(int,input().split()))
s=1
state=[s]
count={}
for i in range(1,k+1):
    s=A[s-1]
    if s in count:
        start=state.index(s)
        end=len(state)
        print(state[start+(k-start)%(end-start)])
        break
    else:
        count[s]=i
        state.append(s)
        continue
else:
    print(s)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
A=tuple(map(int,input().split()))
s=1
state=[s]
count={}
for i in range(1,k+1):
    s=A[s-1]
    if s in count:
        start=state.index(s)
        end=len(state)
        print(state[start+(k-start)%(end-start)])
        break
    else:
        count[state[i]]=i
        state.append(s)
        continue
else:
    print(s)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
A=tuple(map(int,input().split()))
s=1
state=[s]
count={}
for i in range(k+1):
    s=A[s-1]
    if s in count:
        start=len(state)
        end=i=1
        print(state[start+(k-start)%(end-start)])
        break
    else:
        count[state[i]]=i
        state.append[s]
else:
    print(s)
Problem p02696 (python)

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

def main():
    a,b,n = map(int,input().split())
    print(a*min(n,(b-1))//b-a*(min(b-1,n)//b))

if __name__ == "__main__":
    main()

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

def main():
    a,b,n = map(int,input().split())
    l = gcd(a,b)
    print(a*min(n,(b-1))//b-a*(min(b-1,n)//b))

if __name__ == "__main__":
    main()
Problem p02697 (python)

Fixed submission:
import sys
input = sys.stdin.readline
def main():
    n,m = map(int,input().split())
    ans = []
    r = 2*m+1
    if m%2:
        for i in range(1,m//2+1):
            ans.append([i,m+1-i])
        for i in range(m+1,(m+1+r)//2+1):
            ans.append([i,m+1+r-i])
    else:
        for i in range(1,m//2+1):
            ans.append([i,m+1-i])
        for i in range(m+1,(m+1+r)//2):
            ans.append([i,m+1+r-i])            
    for a in ans:
        print(*a)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def main():
    n,m = map(int,input().split())
    ans = []
    if m%2:
        l = 1
        r = m
        while l+1<r:
            ans.append(l,r)
            l += 1;r-=1
        l = r
        r = 2*m+1
        while l<r:
            ans.append([l,r])
            l+=1;r-=1
    else:
        l = 1
        r = m+1
        while l+1<r:
            ans.append(l,r)
            l += 1;r-=1
        l = r
        r = 2*m+1
        while l<r:
            ans.append([l,r])
            l+=1;r-=1
    
    for a in ans:
        print(*a)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def main():
    n,m = map(int,input().split())
    ans = []
    if m%2:
        l = 1
        r = m
        while l+1<r:
            ans.append(l,r)
            l += 1;r-=1
        l = r
        r = 2*m+1
        while l<r:
            ans.append([l,r])
            l+=1;r-=1
    else:
        l = 1
        r = m+1
        while l+1<r:
            ans.append(l,r)
            l += 1;r-=1
        l = r
        r = 2*m+1
        while l<r:
            ans.append([l,r])
            l+=1;r-=1
    
    for a in ans:
        print(*ans)


if __name__ == "__main__":
    main()
Problem p02719 (python)

Fixed submission:
N,K = map(int,input().split())
if K == 1:
    ans = 0
else:
    if N >= K:
        N -= (N//K)*K
        ans = min(N,abs(N-K))
    else:
        ans = min(N,abs(N-K))
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
if K == 1:
    ans = 0
else:
    if N >= K:
        N -= (N//K)*K
        ans = min(N,abs(N-K))
    else:
        min(N,abs(N-K))
print(ans)
Problem p02734 (python)

Fixed submission:
from sys import stdin
mod = 998244353
def main():
    N,S = map(int,stdin.readline().split())
    a = list(map(int,stdin.readline().split()))
    dp = [0]*(S+1)
    ans = 0
    for A in a:
        dp[0] += 1
        for i in reversed(range(A,S+1)):
            dp[i] += dp[i-A]    
            dp[i] %= mod
        ans += dp[S]
        ans %= mod
    print(ans)
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from sys import stdin
mod = 998244353
def solveAsPolynomial():
    from numpy import *
    N,S = map(int,stdin.readline().split())
    a = list(map(int,stdin.readline().split()))
    ans = 0
    f = np.zeros(S+1,int64)#f[k] := ある多項式のx**kの係数
    for A in a:
        #f = (f+1)(1+x**A)として更新していく
        f[0] += 1#f+1
        f[A:] += f[:-A].copy()#f*(1+x**A)
        f %= mod
        ans += f[S]
        #x**S = X**(A_1+...+A_k)ゆえ、f[S]は知りたい組み合わせの数と等しい
        ans %= mod
    return ans
def main():
  ans = solveAsPolynomial()
  print(ans)
if __name__ =="__main__":
  main()

Buggy submission (verdict: Runtime Error):
import numpy as np
from sys import stdin
mod = 998244353
def main():
    N,S = map(int,stdin.readline().split())
    a = list(map(int,stdin.readline().split()))
    a = np.asarray(a)
    dp = np.zeros((N+1,S+1,3))
    dp[0][0][0] = 1
    for i in range(N):
        for j in range(S+1):
            dp[i+1][j][0] += dp[i][j][0] ;dp[i+1][j][0] %= mod
            dp[i+1][j][1] += dp[i][j][0]+dp[i][j][1];dp[i+1][j][1] %= mod
            dp[i+1][j][2] += dp[i][j][0]+dp[i][j][1]+dp[i][j][2];dp[i+1][j][2]%= mod
            if j+a[i] <= S:
                dp[i+1][j+a[i]][1] += dp[i][j][0]+dp[i][j][1];dp[i+1][j+a[i]][1] %= mod
                dp[i+1][j+a[i]][2] += dp[i][j][0]+dp[i][j][1];dp[i+1][j+a[i]][2] %= mod
    print(int(dp[N][S][2]))
if __name__ == "__main__":
    main()
Problem p02761 (python)

Fixed submission:
N,M = map(int,input().split(" "))
ans = [-1 for _ in range(N)]
flag = 0
for i in range(M):
    s,c = map(int,input().split(" "))
    if ans[s-1] != -1 and ans[s-1] != c:
        flag = 1
    else:
        ans[s-1] = c
if N != 1 and ans[0] == 0:
    flag = 1
elif N == 1 and ans[0] == 0:
    print(0)
    exit()
if N == 1:
    if ans[0] == -1:
        print(0)
        exit()
for i in range(N):
    if ans[i] == -1:
        if i == 0:
            ans[i] = 1
        else:
            ans[i] = 0
    ans[i] = str(ans[i])
ans = ''.join(ans)
if flag == 1:
    print(-1)
    exit()
print(int(ans))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split(" "))
ans = [-1 for _ in range(N)]
for i in range(M):
    s,c = map(int,input().split(" "))
    if ans[s-1] != -1 and ans[s-1] != c:
        print(-1)
        exit()
    else:
        ans[s-1] = c
if ans[0] == 0:
    print(-1)
    exit()  
for i in range(N):
    if ans[i] == -1:
        if i != 0:
            ans[i] = 0
        else:
            ans[i] = 1
    ans[i] = str(ans)
ans = ''.join(ans)
print(int(ans))
Problem p02768 (python)

Fixed submission:
def mpow(a,n,mod):
  if n == 0:
    return 1
  elif n == 1:
    return a
  elif n%2==0:
    return (pow(a,n//2,mod))**2%mod
  else:
    return a*pow(a,n-1,mod)%mod
def mfac(l,r,mod):
  ans = l
  for i in reversed(range(r,l)):
    ans *= i
    ans %= mod
  return ans
def mcomb(n,k,mod):
  A = mfac(n,n-k+1,mod)
  B = mfac(k,1,mod)
  B = mpow(B,mod-2,mod)
  return A*B%mod

def main():
  mod = 10**9+7
  n,a,b = map(int,input().split(" "))
  ans = mpow(2,n,mod)-1-mcomb(n,a,mod)-mcomb(n,b,mod)
  ans %= mod
  print(ans)

if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
def mpow(a,n,mod):
  if n == 0:
    return 1
  elif n == 1:
    return a
  elif n%2==0:
    return (pow(a,n/2,mod))**2%mod
  else:
    return a*pow(a,n-1,mod)%mod
def mfac(l,r,mod):
  ans = l
  for i in reversed(range(r,l)):
    ans *= i
    ans %= mod
  return ans
def mcomb(n,k,mod):
  A = mfac(n,n-k+1)
  B = mfac(k,1)
  B = mpow(B,mod-2,mod)
  return A*B%mod

def main():
  mod = 10**9+7
  n,a,b = map(int,input().split(" "))
  ans = mpow(2,n,mod)-1+mcomb(n,a,mod)-mcomv(n,b,mod)
  ans %= mod
  print(ans)

if __name__ == "__main__":
  main()
Problem p02775 (python)

Fixed submission:
N = str(input())
L = len(N)
ans = 0
dp = [[0,0] for _ in range(L)]
s = list(map(int,N))
dp[0] = [s[0],11-s[0]]
for i in range(1,L):
    n = s[i]
    dp[i][0] = min(dp[i-1][0]+n,dp[i-1][1]+n)
    dp[i][1] = min(dp[i-1][1]+9-n,dp[i-1][0]+11-n)
print(min(dp[-1]))

Buggy submission (verdict: Runtime Error):
s = list(map(int,input()))
L = len(s)
o = s[0]
p = 11-s[1]
for i in range(1,L):
    n = s[i]
    np = min(o+n,p+n)
    d = min(p+9-n,o+11-n)
    o = np
    p = d
print(min(o,p))
Problem p02780 (python)

Fixed submission:
from itertools import accumulate
N,K = map(int,input().split(" "))
p = list(map(int,input().split(" ")))
pp = list(accumulate(p))
ans = (pp[K-1]+K)/2
for i in range(N-K):
    ans = max(ans,(pp[i+K]-pp[i]+K)/2)
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
N,K = map(int,input().split(" "))
p = list(map(int,input().split(" ")))
pp = list(accumulate(p))
ans = 0
for i in range(len(pp)):
    ans = max(ans,(pp[i+K]-pp[i]+K)/2)
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
N,K = map(int,input().split(" "))
p = list(map(int,input().split(" ")))
pp = list(accumulate(p))
ans = 0
for i in range(len(pp)//2+1):
    ans = max(ans,(pp[i+K]-pp[i]+K)/2,(pp[-1-i]-pp[-1-i-K]+K)/2)
print(ans)
Problem p02782 (python)

Fixed submission:
mod = 10**9+7

f = [1]*(2*10**6+5)
f[0] = 1
for i in range(1,2*10**6+4):
    f[i] = f[i-1]*i%mod

def inv(i):
    return pow(f[i],mod-2,mod)

def g(x,y):
    return f[x+y]*inv(x)*inv(y)%mod

r1,c1,r2,c2 = map(int,input().split(" "))
ans = g(r2+1,c2+1)-g(r2+1,c1)-g(r1,c2+1)+g(r1,c1)
print(ans%mod)

Buggy submission (verdict: Runtime Error):
mod = 10**9+7

def f(n,k,p):
    n1, k = n+1, min(k, n-k)
    numer = denom = 1
    for i in range(1,k+1):
        numer = numer*(n1-i)
        denom = denom*i
    return numer*pow(denom,p-2,p)%p

r1,c1,r2,c2 = map(int,input().split(" "))
ans = f(r2+c2+2,c2+1,mod)-g(r2+c1+1,c1,mod)-g(r1+c2+1,c2+1,mod)+g(r1+c1,c1,mod)
print(ans%mod)

Buggy submission (verdict: Runtime Error):
mod = 10**9+7

f = [1]*(2*10**6+2)
f[0] = 1
for i in range(1,2*10**6+2):
    f[i] = f[i-1]*i%mod

def inv(i):
    return pow(f[i],mod-2,mod)

def g(x,y):
    return f[x+y]*inv(x)*inv(y)%mod

r1,c1,r2,c2 = map(int,input().split(" "))
ans = g(r2+1,c2+1)-g(r2+1,c1)-g(r1,c2+1)+g(r1,c1)
print(ans%mod)
Problem p02787 (python)

Fixed submission:
H,N = map(int,input().split(" "))
lis = []
lis_append = lis.append
dp = [2**50 for _ in range(H+1)]
ans = 2**60
for i in range(N):
    a,b = map(int,input().split(" "))
    if a >= H:
        ans = min(ans,b)
    lis_append([a,b])

dp[0] = 0
for i in range(H+1):
    for a,b in lis:
        if i + a <= H:
            dp[i+a] = min(dp[i+a],dp[i]+b)
        else:
            dp[H] = min(dp[H],dp[i]+b)

ans = min(ans,dp[H])
print(ans)

Buggy submission (verdict: Runtime Error):
H,N = map(int,input().split(" "))
lis = []
lis_append = lis.append
dp = [2**50 for _ in range(H+1)]
ans = 2**60
for i in range(N):
    a,b = map(int,input().split(" "))
    dp[a] = b
    if a >= H:
        ans = min(ans,b)
    lis_append([a,b])


for i in range(H+1):
    for a,b in lis:
        if i + a <= H:
            dp[i+a] = min(dp[i+a],dp[i]+b)
        else:
            dp[H] = min(dp[H],dp[i]+b)

ans = min(ans,dp[H])
print(ans)

Buggy submission (verdict: Runtime Error):
H,N = map(int,input().split(" "))
lis = []
lis_append = lis.append
dp = [10**8+1 for _ in range(H+1)]
for i in range(N):
    a,b = map(int,input().split(" "))
    dp[a] = b
    lis_append([a,b])


for i in range(H+1):
    for a,b in lis:
        if i + a <= H:
            dp[i+a] = min(dp[i+a],dp[i]+b)
        else:
            dp[H] = min(dp[H],dp[i]+b)
print(dp[H])

Buggy submission (verdict: Runtime Error):
H,N = map(int,input().split(" "))
lis = []
lis_append = lis.append
dp = [10**8+1 for _ in range(H+1)]
for i in range(N):
    a,b = map(int,input().split(" "))
    dp[a] = b
    lis_append([a,b])


for i in range(H+1):
    for a,b in lis:
        if i + a <= H:
            dp[i+a] = min(dp[i+a],dp[i]+b)
        else:
            dp[-1] = min(dp[-1],dp[i]+b)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
H,N = map(int,input().split(" "))
lis = []
lis_append = lis.append
dp = [10**10 for _ in range(H+1)]
for i in range(N):
    a,b = map(int,input().split(" "))
    dp[a] = b
    lis_append([a,b])


for i in range(H+1):
    for a,b in lis:
        if i + a <= H:
            dp[i+a] = min(dp[i+a],dp[i]+b)
        else:
            dp[-1] = min(dp[-1],dp[i]+b)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
H,N = map(int,input().split(" "))
lis = []
lis_append = lis.append
dp = [2**60 for _ in range(H+1)]
for i in range(N):
    a,b = map(int,input().split(" "))
    dp[a] = b
    lis_append([a,b])


for i in range(H+1):
    for a,b in lis:
        if i + a < H:
            dp[i+a] = min(dp[i+a],dp[i]+b)
        else:
            dp[-1] = min(dp[-1],dp[i]+b)
print(dp[-1])
Problem p02803 (python)

Fixed submission:
from collections import deque
h,w = map(int,input().split(" "))
s = [input() for _ in range(h)]
 
ans = 0
direcion = [(1,0),(0,1),(-1,0),(0,-1)]
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            continue
        que = deque([(j,i)])
        dist = [[0]*w for _ in range(h)]
        visited = [[0]*w for _ in range(h)]
        visited[i][j] = 1
        while que:
            j, i = que.popleft()
            for x,y in direcion:
                n_x,n_y = j+x,i+y
                if not 0 <= n_x < w: continue
                if not 0 <= n_y < h: continue
                if visited[n_y][n_x]: continue
                if s[n_y][n_x] == "#": continue
                visited[n_y][n_x] = 1
                dist[n_y][n_x] = dist[i][j] + 1
                que.append((n_x,n_y))
        ans = max(ans,max(max(row) for row in dist))
print(ans)

Buggy submission (verdict: Runtime Error):

Copy
Copy
from collections import deque
h,w = map(int,input().split(" "))
s = [input() for _ in range(h)]
 
ans = 0
direcion = [(1,0),(0,1),(-1,0),(0,-1)]
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            continue
        que = deque([(j,i)])
        dist = [[0]*w for _ in range(h)]
        visited = set()
        visited.add((i,j))
        while que:
            j, i = que.popleft()
            for x,y in direcion:
                n_x,n_y = j+x,i+y
                if not 0 <= n_x < w: continue
                if not 0 <= n_y < h: continue
                if (n_y,n_x) in visited: continue
                if s[n_y][n_x] == "#": continue
                visited.add((n_y,n_x))
                dist[n_y][n_x] = dist[i][j] + 1
                que.append((n_x,n_y))
            ans = max(ans,max(max(row) for row in dist))
print(ans)
Problem p02844 (python)

Fixed submission:
N = int(input())
S = [s for s in input()]
lis = [str(i)+str(j)+str(k) for i in range(10) for j in range(10) for k in range(10)]
ans = 0
from collections import defaultdict
d = defaultdict(list)
for i,s in enumerate(S):
    d[s].append(i)

for s in lis:
    if d[s[0]]:
        i = min(d[s[0]])
        if d[s[1]]:
            for j in d[s[1]]:
                if j > i:
                    if d[s[2]]:
                        if max(d[s[2]]) > j:
                            ans += 1
                            break
                    break
        else:continue
    else:continue
                            
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = [s for s in input()]
lis = [str(i)+str(j)+str(k) for i in range(10) for j in range(10) for k in range(10)]
ans = 0
from collections import defaultdict
d = defaultdict(list)
for i,s in enumerate(S):
    d[s].append(i)

for s in lis:
    if d[s[0]]:
        i = min(d[s][0])
        if d[s[1]]:
            for j in d[s[1]]:
                if j > i:
                    if d[s[2]]:
                        if max(d[s[2]]) > j:
                            ans += 1
                            break
                    break
        else:continue
    else:continue
                            
print(ans)
Problem p02885 (python)

Fixed submission:
A,B = map(int,input().split())
if A < 2*B:
  print(0)
else:
  print(A-2*B)

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

l = []
for j in range(N-1):
    for i in range(j+1,N):
        for k in range(i+1,N):
            if(L[i]+L[j]>L[k])and(L[i]+L[k]>L[j])and(L[i]<L[j]+L[k]):
                l.append([i,j,k])
                if [i,j,k] in l:
                    continue
                else:
                    count += 1
print(count)

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

l = []
for j in range(N-1):
    for i in range(j+1,N):
        for k in range(i+1,N):
            if(L[i]+L[j]>L[k])and(L[i]+L[k]>L[j])and(L[i]<L[j]+L[k]):
                l.append([i,j,k])
                if([i,j,k] in l):
                    count += 1
print(count)
print(l)
Problem p02917 (python)

Fixed submission:
n = int(input())
b = list(map(int, input().split()))
a = [-1]*n
for i in range(n):
    if i == 0:
        a[i] = b[i]
    elif i < n-1:
        a[i] = min(b[i],b[i-1])
    else:
        a[i] = b[i-1]

print(sum(a))

Buggy submission (verdict: Runtime Error):
n = int(input())
b = list(map(int, input().split()))
a = [-1]*n
for i in range(1,n-1):
    a[i] = min(b[i],b[i-1])
a[0] = a[1]
#print(a)
a[n-1] = max(b[-1],b[-2])
#print(a)
print(sum(a))
Problem p02922 (python)

Fixed submission:
a, b = map(int, input().split(" "))
i = 0
s = 1
while s < b:
  s += a-1
  i += 1
print(i)

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

plug = [0] * 50
plug[0] = 1

i = 0
while plug[i] < B:
  i += 1
  plug[i] = plug[i-1] + a - 1
print(i)
Problem p02934 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split(" ")))
ans = 0
for i in range(n):
  ans += 1/a[i]
print(1/ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split(" ")))
for i in range(n):
  ans += 1/a[i]
print(1/ans)
Problem p03086 (python)

Fixed submission:
S = input()
cnt=0
ans = 0
sets = {"A","T","C","G"}
for s in S:
  if s in sets:
    cnt += 1
  else:
    ans = max(ans,cnt)
    cnt = 0
ans = max(ans,cnt)
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
cnt=0
ans = 0
sets = set([A,T,C,G])
for s in S:
  if s in sets:
    cnt += 1
  else:
    ans = max(ans,cnt)
    cnt = 0
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
cnt=0
ans = 0
sets = {A,T,C,G}
for s in S:
  if s in sets:
    cnt += 1
  else:
    ans = max(ans,cnt)
    cnt = 0
print(ans)
Problem p03161 (python)

Fixed submission:
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [2**60 for i in range(110000)]
dp[0] = 0
for i in range(n):
    for j in range(1,k+1):
        if i+j < n:
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i+j]-h[i]))
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [2*10**4]*n*k
dp[0] = 0
for i in range(n):
    for j in range(1,k+1):
      dp[i+j] = min(dp[i+j], dp[i]+abs(h[i+j]-h[i]))
print(dp[n-1])
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]
ans = 0
d1 = Counter(V1)
d2 = Counter(V2)
if len(d1) == 1 and V1 == V2:
    print(N//2)
    exit()
m1 = max(d1.items(), key = lambda x:x[1])
m2 = max(d2.items(), key = lambda x:x[1])
d1.pop(m1[0])
d2.pop(m2[0])
a = m1[1]
b = m2[1]
if m1[0] != m2[0]:
    if d1:
      ans += sum(d1.values())
    if d2:
      ans += sum(d2.values())
else:
    c = 0
    d = 0
    if d1:
	    c = max(d1.values())
    if d2:
	    d = max(d2.values())
    if c != 0:
        tmp = N-b-c
    if c == 0:
        tmp = N-b-a
    if d != 0:
        ttmp = N-a-d
    if d == 0:
        ttmp = N-a-b
    
    ans = min(tmp,ttmp)
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]
ans = 0
if V1 == V2:
  ans = N//2
else:
  d1 = Counter(V1)
  d2 = Counter(V2)
  m1 = max(d1)
  m2 = max(d2)
  a = d1.pop(m1)
  b = d2.pop(m2)
  if a != b:
    if d1:
      ans += sum(d1.values())
    if d2:
      ans += sum(d2.values())
  else:
    c = max(d1.values())
    d = max(d2.values())
    tmp = N - a - d
    ans = min(tmp,N - b - c)
print(ans)