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

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019
 
@author: Owner
"""
 
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:53:12 2019
 
@author: Owner
"""
 
from operator import itemgetter
import itertools
import collections
import bisect
 
N, M = list(map(int, input().split()))
 
A = list(map(int, input().split()))
A.sort()

A = collections.deque(A)

BC = [(0, 0)]*M
for m in range(M):
    BC[m] = tuple(map(int, input().split()))
BC.sort(key=itemgetter(1), reverse = True)
 
def main(): 
    #print(BC)
    res = 0
    for i in range(M):
        idx = 0         
        idx = bisect.bisect_left(A, BC[i][1])
        if idx == 0:
            break
        else:
            less =min(idx, BC[i][0])
            for n in range(less):
                A.popleft()
            res += BC[i][1]*less
 
    print(res+sum(A))
                
                
                
            
            
                
 
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:53:12 2019

@author: Owner
"""

from operator import itemgetter
import itertools
import bisect

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

A = list(map(int, input().split()))
A.sort()

BC = [(0, 0)]*M
for m in range(M):
    BC[m] = tuple(map(int, input().split()))
BC.sort(key=itemgetter(1), reverse = True)

def main(): 
    #print(BC)
    res = 0
    num = 0
    for i in range(M):
        idx = 0         
        idx = bisect.bisect_left(A, BC[i][1])
        if idx == 0:
            break
        else:
            less =min(idx, BC[i][0]) 
            num+=less
            res += BC[i][1]*less

    print(res+sum(A[num：]))
                
                
                
            
            
                

    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:53:12 2019

@author: Owner
"""

from operator import itemgetter
import itertools
import bisect

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

A = list(map(int, input().split()))
A.sort()

BC = [(0, 0)]*M
for m in range(M):
    BC[m] = tuple(map(int, input().split()))
BC.sort(key=itemgetter(1), reverse = True)

def main(): 
    #print(BC)
    res = 0
    num = 0
    for i in range(M):
        idx = 0         
        idx = bisect.bisect_left(A, BC[i][1])
        if idx == 0:
            break
        else:
            less =min(idx, BC[i][0]) 
            num += less
            res += BC[i][1]*less

    print(res+sum(A[num：]))
                
                
                
            
            
                

    
if __name__ == '__main__':
    main()
Problem p03250 (python)

Fixed submission:
# 整数の入力
A, B, C = map(int, input().split())

tmp_max = 10*A + B + C 

if tmp_max < 10*B + C +A:
    tmp_max = 10*B + C +A

if tmp_max < 10*C + A +B:
    tmp_max = 10*C + A +B

# 出力
print("{}".format(tmp_max))

Buggy submission (verdict: Runtime Error):
import time
import collections
import scipy.misc

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   

N, M = map(int, input().split())
t_strt = time.time() 

factors = collections.Counter(prime_decomposition(M))
t_elps = time.time()
#print(f"{t_elps - t_strt} [sec]")
num_pattern = 1;

for exponent in factors.values():
    tmp_num_pattern = scipy.misc.comb(exponent + N -1, N-1, exact = True) 
    num_pattern = num_pattern * int(tmp_num_pattern)
    
#print(num_pattern%(10**9+7))

t_elps = time.time()
print(f"{t_elps - t_strt} [sec]")
Problem p03253 (python)

Fixed submission:
import time
import collections
import scipy.misc

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   

N, M = map(int, input().split())
t_strt = time.time() 

factors = collections.Counter(prime_decomposition(M))
t_elps = time.time()
#print(f"{t_elps - t_strt} [sec]")
num_pattern = 1;

for exponent in factors.values():
    tmp_num_pattern = scipy.misc.comb(exponent + N -1, N-1, exact = True) 
    num_pattern = num_pattern * int(tmp_num_pattern)
    
print(num_pattern%(10**9+7))

Buggy submission (verdict: Runtime Error):
import time
import collections
import scipy.special

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   

N, M = map(int, input().split())
t_strt = time.time() 

factors = collections.Counter(prime_decomposition(M))
t_elps = time.time()
#print(f"{t_elps - t_strt} [sec]")
num_pattern = 1;

for exponent in factors.values():
    tmp_num_pattern = scipy.special.comb(exponent + N -1, N-1, exact = True) 
    num_pattern = num_pattern * int(tmp_num_pattern)
    
#print(num_pattern%(10**9+7))

