Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

def calcGroup(s):
  whiteCount = 0
  blackCount = 0
  prev = ""
  for i in range(len(s)):
    if s[i] == prev:
      pass
    else:
      if s[i] = "":
        pass
      elif s[i] = "W":
        whiteCount += 1
      elif s[i] = "B":
        blackCount += 1
      else:
        raise ValueError
    prev = s[i]
  return whiteCount,blackCount

# @njit
def solve(s):
  # white,black = calcGroup(s)
  return min(calcGroup(s))



def main():
  s = input()
  print(solve(s))
  return

if __name__ == '__main__':
  main()


Fixed submission:
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

def calcGroup(s):
  whiteCount = 0
  blackCount = 0
  prev = ""
  for i in range(len(s)):
    if s[i] == prev:
      pass
    else:
      if s[i] == "W":
        whiteCount += 1
      elif s[i] == "B":
        blackCount += 1
      else:
        raise ValueError
    prev = s[i]
  return whiteCount,blackCount

# @njit
def solve(s):
  white,black = calcGroup(s)
  if abs(white-black) == 0:
    return (white-1)*2+1
  else:
    return min(white,black)*2



def main():
  s = input()
  print(solve(s))
  return

if __name__ == '__main__':
  main()

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

def calcGroup(s):
  whiteCount = 0
  blackCount = 0
  prev = ""
  for i in range(len(s)):
    if s[i] == prev:
      pass
    else:
      if s[i] = "W":
        whiteCount += 1
      elif s[i] = "B":
        blackCount += 1
      else:
        raise ValueError
    prev = s[i]
  return whiteCount,blackCount

# @njit
def solve(s):
  # white,black = calcGroup(s)
  return min(calcGroup(s))



def main():
  s = input()
  print(solve(s))
  return

if __name__ == '__main__':
  main()

Fixed submission:
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

def calcGroup(s):
  whiteCount = 0
  blackCount = 0
  prev = ""
  for i in range(len(s)):
    if s[i] == prev:
      pass
    else:
      if s[i] == "W":
        whiteCount += 1
      elif s[i] == "B":
        blackCount += 1
      else:
        raise ValueError
    prev = s[i]
  return whiteCount,blackCount

# @njit
def solve(s):
  white,black = calcGroup(s)
  if abs(white-black) == 0:
    return (white-1)*2+1
  else:
    return min(white,black)*2



def main():
  s = input()
  print(solve(s))
  return

if __name__ == '__main__':
  main()
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int,input().split())
S = input()

a_counter, b_counter = 0

while S != "":
  s = S[0]
  if s == "a" and a_counter + b_counter <=a+b:
    a_counter += 1
    print("Yes")
  elif s == "b" and b_counter <= b and a_counter + b_counter <=a+b:
    b_counter += 1
    print("Yes")
  else:
    print("No")
  
  S = S[1:]

Fixed submission:
N, A, B = map(int,input().split())
S = input()

a_counter = 0
b_counter = 0

for i in range(N):
  s = S[0]
  if s == "a" and a_counter + b_counter <A+B:
    a_counter += 1
    print("Yes")
  elif s == "b" and b_counter < B and a_counter + b_counter <A+B:
    b_counter += 1
    print("Yes")
  else:
    print("No")
  
  S = S[1:]
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,input().split()))

c = 0
for i in range(N-1):
  for j in range(i+1,N):
    if a[i] == j+1 and a[j] == i+1:
      c += 1
print(c)
    

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

c = 0
for i in range(N):
  if a[a[i]-1]-1 == i:
    c += 1
