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

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

N = int(input())
XY = [list(map(int, input().split())) + [i + 1] for i in range(N)]

dist = []

XY.sort()
for i in range(N - 1):
  dist.append((abs(XY[i][0] - XY[i + 1][0]), (XY[i][2], XY[i + 1][2])))
XY.sort(key = lambda x: x[1])
for i in range(N - 1):
  dist.append((abs(XY[i][1] - XY[i + 1][1]), (XY[i][2], XY[i + 1][2])))
dist.sort()

root = [i for i in range(N + 1)]
comp_size = [1] * (N+1)
 
def root_find(x):
  y = root[x]
  if x == y:
    return x
  else:
    z = root_find(y)
    root[x] = z
    return z

def merge(x, y):
  rx = root_find(x)
  ry = root_find(y)
  sx = comp_size[rx]
  sy = comp_size[ry]
  if rx != ry:
    if sx >= sy:
      root[ry] = rx
      comp_size[rx] = sx + sy
    else:
      root[rx] = ry
      comp_size[ry] = sx + sy
      
answer = 0
for d, (a, b) in dist:
  if root_find(a) != root_find(b):
    merge(a, b)
    answer += d

print(answer)

Buggy submission (verdict: Runtime Error):
import heapq

print(1)

N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
X = []
Y = []
for x, y in XY:
  X.append((x, i + 1))
  Y.append((y, i + 1))
    
X.sort()
Y.sort()
 
graph = [[] for _ in range(N + 1)]
 
for i in range(N - 1):
  x1, a = X[i]
  x2, b = X[i + 1]
  graph[a].append((abs(x1 - x2), b))
  graph[b].append((abs(x1 - x2), a))
  y1, a = Y[i]
  y2, b = Y[i + 1]
  graph[a].append((abs(y1 - y2), b))
  graph[b].append((abs(y1 - y2), a))
    
check = [0] * (N + 1)
stack = []
heapq.heapify(stack)
for w, g in graph[1]:
  heapq.heappush(stack, (w, g))

check[1] = 1
answer = 0
cnt = 0

while cnt < N - 1:
  v, s = heapq.heappop(stack)
  if check[s] == 0:
    check[s] = 1
    answer += v
    cnt += v
    for w, g in graph[s]:
      if check[g] == 0:
        heapq.heappush(stack, (w, g))

print(answer)
Problem p03693 (python)

Fixed submission:
a,b,c=input().split()
print("YES" if int(a+b+c)%4==0 else "NO")

