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

Fixed submission:
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0]
b = [0]
for i in range(0, n):
    a.append(A[i] + a[i])
for i in range(0, m):
    b.append(B[i] + b[i])

ans = 0
j = m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k-a[i]:
        j -= 1
    ans = max(ans, i+j)

print(ans)

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

# k分で読める本の累積
a_ruiseki = [0]*(k+10)
b_ruiseki = [0]*(k+10)
a_cnt = 1
b_cnt = 1
a_sum = a[0]
b_sum = b[0]
for i in range(k+1):
    if a_sum == i and a_cnt < len(a)+1:
        a_cnt += 1
        tmp = min(a_cnt-1, len(a)-1)
        a_sum+=a[tmp]
    if b_sum == i and b_cnt < len(b)+1:
        b_cnt += 1
        tmp = min(a_cnt-1, len(a)-1)
        b_sum+=b[tmp]
    a_ruiseki[i] = a_cnt-1
    b_ruiseki[i] = b_cnt-1

#    print(f'{i} {a_cnt-1}')
#
#print(a_ruiseki)
#print(b_ruiseki)

ans = 0
for i in range(k+1):
    ans = max(ans, a_ruiseki[i]+b_ruiseki[k-i])
print(ans)

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

# k分で読める本の累積
a_ruiseki = [0]*(k+10)
b_ruiseki = [0]*(k+10)
a_cnt = 1
b_cnt = 1
a_sum = a[0]
b_sum = b[0]
for i in range(k+1):
    if a_sum == i and a_cnt < len(a)+1:
        a_cnt += 1
        tmp = min(a_cnt-1, len(a)-1)
        a_sum+=a[tmp]
    if b_sum == i and b_cnt < len(b)+1:
        b_cnt += 1
        tmp = min(a_cnt-1, len(a)-1)
        b_sum+=b[tmp]
    a_ruiseki[i] = a_cnt-1
    b_ruiseki[i] = b_cnt-1

#    print(f'{i} {a_cnt-1}')
#
#print(a_ruiseki)
#print(b_ruiseki)

ans = 0
for i in range(k+1):
    ans = max(ans, a_ruiseki[i]+b_ruiseki[k-i])
print(ans)
Problem p03011 (python)

Fixed submission:
aa =  [int(i) for i in input().split()]

bb = sorted(aa)

print(bb[0]+bb[1])

Buggy submission (verdict: Runtime Error):
aa = list(map(int, input().split()))

bb = sorted(aa)

print(bb[0]+bb[1])
Problem p03073 (python)

Fixed submission:
s = list(input())
pattern_a_count = 0
pattern_b_count = 0

# 1010パターン
for index, value in enumerate(s):
  if index % 2 == 0:
    if value == "0":
      pattern_a_count += 1
  if index % 2 == 1:
    if value == "1":
      pattern_a_count += 1

# 0101
for index, value in enumerate(s):
  if index % 2 == 0:
    if value == "1":
      pattern_b_count += 1
  if index % 2 == 1:
    if value == "0":
      pattern_b_count += 1
      
res = pattern_b_count
if pattern_a_count <= pattern_b_count:
  res = pattern_a_count
print(res)

Buggy submission (verdict: Runtime Error):
s = list(input())
int pattern_a_count = 0
int pattern_b_count = 0

for index, value in enumerate(s):
  if index % 2 =0:
    if value == 0:
      pattern_a_count += 1
  if index % 2 =1:
    if value == 1:
      pattern_a_count += 1
      
for index, value in enumerate(s):
  if index % 2 =0:
    if value == 1:
      pattern_b_count += 1
  if index % 2 =1:
    if value == 0:
      pattern_b_count += 1
      
res = pattern_b_count
if pattern_a_count <= pattern_b_count:
  res = pattern_a_count
print(pattern_a_count)

Buggy submission (verdict: Runtime Error):
s = list(input())
int pattern_a_count = 0
int pattern_b_count = 0

for index, value in enumerate(s):
  if index % 2 =0:
    if value == "0":
      pattern_a_count += 1
  if index % 2 =1:
    if value == "1":
      pattern_a_count += 1
      