print(c//2)

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

c = 0
for i in range(N-1):
  for j in range(i+1,N):
    if a[i] == j+1 and a[j] == i+1:
      c += 1
print(c)

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

c = 0
for i in range(N):
  if a[a[i]-1]-1 == i:
    c += 1
print(c//2)
Buggy python submission (verdict: Runtime Error):
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header
int main() {
	ll sum=0;
	string n;
	cin >> n;
	rep(i, n.length()){
		sum+=n[i]-'0';
	}
	if(sum%9 == 0) puts("Yes");
	else puts("No");
	return 0;
}


Fixed submission:
n = int(input())
if n%9 == 0: print("Yes")
else: print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    cnt=0
    for i in range(len(a)):
        if a[i]==b:
            a[i]=c
    print(sum(a))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
q = int(input())
T={}
for i in range(n):
    if a[i] not in T: T[a[i]]=1
    else: T[a[i]]+=1
Sum = sum(a)
for i in range(q):
    b, c = map(int, input().split())
    if b not in T: T[b]=0
    Sum = Sum-(T[b]*b)+(T[b]*c)
    print(Sum)
    if c not in T: T[c]=T[b]
    else: T[c]+=T[b]
    T[b]=0
Buggy python submission (verdict: Runtime Error):
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	vector<int> a(5);
	int max = 0;
	int kazu = 0;
	rep(i,5){
		cin >> a[i];
		int amari;
		if(a[i]%10 == 0) amari = 0;
		else amari = 10-(a[i]%10);
		if(amari >= max){
			max = amari;
			kazu = i;
		}
	}
	int ans = 0;
	rep(i,5){
		if(i == kazu) continue;
		else{
			if(a[i]%10 == 0) ans+=a[i];
			else ans+= ((a[i]/10)*10 + 10);
		}
	}
	cout << ans+a[kazu] << endl;
	return 0;
}

Fixed submission:
a = [int(input()) for i in range(5)]
max = 0
kazu = 0
ans = 0
for i in range(5):
    if a[i]%10 == 0: amari = 0
    else: amari = 10-(a[i]%10)
    if amari >= max:
        max = amari
        kazu = i
for i in range(5):
    if i == kazu: pass
    else:
        if a[i]%10 == 0:
            ans+=a[i]
        else:
            ans+=((int(a[i]/10))*10 +10)
print(ans+a[kazu])
Buggy python submission (verdict: Runtime Error):
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int n, m, c, ans =0;
	cin >> n >> m >> c;
	vector<int> b(m);
	rep(i,m) cin >> b[i];
	rep(i,n){
		int sum = 0;
		vector<int> a(m);
		rep(j,m){
			cin >> a[j];
			sum += a[j]*b[j];
		}
		sum+=c;
		if(sum > 0) ans++;
	}
	cout << ans << endl;
	return 0;
}

Fixed submission:
n, m, c  = map(int, input().split())
b = [int(i) for i in input().split()]
ans = 0
for i in range(n):
        a = [int(i) for i in input().split()]
        sum = 0
        for k in range(m):
            sum +=(a[k]*b[k])
        sum+=c
        if sum > 0: ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int n;
	double ans=0;
	cin >> n;
	rep(i,n){
		double x; string s;
		cin >> x >> s;
		if(s == "JPY") ans+=x;
		else ans+=380000*x;
	}
	printf("%.15f", ans);
	return 0;
}

Fixed submission:
n = int(input())
ans = 0
for i in range(n):
    x, u = input().split()
    x = float(x)
    if u == "JPY":
        ans+=x
    else:
        ans+=x*380000
print(ans)
Buggy python submission (verdict: Runtime Error):
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int n, x, ans=0, sum = 0;
	cin >> n >> x;
	vector<int> m(n);
	rep(i,n){
		cin >> m[i];
		sum+=m[i];
	}
	x-=sum;
	sort(all(m));
	cout << n+x/m[0] << endl;
	return 0;
}

Fixed submission:
n, x = map(int, input().split())
m = [int(input()) for i in range(n)]
sum = 0
min = 1000000
for i in range(n):
    sum+=m[i]
    if min > m[i]: min = m[i]
x-=sum
print(n+int(x/min))
Buggy python submission (verdict: Runtime Error):
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int a, b, flag=0;
	cin >> a >> b;
	string s;
	cin >> s;
	rep(i,a){
		if(!(s[i]>='0' && s[i]<='9')) flag++; 
	}
	if(s[a] != '-') flag++;
	loop(i, a+1, s.length()){
		if(!(s[i]>='0' && s[i]<='9')) flag++;
	}
	if(flag == 0) puts("Yes");
	else puts("No");
	return 0;
}

Fixed submission:
a, b = map(int, input().split())
s = input()
flag = 0
for i in range(a):
    if s[i]>='0' and s[i]<='9': pass
    else: flag=1
if s[a]!='-': flag=1
for i in range(a+1, len(s)):
    if s[i]>='0' and s[i]<='9': pass
    else: flag=1
if flag==1: print("No")
else: print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = [2, 1]
i = 2
a = 0
while True:
    a = l[i-1]+l[i-2]
    l.append(a)
    if i == n: break
    i+=1
print(a)

Fixed submission:
n = int(input())
a = []
a.append(2)
a.append(1)
for i in range(2, n+1):
    a.append(a[i-2]+a[i-1])