Buggy submission (verdict: Runtime Error):
print(int(input().replace(" ","",3))
Problem p03777 (python)

Fixed submission:
a,b=input().split()
if a==b:
  print("H")
else:
  print("D")

Buggy submission (verdict: Runtime Error):
a,b=map(input().split())
if a==b:
  print("H")
else:
  print("D")
Problem p03880 (python)

Fixed submission:
import math

N=int(input())
A=[int(input()) for _ in range(N)]
#print(A)

B=0
for a in A:
  B^=a

C=[]
D=[0]*100
for a in A:
  C.append(bin(a^(a-1))[2:])
#print(C)
for c in C:
  D[len(c)]=1
#print(D)

ans=0
while B:
  #print(B,bin(B))
  if D[len(bin(B)[2:])]:
    B^=2**len(bin(B)[2:])-1
    ans+=1
  else:
    ans=-1
    break
print(ans)

Buggy submission (verdict: Runtime Error):
import math

N=int(input())
A=[int(input()) for _ in range(N)]
#print(A)

B=0
for a in A:
  B^=a

C=[]
D=[0]*30
for a in A:
  C.append(bin(a^(a-1))[2:])
#print(C)
for c in C:
  D[len(c)]=1
#print(D)

ans=0
while B:
  #print(B,bin(B))
  if D[len(bin(B)[2:])]:
    B^=2**len(bin(B)[2:])-1
    ans+=1
  else:
    ans=-1
    break
print(ans)
Problem p03937 (python)

Fixed submission:
H,W=map(int,input().split())
A=[]
for i in range(H):
  A.append(input())
#print(A)

sw=0
for i in range(H):
  tmp=0
  for j in range(W-1):
    if A[i][j]=="#" and A[i][j+1]==".":
      tmp=1
    if tmp==1 and A[i][j]=="." and A[i][j+1]=="#":
      sw=1
#print(sw)

if sw==1:
  print("Impossible")
else:
  l=[]
  r=[]
  for i in range(H):
    ll=0
    for j in range(W-1):
      if A[i][j]=="." and A[i][j+1]=="#":
        ll=j+1
        break
    l.append(ll)
    
    rr=W-1
    for j in range(W-1):
      if A[i][j]=="#" and A[i][j+1]==".":
        rr=j
        break
    r.append(rr)
#  print(l)
#  print(r)

  sw2=0
  for i in range(len(r)-1):
    if r[i]!=l[i+1]:
      sw2=1
  print("Impossible" if sw2==1 else "Possible")

Buggy submission (verdict: Runtime Error):
a
Problem p03957 (python)

Fixed submission:
S=input()
N=len(S)

if "C" in S and "F" in S:
  c=S.index("C")
  S=S[::-1]
  f=N-S.index("F")-1
  #print(c,f)
  print("Yes" if c<f else "No")
else: 
  print("No")

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

if "C" in S and "F" in S:
  print("No")
else:
  c=S.index("C")
  S=S[::-1]
  f=N-S.index("F")-1
  #print(c,f)
  print("Yes" if c<f else "No")

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

c=S.index("C")
S=S[::-1]
f=N-S.index("F")-1
#print(c,f)

print("Yes" if c<f else "No")

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

c=S.index("C")
S=S[::-1]
f=N-S.index("F")-1
#print(c,f)

print("Yes" if c<f else "No")
Problem p03962 (python)

Fixed submission:
a=list(input().split())
print(len(set(a)))

Buggy submission (verdict: Runtime Error):
a=set(list(input.split()))
print(len(list(a)))

Buggy submission (verdict: Runtime Error):
a=set(list(input.split()))
print(len(a))

Buggy submission (verdict: Runtime Error):
a=set(input.split())
print(len(a))
Problem p03963 (python)

Fixed submission:
n,k=map(int,input().split())
print(k*((k-1)**(n-1)))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
print(k*((k-1)**(n-1))
Problem p04030 (python)

Fixed submission:
import collections

S=input()
N=len(S)
D=collections.deque([])

for i in range(N):
  if S[i]=="B":
    if len(D):
      D.pop()
  else:
    D.append(S[i])
print("".join(list(D)))

Buggy submission (verdict: Runtime Error):
import collections

S=input()
N=len(S)
D=collections.deque([])

for i in range(N):
  if S[i]=="B":
    D.pop()
  else:
    D.append(S[i])
    
print("".join(list(D)))
Problem p04044 (python)

Fixed submission:
N,L=map(int,input().split())
S=[input() for _ in range(N)]
S.sort()
print("".join(S))

Buggy submission (verdict: Runtime Error):
N,L=map(int,input())
S=[input() for _ in range(N)]
S.sort()
print("".join(S))
Problem p03777 (python)

Fixed submission:
res = {
  ('H', 'H'): 'H',
  ('H', 'D'): 'D',
  ('D', 'H'): 'D',
  ('D', 'D'): 'H'
}
print(res[tuple(input().split())])

Buggy submission (verdict: Runtime Error):
w, a, b = list(map(int, input().split()))
if b > (a + w):
  print(b - (a + w))
else:
  print(0)
Problem p02553 (python)

Fixed submission:
inputs = input().split(" ")
a = int(inputs[0])
b = int(inputs[1])
c = int(inputs[2])
d = int(inputs[3])

values = [a*c, a*d, b*c, b*d]
print(max(values))

Buggy submission (verdict: Runtime Error):
values = [a*c, a*d, b*c, b*d]
print(max(values))
Problem p02718 (python)

Fixed submission:
n, m = map(int, input().split())

a = list(map(int, input().split()))

s = sum(a)

a.sort(reverse=True)

if a[m - 1] >= s / (4*m):
    print("Yes")
else:
    print("No")

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

a = list(map(int, input().split()))

s = sum(a)

a.sort()

if a[m - 1] * a * m >= s:
    print("Yes")
else:
    print("No")
Problem p02630 (python)

Fixed submission:
from collections import Counter
n = int(input())
ar = list(map(int, input().split()))

t = int(input())
c = Counter(ar)
s = sum(ar)
for i in range(t):
    a, b = list(map(int, input().split()))
    if b in c:
        c[b] += c[a]
    else:
        c[b] = c[a]
    s += ((b-a)*c[a])
    print(s)
    c[a] = 0

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()
#define INF (int)1e9
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef map<int, int> MPII;
typedef set<int> SETI;

const int mxN = 2e5;
int a[mxN];

int sum(vector<int> v)
{
    int s = 0;
    for (int i = 0; i < v.size(); ++i)
    {
        s += v[i];
    }
    return s;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    vi v(n);
    for (auto &x : v)
        cin >> x;

    int t;
    cin >> t;

    int s = sum(v);
    map<int, int> m;
    for (auto x : v)
        if (m.find(x) != m.end())
            m[x] += 1;
        else
            m[x] = 1;
    while (t--)
    {
        int b, c;
        cin >> b >> c;
        if (m.find(c) != m.end())
            m[c] += m[b];
        else
            m[c] = m[b];
        s += ((c - b) * m[b]);
        m[b] = 0;
        cout << s << "\n";
    }

    return 0;
}
Problem p04011 (python)

Fixed submission:
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N > K:
  print(K*X + (N-K)*Y)
else :
  print(N*X)

Buggy submission (verdict: Runtime Error):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N > K:
  print(K*X + (N-K)*Y)
else :
  print(N*
Problem p02553 (python)

Fixed submission:
abcd=input().split()
a=int(abcd[0])
b=int(abcd[1])
c=int(abcd[2])
d=int(abcd[3])
print(max(a*c,a*d,b*c,b*d))

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
print(max(a*c,a*d,b*c,b*d))
Problem p02741 (python)

Fixed submission:
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input()) - 1
print(L[K])

Buggy submission (verdict: Runtime Error):
import math
a, b,c = map(float, input().split())
if c - a - b > 0 or 4*a*b < (c - a - b)**2:
    print("Yes")
else:
    print("No")
Problem p02743 (python)

Fixed submission:
a, b,c = map(int, input().split())
if (0 < c - a - b) and (4*a*b < (c - a - b)*(c - a - b)):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import math
a, b,c = map(int, input().split())
if (c - a - b > 0) and (4*a*b < int(math.pow((c - a - b)), 2)):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import math
a, b,c = map(float, input().split())
if c - a - b > 0 or 4*a*b < (c - a - b)**2
    print("Yes")
else:
    print("No")
Problem p02761 (python)

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

condition = set()
for i in range(M):
    s, c = map(int, input().split())
    condition.add((s, c))

ans = float("inf")
if N == 1:
    for i in range(10):
        num = str(i)
        for s, c in condition:
            if num[s-1] != str(c):
                break
        else:
            print(i)
            exit()       

for i in range(10**(N-1), 10**N):
    num = str(i)
    for s, c in condition:
        if num[s-1] != str(c):
            break
    else:
        print(i)
        exit()
print(-1)

Buggy submission (verdict: Runtime Error):
import sys

N, M = map(int, input().split())
SC = list()
for i in range(M):
    s, c = map(int, input().split())
    SC.append([s, c])

SSC = sorted(SC, key=lambda x: x[0])

ansL = [list(filter(lambda x:x[0]==1, SSC)), list(filter(lambda x:x[0]==12, SSC)), list(filter(lambda x:x[0]==3, SSC)),]

for L in ansL:
    if L == []:
        continue
    else:
        for l in L:
            if L[0][1] != l[1]:
                print("-1")
                sys.eixt()

ans = ""
for l in ansL:
    if l == []:
        ans += str(0)
    else:
        ans += str(min([x[1] for x in l]))

if ans[0] == "0":
    print(-1)
    sys.exit()
print(ans)
Problem p02802 (python)

Fixed submission:
N, M = map(int, input().split())
ac = 0
wa = 0
mp = [0]*N
for _ in range(M):
    p, S = input().split()
    p = int(p) - 1
    if S == "AC":
        if mp[p] != "AC":
            ac += 1
            wa += mp[p]
            mp[p] = "AC"
    else:
        if mp[p] != "AC":
            mp[p] += 1
print(ac, wa)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
N, M = map(int, input().split())
d = defaultdict(lambda : "WA")
correct = 0
incorrect = 0
for _ in range(M):
    p, S = input().split()
    if d[p] == "WA":
        if S == "WA":
            incorrect += 1
            print(p, "WA", d)
        else:
            correct += 1
            d[p] = "AC"
            print(p, "AC", d)
print(correct, incorrect)
Problem p02865 (python)

Fixed submission:
print((int(input())-1)//2)

Buggy submission (verdict: Runtime Error):
import sys

N = int(input())
D = list(sorted(list(map(int, input().split()))))

check = 0
if not check == D[0]:
    print(0)
    sys.exit()
countl = [0]
for d in D:
    if not check == d:
        check += 1
        countl.append(0)
        if not check == d:
            print(0)
            sys.exit()
    countl[-1] += 1
if not countl[0] == 1:
    print(0)
    sys.exit()

ans = 1
for i in range(len(countl) - 1):
    ans *= pow(countl[i], countl[i + 1], 998244353)
print(ans % 998244353)
Problem p03001 (python)

Fixed submission:
W, H, x, y = map(int, input().split())
print(W*H/2, int((x+x==W and y+y==H)))

Buggy submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())

ans = 0
if x*H == W*y:
    ans = 1
    print(x*H, ans)
    exit()
S = max(min(H*x, H*(W-x)), min(W*y, W*(H-y)))

xp = x*H/y
yp = y*W/x

if xp <= W:
    if S <= xp*H/2:
        S = xp*H/2
        ans = 1
if yp <= H:
    if S <= yp*W/2:
        S = yp*W/2
        ans = 1

print(S, ans)

Buggy submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())

ans = 0
if x*H == W*y:
    ans = 1
    print(x*H, ans)
    exit()
S = max(min(H*x, H*(W-x)), min(W*y, W*(H-y)))

xp = (x/y)*H
yp = (y/x)*W

if xp <= W:
    if S <= xp*H/2:
        S = xp*H/2
        ans = 1
if yp <= H:
    if S <= yp*W/2:
        S = yp*W/2
        ans = 1

print(S, ans)
Problem p02558 (python)

Fixed submission:
from typing import Set


class UnionFind:
    """Union-Find: O(α(N))"""

    __slots__ = ["_data_size", "_first_idx", "_parents"]

    def __init__(self, data_size: int, is_zero_origin: bool = True) -> None:
        self._data_size = data_size
        self._first_idx = 0 if is_zero_origin else 1
        self._parents = [-1] * (data_size + self._first_idx)

    def __getitem__(self, x: int) -> int:
        """Find the group (root) of vertex x."""
        if self._parents[x] < 0:
            return x
        self._parents[x] = self[self._parents[x]]
        return self._parents[x]

    def __len__(self) -> int:
        """Count the number of groups (roots)."""
        return len(self.groups)

    @property
    def groups(self) -> Set[int]:
        """Return the set of groups (roots)."""
        return {
            self[x] for x in range(self._first_idx, self._data_size + self._first_idx)
        }

    def is_connected(self, x: int, y: int) -> bool:
        """Return whether two vertices x and y are connected or not."""
        return self[x] == self[y]

    def unite(self, x: int, y: int) -> None:
        """Unite two groups of vertices x and y."""
        x, y = self[x], self[y]
        if x == y:
            return
        if self._parents[x] > self._parents[y]:
            x, y = y, x
        self._parents[x] += self._parents[y]
        self._parents[y] = x

    def unite_all(self, *vertices: int) -> None:
        """Unite the groups of all of the given vertices."""
        x = vertices[0]
        for y in vertices[1:]:
            self.unite(x, y)

    def get_size(self, x: int) -> int:
        """Return the size of the group vertex x belongs."""
        return -self._parents[self[x]]


def unionfind():
    # https://judge.yosupo.jp/problem/unionfind
    N, Q, *TUV = map(int, open(0).read().split())
    tree = UnionFind(N)
    res = []
    for t, u, v in zip(*[iter(TUV)] * 3):
        if t:
            res.append(int(tree.is_connected(u, v)))
        else:
            tree.unite(u, v)
    print("\n".join(map(str, res)))


if __name__ == "__main__":
    unionfind()

Buggy submission (verdict: Runtime Error):
class UnionFind:
    __slots__ = ["_data_size", "_roots"]

    def __init__(self, data_size: int) -> None:
        self._data_size = data_size
        self._roots = [-1] * data_size

    def __getitem__(self, x: int) -> int:
        while self._roots[x] >= 0:
            x = self._roots[x]
        return x

    def is_connected(self, x: int, y: int) -> bool:
        return self[x] == self[y]

    def unite(self, x: int, y: int) -> None:
        x, y = self[x], self[y]
        if x == y:
            return
        if self._roots[x] > self._roots[y]:
            x, y = y, x
        self._roots[x] += self._roots[y]
        self._roots[y] = x


import sys

read = sys.stdin.read

N, _, *X = map(int, readline().split())
tree = UnionFind(N)
res = []
for t, u, v in zip(*[iter(X)] * 3):
    if t:
        res.append(int(tree.is_connected(u, v)))
    else:
        tree.unite(u, v)
print("\n".join(map(str, res)))
Problem p02681 (python)

Fixed submission:
# A - Registration
def main():
    S, T = open(0).read().split()
    print("Yes" if T[:-1] == S else "No")


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# A - Registration
def main():
    S, T = map(int, open(0).read().split())
    print("Yes" if T[:-1] == S else "No")


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# A - Registration
def main():
    S, T = input().rstrip().split()
    print("Yes" if T[:-1] == S else "No")


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

Fixed submission:
# E - Yutori


def find_workdays(
    total_days: int, workdays_length: int, days_off_length: int, schedule: list
) -> list:
    if days_off_length == 0:
        workdays = [i for i, can_work in enumerate(schedule, 1) if can_work]
        return workdays if len(workdays) <= workdays_length else []

    workdays_left, workdays_right = set(), set()

    cur_days_off = 0
    for i, can_work in enumerate(schedule, 1):
        if cur_days_off:
            cur_days_off -= 1
            continue
        if can_work:
            workdays_left.add(i)
            cur_days_off = days_off_length
            if len(workdays_left) == workdays_length:
                break

    cur_days_off = 0
    for i, can_work in enumerate(schedule[::-1]):
        if cur_days_off:
            cur_days_off -= 1
            continue
        if can_work:
            workdays_right.add(total_days - i)
            cur_days_off = days_off_length
            if len(workdays_right) == workdays_length:
                break

    return sorted(workdays_left & workdays_right)


def main():
    N, K, C = map(int, input().split())
    S = input().rstrip()
    workdays = find_workdays(N, K, C, [s == "o" for s in S])
    print("\n".join(map(str, workdays)))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# E - Yutori
from typing import List


def find_workdays(
    total_days: int, workdays_length: int, days_off_length: int, schedule: List[bool]
) -> List[int]:
    if days_off_length == 0:
        workdays = [i for i, can_work in enumerate(schedule, 1) if can_work]
        return workdays if len(workdays) <= workdays_length else []

    workdays_left, workdays_right = [], []

    for workdays, gen in [
        (workdays_left, enumerate(schedule, 1)),
        (workdays_right, ((total_days - i, x) for i, x in enumerate(schedule[::-1]))),
    ]:
        days_off = 0
        for i, can_work in gen:
            if days_off:
                days_off -= 1
                continue
            if can_work:
                workdays.append(i)
                days_off = days_off_length
                if len(workdays) == workdays_length:
                    break

    return [l for l, r in zip(workdays_left, workdays_right[::-1]) if l == r]


def main():
    N, K, C = map(int, input().split())
    S = input().rstrip()
    workdays = find_workdays(N, K, C, [s == "o" for s in S])
    print("\n".join(map(str, workdays)))


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

Fixed submission:
# B - Bingo
def is_winnable(player: int) -> bool:
    winnable_conditions = \
        {0b111000000, 0b000111000, 0b000000111, 0b100100100, 0b010010010, 0b001001001, 0b100010001, 0b001010100}
    return any(player & condition == condition for condition in winnable_conditions)


def main():
    *ANB, = map(int, open(0).read().split())
    A, B = ANB[:9], set(ANB[10:])
    player = 0b000000000
    for i, a in enumerate(A):
        if a in B:
            player |= 1 << i
    print("Yes" if is_winnable(player) else "No")


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
/* 
 * Created by solzard on 2020-03-05.
 * 
 */
#include <iostream>
#include <vector>
#include <unordered_set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

bool is_bingo(int player) {
  std::unordered_set<int> winnable_conditions
      {0b111000000, 0b000111000, 0b000000111, 0b100100100, 0b010010010, 0b001001001, 0b100010001, 0b001010100};
  for (const auto &condition : winnable_conditions) {
    if ((player & condition) == condition) return true;
  }
  return false;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);

  std::vector<int> sheet;
  std::unordered_set<int> bingo;
  int a, n, b;
  rep(_, 9) {
    std::cin >> a;
    sheet.emplace_back(a);
  }
  std::cin >> n;
  rep(_, n) {
    std::cin >> b;
    bingo.emplace(b);
  }
  int player = 0;
  rep(i, 9) {
    if (bingo.find(sheet[i]) != bingo.end()) {
      player |= 1 << i;
    }
  }
  std::cout << (is_bingo(player) ? "Yes" : "No") << "\n";
}

