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

Fixed submission:
X,Y,a,b,c = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()

ans = 0
if X < a:
    A = A[a-X:]
if Y < b:
    B = B[b-Y:]
ans = 0
for i in range(X+Y):
    if len(A) == 0:
        A.append(0)
    if len(B) == 0:
        B.append(0)
    if len(C) == 0:
        C.append(0)
    if max(A[-1],B[-1],C[-1]) == A[-1]:
        ans += A[-1]
        A.pop()
    elif max(A[-1],B[-1],C[-1]) == B[-1]:
        ans += B[-1]
        B.pop()
    else:
        ans += C[-1]
        C.pop()
print(ans)

Buggy submission (verdict: Runtime Error):
X,Y,A,B,C = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort(
ans = 0

for i in range(X):
    if A[-1] >= C[-1]:
        ans += A[-1]
        A.pop()
    else:
        ans += C[-1]
        C.pop()

for i in range(Y):
    if B[-1] >= C[-1]:
        ans += B[-1]
        B.pop()
    else:
        ans += C[-1]
        C.pop()
        
print(ans)

Buggy submission (verdict: Runtime Error):
X,Y,A,B,C = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
ans = 0

for i in range(X):
    if A[0] >= C[0]:
        ans += A[0]
        A.pop(0)
    else:
        ans += C[0]
        C.pop(0)

for i in range(Y):
    if B[0] >= C[0]:
        ans += B[0]
        B.pop(0)
    else:
        ans += C[0]
        C.pop(0)
        
print(ans)
Problem p02761 (python)

Fixed submission:
n,m = map(int,input().split())
if m == 0:
    if n == 1:
        print(0)
        exit()
    if n == 2:
        print(10)
        exit()
    if n == 3:
        print(100)
        exit()

a = [-1]*n
for _ in range(m):
    s,c = map(int,input().split())
    if s == 1 and c == 0 and n == 3:
        print(-1)
        exit()
    if s == 1 and c == 0 and n == 2:
        print(-1)
        exit()
    if a[s-1] == -1:
        a[s-1] = c
    else:
        if a[s-1] != c:
            print(-1)
            exit()

ans = ""
for i in range(n):
    if a[i] == -1:
        if i == 0:
            ans += "1"
        else:
            ans += "0"
    else:
        ans += str(a[i])
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
query = [list(map(int,input().split())) for _ in range(m)]
for i in range(10**n):
    k = str(i)
    flag = True
    for s,c in query:
        if k[s-1] != str(c):
            flag = False
    if flag and len(k) == n:
        print(i)
        exit()
print(-1)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
query = [list(map(int,input().split())) for _ in range(m)]
for i in range(10**n):
    k = str(i)
    flag = True
    for s,c in query:
        if k[s-1] != c:
            flag = False
    if flag and len(k) == n:
        print(i)
        exit()
print(-1)
Problem p02811 (python)

Fixed submission:
k,x = map(int,input().split())
if k*500 >= x:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import math 
def lcm(x,y):
    return x*y//math.gcd(x,y)
n,m = map(int,input().split())
a = list(map(int,input().split()))
gcds = a[0]
for i in a:
    gcds = lcm(gcds,i)
a = [i//2 for i in a]
a_0 = a[0]
for i in a:
    a_0 = lcm(a_0,i)
#print(a_0,gcds)
if a_0 < m:
    ans = math.ceil((m - a_0) // gcds)
elif a_0 == m:
    ans = 1
else:
    ans = 0
print(ans)
Problem p02823 (python)

Fixed submission:
n,a,b = map(int,input().split())
if (b-a-1) % 2 == 0:
    ans = min(a-1, n-b) + 1 + (b-a-1)//2
else:
    ans = (b-a)//2
print(ans)

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
if (b-a-1) % 2 == 0:
    #print(b-1,n-a)
    ans = min(a-1, n-b) + 1  + (B-A-1)//2
else:
    ans = (b-a)//2
print(ans)
Problem p02838 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
ans = 0
for i in range(60):
    x = 1<< i
    l = len([1 for j in a if j & x])
    ans += x * l * (n-l) % mod
    ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
mod = 10e9+7
ans = 0
for i in range(60):
    x = 1 << i
    n = len([1 for j in a if j & X])
    ans += x * n * (N-n) % mod
    ans %= mod
print(ans)
Problem p02927 (python)

Fixed submission:
m,d = map(int,input().split())
ans = 0
if d < 10:
    print(ans)
else:
    for month in range(1,m+1):
        for day in range(10,d+1):
            if int(str(day)[0])*int(str(day)[1]) == month:
                if int(str(day)[1]) >= 2 and int(str(day)[0]) >= 2:
                    ans += 1
    print(ans)

Buggy submission (verdict: Runtime Error):
m,d = map(int,input().split())
ans = 0
if d < 10:
    print(ans)
else:
    for month in range(1,m+1):
        for day in range(1,d+1):
            if int(str(day)[0])*int(str(day)[1]) == month:
                if int(str(day)[1]) >= 2 and int(str(day)[0]) >= 2:
                    ans += 1
    print(ans)
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.readline


def dfs(v, par):
    for nv in tree[v]:
        if nv != par:
            adds[nv] += adds[v]
            dfs(nv, v)


n,q = map(int, input().split())
tree = [[]for _ in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    tree[a].append(b)
    tree[b].append(a)

adds = [0] * n
for i in range(q):
    p,x = map(int, input().split())
    p -= 1
    adds[p] += x
dfs(0, -1)
print(*adds)

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


def dfs(v, par):
    for nv in tree[v]:
        if nv != par:
            adds[nv] += adds[v]
            dfs(nv, v)


n,q = map(int, input().split())
tree = [[]for _ in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    tree[a].append(b)
    tree[b].append(a)

adds = [0] * n
for i in range(q):
    p,x = map(int, input().split())
    p -= 1
    adds[p] += x
dfs(0, -1)
print(*adds)
Problem p02971 (python)

Fixed submission:
n = int(input())
num = [ int(input()) for _ in range(n) ]
B = sorted(num,reverse=True)
maxnum = B[0]
maxnum2 = B[1]

for i in range(n):
    if num[i] != maxnum:
        print(maxnum)
    else:
        print(maxnum2)

Buggy submission (verdict: Runtime Error):
n = int(input())
num = [ int(input()) for _ in range(n) ]
B = sorted(num,revese=True)
maxnum = B[0]
maxnum2 = B[1]

for i in range(n):
    if num[i] != maxnum:
        print(maxnum)
    else:
        print(maxnum2)
Problem p02975 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
A = list(set(a))
A.sort()
ans = "No"
if len(A) == 1:
    if A[0] == 0:
        ans = "Yes"
elif len(A) == 2:
    if A[0] == 0:
        if a.count(A[1]) == 2* (n // 3) :
            ans = "Yes"
elif len(A) == 3:
    if A[0]^A[1]^A[2] == 0:
        if a.count(A[0]) == n//3:
            if a.count(A[1]) == n//3:
                if a.count(A[2]) == n//3:
                    ans = "Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
A = list(set(a))
A.sort()
if len(A) == 1:
    if A[0] == 0:
        ans = "Yes"
elif len(A) == 2:
    if A[0] == 0:
        if a.count(A[1]) == 2* (n // 3) :
            ans = "Yes"
elif len(A) == 3:
    if A[0]^A[1]^A[2] == 0:
        if a.count(A[0]) == n//3:
            if a.count(A[1]) == n//3:
                if a.count(A[2]) == n//3:
                    ans = "Yes"
else:
    ans = "No"

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
A = list(set(a))
A.sort()
if A == [0]:
    ans = "Yes"
elif len(A) == 2:
    if A[0] == 0:
        if a.count(A[1]) == 2* (n // 3) :
            ans = "Yes"
elif len(A) == 3:
    if A[0]^A[1]^A[2] == 0:
        if a.count(A[0]) == n//3:
            if a.count(A[1]) == n//3:
                if a.count(A[2]) == n//3:
                    ans = "Yes"
else:
    ans = "No"

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
A = list(set(a))
if A == (0):
    ans = "Yes"
elif len(A) == 2 and 0 in A:
    if a.count(A[1]) == (2*n // 3) :
        ans = "Yes"
elif len(A) == 3:
    if A[0]^A[1]^A[2] == 0:
        if a.count(A[0]) == n//3:
            if a.count(A[1]) == n//3:
                if a.count(A[2]) == n//3:
                    ans = "Yes"
else:
    ans = "No"

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
A = set(a)
if A == (0):
    ans = "Yes"
elif len(A) == 2 and 0 in A:
    b = list(A)
    if a.count(b[1]) == (2*n // 3) :
        ans = "Yes"
elif len(A) == 3:
    b = list(A)
    if b[0]^b[1]^b[2] == 0:
        if a.count(b[0]) == n//3:
            if a.count(b[1]) == n//3:
                if a.count(b[2]) == n//3:
                    ans = "Yes"
else:
    ans = "No"

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
A = set(a)
if A == (0):
    ans = "Yes"
elif len(A) == 2 and 0 in A:
    b = list(A)
    if a.count(b[1]) == (2*n // 3) :
        ans = "Yes"
elif len(A) == 3:
    b = list(A)
    if b[0]^b[1]^b[2] == 0:
        if a.count(b[0]) == n//3 and a.count(b[1]) == n//3 and a.count(b[2]) == n//3:
            ans = "Yes"
else:
    ans = "No"

print(ans)
Problem p02981 (python)

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

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
print(min(n*a),b)
Problem p02982 (python)

Fixed submission:
n,d = map(int,input().split())
obj = [list(map(int,input().split())) for _ in range(n)]
ans = 0
for i in range(n):
    for j in range(n):
        if i == j:
            pass
        else:
            dis = 0
            for k in range(d):
                dis += (obj[i][k] - obj[j][k])**2
            dis = dis ** 0.5
            if dis == dis // 1:
                ans += 1

print(ans//2)

Buggy submission (verdict: Runtime Error):
n,d = map(int,input().split())
obj = [list(map(int,input().split())) for _ in range(n)]
ans = 0
for i in range(n):
    for j in range(n):
        if i == j:
            pass
        else:
            dis = 0
            for k in range(d):
                dis += (obj[i][k] - obj[j][k])**2
            dis = dis ** 0.5
            if dis == dis // 1:
                ans += 1

print(ans//2
Problem p02996 (python)

Fixed submission:
n = int(input())
tasks = []

for _ in range(n):
    c,d = map(int,input().split())
    tasks.append([d,c])
tasks.sort()
maxday = tasks[-1][0]
worked = 0
for i in range(n):
    day = tasks[i][0]
    cost = tasks[i][1]
    if day - worked < cost :
        print("No")
        exit()
    else:
        worked += cost
print("Yes")

Buggy submission (verdict: Runtime Error):
n = int(input())
tasks = []

for _ in range(n):
    c,d = map(int,input().split())
    tasks.append([d,c])
tasks.sort()
maxday = tasks[-1][0]
cul = [0] * maxday
for i in range(n):
    day = tasks[i][0]
    cost = tasks[i][1]
    if day - sum(cul[0:day+1]) < cost :
        print("No")
        exit()
    else:
        j = 0
        k = 0
        while k < cost:
            if cul[j] == 0:
                cul[j] = 1
                k += 1

            j += 1
    #print(cul)
print("Yes")
Problem p03035 (python)

Fixed submission:
a,b = map(int,input().split())
if a >= 13:
    ans = b
elif 6 <= a <= 12:
    ans = b//2
else:
    ans = 0
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import bisect
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
#Query = []
#for _ in range(m):
#    b,c = map(int,input().split())
#    Query.append([c,b])
#Query.sort(reverse=True)
Query = [list(map(int,input().split())) for _ in range(m)]
Query = sorted(Query, key=lambda x:(x[1], x[0]), reverse=True)
ans = 0
for b,c in Query:
    #b,c = Query[i][1],Query[i][0]
    #b,c = Query[i][0],Query[i][1]
    if A[0] >= c:
        break
    else:
        #A.sort()
        index = bisect.bisect_left(A,c)
        ans += sum(A[index:])
        if b <= index:
            #for i in range(b):
            #    A[i] = c
            A = A[b:index].extend([c for i in range(b)])
        else:
            #for i in range(index):
            #    A[i] = c
            A = [ c for i in range(index)]
    #print(A)
print(ans + sum(A))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import bisect
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
Query = [list(map(int,input().split())) for _ in range(m)]
Query = sorted(Query, key=lambda x:(x[1], x[0]), reverse=True)
for b,c in Query:
    if A[0] >= c:
        break
    else:
        index = bisect.bisect_left(A,c)
        if b <= index:
            A = A[b:index] + [c for i in range(b)] + A[index:]
        else:
            A = [ c for i in range(index)] + A[index:]
print(sum(A))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import bisect
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
Query = []
for _ in range(m):
    b,c = map(int,input().split())
    Query.append([c,b])
Query.sort(reverse=True)
for i in range(m):
    b,c = Query[i][1],Query[i][0]
    if A[0] >= c:
        break
    else:
        #A.sort()
        index = bisect.bisect_left(A,c)
        if b <= index:
            #for i in range(b):
            #    A[i] = c
            A = A[b:index] + [c for i in range(b)] + A[index:]
        else:
            #for i in range(index):
            #    A[i] = c
            A = [ c for i in range(index)] + A[index:]
    #print(A)
print(sum(A))
Problem p03047 (python)

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

ans = 0
for i in range(a):
    if i + b > a:
        break
    else:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = 0
ls = 0
rs = 0
lr = 0
for _ in range(N):
    s = str(input())
    if "AB" in s:
        ans += 1
    if s[-1] == "A" and s[0] == "B":
        lr += 1
    elif s[-1] == "A":
        rs += 1
    elif s[0] == "B":
        ls += 1
if ls == 0 and rs == 0:
    ans += lr - 1 
elif ls == 0 and rs != 0:
    ans += lr
elif ls != 0 and rs == 0:
    ans += lr
else:
    lr += 1
    rs -= 1
    ls -= 1
    ans += lr
    ans += (rs+ls)//2
#ans += lr
print(ans)
Problem p03067 (python)

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

Buggy submission (verdict: Runtime Error):
n = int(input())
S = input()
s = list(S)
j = list(S)
ans = 0
aans = 0
for i in range(n-2,-1,-1):
    if s[i] == "#" and s[i+1] == ".":
        ans += 1
        s[i+1] = "#"
for i in range(n-1):
    if j[i] == "#" and j[i+1] == ".":
        aans += 1
        j[i+1] == "#"
print(min(ans,aans))
Problem p03069 (python)

Fixed submission:
n = int(input())
s = list(input())
b = [0] * n
w = [0] * n
x,y = 0,0
ans = 0
for i in range(n):
    if s[i] == '#':
        x += 1
    else:
        y += 1
    b[i] = x
    w[i] = y

ans = float('inf')
for i in range(n):
    ans = min(ans, b[i] + w[n-1] - w[i])
print(min(ans, b[n-1], w[n-1]))

Buggy submission (verdict: Runtime Error):
n = int(input())
S = input()
a = list(S)
ans = 0

for i in range(n-2,-1,-1):

    if a[i] == "#" and a[i+1] == ".":
        bns += 1
        a[i] = "."

print(ans)
Problem p03087 (python)

Fixed submission:
from itertools import *
n,q = map(int,input().split())
s = str(input())
k = [ 1 if s[i-1] == "A" and s[i] == "C" else 0  for i in range(n)]
cumsum = list(accumulate(k))
#print(k)
#print(cumsum)
for i in range(q):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    #print(k[a:b+1])
    ans = cumsum[b] - cumsum[a]
    """
    if k[a] == 1:
        ans -= 1
    """
    print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n,q = map(int,input().split())
s = str(input())
k = np.array([ 1 if s[i-1] == "A" and s[i] == "C" else 0  for i in range(n)])
#print(k)
for i in range(q):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    #print(k[a:b+1])
    ans = np.sum(k[a:b+1])
    if k[a] == 1:
        ans -= 1
    print(ans)
Problem p03106 (python)

Fixed submission:
a,b,k = map(int,input().split())
cd = []
for i in range(1,min(a,b)+1):
    if a % i == 0:
        if b % i == 0:
            cd.append(i)
cd.sort(reverse=True)
print(cd[k-1])

Buggy submission (verdict: Runtime Error):
from fractions import gcd
a,b,k = map(int,input().split())
mods = []
for i in range(1,min(a,b)):
    if a % i == 0 and b % i == 0:
        mods.append(i)
mods.sort(reverse=True)
if len(mods) == 1:
    print(mods[0])
else:
    print(mods[k-1])

Buggy submission (verdict: Runtime Error):
from fractions import gcd
a,b,k = map(int,input().split())
mods = []
for i in range(1,min(a,b)):
    if a % i == 0 and b % i == 0:
        mods.append(i)
mods.sort(reverse=True)
if len(mods) == 1:
    print(mods[0])
else:
    print(mods[k-1])

Buggy submission (verdict: Runtime Error):
from fractions import gcd
a,b,k = map(int,input().split())
mods = []
for i in range(1,max(a,b)):
    if a % i == 0 and b % i == 0:
        mods.append(i)
print(mods[k-1])
Problem p03150 (python)

Fixed submission:
s = str(input())
for i in range(len(s)):
    for j in range(i, len(s)):
        a = s[:i] + s[j:]
        if a == "keyence":
            print("YES")
            exit()
print("NO")

Buggy submission (verdict: Runtime Error):
S = str(input())
s = input()
for i in range(len(s)):
    for j in range(i, len(s)):
        a = s[:i] + s[j:]
        if a == "keyence":
            print("YES")
            exit()
print("NO")

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

while True:
    if s[0] == "k":
        break
    else:
        s = s[1:]
if len(s) < 7:
    print("NO")
else:
    middlerange = len(s) - 7
    if s[0]+s[middlerange+1:] == "keyence":
        print("YES")
    elif s[0:2]+s[middlerange+2:] == "keyence":
        print("YES")
    elif s[0:3]+s[middlerange+3:] == "keyence":
        print("YES")
    elif s[0:4]+s[middlerange+4:] == "keyence":
        print("YES")
    elif s[0:5]+s[middlerange+5:] == "keyence":
        print("YES")
    elif s[0:6]+s[middlerange+6:] == "keyence":
        print("YES")
    elif s[0:7]+s[middlerange+7:] == "keyence":
        print("YES")
    else:
        print("NO")
Problem p03161 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000) 
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
A = [0]*(n)
if k >= n:
    k = n
for i in range(1,k):
    A[i] = abs(l[i]-l[0])
for i in range(k,n):
    tmp = float('Inf')
    for j in range(1,k+1):
        dis = A[i-j] + abs(l[i]-l[i-j])
        tmp = min(tmp,dis)
    A[i] = tmp
print(A[n-1])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000) 
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
A = [0]*(n)
if k >= n:
    k = n
for i in range(1,k+1):
    A[i] = abs(l[i]-l[0])
for i in range(k,n):
    tmp = float('Inf')
    for j in range(1,k+1):
        dis = A[i-j] + abs(l[i]-l[i-j])
        tmp = min(tmp,dis)
    A[i] = tmp
print(A[n-1])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000) 
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
A = [0]*(n)
for i in range(1,k+1):
    A[i] = abs(l[i]-l[0])
for i in range(k,n):
    tmp = float('Inf')
    for j in range(1,k+1):
        dis = A[i-j] + abs(l[i]-l[i-j])
        tmp = min(tmp,dis)
    A[i] = tmp
print(A[n-1])

Buggy submission (verdict: Runtime Error):
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
A = [0]*(n)
for i in range(1,k+1):
    A[i] = abs(l[i]-l[0])
for i in range(k,n):
    tmp = float('Inf')
    for j in range(1,k+1):
        dis = A[i-j] + abs(l[i]-l[i-j])
        tmp = min(tmp,dis)
    A[i] = tmp
print(A[n-1])

Buggy submission (verdict: Runtime Error):
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
A = [0]*(n)
for i in range(1,k+1):
    A[i] = abs(l[i]-l[0])
for i in range(k,n):
    tmp = float('Inf')
    for j in range(1,k+1):
        dis = A[i-j] + abs(l[i]-l[i-j])
        tmp = min(tmp,dis)
    A[i] = tmp
print(A[n-1])
Problem p03227 (python)

Fixed submission:
S = str(input())
if len(S) == 3:
    print(S[::-1])
else:
    print(S)

Buggy submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
i = 1
c = 1
while i <= K:
    if c % 2 == 1:
        if A % 2 == 0:
            A_ = A // 2
            A = A_
            B = B + A_
        else:
            A -= 1
            A_ = A // 2
            A = A_
            B = B + A_

        i += 1
        c += 1
    else:
        if B % 2 == 0:
            B_ = B //2
            A = A + B_
            B = B_
        else:
            B -= 1
            B_ = B //2
            A = A + B_
            B = B_

        i += 1
        c += 1
print(A,B)
Problem p03244 (python)

Fixed submission:
from collections import Counter
n = int(input())
v = list(map(int,input().split()))
o = Counter(v[::2]).most_common()
o.append((0,0))
e = Counter(v[1::2]).most_common()
e.append((0,0))
if o[0][0] == e[0][0]:
    ans = min(n - o[0][1] - e[1][1], n - o[1][1] - e[0][1])
else:
    ans = n - o[0][1] - e[0][1]
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
v = list(map(int,input().split()))
ev = [v[i] for i in range(n) if i % 2 == 0]
ov = [v[i] for i in range(n) if i % 2 == 1]
#print(ov,ev)
E = collections.Counter(ev).most_common()
#print(E)
if len(E) == 1:
    e = E[0][0]
    e1 = E[0][0]
    e2 = E[0][0]
else:
    e1 = E[0][0]
    e2 = E[1][0]
O = collections.Counter(ov).most_common()
#print(O)
if len(O) == 1:
    o = O[0][0]
    if e == o:
        print(n//2)
        exit()
    else:
        print(0)
        exit()
else:
    o1 = O[0][0]
    o2 = O[1][0]

tmp = 0
for i in range(n):
    if i % 2 == 0 and v[i] != e1:
        tmp += 1
    elif i % 2 == 1 and v[i] != o2:
        tmp += 1
ttmp = 0
for i in range(n):
    if i % 2 == 0 and v[i] != e2:
        ttmp += 1
    elif i % 2 == 1 and v[i] != o1:
        ttmp += 1
        
print(min(tmp,ttmp))

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
from collections import Counter

N = int(input())
v = list(map(int,input().split()))
d = Counter(v).most_common()
most_common = d[0][0]
try:
    second_common = d[1][0]
except:
    print(N//2)
    exit()
try:
    third_common = d[2][0]
except:
    third_common = float('Inf')

def f(v,m,s):
    cnt = 0
    for j in range(N):
        if j % 2 != 0:
            if v[j] != m:
                cnt += 1
        else:
            if v[j] != s:
                cnt += 1
    return cnt

p = [most_common,second_common,third_common]
p = list(product(p,p))
p = [i for i in p if i[0] != i[1]]
ans = float('inf')
for i in p:
    tmp = f(v,i[0],i[1])
    ans = min(ans,tmp)
print(ans)
Problem p03251 (python)

Fixed submission:
n,m,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
for i in range(max(x)+1,min(y)+1):
    if X < i <= Y:
        print("No War")
        exit()
print("War")

Buggy submission (verdict: Runtime Error):
N,M,X,Y = map(int,input().split())
Lx = list(map(int,input().split()))
Ly = list(map(int,input().split()))
count = 0
for i in range(X;Y):
    if max(Lx) < i <= min(Ly):
        count += 1
if count > 0:
    print("No War")
else:
    print("War")

Buggy submission (verdict: Runtime Error):
N,M,X,Y = map(int,input().split())
Lx = list(map(int,input().split()))
Ly = list(map(int,input().split()))
count = 0
for i in range(X:Y):
    if max(Lx) < i <= min(Ly):
        count += 1
if count > 0:
    print("No War")
else:
    print("War")
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:
    print("Yes")