for index, value in enumerate(s):
  if index % 2 =0:
    if value == "1":
      pattern_b_count += 1
  if index % 2 =1:
    if value == "0":
      pattern_b_count += 1
      
res = pattern_b_count
if pattern_a_count <= pattern_b_count:
  res = pattern_a_count
print(pattern_a_count)

Buggy submission (verdict: Runtime Error):
s = list(input())
int pattern_a_count = 0
int pattern_b_count = 0

for index, value in enumerate(s):
  if index % 2 =0:
    if value == "0":
      pattern_a_count += 1
  if index % 2 =1:
    if value == "1":
      pattern_a_count += 1
      
for index, value in enumerate(s):
  if index % 2 =0:
    if value == "1":
      pattern_b_count += 1
  if index % 2 =1:
    if value == "0":
      pattern_b_count += 1
Problem p02933 (python)

Fixed submission:
a=int(input())
s=input()
if a<3200:
  print("red")
else:
  print(s)

Buggy submission (verdict: Runtime Error):
a=int(input())
s=int(input())
if a<3200:
  print("red")
else:
  print(s)
Problem p02623 (python)

Fixed submission:
def is_ok(index, key):
    return B[index] <= key

def upper_bound(key): 
    ng = len(B)
    ok = -1

    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if is_ok(mid, key):
            ok = mid
        else:
            ng = mid
    
    return ok 

n, m, k = map(int, input().split())
tmpA = list(map(int, input().split()))
tmpB = list(map(int, input().split()))
A = [0]
B = [0]
# 読むのにかかる時間の累計和のリスト
if A:
    for i in range(n):
        tmp = A[i] + tmpA[i]
        if tmp > k:
            break
        else:
            A.append(tmp)
if B:
    for i in range(m):
        tmp = B[i] + tmpB[i]
        if tmp > k:
            break
        else:
            B.append(tmp)

answer = 0
for i in range(len(A)):
    key = k - A[i]
    answer = max(answer, upper_bound(key) + i)

print(answer)

Buggy submission (verdict: Runtime Error):
from collections import deque
n, m, k = map(int,input().split())
tmpA = list(map(int,input().split()))
tmpB = list(map(int,input().split()))
A = [tmpA[0]]
B = [tmpB[0]]
for i in range(1, n):
    tmp = A[i-1] + tmpA[i]
    if tmp > k:
        break
    else:
        A.append(tmp)
for i in range(1, m):
    tmp = B[i-1] + tmpB[i]
    if tmp > k:
        break
    else:
        B.append(tmp)

if len(A) == 1 and len(B) == 1:
    if A[0] > k:
        A.pop()
    if B[0] > k:
        B.pop()
    print(len(A) + len(B))
elif len(A) == 1:
    if A[0] > k:
        print(len(B))
    else:
        while True:
            if A[0] + B[-1] <= k:
                break
            if A[0] > B[-1]:
                A.pop()
            else:
                B.pop()
        print(len(A) + len(B))
elif len(B) == 1:
    if B[0] > k:
        print(len(A))
    else:
        while True:
            if B[0] + A[-1] <= k:
                break
            if B[0] > A[-1]:
                B.pop()
            else:
                A.pop()
        print(len(A) + len(B))
else:
    while True:
        if A[-1] + B[-1] <= k:
            break
        if A[-1] > B[-1]:
            A.pop()
        else:
            B.pop()
    print(len(A) + len(B))
Problem p02623 (python)

Fixed submission:
import itertools
import bisect
N, M, K = map(int,input().split())
al = list(map(int,input().split()))
bl = list(map(int,input().split()))

als = list(itertools.accumulate(al))
als.insert(0,0)
bls = list(itertools.accumulate(bl))
bls.insert(0,0)
# print(als)
# print(bls)

ans = 0
for i in range(N+1):
    nokori = K - als[i]
    if nokori >= 0:
        index = bisect.bisect_right(bls,nokori)
        if index > 0:
            index -= 1
        tmp = i + index
        #print(i,index)
        if tmp > ans:
            ans = tmp
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
N, M, K = map(int,input().split())
al = list(map(int,input().split()))
bl = list(map(int,input().split()))
al = deque(al)
bl = deque(bl)