Buggy submission (verdict: Runtime Error):
/* 
 * Created by solzard on 2020-03-05.
 * 
 */
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

bool is_bingo(int player) {
  std::unordered_set<int> winnable_conditions
      {0b111000000, 0b000111000, 0b000000111, 0b100100100, 0b010010010, 0b001001001, 0b100010001, 0b001010100};
  for (const auto &condition : winnable_conditions) {
    if ((player & condition) == condition) return true;
  }
  return false;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);

  std::vector<int> sheet;
  std::unordered_set<int> bingo;
  int a, n, b;
  rep(_, 9) {
    std::cin >> a;
    sheet.emplace_back(a);
  }
  std::cin >> n;
  rep(_, n) {
    std::cin >> b;
    bingo.emplace(b);
  }
  int player = 0;
  rep(i, 9) {
    if (bingo.find(sheet[i]) != std::end(bingo)) {
      player |= 1 << i;
    }
  }
  std::cout << (is_bingo(player) ? "Yes" : "No") << "\n";
}
Problem p02761 (python)

Fixed submission:
# C - Guess The Number
def guess_number(N: int, conditions: list) -> int:
    if N > 1 and any(cond == (1, 0) for cond in conditions):  # 1st digit mustn't be 0 if N > 1
        return -1
    result = [-1] * N
    for digit, num in conditions:
        if result[-digit] >= 0 and result[-digit] != num:
            return -1
        result[-digit] = num
    if result[-1] == -1:  # 1st digit must be 1 if N > 1 (no leading zeros)
        result[-1] = 1 if N > 1 else 0
    return sum(x * (10 ** i) if x != -1 else 0 for i, x in enumerate(result))


