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

Fixed submission:
import collections
n = int(input())
a = [int(i) for i in input().split()]
b = collections.Counter(a)
ans = "No"
if (len(b) == 3):
    if (list(b.keys())[0] ^ list(b.keys())[1] ^ list(b.keys())[2]) == 0:
        if ((list(b.values())[0] == list(b.values())[1]) & (list(b.values())[0] == list(b.values())[2])):
            ans = "Yes"
elif (len(b) == 1):
    if list(b.keys())[0] == 0:
        ans = "Yes"
elif (len(b) == 2):
    if (n % 3 == 0):
        dd = list(b.keys())
        dd.sort()
        if (dd[0] == 0) & ((b[0] * 2) == (b[dd[1]])):
            ans = "Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
a = [int(i) for i in input().split()]
b = collections.Counter(a)
ans = "No"
if (len(b) == 3):
    if (list(b.keys())[0] ^ list(b.keys())[1] ^ list(b.keys())[2]) == 0:
        if ((list(b.values())[0] == list(b.values())[1]) & (list(b.values())[0] == list(b.values())[2])):
            ans = "Yes"
        else:
            ans = "No"
    else:
        ans = "No"
elif (len(b) == 1):
    if list(k.keys())[0] == 0:
        ans = "Yes"
    else:
        ans = "No"
elif (len(b) == 2):
    if n % 3 == 0:
        dd = list(b.keys())
        dd.sort()
        if (dd[0] == 0) & ((b[0] * 2) == (b[1])):
            ans = "Yes"
        else:
            ans = "No"
    else:
        ans = "No"
else:
    ans = "No"
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
a = [int(i) for i in input().split()]
b = collections.Counter(a)
ans = "No"
if (len(b) == 3):
    if (list(b.keys())[0] ^ list(b.keys())[1] ^ list(b.keys())[2]) == 0:
        if ((list(b.values())[0] == list(b.values())[1]) & (list(b.values())[0] == list(b.values())[2])):
            ans = "Yes"
elif (len(b) == 1):
    if list(k.keys())[0] == 0:
        ans = "Yes"
elif (len(b) == 2):
    if n % 3 == 0:
        dd = list(b.keys())
        dd.sort()
        if (dd[0] == 0) & ((b[0] * 2) == (b[1])):
            ans = "Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
a = [int(i) for i in input().split()]
b = collections.Counter(a)
ans = "No"
if (len(b) == 3):
    if (list(b.keys())[0] ^ list(b.keys())[1] ^ list(b.keys())[2]) == 0:
        ans = "Yes"
elif (len(b) == 1):
    if list(k.keys())[0] == 0:
        ans = "Yes"
else:
    continue
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
a = [int(i) for i in input().split()]
b = collections.Counter(a)
ans = "No"
if (len(b) == 3):
    if (list(b.keys())[0] ^ list(b.keys())[1] ^ list(b.keys())[2]) == 0:
        ans = "Yes"
elif (len(b) == 1):
    if list(k.keys())[0] == 0:
        ans = "Yes"
print(ans)
Problem p02995 (python)

Fixed submission:
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
def lcm(x, y):
    return (x * y) // gcd(x, y)

