Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()

i = 0
ans = []
while i < len(s) - len(t):
    cnt = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            cnt += 1
    ans.append(cnt)
    i += 1

print(min(ans))

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

i = 0
ans = []
while i <= len(s) - len(t):
    cnt = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            cnt += 1
    ans.append(cnt)
    i += 1

print(min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())
a = np.array([int(x) for x in input().split()])
mod = 10**9+7
mod_sum = 0
for i in range(n-1):
    mod_sum += a[i] * sum(a[i+1:]) % mod

print(mod_sum%mod)


Fixed submission:
import numpy as np

n = int(input())
a = np.array([int(x) for x in input().split()])
mod = 10**9+7
mod_sum = 0
a_sum = sum(a)
for i in range(n-1):
    a_sum -= a[i]
    mod_sum += (a[i] % mod) * (a_sum % mod) % mod

print(mod_sum%mod)
Buggy python submission (verdict: Runtime Error):
import numpy as np

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

a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

a_cum = np.cumsum(a)
b_cum = np.cumsum(b)

j = m-1
ans = 0
for i in range(n):
    if a_cum[i] > k:
        break
    while a_cum[i] + b_cum[j] > k:
        j -= 1
    ans = max(ans, i + 1 + j + 1)
    
print(ans)


Fixed submission:
import numpy as np

n, m, k = map(int, input().split())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

a = [0]
b = [0]

a = np.append(a, np.cumsum(A))
b = np.append(b, np.cumsum(B))

j = m
ans = 0
for i in range(n + 1):
    if a[i] > k:
        break
    while a[i] + b[j] > k:
        j -= 1
    ans = max(ans, i + j)
    
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = list(map(int, input().split()))

if 0 in A: 
    print (0)
    return

prod = 1 for a in A:
    prod *= a
    
if prod > 1000000000000000000:
    print(-1) 
    return

Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))

    if 0 in A: 
        print(0)
        return

    prod = 1 
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1) 
            return

    print(prod)

main()
Buggy python submission (verdict: Runtime Error):
mport numpy as np
import math

A, B, H, M = map(int, input().split())

d = np.sqrt((B*math.cos(6*M)-A*math.cos(30*H+M/2))**2+ (B*math.sin(6*M)-A*math.sin(30*H+M/2))**2)
print(d)

Fixed submission:
import numpy as np
import math


A, B, H, M = map(int, input().split())

d = np.sqrt((B*math.cos(math.radians(6*M))-A*math.cos(math.radians(30*H+M/2)))**2+(B*math.sin(math.radians(6*M))-A*math.sin(math.radians(30*H+M/2)))**2)
print(d)

Buggy python submission (verdict: Runtime Error):
import numpy as np
import math

A, B, H, M = map(int, input().split())

d = np.sqrt((B*math.cos(6*M)-A*math.cos(6*H+M/4))**2+/
            (B*math.sin(6*M)-A*math.sin(6*H+M/4))**2)
print(d)

Fixed submission:
import numpy as np
import math


A, B, H, M = map(int, input().split())

d = np.sqrt((B*math.cos(math.radians(6*M))-A*math.cos(math.radians(30*H+M/2)))**2+(B*math.sin(math.radians(6*M))-A*math.sin(math.radians(30*H+M/2)))**2)
print(d)
Buggy python submission (verdict: Runtime Error):
S = str(int(input()))
if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
    print('Bad')
else:
    print('Good')

Fixed submission:
S = str(input())
if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
    print('Bad')
else:
    print('Good')

Buggy python submission (verdict: Runtime Error):
S = str(int(input()))
if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
    print('Bad')
else:
    print('Good')

Fixed submission:
S = str(input())
if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
    print('Bad')
else:
    print('Good')

Buggy python submission (verdict: Runtime Error):
S = str(int(input("４桁の数字を入力してください。＞＞＞")))
cnt = 0
for i in range(1, 4):
    cnt+=1
    if S[i] == S[i-1]:
        print('Bad')
        break
    elif cnt == 3:
        print('Good')

Fixed submission:
S = str(input())
if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
    print('Bad')
else:
    print('Good')

Buggy python submission (verdict: Runtime Error):
S = str(int(input("４桁の数字を入力してください。＞＞＞")))
cnt = 0
for i in range(1, 4):
    cnt+=1
    if S[i] == S[i-1]:
        print('Bad')
        break
    elif cnt == 3:
        print('Good')

Fixed submission:
S = str(input())
if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
    print('Bad')
else:
    print('Good')
Buggy python submission (verdict: Runtime Error):
import sys, re
import math
import numpy as np
from decimal import Decimal
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul	# 
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd	# 最大公約数
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.maxsize = 10 ** 15
sys.setrecursionlimit(10 ** 9 + 7)
INF = float('inf')
MOD = 10 ** 9 + 7

# -*- coding: utf-8 -*-

n = input()
if n[len(n) - 1] == s:
    print(n + "es")
else:
    print(n + "s")

Fixed submission:
import sys, re
import math
import numpy as np
from decimal import Decimal
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul	# 
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd	# 最大公約数
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.maxsize = 10 ** 15
sys.setrecursionlimit(10 ** 9 + 7)
INF = float('inf')
MOD = 10 ** 9 + 7

