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

Fixed submission:
p,q,r = map(int, input().split())
print(p+q+r-max(p,q,r))

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

a = []
#通過できない階段をaに格納
for _ in range(m):
    a.append(int(input()))
    
count = [0]*(n+1)
count[0] = 1
for i in range(1,n+1):
    if i in a:
        continue
    else:
        count[i] = count[i-1]+count[i-2]

print(count[-1]%(10**9+7))
Problem p03038 (python)

Fixed submission:
import sys
import os
import bisect
from operator import itemgetter

N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
B = [ 0  for _ in range(M)]
for i in range(M):
    b,c = map(int,input().split())
    B[i] = [b,c]
B = sorted(B,key=itemgetter(1),reverse=True)
ans = 0
for i in range(M):
    id = bisect.bisect_left(A,B[i][1])
    if id > 0:
        for j in range(min(B[i][0],id+1)):
            if len(A) > 0 and A[0] < B[i][1]:
                ans += B[i][1]
                del A[0]
    else:
        break
print(sum(A)+ans)

Buggy submission (verdict: Runtime Error):
import sys
import os
import bisect
from operator import itemgetter

N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
B = [ 0  for _ in range(M)]
for i in range(M):
    b,c = map(int,input().split())
    B[i] = [b,c]
B = sorted(B,key=itemgetter(1),reverse=True)
ans = 0
for i in range(M):
    id = bisect.bisect_left(A,B[i][1])
    if id > 0:
        for j in range(min(B[i][0],id+1)):
            if A[0] < B[i][1]:
                ans += B[i][1]
                del A[0]
    else:
        break
print(sum(A)+ans)
Problem p03221 (python)

Fixed submission:
import sys
import os
from operator import itemgetter

N,M = map(int,input().split())
cities = [ 0 for _ in range(M) ]

for i in range(M):
    p,y = map(int,input().split())
    cities[i] = [p,y,i]
cities = sorted(cities,key=itemgetter(1))
cities = sorted(cities,key=itemgetter(0))

out = ["*" for _ in range(M)]
beforeCity = cities[0][0]
cityCnt = 1
for i in range(M):
    curCity = cities[i][0]
    if beforeCity != curCity:
        cityCnt = 1
    cityNo1 = str(curCity).zfill(6)
    cityNo2 = str(cityCnt).zfill(6)
    out[cities[i][2]] = cityNo1+cityNo2
    beforeCity = curCity
    cityCnt += 1

for a in out:
    print(a)

Buggy submission (verdict: Runtime Error):
from operator import itemgetter

N,M = map(int,input().split())
cities = [ 0 for _ in range(M) ]

for i in range(M):
    p,y = map(int,input().split())
    cities[i] = [p,y,i]
cities = sorted(cities,key=itemgetter(1))
cities = sorted(cities,key=itemgetter(0))

out = ["*" for _ in range(M)]

beforeCity = cities[0][0]
cityCnt = 1
for i in range(M):
    if beforeCity != cities[i][0]:
        cityCnt = 1
    if len(str(cities[i][0])) < 6:
        cityNo1 = "0"*(6 - len(str(cities[i][0])))+str(cities[i][0])
    if len(str(cityCnt)) < 6:
        cityNo2 = "0"*(6 - len(str(cityCnt)))+str(cityCnt)
    out[cities[i][2]] = cityNo1+cityNo2
    cityCnt += 1
for a in out:
    print(a)
Problem p03242 (python)

Fixed submission:
n = input()
n = n.replace('9','x')
n = n.replace('1','9')
n = n.replace('x','1')
print(n)

Buggy submission (verdict: Runtime Error):
import collections

n = input()
line = input().split()
odd = line[::2]
even = line[1::2]
o = collections.Counter(odd)
e = collections.Counter(even)
maxoddcnt = o.most_common()[0][1]
maxevencnt = e.most_common()[0][1]

#すべての値が同じときは半分を置換する
if odd == even:
    print(len(odd))
    exit(0)

#奇数列，偶数列それぞれの最頻の文字が同じ場合は，いずれかを2番目に多い文字に置換しなければならない
if o.most_common()[0][0] == e.most_common()[0][0]:
    if len(o.most_common()) > 1 and len(e.most_common()) <= 1:
        maxoddcnt = o.most_common()[1][1]
    if len(o.most_common()) <= 1 and len(e.most_common()) > 1:
        maxevencnt = e.most_common()[1][1]
    if o.most_common()[1][1] + e.most_common()[0][1] >= o.most_common()[0][1] + e.most_common()[1][1]:
        maxoddcnt = o.most_common()[1][1]
    else: #if o.most_common()[1][1] + e.most_common()[0][1] <= o.most_common()[0][1] + e.most_common()[1][1] :
        maxevencnt = e.most_common()[1][1]
        input()

