Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
ss = input()

n = len(ss)
arrs = [ss[0]]

for i in range(1, n):
    if len(arrs[-1]) == 2:
        if arrs[-1].endswith(ss[i]):
            arrs.append('*')
        else:
            arrs.append(ss[i])

    else:
        if arrs[-1] == ss[i]:
            arrs.append(ss[i: i + 2])
        else:
            arrs.append(ss[i])

while '*' in arrs:
    arrs.remove('*')

if arrs[-1] == arrs[-2]:
    ans = len(arrs) - 1

else:
    ans = len(arrs)
print(ans)

Fixed submission:
ss = input()

n = len(ss)
arrs = [ss[0]]

for i in range(1, n):
    if len(arrs[-1]) == 2:
        if arrs[-1].endswith(ss[i]):
            arrs.append('*')
        else:
            arrs.append(ss[i])

    else:
        if arrs[-1] == ss[i]:
            arrs.append(ss[i: i + 2])
        else:
            arrs.append(ss[i])

c = arrs.count('*')

if arrs[-1] == arrs[-2]:
    ans = len(arrs) - 1

else:
    ans = len(arrs)
print(ans - c)

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())

a = S[0]
c = 1
while len(S) >1:
  if S[1] == a:
    if len(S) >2:
      a = S[1:3]
      S = [a] + S[3:]
      c += 1
    else:
      break
  else: 
    a = S[1]
    S = [a] + S[2:]
    c += 1
    
print(c)  

Fixed submission:
ss = input()

n = len(ss)
arrs = [ss[0]]

for i in range(1, n):
    if len(arrs[-1]) == 2:
        if arrs[-1].endswith(ss[i]):
            arrs.append('*')
        else:
            arrs.append(ss[i])

    else:
        if arrs[-1] == ss[i]:
            arrs.append(ss[i: i + 2])
        else:
            arrs.append(ss[i])

c = arrs.count('*')

if arrs[-1] == arrs[-2]:
    ans = len(arrs) - 1

else:
    ans = len(arrs)
print(ans - c)

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

a = S[0]
c = 1
while len(S) >1:
  if S[1] == a:
    if len(S) >2:
      a = S[1:3]
      S = [a] + S[3:]
      c += 1
    else:
      break
  else: 
    a = S[1]
    S = [a] + S[2:]
    c += 1
    print(S)
print(c) 

Fixed submission:
ss = input()

n = len(ss)
arrs = [ss[0]]

for i in range(1, n):
    if len(arrs[-1]) == 2:
        if arrs[-1].endswith(ss[i]):
            arrs.append('*')
        else:
            arrs.append(ss[i])

    else:
        if arrs[-1] == ss[i]:
            arrs.append(ss[i: i + 2])
        else:
            arrs.append(ss[i])

c = arrs.count('*')

if arrs[-1] == arrs[-2]:
    ans = len(arrs) - 1

else:
    ans = len(arrs)
print(ans - c)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

n = int(input())
aa = []

for i in range(n):
  s = sorted(input())
  s = [''.join(s)]
  aa.append(*s)

cc = collections.Counter(aa)
c = [c[1] for c in cc.items() if c[1] >1]

def fact(n):
  x = 1
  for i in range(1, n+1):
    x *= i
  return x

def comb(n):
  return fact(n) / ( 2 * fact((n-2)))


ans = 0
for i in range(len(c)):
  ans += comb(c[i])
  

print(int(ans))


Fixed submission:
import collections

from scipy.special import comb


n = int(input())
aa = []

for i in range(n):
  s = sorted(input())
  s = [''.join(s)]
  aa.append(*s)

cc = collections.Counter(aa)
c = [c[1] for c in cc.items() if c[1] >1]

ans = 0
for i in range(len(c)):
  ans += comb(c[i], 2, exact=True)
  

print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import collections

n = int(input())
aa = []

for i in range(n):
  s = sorted(input())
  s = [''.join(s)]
  aa.append(*s)

cc = collections.Counter(aa)
c = [c[1] for c in cc.items() if c[1] >1]

def fact(n):
  x = 1
  for i in range(1, n+1):
    x *= i
  return x

def comb(n):
  return fact(n) / ( 2 * fact((n-2)))


ans = 0
for i in range(len(c)):
  ans += comb(c[i])
  