# -*- coding: utf-8 -*-

n = input()
if n[-1] == "s":
    print(n + "es")
else:
    print(n + "s")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = []

addFlag = True

for x in range(n):
    text = input()
    addFlag = True
    for y in list:
        if text == y:
            addFlag = False
            break
    if addFlag:
        list.append(text)
        
print(len(list))

Fixed submission:
import sys
import collections

n = int(sys.stdin.readline().strip())
data = []

for x in range(n):
    data.append(input())

print(len(collections.Counter(data)))

Buggy python submission (verdict: Time Limit Exceeded):
import sys, re
import math
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul	# 
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd	# 最大公約数
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

# -*- coding: utf-8 -*-
n = INT()
list = []

addFlag = True

for x in range(n):
    text = input()
    addFlag = True
    for y in list:
        if text == y:
            addFlag = False
            break
    if addFlag:
        list.append(text)
        
print(len(list))

Fixed submission:
import sys
import collections

n = int(sys.stdin.readline().strip())
data = []

for x in range(n):
    data.append(input())

print(len(collections.Counter(data)))
Buggy python submission (verdict: Runtime Error):
a = int(input())
print(a * pi * 2)

Fixed submission:
import sys, re
import math
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul	# 
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd	# 最大公約数
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

# -*- coding: utf-8 -*-

a = INT() 
print(a * pi * 2)
Buggy python submission (verdict: Time Limit Exceeded):
import sys, re
import math
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
 
# 整数リストを連結表示    print(''.join(map(str, list)))
 
# -*- coding: utf-8 -*-
 
k = INT()
sum = 0

for a in range(1, k + 1):
    for b in range(1, k + 1):
        for c in range(1, k + 1):
            sum += math.gcd(math.gcd(a, b), c)

print(sum)

Fixed submission:
import sys, re
import math
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
 
# 整数リストを連結表示    print(''.join(map(str, list)))
 
# -*- coding: utf-8 -*-
 
k = INT()
sum = 0


def A(value, sum):
    if value == 0:
        print(sum)
    else:
        for b in range(1, k + 1):
            for c in range(1, k + 1):
                sum += math.gcd(math.gcd(value, b), c)
        A(value - 1, sum)

A(k, 0)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
char = ""
count = 0

for i in range(len(s)):
    for j in range(i + 1, len(s)):
        if s[j] != s[i]:

            if s[i] == "R":
               if s[j] == "G": char = "B"
               else: char = "G"
            elif s[i] == "G":
                if s[j] == "R": char = "B"
                else: char = "R"
            else:   # s[i] は B
                if s[j] == "G": char = "R"
                else: char = "G"
            a = j - i

            for k in range(j + 1, len(s)):     
                if s[k] == char and a != k - j:
                    count += 1
print(count)

Fixed submission:
import math

n = int(input())
s = input()
count = 0

rCount = s.count("R")
gCount = s.count("G")
bCount = s.count("B")
ans = rCount * gCount * bCount

for dis in range(1, math.ceil(len(s) / 2)):
    for i in range(dis, len(s) - dis):
        if s[i-dis] != s[i] and s[i-dis] != s[i+dis] and s[i] != s[i+dis]:
            ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
count = 0

for i in range(len(s)):
        for j in range(i + 1, len(s)):
            if s[j] != s[i]:
                for k in range(j + 1, len(s)):
                    if s[k] != s[j] and s[k] != s[i] and j - i != k - j:
                        count += 1
print(count)


Fixed submission:
import math

n = int(input())
s = input()
count = 0

rCount = s.count("R")
gCount = s.count("G")
bCount = s.count("B")
ans = rCount * gCount * bCount

for dis in range(1, math.ceil(len(s) / 2)):
    for i in range(dis, len(s) - dis):
        if s[i-dis] != s[i] and s[i-dis] != s[i+dis] and s[i] != s[i+dis]:
            ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
count = 0
len = len(s)

for i in range(len):
        for j in range(i, len):
            if s[j] != s[i]:
                for k in range(j, len):
                    if s[k] != s[j] and s[k] != s[i] and j - i != k - j:
                        count += 1
print(count)

Fixed submission:
import math

n = int(input())
s = input()
count = 0

rCount = s.count("R")
gCount = s.count("G")
bCount = s.count("B")
ans = rCount * gCount * bCount

for dis in range(1, math.ceil(len(s) / 2)):
    for i in range(dis, len(s) - dis):
        if s[i-dis] != s[i] and s[i-dis] != s[i+dis] and s[i] != s[i+dis]:
            ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
count = 0

for i in range(len(s)):
        for j in range(i, len(s)):
            if s[j] != s[i]:
                for k in range(j, len(s)):
                    if s[k] != s[i] and s[k] != s[j] and j - i != k - j:
                        count += 1
print(count)

Fixed submission:
import math

n = int(input())
s = input()
count = 0

rCount = s.count("R")
gCount = s.count("G")
bCount = s.count("B")
ans = rCount * gCount * bCount