a, b, c, d = map(int, input().split())
l = lcm(c, d)
bad = (b // c) - ((a-1) // c) + (b // d) - ((a-1) // d) - (b // l) + ((a-1) // l)
ans = b - a + 1 - bad
print(ans)

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

a, b, c, d = map(int, input().split())
l = lcm(c, d)
bad = (b // c) - ((a-1) // c) + (b // d) - ((a-1) // d) - (b // l) + ((a-1) // l)
ans = b - a + 1 - bad
print(ans)

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
l = lcm(c, d)
bad = (b // c) - ((a-1) // c) + (b // d) - ((a-1) // d) - (b // l) + ((a-1) // l)
ans = b - a + 1 - bad
print(ans)
Problem p03006 (python)

Fixed submission:
from collections import Counter
n = int(input())
a = []
ans = []
if n == 1:
    print(1)
    exit()
for _ in range(n):
    x, y = map(int, input().split())
    a.append([x, y])
a.sort()
for i in range(n):
    for j in range(i + 1, n):
        p = a[i][0] - a[j][0]
        q = a[i][1] - a[j][1]
        ans.append(str(p) + " " + str(q))
print(n - max(Counter(ans).values()))

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
a = []
ans = []
for _ in range(n):
    x, y = map(int, input().split())
    a.append([x, y])
for i in range(n):
    for j in range(i + 1, n):
        p = a[i][0] - a[j][0]
        q = a[i][1] - a[j][1]
        ans.append(str(p) + " " + str(q))
print(n - max(Counter(ans).values()))
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

n = int(input())
graph = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    if w % 2 == 0:
        graph[u].append((v, 1))
        graph[v].append((u, 1))
    else:
        graph[u].append((v, -1))
        graph[v].append((u, -1))
            
color = [None for i in range(n)]
def set_color(v, c):
    color[v] = c
    for next_v, d in graph[v]:
        if color[next_v] is None:
            set_color(next_v, d * c)

set_color(0, 1)
for c in color:
    if c != 1:
        print(0)
    else:
        print(1)

Buggy submission (verdict: Runtime Error):
n = int(input())
graph = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    if w % 2 == 0:
        graph[u].append((v, 1))
        graph[v].append((u, 1))
    else:
        graph[u].append((v, -1))
        graph[v].append((u, -1))
            
color = [None for i in range(n)]
def set_color(v, c):
    color[v] = c
    for next_v, d in graph[v]:
        if color[next_v] is None:
            set_color(next_v, d * c)

set_color(0, 1)
for c in color:
    if c != 1:
        print(0)
    else:
        print(1)
Problem p03048 (python)

Fixed submission:
import math
r, g, b, n = map(int, input().split())
ans = 0
for r_num in range(math.floor(n/r)+1):
    for g_num in range(math.floor(math.floor(n - r*r_num)/g)+1):
        if ((n - (r_num * r) - (g_num * g)) % b == 0):
            ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
r, g, b, n = map(int, input().split())
ans = 0
for r_num in range(math.floor(n/r)+1):
    for g_num in range(math.floor(math.floor(n - r*r_num)/g)+1):
        if ((n - (r_num * r) - (g_num * g)) % b == 0):
            ans += 1
print(ans)
Problem p03061 (python)

Fixed submission:
def gcd(x, y):
    if x * y == 0:
        return (x+y)
    x, y = max(x, y), min(x, y)
    while y > 0:
        r = x % y
        x, y = y, r
    return x

n = int(input())
a = [int(i) for i in input().split()]
l_list = [0]
r_list = [0]
for i in range(n):
    l = gcd(l_list[i], a[i])
    l_list.append(l)
    r = gcd(r_list[-1], a[-i-1])
    r_list.append(r)
r_list = list(reversed(r_list))
r_list = r_list[1:]
l_list = l_list[:n]
c_list = []
for i in range(n):
    c_list.append(gcd(l_list[i], r_list[i]))
print(max(c_list))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]
l_list = [0]
r_list = [0]
for i in range(n):
    l = gcd(l_list[i], a[i])
    l_list.append(l)
    r = gcd(r_list[-1], a[-i-1])
    r_list.append(r)
r_list = list(reversed(r_list))
r_list = r_list[1:]
l_list = l_list[:n]
c_list = []
for i in range(n):
    c_list.append(gcd(l_list[i], r_list[i]))
print(max(c_list))

Buggy submission (verdict: Runtime Error):
from functools import reduce

def gcdd(x, y):
    for i in range(min(x, y), 1, -1):
        if x % i == 0 and y % i == 0:
            return i

def gcd(numbers):
    return reduce(gcdd, numbers)

n = int(input())
a = [int(i) for i in input().split()]
b = []
for i in range(n):
    d = a[:i] + a[i+1:]
    b.append(gcd(d))
print(max(b))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(numbers):
    return reduce(math.gcd, numbers)

n = int(input())
a = [int(i) for i in input().split()]
b = []
for i in range(n):
    d = a[:i] + a[i+1:]
    b.append(gcd(d))
print(max(b))
Problem p03069 (python)

Fixed submission:
import bisect
n = int(input())
s = list(input())
b = [0]*(n+1)
c = [s.count(".")]*(n+1)
a = []
a.append(c[0])
for i in range(n):
    if s[i] == "#":
        b[i+1] = b[i] + 1
        c[i+1] = c[i]
    else:
        c[i+1] = c[i] - 1
        b[i+1] = b[i]
    a.append(b[i+1] + c[i+1])
if "." not in s:
    a.append(0)
elif "#" not in s:
    a.append(0)
print(min(a))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(input())
if "." in s:
    a = [i for i, x in enumerate(s) if x == '.'][-1]
    ans1 = s[:a].count("#")
else:
    ans2 = 0
if "#" in s:
    b = [i for i, x in enumerate(s) if x == '#'][0]
    ans2 = s[b:].count(".")
else:
    ans2 = 0
print(min(ans1, ans2))
Problem p03074 (python)

Fixed submission:
n, k = map(int, input().split())
s = input()
hand_list = []
for i in range(n):
    if i == 0:
        hand_list.append(i)
    else:
        if s[i] != s[i - 1]:
            hand_list.append(i)
hand_list.append(n)

ans_list = []
if len(hand_list) > 2 * k:
    for i in range(len(hand_list) - 2 * k):
        if s[hand_list[i]] == '1':
            ans = hand_list[min(i + 2 * k + 1, len(hand_list)-1)] - hand_list[i]
        else:
            ans = hand_list[i + 2 * k] - hand_list[i]
        ans_list.append(ans)
else:
    ans_list.append(n)
print(max(ans_list))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()
hand_list = []
for i in range(n):
    if i == 0:
        hand_list.append(i)
    else:
        if s[i] != s[i - 1]:
            hand_list.append(i)
hand_list.append(n)

ans_list = []
if len(hand_list) > 2 * k:
    for i in range(len(hand_list) - 2 * k):
        if s[i] == '1':
            ans = hand_list[i + 2 * k + 1] - hand_list[i]
        else:
            ans = hand_list[i + 2 * k] - hand_list[i]
        ans_list.append(ans)
else:
    ans_list.append(n)
print(max(ans_list))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()
hand_list = []
for i in range(n):
    if i == 0:
        hand_list.append(i)
    else:
        if s[i] != s[i - 1]:
            hand_list.append(i)
hand_list.append(n)

ans_list = []
for i in range(len(hand_list) - 2 * k):
    if s[i] == '1':
        ans = hand_list[i + 2 * k + 1] - hand_list[i]
    else:
        ans = hand_list[i + 2 * k] - hand_list[i]
    ans_list.append(ans)
print(max(ans_list))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()

a = []
j = 0
temp = 1
prev = s[0]
for i in s[1:]:
    if i == prev:
        prev = i
        temp += 1
    else:
        a.append(temp)
        prev = i        
        temp = 1
a.append(temp)

b = []
if s[0] == "1":
    b.append(sum(a[:2*k+1]))
    for i in range(len(a) - 2*k - 1):
        b.append(b[-1] - a[i] + a[2*k+i+1])
    print(max(b))
else:
    t = a[1:]
    b.append(sum(t[:2*k+1]))
    for i in range(len(a) - 2*k - 1):
        b.append(b[-1] - t[i] + t[2*k+i+1])
    b.append(sum(a[:2*k]))
    print(max(b))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()
temp = ""
ans = []
c = 0
for s_ in s:
    if temp != s_:
        if s_ == "0":
            ans.append(c)
            temp = "0"
            c = -1
        else:
            ans.append(c)
            temp = "1"
            c = 1
    else:
        if s_ == "0":
            c -= 1
        else:
            c += 1
ans.append(c)
ans = ans[1:]
c = []
t = [i for i in range(len(ans)) if ans[i] < 0]
aaa = []
for v in itertools.combinations(t, k):
    anst = ans.copy()
    for v_ in v:
        anst[v_] *= -1
    c_ = 0
    for s_ in anst:
        if s_ > 0:
            c_ += s_
        else:
            aaa.append(c_)
            c_ = 0
    aaa.append(c_)
if len(aaa) > 0:
    print(max(aaa))
else:
    print(len(s))
Problem p03078 (python)

Fixed submission:
x, y, z, k = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)
c = sorted(list(map(int, input().split())), reverse=True)

ans = []
for i in range(x):
    for j in range(y):
        for l in range(z):
            if (i+1) * (j+1) * (l+1) <= k:
                ans.append(a[i] + b[j] + c[l])
            else:
                break

ans.sort(reverse=True)
for i in range(k):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
x, y, z, k = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)
c = sorted(list(map(int, input().split())), reverse=True)

