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

Fixed submission:

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

A.sort()

CB = []
for i in range(M):
    B, C = map(int, input().split())
    CB.append([C, B])
    
CB.sort(reverse=True)

idx = 0
c = 0
for i in range(N):
    if A[i] < CB[idx][0]:
        A[i] = CB[idx][0]
        c += 1
    if CB[idx][1] <= c:
        idx += 1
        c = 0
    if idx >= M:
        break
    #print(A)
        
print(sum(A))

Buggy submission (verdict: Runtime Error):
import bisect
A.sort()
A = [-1] + A
for i in range(M):
    b, c = map(int, input().split())
    idx = bisect.bisect_left(A, c)
    #print(A[:idx], A[idx:])
    A = A[:idx] + [c] * b + A[idx:]
    A = A[-N:]
    #print(A)
print(sum(A))
Problem p03104 (python)

Fixed submission:

A, B = map(int, input().split())

A -= 1

if (A+1) % 2 == 0:
    a = (A+1) // 2 % 2
else:
    a = (A // 2 % 2) ^ A

if (B+1) % 2 == 0:
    b = (B+1) // 2 % 2
else:
    b = (B // 2 % 2) ^ B
    
#print(a, b)
print(a ^ b)

Buggy submission (verdict: Runtime Error):

A, B = map(int, input().split())

a = bin(A)[2:].zfill(len(bin(B))-2)
b = bin(B)[2:]
#print(a, b)

import math

MAX = math.floor(math.log2(B)) + 1
#print("二進数の桁数の最大値", MAX)

c = [0] * (MAX+1)

for i in range(1, MAX):
    #print("桁", 2**i)
    ma = B//(2**i) * (2**i)
    mi = A//(2**i) * (2**i) + (2**i)
    #print(ma, mi)
    sum = int(a[-(i+1)]) * (mi - A) + int(b[-(i+1)]) * (B+1 - ma)
    #print(sum, sum % 2)
    c[-(i+1)] = sum % 2
    
a = (A+1)//2 if A % 2 == 1 else (A+2)//2
b = (B+1)//2 if B % 2 == 1 else B//2
    
c[-1] = (b-(a-1)) % 2

#print(c)
print(int("".join(map(str, c)), 2))

Buggy submission (verdict: Runtime Error):

A, B = map(int, input().split())

a = bin(A)[2:].zfill(len(bin(B))-2)
b = bin(B)[2:]
#print(a, b)

import math

MAX = math.floor(math.log2(B)) + 1
#print("二進数の桁数の最大値", MAX)

c = [0] * (MAX+1)

for i in range(1, MAX):
    #print("桁", 2**i)
    ma = B//(2**i) * (2**i)
    mi = A//(2**i) * (2**i) + (2**i)
    #print(ma, mi)
    sum = int(a[-(i+1)]) * (mi - A) + int(b[-(i+1)]) * (B+1 - ma)
    #print(sum, sum % 2)
    c[-(i+1)] = sum % 2
    
c[-1] = (A % 2 + (B-A) // 2 % 2) % 2

#print(c)
print(int("".join(map(str, c)), 2))
Problem p02763 (python)

Fixed submission:
import math
import collections

N = int(input())
S = input()

S = list(S)
def bit_add(A,a,w): #リストAのa番目にwを足す
    ind = a

    while len(A) > ind:
        A[ind] += w
        lsb = ind & (-ind)
        # print(ind)
        ind += lsb

    return

def bit_sum(A, a):  # リストAのa番目までの和を取る
    s = 0
    ind = a
    while ind != 0:
        s += A[ind]
        lsb = ind & (-ind)
        ind -= lsb

    return s
# cs = set(list(S))
li = {}
for c in "abcdefghijklmnopqrstuvwxyz":
    li[c] = [0] * (N + 1)

for i in range(1,N + 1):
    char = S[i - 1]
    bit_add(li[char],i,1)

# li → 1 スタート
# S → 0スタート
Q = int(input())
queries = [input().split() for _ in range(Q)]
for query in queries:
    a,b,c = query
    a = int(a)
    b = int(b)
    if a == 1: # 書き換え
        i = b

        c_org = S[i - 1] # 元の文字
        # li[c_org][i] -= 1
        S[i - 1] = c
        bit_add(li[c_org], i,  -1)#元の文字をbiマイナス
        bit_add(li[c], i, 1) #新たな文字をbiプラス

    if a == 2:
        ans = 0
        l = b
        r = int(c)
        for c in "abcdefghijklmnopqrstuvwxyz":
            temp = li[c]
            r_sum = bit_sum(temp,r)
            l_sum = bit_sum(temp,l - 1)
            diff = r_sum-l_sum
            if diff > 0: # ある文字
                ans += 1
        print(ans)

Buggy submission (verdict: Runtime Error):
import math
import collections

N = int(input())
S = input()


def bit_add(A,a,w): #リストAのa番目にwを足す
    ind = a

    while len(A) > ind:
        A[ind] += w
        lsb = ind & (-ind)
        # print(ind)
        ind += lsb

    return

def bit_sum(A, a):  # リストAのa番目までの和を取る
    s = 0
    ind = a
    while ind != 0:
        s += A[ind]
        lsb = ind & (-ind)
        ind -= lsb

    return s
# cs = set(list(S))
li = {}
for c in "abcdefghijklmnopqrstuvwxyz":
    li[c] = [0] * (N + 1)

for i in range(1,N + 1):
    char = S[i - 1]
    bit_add(li[char],i,1)

# li → 1 スタート
# S → 0スタート
Q = int(input())
queries = [input().split() for _ in range(Q)]
for query in queries:
    a,b,c = query
    a = int(a)
    b = int(b)
    if a == 1: # 書き換え
        i = b

        c_org = S[i - 1] # 元の文字
        # li[c_org][i] -= 1
        S[i - 1] = c
        bit_add(li[c_org], i,  -1)#元の文字をbiマイナス
        bit_add(li[c], i, 1) #新たな文字をbiプラス

    if a == 2:
        ans = 0
        l = b
        r = int(c)
        for c in "abcdefghijklmnopqrstuvwxyz":
            temp = li[c]
            r_sum = bit_sum(temp,r)
            l_sum = bit_sum(temp,l - 1)
            diff = r_sum-l_sum
            if diff > 0: # ある文字
                ans += 1
        print(ans)
Problem p02880 (python)

Fixed submission:
n = int(input())
for i in range(1,10):
  for j in range(1,10):
    if i * j == n:
      print("Yes")
      exit(0)
print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
for i in range(1,10):
  for j in range(1,10):
    if i * j == n:
      print("Yes")
      exit(1)
print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
for i in range(1,10):
  fof j in range(1,10):
    if i * j == n:
      print("Yes")
      exit(0)
print("No")
Problem p02891 (python)

Fixed submission:
S = input()
K = int(input())
cot = 0
before = ""
seq = []


for i in range(len(S)):
    c = S[i]
    if cot == 0:
        cot += 1
        before =c
    else:
        if c == before:
            cot += 1
        else:
            before = c
            seq.append(cot)
            cot = 1

seq.append(cot)
ans = 0
for temp in seq: #素の状態で連続してる文字列
    ans +=temp//2
ans *= K
if S[0] == S[-1]: #頭と尾で一緒→つなげたときに長い連続区間が発生
    ans += (seq[0] + seq[-1]) //2 * (K - 1) - (seq[0] //2 + seq[-1]//2 )* (K - 1)
if len(seq) == 1:
    ans = min(ans,seq[0] * K //2)
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
cot = 0
before = ""
seq = []

if len(S) == 1:
    ans = len(K)//2
else:
    for i in range(len(S)):
        c = S[i]
        if cot == 0:
            cot += 1
            before =c
        else:
            if c == before:
                cot += 1
            else:
                before = c
                seq.append(cot)
                cot = 1

    seq.append(cot)
    ans = 0
    for temp in seq:
        ans +=temp//2
    ans *= K
    if S[0] == S[-1]:
        ans += (seq[0] + seq[-1]) * (K - 1) //2 - (seq[0] //2 + seq[-1]//2 )* (K - 1)
print(ans)
Problem p02897 (python)

Fixed submission:
n =int(input())
ans =0

for i in range(1,n+1):
  if i%2== 1:
    ans+= 1
print(ans/ n)

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

for i in range(1,n+1):
  if i%2= 1:
    ans+= 1
print(ans/ n)

Buggy submission (verdict: Runtime Error):
n =int(input())
cot =0

for i in range(1,n+1):
  if i%2= 1:
    ans+= 1
print(ans/ n)
Problem p03053 (python)

Fixed submission:
from collections import deque
import sys
from collections import defaultdict
import copy
# input = sys.stdin.readline



H, W = map(int, input().split())
C = [list(input()) for _ in range(H)]
gone = [[0] * W for _ in range(H)]
cot = 0
que = deque()

que_count = 0
for h in range(H):
    for w in range(W):
        if C[h][w] == "#":
            gone[h][w] = 1
            que.append((h,w))
            que_count += 1
            cot += 1
INF = 10 ** 9
go = [[1, 0], [0, 1], [-1, 0], [0, -1]]
ans  = 0
nq = 0
while cot != H*W:
    while que_count != 0 and cot != H*W:
        h,w = que.popleft()
        que_count -= 1

        for temp in go:
            # この時，実際に行くのかは不明
            gx,gy = temp
            nx = w + gx
            ny = h + gy

            if 0<= nx < W and 0<= ny < H and gone[ny][nx] != 1: #行って無かったら，行く
                # この時に実際に移動する
                gone[ny][nx] = 1
                que.append( (ny,nx))
                nq += 1
                cot += 1
    que_count = nq
    nq = 0
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys
from collections import defaultdict
import copy
import numpy as np
# input = sys.stdin.readline



H, W = map(int, input().split())
C = [list(input()) for _ in range(H)]
gone = np.zeros((H,W))
cot = 0
que = deque()
next_que =  deque()

for h in range(H):
    for w in range(W):
        if C[h][w] == "#":
            gone[h][w] = 1
            next_que.append((h,w))
            cot += 1
INF = 10 ** 9
go = [[1, 0], [0, 1], [-1, 0], [0, -1]]
ans  = 0
que = next_que
while cot != H*W:
    que = copy.deepcopy(next_que)
    next_que = deque()
    while que:
        h,w = que.popleft()
        for temp in go:
            gx,gy = temp
            nx = w + gx
            ny = h + gy
            if 0<= nx < W and 0<= ny < H and gone[ny][nx] != 1: #行って無かったら，行く
                gone[ny][nx] = 1
                next_que.append( (ny,nx))
                cot += 1
    ans += 1
print(ans)
Problem p03253 (python)

Fixed submission:
import math
N,M = list(map(int,input().split(" ")))
MOD = 10 ** 9 + 7
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans = 1
fac = factorize(M)
for temp in fac:
    num = temp[1]
    ans *= combinations_count(num + N - 1,N-1)
    ans %= MOD
print(ans)

Buggy submission (verdict: Runtime Error):
import math
N,M = list(map(int,input().split(" ")))
MOD = 10 ** 9 + 7
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n;

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k]) % X

    return result % X

ans = 1
fac = factorize(M)
for temp in fac:
    num = temp[1]
    ans *= cmb(num + N - 1,num)
    ans %= MOD
print(ans)
Problem p03806 (python)

Fixed submission:


import math
N,Ma,Mb = map(int,input().split(" "))
drags = [list(map(int,input().split(" "))) for  _ in range(N)]
INF = 10 ** 9
lim = N* 10 + 1
dp = [[[ INF for i in range(lim)] for j in range(lim)] for _ in range(N+1)]
dp[0][0][0] = 0
for num in range( N ):
    a,b,c = drags[num]
    dp[num + 1][0][0] = 0
    for i in range(0,lim): #完成した液体の aの量
        for j in range(0,lim):# bの量
            dp[num + 1][i][j]  =  dp[num][i][j]
            if i - a >= 0 and j - b >= 0:
                dp[num + 1][i ][j ] = min(dp[num][i ][j ] ,dp[num][i -a ][j -b  ]  + c)

ans = INF
for i in range(1,41):
    MA = Ma * i
    MB = Mb * i
    if MA >= lim or MB >= lim:
        break
    ans = min(ans, dp[-1][MA][MB])
if ans == INF:
    ans = -1
print(ans)

Buggy submission (verdict: Runtime Error):


import math
N,Ma,Mb = map(int,input().split(" "))
drags = [list(map(int,input().split(" "))) for  _ in range(N)]
INF = 10 ** 9
lim = N * 10 + 1
dp = [[[ INF for i in range(lim)] for j in range(lim)] for _ in range(N+1)]
dp[0][0][0] = 0
for num in range( N ):
    a,b,c = drags[num]
    for i in range(a,401): #薬品厨のa の量
        for j in range(b,401 ):#薬品厨のb の量
             dp[num + 1][i][j] = min(dp[num][i ][j] ,dp[num][i - a][j - b]  + c)

ans = INF
for i in range(1,41):
    MA = Ma * i
    MB = Mb * i
    if MA >= lim or MB >= lim:
        break
    ans = min(ans, dp[-1][MA][MB])
if ans == INF:
    ans = -1
print(ans)
Problem p02629 (python)

Fixed submission:
n = int(input())
ans = ''
i = 1
while n > 0 :
    x = n % 26
    if x != 0:
        ans += chr(x+96)
    else:
        ans += 'z'
        n -= 1
    n = n//26
print(ans[::-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = ''
while N > 0:
    N -= 1
    ans += chr(ord('a' + N % 26))
    N //= 26
print(ans[::-1])

Buggy submission (verdict: Runtime Error):
import itertools
import math
N = int(input())
alphabet = list('abcdefghijklmnopqrstuvwxyz')
num = math.ceil(math.log(N, 26))
cnt = [26**i for i in range(1, 15)]
cumsum = list(itertools.accumulate(cnt))
if num == 1:
    ans_n = N-1
    ans_li = list(itertools.product(alphabet, repeat=num))
    print(''.join(ans_li[ans_n]))
else:
    ans = ''
    # for i in range(num):
    #     if i == 1:
    #         ans_n = N-1
    #         ans_li = list(itertools.product(alphabet, repeat=num))
    #         ans += ans_li[ans_n]
    #     else:
    #         now_n = N-26**(i-1) - 1
    #         pre = 26**(i-1)
    #         tmp = ans_n//pre

    ans_n = N - cumsum[num-1] - 1
    pre = 26**(num-1)
    tmp = ans_n//pre
    ans = alphabet[tmp]
    final = ans_n - pre*tmp
    ans_li = list(itertools.product(alphabet, repeat=num-1))
    print(ans + ''.join(ans_li[final]))
Problem p02659 (python)

Fixed submission:
A, B = input().split()
B = int(B[0]+B[-2]+B[-1])
A = int(A)
ans = A*B
print(ans//100)

Buggy submission (verdict: Runtime Error):
A, B = input().split()
print(A*B//1)

Buggy submission (verdict: Runtime Error):
import math
A, B = input().split()
A = int(A)
B = float(B)
B = format(B, '.20f')
# B *= 100
# B = int(B)
# ans = A*B
# ans /= 100
ans = A*B
print(math.floor(ans))
Problem p02792 (python)

Fixed submission:
N = int(input())

cnt = [[0 for _ in range(10)] for _ in range(10)]

for k in range(1, N+1):
    s = str(k)
    cnt[int(s[0])][int(s[-1])] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += cnt[i][j] * cnt[j][i]
print(ans)

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

cnt = [[0 for _ in range(10)] for _ in range(10)]

for k in range(1, n+1):
    s = str(k)
    cnt[int(s[0])][int(s[-1])] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += cnt[i][j] * cnt[j][i]
print(ans)

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

cnt = [[0 for _ in range(10)] for _ in range(10)]

for k in range(1, n+1):
    s = str(k)
    cnt[int(s[0])][int(s[-1])] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += c[i][j] * c[j][i]
print(ans)
Problem p02819 (python)

Fixed submission:
import math
X = int(input())


def get_primenumber(number):
    prime_list = []
    # 2からnumberまでの数字をsearch_listに入れる
    search_list = list(range(2, number+1))
    while True:
    # search_listの先頭の値が√nの値を超えたら処理終了
        if search_list[0] > math.sqrt(number):
            # prime_listにsearch_listを結合
            prime_list.extend(search_list)
            break
        else:
            # search_listの先頭をprime_listに入れる
            head_num = search_list[0]
            prime_list.append(head_num)
            # search_listの先頭をpopする
            search_list.pop(0)
            # head_numの倍数を取り除く
            search_list = [num for num in search_list if num % head_num != 0]
    return prime_list

prime_list = get_primenumber(100000)

left = 0
right = len(prime_list)-1

if X == 2:
    print(int(2))
elif X > 99991:
    print(int(100003))
else:
    while left <= right:
        mid = (left+right) // 2
        if prime_list[mid] == X:
            ans = prime_list[mid]
            break
        elif prime_list[mid] > X:
            if prime_list[mid-1] < X:
                ans = prime_list[mid]
                break
            else:
                right = mid - 1
        else:
            if prime_list[mid+1] > X:
                ans = prime_list[mid+1]
                break
            else:
                left = mid + 1

    print(int(ans))

Buggy submission (verdict: Runtime Error):
while True:
    i = 2
    ok = True
    while i * i <= x:
        if x % i == 0:
            ok = False
            break
        i += 1
    if ok:
        print(x)
        break
    x += 1
Problem p02820 (python)

Fixed submission:
def resolve():
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    T = list(input())

    score = {'r':  P, 's': R, 'p': S}

    ans = 0
    for i in range(K):
        ans += score[T[i]]

    for i in range(K, N):
        if T[i-K] == T[i]:
            T[i] = ' '
            continue
        ans += score[T[i]]

    print(ans)

if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):

def resolve():
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    T = list(input())

    score = {'r':  P, 's': R, 'p': S}

    ans = 0
    for i in range(K):
        ans += score[T[i]]

    for i in range(K, N):
        if T[i-K] == T[i]:
            T[i] = ' '
            continue
        ans += score[T[i]]

    print(s)

if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    N, K = map(int, input().rstrip().split())
    R, S, P = map(int, input().rstrip().split())
    T = list(input().rstrip())

    score = {"r":  P, "s": R, "p": S}

    ans = 0
    for i in range(K):
        ans += score[T[i]]

    for i in range(K, N):
        if T[i-K] == T[i]:
            T[i] = ""
            continue
        ans += score[T[i]]

    print(s)

if __name__ == "__main__":
    resolve()
Problem p03127 (python)

Fixed submission:
import fractions
from functools import reduce
N = int(input())
An = list(map(int, input().split()))


def gcd(list):
    return reduce(fractions.gcd, list)


print(gcd(An))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
N = int(input())
An = list(map(int, input().split()))


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


print(gcd(An))
Problem p03137 (python)

Fixed submission:
n, m = map(int, input().split())
Xm = list(map(int, input().split()))
Xm.sort()
check = [Xm[i+1] - Xm[i] for i in range(m-1)]
check.sort()
print(sum(check[:max(m-n, 0)]))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
Xm = list(map(int, input().split()))
if n >= m:
    print(0)
else:
    Xm.sort()
    check = [Xm[i+1] - Xm[i] for i in range(m-1)]
    check.sort(reverse=True)
    print(sum(check) - check[:n-1])
Problem p02785 (python)

Fixed submission:
N,K = map(int,input().split())
W = sorted(list(map(int,input().split())),reverse=True)
if N<=K:
    print(0)
else:
    for i in range(K):
        W[i] = 0
    print(sum(W))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
W = sorted(list(map(int,input().split())),reverse=True)
if N<=K:
    print(0)
for i in range(K):
    W[i] = 0
print(sum(W))
Problem p02819 (python)

Fixed submission:
x = int(input())
while True:
    for i in range(2,x):
        if x%i==0:
            break
    else:
        print(x)
        break
    x +=1

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

while True:
  for x in range(2, n):
    if n % p == 0:
      break
  else:
    print(x)
    break
  x +=1
Problem p03013 (python)

Fixed submission:
n,m = map(int,input().split())
mod = 10**9+7
dp = [1]*(n+1)
for i in range(m):
    dp[int(input())] =0

for i in range(2,n+1):
    if dp[i]!=0:
        dp[i]=dp[i-1]+dp[i-2]

print(dp[n]%mod)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
xx = [int(input()) for _ in range(m)]
mod = 10**9+7
dp = [1]*(n+1)
for i in range(m):
    dp[int(input())] =0

for i in range(2,n+1):
    if dp[i]!=0:
        dp[i]=dp[i-1]+dp[i-2]

print(dp[n]%mod)
Problem p02689 (python)

Fixed submission:
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
h = list(map(int, input().split()))
h_cond = [True]*n
count = 0

for i in range(m):
    tmp_a, tmp_b = map(int, input().split())
    if h[tmp_a-1] < h[tmp_b-1]:
        h_cond[tmp_a-1] = False
    elif h[tmp_a-1] > h[tmp_b-1]:
        h_cond[tmp_b-1] = False
    else:
        h_cond[tmp_a - 1] = False
        h_cond[tmp_b - 1] = False

# print(h_cond)
# print(route)
for idx, hi in enumerate(h_cond):
    if h_cond[idx]:
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
h = list(map(int, input().split()))
h_cond = [True]*n
count = 0

for i in range(m):
    tmp_a, tmp_b = map(int, input().split())
    if h[tmp_a-1] < h[tmp_b-1]:
        h_cond[tmp_a-1] = False
    elif h[tmp_a-1] > h[tmp_b-1]:
        h_cond[tmp_b-1] = False
    else:
        h_cond[tmp_a - 1] = False
        h_cond[tmp_b - 1] = False

# print(h_cond)
# print(route)
for idx, hi in enumerate(route):
    if h_cond[idx]:
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
a = [0]*k
has_k = [False]*n
count = 0

for i in range(k):
    tmp_d = int(input())
    tmp_a = list(map(int, input().split()))
    for ai in tmp_a:
        has_k[ai-1] = True

for ki in has_k:
    if ki == False:
        count += 1

print(count)
Problem p03634 (python)

Fixed submission:
import sys

sys.setrecursionlimit(1000000)

N = int(input())
Nodes = [{} for i in range(N)]


def search(index, dist):
    neighbors = Nodes[index]
    for key in neighbors:
        if distances[key] is not None:
            continue

        distances[key] = dist + neighbors[key]
        search(key, distances[key])


# 木を作る
for _ in range(N-1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    Nodes[a][b] = c
    Nodes[b][a] = c

# 頂点Kから各点への距離を求める
Q, K = map(int, input().split())
distances = [None for i in range(N)]
distances[K-1] = 0
search(index=K-1, dist=0)

#print(distances)

# 解答
for _ in range(Q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(distances[x] + distances[y])

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(100000)

N = int(input())
Nodes = [{} for i in range(N)]


def search(index, dist):
    neighbors = Nodes[index]
    for key in neighbors:
        if distances[key] is not None:
            continue

        distances[key] = dist + neighbors[key]
        search(key, distances[key])


# 木を作る
for _ in range(N-1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    Nodes[a][b] = c
    Nodes[b][a] = c

# 頂点Kから各点への距離を求める
Q, K = map(int, input().split())
distances = [None for i in range(N)]
distances[K-1] = 0
search(index=K-1, dist=0)

#print(distances)

# 解答
for _ in range(Q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(distances[x] + distances[y])

Buggy submission (verdict: Runtime Error):
N = int(input())
Nodes = [{} for i in range(N)]


def search(index, dist):
    neighbors = Nodes[index]
    for key in neighbors:
        if distances[key] is not None:
            continue

        distances[key] = dist + neighbors[key]
        search(key, distances[key])


# 木を作る
for _ in range(N-1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    Nodes[a][b] = c
    Nodes[b][a] = c

# 頂点Kから各点への距離を求める
Q, K = map(int, input().split())
distances = [None for i in range(N)]
distances[K-1] = 0
search(index=K-1, dist=0)

#print(distances)

# 解答
for _ in range(Q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(distances[x] + distances[y])
Problem p02987 (python)

Fixed submission:
print('YNeos'[len(set(input()))!=2::2])

Buggy submission (verdict: Runtime Error):
print('YNeos'[len(set(input()))!=2::2]
Problem p03327 (python)

Fixed submission:
n=int(input())
if n - 999 > 0:
  print('ABD')
else:
  print('ABC')

Buggy submission (verdict: Runtime Error):
n=int(input())
if n - 999 > 0:
  print('ABD')
elif:
  print('ABC')