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

Fixed submission:
sa = str(input())
sb = str(input())
sc = str(input())
sa_count = 0
sb_count = 0
sc_count = 0
tmp = 'a'

for _ in range(300):
    if tmp=='a':
        sa_count += 1
        if sa_count==len(sa)+1:
            print('A')
            break
        else:
            tmp = str(sa[sa_count-1])
    elif tmp=='b':
        sb_count += 1
        if sb_count==len(sb)+1:
            print('B')
            break
        else:
            tmp = str(sb[sb_count-1])
    elif tmp=='c':
        sc_count += 1
        if sc_count==len(sc)+1:
            print('C')
            break
        else:
            tmp = str(sc[sc_count-1])

Buggy submission (verdict: Runtime Error):
sa = str(input())
sb = str(input())
sc = str(input())
sa_count = 0
sb_count = 0
sc_count = 0
lst = [sa,sb,sc]
count = [sa_count,sb_count,sc_count]
k = 0
abc = 'abc'
flag = False

for _ in range(len(sa)+len(sb)+len(sc)):
    for i in range(3):
        if lst[k][count[k]]==abc[i]:
            count[k] += 1
            count[i] += 1
            k = i
            if count[k]==len(lst[k])+1:
                flag = True
                break
    if flag:
        break

print(abc[k].upper())

Buggy submission (verdict: Runtime Error):
sa = str(input())
sb = str(input())
sc = str(input())
sa_count = 0
sb_count = 0
sc_count = 0
lst = [sa,sb,sc]
count = [sa_count,sb_count,sc_count]
k = 0
abc = 'abc'
flag = False

for _ in range(len(sa)+len(sb)+len(sc)):
    for i in range(3):
        if lst[k][count[k]]==abc[i]:
            count[i] += 1
            if len(lst[k])==count[k]:
                flag = True
                break
            else:
                k = i
    if flag:
        break

print(abc[k].upper())
Problem p04030 (python)

Fixed submission:
s = str(input())
lst = []

for i in range(len(s)):
    if s[i]=='B':
        if len(lst)!=0:
            del lst[-1]
        else:
            continue
    else:
        for j in range(2):
            if int(s[i])==j:
                lst.append(str(j))

print(''.join(lst))

Buggy submission (verdict: Runtime Error):
s = str(input())
lst = []

for i in range(len(s)):
    if s[i]=='B' and len(lst)!=0:
        del lst[-1]
    else:
        for j in range(2):
            if int(s[i])==j:
                lst.append('{}'.format(j))

print(''.join(lst))
Problem p02555 (python)

Fixed submission:
n = int(input())
s = n // 3

