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

Fixed submission:
n,m = map(int,input().split())
lis = [[] for i in range(n)]
query = []

for num in range(m):
  tp = tuple(map(int,input().split()))
  query.append(tp)
  lis[tp[0]-1].append((tp[1],num))  

ans = [[0,0] for i in range(m)]

for num_p , pref in enumerate(lis):
  pref.sort(key = lambda tp:tp[0])
  for i,tp_city in enumerate(pref):
    ans[tp_city[1]][0] = num_p
    ans[tp_city[1]][1] = i+1

for item in ans:
  print("{:06}{:06}".format(item[0]+1,item[1]))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
lis = [[] for i in range(n)]
lnum = [0]*100001
query = []

for _ in range(m):
  tp = tuple(map(int,input().split()))
  query.append(tp)
  lis[tp[0]-1].append(tp[1])
  
for i in range(n):
  lis[i].sort()

for pref in lis:
  for i,city in enumerate(pref):
    lnum[city] = i+1
  
for item in query:
  print("{:06}{:06}".format(item[0],lnum[item[1]]))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
lis = [[] for i in range(n)]
lnum = [0]*100001
query = []

for _ in range(m):
  tp = tuple(map(int,input().split()))
  query.append(tp)
  lis[tp[0]-1].append(tp[1])
  
for i in range(n):
  lis[i].sort()

for pref in lis:
  for i,city in enumerate(pref):
    lnum[city] = i
  
for item in query:
  print("{:06}{:06}".format(item[0],lnum[item[1]]+1))
Problem p02835 (python)

Fixed submission:
a=input()
lst = [int(e) for e in a.split(' ')]

print('bust'if sum(lst)>=22 else 'win')

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
c=input()

print('bust'if a+b+c>=22 else 'win')

Buggy submission (verdict: Runtime Error):
return 'bust' if a+b+c>=22 else 'win'
Problem p02622 (python)

Fixed submission:
import numpy as np
s = np.array([ord(c) for c in input()])
t = np.array([ord(c) for c in input()])
print(np.count_nonzero(s - t))

Buggy submission (verdict: Runtime Error):
import numpy as np
s = np.array([ord(c) for c in input()])
t = np.array([ord(c) for c in input()])
print(np.count_nonzero(s - t))
Problem p02623 (python)

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

A = cumsum([0] + A)
B = cumsum([0] + B)
n_read = 0
l = len(B) - 1
for i, a in enumerate(A):
    if a > k:
        break
    for j, b in enumerate(B[l::-1]):
        if a + b <= k:
            l -= j
            n_read = max(n_read, i + l)
            break
print(n_read)

Buggy submission (verdict: Runtime Error):
@profile
def main():
    from numpy import cumsum
    n, m, k = list(map(int, input().split()))
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    A = cumsum([0] + A)
    B = cumsum([0] + B)
    n_read = 0
    b_tail = B[-1]
    for i, a in enumerate(A):
        if a > k:
            break
        j = m
        if b_tail + a > k:
            for j, b in enumerate(B):
                if a + b > k:
                    break
        n_read = max(n_read, i + j)
    print(n_read)
main()

Buggy submission (verdict: Runtime Error):
from collections import deque
n, m, k = [int(n) for n in input().split()]
A = deque([int(n) for n in input().split()])
B = deque([int(n) for n in input().split()])
dp = [0] * k

t, n = 0, 0
while True:
    a = A[0] if A else None
    b = B[0] if B else None
    if a and a < b:
        d = A.popleft()
    elif b:
        d = B.popleft()
    t += d
    if t > k:
        break
    n += 1
print(n)

Buggy submission (verdict: Runtime Error):
from collections import deque
n, m, k = [int(n) for n in input().split()]
A = deque([int(n) for n in input().split()])
B = deque([int(n) for n in input().split()])
dp = [0] * k

t, n = 0, 0
while True:
    a = A[0] if A else None
    b = B[0] if B else None
    if a and a < b:
        d = A.popleft()
    elif b:
        d = B.popleft()
    t += d
    if t > k:
        break
    n += 1
print(n)
Problem p02990 (python)