print(len(odd)-maxoddcnt+len(even)-maxevencnt)

Buggy submission (verdict: Runtime Error):
import collections

n = input()
line = input().split()
odd = line[::2]
even = line[1::2]
o = collections.Counter(odd)
e = collections.Counter(even)
maxoddcnt = o.most_common()[0][1]
maxevencnt = e.most_common()[0][1]

#すべての値が同じときは半分を置換する
if odd == even:
    print(len(odd))
    exit(0)

#奇数列，偶数列それぞれの最頻の文字が同じ場合は，いずれかを2番目に多い文字に置換しなければならない
if o.most_common()[0][0] == e.most_common()[0][0]:
    if o.most_common()[1][1] + e.most_common()[0][1] > o.most_common()[0][1] + e.most_common()[1][1]:
        maxoddcnt = o.most_common()[1][1]
    else: #if o.most_common()[1][1] + e.most_common()[0][1] <= o.most_common()[0][1] + e.most_common()[1][1] :
        maxevencnt = e.most_common()[1][1]

print(len(odd)-maxoddcnt+len(even)-maxevencnt)
Problem p03804 (python)

Fixed submission:
N, M  = map(int, input().split())
A = [ input() for i in range(N)]
B = [ input() for i in range(M)]


def serch(x0, y0):
  for i in range(M):
    for j in range(M):
      if x0+i >= N or y0+j >= N:
        return False
      if A[x0+i][y0+j] != B[i][j]:
        return False
  return True

if M > N:
  print('No')
  exit()


for x in range(N):
  for y in range(N):
    if not serch(x,y):
      continue
    else:
      print('Yes')
      exit()
print('No')

Buggy submission (verdict: Runtime Error):
N, M  = map(int, input().split())
A = [ input() for i in range(N)]
B = [ input() for i in range(M)]


def serch(x0, y0):
  for i in range(M):
    for j in range(M):
      if A[x0+i][y0+j] != B[i][j]:
        return False
  return True

if M > N:
  print('No')
  exit()


for x in range(N):
  for y in range(N):
    if not serch(x,y):
      continue
    else:
      print('Yes')
      exit()
print('No')

Buggy submission (verdict: Runtime Error):
N, M  = map(int, input().split())
A = [ input() for i in range(N)]
B = [ input() for i in range(M)]


def serch(x0, y0):
  for i in range(M):
    for j in range(M):
      if A[x0+i][y0+j] != B[i][j]:
        return False
  return True

if M > N:
  print('No')
  exit()

for b in B:
  for x in range(N):
    for y in range(N):
      if not serch(x,y):
        continue
      else:
        print('Yes')
        exit()
print('No')

Buggy submission (verdict: Runtime Error):
N, M  = map(int, input().split())
A = [ input() for i in range(N)]
B = [ input() for i in range(M)]


def serch(x0, y0):
  for i in range(M):
    for j in range(M):
      if A[x0+i][y0+j] != B[i][j]:
        return False
  return True


for b in B:
  for x in range(N):
    for y in range(N):
      if not serch(x,y):
        continue
      else:
        print('Yes')
        exit()
print('No')
Problem p03835 (python)

Fixed submission:
K, S = map(int,input().split())
ans = 0
for x in range(K+1):
    for y in range(K+1):
        z = S-x-y
        if 0 <= z and z <= K:
            ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
K, S = map(int,input().split())
listK = [i for i in range(K+1)]
list2K = [i for i in range(K**2)]
ans = 0
for i in range(K+1):
    id = bisect.bisect_left(list2K,S-i)
    if id < len(list2K) and list2K[id] == S-i:
        for j in range(K+1):
            id2 = bisect.bisect_left(listK,list2K[id]-j)
            if id2 < len(listK) and listK[id2] == list2K[id]-j:
                ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
K, S = map(int,input().split())
listK = [i for i in range(K+1)]
ans = 0
for i in range(K+1):
    for j in range(K+1):
        id = bisect.bisect_left(listK,S-i-j)
        if id < len(listK) and listK[id] == S-i-j:
                ans += 1
print(ans)
Problem p02623 (python)

Fixed submission:
N, M, K = [int(v) for v in input().strip().split(" ")]
A = [int(v) for v in input().strip().split(" ")]
B = [int(v) for v in input().strip().split(" ")]

a, b = [0], [0]
max_sum = 0

for i in range(len(A)):
    a.append(a[i] + A[i])