t_elps = time.time()
print(f"{t_elps - t_strt} [sec]")

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

N, M = map(int, input().split())
factors = sympy.factorint(M)
print(factors)
num_pattern = 1;
for exponent in factors.values():
    if exponent < N:
        tmp_num_pattern = int(math.factorial(exponent + N -1) \
                            / (math.factorial(N-1)*math.factorial(exponent)))
    else:
        tmp_num_pattern = int(math.factorial(exponent + N -1) \
                            / (math.factorial(exponent)*math.factorial(N-1)))
        
    num_pattern = num_pattern * int(tmp_num_pattern)
print(int(num_pattern%(10**9 +7)))
Problem p03295 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun May 19 20:12:17 2019

@author: Owner
"""

from operator import itemgetter
import bisect

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


ab = [(0, 0)]*M
for m in range(M):
    ab[m] = tuple(map(int, input().split()))

ab = tuple(sorted(ab, key = itemgetter(1)))

#print(ab)
x_rm = -1
res = 0
for m in range(M):
    if ab[m][0] < x_rm:
        continue
    else:
        x_rm = ab[m][1]
        res += 1
    
    
        

print(res)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun May 19 20:12:17 2019

@author: Owner
"""

import numpy as np
from operator import itemgetter
import bisect

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


ab = [(0, 0)]*M
c = np.zeros(N)
for m in range(M):
    ab[m] = tuple(map(int, input().split()))

ab = tuple(sorted(ab, key = itemgetter(0)))

a = [0]*M
b = [0]*M
for m in range(M):
    a[m], b[m] = ab[m]
b.sort()
res = 0
n = -1
while True:
    tmp = bisect.bisect_left(a, n)
    
    n = b[bisect.bisect_right(b, a[tmp])]
    res+=1
    if n > a[m]:
        break
    
    
        

print(res)
Problem p02916 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
point = 0
for i in range(N):
    A[i] -= 1
    point += B[A[i]]
    if i > 0 and A[i - 1] + 1 == A[i]:
        point += C[A[i - 1]]
 
print(point)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
point = 0
for i in range(N):
    a[i] -= 1
    point += b[a[i]]
    if i > 0 and a[i - 1] + 1 == a[i]:
        point += c[a[i - 1]]
 
print(point)
Problem p02933 (python)

Fixed submission:
a, s = open(0).read().split()
if int(a) >= 3200:
  print(s)
else:
  print('red')

Buggy submission (verdict: Runtime Error):
a, s = open(0).read().split()
if a >= 3200:
  print('red')
else:
  print(a)

Buggy submission (verdict: Runtime Error):
a, s = input().split()
if a >= 3200:
  print('red')
else:
  print(a)
Problem p03041 (python)

Fixed submission:
N, K = map(int, input().split())
S = str(input())
ans = ""
for i in range(N):
  if i == K-1:
    ans += S[i].lower()
  else:
    ans += S[i]
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = str(input())
ans = ""
for i in range(0, K-1):
  ans += S[i]
ans += S[K].lower()
for j in range(K+1,N):
  ans += S[j]
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = str(input())
ans = ""
for i in range(0, K-1):
  ans.append(S[i])
ans.append(S[K].lower())
for j in range(K+1,N):
  ans.append(S[j])
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = str(input())
ans = []
for i in range(0, K-1):
  ans.append(S[i])
ans.append(S[K].lower())
for j in range(K+1,N):
  ans.append(S[j])
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = str(input())
S[K] = S[K].lower()
print(S)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = str(input())
S[K] = S[K].lower()
Problem p03315 (python)

Fixed submission:
S = str(input())
p = S.count('+') 
m = S.count('-')
print(p-m)

Buggy submission (verdict: Runtime Error):
----

Buggy submission (verdict: Runtime Error):
S = str(input())
p = S.count('+') 
m = S.sount('-')
print(p-m)
Problem p03631 (python)

Fixed submission:
N = str(input())
if N[0]==N[2]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N = map(str, input())
if N[0]==N[2]:
  print('Yes')
else:
  print('No')
Problem p02726 (python)

Fixed submission:
n, x, y = map(int, input().split())
ans = [0] * (n-1)
for i in range(1, n):
    for j in range(i+1, n+1):
        # iとjを固定、rangeでi<jを表現
        d = min(j-i, abs(x-i)+abs(j-y)+1, abs(y-i)+abs(x-j)+1)
        # 長さを示すところに+１
        ans[d-1] += 1