Fixed submission:
from math import factorial as f
n, blue = map(int, input().split())
red = n - blue
mod = 10 ** 9 + 7


def p(n, r):
    return f(n) // f(n-r)


def c(n, r):
    return p(n, r) // f(r)


for i in range(1, blue + 1):
    if red < i - 1:
        print(0)
    else:
        space = c(red + 1, i)
        pattern = c(blue - 1, blue - i)
        print(space * pattern % mod)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 7)
from math import factorial as f
n, blue = map(int, input().split())
red = n - blue
mod = 10 ** 9 + 7


def p(n, r):
    return f(n) // f(n-r)


def c(n, r):
    return p(n, r) // f(r)


for i in range(1, blue + 1):
    space = c(red + 1, i)
    pattern = c(blue - 1, blue - i)
    print(space * pattern % mod)

Buggy submission (verdict: Runtime Error):
from math import factorial as f
n, blue = map(int, input().split())
red = n - blue
mod = 10 ** 9 + 7


def p(n, r):
    return f(n) // f(n-r)


def c(n, r):
    return p(n, r) // f(r)


for i in range(1, blue + 1):
    space = c(red + 1, i)
    pattern = c(blue - 1, blue - i)
    print(space * pattern % mod)
Problem p03013 (python)

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

cnt = [1, 2]

for i in range(1, n - 1):
    cnt.append(cnt[i] + cnt[i - 1])

if m == 0:
    print(cnt[n - 1] % 1000000007)
    exit()

l = [int(input()) for _ in range(m)]

l_diff = [l[0] - 1]
for i in range(1, m):
    l_diff.append(l[i] - l[i - 1] - 2)
l_diff.append(n - l[m - 1] - 1)

for k in range(1, m):
    if l[k] - l[k - 1] == 1:
        print(0)
        exit()


total = 1
for j in l_diff:
    if j == 0:
        pass
    else:
        total *= cnt[j - 1]

print(total % 1000000007)

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


def fib(num):
    a, b = 0, 1
    for i in range(num):
        a, b = b, a + b
    return b


cnt = [fib(i) for i in range(1, n)]
if m == 0:
    print(cnt[n])
    exit()

l = [int(input()) for _ in range(m)]
l_diff = [l[0] - 1]
for i in range(1, m):
    l_diff.append(l[i] - l[i - 1] - 2)
l_diff.append(n - l[m - 1] - 1)

for k in range(1, m):
    if l[k] - l[k - 1] == 1:
        print(0)
        exit()


total = 1
for j in l_diff:
    if j == 0:
        pass
    else:
        total *= cnt[j - 1]

print(total % 1000000007)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
    
l = [int(input()) for _ in range(m)]
l_diff = [l[0] - 1]
for i in range(1, m):
    l_diff.append(l[i] - l[i - 1] - 2)
l_diff.append(n - l[m - 1] - 1)

for k in range(1, m):
    if l[k] - l[k - 1] == 1:
        print(0)
        exit()


def fib(num):
    a, b = 0, 1
    for i in range(num):
        a, b = b, a + b
    return b


cnt = [fib(i) for i in range(1, n)]
if m == 0:
    print(cnt[n])
    exit()

total = 1
for j in l_diff:
    if j == 0:
        pass
    else:
        total *= cnt[j - 1]

print(total % 1000000007)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
l = [int(input()) for _ in range(m)]
l_diff = [l[0] - 1]
for i in range(1, m):
    l_diff.append(l[i] - l[i - 1] - 2)
l_diff.append(n - l[m - 1] - 1)

for k in range(1, m):
    if l[k] - l[k - 1] == 1:
        print(0)
        exit()


def fib(n):
    a, b = 0, 1
    for i in range(n):
        a, b = b, a + b
    return b


cnt = [fib(i) for i in range(1, n)]
total = 1
for j in l_diff:
    if j == 0:
        pass
    else:
        total *= cnt[j - 1]

print(total % 1000000007)
Problem p03038 (python)

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
bc = [list(map(int, input().split())) for _ in range(m)]

bc.sort(reverse=True, key=lambda x:x[1])