print(int(ans))

Fixed submission:
import collections

from scipy.special import comb


n = int(input())
aa = []

for i in range(n):
  s = sorted(input())
  s = [''.join(s)]
  aa.append(*s)

cc = collections.Counter(aa)
c = [c[1] for c in cc.items() if c[1] >1]

ans = 0
for i in range(len(c)):
  ans += comb(c[i], 2, exact=True)
  

print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
arr = []
cnt = 0

for i in range(n):
  s = sorted(list(input()))
  arr.append(s)

for i in range(n):
  for j in range(n):
    if i != j and arr[i] == arr[j]:      
      cnt += 1

print(cnt//2)

Fixed submission:
import collections

from scipy.special import comb


n = int(input())
aa = []

for i in range(n):
  s = sorted(input())
  s = [''.join(s)]
  aa.append(*s)

cc = collections.Counter(aa)
c = [c[1] for c in cc.items() if c[1] >1]

ans = 0
for i in range(len(c)):
  ans += comb(c[i], 2, exact=True)
  

print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, (input() for i in range(N))))

for i in range(N) :
  x = A[i]
  A.remove(x)
  print(max(A))
  A.insert(i,x)

Fixed submission:
N = int(input())
A = list(map(int, (input() for i in range(N))))
B = sorted(A, reverse=True)
a = B[0]
a1 = B[1]


for x in A:  
  if x != a:
    print(a)
  else:
    print(a1)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, (input() for i in range(N))))
for i in range(N):

  print(max(A[:i]+A[i+1:]))

Fixed submission:
N = int(input())
A = list(map(int, (input() for i in range(N))))
B = sorted(A, reverse=True)
a = B[0]
a1 = B[1]


for x in A:  
  if x != a:
    print(a)
  else:
    print(a1)
Buggy python submission (verdict: Time Limit Exceeded):
l, r = map(int, input().split())
x = 2018

for i in range(l,r):
  i1 = i % 2019
  for j in range(i+1, r+1):
    j1 = j% 2019
    if (i1 * j1) % 2019 <x:
      x = (i1 * j1) % 2019
print(x)

Fixed submission:
l, r = map(int, input().split())
x = 2018

if r - l >=2019:
  x = 0
  
else:
  for i in range(l,r):
    for j in range(i+1, r+1):
      if (i * j) % 2019 < x:
        x = (i * j) % 2019
        
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
l, r = map(int, input().split())
x = 2018

for i in range(l,r):
  for j in range(i+1, r+1):
    if (i * j) % 2019 <x:
      x = (i * j) % 2019
print(x)
    

Fixed submission:
l, r = map(int, input().split())
x = 2018

if r - l >=2019:
  x = 0
  
else:
  for i in range(l,r):
    for j in range(i+1, r+1):
      if (i * j) % 2019 < x:
        x = (i * j) % 2019
        
print(x)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())


L, R = map(int, input().split())
ar = [i for i in range(L, R+1)]
for i in range(M-1):
      L, R = map(int, input.split())
      if ar[-1] < L or ar[0] > R:
        break
      else:
        if ar[0] < L < ar[-1]:
          ar = [x for x in range(L, ar[-1]+1)]
        elif ar[0] < R <ar[-1]:
          ar = [x for x in range(ar[0], R+1)]
print(len(ar))

Fixed submission:
N, M = map(int, input().split())
L, R = map(int, input().split())


for i in range(M-1):
      L1, R1 = map(int, input().split())
      if R1 < L or R < L1:
        print(0)
        exit()
      else:
        if L <= L1 <= R:
          L = L1
          
        elif L <= R1 <= R:
          R = R1
        
          
print(R-L+1)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
set1 = set([x for x in range(1, N+1)])
for i in range(M):
  L, R = map(int, input().split())
  lr = set([x for x in range(L, R+1)])
  set1 =set1 & lr
print(len(set1))

Fixed submission:
N, M = map(int, input().split())
L, R = map(int, input().split())


for i in range(M-1):
      L1, R1 = map(int, input().split())
      if R1 < L or R < L1:
        print(0)
        exit()
      else:
        if L <= L1 <= R:
          L = L1
          
        elif L <= R1 <= R:
          R = R1
        
          