def cmb2(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10**9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


total = 0
for i in range(s):
  y = n - 3*(i+1)
  x = cmb2(y+i,i,p)
  total = (total + x) % (10**9+7)
  
print(total)

Buggy submission (verdict: Runtime Error):
import sys
n = int(input())
ans = [0]*(n+1) #ans[k]:入力値kでの答え
#初期値３、４、５
ans[3] = 1
ans[4] = 1
ans[5] = 1

if n == 1 or n == 2:
  print(0)
  sys.exit()
  
if 3<= n <=5:
  print(1)
  sys.exit()
for i in range(6,n+1):
  start = 3
  stop = i-3
  s = 1
  for j in range(start,stop+1):
    s = (s+ans[j]) % (10**9+7)
    
  ans[i] = s
  
print(ans[-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = [0]*(n+1) #ans[k]:入力値kでの答え
#初期値３、４、５
ans[3] = 1
ans[4] = 1
ans[5] = 1

for i in range(6,n+1):
  start = 3
  stop = i-3
  s = 1
  for j in range(start,stop+1):
    s = (s+ans[j]) % (10**9+7)
    
  ans[i] = s
  
print(ans[-1])
Problem p02579 (python)

Fixed submission:
import sys
from collections import deque
h,w = map(int,input().split())
sx,sy = map(int,input().split())
sx -= 1
sy -= 1
gx,gy = map(int,input().split())
gx -= 1
gy -= 1
route = []
for i in range(h):
  lst = list(input())
  route.append(lst)
  
brock = [['#']*w for i in range(h)]

que = deque([])
dx = [-1,0,1,0]
dy = [0,-1,0,1]

brock[sx][sy] = 0
que.append((sx,sy))



while que:
  
  (p,q) = que.popleft()
  if (p,q) == (gx,gy):
    print(brock[gx][gy])
    sys.exit()
  for i in range(4):
    p2,q2 = p+dx[i],q+dy[i]
    if 0 <= p2 < h and 0<= q2 < w and route[p2][q2] == '.' and (brock[p2][q2] == '#' or brock[p2][q2] > brock[p][q]):
      brock[p2][q2] = brock[p][q]
      que.appendleft((p2,q2))
  
  for j in range(-2,3):
    for k in range(-2,3):
      p3 = p+j
      q3 = q+k
      if 0 <= p3 < h and 0<= q3 < w and route[p3][q3] == '.' and brock[p3][q3] == '#':
        brock[p3][q3] = brock[p][q]+1
        que.append((p3,q3))
        
        
            
                  
              
print(-1)

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
sx,sy = map(int,input().split())
sx -= 1
sy -= 1
gx,gy = map(int,input().split())
gx -= 1
gy -= 1
route = []
for i in range(h):
  lst = list(input())
  route.append(lst)
  
brock = [['#']*w for i in range(h)]
s = 0
que = deque([])
dx = [-1,0,1,0]
dy = [0,-1,0,1]

brock[sx][sy] = 0
que.append((sx,sy))
lst = [(sx,sy)]


while que:
  
  (p,q) = que.popleft()
  if (p,q) == (gx,gy):
    print(brock[gx][gy])
    sys.exit()
  for i in range(4):
    p2,q2 = p+dx[i],q+dy[i]
    if 0 <= p2 < h and 0<= q2 < w and route[p2][q2] == '.' and brock[p2][q2] == '#':
      brock[p2][q2] = brock[p][q]
      que.append((p2,q2))
      lst.append((p2,q2))
  
  if len(que) == 0:
    
    s += 1
    for u in range(h):
      for v in range(w):
        if brock[u][v] == s-1:
          x,y = u,v
          for j in range(-2,3):
             for k in range(-2,3):
                x2 = x+j
                y2 = y+k
                if 0 <= x2 < h and 0<= y2 < w and route[x2][y2] == '.' and brock[x2][y2] == '#':
                  brock[x2][y2] = s
                  que.append((x2,y2))
            
                  
              
print(-1)
Problem p02584 (python)

Fixed submission:
x,k,d = map(int,input().split())

min_p = abs(x)//d
min_n = min_p + 1
rest_p = abs(x)- d*min_p
rest_n = rest_p - d

if k < min_p:
  print(abs(x) - k*d)
elif (k-min_p) % 2 == 0:
  print(rest_p)
else:
  print(abs(rest_n))

Buggy submission (verdict: Runtime Error):
x,k,d = map(int,input().split())
if x >= 0:
  min_p = x//d
  min_n = min_p + 1
  rest_p = x- d*min_p
  rest_n = rest_p - d
  if (k-min_p) % 2 == 0:
    print(rest_p)
  else:
    print(abs(rest_n))
    
if x <0:
  min_n = abs(x)//d
  min_p = min_p + 1
  rest_n = x + d*min_p
  rest_p = rest_p + d
  if (k-min_p) % 2 == 0:
    print(rest_p)
  else:
    print(abs(rest_n))
Problem p02639 (python)

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

for x in lst:
  if x == 0:
    s = lst.index(x) + 1
    
print(s)

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

lst = sorted(lst)
bol = [True]*n
s=0
for i in range(n-1):
  if bol[i] == True:
    bol[i] = False
    if lst[i] != lst[i+1]:
      s += 1
    
    for j in range(i+1,n):
      if bol[j] == True and lst[j] % lst[i] == 0:
        bol[j] = False

if bol[n-1] == True:
  s += 1
  
print(s)
Problem p02681 (python)

Fixed submission:
S = input()
T = input()
if len(T) == len(S) + 1 and T[:len(S)] == S:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
L = list(map(int,input().split()))
X = [0]*(n+1)
X[0] = 1
for i in range(n):
  if L[X[i]-1] in X:
    X[i+1] = L[X[i]-1]  
    break
  X[i+1] = L[X[i]-1]
    
def f(lst,value):
  return [i for i,x in enumerate(lst) if x == value]
for x in X:
  if X.count(x) == 2:
    a = f(X,x)
    X_ans = X[a[0]:a[1]]
    break

if k <= a[0]:
  print(X[k])
else:
  b = (k - a[0] + 1) % (a[1]-a[0])
  print(X_ans[b-1])
Problem p02705 (python)

Fixed submission:
import math
a = input()
b = math.pi
print(2*int(a)*b)

Buggy submission (verdict: Runtime Error):
N ,K =(int(x) for x in input().split(' '))

s = 0

for a in range(K,N+2) :
  
  SUM1 = sum([x for x in range(0,a)])
  SUM2 = sum([x for x in range(N-a+1, N+1)])
  
  s = s + SUM2 - SUM1 + 1
  
print(s%10**9+7)

Buggy submission (verdict: Runtime Error):
N ,K =(int(x) for x in input().split(' '))

s = 0

for a in range(K,N+2) :
  
  SUM1 = sum([x for x in range(0,a)])
  SUM2 = sum([x for x in range(N-a+1, N+1)])
  
  s = s + SUM2 - SUM1 + 1
  
  print(s%10**9+7)

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

List1 = [int(a) for a in input().split(" ")]
List2 = [0]*N

for x in List1:
  List2[x-1] = List2[x-1] + 1
  
for y in List2:
  print(y)

Buggy submission (verdict: Runtime Error):
N,M = (int(x) for x in input().split(" "))
List= [int(y) for y in input().split(" ")]

if sum(List)>N:
  print(-1)
else:
  print(N -sum(List))
Problem p02720 (python)

Fixed submission:
import sys
k = int(input())
lst = [[0]*10 for i in range(10)]
for i in range(10):
  lst[0][i] = 1
l_sum = [9]  


for i in range(1,10):
  s = 0
  for j in range(10):
    if j == 0:
      lst[i][j] = lst[i-1][j] + lst[i-1][j+1]
    elif j == 9:
      lst[i][j] = lst[i-1][j] + lst[i-1][j-1] 
    else:
      lst[i][j] = lst[i-1][j-1] + lst[i-1][j] + lst[i-1][j+1] 
      
    if j !=0:
      s += lst[i][j]
  l_sum.append(s+l_sum[-1])
    

#表を逆から辿っていく、さらに手直し
i = 0
if k < l_sum[0]:
  print(k)
  sys.exit()
else:
  while True:
    if k < l_sum[i]:
      break
    i += 1
  k = k - l_sum[i-1]
   
  ans = []
  for j in reversed(range(0, i+1)):
    
    if j == i:
      p = 1
      while True:
        if k - lst[j][p] <= 0:
          ans.append(p)
          break
        else:
          k -= lst[j][p]
          p += 1
          
    else:
      if p == 0:
        if k <= lst[j][p]:
          ans.append(p)
        else:
          k -= lst[j][p]
          p += 1
          ans.append(p)
          
      elif p == 9:
        if k <= lst[j][p-1]:
          p = p-1
          ans.append(p)
        else:
          k -= lst[j][p-1]
          ans.append(p)
          
      else:
        if k <= lst[j][p-1]:
          p = p-1
          ans.append(p)
        else:
          k -= lst[j][p-1]
          if k <= lst[j][p]:
            ans.append(p)
          else:
            k -= lst[j][p]
            p = p+1
            ans.append(p)
              
l_s = [str(q) for q in ans]
print(''.join(l_s))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
lst = list(map(int,input().split()))
s = 0
total = sum(lst)
for i in range(n):
  if lst[i] >= total/(4*m):
    s += 1
    
if s >= m:
  print('Yes')
else:
  print('No')
Problem p03161 (python)

Fixed submission:
import numpy as np
n,k = map(int,input().split())
height = np.array(list(map(int,input().split())))
cost_list = np.zeros(n,dtype = int)

for m in range(1,n+1):
  if m <= k:
    cost_list[m-1] = abs(height[m-1]-height[0])
  else:
    Min = min(cost_list[m-k-1:m-1] + abs(height[m-k-1:m-1] - height[m-1]))
    cost_list[m-1] = Min
              
print(cost_list[-1])

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

def cost(n):
  if n <= k:
    return abs(height[n-1]-height[0])
  else:
    Min = cost(n-1) + abs(height[n-2]-height[n-1])
    if k > 1:
      for x in range(2,k+1):
        money2 = cost(n-x) + abs(height[n-x-1]-height[n-1])
        if money2 < Min:
          Min = money2 
    return Min      
    
          
print(cost(n))
Problem p03625 (python)

Fixed submission:
N = int(input())
List = list(map(int,input().split()))
List_t = []
List_q = []
List.sort()
for x in range(N-1):
  if List[x]==List[x+1]:
    List_t.append(List[x])
for x in range(N-3):
  if List[x]==List[x+1]==List[x+2]==List[x+3]:
    List_q.append(List[x])

if len(List_q) == 0:
  if len(List_t)<=1:
    print(0)
  else:
    M = sorted(set(List_t))[-1]
    m = sorted(set(List_t))[-2]
    print(M*m)
else:
  M_q = sorted(set(List_q))[-1]
  M_t = sorted(set(List_t))[-1]
  m = sorted(set(List_t))[-2]
  print(max([M_q**2,M_t*m]))

Buggy submission (verdict: Runtime Error):
N = int(input())
List = list(map(int,input().split()))
List_ans = []
List.sort()
for x in range(N-1):
  if List[x]==List[x+1]:
    List_ans.append(List[x])
M = max(List_ans)
m = min(List_ans)
print(M*m)
Problem p02553 (python)

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

if a >= 0:
  if c>=0:
    ans = b*d
  elif d >=0:
    ans=b*d
  else:
    ans=a*d
else:
  if b>=0:
    if c>=0:
      ans = b*d
    elif d >=0:
      if a*c < b*d:
        ans = b*d
      else:
        ans= a*c
    else:
      ans=a*c
  elif c>=0:
    ans=b*c
  else:
    ans= a*c
print(ans)

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

if a => 0:
  if c=>0:
    ans = b*d
  elif d =>0:
    ans=b*d
  else:
    ans=a*d
else:
  if b=>0:
    if c=>0:
      ans = b*d
    elif d =>0:
      if a*c < b*d:
        ans = b*d
      else:
        ans= a*c
    else:
      ans=a*c
  elif c=>0:
    ans=b*c
  else:
    ans= a*c
print(ans)
Problem p02641 (python)

Fixed submission:
x, n = map(int, input().split())
if n==0:
    print(x)
if n > 0:
    P = list(map(int, input().split()))
    for i in range(0,102):
        if x-i not in P or x+i not in P:
            if x-i not in P:
                print(x-i)
                exit(0)
            if x+i not in P:
                print(x+i)
                exit(0)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n==0:
    print(x)
else:
    P = list(map(int, input().split())
    for i in range(0, 102):
        if x-i not in P or x+i not in P:
            if x-i not in P:
                print(x-i)
                exit(0)
            if x+i not in P:
                print(x+i)
                exit(0)
Problem p02657 (python)

Fixed submission:
a,b=map(int,input().split())
c=a*b
print(c)

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

Fixed submission:
s = input()
t = input()
if s == t[:-1]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
A = list(map(int, input().split()))
c = 1
P = [1]
for i in range(1,k+1):
    c = A[c-1]
    if c in P:
        roop_start = P.index(c)
        roop_num = i- roop_start
        break
    P.append(c)
    if i == k:
        roop_start = '8'
        roop_num = 'b'
if roop_start == '8':
    a = k
    roop_start = 0
else:
    a = (k - roop_start) %  roop_num
b = P[a + roop_start]
print(b)
Problem p02684 (python)

Fixed submission:
n, k = map(int, input().split())
A = list(map(int, input().split()))
now = 1
 
for i in range(len(bin(k))-2):
    if (k>>i)&1:
        now = A[now-1]
    A = [A[a-1] for a in A]
print(now)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
A = list(map(int, input().split()))
doubleA = {}
doubleA[1] = [A[i-1] for i in range(n)]

def f(x):
    return A[x-1]
for i in range(2, 73):
    doubleA[i] = [doubleA[i-1][doubleA[i-1][j]-1] for j in range(n)]
c = k - 2**(len(bin(k))-3)
start = doubleA[2**(len(bin(k))-3)][0]
for i in range(c):
    start = f(start)
print(start)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
A = list(map(int, input().split()))
def f(x):
    return A[x-1]
c = 1
P = [1]
 
for i in range(1,k+1):
    c = f(c)
    if c in P:
        roop_start = P.index(c)
        roop_num = i- roop_start
        break
    P.append(c)
a = (k - roop_start) %  roop_num
for i in range(a):
    P[roop_start] = f(P[roop_start])
print(P[roop_start])

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
A = list(map(int, input().split()))
def f(x):
    return A[x-1]
c = 1
P = [1]
 
for i in range(1,k+1):
    c = f(c)
    if c in P:
        roop_start = P.index(c)
        roop_num = i- roop_start
        break
    P.append(c)
a = (k - roop_start) %  roop_num
for i in range(a):
    P[roop_start] = f(P[roop_start])
print(roop_start)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
A = list(map(int, input().split()))
def f(x):
    return A[x-1]
c = 1
P = [1]
 
for i in range(k):
    c = f(c)
    P.append(c)
    if c in P:
        roop_start = P.index(c)
        roop_num  = i + 1-  roop_start
        break
a = (k - roop_start) % roop_num
for i in range(a):
    roop_start = f(roop_start)
print(roop_start)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
A = list(map(int, input().split()))
def f(x):
    return A[x-1]
c = 1
P = [1]
 
for i in range(k):
    c = f(c)
    P.append(c)
    if c in P:
        roop_start = P.find(c)
        roop_num  = i + 1-  roop_start
        break
a = (k - roop_start) % roop_num
for i in range(a):
    roop_start = f(roop_start)
print(roop_start)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
A = list(map(int, input().split()))
def f(x):
    return A[x-1]
c = 1, P = [1]

for i in range(k):
    c = f(c)
    P.append(c)
    if c in P:
        roop_start = P.find(c)
        roop_num  = i + 1-  roop_start
        break
a = (k - roop_start) % roop_num
for i in range(a):
    roop_start = f(roop_start)
print(roop_start)
Problem p02687 (python)

Fixed submission:
s = input()

if s == 'ABC':
    print('ARC')
else:
    print('ABC')

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
H = list(map(int, input().split()))
s = [[0]]*m
 
for _  in range(m):
    a, b = map(int, input().split())
    s[a-1].append(H[b-1])
    s[b-1].append(H[a-1])
 
c = 0
for j in range(n):
    if H[j] > max(s[j]):
        c+= 1
 
print(c)
Problem p02700 (python)

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

while a>=0 and c>=0:
  c=c-b
  if c<=0:
    print("Yes")
    sys.exit(0)
  a=a-d
  if a<=0:
    print("No")
    sys.exit(0)

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

while a>=0 and c>=0:
  c=c-b
  if c<=0:
    print("Yes")
    exit("0")
  a=a-d
  if a<=0:
    print("No")
    exit("0")
Problem p02582 (python)

Fixed submission:
S = input()

if S =="SSS":
  print(0)
elif S[1] == "S":
  print(1)
elif S == "SRS":
  print(1)
elif S == "RRR":
  print(3)
else:
  print(2)

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

if S =="SSS":
  print(0)
elif S[1] == "S":
  print(1)
elif S = "SRS":
  print(1)
elif S == "RRR":
  print(3)
else:
  print(2)
Problem p02583 (python)

Fixed submission:
N = int(input())
L = list(map(int, input().split()))
num_list =[]
ans = 0
for i in range(N):
  for j in range(N):
    for k in range(N):
      if L[i]!=L[j] and L[j]!=L[k] and L[i]!=L[k]:
        num_list.append(L[i])
        num_list.append(L[j])
        num_list.append(L[k])
        num_list.sort()
        if num_list[0]+num_list[1] > num_list[2]:
          ans += 1
          num_list.clear()
        else:
          num_list.clear()
print(int(ans/6))

Buggy submission (verdict: Runtime Error):
num_list =[]
ans = 0
for i in range(N):
  for j in range(N):
    for k in range(N):
      if L[i]!=L[j] and L[j]!=L[k] and L[i]!=L[k]:
        num_list.append(L[i])
        num_list.append(L[j])
        num_list.append(L[k])
        num_list.sort()
        if num_list[0]+num_list[1] > num_list[2]:
          ans += 1
          num_list.clear()
        else:
          num_list.clear()
print(int(ans/6))
Problem p02845 (python)

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

mul = 3 if L[-1] == n-1 else 6
MOD = 1000000007

ans = 1
zero_counter = 0
available = []
for elm in L:
    if elm == 0:
        zero_counter += 1
        if zero_counter > 3:
            ans = 0
            break
        available.append(elm)
    else:
        counter = available.count(elm-1)
        if counter == 0:
            ans = 0
            break
        ans *= counter
        available.remove(elm-1)
        available.append(elm)
        ans = ans % MOD

ans = (ans * mul) % MOD
print(ans)

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

mul = 3 if L[-1] == n-1 else 6
MOD = 1000000007

ans = 1
available = []
for elm in L:
    if elm == 0:
        available.append(elm)
    else:
        ans *= available.count(elm-1)
        available.remove(elm-1)
        available.append(elm)
        ans = ans % MOD

ans = (ans * mul) % MOD
print(ans)
Problem p02856 (python)

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

short = []
additional = 0
for elm in L:
    additional += (elm[1] - 1)
    total = elm[0] * elm[1]
    if total > 9:
        if total % 9 == 0:
            additional += (total // 9) - 1
        else:
            additional += total // 9
        # additional += (total - 1) // 9
    if total > 9:
        if total % 9 == 0:
            res = 9
        else:
            res = total % 9
    else:
        res = total
    short.append(res)

prev = 0
additional += len(short) - 1
for elm in short:
    prev = prev + elm
    if prev > 9:
        prev -= 9
        additional += 1

print(additional)

Buggy submission (verdict: Runtime Error):
m = int(input())
L = []
for _ in range(m):
    L.append(list(map(int, input().split())))

short = []
additional = 0
for elm in L:
    additional += (elm[1] - 1)
    total = elm[0] * elm[1]
    if total > 9:
        if total % 9 == 0:
            additional += (total // 9) - 1
        else:
            additional += total // 9
        # additional += (total - 1) // 9
    if total > 9:
        if total % ９==０：
            res = 9
        else:
            res = total % 9
    else:
        res = total
    short.append(res)

prev = 0
additional += len(short) - 1
for elm in short:
    prev = prev + elm
    if prev > 9:
        prev -= 9
        additional += 1

print(additional)

Buggy submission (verdict: Runtime Error):
m = int(input())
L = []
for _ in range(m):
    L.append(list(map(int, input().split())))

short = []
additional = 0
for elm in L:
    additional += (elm[1] - 1)
    total = elm[0] * elm[1]
    if total > 9:
        if total % 9 == 0:
            additional += (total // 9) - 1
        else:
            additional += total // 9
        # additional += (total - 1) // 9
    if total > 9:
        if total % ９＝＝０：
            res = 9
        else:
            res = total % 9
    else:
        res = total
    short.append(res)

prev = 0
additional += len(short) - 1
for elm in short:
    prev = prev + elm
    if prev > 9:
        prev -= 9
        additional += 1

print(additional)
Problem p02921 (python)

Fixed submission:
s = input()
t = input()

count = 0
for i in range(3):
    if s[i] == t[i]:
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):
def main():
    from collections import deque
    import sys
    input = sys.stdin.readline

    n = int(input())
    L = [deque(map(lambda x: int(x) - 1, input().split())) for _ in range(n)]

    ans = 0
    count = 0
    MAX_COUNT = n * (n-1)
    iteration_times = 0
    flag = 0

    while iteration_times <= MAX_COUNT:
        iteration_times += 1

        if count == MAX_COUNT:
            flag = 1
            break
        
        numset = set()
        add = numset.add
        flag = 100
        for i in range(n):
            if len(L[i]) != 0 and i not in numset:
                a = L[i][0]
                b = L[a][0]
                if i == b:
                    add(i)
                    add(b)
                    flag = 0
        
        if flag == 100:
            break
        for elm in numset:
            L[elm].popleft()
            count += 1

        ans += 1

    if flag == 1:
        print(ans)
    else:
        print(-1)


if __name__ == "__main__":
    main()