i = 0
for b,c in bc:
    for j in range(i, min(n, i+b)):
        if a[j]<c:
            a[j] = c
    i = i+b
print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = []
for _ in range(m):
    b, c = map(int, input().split())
    bc.append([b, c])
a.sort()
bc.sort(reverse=True, key=lambda x: x[1])
cnt = 0
for i in range(m):
    for j in range(bc[i][0]):
        if bc[i][1] > a[cnt]:
            a[cnt] = bc[i][1]
            if cnt == n:
                break
            cnt += 1
        else:
            break
print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = []
for _ in range(m):
    b, c = map(int, input().split())
    bc.append([b, c])
a.sort()
bc.sort(reverse=True, key=lambda x: x[1])
cnt = 0
for i in range(m):
    for j in range(bc[i][0]):
        if bc[i][1] > a[cnt]:
            a[cnt] = bc[i][1]
            cnt += 1
        else:
            break
print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
bc = [map(int, input().split()) for _ in range(m)]

bc.sort(reverse=True, key=lambda x:x[1])

i = 0
for b,c in bc:
    for j in range(i, min(n, i+b)):
        if a[j]<c:
            a[j] = c
    i = i+b
print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
card = []

for _ in range(m):
    b, c = map(int, input().split())
    card += [c] * b
card.sort(reverse=True)

i = 0
while card[i] > a[i]:
    a[i] = card[i]
    i += 1

print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
s = sum(a)
card = []

for _ in range(m):
    b, c = map(int, input().split())
    card += [c] * b
card.sort(reverse=True)

i = 0
while card[i] > a[i]:
    s += card[i] - a[i]
    i += 1
    if i == n:
        break
print(s)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
s = sum(a)
card = []

for _ in range(m):
    b, c = map(int, input().split())
    card += [c] * b
card.sort(reverse=True)

i = 0
while card[i] > a[i]:
    s += card[i] - a[i]
    i += 1
print(s)
Problem p03137 (python)

Fixed submission:
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
diff = []
if m <= n:
    print(0)
    exit()
for i in range(1, m):
    diff.append(x[i] - x[i - 1])
diff.sort()
print(sum(diff[:m-n]))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
diff = []
if M <= N:
    print(0)

for i in range(1, m):
    diff.append(x[i] - x[i - 1])
diff.sort()
print(sum(diff[:m-n]))
Problem p03221 (python)

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

n, m = map(int, input().split())
l = []
num = [0] * n
ans = [""] * m

for i in range(m):
    p, y = map(int, input().split())
    l.append(list([p, y, i]))

l.sort()


for p, y, i in l:
    num[p - 1] += 1
    ans[i] = str(p).zfill(6) + str(num[p - 1]).zfill(6)

for a in ans:
    print(a)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline()

n, m = map(int, input().split())
city = [[0] for _ in range(n)]
buffer = []

for i in range(m):
    p, y = map(int, input().split())
    buffer.append(list([p, y]))
    city[p - 1].append(y)

for i in range(n):
    city[i].sort()

for i in range(m):
    p, y = buffer[i]
    print(str(p).zfill(6) + str(city[p - 1].index(y)).zfill(6))
Problem p03242 (python)

Fixed submission:
n = input()
print(n.translate(str.maketrans({'1': '9', '9': '1'})))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

import collections

n = int(input())
v_l = list(map(int, input().split()))