for j in range(len(B)):
    b.append(b[j] + B[j])

j = len(B)
for i in range(len(A)+1):
    if a[i] > K:
        continue
    else:
        while b[j] > K - a[i]:
            j -= 1
        max_sum = max(max_sum, i + j)

print(max_sum)

Buggy submission (verdict: Runtime Error):
N, M, K = [int(v) for v in input().strip().split(" ")]
A = [int(v) for v in input().strip().split(" ")]
B = [int(v) for v in input().strip().split(" ")]

A = [0] + A
B = [0] + B

class Solution():
    def __init__(self):
        self.max_num = 0

    def search(self, now_sum, A_index, B_index, add_axis):
        if add_axis == "A":
            A_index += 1
            if A_index < len(A):
                now_sum += A[A_index]
            else:
                return
        else:
            B_index += 1
            if B_index < len(B):
                now_sum += B[B_index]
            else:
                return

        # print(A_index, B_index, now_sum)

        if A_index + B_index > self.max_num and now_sum <= K:
            self.max_num = A_index + B_index

        if now_sum < K:
            self.search(now_sum, A_index, B_index, "A")
            self.search(now_sum, A_index, B_index, "B")
        else:
            return

    def search_main(self):
        self.search(0, A_index=0, B_index=0, add_axis="A")
        self.search(0, A_index=0, B_index=0, add_axis="B")
        print(self.max_num)

s = Solution()
s.search_main()
Problem p02597 (python)

Fixed submission:
N = int(input())
C = list(input())
ans = 0
r = 0
l = N - 1
while r < l:
    if C[r] == 'W':
        while True:
            if C[l] == 'R':
                ans += 1
                l -= 1
                break
            else:
                l -= 1
                if r == l:
                    break
    r += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
C = list(input())
ans = 0
r = 0
l = N - 1
while r+1 < l or r < N - 1:
    if C[r] == 'W':
        while True:
            if C[l] == 'R':
                ans += 1
                l -= 1
                break
            else:
                l -= 1
                if r+1 == l:
                    break
    r += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
C = list(input())
ans = 0
r = 0
l = N - 1
while r+1 != l:
    while True:
        if C[r] != C[l]:
            ans += 1
            break
        else:
            l -= 1
            if r+1 == l:
                break
    r += 1
print(ans)
Problem p02773 (python)

Fixed submission:
from collections import Counter

n=int(input())
S=[input() for _ in range(n)]

c=Counter(S)
m=max(c.values())
ans = sorted(k for k,v in c.items() if v == m)
print("\n".join(ans))

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

n=int(input())
S=[input() for _ in range(n)]

c=Counter(s)
m=max(c.values())
ans = sorted(k for k,v in c.items() if v == m)
print("\n".join(ans))
Problem p02819 (python)

Fixed submission:
def is_prime(x):
    if x<= 1: return False
    i=2
    while i*i<=x:
        if x%i==0:
            return False
        i+=1
    return True

ans = int(input())
while not is_prime(ans):
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(20000)
x = int(input())

def mody(x,n):
	if n == 1:
		return 1
	if x%n == 0:
		return x
	else:
		return mody(x,n-1)

for i in range(0,10**5-x):
	n = mody(x+i,x+i-1)
	if n == 1:
		ans = x+i
		break
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**5)
x = int(input())

def mody(x,n):
	if n == 1:
		return 1
	if x%n == 0:
		return x
	else:
		return mody(x,n-1)

for i in range(0,10**5-x):
	n = mody(x+i,x+i-1)
	if n == 1:
		ans = x+i
		break
print(ans)
Problem p02832 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(N):
    if A[i] != i+1-cnt:
        cnt += 1
if cnt == N:
    print(-1)
else:
    print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
cnt = 0

def ers(a,cnt):
    if len(a) == 0:
        cnt = -1
        return cnt
    for i in range(len(a)):
        if i+1 != a[i]:
            a.pop(i)
            cnt+=1
            return ers(a,cnt)
    return cnt

res = ers(a,cnt)

print(str(res))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
cnt = 0

def ers(a,cnt):
    if len(a) == 0:
        cnt = -1
        return cnt
    for i in range(len(a)):
        if i+1 != a[i]:
            a.pop(i)
            cnt+=1
            return ers(a,cnt)
    return cnt

res = ers(a,cnt)

print(res)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
cnt = 0

def ers(a,cnt,n):
    if len(a) == 0:
        cnt = -1
        return cnt
    for i in range(n):
        if i+1 != a[i]:
            a.pop(i)
            cnt+=1
            n -= 1
            return ers(a,cnt,n)
    return cnt