time = 0
cnt = 0
for i in range(N+K):
    if len(al) >= 1 and len(bl) >= 1:
        if al[0] >= bl[0]:
            time += bl[0]
            if time > K:
                print(cnt)
                exit()
            else:
                bl.popleft()
                cnt += 1
        else:
            time += al[0]
            if time > K:
                print(cnt)
                exit()
            else:
                al.popleft()
                cnt += 1
    elif len(bl) == 0:
        time += al[0]
        if time > K:
            print(cnt)
            exit()
        else:
            al.popleft()
            cnt += 1
    elif len(al) == 0:
        time += bl[0]
        if time > K:
            print(cnt)
            exit()
        else:
            bl.popleft()
            cnt += 1
    else:
        print(cnt)
        break
Problem p02629 (python)

Fixed submission:
n = int(input())

moji = [chr(i) for i in range(97, 97+26)]
ans = ''
while n > 0:
    n -= 1
    x = int(n % 26)
    ans = moji[n % 26] + ans
    n //= 26
print(ans)

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

moji = [chr(i) for i in range(97, 97+26)]


lst = [0]
n = 0
for i in range(1,12):
    n = n + 26 ** i
    lst.append(n)

#lst.sort(reverse=True)
#print(lst)
keta = 0
for i in range(len(lst)):
    if N <= lst[i]:
        keta = i
        break

keta -= 1
ans = []
for i in range(keta+1):
    tmp = N // (26**keta)
    ans.append(tmp)
    N = N % (26**keta)
    keta -= 1
#print(ans)

answer = ''
for i in ans:
    answer += moji[i-1]
print(answer)
Problem p02633 (python)

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(x, 360)//x)

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(x, 360)//x)
Problem p02695 (python)

Fixed submission:
import itertools
N, M, Q = map(int,input().split())
abcd_list = []
for i in range(Q):
    abcd_list.append(list(map(int,input().split())))

ans = 0
for A in itertools.combinations_with_replacement(range(1, M+1), N):
    A = sorted(list(A))
    point = 0
    for abcd in abcd_list:
        if A[abcd[1]-1] - A[abcd[0]-1] == abcd[2]:
            point += abcd[3]
    if point > ans:
        ans = point

print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
N, M, Q = map(int,input().split())
abcd_list = []
for i in range(Q):
    abcd_list.append(list(map(int,input().split())))

num_lis = []
for i in range(M+1):
    num_lis.append(i)

point_list = []
for A in itertools.permutations(num_lis,N):
    A = sorted(list(A))
    point = 0
    for abcd in abcd_list:
        if A[abcd[1]-1] - A[abcd[0]-1] == abcd[2]:
            point += abcd[3]
    point_list.append(point)

print(max(point_list))
Problem p02725 (python)

Fixed submission:
k, n = map(int,input().split())
al = list(map(int,input().split()))

dtlst = [al[0]]
for i in range(1,n):
  dtlst.append(al[i]-al[i-1])
dtlst.append(k - al[-1]+al[0])

print(k - max(dtlst))

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

dtlst = [al[0]]
for i in range(1,n):
  dtlst.append(al[i]-al[i-1])
dtlst.append(k - al[-1]+al[0])

print(k - max(dtlst))

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

dtlst = [al[0]]
for i in range(1,n):
  dtlst.append(al[i]-al[i-1])
dtlst.append(k - al[-1]+al[0])

print(k - max(dtlst))
Problem p02819 (python)

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

def is_prime(x):
    if x < 2: return False # 2未満に素数はない
    if x == 2 or x == 3 or x == 5: return True # 2,3,5は素数
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False # 2,3,5の倍数は合成数

    # ためし割り: 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True

while True:
    if is_prime(x):
        print(x)
        break
    x += 1

Buggy submission (verdict: Runtime Error):
from sympy import sieve

x = int(input())

while True:
    if x in sieve:
        print(x)
        break
    x += 1
Problem p02989 (python)

Fixed submission:
n = int(input())
dl = list(map(int,input().split()))
dl.sort()