print(*ans, sep="\n")

Buggy submission (verdict: Runtime Error):
n, x, y = map(int, input().split())
ans = [0] * (n-1)
for i in range(1, n+1):
    for j in range(1, n+1):
        if i < j
            # iとjを固定、rangeでi<jを表現
            d = min(j-i, abs(x-i)+abs(j-y)+1, abs(y-i)+abs(x-j)+1)
            # 長さを示すところに+１
            ans[d-1] += 1
print(*ans, sep="\n")
Problem p03013 (python)

Fixed submission:
n, m = map(int, input().split())
dp = [0] * (10**5+10)
jud = [True]*(10**5)
for k in range(m):
    a = int(input())
    jud[a] = False

dp[0] = 1
if jud[1]:
    dp[1] = 1
else:
    dp[1] = 0

for i in range(2, n+1):
    if jud[i-1]:
        dp[i] += dp[i-1]
    if jud[i-2]:
        dp[i] += dp[i-2]
print(dp[n] % 1000000007)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
dp = [0] * (10**5)
jud = [True]*(n+1)
for k in range(m):
    a = int(input())
    jud[a] = False

dp[0] = 1
if jud[1]:
    dp[1] = 1
else:
    dp[1] = 0

for i in range(2, n+1):
    if jud[i-1]:
        dp[i] += dp[i-1]
    if jud[i-2]:
        dp[i] += dp[i-2]
print(dp[n] % 1000000007)
Problem p03038 (python)

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

bclist=sorted(bclist, key = lambda x:x[1], reverse=True)

all = []


for i in range(m):
    all.extend([bclist[i][1]]*bclist[i][0])
    if len(all) >n:
        break

all.extend(a)
all.sort(reverse=True)

print(sum(all[:n]))

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


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

a = list(map(int,input().split()))
bclist = [list(map(int,input().split())) for _ in range(m)]

a.sort()
bclist.sort(key=itemgetter(1))

last = 0

for bc in  reversed(bclist):
    for i in range(bc[0]):
        if bc[1] > a[last]:
            a[last] = bc[1]
            last += 1


print(sum(a))
Problem p02627 (python)

Fixed submission:
if input().isupper():
  print('A')
else:
  print('a')

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
num = [0] * (10 ** 5)

for a in A:
    num[a] += 1
_sum = sum(A)

result = []
q = int(input())
for i in range(q):
    b, c = list(map(int, input().split()))
    _sum += (c - b) * num[b]
    num[c] += num[b]
    num[b] = 0
    result.append(str(_sum))
print('\n'.join(result))
Problem p02659 (python)

Fixed submission:
a=input().split()

b=int(a[0])
lst=list(a[1])

del lst[-3]

c=""
for i in lst:
    c=c+i
c=int(c)

