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

Fixed submission:
S = input()
S = list(S)

if len(set(S)) == 2:
    
    m = list(set(S))[0]
    n = list(set(S))[1]

    m_c, n_c = 0, 0
    c = False
    
    for i in range(len(S)):
        if S[i] == m:
            m_c += 1
        else:
            n_c += 1
            
    if m_c == n_c:
        c = True

    if c:
        print('Yes')
    else:
        print('No')

else:
    print('No')

Buggy submission (verdict: Runtime Error):
S = list(input())

if len(S) == 0:
    print('No')
else:
    c1 = (len(set(S)) == 2)

    m = list(set(S))[0]
    n = list(set(S))[1]

    m_c, n_c = 0, 0

    c2 = False

    if c1:
        for i in range(len(S)):
            if S[i] == m:
                m_c += 1
            else:
                n_c += 1
        if m_c == n_c:
            c2 = True

    if c1 and c2:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
S = list(input())

c1 = (len(set(S)) == 2)

m = list(set(S))[0]
n = list(set(S))[1]

m_c, n_c = 0, 0

c2 = False

if c1:
    for i in range(len(S)):
        if S[i] == m:
            m_c += 1
        else:
            n_c += 1
    if m_c == n_c:
        c2 = True
else:
    print('No')

if c1 and c2:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
S = list(input())
c1 = (len(set(S)) == 2)
m = list(set(S))[0]
n = list(set(S))[1]
m_c, n_c = 0, 0
c2 = False
if c1:
    for i in range(len(S)):
        if S[i] == m:
            m_c += 1
        else:
            n_c += 1
    if m_c == n_c:
        c2 = True

if c1 and c2:
    print('Yes')
else:
    print('No')
Problem p03208 (python)

Fixed submission:
N, K = map(int, input().split())
hs = [int(input()) for _ in range(N)]
hs_sort = sorted(hs)
diff_min = 1e10
for i in range(N-K+1):
    diff = hs_sort[i+K-1] - hs_sort[i]
    if diff <= diff_min:
        diff_min = diff
    else:
        continue
print(diff_min)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
hs = [int(input()) for _ in range(N)]
hs_sort = sorted(hs)
diff_min = 1e5
for i in range(N-K+1):
    diff = hs_sort[i+2] - hs_sort[i]
    if diff < diff_min:
        diff_min = diff
    else:
        continue
print(diff_min)
Problem p03221 (python)

Fixed submission:
N, M = map(int, input().split())
anses = [0] * M
pre = [0] * N
 
for idx in range(M):
    p, y = (int(x) for x in input().split())
    anses[idx] = [idx, p, y, 0]

anses = sorted(anses, key=lambda x: x[2])

for ans in anses:
    pre[ans[1]-1] += 1
    ans[3] = pre[ans[1]-1]

anses = sorted(anses, key=lambda x: x[0])

for ans in anses:
    print('{:0=6}{:0=6}'.format(ans[1], ans[3]))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
p = []
y = []
for i in range(M):
    p1,y1=[int(i) for i in input().split()]
    p.append(p1)
    y.append(y1)
for idx in range(M):
    ans[idx] = [idx, p[idx], y[idx]]
ans = sorted(ans, key=lambda x: x[1])
ans = sorted(ans, key=lambda x: x[2])
for idx in range(M):
    if idx == 0:
        ans[idx][2] = 1
    else:
        if ans[idx][1] == ans[idx-1][1]:
            ans[idx][2] = ans[idx-1][2] + 1
        else:
            ans[idx][2] = 1
ans = sorted(ans, key=lambda x: x[0])
for idx in range(M):
    print('{:0=6}{:0=6}'.format(ans[idx][1], ans[idx][2]))
Problem p02933 (python)

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

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

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

a.reverse()

answer = 0.0
for i in range(0, len(a)-1):
  a[i+1] = (a[i] + a[i+1]) / 2

print(a[len(a)-1])
Problem p02948 (python)

Fixed submission:
# D - Summer Vacation ★
from collections import defaultdict
from heapq import heappush, heappop

_input = list(map(int, input().split()))
n = _input[0]
m = _input[1]
jobs = defaultdict(list)

# かかる日数ごとに報酬をまとめる
for i in range(n):
    a, b = list(map(int, input().split()))
    if a <= m:
        jobs[a].append(b)