for dis in range(1, math.ceil(len(s) / 2)):
    for i in range(dis, len(s) - dis):
        if s[i-dis] != s[i] and s[i-dis] != s[i+dis] and s[i] != s[i+dis]:
            ans -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = MAP()

ans = 0

for x in range(0, n ):
    ans += x
for x in range(0, m ):
    ans += x

print(ans)

Fixed submission:
import sys, re
import math
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7


n, m = MAP()

ans = 0

for x in range(0, n ):
    ans += x
for x in range(0, m ):
    ans += x

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import re
import queue
import collections
import math
import sympy
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []


def main():
	N = i_input()
	sum = 0
	for i in range(1,N):
		sum += (N-1) // i

	print(sum)

	return

if __name__ == '__main__':
	main()

Fixed submission:
import sys
import re
import queue
import collections
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []


def main():
	N = i_input()
	sum = 0
	for i in range(1,N):
		sum += (N-1) // i

	print(sum)

	return

if __name__ == '__main__':
	main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import re
import queue
import collections
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []


def main():
	N,K= i_map()
	L = []
	R = []
	for i in range(0,K):
		tmpL,tmpR = i_map()
		L.append(tmpL)
		R.append(tmpR)

	a = []
	a.append(0)
	a.append(-1)
	for i in range(2,3*N):
		a.append(0)

	f = []
	f.append(1)

	for i in range(0,N):
		for j in range(0,K):
			a[i+L[j]] += f[i]
			a[i+R[j]+1] += -f[i]
		f.append(f[i]+a[i+1])

	print(f[N-1]%998244353)

	return

if __name__ == '__main__':
	main()

Fixed submission:
import sys
import re
import queue
import collections
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []


def main():
	N,K= i_map()
	m = 998244353
	L = []
	R = []
	for i in range(0,K):
		tmpL,tmpR = i_map()
		L.append(tmpL)
		R.append(tmpR)

	a = []
	a.append(0)
	a.append(-1)
	for i in range(2,3*N):
		a.append(0)

	f = []
	f.append(1)

	for i in range(0,N):
		for j in range(0,K):
			a[i+L[j]] += f[i]
			a[i+R[j]+1] += -f[i]
		f.append((f[i]+a[i+1])%m)

	print(f[N-1]%m)

	return

if __name__ == '__main__':
	main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import re
import queue
import collections
import math
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []


def main():
	N,K = i_map()
	A = i_list()

	for i in range(0,len(A)):
		A[i] = A[i] - 1

	lengthA = math.ceil(math.log2(K))

	next = [[0 for _ in range(N)] for _ in range(lengthA)]
	
	for i in range(0,N):
		next[0][i] = A[(i)%(N)]

	for i in range(1,lengthA):
		for j in range(0,N):
			next[i][j] = next[i-1][next[i-1][j]]

	current = 0

	for i in range(0,lengthA):
		if((1 << i) & K):
			current = next[i][current]

	print(current+1)

	return

if __name__ == '__main__':
	main()

Fixed submission:
import sys
import re
import queue
import collections
import math
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []


def main():
	N,K = i_map()
	A = i_list()

	for i in range(0,len(A)):
		A[i] = A[i] - 1

	lengthA = math.ceil(math.log2(K))

	next = [[0 for _ in range(N)] for _ in range(lengthA)]
	
	for i in range(0,N):
		next[0][i] = A[(i)%(N)]

	for i in range(1,lengthA):
		for j in range(0,N):
			next[i][j] = next[i-1][next[i-1][j]]

	current = 0

	for i in range(0,lengthA):
		if((1 << i) & K):
			current = next[i][current]

	print(current+1)

	return

if __name__ == '__main__':
	main()
Buggy python submission (verdict: Runtime Error):


def main():
    n, x, m = map(int, input().split())
    mflg = [0] + [-1] * (m-1)
    ltot = [x]

    tot = x
    a = x
    for i in range(1, n):
        a = a ** 2 % m
        if mflg[a-1] >= 0:
            z = (n - i) // (i - mflg[a-1]) - 1
            y = (n - j) % (i - mflg[a-1])
            tot += (ltot[mflg[a-1] - 1 + y] - ltot[mflg[a-1] - 1]) + (ltot[-1] - ltot[mflg[a-1] - 1]) * z
            break
        
        mflg[a-1] = i
        tot += a
        ltot.append(tot)

    print(tot)


main()



Fixed submission:


def main():
    n, x, m = map(int, input().split())
    mflg = [-1] * m
    mflg[x] = 0
    ltot = [x]

    tot = x
    a = x
    for i in range(1, n):
        a = a ** 2 % m

        if mflg[a] >= 0:
            b = mflg[a]
            z = (n - i) // (i - b)
            y = (n - i) % (i - b)
            if b == 0 and y == 0:
                tot += ltot[i - 1] * z
            elif b == 0:
                tot += ltot[b - 1 + y] + ltot[i - 1] * z
            else:
                tot += (ltot[b - 1 + y] - ltot[b - 1]) + (ltot[i - 1] - ltot[b - 1]) * z
            break

        mflg[a] = i
        tot += a
        ltot.append(tot)

    print(tot)


main()