res = ers(a,cnt,n)

print(res)
Problem p02836 (python)

Fixed submission:
s = list(input())
m=len(s)//2
t=-1
cnt=0

for i in s[:m]:
    if i != s[t]:
        cnt+=1
    t-=1
    
print(cnt)

Buggy submission (verdict: Runtime Error):
s = list(input())
t=-1
cnt=0

for i in s[:m]:
    if i != s[t]:
        cnt+=1
    t-=1
    
print(cnt)
Problem p03221 (python)

Fixed submission:
from collections import defaultdict

n, m = map(int, input().split())
PY = [tuple(map(int, input().split())) for _ in range(m)]
ypi = sorted((y, p, i) for i, (p, y) in enumerate(PY))
d = defaultdict(lambda: 0)

ans = [None]*m

for y, p, i in ypi:
    d[p] += 1
    ans[i] = str(p).zfill(6) + str(d[p]).zfill(6)

print(*ans, sep='\n')

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

n, m = map(int, input().split())
PY = [tuple(map(int, input().split())) for _ in range(m)]
ypi = sorted((y, p) for i, (p, y) in enumerate(PY))
d = defaultdict(lambda: 0)

ans = [None]*m

for y, p in ypi:
    d[p] += 1
    ans[i] = str(p).zfill(6) + str(d[p]).zfill(6)

print(*ans, sep='\n')
Problem p03329 (python)

Fixed submission:
n=int(input())
dp=[float("inf") for _ in range(n+1)]
dp[0]=0
for i in range(n):
    power=1
    while i+power <= n:
        dp[i+power] = min(dp[i+power],dp[i]+1)
        power*=6
    power=1
    while i+power <= n:
        dp[i+power] = min(dp[i+power],dp[i]+1)
        power*=9
print(dp[n])

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
dp=[math.inf for _ in range(n+1)]
dp[0]=0
for i in range(n):
    power=1
    while i+power <= n:
        dp[i+power] = min(dp[i+power],dp[i]+1)
        power*=6
    power=1
    while i+power <= n:
        dp[i+power] = min(dp[i+power],dp[i]+1)
        power*=9
print(dp[n])

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
dp=[math.inf]*(n+1)
dp[0]=0
for i in range(n):
    power=1
    while i+power <= n:
        dp[i+power] = min(dp[i+power],dp[i]+1)
        power*=6
    power=1
    while i+power <= n:
        dp[i+power] = min(dp[i+power],dp[i]+1)
        power*=9
print(dp[n])
Problem p03774 (python)

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

ab = []
cd = []
for _ in range(N):
    a, b = map(int, input().split())
    ab.append([a, b])
for _ in range(M):
    c, d = map(int, input().split())
    cd.append([c, d])

for a, b in ab:
    near = 10**32
    for i, n in enumerate(cd):
        tmp = abs(a-n[0])+abs(b-n[1])
        if near == tmp:
            continue
        near = min(near, tmp)
        if near == tmp:
            ans = i + 1
    print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ab = []
cd = []
for _ in range(N):
    a, b = map(int, input().split())
    ab.append([a, b])
for _ in range(N):
    c, d = map(int, input().split())
    cd.append([c, d])

for a, b in ab:
    near = 10**32
    for i, n in enumerate(cd):
        tmp = abs(a-n[0])+abs(b-n[1])
        if near == tmp:
            continue
        near = min(near, tmp)
        if near == tmp:
            ans = i + 1
    print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ab = []
cd = []
for _ in range(N):
    a, b = map(int, input().split())
    ab.append([a, b])
for _ in range(N):
    c, d = map(int, input().split())
    cd.append([c, d])

for a, b in ab:
    near = 10**16
    for i, n in enumerate(cd):
        tmp = abs(a-n[0])+abs(b-n[1])
        if near == tmp:
            continue
        near = min(near, tmp)
        if near == tmp:
            ans = i + 1
    print(ans)
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()

if a >= 3200:
  print(s)
  
else:
  print("red")

Buggy submission (verdict: Runtime Error):
if a >= 3200:
  print(s)
else:
  print('red')
Problem p02629 (python)