if n % 2 != 0:
  print(0)
  exit()

  
left = dl[(n//2)-1]
right = dl[(n//2)]

print(right-left)

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

if n % 2 != 0:
  print(0)
  exit()

  
left = dl[(n//2)-1]
right = dl[(n//2)]

print(right-left)
Problem p03017 (python)

Fixed submission:
n, a, b, c, d = map(int, input().split())
s = input()

if '##' in s[a-1:d]:
    print('No')
    exit()

if c < d:
    print('Yes')
    exit()

if '...' in s[b-2:d+1]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n, a, b, c, d = map(int, input().split())
s = set(input())

if '##' in s[a-1:d]:
    print('No')
    exit()

if c < d:
    print('Yes')
    exit()

if '...' in s[b-2:d+1]:
    print('Yes')
else:
    print('No')
Problem p03127 (python)

Fixed submission:
import fractions
N = int(input())
al = list(map(int,input().split()))

ans = al[0]
for i in range(1,N):
    ans = fractions.gcd(ans, al[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
al = list(map(int,input().split()))

ans = al[0]
for i in range(1,N):
    ans = math.gcd(ans, al[i])
print(ans)
Problem p03745 (python)

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

if n == 1:
    print(1)
    exit()
    
if al[1] > al[0]:
    now = 'U'
elif al[1] < al[0]:
    now = 'D'
else:
    now = 'E'

cnt = 1
for i in range(2, n):
    if now == 'U':
        if al[i] > al[i-1] or al[i] == 'E':
            now = 'U'
        elif al[i] < al[i-1]:
            cnt += 1
            i += 1
            now = 'E'
    elif now == 'D':
        if al[i] < al[i-1] or al[i] == 'E':
            now = 'D'
        elif al[i] > al[i-1]:
            cnt += 1
            now = 'E'
    elif now == 'E':
        if al[i] == al[i - 1]:
            now = 'E'
        elif al[i] > al[i - 1]:
            now = 'U'
        elif al[i] < al[i - 1]:
            now = 'D'
print(cnt)

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

if al[1] > al[0]:
    now = 'U'
elif al[1] < al[0]:
    now = 'D'
else:
    now = 'E'

cnt = 1
for i in range(2, n):
    if now == 'U':
        if al[i] > al[i-1] or al[i] == 'E':
            now = 'U'
        elif al[i] < al[i-1]:
            cnt += 1
            i += 1
            now = 'E'
    elif now == 'D':
        if al[i] < al[i-1] or al[i] == 'E':
            now = 'D'
        elif al[i] > al[i-1]:
            cnt += 1
            now = 'E'
    elif now == 'E':
        if al[i] == al[i - 1]:
            now = 'E'
        elif al[i] > al[i - 1]:
            now = 'U'
        elif al[i] < al[i - 1]:
            now = 'D'
print(cnt)
Problem p03821 (python)

Fixed submission:
n = int(input())
ab = []
for _ in range(n):
    ab.append(list(map(int,input().split())))

cnt = 0
for i in range(n-1,-1,-1):
    a,b = ab[i][0],ab[i][1]
    num = a + cnt
    if num % b == 0:
        continue
    else:
        amari = num % b
        cnt += b-amari
    
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
al = []
bl = []
for i in range(N):
    a,b = map(int,input().split())
    al.append(a)
    bl.append(b)
al.reverse()
bl.reverse()

plus = 0
for i in range(N):
    if al[i]+plus > bl[i]:
        amari = (al[i]+plus) % bl[i]
        syo = (al[i]+plus) // bl[i]
        if amari != 0:
            syo += 1
        plus += bl[i] * syo - (al[i]+plus)

    elif al[i]+plus < bl[i]:
        amari = bl[i] % (al[i]+plus)
        syo = bl[i] // (al[i]+plus)
        if amari != 0:
            syo += 1
        plus += syo

    else:
        continue


print(plus)
Problem p02773 (python)

Fixed submission:
n = int(input())
s = list(input() for _ in range(n))
s.sort()
now = s[0]
ans = [s[0],]
cnt = 0
m_cnt = 0

for i in range(n):
    word = s[i]
    if word == now:
        cnt +=1
        if cnt > m_cnt:
            ans = [word,]
            m_cnt = cnt
        elif cnt == m_cnt:
            ans.append(word)
    else:
        cnt = 1
        now = word
        if cnt > m_cnt:
            ans = [word,]
            m_cnt = cnt
        elif cnt == m_cnt:
            ans.append(word)

for k in sorted(ans):
    print(k)

Buggy submission (verdict: Runtime Error):
n = int(input())
w = {}
for _ in range(n):
  	s = input()
    w[s] = w.get(s, 0) + 1
ans = sorted(i for i, j in w.items() if j == max(w.values()))
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
n = int(input())
w = {}
for _ in range(n):
    w[i] = w.get(input(), 0) + 1
ans = sorted(i for i, j in w.items() if j == max(w.values()))
for i in ans:
    print(i)
Problem p02989 (python)

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

d.sort()
result = d[int(N/2)]-d[int((N-1)/2)]
print(result)

Buggy submission (verdict: Runtime Error):
N = int(input().split())
d = list(map(int, input().split()))

d.sort()
result = d[int(N/2)]-d[int((N-1)/2)]
print(result)

Buggy submission (verdict: Runtime Error):
N = int(input().split())
d = list(map(int, input().split()))

d.sort()

if d[int((N-1)/2)] == d[int(N/2)]:
    result = 0
else:
    result = d[int(N/2)]-d[int((N-1)/2)]

print(result)

Buggy submission (verdict: Runtime Error):
N = int(input().split()
d = list(map(int, input().split()))

d.sort()

if d[int((N-1)/2)] == d[int(N/2)]:
    result = 0
else:
    result = d[int(N/2)]-d[int((N-1)/2)]

print(result)
Problem p03208 (python)

Fixed submission:
n, k = map(int, input().split())
h = [int(input()) for _ in range(n)]
h.sort()

for i in range(n-k+1):
    a = h[i+k-1]-h[i]
    ans = a if i == 0 else min(ans, a)

print(ans)

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

for i in range(n-k+1):
    a = h[i+k-1]-h[i]
    ans = a if i == 0 else min(ans, a)

print(ans)
Problem p03617 (python)

Fixed submission:
q, h, s, d = map(int, input().split())
n = int(input())

ans = n//2*min(8*q, 4*h, 2*s, d) + min(4*q, 2*h, s)*(n%2!=0)
print(ans)

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

ans = n//2*min(8*q, 4*h, 2*s, d) + min(4*q, 2*h, s)*(n%2!==0)
print(ans)
Problem p02726 (python)

Fixed submission:
n, x, y = map(int, input().split())
x -= 1
y -= 1

dists = [0] * (n-1)

for i in range(n):
    for j in range(i+1, n):
        d = min(
            abs(j-i),
            abs(i-x) + abs(y-j) + 1,
            abs(i-y) + abs(x-j) + 1
        )

        dists[d-1] += 1

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

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

maxi = 0

for i in range(1, n):
    x = a[i] - a[i-1]

    maxi = max(maxi, x)

x = a[-1] - a[0]

if k - x < x:
    x = k - x

maxi = max(maxi, x)

print(k - maxi)
Problem p02762 (python)

Fixed submission:
from sys import setrecursionlimit
setrecursionlimit(2 * 10 ** 9)

n, m, k = map(int, input().split())

def dfs(u):
    if visited[u]:
        return

    visited[u] = True

    for v in graph[u]:
        s.add(v)
        dfs(v)

graph = {i: set() for i in range(n)}
blocks = {i: set() for i in range(n)}

for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1

    graph[a].add(b)
    graph[b].add(a)

for _ in range(k):
    c, d = map(int, input().split())
    c -= 1
    d -= 1

    blocks[c].add(d)
    blocks[d].add(c)

ans = [0] * n

visited = [False] * n

for u in range(n):
    if not visited[u]:
        s = set()

        dfs(u)

        l = len(s)

        for i in s:
            ans[i] += l - 1
            ans[i] -= len(blocks[i].intersection(s))
            ans[i] -= len(graph[i].intersection(s))

print(*ans)

Buggy submission (verdict: Runtime Error):
from sys import setrecursionlimit
setrecursionlimit(10 ** 9)

n, m, k = map(int, input().split())

def dfs(u):
    if visited[u]:
        return

    visited[u] = True

    for v in graph[u]:
        s.add(v)
        dfs(v)

graph = {}

for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1

    graph[a] = graph.get(a, set())
    graph[a].add(b)

    graph[b] = graph.get(b, set())
    graph[b].add(a)

blocks = {}

for _ in range(k):
    c, d = map(int, input().split())
    c -= 1
    d -= 1

    blocks[c] = blocks.get(c, set())
    blocks[c].add(d)

    blocks[d] = blocks.get(d, set())
    blocks[d].add(c)

ans = [0] * n

visited = [False] * n

for u in range(n):
    if not visited[u]:
        s = set()

        dfs(u)

        l = len(s)

        for i in s:
            ans[i] += l - 1

            if i in blocks:
                ans[i] -= len(blocks[i].intersection(s))

            if i in graph:
                ans[i] -= len(graph[i].intersection(s))

print(*ans)

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

def dfs(u):
    if visited[u]:
        return

    visited[u] = True

    for v in graph[u]:
        s.add(v)
        dfs(v)

graph = {}

for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1

    graph[a] = graph.get(a, set())
    graph[a].add(b)

    graph[b] = graph.get(b, set())
    graph[b].add(a)

blocks = {}

for _ in range(k):
    c, d = map(int, input().split())
    c -= 1
    d -= 1

    blocks[c] = blocks.get(c, set())
    blocks[c].add(d)

    blocks[d] = blocks.get(d, set())
    blocks[d].add(c)

ans = [0] * n

visited = [False] * n

for u in range(n):
    if not visited[u]:
        s = set()

        dfs(u)

        l = len(s)

        for i in s:
            ans[i] += l - 1

            if i in blocks:
                ans[i] -= len(blocks[i].intersection(s))

            if i in graph:
                ans[i] -= len(graph[i].intersection(s))

print(*ans)
Problem p02762 (python)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.par = [-1] * n
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.find(x) > self.find(y):
            x, y = y, x
        self.par[x] += self.par[y]
        self.par[y] = x
    def size(self, x):
        return -self.par[(self.find(x))]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.par) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m, k = map(int, input().split())
a, b = [0] * m, [0] * m
c, d = [0] * k, [0] * k

direct =[[] for _ in range(n)]
uf = UnionFind(n)

for i in range(m):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1
    direct[a[i]].append(b[i])
    direct[b[i]].append(a[i])
    uf.union(a[i], b[i])

for i in range(k):
    c[i], d[i] = map(int, input().split())
    c[i] -= 1
    d[i] -= 1
    if uf.same(c[i], d[i]):
        direct[c[i]].append(d[i])
        direct[d[i]].append(c[i])

ans = [0] * n
for i in range(n):
    ans[i] = uf.size(i) - len(direct[i]) - 1

print(*ans)

Buggy submission (verdict: Runtime Error):
a, b = [0] * m, [0] * m
c, d = [0] * k, [0] * k

direct =[[] for _ in range(n)]
uf = UnionFind(n)

for i in range(m):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1
    direct[a[i]].append(b[i])
    direct[b[i]].append(a[i])
    uf.union(a[i], b[i])

for i in range(k):
    c[i], d[i] = map(int, input().split())
    c[i] -= 1
    d[i] -= 1
    if uf.same(c[i], d[i]):
        direct[c[i]].append(d[i])
        direct[d[i]].append(c[i])

ans = [0] * n
for i in range(n):
    ans[i] = uf.size(i) - len(direct[i]) - 1

print(*ans)
Problem p02771 (python)

Fixed submission:
lst = list(map(int, input().split()))
print('Yes' if len(set(lst)) == 2 else 'No')

Buggy submission (verdict: Runtime Error):
    lst = map(int, input().split())
    print('Yes' if len(set(lst)) >= 2 else 'No')

Buggy submission (verdict: Runtime Error):
lst = map(int, input().split())
print('Yes' if set(len(lst)) >= 2 else 'No')