a_b = []
for i in range(x):
    for j in range(y):
        a_b.append(a[i] + b[j])
a_b.sort(reverse=True)
ans = []
for i in range(k):
    for j in range(k):
        ans.append(a_b[i] + c[j])
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
x, y, z, k = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
max_num = a[-1] + b[-1] + c[-1]
a_m = [aa - a[-1] for aa in a[:-1]]
b_m = [bb - b[-1] for bb in b[:-1]]
c_m = [cc - c[-1] for cc in c[:-1]]
d = a_m + b_m + c_m + [0]
d.sort()
d = list(reversed(d))
for i in range(k):
    ans = max_num + d[i]
    print(ans)
Problem p03086 (python)

Fixed submission:
s = str(input())
a = 0
b = ["A", "T", "G", "C"]
c = 0
for s_ in s:    
    if s_ in b:
        c += 1
    else:
        a = max(c, a)
        c = 0
a = max(c,a)        
print(a)

Buggy submission (verdict: Runtime Error):
s = str(input())
a = []
b = ["A", "T", "G", "C"]
c = ""
for s_ in s:
    
    if s_ in b:
        c = c + s_
    else:
        a.append(c)
        c = ""
aa = [len(i) for i in a]
print(max(aa))
Problem p03096 (python)

Fixed submission:
mod = 10 ** 9 + 7
n = int(input())
c = [int(input()) for _ in range(n)]
import copy
cc = copy.deepcopy(c)
color_sum = {i: 0 for i in range(10 ** 6)}
dp = [1 for _ in range(n + 1)]
color_sum[cc[0]] = 1
for i in range(2, n + 1):
    dp[i] = dp[i - 1]
    if cc[i - 2] == cc[i - 1]:
        continue
    dp[i] += color_sum[cc[i - 1]]
    dp[i] %= mod
    color_sum[c[i - 1]] += dp[i - 1]
    color_sum[c[i - 1]] %= mod