print (int(b*c//100))

Buggy submission (verdict: Runtime Error):
a=input().split()

a=[float(p) for p in a]

c=a*b*100
print (c//100)
Problem p02951 (python)

Fixed submission:
a, b, c = map(int, input().split())
c2 = c-(a-b)
if c2<0: c2=0
print(c2)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.reverse()
count = 0
for i in range(n-1):
    if a[i+1] > a[i]:
        a[i+1] -= 1
for i in range(n-1):
    if a[i+1]>a[i]:
        count +=1
if count == 0:
    print('Yes')
else:
    print('No')
Problem p03835 (python)

Fixed submission:
k, s = map(int, input().split())
p = 0
for x in range(0,k+1):
  for y in range(0,k+1):
    z = s - x - y
    if z >= 0 and z <= k:
      p += 1
print(p)

Buggy submission (verdict: Runtime Error):
k, s = map(int, input().split())
p = 0
for x in range(0,k+1):
  for y in range(0,k+1):
    for z in range(0,k+1):
      if (x+y+z) == s:
        p+=1
      if (x+y+z) >= s:
        break
    if (x+y+Z) >= s:
      break
print(p)
Problem p02699 (python)

Fixed submission:
from sys import stdin

s,w = [int(x) for x in stdin.readline().rstrip().split()]
print("safe" if s > w else "unsafe")

Buggy submission (verdict: Runtime Error):
from sys import stdin

s = int(stdin.readline().rstrip())

sl = len(str(s))
cnt = 0

for i in range(sl - 3):
    for j in range(i + 3, sl):
        num = s % (10 ** (sl - i)) // (10 ** (sl - j - 1))
        if num % 2019 == 0 and num > 0:
            cnt += 1

print(cnt)
Problem p02659 (python)

Fixed submission:
a, b = input().split()
a = int(a)
b = int(int(b[0])*100+0.1 + int(b[2])*10 + int(b[3]))
print(a*b // 100)

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

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
    n = int(input())
    cache = set()
    a = prime_factorize(n)
    tmp = 1
    ans = 0
    while a:
        x = a.pop()
        if tmp % x == 0:
            tmp *= x
        else:
            tmp = x
        if tmp in cache:
            continue
        cache.add(tmp)
        ans += 1
        tmp = 1


    print(ans)


main()
Problem p03107 (python)

Fixed submission:
s = input()

zero = s.count('0')
one = s.count('1')

print(2 * min(zero, one))

Buggy submission (verdict: Runtime Error):
s = input()

count = 0
while True:
    n = len(s)
    if n == 0 or sum(s) == 0 or sum(s) == n:
        break
    sn = s + '\n'
    for i in range(n):
        if sn[i-1] + sn[i] == '10' or sn[i-1] + sn[i] == '01':
            s = sn[:i-1] + sn[i+1:n]
            count += 1
            break

print(count * 2)
Problem p03127 (python)

Fixed submission:
n = int(input())

zombies = [int(c) for c in input().split()]


def gcd(a, b):
    c = a % b
    if c == 0:
        return b
    else:
        return gcd(b, c)


m = zombies[0]
for i in range(1, len(zombies)):
    m = gcd(m, zombies[i])

print(m)

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

zombies = [int(c) for c in input().split()]


def gcd(a, b):
    mod = a % b
    if mod == 0:
        return b
    else:
        return gcd(b, mod)


def saidai_koyakusu(n, ns):
    if len(ns) == 1:
        return ns[0]
    return gcd(n, saidai_koyakusu(ns[0], ns[1:]))


if len(zombies) == 1:
    print(zombies[0])
else:
    print(saidai_koyakusu(zombies[0], zombies[1:]))

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

zombies = [int(c) for c in input().split()]


def gcd(a, b):
    mod = a % b
    if mod == 0:
        return b
    else:
        return gcd(b, mod)


def saidai_koyakusu(n, ns):
    if len(ns) == 1:
        return ns[0]
    return gcd(n, saidai_koyakusu(ns[0], ns[1:]))


print(saidai_koyakusu(zombies[0], zombies[1:]))
Problem p03208 (python)

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

h.sort()

min_d = 1000000000
for i in range(n-k+1):
    d = h[i+k-1] - h[i]
    if d < min_d:
        min_d = d

print(min_d)

Buggy submission (verdict: Runtime Error):
n, k = [int(c) for c in input().split()]
h = [int(input()) for _ in range(n)]

h.sort()

min_d = 100000
for i in range(n-k+1):
    d = h[i+k] - h[i]
    if d < min_d:
        min_d = d

print(min_d)
Problem p02623 (python)

Fixed submission:
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
asum = [0]*(n+1)
bsum = [0]*(m+1)
for i in range(n):
	asum[i+1] = a[i] + asum[i]
for j in range(m): 
	bsum[j+1] = b[j] + bsum[j]
j = m
res = 0
for i in range(n+1):
	if asum[i] > k:
		break
	while asum[i] + bsum[j] > k:
		j-=1
	res = max(res,i+j)
print(res)

Buggy submission (verdict: Runtime Error):
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
asum = [0]*(n+1)
bsum = [0]*(m+1)
for i in range(n):
	asum[i+1] = a[i] + asum[i]
for j in range(m): 
	bsum[i+1] = b[j] + bsum[j]
j = m
res = 0
for i in range(n+1):
	if asum[i] > k:
		break
	while asum[i] + bsum[j] > k:
		j-=1
	res = max(res,i+j)
print(res)
Problem p02915 (python)

Fixed submission:

n = int(input())

print(pow(n, 3))

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

print(pow(n, 3)
Problem p02831 (python)

Fixed submission:
import fractions

a , b = map (int,input().split())
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import math

a , b = map (int,input().split())
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))
Problem p02832 (python)

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


if m == [i+1 for i in range(n)]:
    print(0)
elif 1 not in m:
    print(-1)
else:
    target = 1
    for i in m:
    
        if i == target:
            ans += 1
            target += 1

    print(n-ans)

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


if m == [i+1 for i in range(n)]:
    print(0)
elif 1 not in m:
    print(-1)
else:
    for i in m:
    
        if i == target:
            ans += 1
            target += 1

    print(n-ans)
Problem p02859 (python)

Fixed submission:
print(int(input())**2)

Buggy submission (verdict: Runtime Error):
print(int(input())*int(input()))

Buggy submission (verdict: Runtime Error):
r*r
Problem p03038 (python)

Fixed submission:
n, m =map(int,input().split())
A = list(map(int,input().split()))
BC = [tuple(map(int,input().split()))for i in range(m)]

A.sort()
BC.sort(key= lambda x : -x[1])


i = 0
for b, c in BC:
    for _ in range(b):
        if c <=  A[i] : break
        A[i] = c
        i += 1
        if i >= n: break
    else:continue
    break
print(sum(A))

Buggy submission (verdict: Runtime Error):
n, m =map(int,input().split())
A = list(map(int,input().split()))
BC = [tuple(map(int,input().split()))for i in range(m)]

A.sort()
BC.sort(key= lambda x : -x[1])


i = 0
for b, c in BC:
    for _ in range(b):
        if c <=  A[i] : break
        A[i] = c
        i += 1
        if i >= n: break
        else:continue
print(sum(A))

Buggy submission (verdict: Runtime Error):
n, m =map(int,input().split())
A = list(map(int,input().split()))
BC = [tuple(map(int,input().split()))for i in range(m)]

A.sort()
BC.sort(key= lambda x : -x[1])


i = 0
for b, c in BC:
    for _ in range(b):
        if c <=  A[i] : break
        A[i] = c
        i += 1
        if i >= n: break
    else:
        continue
print(sum(A))
Problem p03317 (python)

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

Buggy submission (verdict: Runtime Error):
n , k = map(int,input().split())
print((n-1)//(k-2)+1)
Problem p02659 (python)

Fixed submission:
[a,b] = list(map(str,input().split()))
b = b[:1] + b[2:]
print((int(a)*int(b))//100)

Buggy submission (verdict: Runtime Error):
[a,b] = list(map(str,input().split()))
b.rstrip(".")
print((a*b)//100)
Problem p03045 (python)

Fixed submission:
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * (n)

    def find(self, x):
        if self.par[x] == x:
            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 self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

n,m=map(int,input().split())
U=UnionFind(n)

for i in range(m):
  x,y,z=map(int,input().split())
  U.union(x-1,y-1)
ans=0
for i,j in enumerate(U.par):
  if i==j:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * (n)

    def find(self, x):
        if self.par[x] == x:
            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 self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

n,m=map(int,input().split())
U=UnionFind(n)

for i in range(m):
  x,y,z=map(int,input().split())
  U.union(x-1,y-1)
ans=0
for i,j in enamurate(U.par):
  if i==j:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * (n)

    def find(self, x):
        if self.par[x] == x:
            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 self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

n,m=map(int,input().split())
U=UnionFind(n)

for i in range(m):
  x,y,z=map(int,input().split())
  U.union(x-1,y-1)
ans=0
for i,j in ensmurate(U.par):
  if i==j:
    ans+=1
print(ans)
Problem p03207 (python)

Fixed submission:
n=range(int(input()))
a=[int(input()) for i in n]
print(sum(a)-max(a)//2)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for i in n]
print(sum(a)-max(a)/2)
Problem p03346 (python)

Fixed submission:
n=int(input())
a=[int(input()) for i in range(n)]

al= {}
ans=0
for ai in a:
  if ai - 1 in al.keys():
    al[ai]=al[ai-1]+1
    ans=max(ans,al[ai-1]+1)   
    del al[ai-1]
  else:
    al[ai]=0
    if ai + 1 in al.keys():
      del al[ai]
print(n-ans-1)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for i in range(n)]

al= {}
ds=[]
ans=0
for ai in a:
  ds=
  if ai - 1 in al.keys():
    al[ai]=al[ai-1]+1
    ans=max(ans,al[ai-1]+1)   
    del al[ai-1]
  else:
    al[ai]=0
    if ai + 1 in al.keys():
      del al[ai]
print(n-ans-1)