print(a[n])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = [2, 1]
i = 2
a = 0
while True:
    a = l[i-1]+l[i-2]
    l.append(a)
    if i == n: break
    i+=1
print(a)

Fixed submission:
n = int(input())
a = []
a.append(2)
a.append(1)
for i in range(2, n+1):
    a.append(a[i-2]+a[i-1])
print(a[n])
Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
k=[]
for i in range(len(t)):
    k.append(s[i])
    k.append(t[i])
if len(s)>len(t):
    t.append(s[len(s)-1])
print("".join(k))


Fixed submission:
s=input()
t=input()
k=[]
for i in range(len(t)):
    k.append(s[i])
    k.append(t[i])
if len(s)>len(t):
    k.append(s[len(s)-1])
print("".join(k))
Buggy python submission (verdict: Runtime Error):
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header
int main() {
	string s;
	cin >> s;
	int f1, f2;
	rep(i,s.length()){
		if(s[i]=='A'){
			f1=i;
			break;
		}
	}
	rep(i,s.length()){
		if(s[i]=='Z') f2=i;
	}
	cout << f2-f1+1 << endl;
	return 0;
}

Fixed submission:
s=input()
f1=0
f2=0
ok=True
for i in range(len(s)):
    if s[i]=='A' and ok:
        ok=False
        f1=i
    if s[i]=='Z': f2=i
print(f2-f1+1)
Buggy python submission (verdict: Runtime Error):
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header
int main() {
	string s, ans="";
	cin >> s;
	for(auto x : s){
		if(x!='B') ans+=x;
		else if(ans!="") ans.pop_back();
	}
	cout << ans << endl;
 	return 0;
}

Fixed submission:
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
# ... 最小側の制約も確認した？
# ... オーバーフローしない？
s = input()
ans = []
for x in s:
    if x=='0': ans.append('0')
    elif x == '1': ans.append('1')
    else:
        if len(ans) == 0: pass
        else: ans.pop()
for t in ans: print(t, end = "")
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
if N % K == 0:
    print(0)
elif N > K:
    while N > 0:
        hako1 = N
        N -= K
        hako2 = abs(N)
    if hako1 > hako2:
      print(hako2)
    else:
      print(hako1)
else:
    if N >= abs(N-K):
        print(abs(N-K))
    else:
        print(N)

Fixed submission:
N,K = map(int, input().split())
if N % K == 0:
    print(0)
elif N > K:
    hako1 = N%K
    hako2 = abs(hako1-K)
    if hako1 > hako2:
      print(hako2)
    else:
      print(hako1)
else:
    if N >= abs(N-K):
        print(abs(N-K))
    else:
        print(N)
Buggy python submission (verdict: Time Limit Exceeded):
N,A,B = map(int, input().split())
li = []
for i in range(A):
    li.append('b')
for i in range(B):
    li.append('r')

balls = A+B
an = 0
if N % balls == 0:
    print(int(A * (N/balls)))