print(dp[n])

Buggy submission (verdict: Runtime Error):
mod = 10 ** 9 + 7
import copy
cc = copy.deepcopy(c)
color_sum = {i: 0 for i in range(10 ** 6)}
dp = [1 for _ in range(n)]
color_sum[cc[0]] = 1
for i in range(1, n):
    dp[i] = dp[i - 1]
    if cc[i - 1] == cc[i]:
        continue
    dp[i] += color_sum[cc[i]]
    dp[i] %= mod
    color_sum[c[i]] += dp[i]
    color_sum[c[i]] %= mod
print(dp[n - 1])

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

import copy
cc = copy.deepcopy(c)
color_sum = {i: 0 for i in range(10 ** 6)}
dp = [1 for _ in range(n + 1)]
color_sum[cc[0]] = 1
for i in range(2, n + 1):
    dp[i] = dp[i - 1]
    if cc[i - 2] == cc[i - 1]:
        continue
    dp[i] += color_sum[cc[i - 1]]
    dp[i] %= mod
    color_sum[c[i - 1]] += dp[i - 1]
    color_sum[c[i - 1]] %= mod
print(dp[n])
Problem p03102 (python)

Fixed submission:
n, m, c = [int(i) for i in input().split(" ")]
a_list = input().split(" ")
ia = 0

for i in range(n):
    b_list = input().split(" ")
    ans = c
    for j in range(m):
        ans += int(a_list[j]) * int(b_list[j])
    if ans > 0:
        ia += 1

print(ia)

Buggy submission (verdict: Runtime Error):
n, m, c = [int(i) for i in input().split(" ")]
a_list = input()
i = 0