print(R-L+1)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
ss = set(x for x in range(1,N+1))
for i in range(M):
  
  L, R = map(int, input().split())
  st = set(x for x in range(L, R+1))
  ss = ss & st
print(len(ss))

Fixed submission:
N, M = map(int, input().split())
L, R = map(int, input().split())


for i in range(M-1):
      L1, R1 = map(int, input().split())
      if R1 < L or R < L1:
        print(0)
        exit()
      else:
        if L <= L1 <= R:
          L = L1
          
        elif L <= R1 <= R:
          R = R1
        
          
print(R-L+1)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
list1 = []
ss = set(x for x in range(1,N+1))
for i in range(M):
  ar = []
  L, R = map(int, input().split())
  st = set(x for x in range(L, R+1))
  list1.append(st)
for s in list1:
  ss = ss & s
print(len(ss))
    

Fixed submission:
N, M = map(int, input().split())
L, R = map(int, input().split())


for i in range(M-1):
      L1, R1 = map(int, input().split())
      if R1 < L or R < L1:
        print(0)
        exit()
      else:
        if L <= L1 <= R:
          L = L1
          
        elif L <= R1 <= R:
          R = R1
        
          
print(R-L+1)
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, n = map(int, input().split())
cnt = 0
for r in range(int(n//R)+1):
  for g in range(int(n//G)+1):
    
      if (n - (r*R + g*G)) % B == 0 and n - (r*R + g*G) >= 0:
        
        cnt +=1
print(cnt)

Fixed submission:
R, G, B, n = map(int, input().split())
cnt = 0
for r in range((n//R)+1):
  for g in range((n//G)+1):
    
      if (n - (r*R + g*G)) % B == 0 and n - (r*R + g*G) >= 0:
        
        cnt +=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
s = list(input())
count = 0
list1 = []
for x in s:
  if x == 'A' or x == 'G' or x == 'T' or x == 'C':
    count = count + 1
  else:
    list1.append(count)
    count = 0
    
print(max(list1))

Fixed submission:
s = list(input())
count = 0
list1 = []
for x in s:
  if x == 'A' or x == 'G' or x == 'T' or x == 'C':
    count = count + 1
  list1.append(count)
  if x != 'A' and x != 'G' and x != 'T' and x != 'C':
    count = 0
    

print(max(list1))
Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
x = len(S)
while '01' in S:
  S = S.replace('01', '')
while '10' in S:
  S = S.replace('01', '')
y = len(S)
print(x-y)

Fixed submission:
S = str(input())
x = len(S)
if '0' in S:
  y0 = S.count('0')
else:
  y0 = 0
if '1' in S:
  y1 = S.count('1')
else:
  y1 = 0
  
d = abs(y0 - y1)
print(x - d)
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
x = len(S)
c = 0
for i in range(x):
  if S[i] == 'W':
    c += S[:i].count('B')
print(c)
    

Fixed submission:
S = input()
x = len(S)
c = 0
ans = 0
for i in range(x):
  
  if S[i] == 'W':
    
    c += 1
    
    ans += i + 1 - c
    
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
c = 0
while 'BW' in S:
  c += S.count('BW')
  S = S.replace('BW', 'WB')
print(c)

Fixed submission:
S = input()
x = len(S)
c = 0
ans = 0
for i in range(x):
  
  if S[i] == 'W':
    
    c += 1
    
    ans += i + 1 - c
    
    
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())

if S[0] == '1':
  count  = 0
  while S[i] == '1':
    count += 1
  if count >= K:
    print(1)
  else:
    print(S[count])
else:
  print(S[0])

Fixed submission:
S = input()
K = int(input())
count = 0

if S[0] != '1':
  print(S[0])
  exit()

for i in range(len(S)):
    if S[i] == '1':
      count += 1
    else:
      break

if count >= K:
  print(1)
else:
  print(S[count])

Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())

if S[0] == '1':
  print(S[1])
else:
  print(S[0])

Fixed submission:
S = input()
K = int(input())
count = 0

if S[0] != '1':
  print(S[0])
  exit()

for i in range(len(S)):
    if S[i] == '1':
      count += 1
    else:
      break

if count >= K:
  print(1)
else:
  print(S[count])
Buggy python submission (verdict: Runtime Error):
D, N = map(int, input().split())
if D == 0:
  print(N)
elif D == 1:
  x = [100 * i for i in range(1,101)]
  print(x[N])
elif D == 2:
  x = [10000 * i for i in range(1,101)]
  print(x[N])

Fixed submission:
D, N = map(int, input().split())
if N != 100:
  if D == 0:
    print(N)
  elif D == 1:
    x = [100 * i for i in range(1, 101)]
    print(x[N-1])
  elif D == 2:
    x = [10000 * i for i in range(1, 101)]
    print(x[N-1])
else:
  if D == 0:
    print(101)
  elif D == 1:
    x = [100 * i for i in range(1, 101)]
    print(x[N-1]+100)
  elif D == 2:
    x = [10000 * i for i in range(1, 101)]
    print(x[N-1]+10000)

Buggy python submission (verdict: Runtime Error):
D, N = map(int, input().split())
if D == 0:
  print(N)
elif D == 1:
  x = [100 * i for i in range(100)]
  print(x[N])
elif D == 2:
  x = [10000 * i for i in range(100)]
  print(x[N])

Fixed submission:
D, N = map(int, input().split())
if N != 100:
  if D == 0:
    print(N)
  elif D == 1:
    x = [100 * i for i in range(1, 101)]
    print(x[N-1])
  elif D == 2:
    x = [10000 * i for i in range(1, 101)]
    print(x[N-1])
else:
  if D == 0:
    print(101)
  elif D == 1:
    x = [100 * i for i in range(1, 101)]
    print(x[N-1]+100)
  elif D == 2:
    x = [10000 * i for i in range(1, 101)]
    print(x[N-1]+10000)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
s = input()
s_list = list(s)
ans_list = []

for i in range(n):
    before_list = s[:i]
    after_list = s[i+1:]
    cnt_before = collections.Counter(before_list)
    cnt_after = collections.Counter(after_list)
    ans_list.append(cnt_before['W'] + cnt_after['E'])

print(min(ans_list))

Fixed submission:
n = int(input())
s = list(input())
cnt = 0
ans_list = [0]
e_cnt = 0

for i in range(1,n):
    if s[i-1] == "E" and s[i] == "E":
        cnt -= 1
        e_cnt += 1
    if s[i-1] == "E" and s[i] == "W":
        cnt -= 0
    if s[i-1] == "W" and s[i] == "E":
        cnt += 0
        e_cnt += 1
    if s[i-1] == "W" and s[i] == "W":
        cnt += 1
    ans_list.append(cnt)

print(min(ans_list) + e_cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())
ans_list = []

for _ in range(n):
    if s[_] == "E":
        s[_] = -1
    else:
        s[_] = 1

for i in range(n):
    ans_list.append(sum(s[:i]))

print(min(ans_list) + (sum(s)-n)//(-2))

Fixed submission:
n = int(input())
s = list(input())
cnt = 0
ans_list = [0]
e_cnt = 0

for i in range(1,n):
    if s[i-1] == "E" and s[i] == "E":
        cnt -= 1
        e_cnt += 1
    if s[i-1] == "E" and s[i] == "W":
        cnt -= 0
    if s[i-1] == "W" and s[i] == "E":
        cnt += 0
        e_cnt += 1
    if s[i-1] == "W" and s[i] == "W":
        cnt += 1
    ans_list.append(cnt)

print(min(ans_list) + e_cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())
e_count = s[1:].count('E')
ans_list = []

for _ in range(n):
    if s[_] == "E":
        s[_] = -1
    else:
        s[_] = 1

for i in range(n):
    ans_list.append(sum(s[:i])+e_count)

print(min(ans_list))

Fixed submission:
n = int(input())
s = list(input())
cnt = 0
ans_list = [0]
e_cnt = 0

for i in range(1,n):
    if s[i-1] == "E" and s[i] == "E":
        cnt -= 1
        e_cnt += 1
    if s[i-1] == "E" and s[i] == "W":
        cnt -= 0
    if s[i-1] == "W" and s[i] == "E":
        cnt += 0
        e_cnt += 1
    if s[i-1] == "W" and s[i] == "W":
        cnt += 1
    ans_list.append(cnt)

print(min(ans_list) + e_cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
list_count = []

for i in range(n):
    ce = s[i+1:].count('E')
    cw = s[:i].count('W')
    cnt = ce + cw
    list_count.append(cnt)

print(min(list_count))

Fixed submission:
n = int(input())
s = list(input())
cnt = 0
ans_list = [0]
e_cnt = 0

for i in range(1,n):
    if s[i-1] == "E" and s[i] == "E":
        cnt -= 1
        e_cnt += 1
    if s[i-1] == "E" and s[i] == "W":
        cnt -= 0
    if s[i-1] == "W" and s[i] == "E":
        cnt += 0
        e_cnt += 1
    if s[i-1] == "W" and s[i] == "W":
        cnt += 1
    ans_list.append(cnt)

print(min(ans_list) + e_cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
xx = list(map(int, input().split()))
 
for i in range(n):
  yy = xx[:i] + xx[i+1:]
  zz = sorted(yy)
  print(zz[(n-1)//2])

Fixed submission:
n = int(input())
xx = list(map(int, input().split()))
yy = sorted(xx)

a = yy[n//2-1]
b = yy[n//2]

for x in xx:
  if x <= a:
    print(b)
  elif x >= b:
    print(a)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
xx = list(map(int, input().split()))

for i in range(n):
  yy = xx[:i] + xx[i+1:]
  zz = sorted(yy)
  print(zz[(n-1)//2])

Fixed submission:
n = int(input())
xx = list(map(int, input().split()))
yy = sorted(xx)

a = yy[n//2-1]
b = yy[n//2]

for x in xx:
  if x <= a:
    print(b)
  elif x >= b:
    print(a)
Buggy python submission (verdict: Time Limit Exceeded):
from scipy.special import comb
n = int(input())
aa = list(map(int, input().split()))
list1 = []

for j in range(n):
  for i in range(j+1, n):
    list1.append([comb(aa[i], aa[j]), aa[i],aa[j]])
    
ma = max(list1, key= lambda x:x[0])
ans = sorted([ma[1], ma[2]], reverse = True)

print(*ans)

Fixed submission:
n = int(input())
aa = sorted(list(map(int, input().split())))
list1 = []
ma = aa[-1]
for i in range(n):
  d = abs(aa[i]-(ma+1)//2)
  list1.append([d,i])
md = min(list1, key=lambda x:x[0])

print(ma, aa[md[1]])
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
x = [i for i in range(a, b+1)]
if len(x) <= 2 * k:
  print(*[str(i) + '\n' for i in x])
else:
  ans = x[:k] + x[-k:]

  print(*[str(i)+'\n' for i in ans] )

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

if (b-a +1) <= 2 * k:
  for i in range(a,b+1):
    print(i)
else:
  for i in range(a, a+k):
    print(i)
  for i in range(b-k+1, b+1):
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
x = [i for i in range(a, b+1)]
if len(x) <= 2 * k:
  ans = x
else:
  ans = x[:k] + x[-k:]

for i in ans:
  print(i)

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

if (b-a +1) <= 2 * k:
  for i in range(a,b+1):
    print(i)
else:
  for i in range(a, a+k):
    print(i)
  for i in range(b-k+1, b+1):
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
x = [i for i in range(a, b+1)]
y = set(x[:k])
z = set(x[-k:])
ans = y | z
ans1 = sorted(list(ans))
for i in ans1:
  print(i)

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

if (b-a +1) <= 2 * k:
  for i in range(a,b+1):
    print(i)
else:
  for i in range(a, a+k):
    print(i)
  for i in range(b-k+1, b+1):
    print(i)
Buggy python submission (verdict: Runtime Error):
N  = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]

T1 = [x+'*' for x in T]
arr = S + T1
list1 = []
for i in range(len(arr)):
  if arr[i] not

list2 = [] in list2:
    s = arr.count(arr[i])
    t = arr.count(arr[i]+'*')
    a = s-t
    list1.append((arr[i], a))
    list2.append(arr[i])

for i in list1:
  
  if i[0].endswith('*'):
    list1.remove(i)
  print(list1)

ans1 = max(list1, key= lambda x:x[1])

if int(ans1[1]) <= 0:
  print(0)
else:
  print(ans1[1])

Fixed submission:
import collections

N = int(input())
S = [input() for i in range(N)]
cS = collections.Counter(S)
lS = list(cS.items())
M = int(input())
T = [input() for i in range(M)]
cT = collections.Counter(T)
list1 = []
ans = 0

for i in range(len(lS)):
    
    if lS[i][0] in cT:
        x = lS[i][1] - cT[lS[i][0]]
        
    else:
        x = lS[i][1]
        
    if x > 0:
        list1.append(x)
    
if list1 == []:
  print(0)
else:
  print(max(list1))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

aa = [[1]*(m + 2) for i in range(n+2)]

for i in range(1, n+1):
  for j in range(1, m+1):
    aa[i][j-1] *= -1
    aa[i][j] *= -1
    aa[i][j+1] *= -1
    aa[i-1][j-1] *= -1
    aa[i-1][j] *= -1
    aa[i-1][j+1] *= -1
    aa[i+1][j-1] *= -1
    aa[i+1][j] *= -1
    aa[i+1][j+1] *= -1
aa = aa[1:-1]
bb = [b[1:-1] for b in aa]
cc = [x  for y in bb for x in y]
ans = cc.count(-1)

print(ans)

Fixed submission:
n, m = map(int, input().split())
if n > 2 and m > 2:
  ans = (n-2)*(m-2)
elif n == 2 or m == 2:
  ans = 0
elif n == 1 and m == 1:
  ans = 1
elif n == 1:
  ans = m - 2
elif m == 1:
  ans = n - 2

print(ans)
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
ln = int(math.log10(n))
#1つ下の桁がない場合
if ln == 0:
  print(n)
#全ての桁が9の場合
elif (n+1) % (10 ** (ln + 1)) == 0:
  print(9 * (ln + 1))
#それ以外
else:
  a = n // (10 ** ln)
  b = a * (10 ** ln )- 1
  c = [int(x) for x in list(str(b))]

  print(sum(c))

Fixed submission:
import math
n = int(input())
k = int(math.log10(n))

a = n // (10 ** k)
b = n % (10 ** k)

if k == 0:
  ans = n
elif n % 10 == 9:
  ans = k * 9 + a
else:
  ans = k * 9 + a -1

print(ans)

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
ln = int(math.log10(n))
if ln == 0:
  print(n)
else:
  a = n // (10 ** ln)
  b = a * (10 ** ln )- 1
  c = [int(x) for x in list(str(b))]

  print(sum(c))

Fixed submission:
import math
n = int(input())
k = int(math.log10(n))

a = n // (10 ** k)
b = n % (10 ** k)

if k == 0:
  ans = n
elif n % 10 == 9:
  ans = k * 9 + a
else:
  ans = k * 9 + a -1

print(ans)

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
ln = int(math.log10(n))
a = n // (10 ** ln)
b = a * 10 ** ln - 1
c = [int(x) for x in list(str(b))]

print(sum(c))

Fixed submission:
import math
n = int(input())
k = int(math.log10(n))

a = n // (10 ** k)
b = n % (10 ** k)

if k == 0:
  ans = n
elif n % 10 == 9:
  ans = k * 9 + a
else:
  ans = k * 9 + a -1

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
list1 = []
ame = A[0]
for i in range(N-1):
  list1.append(sum(A[:i+1])+sum(B[i:]))
  
if list1 = []:
  print(A[0]+b[0])
else:
  print(max(list1))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
list1 = []
ame = A[0]
for i in range(N-1):
  list1.append(sum(A[:i+1])+sum(B[i:]))
  
if list1 == []:
  print(A[0]+B[0])
else:
  print(max(list1))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
list1 = []

for i in range(N-1):
  list1.append(sum(A[:i+1])+sum(B[i:]))
print(max(list1))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
list1 = []
ame = A[0]
for i in range(N-1):
  list1.append(sum(A[:i+1])+sum(B[i:]))
  
if list1 == []:
  print(A[0]+B[0])
else:
  print(max(list1))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
list1 = []
ame = A[0]
for i in range(N-1):
  list1.append(sum(A[:i+1])+sum(B[i:]))
print(max(list1))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
list1 = []
ame = A[0]
for i in range(N-1):
  list1.append(sum(A[:i+1])+sum(B[i:]))
  
if list1 == []:
  print(A[0]+B[0])
else:
  print(max(list1))