else:
    an += A * (N//balls)
    for i in range(N % balls):
        if li[i] == 'b':
            an += 1
    print(an)

Fixed submission:
N,A,B = map(int, input().split())
balls = A+B
an = 0
if N % balls == 0:
    print(int(A * (N//balls)))
else:
    an += A * (N//balls)
    an += min(A,N % balls)
    print(an)
Buggy python submission (verdict: Runtime Error):

N = int(input())
li = list(map(int, input().split()))
li_2 = []

if N == 1:
    print(0)
else:
   for i in range(min(li),max(li)+1):
       cost_sum = 0
       for t in range(N):
           cost_sum += (li[t]-i) ** 2
       li_2.append(cost_sum)
print(min(li_2))


Fixed submission:
N = int(input())
li = list(map(int, input().split()))
li_2 = []

if N == 1:
    print(0)
else:
   for i in range(min(li),max(li)+1):
       cost_sum = 0
       for t in range(N):
           cost_sum += (li[t]-i) ** 2
       li_2.append(cost_sum)
   print(min(li_2))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
li = list(map(int, input().split()))
an = []
for i in range (1,N+1):
    an.append(li.index(i) + 1)
an=[str(a) for a in an]
an=" ".join(an)
print(an)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(0,n):
  b[a[i]-1]=i+1
ans=''
for i in range(n):
  ans+=str(b[i])+' '
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A,B= map(int, input().split())
now_sum = A
ans = 1
while True:
     if now_sum >= B:
         print(ans)
     now_sum += A-1
     ans += 1
print(ans)

Fixed submission:
A,B= map(int, input().split())
now_sum = 1
ans = 0
while True:
     if  now_sum >= B:
         print(ans)
         break
     now_sum += A-1
     ans += 1

Buggy python submission (verdict: Time Limit Exceeded):
A,B= map(int, input().split())
now_sum = A
ans = 1
while True:
     if now_sum >= B:
         print(ans)
     now_sum += A-1
     ans += 1


Fixed submission:
A,B= map(int, input().split())
now_sum = 1
ans = 0
while True:
     if  now_sum >= B:
         print(ans)
         break
     now_sum += A-1
     ans += 1
Buggy python submission (verdict: Time Limit Exceeded):
N,M= map(int, input().split())
li=[]
for i in range(N):
    li.append(0)
for i in range(M):
    L,R= map(int, input().split())
    for t in range(L-1,R):
        li[t] +=1
print(li.count(M))


Fixed submission:
N,M= map(int, input().split())
L,R= map(int, input().split())
flag = True
for i in range(M-1):
    a,b= map(int, input().split())
    if a >= L and b <= R:
        L = a
        R = b
    elif L <= b and R >= b:
        R = b
    elif L <= a and R >= a:
        L = a
    elif a < L and R < b:
        L = L
    else:
        flag = False
        break
if flag:
 print(R-L+1)
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
N,M= map(int, input().split())
li=[]
for i in range(N):
    li.append(0)
L,R= map(int, input().split())
for i in range(L-1,R):
    li[i] = 1
for i in range(M-1):
    L,R= map(int, input().split())
    for t in range(0,L-1):
        li[t] = 0
    for t in range(R,len(li)):
        li[t] = 0
print(li.count(1))

Fixed submission:
N,M= map(int, input().split())
L,R= map(int, input().split())
flag = True
for i in range(M-1):
    a,b= map(int, input().split())
    if a >= L and b <= R:
        L = a
        R = b
    elif L <= b and R >= b:
        R = b
    elif L <= a and R >= a:
        L = a
    elif a < L and R < b:
        L = L
    else:
        flag = False
        break
if flag:
 print(R-L+1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
flag = False
for i in range(len(S)):
    if flag:
        break
    if S[i] == T[0]:
        tem = i+1
        f = 1
        for t in range(1,len(T)):
            if T[t] == S[tem]:
                tem += 1
                if tem == len(S):
                    tem = 0
            else:
                break
            if t == len(T)-1:
                flag = True
if flag:
    print('Yes')
else:
    print('No')

Fixed submission:
S = input()
T = input()
flag = False

for i in range(len(S)):
    if flag:
        break
    if S[i] == T[0]:
        tem = i+1
        f = 1
        if tem == len(S):
            tem = 0
        for t in range(1,len(T)):
            if T[t] == S[tem]:
                tem += 1
                if tem == len(S):
                    tem = 0
            else:
                break
            if t == len(T)-1:
                flag = True
if flag:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
N = int(input())
data = list(input())
bef_ans = 0
for i in range(N-1):#リーダー
  count = 0
  for t in range(N):#向いてるか
    if i < t:
      if data[t] == 'W':
        count += 1
    if i > t:
      if data[t] == 'E':
        count += 1
  if bef_ans < count:
    bef_ans = count
print(N - bef_ans-1)

Fixed submission:
N = int(input())
S = input()
 
eastNumber = S.count('E')
westNumber = 0
minimum = N
 
for i in range(N):
    if S[i] == 'E':
        eastNumber -= 1
        number = eastNumber + westNumber
        if minimum > number:
            minimum = number
    else:
        number = eastNumber + westNumber
        if minimum > number:
            minimum = number
        westNumber += 1
 
print(minimum)
Buggy python submission (verdict: Runtime Error):
N,M,X = map(int, input().split())
li = list(map(int, input().split()))
an1 = 0
an2 = 0
nu = 0
for i in range(1,X):
    if i == li[nu]:
        an1 += 1
        nu += 1
for i in range(X+1,N):
    if i == li[nu]:
        an2 += 1
        nu += 1
if an1 > an2:
    print(an2)
else:
    print(an1)

Fixed submission:
N,M,X = map(int, input().split())
li = list(map(int, input().split()))
a = 0
nu = 0
for i in range(1,X):
    if i == li[nu]:
        a += 1
        nu += 1
    if nu == len(li):
        break
b = len(li) - a
if a > b:
    print(b)
else:
    print(a)

Buggy python submission (verdict: Runtime Error):
N,M,X = map(int, input().split())
li = list(map(int, input().split()))
an1 = 0
an2 = 0
nu = 0
for i in range(1,X+1):
    if i == li[nu]:
        an1 += 1
        nu += 1
for i in range(X+1,N):
    if i == li[nu]:
        an2 += 1
        nu += 1
if an1 > an2:
    print(an2)
else:
    print(an1)

Fixed submission:
N,M,X = map(int, input().split())
li = list(map(int, input().split()))
a = 0
nu = 0
for i in range(1,X):
    if i == li[nu]:
        a += 1
        nu += 1
    if nu == len(li):
        break
b = len(li) - a
if a > b:
    print(b)
else:
    print(a)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,x=map(int,input().split())
ans = 0
for i in range(a,b+1):
  if i%x == 0:
    ans += 1
print(ans)

Fixed submission:
a, b, x = map(int, input().split())
ans = int(b//x) - int(a//x)
if a%x ==0:
    ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from operator import mul
from functools import reduce

def main():
    def factorization(n):
        l = []
        tmp = n
        for i in range(2, int(-(-tmp**0.5//1))+1):
            if tmp%i == 0:
                cnt = 0
                while tmp%i == 0:
                    cnt += 1
                    tmp //= i
                l.append(cnt+1)
                i += 1
        if tmp != 1:
            l.append(2)
        if l == []:
            if n != 1:
                l.append(2)
        if n == 1:
            l = [2]
        return l

    n = int(input())
    cnt = 0
    i = n
    for i in range(1, n):
        div = factorization(n-i)
        pattern = reduce(mul, div)
        cnt += pattern
    print(cnt-1) 
    
if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    cnt = 0
    # aが1からn-1まで動くと考える
    for a in range(1, n):
        # a*bがn-1以下であると考える
        cnt += (n-1) // a
    print(cnt)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    mod = 10 ** 9 + 7 #素数
    
    def modpow(x, n, mod):
        res = 1
        while n:
            if n % 2:
                res *= x % mod
                res %= res
            x *= x % mod
            n >>= 1
        return res
 
    # 全パターン:10 ** n
    all_p = modpow(10, n, mod)
    # 0を含まないパタンーン:9 ** n
    not_0 = modpow(9, n, mod)
    # 9を含まないパターン:9 ** n
    not_9 = modpow(9, n, mod)
    # 0と９を含まないパターン:8 ** n
    not_0_9 = modpow(8, n, mod)
    # 条件のパターン
    ans = (all_p - not_0 - not_9 + not_0_9) % mod
    print(ans)
 
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n = int(input())
    mod = 10 ** 9 + 7 #素数
    
    def modpow(x, n, mod):
        res = 1
        while n:
            if n % 2:
                res *= x % mod
                res %= mod
            x *= x % mod
            n >>= 1
        return res

    # 全パターン:10 ** n
    all_p = modpow(10, n, mod)
    # 0を含まないパタンーン:9 ** n
    not_0 = modpow(9, n, mod)
    # 9を含まないパターン:9 ** n
    not_9 = modpow(9, n, mod)
    # 0と９を含まないパターン:8 ** n
    not_0_9 = modpow(8, n, mod)
    # 条件のパターン
    ans = all_p - not_0 - not_9 + not_0_9
    print(ans%mod)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    cnt = 0
    while n > 1:
        a_max = max(a[:n])
        a_max_i = a.index(a_max)
        if a_max_i != n-1:
            cnt += (n - a_max_i) * a_max - sum(a[a_max_i:n])
        n = a_max_i
    print(cnt)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n = int(input())
    A = [int(x) for x in input().split()]
    maxv = 0
    ans = 0
    for a in A:
        if maxv > a:
            ans += maxv - a
        else:
            maxv = a  
    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    cnt = 0
    while n > 1:
        a_max = max(a[:n])
        a_max_i = a.index(a_max)
        cnt += (n - a_max_i) * a_max - sum(a[a_max_i:n])
        n = a_max_i
    print(cnt)
    
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n = int(input())
    A = [int(x) for x in input().split()]
    maxv = 0
    ans = 0
    for a in A:
        if maxv > a:
            ans += maxv - a
        else:
            maxv = a  
    print(ans)

if __name__ == '__main__':
    main()