# M-1日目、M-2日目…と後ろから順に得られる報酬が多い仕事を割り振っていく
# ※日数制限があったほうが埋めやすいので
reward = 0
heapsort = []
for daysLeft in range(1, m + 1):
    if daysLeft in jobs:
        for b in jobs[daysLeft]:
            heappush(heapsort, -b)
    if len(heapsort) > 0:
        reward += -heappop(heapsort)
print(reward)

Buggy submission (verdict: Runtime Error):
# D - Summer Vacation

_input = list(map(int, input().split()))
n = _input[0]
m = _input[1]
jobs = dict()
for i in range(n):
    __input = list(map(int, input().split()))
    a = __input[0]
    b = __input[1]
    item = jobs[b] if b in jobs else list()
    item.append(a)
    item.sort(reverse=True)
    jobs[b] = item

sorted(jobs.items(), key=lambda j: -j[0])
reward = 0
while m > 0:
    for b, aList in jobs:
        if len(aList) > 0 and m >= aList[0]:
            reward += b
            aList.pop(0)
            jobs[b] = aList
            break
    m -= 1

print(reward)
Problem p02955 (python)

Fixed submission:
# E - Max GCD ★

def slvDivisor(summary):
    divisor = set()
    for d in range(1, int(summary ** 0.5) + 1):
        if summary % d == 0:
            divisor.add(d)
            divisor.add(summary // d)
    return divisor



input1 = list(map(int, input().split()))
n = input1[0]
k = input1[1]
a = list(map(int, input().split()))

# 和の約数を求める
sumA = sum(a)
divisor = slvDivisor(sumA)

# 各値を約数で割った際の余りも約数の整数倍（i倍とする）になるはず
# → ＋－する操作はその余りを他の値に移動して約数を作る操作になる
# → 余りが小さい値から大きい値へ余りを寄せていくのが効率的
# → 寄せきると約数 * i個、0 * (N - i)個の2ブロックに分かれる
# → 寄せきるまでの回数がk以下ならOK
for d in sorted(divisor, reverse=True):
    modA = [x % d for x in a]
    modA.sort()
    i = sum(modA) // d
    cnt = sum(modA[:-i])
    if cnt <= k:
        print(d)
        break

Buggy submission (verdict: Runtime Error):
# E - Max GCD
import sympy
import sys

def check(targetSet):

    # Aiを割り切れる整数を大きいものから順に、指定回数の値操作で実現可能か判定する
    for target in sorted(targetSet, reverse=True):
        ret = True
        incDecList = [[0, 0, 0]]
        for ai in a:
            dec = -(ai % target)
            inc = target + dec
            if min(inc, abs(dec)) > k:
                ret = False
                break
            updateList = list()
            for incDec in incDecList:
                if inc <= k:
                    updateList.append([incDec[0] + inc, incDec[1] + inc, incDec[2]])
                if abs(dec) <= k:
                    updateList.append([incDec[0] + dec, incDec[1], incDec[2] + dec])
            incDecList = updateList
        if ret:
            for incDec in incDecList:
                if incDec[0] == 0 and incDec[1] <= k:
                    print(target)
                    return

                
                
input1 = list(map(int, input().split()))
n = input1[0]
k = input1[1]
a = list(map(int, input().split()))

# Aiの合計値を素因数分解
a.sort(reverse=True)
sumFact = sympy.factorint(sum(a))
targetSet = {1}
for fact, power in sumFact.items():
    for i in range(power):
        for ele in list(targetSet):
            targetSet.add(ele * fact)
check(targetSet)
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()
if a >= 3200:
   print((s))
else:
  print('red')

Buggy submission (verdict: Runtime Error):
a = list(input())
s = list(input())
if a >= 3200:
   print('{}'format.(s))
else:
  print('red')
Problem p02933 (python)

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

if a >= 3200:
  print(b)
else:
  print('red')

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

if b >= 3200:
  print(a)
else:
  print("red")
Problem p03834 (python)

Fixed submission:
string = input()

ans = string.replace(',', ' ')
print(ans)

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

    ans = string.replace(',', ' ')
    print(ans)
Problem p02925 (python)

Fixed submission:
import sys
import time
from collections import deque

start = time.time()

input = sys.stdin.readline

n = int(input())
a = [deque([x for x in list(map(int, input().split()))]) for _ in range(n)]
nokori_games = n * (n - 1) / 2 
day = 1
r5000 = range(5000)
player_in_this_game = set()
rn = range(n)
for _ in r5000:
  for m in rn: #選手ごとに判定
    #整合性のある対戦組み合わせがあれば配列から消す
    #全員の判定が終わって試合が残っていたら1日増やす
    if m in player_in_this_game:
      #自分が既に試合が組まれている
      continue

    la = len(a[m])      
    if la: #選手に試合予定が残っている
      teki = a[m][0] #対戦相手
      jibun = m + 1 #自分
      teki_idx = teki - 1
      if teki_idx in player_in_this_game:
        #相手が既に試合に組まれている
        continue

      if a[teki_idx][0] == jibun: #対戦相手の予定も自分でかつ相手がこのターンで試合中ではない
        a[m].popleft() #自分の予定を消す
        a[teki_idx].popleft() #相手の予定を消す
        player_in_this_game.add(m) #自分を試合中にする
        player_in_this_game.add(teki_idx) #相手を試合中にする
        nokori_games -= 1 #残り試合予定を1つ減らす

  if nokori_games: #残り試合があるのに
    if not len(player_in_this_game): #今回対戦が組まれなければ残りの予定が不整合なのでエラー
      print(-1)
      sys.exit()
  else: #誰も残り試合予定がなければ終了
    print(day)
    sys.exit()
  day += 1
  player_in_this_game.clear()
  elapsed_time = time.time() - start
  if elapsed_time > 1:
    print(n*(n-1)//2)
    exit()

Buggy submission (verdict: Runtime Error):
import sys

n = int(input())

a = []
for i in range(n):
  v = list(map(int, input().split(' ')))
  a.append(v)

f = True
day = 1
while(f):
  done = []
  nokori_games = []
  
  for m in range(n):
    nokori_games[m] = len(a[m])
    if m in done:
      pass
    elif nokori_games[m]:
      teki = a[m][0]
      jibun = m + 1
      if not len(a[teki - 1]):
        print(-1)
        sys.exit()
      elif a[teki - 1][0] == jibun and teki - 1 not in done:
        a[m].pop(0)
        a[teki - 1].pop(0)
        done.append(m)
        done.append(teki - 1)
        nokori_games[m] -= 1
  if not sum(nokori_games):
    print(day)
    sys.exit()
  else:
    if not len(done):
      print(-1)
      sys.exit()
  day += 1

Buggy submission (verdict: Runtime Error):
import sys

n = int(input())

a = []
for i in range(n):
  v = list(map(int, input().split(' ')))
  a.append(v)

f = True
day = 1
while(f):
  done = []
  nokori = False
  for m in range(n):
    if m in done:
      pass
    elif len(a[m]):
      teki = a[m][0]
      jibun = m + 1
      if not len(a[teki - 1]):
        print(-1)
        sys.exit()
      elif a[teki - 1][0] == jibun and teki - 1 not in done:
        a[m].pop(0)
        a[teki - 1].pop(0)
        done.append(m)
        done.append(teki - 1)
      	if not nokori and len(a[m]):
          nokori = True
  if not nokori:
    for m in range(n):
      if len(a[m]):
        print(-1)
        sys.exit()
    print(day)
    sys.exit()
  day += 1
Problem p02990 (python)

Fixed submission:
from scipy.misc import comb

def c(a, b):
    return comb(a, b, exact=True)

n, k = map(int, input().split())
MOD = 10**9+7
memo = 0
for i in range(1, k+1):
    print((c(n-k+1, i) * c(k-1, i-1)) % MOD)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb

def c(a, b):
    return comb(a, b, exact=True)

n, k = map(int, input().split())
MOD = 10**9+7
memo = 0
for i in range(1, k+1):
    # tmp = c(n-k+i, i)
    # print(((tmp - memo) * c(k-1, i-1)) % MOD)
    # memo += tmp
    # memo %= MOD
    tmp = ((c(n-k+i, i) - memo) * c(k-1, i-1)) % MOD
    print(tmp)
    memo += tmp
    memo %= MOD
Problem p02959 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
res = 0
for i in range(n):
    res += min(a[i], b[i])
    b[i] = max(0, b[i] - a[i])
    res += min(b[i], a[i + 1])
    a[i + 1] = max(0, a[i + 1] - b[i])
print(res)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [*map(int, input().split())]
b = [*map(int, input().split())]
res = 0
for i in range(n):
    res += min(a[i], b[i])
    b[i] = max(0, b[i] - a[i])
    res += min(b[i], a[i + 1])
    a[i + 1] = max(0, a[i + 1] - b[i])
print(res)
Problem p03135 (python)

Fixed submission:
T, X = map(int,input().split())
print(T / X)

Buggy submission (verdict: Runtime Error):
import sys
N, M = map(int, input().split())
X = sorted(list(map(int,input().split())))
A = []
if M == 1:
    print(0)
    sys.exit()
for i in range(M - 1):
    dif = X[i + 1] - X[i]
    A.append(dif)
for i in range(N - 1):
    A.remove(max(A))
print(sum(A))
Problem p03137 (python)

Fixed submission:
import sys
N, M = map(int, input().split())
X = sorted(list(map(int,input().split())))
A = []
sum = 0
if N >= M:
    print(0)
    sys.exit()
else:
    for i in range(M - 1):
        A.append(X[i + 1] - X[i])
    A = sorted(A, reverse = True)
    for k in A[N - 1:]:
        sum += k
print(sum)

Buggy submission (verdict: Runtime Error):
import sys
N, M = map(int, input().split())
X = sorted(list(map(int,input().split())))
A = []
if M == 1:
    print(0)
    sys.exit()
for i in range(M - 1):
    dif = X[i + 1] - X[i]
    A.append(dif)
for i in range(N - 1):
    A.remove(max(A))
print(sum(A))

Buggy submission (verdict: Runtime Error):
import sys
N, M = map(int, input().split())
X = sorted(list(map(int,input().split())))
A = []
if M == 1:
    print(0)
    sys.exit()
for i in range(M - 1):
    dif = X[i + 1] - X[i]
    A.append(dif)
for i in range(N - 1):
    A.remove(max(A))
print(sum(A))
Problem p03835 (python)

Fixed submission:
k,s = map(int, input().split())
ans = 0
x = range(k + 1)
y = range(k + 1)
z = range(k + 1)


for i in x:
	for j in y:
			if 0 <= s - i - j <= k:
				ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
k,s = map(int, input().split())
ans = 0
x = range(k + 1)
y = range(k + 1)
z = range(k + 1)


for i in x:
	for j in y:
		for k in z:
			if s - i - j <= z and i + j + k == s:
				ans += 1

print(ans)
Problem p02933 (python)

Fixed submission:
n = int(raw_input())
s = raw_input().rstrip()
print s if n >= 3200 else "red"

Buggy submission (verdict: Runtime Error):
print s if int(raw_input()) >= 3200 else "red"
Problem p03041 (python)

Fixed submission:
N, K = list(map(int, input().split()))
S = input()
print(S[:K-1]+S[K-1].lower()+S[K:])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()
S[K-1] += 32
print(S)
Problem p02987 (python)

Fixed submission:
S = input()


list_S=list(S)

if list_S[0]==list_S[1] and list_S[2]==list_S[3] and list_S[0] != list_S[2]:
    print("Yes")
elif list_S[0]==list_S[2] and list_S[1]==list_S[3] and list_S[0] != list_S[1]:
    print("Yes")
elif list_S[0]==list_S[3] and list_S[1]==list_S[2] and list_S[0] != list_S[1]:
    print("Yes")
else:
    print("No")

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

for i in range(int(max(d)+1)):
    ABC=0
    ARC=0
    for j in range(int(N)):

        if d[j]<i:
            ABC+=1
        else:
            ARC+=1

    if ARC==ABC:
        ans+=1

print(ans)
Problem p03745 (python)

Fixed submission:
n = int(input())
a = [int(c) for c in input().split(' ')]
#a = [1 ,2 ,1 ,2 ,1 ,2 ,1 ,2 ,1]
l = len(a)
prev = None
c = 1
inc = None

for i in range(l):
    current = a[i]
    if i == 0 :
        continue
    if inc == None:
        if a[i] > a[i-1] :
            inc = True
        elif             a[i] < a[i - 1]:
            inc = False
        else:
            continue 
    elif inc == True:
        if a[i-1] < a[i]:
            pass
        elif a[i -1] > a[i]:
            c += 1
            inc = None
    elif inc == False:
        if a[i-1] > a[i]:
            pass
        elif a[i - 1] < a[i]:
            c += 1
            inc = None
print(c)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(c) for c in input().split(' ')]
prev = None
c = 1
inc = None

for i in range(l):
    current = a[i]
    if i == 0 :
        continue
    if inc == None:
        if a[i] > a[i-1] :
            inc = True
        elif             a[i] < a[i - 1]:
            inc = False
        else:
            continue 
    elif inc == True:
        if a[i-1] < a[i]:
            pass
        elif a[i -1] > a[i]:
            c += 1
            inc = None
    elif inc == False:
        if a[i-1] > a[i]:
            pass
        elif a[i - 1] < a[i]:
            c += 1
            inc = None
print(c)
Problem p02935 (python)

Fixed submission:
a = int(input())
n = list(map(int, input().split()))
s = sorted(n)[::-1]
for i in range(a-1) :
    x = s.pop()
    y = s.pop()
    s.append((x + y) / 2)
print(s[0])

Buggy submission (verdict: Runtime Error):
a = int(input())
n = list(map(int, input().split()))
for i in range(a-1) :
    x = s.pop()
    y = s.pop()
    s.append((x + y) / 2)
print(s[0])
Problem p03631 (python)

Fixed submission:
a,b,c = input()
print('Yes' if a == c else 'No')

Buggy submission (verdict: Runtime Error):
a,b,c = int(input())
print('Yes' if a == c else 'No')
Problem p03767 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A = sorted(A,reverse = True)
ans = 0
for i in range(1, 2*N, 2):
    ans += A[i]
print(ans)

Buggy submission (verdict: Runtime Error):
###ABC 012A
N = input()
A = list(map(int, input().split()))
A = sorted(A,reverse = True)
ans = 0
for i in range(1, 2*N, 2):
    ans += A[i]
print(ans)

Buggy submission (verdict: Runtime Error):
N = input()
A = list(map(int, input().split()))
A = sorted(A,reverse = True)
ans = 0
for i in range(1, 2*N, 2):
  ans += A[i]

Buggy submission (verdict: Runtime Error):
N = input()
A = list(map(int, input().split()))
A = sorted(A,reverse = True)
ans = 0
for i in range(1, 2*N, 2):
    ans += A[i]
Problem p02933 (python)

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

if a < 3200 :
    print('red')
else:
    print(s)

Buggy submission (verdict: Runtime Error):
  1 a = int(input())
  2 s = input()
  3
  4
  5 if a < 3200 :
  6     print('red')
  7 else:
  8     print(s)
Problem p02933 (python)

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

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

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

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

Fixed submission:
a, b, c = map(int, input().split())
left_in_c = c - (a -b )
if left_in_c <=0:
  left_in_c =0
print("{}".format(left_in_c));

Buggy submission (verdict: Runtime Error):
a = int(input())
c =0
for a in range(1,a+1):
  if ((len(str(a))% 2) == 1):
    c += 1 
print(c)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a, b, c = map(int, input().split())
left_in_c = c - (a -b )
if left_in_c < 0
	left_in_c = 0 
print("{}".format(left_in_c));

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a, b, c = map(int, input().split())
left_in_c = c - (a -b )
left_in_c = 0 if left_in_c < 0
print("{}".format(left_in_c));
Problem p03327 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
    
if __name__ == '__main__':
  i = int(input())
  if i >= 0 and 999 >= i:
    print('ABC')
  elif i > 999:
    print('ABD')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

def main(argv):
  i = int(argv[0])
  if i >= 0 and 999 >= i:
    print('ABC')
  elif i > 999:
    print('ABD')
    
if __name__ == '__main__':
  main(sys.argv[1:])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

def main(argv):
  i = int(argv[0])
  if i => 0 and 999 <= i:
    print('ABC')
  elif i > 999:
    print('ABD')
if __name__ == '__main__':
  main(sys.argv[1:])
Problem p02951 (python)

Fixed submission:
a, b, c = map(int, input().split())
print(max(c-a+b,0))

Buggy submission (verdict: Runtime Error):
a, b, c = map(input().split(), int)
print(c-a+b)
Problem p02987 (python)

Fixed submission:
s=list(input())
a='No'
if s[1]==s[2] and s[3]==s[0] and s[1]!=s[3] and s[1]!=s[0]:
  a='Yes'
elif s[1]==s[3] and s[2]==s[0] and s[1]!=s[2] and s[1]!=s[0]:
  a='Yes'
elif s[1]==s[0] and s[2]==s[3] and s[1]!=s[2] and s[1]!=s[3]:
  a='Yes'
print(a)

Buggy submission (verdict: Runtime Error):
N,k=map(int,input().split())
R=N-k
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
    
for i in range(1,k+1):
  a= cmb(k-1,i-1)
  b= cmb(R+1,i)
  print(a*b)
Problem p02935 (python)

Fixed submission:
N = int(input())
v = [int(vi) for vi in input().split()]
vv = [float(vf) for vf in v]
vv.sort()
ans = vv[0]
for i in range(1, N):
  ans = (ans + vv[i]) / 2
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
v = map(int, input().split())
vv = map(float, v)
vv.sort()
ans = vv[0]
for i in range(1, len(vv)):
  ans = (ans + vv[i]) / 2
print(ans)
Problem p03221 (python)

Fixed submission:
import sys
from collections import defaultdict
from copy import deepcopy

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

PY = []
for _ in range(M):
    PY.append(list(map(int, input().split())))

sorted_PY = deepcopy(PY)
sorted_PY.sort(key=lambda x: x[1])

p_count_dict = defaultdict(lambda: 0)
y_dict = {}

for py in sorted_PY:
    p_count_dict[py[0]] += 1
    y_dict[py[1]] = p_count_dict[py[0]]

for py in PY:
    # print(f'{py[0]:0>6}{y_dict[py[1]]:0>6}')
    print('{}{}'.format(str(py[0]).zfill(6), str(y_dict[py[1]]).zfill(6)))

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

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

PY = []
for _ in range(M):
    PY.append(list(map(int, input().split())))

sorted_PY = deepcopy(PY)
sorted_PY.sort(key=lambda x: x[1])

p_count_dict = defaultdict(lambda: 0)
y_dict = {}

for py in sorted_PY:
    p_count_dict[py[0]] += 1
    y_dict[py[1]] = p_count_dict[py[0]]

for py in PY:
    print(f'{py[0]:0>6}{y_dict[py[1]]:0>6}')
Problem p02933 (python)

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

if a < 3200:
    print('red')
else:
    print(s)

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <string>

using namespace std;

int main(){
  int a;
  string s;
  cin >> a >> s;
  if(a < 3200){
    cout << "red" << endl;
  }else{
    cout << s << endl;
  }
}
Problem p03108 (python)

Fixed submission:
# find-union

import sys
input = sys.stdin.readline

#木の根を求める
def find(x):
    if par[x] == x:
        return x
    else:
        return find(par[x])

#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)

    if x != y:
        #xとyの属している集合が異なるとき
        if rank[x] < rank[y]:
            par[x] = y
            size[y] += size[x]
        else:
            par[y] = x
            size[x] += size[y]
            if rank[x] == rank[y]:
                rank[x] += 1

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#################################

#初期化
n,m = map(int,input().split())

par = [0]*(n+1)     #親
for i in range(n):
    par[i] = i
rank = [1]*(n+1)    #深さ
size = [1]*(n+1)    #size[i]:iを根とするグループのサイズ

edge = [tuple(map(int,input().split())) for i in range(m)]
edge = edge[::-1]

res = []
for i in range(m):
    fi = find(edge[i][0])
    se = find(edge[i][1])
    if fi == se:
        res.append(0)
    else:
        res.append(size[fi]*size[se])
        unite(fi,se)
ass  = 0
for i in range(m):
    ass += res[m-1-i]
    print(ass)

Buggy submission (verdict: Runtime Error):
# find-union

import sys
input = sys.stdin.readline

#木の根を求める
def find(x):
    if par[x] == x:
        return x
    else:
        return find(par[x])

#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)

    if x != y:
        #xとyの属している集合が異なるとき
        if rank[x] < rank[y]:
            par[x] = y
            size[y] += size[x]
        else:
            par[y] = x
            size[x] += size[y]
            if rank[x] == rank[y]:
                rank[x] += 1

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#################################

#初期化
n,m = map(int,input().split())

par = [0]*n     #親
for i in range(n):
    par[i] = i
rank = [1]*n    #深さ
size = [1]*n    #size[i]:iを根とするグループのサイズ

edge = [tuple(map(int,input().split())) for i in range(m)]
edge = edge[::-1]

res = []
for i in range(m):
    fi = find(edge[i][0])
    se = find(edge[i][1])
    if fi == se:
        res.append(0)
    else:
        res.append(size[fi]*size[se])
        unite(fi,se)
ass  = 0
for i in range(m):
    ass += res[m-1-i]
    print(ass)