Fixed submission:
n=int(input())
def alpha2num(alpha):
    if alpha<=26:
        return chr(64+alpha)
    elif alpha%26==0:
        return alpha2num(alpha//26-1)+chr(90)
    else:
        return alpha2num(alpha//26)+chr(64+alpha%26)
print(alpha2num(n).lower())

Buggy submission (verdict: Runtime Error):
n=int(input())
def alpha2num(alpha):
    num=0
    for index,item in enumerate(list(alpha)):
        num+=pow(26,len(alpha)-index-1)*(ord(item)-ord("A")+1)
    return num
if 1<=n<=26:
    n=n
    print(alpha2num(n))
elif 27<=n<=702:
    n-=26
    print(alpha2num(n))
elif 703<=n<=18278:
    n-=702
    print(alpha2num(n))
elif 18279<=n<=475254:
    n-=18278
    print(alpha2num(n))
else:
    n-=475254
    print(alpha2num(n))
Problem p02676 (python)

Fixed submission:
K=int(input())
S=input()
if len(S)<=K:
    print(S)
else:
    print(S[:K]+"...")

Buggy submission (verdict: Runtime Error):
S=input()
K=int(input())
if len(S)<=K:
    print(S)
else:
    print(S[:K]+"...")

Buggy submission (verdict: Runtime Error):
S=str(input())
K=int(input())
if len(S)<=K:
    print(S)
else:
    print(S[0:K]+"...")

Buggy submission (verdict: Runtime Error):
S=input()
K=input()
if len(S)<=K:
    print(S)
else:
    print(S[:K]+"...")

Buggy submission (verdict: Runtime Error):
S=str(input())
K=int(input())
if len(S)<=K:
    print(S)
else:
    print(S[:K]+"...")
Problem p02682 (python)

Fixed submission:
a,b,c,k=map(int,input().split())
n=k-a-b
if n>=0: 
    print(a-n)
elif n<0 and a<=k:
    print(a)
elif n<0 and a>k:
    print(k)

Buggy submission (verdict: Runtime Error):
a,b,c,k=map(int,input().split())
n=k-a-b
if n>=0 
    print(a-n)
elif n<0 and a<=k:
    print(a)
elif n<0 and a>k:
    print(k)

Buggy submission (verdict: Runtime Error):
a,b,c,k=map(int,input().split())
n=k-a-b
if n>=0 
    print(a-n)
elif n<0 and a<=k:
    print(a)
else:
    print(k)
Problem p02701 (python)

Fixed submission:
n=int(input())
li=[]
for si in range(n):
    si=input()
    li.append(si)
print(len(set(li)))

Buggy submission (verdict: Runtime Error):
n=int(input())
li=[]
for si in n:
    si=input()
    li.append(si)
print(len(set(li)))
Problem p02707 (python)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
m=[0]*n
for i in p:
    m[i-1]+=1
for a in m:
    print(a,"\n")

Buggy submission (verdict: Runtime Error):
n=int(input())
p=list(map(int,input().split()))
li=[]
for i in range(1,n):
    q=p.count(i)
    li.append(q)
nl=li.split("\n")
print(nl)
Problem p02711 (python)

Fixed submission:
n=str(input())
if n[-1]=="7" or n[-3]=="7" or n[-2]=="7":
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
num=map(int,str(n))
if num[-1]=="7" or num[-3]=="7" or num[-2]=="7":
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
if n[-1]==7 or n[-3]==7 or n[-2]==7:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
if n[-1]==7 or n[-3]==7 or n[-2]==7
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n=str(input())
if n[-1]=="7" or n[-3]=="7" or n[-2]=="7"
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n=str(input())
if n[1]=="7" or n[0]=="7" or n[2]=="7"
    print("Yes")
else:
    print("No")
Problem p02688 (python)

Fixed submission:
#!usr/bin/env python3
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n, k = LI()
    flag_list = [False] * n
    for _ in range(k):
        d = I()
        a = LI()
        for i in range(d):
            flag_list[a[i]-1] = True
    print(flag_list.count(False))
    
    return


if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
#!usr/bin/env python3
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n, k = LI()
    flag_list = [False] * n
    for _ in range(k-1):
        d = I()
        a = LIR(max(d-1, 1))
        for i in range(d):
            flag_list[a[0][i]-1] = True
    print(flag_list.count(False))
    
    return


if __name__ == "__main__":
    solve()
Problem p02771 (python)

Fixed submission:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    a, b, c = LI()
    if a == b == c:
        print('No')
    elif a == b:
        print('Yes')
    elif a == c:
        print('Yes')
    elif b == c:
        print('Yes')
    else:
        print('No')


# Solve
if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
#!usr/bin/env python3


import sys


def I(): return int(sys.stdin.readline())


def solve():
    n = I()
    sli = [input() for i in range(n)]
    setli = set(sli)
    rank = {}
    for i in setli:
        j = sli.count(i)
        rank[i] = j
    for i in sorted([k for k, v in rank.items() if v == max(rank.values())]):
        print(i)


# Solve
if __name__ == "__main__":
    solve()