def main():
    N, M, *SC = map(int, open(0).read().split())
    conditions = list(zip(*[iter(SC)] * 2))
    ans = guess_number(N, conditions)
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# C - Guess The Number
def guess_number(N: int, M: int, conditions: list) -> int:
    if N == 1:
        digit, num = conditions[0]
        if len(set(conditions)) == 1 and digit == 1:
            return num
        return -1

    if any(cond == (1, 0) for cond in conditions):  # 1st digit mustn't be 0
        return -1

    result = [0] * N
    for digit, num in conditions:
        if result[-digit] not in (0, num):
            return -1
        result[-digit] = num
    return sum(x * (10 ** i) for i, x in enumerate(result))


def main():
    N, M, *SC = map(int, open(0).read().split())
    conditions = list(zip(*[iter(SC)] * 2))
    ans = guess_number(N, M, conditions)
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# C - Guess The Number
def guess_number(N: int, M: int, conditions: list) -> int:
    if N == 1:
        digit, num = conditions[0]
        if M != 1 or digit != 1:
            return -1
        return num

    if any(cond == (1, 0) for cond in conditions):  # 1st digit mustn't be 0
        return -1

    result = [0] * N
    for digit, num in conditions:
        if result[-digit] not in (0, num):
            return -1
        result[-digit] = num
    return sum(x * (10 ** i) for i, x in enumerate(result))


def main():
    N, M, *SC = map(int, open(0).read().split())
    conditions = list(zip(*[iter(SC)] * 2))
    ans = guess_number(N, M, conditions)
    print(ans)


if __name__ == "__main__":
    main()