if len(set(v_l)) == 1:
    print(n // 2)
    exit()

v_l_odd = []
v_l_even = []

for i in range(n):
    if i % 2 == 0:
        v_l_odd.append(v_l[i])
    else:
        v_l_even.append(v_l[i])

max_odd = collections.Counter(v_l_odd)
mon = max_odd.most_common(1)[0][0]
max_even = collections.Counter(v_l_even)
men = max_even.most_common(1)[0][0]

if mon == men:
    if max(max_odd.most_common(2)[1][1], max_even.most_common(2)[1][1]) == max_odd.most_common(2)[1][1]:
        mon = max_odd.most_common(2)[1][1]
    else:
        men = max_even.most_common(2)[1][1]

v_l_odd_l = []
v_l_even_l = []

for i in range(n):
    if i % 2 == 0:
        if v_l[i] != mon:
            v_l_odd_l.append(v_l[i])
    else:
        if v_l[i] != men:
            v_l_even_l.append(v_l[i])

print(len(v_l_odd_l) + len(v_l_even_l))
Problem p03250 (python)

Fixed submission:
num = list(map(int, input().split()))
num.sort()
num.reverse()
m_ = int(str(num[0]) + str(num[1]))
_m = num[2]
sum_ = m_ + _m
print(sum_)

Buggy submission (verdict: Runtime Error):
s, t = [input() for _ in range(2)]

for i in range(len(s)):
    if s[i] == t[i]:
        pass
    else:
        s_diff = s[i]
        t_diff = t[i]
        s = s.translate(str.maketrans({s_diff: "", t_diff: ""}))
        t = t.translate(str.maketrans({s_diff: "", t_diff: ""}))
if s == t:
    print("Yes")
else:
    print("No")
Problem p02624 (python)

Fixed submission:
n=int(input())
ans =0
for i in range(1,n+1):
	for j in range(i,n+1,i) :ans+=j
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans =0
for i in range(1,n+1)
	for j in range(i,n+1,i) :ans+=j
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans =0
for i in range(1,n+1)
	for j in range(i,n+1,i) :ans+=j
print(ans)
Problem p02695 (python)

Fixed submission:
n, m, q = map(int, input().split())
A, B, C, D = [], [], [], []
for i in range(q):
    a, b, c, d = map(int, input().split())
    A.append(a - 1)
    B.append(b - 1)
    C.append(c)
    D.append(d)

L = []

def f(l):
    if len(l) == n:
        L.append(l)
        return
    for i in range(l[-1], m + 1):
        f(l + [i])

for i in range(1, m + 1):
    f([i])

ans = 0

for l in L:
    ans = max(ans, sum(d for a, b, c, d in zip(A, B, C, D) if l[b] - l[a] == c))

print(ans)

Buggy submission (verdict: Runtime Error):
 n, m, q = map(int, input().split())
 T = []
 for i in range(q):
     a, b, c, d = map(int, input().split())
     T.append((a-1, b-1, c, d))
 
 L = []
 def f(l):
     if len(l) == n+1:
         L.append(l[1:])
         return
     for i in range(l[-1], m + 1):
         f(l + [i])
	f([1])
 
 print(max(sum(d for a, b, c, d in T if l[b] - l[a] == c)) for l in L)
Problem p02793 (python)

Fixed submission:
from functools import reduce
import fractions


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


n = int(input())
a = list(map(int, input().split()))
l = lcm_list(a)
ans = sum([l // x for x in a]) % int(1e9+7)
print(ans)
# print(l)
# print(a)

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


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


n = int(input())
a = list(map(int, input().split()))
l = lcm_list(a)
ans = sum([l // x for x in a]) %
int(1e9+7)
print(ans)
# print(l)
# print(a)
Problem p03017 (python)

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

a,b,c,d=a-1,b-1,c-1,d-1
if a > b:
    a, b, c, d = b, a, d, c


if '##' in s[a:c] or '##' in s[b:d]:print('No')
else:
    if c < d:
        print('Yes')

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

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


if a > b:
    a, b, c, d = b, a, d, c

def search(start, goal):
    for i in range(start+1, goal - 2):
        if s[i] + s[i + 1] == '##': return False
    return True


def search3(start, goal):
    for i in range(start, goal -3):
        if s[i] + s[i + 1]+[i+2] == '...': return True
    return False
if c < b:
    if search(a,c) and search(b,d):print('Yes')
    else:print('No')

else:
    if search3(b-1,d+1):print('Yes')
    else:print('No')

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


if a > b:
    a, b, c, d = b, a, d, c

def search(start, goal):
    for i in range(start+1, goal - 2):
        if s[i] + s[i + 1] == '##': return False
    return True


def search3(start, goal):
    for i in range(start, goal -2):
        if s[i] + s[i + 1]+[i+2] == '...': return True
    return False
if c < b:
    if search(a,c) and search(b,d):print('Yes')
    else:print('No')

else:
    if search3(b-1,d+1):print('Yes')
    else:print('No')
Problem p03127 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
# a.sort()
# now = a[0]
# for i in range(1, n):
#     if (a[i] % now != 0):
#         now = a[i] % now
# print(now)
import fractions
from functools import reduce
print(reduce(fractions.gcd,a))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
# a.sort()
# now = a[0]
# for i in range(1, n):
#     if (a[i] % now != 0):
#         now = a[i] % now
# print(now)
import math
from functools import reduce
print(reduce(math.gcd,a))
Problem p03252 (python)

Fixed submission:
s = input()
t = input()
snum = []
tnum = []
for c in range(ord('a'), ord('z') + 1):
    snum.append([i for i, x in enumerate(s) if x == chr(c)])
for c in range(ord('a'), ord('z') + 1):
    tnum.append([i for i, x in enumerate(t) if x == chr(c)])
snum.sort()
tnum.sort()
print('Yes' if snum == tnum else 'No')

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
# snum = []
# tnum = []
# for c in range(ord('a'), ord('z') + 1):
#     snum.append([i for i, x in enumerate(s) if x == chr(c)])
# for c in range(ord('a'), ord('z') + 1):
#     tnum.append([i for i, x in enumerate(t) if x == chr(c)])
# snum.sort()
# tnum.sort()
# print('Yes' if snum == tnum else 'No')


sn=[0 for i in range(26)]
tn=[0 for i in range(26)]
for i in range(len(s)):
    sn[ord(s[i])]+=1
    tn[ord(t[i])]+=1
print('Yes' if sorted(sn) == sorted(tn) else 'No')
Problem p03317 (python)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(1, n, k - 1):
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int, input().split())
a=map(int, input().split())
print(N-K+1)
Problem p02777 (python)

Fixed submission:
s1, s2 = input().split()
a1, a2 = [int(i) for i in input().split()]
s = input()

if s1 == s:
  print(a1 - 1, a2)
elif s2 == s:
  print(a1, a2 - 1)
else:
  print(a1, a2)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
n_str = input()
k = int(input())

def k1(n_str):
	n_str = str(int(n_str))
	n_len = len(n_str)
	return 9*(n_len-1) + int(n_str[0])

def k2(n_str):
    s = 0
    n_str = str(int(n_str))
    n_len = len(n_str)
    if n_len < 2:
        return 0
    s += k2('9'*(n_len - 1))
    s += k1('9'*(n_len - 1)) * (int(n_str[0]) - 1)
    s += k1(n_str[1:])
    return s
                      
def k3(n_str):
    s = 0
    n_str = str(int(n_str))
    n_len = len(n_str)
    if n_len < 3:
        return 0
    s += k3('9'*(n_len - 1))
    s += k2('9'*(n_len - 1)) * (int(n_str[0]) - 1)
    s += k2(n_str[1:])
    return s

if k == 1:
    print(k1(n_str))
elif k == 2:
    print(k2(n_str))
elif k == 3:
    print(k3(n_str))

Buggy submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split(' ')]
input_list = [int(i) for i in input().split(' ')]
 
maximum = sum(input_list[:k])
s = sum(input_list[:k])
for i in range(1, n-k+1):
  s = s - input_list[i-1] + input_list[i+k-1]
  maximum = max(maximum, s)

print( (maximum + k) / 2 )
Problem p02779 (python)

Fixed submission:
input_length = int(input())
length = len(list(set([int(i) for i in input().split(' ')]))) 
 
if length == input_length:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
input_length = int(input())
length = len(list(set([int(i) for i in input.split(' ')]))) 

if length == input_length:
  print('YES')
else:
  print('NO')
Problem p03208 (python)

Fixed submission:
N,K=map(int,input().split())
h=[int(input()) for i in range(N)]
h.sort()
m=100000000000000
for i in range(N-K+1):
    m=min(m,h[i+K-1]-h[i])
print(m)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
h=[int(input()) for i in range(N)]
h.sort()
m=1000000
for i in range(N-K+1):
    m=min(m,max(h[i:K+1])-min(h[i:K+1]))
print(m)
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
    ans += 1 if z>=0 and z<=k else 0
print(ans)

Buggy submission (verdict: Runtime Error):
k,s=map(int,input().split())
ans=0
for x in range(k+1):
  for y in range(k+1):
    z=s-x+y
    ans += 1 if z>=0 and z<=k
print(ans)
Problem p02762 (python)

Fixed submission:
class UnionFind():
 def __init__(self, n):
  self.n = n
  self.parents = [-1] * n

 def find(self, x):
  if self.parents[x] < 0:
   return x
  else:
   self.parents[x] = self.find(self.parents[x])
   return self.parents[x]

 def union(self, x, y):
  x = self.find(x)
  y = self.find(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 size(self, x):
  return -self.parents[self.find(x)]
 def same(self, x, y):
  return self.find(x) == self.find(y)

N,M,K = map(int,input().split())
uf = UnionFind(N)
lst=[0]*(N)
ans=[0]*(N)
for i in range(M):
 A,B=map(int,input().split())
 uf.union(A-1,B-1)
 lst[A-1]+=1
 lst[B-1]+=1
for i in range(K):
 A,B=map(int,input().split())
 if uf.same(A-1,B-1):
  lst[A-1]+=1
  lst[B-1]+=1
for i in range(N):
 ans[i]=uf.size(i)-lst[i]-1
L=[str(a) for a in ans]
L=' '.join(L)
print(L)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
if self.parents[x] < 0:
   return x
  else:
   self.parents[x] = self.find(self.parents[x])
   return self.parents[x]

 def union(self, x, y):
  x = self.find(x)
  y = self.find(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 size(self, x):
  return -self.parents[self.find(x)]
 def same(self, x, y):
  return self.find(x) == self.find(y)

N,M,K = map(int,input().split())
uf = UnionFind(N)
lst=[0]*(N)
ans=[0]*(N)
for i in range(M):
 A,B=map(int,input().split())
 uf.union(A-1,B-1)
 lst[A-1]+=1
 lst[B-1]+=1
for i in range(K):
 A,B=map(int,input().split())
 if uf.same(A-1,B-1):
  lst[A-1]+=1
  lst[B-1]+=1
for i in range(N):
 ans[i]=uf.size(i)-lst[i]-1
L=[str(a) for a in ans]
L=' '.join(L)
print(L)
Problem p02769 (python)

Fixed submission:
mod=10**9+7
comb1=1
comb2=1
N,K=map(int,input().split())
k=min(K,N-1)
x=0
for i in range(k):
 comb1=(comb1*(N-i)*pow(i+1,mod-2,mod))%(mod)
 comb2=(comb2*(N-1-i)*pow(i+1,mod-2,mod))%(mod)
 x+=(comb1*comb2)%(mod)
print((x+1)%(mod))

Buggy submission (verdict: Runtime Error):
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])

    return result

N,K=map(int,input().split())
k=min(K,N-1)
x=0
A=[0]*(k+1)
B=[0]*(k+1)
for i in range(k+1):
 B[i]=cmb(N-1,i)%(10**9+7)
 A[i]=cmb(N,i)%(10**9+7)
for i in range(k+1):
 x+=(A[i]*b[i])%(10**9+7)
print(x%(10**9+7))
Problem p02833 (python)

Fixed submission:
N= int(input())
if N%2==1:
 print(0)
else:
 a=0
 i=0
 while (5**i)*2<=N:
  i+=1
  b=(5**i)*2
  a+=(N//b)
 print(a)

Buggy submission (verdict: Runtime Error):
N= int(input())
if N%2==1:
 print(0)
else:
 a=0
 i=0
 while (5**i)*2<=N:
  i+=1
  b=(5**i)*2
  a+=(N//b)
print(a)

Buggy submission (verdict: Runtime Error):
N= int(input())
if N%2==1:
 print(0)
else:
 N/=2
 a=0
 i=0
 while (5**i)<=N:
  i+=1
  b=5**i
  a+=(N//b)
print(a)

Buggy submission (verdict: Runtime Error):
N= int(input())
if N%2==1:
 print(0)
else:
 N/=2
 a=0
 i=0
 while (5**i)<=N:
  i+=1
  a+=int(N/(5**i))
print(a)