for i in range(n):
    b_list = input()
    ans = c
    for j in range(m):
        ans += a_list[j] * b_list[j]
    if ans > 0:
        i ++

print(i)
Problem p03131 (python)

Fixed submission:
k, a, b = map(int, input().split())
if b - a <= 2:
    print(1 + k)
else:
    if k > a:
        d = (k - a + 1) // 2
        m = (k - a + 1) % 2
        print(max(a + (b - a) * d + m, k + 1))
    else:
        print(k + 1)

Buggy submission (verdict: Runtime Error):
k, a, b = map(int, input().split())
if a >= b:
    print(1 + k)
else:
    if k > a + 1:
        print(max(a + (b - a) * ((k - (a - 1)) // 2) + ((k - (a - 1)) % 2)), k + 1)
    else:
        print(k)
Problem p03196 (python)

Fixed submission:
import collections

def prime_return(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n, p = map(int, input().split())
t = collections.Counter(prime_return(p))
ans = 1
for k, v in t.items():
    if v >= n:
        ans *= (k ** (v // n))
print(ans)

Buggy submission (verdict: Runtime Error):
n, p = map(int, input().split())
if n == 1:
    print(p)
else:
    ans = 1
    for i in range(2, int(p ** (1 / n)) + 1):
        if p % (i ** n) == 0:
            ans = i
    if ans == 1:
        if p % ((i + 1) ** n) == 0:
            ans = i + 1
    print(ans)
Problem p03206 (python)

Fixed submission:
d = int(input())

if (d ==25):
    print("Christmas")
elif (d==24):
    print("Christmas Eve")
elif (d==23):
    print("Christmas Eve Eve")
else:
    print("Christmas Eve Eve Eve")

Buggy submission (verdict: Runtime Error):
def putty(n):
    if (n == 0):
        return [1]
    return [0]+putty(n-1)+[1]+putty(n-1)+[0]

n, x = map(int, input().split())
a = putty(n)
a = a[:x]
print(sum(a))

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

if (d ==25):
    print("Christmas")
else if (d==24):
    print("Christmas Eve")
else if (d==23):
    print("Christmas Eve Eve")
else:
    print("Christmas Eve Eve Eve")
Problem p03231 (python)

Fixed submission:
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while (b != 0):
        a, b = b, a % b
    return a

n, m = map(int, input().split())
s = input()
t = input()
lcm = (n * m) // gcd(n, m)
gcd = gcd(n, m)
ans = lcm
if gcd > 1:
    for i in range(gcd):
        if s[i * (n // gcd)] != t[i * (m // gcd)]:
            ans = -1
if s[0] != t[0]:
    ans = -1
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n, m = map(int, input().split())
s = input()
t = input()
lcm = (n * m) // math.gcd(n, m)
gcd = math.gcd(n, m)
ans = lcm
if gcd > 1:
    for i in range(gcd):
        if s[i * (n // gcd)] != t[i * (m // gcd)]:
            ans = -1
print(ans)
Problem p03282 (python)

Fixed submission:
s = str(input())
k = int(input())
ans = None
for i in range(k):
    if s[i] != "1":
        ans = s[i]
        break
if ans != None:
    print(ans)
else:
    print("1")

Buggy submission (verdict: Runtime Error):
s = str(input())
k = int(input())
max_k = min(len(s), k)
for i in range(max_k+1):
    if s[i] != "1":
        ans = s[i]
        break
    else:
        ans = 1
print(ans)

Buggy submission (verdict: Runtime Error):
s = str(input())
k = int(input())
if k <= len(s):
    if s[:k] == ["1"]*k:
        ans = "1"
    else:
        ans = s[:k].replace("1", "")[0]
else:
    ans = s.replace("1", "")[0]
print(ans)

Buggy submission (verdict: Runtime Error):
s = str(input())
k = int(input())
if k <= len(s):
    if s[:k] == ["1"]*k:
        ans = "1"
    else:
        ans = s.replace("1", "")[0]
else:
    ans = s.replace("1", "")[0]
print(ans)

Buggy submission (verdict: Runtime Error):
s = str(input())
k = int(input())
if s[:k] == ["1"]*k:
    ans = "1"
else:
    ans = s[:k].replace("1", "")[0]
print(ans)

Buggy submission (verdict: Runtime Error):
s = str(input())
k = int(input())
for i in s:
    if i != "1":
        ans = i
        break
print(ans)
Problem p03352 (python)

Fixed submission:
import math
x = int(input())
t = math.floor(x ** (1/2))
a = [1]
for i in range(2, t+1):
    b = i
    while (b <= x):
        a.append(b)
        b *= i
print(max(a))

Buggy submission (verdict: Runtime Error):
x = int(input())
t = []
for b in range(2, x+1):
    c = b * b
    for p in range(2, x):
        while (c < x):
            t.append(c)
            c = c * b
print(max(t))
Problem p03380 (python)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
max_a = a[-1]
temp = a[0]
for i in a[1:-1]:
    if abs(i - max_a / 2) < abs(temp - max_a / 2):
        temp = i
print(*[max_a, temp])

Buggy submission (verdict: Runtime Error):
import bisect
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
temp = 0
for j, i in enumerate(a):
    k = bisect.bisect_left(a[:j], (i / 2) + 1) - 1
    if (i - a[k]) > 0:
        if math.factorial(i) // (math.factorial(a[k]) * (math.factorial(i - a[k]))) > temp:
            ans = [i, a[k]]
print(*ans)
Problem p03407 (python)

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

Buggy submission (verdict: Runtime Error):
import copy
n = int(input())
red = []
blue = []
for _ in range(n):
    a, b = map(int, input().split())
    red.append([a, b])
for _ in range(n):
    c, d = map(int, input().split())
    blue.append([c, d])

red_list = copy.copy(red)
blue_list = copy.copy(blue)
    
red_list.sort()
blue_list.sort()
count = 0
for i in range(n):
    a, b = red_list.pop(0)
    for j in range(len(blue_list)):
        if (a < blue_list[j][0]) & (b < blue_list[j][1]):
            count += 1
            blue_list.pop(j)
            break

red_list = copy.copy(red)
blue_list = copy.copy(blue)
    
red_list.sort(key=lambda x: x[1])
blue_list.sort(key=lambda x: x[1])
count1 = 0
for i in range(n):
    a, b = red_list.pop(0)
    for j in range(len(blue_list)):
        if (a < blue_list[j][0]) & (b < blue_list[j][1]):
            count1 += 1
            blue_list.pop(j)
            break            

ans = max(count, count1)        
print(ans)
Problem p03408 (python)

Fixed submission:
import collections
n = int(input())
s = []
for _ in range(n):
    s.append(input())
m = int(input())
t = []
for _ in range(m):
    t.append(input())
s_ = collections.Counter(s)
t_ = collections.Counter(t)
a = []
for key in s_.keys():
    num = s_[key] - t_[key]
    a.append(num)
print(max(max(a),0))

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
s = []
for _ in range(n):
    s.append(input())
m = int(input())
t = []
for _ in range(m):
    t.append(input())
s_ = collections.Counter(s)
t_ = collections.Counter(t)
a = []
for key in s_.keys():
    num = s_[key] - t_[key]
    a.append(num)
print(max(a, 0))
Problem p03409 (python)

Fixed submission:
n = int(input())
red = []
blue = []
for _ in range(n):
    a, b = map(int, input().split())
    red.append([a, b])
for _ in range(n):
    c, d = map(int, input().split())
    blue.append([c, d])
blue.sort()
red.sort(key=lambda x: x[1], reverse=True)
ans = 0
for b in blue:
    for i, r in enumerate(red):
        if (r[0] < b[0]) & (r[1] < b[1]):
            ans += 1
            red.pop(i)
            break
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
red = []
blue = []
for _ in range(n):
    a, b = map(int, input().split())
    red.append([a, b])
for _ in range(n):
    c, d = map(int, input().split())
    blue.append([c, d])
red.sort()
b.sort()
count = 0
for i in range(n):
    a, b = red.pop(0)
    for j in range(len(blue)):
        if (a < blue[j][0]) & (b < blue[j][1]):
            count += 1
            blue.pop(j)
            break