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

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
n,m=map(int,input().split())
l=[[]for _ in range(n+1)]
for _ in range(m):
    x,y=map(int,input().split())
    l[x].append(y)

memo=[0]*(n+1)
def chain(v):
    if memo[v]!=0:
        return memo[v]
    else:
        for a in l[v]:
            memo[v]=max(chain(a)+1,memo[v])
        return memo[v]
res=0
for i in range(1,n+1):
    res=max(res,chain(i))
print(res)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[[]for _ in range(n+1)]
for _ in range(m):
    x,y=map(int,input().split())
    l[x].append(y)

memo=[0]*(n+1)
def chain(v):
    if memo[v]!=0:
        return memo[v]
    else:
        for a in l[v]:
            memo[v]=max(chain(a)+1,memo[v])
        return memo[v]
res=0
for i in range(1,n+1):
    res=max(res,chain(i))
print(res)
Problem p03231 (python)

Fixed submission:
import fractions
n,m=map(int,input().split())
s=input()
t=input()
b=0
for i in range(n):
    if (i*m)%n==0 and (i*m)//n<m:
        if not t[(i*m)//n]==s[i]:
            b=1

if b:
    print(-1)
else:
    print(n*m//fractions.gcd(n,m))

Buggy submission (verdict: Runtime Error):
import fraction
n,m=map(int,input().split())
s=input()
t=input()
b=0
for i in range(n):
    if (i*m)%n==0 and (i*m)//n<m:
        if not t[(i*m)//n]==s[i]:
            b=1

if b:
    print(-1)
else:
    print(n*m//fraction.gcd(n,m))

Buggy submission (verdict: Runtime Error):
import math
n,m=map(int,input().split())
s=input()
t=input()
b=0
for i in range(n):
    if (i*m)%n==0 and (i*m)//n<m:
        if not t[(i*m)//n]==s[i]:
            b=1

if b:
    print(-1)
else:
    print(n*m//math.gcd(n,m))
Problem p03244 (python)

Fixed submission:
n=int(input())
v=list(map(int,input().split()))
d1=[0]*(10**5+1)
d2=[0]*(10**5+1)

for i in range(n):
    if i%2==0:
        d1[v[i]]+=1
    else:
        d2[v[i]]+=1
if d1.index(max(d1))==d2.index(max(d2)):
    d1n=sorted(d1,reverse=True)
    d2n=sorted(d2,reverse=True)
    if d1n[1]>d2n[1]:
        print(n-d1n[1]-d2n[0])
    else:
        print(n-d1n[0]-d2n[1])
else:
    print(n-max(d1)-max(d2))

Buggy submission (verdict: Runtime Error):
n=int(input())
v=list(map(int,input().split()))
d1=[0]*(10**5+1)
d2=[0]*(10**5+1)

for i in range(n):
    if i%2==0:
        d1[v[i]]+=1
    else:
        d2[v[i]]+=1
assert n-max(d1)-max(d2)<0
print(n-max(d1)-max(d2))
Problem p03393 (python)

Fixed submission:
import string
ABC=list(string.ascii_lowercase)
s=input()
S=list(s[::-1])

if s=='zyxwvutsrqponmlkjihgfedcba':
    print(-1)
else:
    if len(s)==26:
        for i in range(len(s)):
            n=ABC.index(S[i])
            if not set(ABC[n+1:])<=set(S[i+1:]):
                j=i
                break
        L=list(set(ABC[n+1:])-set(S[j+1:]))
        L.sort()
        sgyku=L[0:1]+S[j+1:]
        print("".join(sgyku[::-1]))
    else:
        L=list(set(ABC)-set(s))
        L.sort()
        print(s+L[0])

Buggy submission (verdict: Runtime Error):
import string
ABC=list(string.ascii_lowercase)
s=input()
S=s[::-1]

if s=='zyxwvutsrqponmlkjihgfedcba':
    print(-1)
else:
    if len(s)==26:
        for i in range(len(s)):
            n=ABC.index(S[i])
            if not set(ABC[n+1:])<=set(S[i+1:]):
                j=i
                break
        L=list(set(ABC[n+1])-set(S[j+1:]))
        L.sort()
        sgyku=L[0:1]+S[j+1:]
        print("".join(sgyku[::-1]))
    else:
        L=list(set(ABC)-set(s))
        L.sort()
        print(s+L[0])
Problem p03607 (python)

Fixed submission:
from collections import defaultdict
n=int(input())
a=[]
d=defaultdict(int)
D=[]
for i in range(n):
    a.append(input())

for key in a:
    d[key]+=1

for k,v in d.items():
    if v%2==1:
        D.append(k)
print(len(D))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(n):
    m=int(input())
    if m in a:
        a.append(m)
    else:
        a.remove(m)
print(len(a))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(n):
    m=int(input())
    if m in a:
        a.append(m)
    else:
        a.remove(a)
print(len(a))
Problem p03681 (python)

Fixed submission:
n,m=map(int,input().split())
import math
a=math.factorial(n)
b=math.factorial(m)
if abs(n-m) > 1:
    print(0)

elif abs(n-m)==1:

    print((a*b)%(10**9+7))
else:
    print((a*b*2)%(10**9+7))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
import math

if abs(n-m) > 1:
    print(0)
else:
    print(math.factorial(n)*math.factorial(m)
Problem p03729 (python)

Fixed submission:
a,b,c=input().split()
A=a[len(a)-1]
B=b[0]
B1=b[len(b)-1]
C=c[0]

if A==B and B1==C:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
A=a[len(a)-1]
B=b[0]
B1=b[len(b)-1]
C=c[0]

If A==B and B1==C:
    print(“YES”)
else:
    print(“NO”)
Problem p03838 (python)

Fixed submission:
x,y=map(int,input().split())
X=abs(x)
Y=abs(y)
if X<Y:
    if x<y:
        if x*y>=0:
            p=y-x
        else:
            p=y-(-x)+1      
    else:
        if x*y>0:
            p=(-y)-(-x)+2
        else:
            p=(-y)-x+1

else:
    if x<y:
        if x*y>=0:
            p=y-x
        else:
            p=(-y)-x+1
    else:
        if x*y>0:
            p=(-y)-(-x)+2
        else:
            p=y-(-x)+1
print(p)

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
x0=x
y0=y
X=[1,1,-1,-1]
Y=[1,-1,1,-1]
l=[]
for i in range(4):
    x=x*X[i]
    y=y*Y[i]
    if y-x>=0:
      q=y-x
      if X[i]==-1:
        q+=1
      if Y[i]==-1:
        q+=1
    l.append(q)
    x=x0
    y=y0  
print(min(l))
Problem p04001 (python)

Fixed submission:
s=input()
n=len(s)
l=[[] for _ in range(2**(n-1))]
for b in range(2**(n-1)):
    x=b
    for i in range(n-1):
        if x%2==1:
            l[b].append(1)
        else:
            l[b].append(0)
        x//=2
#print(l)
indexes=[[] for _ in range(2**(n-1))]
for k in range(2**(n-1)):
    indexes[k]=[i for i, x in enumerate(l[k]) if x == 1]
#print(indexes)
SUM=0
for j in range(2**(n-1)):
    L=len(indexes[j])
    if L==0:
        SUM+=int(s)
        #print(SUM)
    else:
        SUM+=int(s[:indexes[j][0]+1])
        #print(SUM)
        SUM+=int(s[indexes[j][L-1]+1:])
        #print(SUM)
        if L>1:
            for h in range(L-1):
                SUM+=int(s[indexes[j][h]+1:indexes[j][h+1]+1])
                #print(SUM)
print(SUM)

Buggy submission (verdict: Runtime Error):
print(l)
indexes=[[] for _ in range(2**(n-1))]
for k in range(2**(n-1)):
    indexes[k]=[i for i, x in enumerate(l[k]) if x == 1]
#print(indexes)
SUM=0
for j in range(2**(n-1)):
    L=len(indexes[j])
    if L==0:
        SUM+=int(s)
        #print(SUM)
    else:
        SUM+=int(s[:indexes[j][0]+1])
        #print(SUM)
        SUM+=int(s[indexes[j][L-1]+1:])
        #print(SUM)
        if L>1:
            for h in range(L-1):
                SUM+=int(s[indexes[j][h]+1:indexes[j][h+1]+1])
                #print(SUM)
print(SUM)
Problem p02645 (python)

Fixed submission:
import random

name = input()
start = random.randint(0, len(name) - 3)
nickname = name[start:start + 3]
print(nickname)

Buggy submission (verdict: Runtime Error):
import random

name = input()
start = random.randint(0, len(name) - 4)
nickname = name[start:start + 3]
print(nickname)
Problem p03711 (python)

Fixed submission:
x,y = [int(i) for i in input().split()]

groupA = [1,3,5,7,8,10,12]
groupB = [4,6,9,11]
groupC = [2]

if x in groupA and y in groupA:
    print("Yes")
elif x in groupB and y in groupB:
    print("Yes")
elif x in groupC and y in groupC:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
x = input()
y = input()

groupA = [1,3,5,7,8,10,12]
groupB = [4,6,9,11]
groupC = [2]

if x in groupA and y in groupA:
    print("Yes")
elif x in groupB and y in groupB:
    print("Yes")
elif x in groupC and y in groupC:
    print("Yes")
else:
    print("No")
Problem p02675 (python)

Fixed submission:
n = int(input())
n= n %10
if n == 3:
    print('bon')
elif n == 0 or n== 1 or n==6 or n==8:
    print('pon')
else:
    print('hon')

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

n, m = map(int, input().split())
a = [0] * m
b = [0] * m
c = [[-1] * n for i in range(n)]
lead = [0] * n
i_n = [0] * n
for i in range(m):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1
    c[b[i]][i_n[b[i]]] = a[i]
    c[a[i]][i_n[a[i]]] = b[i]
    i_n[b[i]] += 1
    i_n[a[i]] += 1

d = deque()
d.append(0)

while len(d):
    k = len(d)
    for i in range(k):
        p = d[0]
        for j in range(n):
            if c[p][j] == -1:
                break
            if lead[c[p][j]] == 0:
                lead[c[p][j]] = p + 1
                d.append(c[p][j])
        d.popleft()

print('Yes')
for i in range(n - 1):
    print(lead[i + 1])
Problem p02855 (python)

Fixed submission:
h, w, k = map(int, input().split())
s = [""] * h
for i in range(h):
    s[i] = input()

ans = [[0 for i in range(w)] for j in range(h)]
lcnt = [0] * h
cnt = 0

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            lcnt[i] += 1

flag = 0
mem = [0] * w

a = 1

for i in range(h):
    t = 0
    j = 0

    while t < lcnt[i]:

        if s[i][j] == "#":
            t += 1
            ans[i][j] = a
            a += 1
        else:
            ans[i][j] = a

        j += 1

    for l in range(j, w):
        ans[i][l] = a - 1

for i in range(h):
    if lcnt[i] > 0:
        for j in range(w):
            mem[j] = ans[i][j]
        break

t = 0
while lcnt[t] == 0:
    for i in range(w):
        ans[t][i] = mem[i]
    lcnt[t] = 1
    t += 1

for i in range(1, h):
    if lcnt[i] == 0:
        for j in range(w):
            ans[i][j] = ans[i - 1][j]

for i in range(h):
    for j in range(w):
        print(ans[i][j], end="")
        if j != w - 1:
            print(" ", end="")
    print()

Buggy submission (verdict: Runtime Error):
h, w, k = map(int, input().split())
s = [""] * h
for i in range(h):
    s[i] = input()

ans = [[0 for i in range(w)] for j in range(h)]
lcnt = [0] * h
cnt = 0

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            lcnt[i] += 1

flag = 0
mem = [0] * w

a = 1

for i in range(h):
    t = 0
    j = 0

    while t < lcnt[i]:

        if s[i][j] == "#":
            t += 1
            ans[i][j] = a
            a += 1
        else:
            ans[i][j] = a

        j += 1

    for l in range(j, w):
        ans[i][l] = a - 1

for i in range(h):
    if lcnt[i] > 0:
        for j in range(w):
            mem[j] = ans[i][j]
        break

t = 0
while lcnt[t] == 0:
    for i in range(w):
        ans[t][i] = mem[i]
    lcnt[i] = 1
    t += 1

for i in range(1, h):
    if lcnt[i] == 0:
        for j in range(w):
            ans[i][j] = ans[i - 1][j]

for i in range(h):
    for j in range(w):
        print(ans[i][j], end="")
        if j != w - 1:
            print(" ", end="")
    print()
Problem p03473 (python)

Fixed submission:
m=int(input())
print(48-m)

Buggy submission (verdict: Runtime Error):
m=int(input())
  print(48-m)
Problem p03524 (python)

Fixed submission:
s=input()
t = set(s)
if len(s) ==1:
    print("YES")
    exit(0)
elif len(s) == 2 and len(t) ==2:
    print("YES")
    exit(0)
if len(t) != 3:
    print("NO")
else:
    a = s.count("a")
    b = s.count("b")
    c = s.count("c")
    M = max(a,b,c)
    m = min(a,b,c)
    if M - m >1 :
        print("NO")
    else:
        print("YES")

Buggy submission (verdict: Runtime Error):
s=input()
t = set(s)
if len(s) ==1:
    print("YES")
    exit(0)
elif len(s) == 1 && len(t) ==2:
    print("YES")
    exit(0)
if len(t) != 3:
    print("NO")
else:
    a = s.count("a")
    b = s.count("b")
    c = s.count("c")
    M = max(a,b,c)
    m = min(a,b,c)
    if M - m >1 :
        print("NO")
    else:
        print("YES")
Problem p04011 (python)

Fixed submission:
a=[0]*4
for i in range(4):
  a[i]=int(input())
if(a[0]<a[1]):print(a[2]*a[0])
else:print(a[2]*(a[1])+a[3]*(a[0]-a[1]))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]*4
for i range(4):
  a[i]=int(input())
if(a[0]<a[1]):print(a[2]*a[0])
else:print(a[2]*(a[1]-1)+a[3]*(a[0]-a[1]+1))
Problem p02612 (python)

Fixed submission:
N = int(input())

n = N % 1000
if n == 0:
    print(0)
else:
    print(1000-n)

Buggy submission (verdict: Runtime Error):
H, W, K = [int(s) for s in input().split()]

cs = []

for _ in range(H):
    if s == "AC":
        ac += 1
    elif s == "WA":
        wa += 1
    elif s == "TLE":
        tle += 1
    elif s == "RE":
        re += 1

print(f"AC x {ac}")
print(f"WA x {wa}")
print(f"TLE x {tle}")
print(f"RE x {re}")
Problem p03059 (python)

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

print((t // a)*b)

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

    if N == 2:
        print(max(A[0]+A[1], (-A[0])+(-A[1])))
        return

    a_sum, a1, a2 = 0, A[0], A[1]
    b_sum, b1, b2 = 0, -A[0], -A[1]

    for i in range(2, N):

        if (a_sum + a1 + a2 + A[i]) > (b_sum + b1 + b2 + A[i]):
            new_a_sum = a_sum + a1
            new_a1 = a2
            new_a2 = A[i]
        else:
            new_a_sum = b_sum + b1
            new_a1 = b2
            new_a2 = A[i]

        if (a_sum + a1 - a2 - A[i]) > (b_sum + b1 - b2 - A[i]):
            new_b_sum = a_sum + a1
            new_b1 = -a2
            new_b2 = -A[i]
        else:
            new_b_sum = b_sum + b1
            new_b1 = -b2
            new_b2 = -A[i]

        a_sum, a1, a2 = new_a_sum, new_a1, new_a2
        b_sum, b1, b2 = new_b_sum, new_b1, new_b2

    print(max(a_sum+a1+a2, b_sum+b1+b2))

main()

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

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

    if len(A) == 2:
        print(max(A))
        return

    if len(A) == 3:
        gcd1 = gcd(A[0], A[1])
        gcd2 = gcd(A[0], A[2])
        gcd3 = gcd(A[1], A[2])
        print(max(gcd1, gcd2, gcd3))
        return

    gcd1 = gcd(A[0], A[1])
    gcd2 = gcd(A[0], A[2])
    gcd3 = gcd(A[1], A[2])
    yet_used_gcd = max(gcd1, gcd2, gcd3)
    not_used_gcd = gcd(gcd1, A[2])

    for i in range(3, N):
        yet_used_gcd = gcd(yet_used_gcd, A[i])
        if yet_used_gcd < not_used_gcd:
            yet_used_gcd = not_used_gcd
        not_used_gcd = gcd(not_used_gcd, A[i])

    if yet_used_gcd > not_used_gcd:
        print(yet_used_gcd)
    else:
        print(not_used_gcd)

main()
Problem p03061 (python)

Fixed submission:
from fractions import gcd

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

    if len(A) == 2:
        print(max(A))
        return

    if len(A) == 3:
        gcd1 = gcd(A[0], A[1])
        gcd2 = gcd(A[0], A[2])
        gcd3 = gcd(A[1], A[2])
        print(max(gcd1, gcd2, gcd3))
        return

    gcd1 = gcd(A[0], A[1])
    gcd2 = gcd(A[0], A[2])
    gcd3 = gcd(A[1], A[2])
    yet_used_gcd = max(gcd1, gcd2, gcd3)
    not_used_gcd = gcd(gcd1, A[2])

    for i in range(3, N):
        yet_used_gcd = gcd(yet_used_gcd, A[i])
        if yet_used_gcd < not_used_gcd:
            yet_used_gcd = not_used_gcd
        not_used_gcd = gcd(not_used_gcd, A[i])

    if yet_used_gcd > not_used_gcd:
        print(yet_used_gcd)
    else:
        print(not_used_gcd)

main()

Buggy submission (verdict: Runtime Error):
import fractions

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

g_memo = {}

def my_gcd(i_list):
    global g_memo

    k = str(sorted(i_list))

    if k in g_memo.keys():
        return g_memo[k]

    if len(i_list) == 2:
        g_memo[k] = fractions.gcd(i_list[0], i_list[1])
        return g_memo[k]

    g_memo[k] = fractions.gcd(i_list[0], my_gcd(i_list[1:]))
    return g_memo[k]

if len(A) == 2:
    print(max(A))
else:
    max_gcd = 0
    for i in range(N):
        i_list = A[:i] + A[i+1:]
        gcd = my_gcd(i_list)
        if max_gcd < gcd:
            max_gcd = gcd

    print(max_gcd)
Problem p03062 (python)

Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))

    if N == 2:
        print(max(A[0]+A[1], (-A[0])+(-A[1])))
        return

    a_sum, a1, a2 = 0, A[0], A[1]
    b_sum, b1, b2 = 0, -A[0], -A[1]
    for i in range(2, N):
        #print(a_sum, a1, a2)
        #print(b_sum, b1, b2)
        #print(A[i])
        

        if (a_sum + a1 + a2 + A[i]) > (b_sum + b1 + b2 + A[i]):
            new_a_sum = a_sum + a1
            new_a1 = a2
            new_a2 = A[i]
        else:
            new_a_sum = b_sum + b1
            new_a1 = b2
            new_a2 = A[i]

        if (a_sum + a1 - a2 - A[i]) > (b_sum + b1 - b2 - A[i]):
            new_b_sum = a_sum + a1
            new_b1 = -a2
            new_b2 = -A[i]
        else:
            new_b_sum = b_sum + b1
            new_b1 = -b2
            new_b2 = -A[i]

        a_sum, a1, a2 = new_a_sum, new_a1, new_a2
        b_sum, b1, b2 = new_b_sum, new_b1, new_b2
        
    print(max(a_sum+a1+a2, b_sum+b1+b2))

main()

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

    if N == 2:
        print(max(A[0]+A[1], (-A[0])+(-A[1])))
        return

    a_sum, a1, a2 = 0, A[0], A[1]
    b_sum, b1, b2 = 0, -A[0], -A[1]
    for i in range(2, N):
        #print(a_sum, a1, a2)
        #print(b_sum, b1, b2)
        #print(A[i])


        if (a_sum + a1 + a2 + A[i]) > (b_sum + b1 + b2 + A[i]):
            new_a_sum = a_sum + a1
            new_a1 = a2
            new_a2 = A[i]
        else:
            new_a_sum = b_sum + b1
            new_a1 = b2
            new_a2 = A[i]
        a_sum, a1, a2 = new_a_sum, new_a1, new_a2
        b_sum, b1, b2 = new_b_sum, new_b1, new_b2

    print(max(a_sum+a1+a2, b_sum+b1+b2))

main()
Problem p03238 (python)

Fixed submission:
# coding: utf-8

def main():
    N = int(input().strip())

    if N == 1:
        print("Hello World")
    else:
        A = int(input().strip())
        B = int(input().strip())
        print(A+B)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math

N, M = [int(s) for s in input().strip().split()]

if N == 1:
    print(M)
    exit()

ROOT_M = int(math.sqrt(M))
divisors = []
for d in range(1, ROOT_M+1):
    if M % d == 0:
        divisors.append(d)
        divisors.append(M//d)

divisors.sort()
MAX_VAL = int(M/N)
for d in divisors:
    if d > MAX_VAL:
        break
    max_gcd = d

print(max_gcd)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

N = int(input().strip())

input_tuples = []
selected_tuple = None

for _ in range(N):
    x, y, h = [int(s) for s in input().strip().split()]
    if selected_tuple is None and h > 0:
        selected_tuple = ((x, y, h))
    else:
        input_tuples.append((x, y, h))

for cx in range(0, 101):
    for cy in range(0, 101):
        H = selected_tuple[2] + \
            abs(selected_tuple[0] - cx) + abs(selected_tuple[1] - cy)

        for x, y, h in input_tuples:
            if h != max(H - abs(x - cx) - abs(y - cy), 0):
                break
        else:
            break
        continue
    else:
        continue
    break

print("{} {} {}".format(cx, cy, H))
Problem p03241 (python)

Fixed submission:
# coding: utf-8
import math

N, M = [int(s) for s in input().strip().split()]

if N == 1:
    print(M)
    exit()

ROOT_M = int(math.sqrt(M))
divisors = []
for d in range(1, ROOT_M+1):
    if M % d == 0:
        divisors.append(d)
        divisors.append(M//d)

divisors.sort()
MAX_VAL = int(M/N)
for d in divisors:
    if d > MAX_VAL:
        break
    max_gcd = d

print(max_gcd)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math

N, M = [int(s) for s in input().strip().split()]

if N == 1:
    print(M)
    exit()

ROOT_M = int(math.sqrt(M))
divisors = []
for d in range(1, ROOT_M+1):
    if M % d == 0:
        divisors.append(d)
        divisors.append(M//d)

max_gcd = max([d for d in divisors if d < M/N])
print(max_gcd)
Problem p03244 (python)

Fixed submission:
# coding: utf-8
import collections

n = int(input().strip())
vs = [int(s) for s in input().strip().split()]

e = [vs[i*2] for i in range(n//2)]
o = [vs[i*2+1] for i in range(n//2)]

e_counter = collections.Counter(e).most_common()
o_counter = collections.Counter(o).most_common()

e1, e1_count = e_counter[0]
try:
    e2, e2_count = e_counter[1]
except IndexError:
    e2_count = 0

o1, o1_count = o_counter[0]
try:
    o2, o2_count = o_counter[1]
except IndexError:
    o2_count = 0

if e1 != o1:
    keep_num_count = e1_count + o1_count
else:
    keep_num_count = e1_count + o2_count
    if keep_num_count < e2_count + o1_count:
        keep_num_count = e2_count + o1_count

print(n - keep_num_count)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

n = int(input().strip())
vs = [int(s) for s in input().strip().split()]

as_i = [vs[i*2] for i in range(n//2)]
as_i2 = [vs[i*2+1] for i in range(n//2)]

count_i = [0] * 10001
for a in as_i:
    count_i[a] += 1

as_i2 = [vs[i*2+1] for i in range(n//2)]
count_i2 = [0] * 10001
for a in as_i2:
    count_i2[a] += 1


max_val_i = 0
max_count_i = 0
next_max_val_i = 0
next_max_count_i = 0
for i in range(1, 10001):
    if count_i[i] > max_count_i:
        next_max_count_i, next_max_val_i = max_count_i, max_val_i
        max_count_i, max_val_i = count_i[i], i

max_val_i2 = 0
max_count_i2 = 0
next_max_val_i2 = 0
next_max_count_i2 = 0
for i in range(1, 10001):
    if count_i2[i] > max_count_i2:
        next_max_count_i2, next_max_val_i2 = max_count_i2, next_max_val_i2
        max_count_i2, max_val_i2 = count_i2[i], i

# print(max_val_i, max_count_i)
# print(max_val_i2, max_count_i2)

keep_num = 0
if max_val_i != max_val_i2:
    keep_count = max_count_i + max_count_i2
else:
    if max_count_i > max_count_i2:
        keep_count = max_count_i + next_max_count_i2
    else:
        keep_count = next_max_count_i + max_count_i2

print(n - keep_count)
Problem p03361 (python)

Fixed submission:
OFFSETS = [(-1,0),(0,-1),(0,1),(1,0)]

H, W = map(int, input().split())

Ses = []
for _ in range(H):
    Ses.append(input())

for y in range(H):
    for x in range(W):
        if Ses[y][x] == "#":
            found = False
            for dx, dy in OFFSETS:
                now_x = x+dx
                now_y = y+dy
                if now_x < 0 or now_x >= W:
                    continue
                if now_y < 0 or now_y >= H:
                    continue
                if Ses[now_y][now_x] == "#":
                    found = True
                    break
            if not found:
                print("No")
                exit()

print("Yes")

Buggy submission (verdict: Runtime Error):
wOFFSETS = [(-1,0),(0,-1),(0,1),(1,0)]

H, W = map(int, input().split())

Ses = []
for _ in range(H):
    Ses.append(input())

for y in range(H):
    for x in range(W):
        if Ses[y][x] == "#":
            found = False
            for dx, dy in OFFSETS:
                now_x = x+dx
                now_y = y+dy
                if now_x < 0 or now_x >= W:
                    continue
                if now_y < 0 or now_y >= H:
                    continue
                if Ses[now_y][now_x] == "#":
                    found = True
                    break
            if not found:
                print("No")
                exit()

print("Yes")
Problem p02621 (python)

Fixed submission:
a = int(input())
print(a + a**2 + a**3)

Buggy submission (verdict: Runtime Error):
a = int(raw_input())
print(a + a**2 + a**3)