Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = [0] (N + 1)
for i in range (1, 101):
  for j in range(1, 101):
    for k in range(1, 101):
      n = i*i+j*j+k*k+i*j+j*k+k*i
      if n <= N:
        ans[n] += 1

print(*ans[1:], sep='\n')



Fixed submission:
N = int(input())
ans = [0] * (N + 1)
for i in range (1, 101):
  for j in range(1, 101):
    for k in range(1, 101):
      n = i*i+j*j+k*k+i*j+j*k+k*i
      if n <= N:
        ans[n] += 1

print(*ans[1:], sep='\n')

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

for n in range(1, N+1):
  count = 0
  for i in range (1, 101):
    if i*i > n:
      break
    for j in range(1, 101):
      if i*i+j*j > n:
        break
      for k in range(1, 101):
        if i*i+j*j+k*k >n:
          break
        if i*i+j*j+k*k+i*j+j*k+k*i == n:
          count += 1

  print(count)




Fixed submission:
N = int(input())
ans = [0] * (N + 1)
for i in range (1, 101):
  for j in range(1, 101):
    for k in range(1, 101):
      n = i*i+j*j+k*k+i*j+j*k+k*i
      if n <= N:
        ans[n] += 1

print(*ans[1:], sep='\n')

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

for n in range(1, N+1):
  count = 0
  for i in range (1, 101):
    if i*i > n:
      break
    for j in range(1, 101):
      if i*i+j*j > n:
        break
      for k in range(1, 101):
        if i*i+j*j+k*k >n:
          break
        if i*i+j*j+k*k+i*j+j*k+k*i == n:
          count += 1

  print(count)




Fixed submission:
N = int(input())
ans = [0] * (N + 1)
for i in range (1, 101):
  for j in range(1, 101):
    for k in range(1, 101):
      n = i*i+j*j+k*k+i*j+j*k+k*i
      if n <= N:
        ans[n] += 1

print(*ans[1:], sep='\n')

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

for n in range(1, N+1):
  count = 0
  for i in range (1, 101):
    for j in range(1, 101):
      for k in range(1, 101):
        if i*i+j*j+k*k+i*j+j*k+k*i == n:
          count += 1

  print(count)



Fixed submission:
N = int(input())
ans = [0] * (N + 1)
for i in range (1, 101):
  for j in range(1, 101):
    for k in range(1, 101):
      n = i*i+j*j+k*k+i*j+j*k+k*i
      if n <= N:
        ans[n] += 1

print(*ans[1:], sep='\n')

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

for n in range(1, N+1):
  count = 0
  for i in range (1, 101):
    for j in range(1, 101):
      for k in range(1, 101):
        if i*i+j*j+k*k+i*j+j*k+k*i == n:
          count += 1

  print(count)



Fixed submission:
N = int(input())
ans = [0] * (N + 1)
for i in range (1, 101):
  for j in range(1, 101):
    for k in range(1, 101):
      n = i*i+j*j+k*k+i*j+j*k+k*i
      if n <= N:
        ans[n] += 1

print(*ans[1:], sep='\n')
Buggy python submission (verdict: Runtime Error):
S = int(input())
if S == "ABC":
  print("ARC")
else:
  print("ABC")


Fixed submission:
S = input()
if S == "ABC":
  print("ARC")
else:
  print("ABC")

Buggy python submission (verdict: Runtime Error):
S = int(input())
if S == "ABC":
  print("ARC")
else:
  print("ABC")


Fixed submission:
S = input()
if S == "ABC":
  print("ARC")
else:
  print("ABC")
Buggy python submission (verdict: Runtime Error):
X = int(input())

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

flag = False
for x in range(A, B+1):
  if x % K == 0:
    flag = True
    
if flag:
  print("OK")
else: 
  print("NG")

Fixed submission:
K = int(input())

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

flag = False
for x in range(A, B+1):
  if x % K == 0:
    flag = True


if flag:
  print("OK")
else: 
  print("NG")

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

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

flag = False
for x in range(A, B+1):
  if x % K == 0:
    flag = True


if flag:
  print("OK")
else: 
  print("NG")

Fixed submission:
K = int(input())

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

flag = False
for x in range(A, B+1):
  if x % K == 0:
    flag = True


if flag:
  print("OK")
else: 
  print("NG")

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

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

flag = False
for x in range(A, B+1):
  if x % K == 0:
    flag = True


if flag:
  print("OK")
else: 
  print("NG")

Fixed submission:
K = int(input())

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

flag = False
for x in range(A, B+1):
  if x % K == 0:
    flag = True


if flag:
  print("OK")
else: 
  print("NG")
Buggy python submission (verdict: Runtime Error):
S, W = map(int, input().split())if W >= S:  print("unsafe")else:  print("safe")


Fixed submission:
S, W = map(int, input().split())
if W >= S:
  print("unsafe")
else:
  print("safe")

Buggy python submission (verdict: Runtime Error):
S, W = map(int, input().split())

if W &gt;= S:
  print("unsafe")
else:
  print("safe")

Fixed submission:
S, W = map(int, input().split())
if W >= S:
  print("unsafe")
else:
  print("safe")

Buggy python submission (verdict: Runtime Error):
S, W = map(int, input().split())
if W >= S:
  print(“unsafe”)
else:
  print(“safe”)

Fixed submission:
S, W = map(int, input().split())
if W >= S:
  print("unsafe")
else:
  print("safe")
Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())
for _ in range(10000):
  C -= B
  if C <= 0:
    print("Yes")
    exit()
  A -= D
  if A <= 0:
    print("No")
    exit()

Fixed submission:
A, B, C, D = map(int, input().split())
for _ in range(10000):
  C -= B
  if C <= 0:
    print("Yes")
    exit()
  A -= D
  if A <= 0:
    print("No")
    exit()

Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())

for _ in range(10000):
  C -= B
  if C <= 0:
    print("Yes")
    exit()

  A -= D
  if A <= 0:
    print("No")
    exit()


Fixed submission:
A, B, C, D = map(int, input().split())
for _ in range(10000):
  C -= B
  if C <= 0:
    print("Yes")
    exit()
  A -= D
  if A <= 0:
    print("No")
    exit()

Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())

for _ in range(10000):
  C -= B
  if C <= 0:
    print("Yes")
    exit()

  A -= D
  if A <= 0:
    print("No")
    exit()


Fixed submission:
A, B, C, D = map(int, input().split())
for _ in range(10000):
  C -= B
  if C <= 0:
    print("Yes")
    exit()
  A -= D
  if A <= 0:
    print("No")
    exit()
Buggy python submission (verdict: Runtime Error):
X = int(input())
if n==17:
  print('YES')
  
else:
  print('NO')

Fixed submission:
S = input()
if S[2] == S[3] and S[4] == S[5]:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
S = input()
if S[2] == S[3] and S[4] == S[5]:
  print("Yes")
else:
  print("No"

Fixed submission:
S = input()
if S[2] == S[3] and S[4] == S[5]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
X = int(input())
if X >= 500:
  q = X // 500 
  mod = X % 500 
  f = mod // 5
  print(q*1000+f*5)
else:
  f = X // 5
  print(f*5

Fixed submission:
X = int(input())
if X >= 500:
  q = X // 500 
  mod = X % 500 
  f = mod // 5
  print(q*1000+f*5)
else:
  f = X // 5
  print(f*5)
Buggy python submission (verdict: Runtime Error):
mod = 7+10**9
def ncr(n,c,mod):
  x = 1
  y = 1
  for i in range(n-c+1,n+1):
    x = x*i%mod
  for j in range(1,c+1):
    y = y*j%mod
  return (x * pow(y, mod-2, mod)) % mod

n, a, b = map(int, input().split())
al = pow(2, n, mod) -1
acr = ncr(n, a, mod)
bcr = ncr(n, b, mod)
print((al-(acr+bcr))%mod

Fixed submission:
mod = 7+10**9
def ncr(n,c,mod):
  x = 1
  y = 1
  for i in range(n-c+1,n+1):
    x = x*i%mod
  for j in range(1,c+1):
    y = y*j%mod
  return (x * pow(y, mod-2, mod)) % mod

n, a, b = map(int, input().split())
al = pow(2, n, mod) -1
acr = ncr(n, a, mod)
bcr = ncr(n, b, mod)
print( (al-(acr+bcr))%mod )

Buggy python submission (verdict: Time Limit Exceeded):
def ncr(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

N, a, b = map(int, input().split())
p = 10 ** 9 + 7
"N = 10 ** 6  # N は必要分だけ用意する"
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
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)

 
al = 2**N -1
acr = ncr(N, a, p)
bcr = ncr(N, b, p)
print(al-acr-bcr)

Fixed submission:
mod = 7+10**9
def ncr(n,c,mod):
  x = 1
  y = 1
  for i in range(n-c+1,n+1):
    x = x*i%mod
  for j in range(1,c+1):
    y = y*j%mod
  return (x * pow(y, mod-2, mod)) % mod

n, a, b = map(int, input().split())
al = pow(2, n, mod) -1
acr = ncr(n, a, mod)
bcr = ncr(n, b, mod)
print( (al-(acr+bcr))%mod )

Buggy python submission (verdict: Time Limit Exceeded):
def ncr(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

N, a, b = map(int, input().split())
p = 10 ** 9 + 7
"N = 10 ** 6  # N は必要分だけ用意する"
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
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)

 
al = 2**N -1
acr = ncr(N, a, p)
bcr = ncr(N, b, p)
print(al-acr-bcr)

Fixed submission:
mod = 7+10**9
def ncr(n,c,mod):
  x = 1
  y = 1
  for i in range(n-c+1,n+1):
    x = x*i%mod
  for j in range(1,c+1):
    y = y*j%mod
  return (x * pow(y, mod-2, mod)) % mod

n, a, b = map(int, input().split())
al = pow(2, n, mod) -1
acr = ncr(n, a, mod)
bcr = ncr(n, b, mod)
print( (al-(acr+bcr))%mod )
Buggy python submission (verdict: Runtime Error):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

data = np.fromstring(read(), np.int64, sep=' ')

N, K = data[:2]
P = np.hstack([[0], data[2:] + 1])

Pcum = P.custom()
x = Pcum[K:] - Pcum[0:-K]
print(x.max()/2)

Fixed submission:
N, K = map(int, input().split())
P = list(map(int, input().split()))
lst = [0]
for x in P:
  lst.append(lst[-1] + (x+1)/2)

res = -1
for i in range(N-K+1):
  sum = lst[i+K]-lst[i]
  res = max(res, sum)

print("{:.6f}".format(res))

Buggy python submission (verdict: Runtime Error):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as numpy

data = np.fromstring(read(), np.int64, sep = ' ')

N, K = data[:2]
P = np.hstack([[0], data[2:] + 1])

Pcum = P.custom()
x = Pcum[K:] - Pcum[0:-K]
print(x.max()/2)

Fixed submission:
N, K = map(int, input().split())
P = list(map(int, input().split()))
lst = [0]
for x in P:
  lst.append(lst[-1] + (x+1)/2)

res = -1
for i in range(N-K+1):
  sum = lst[i+K]-lst[i]
  res = max(res, sum)

print("{:.6f}".format(res))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = list(map(int, input().split()))
lst = []
for x in P:
  res = 0
  for y in range(x):
    c = 1/x
    res += (y+1)*c

  lst.append(res)

s = [0] 
s[0] = 0
for i in range(0, N):
  s.append(s[i] + lst[i])

res = -1
for i in range(N-K+1):
  sum = s[i+K]-s[i]
  res = max(res, sum)

print("{:.6f}".format(res))
 

Fixed submission:
N, K = map(int, input().split())
P = list(map(int, input().split()))
lst = [0]
for x in P:
  lst.append(lst[-1] + (x+1)/2)

res = -1
for i in range(N-K+1):
  sum = lst[i+K]-lst[i]
  res = max(res, sum)

print("{:.6f}".format(res))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = list(map(int, input().split()))
lst = []
for x in P:
  res = 0
  for y in range(x):
    c = 1/x
    res += (y+1)*c

  lst.append(res)

s = [0] 
s[0] = 0
for i in range(0, N):
  s.append(s[i] + lst[i])

res = -1
for i in range(N-K+1):
  sum = s[i+K]-s[i]
  res = max(res, sum)

print("{:.6f}".format(res))
 

Fixed submission:
N, K = map(int, input().split())
P = list(map(int, input().split()))
lst = [0]
for x in P:
  lst.append(lst[-1] + (x+1)/2)

res = -1
for i in range(N-K+1):
  sum = lst[i+K]-lst[i]
  res = max(res, sum)

print("{:.6f}".format(res))
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
 
if (A+B+C>=22):
  print("bust")

else:
  print("win")
 

Fixed submission:
A, B, C = map(int, input().split())
 
if (A+B+C>=22):
  print("bust")

else:
  print("win")
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())

L = list(map(int, input().split()))

listarray = itertools.combinations(L,3)
count = 0

for items in listarray:
  a = items[0]
  b = items[1]
  c = items[2]
  if a < b + c and b < c + a and c < a + b:
    count +=1

print(count)

Fixed submission:
from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))

L.sort()

ans = 0
for i in range(N - 2):
  a = L[i]
  for j in range(i + 1, N - 1):
    b = L[j]
    c = bisect_left(L, a + b)
    ans += c - j - 1

print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
d = {}
for s in S:
  d[s] = True
  
if 'N' in d:
  if 'S' not in d:
    print 'No'
    exit()
    
if 'S' in d:
  if 'N' not in d:
    print 'No'
    exit()

if 'E' in d:
  if 'W' not in d:
    print 'No'
    exit()
    
if 'W' in d:
  if 'E' not in d:
    print 'No'
    exit()  
    
print 'Yes'

Fixed submission:
S = input()
d = {}

for s in S:
  d[s] = True

if 'N' in d:
  if 'S' not in d:
    print("No")
    exit()
    
if "S" in d:
  if 'N' not in d:
    print("No")
    exit()

if "E" in d:
  if "W" not in d:
    print("No")
    exit()
    
if "W" in d:
  if "E" not in d:
    print("No")
    exit()  
    
print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ret = 1
a = list(map(int, input().split()))
for ai in a:
    ret *= ai
if ret > 1000000000000000000:
    print(-1)
else:
    print(ret)


Fixed submission:
n = int(input())
ret = 1
a = sorted(list(map(int, input().split())))
for ai in a:
    ret *= ai
    if ret > 1000000000000000000:
        print(-1)
        exit(0)
print(ret)
Buggy python submission (verdict: Runtime Error):
m = int(input())
csum = 0
dsum = 0
for i in range(m):
  d,c = (int(x) for x in input().split())
  csum += c
  dsum += d*c
print(csum-1 + (dsum-1) // 9)


Fixed submission:
m = int(input())
csum = 0
dsum = 0
for i in range(m):
  d,c = (int(x) for x in input().split())
  csum += c
  dsum += d*c
print(csum-1 + (dsum-1) // 9)
Buggy python submission (verdict: Runtime Error):
N,T = int(x) for x in input().split()
C = 2000
for i in range(N):
  c,t = int(x) for x in input().split()
  if t <= T:
    C = min(c,C)
    
if C == 2000:
  print("TLE")
else: print(C)


Fixed submission:
N,T = (int(x) for x in input().split())
C = 2000
for i in range(N):
  c,t = (int(x) for x in input().split())
  if t <= T:
    C = min(c,C)
    
if C == 2000:
  print("TLE")
else: print(C)

Buggy python submission (verdict: Runtime Error):
N,T = int(input().split())
C = 2000
for i in range(N):
  c,t = int(input().split())
  if t <= T:
    C = min(c,C)
    
if C == 2000:
  print("TLE")
else: print(C)

Fixed submission:
N,T = (int(x) for x in input().split())
C = 2000
for i in range(N):
  c,t = (int(x) for x in input().split())
  if t <= T:
    C = min(c,C)
    
if C == 2000:
  print("TLE")
else: print(C)
Buggy python submission (verdict: Runtime Error):
s = input()
ans = ""
for i in s:
  if(i == '9'):
    ans += '1'
  else if(i == '1'):
    ans += '9'
  else:
    ans += i
    
print(ans)


Fixed submission:
s = input()
ans = ""
for i in s:
  if(i == '9'):
    ans += '1'
  elif(i == '1'):
    ans += '9'
  else:
    ans += i
    
print(ans)

Buggy python submission (verdict: Runtime Error):
s = input()
ans = ""
for i in s:
  if(i == "9"):
    ans += "1"
  else if(i == "1"):
    ans += "9"
  else:
    ans += i
    
print(ans)

Fixed submission:
s = input()
ans = ""
for i in s:
  if(i == '9'):
    ans += '1'
  elif(i == '1'):
    ans += '9'
  else:
    ans += i
    
print(ans)
Buggy python submission (verdict: Runtime Error):
a = map(int, input.split())
a = sorted(a)
ans = 0
ans += a[1] - a[0]
ans += a[2] - a[1]
print(ans)

Fixed submission:
a = map(int, input().split())
a = sorted(a)
ans = 0
ans += a[1] - a[0]
ans += a[2] - a[1]
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
if(n %2=1):
  n *= 2
print(n)

Fixed submission:
n = int(input())
if(n %2==1):
  n *= 2
print(n)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input())
if(a <= 8 and b <= 8):
  print('Yay!')
else:
  print(':(')

Fixed submission:
a,b = map(int,input().split())
if(a <= 8 and b <= 8):
  print('Yay!')
else:
  print(':(')
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a = list(map(int,input().split()))
p = 1;
for i in range(k):
	p *= a[i]
for i in range(k,n):
	r = p
	r /= a[i-k]
	r *= a[i]
	if r > p:
		print("Yes")
	else:
		print("No")
	p = r

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
p = 1
for i in range(k,n):
	if a[i] > a[i-k]:
		print("Yes")
	else:
		print("No")
Buggy python submission (verdict: Runtime Error):
from math import gcd
def lcm(a,b):
	p = a*b
	g = gcd(a,b);
	return p//g
MOD = int(10**9+7)
n = int(input())
a = list(map(int,input().split()))
lc = a[0];
for i in range(1,n):
	lc = lcm(a[i],lc)
ans = 0
for i in range(n):
	ans += (lc//a[i])
	ans %= MOD
print(ans)

Fixed submission:
def gcd(a,b):
	if b == 0:
		return a
	return gcd(b,a%b)

def lcm(a,b):
	p = a*b
	g = gcd(a,b);
	return p//g
MOD = int(10**9+7)
n = int(input())
a = list(map(int,input().split()))
lc = a[0];
for i in range(1,n):
	lc = lcm(a[i],lc)
ans = 0
for i in range(n):
	ans += (lc//a[i])
print(ans%MOD)

Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b):
	if b == 0:
		return a
	return gcd(b,a%b)

def lcm(a,b):
	p = a*b
	g = gcd(a,b);
	return p//g
MOD = int(10**9+7)
n = int(input())
a = list(map(int,input().split()))
lc = a[0];
for i in range(1,n):
	lc = lcm(a[i],lc)
ans = 0
for i in range(n):
	ans += (lc//a[i])
	ans %= MOD
print(ans)

Fixed submission:
def gcd(a,b):
	if b == 0:
		return a
	return gcd(b,a%b)

def lcm(a,b):
	p = a*b
	g = gcd(a,b);
	return p//g
MOD = int(10**9+7)
n = int(input())
a = list(map(int,input().split()))
lc = a[0];
for i in range(1,n):
	lc = lcm(a[i],lc)
ans = 0
for i in range(n):
	ans += (lc//a[i])
print(ans%MOD)

Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b):
	if b == 0:
		return a
	return gcd(b,a%b)

def lcm(a,b):
	p = a*b
	g = gcd(a,b);
	return p//g
MOD = int(10**9+7)
n = int(input())
a = list(map(int,input().split()))
lc = a[0];
for i in range(n):
	lc = lcm(a[i],lc)
ans = 0
for i in range(n):
	ans += (lc//a[i])
	ans %= MOD
print(ans)

Fixed submission:
def gcd(a,b):
	if b == 0:
		return a
	return gcd(b,a%b)

def lcm(a,b):
	p = a*b
	g = gcd(a,b);
	return p//g
MOD = int(10**9+7)
n = int(input())
a = list(map(int,input().split()))
lc = a[0];
for i in range(1,n):
	lc = lcm(a[i],lc)
ans = 0
for i in range(n):
	ans += (lc//a[i])
print(ans%MOD)
Buggy python submission (verdict: Time Limit Exceeded):
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
  
n = int(input())
c = 1
ans = 0
while n-c>0:
  #print(make_divisors(n-c))
  ans += len(make_divisors(n-c))
  c += 1
print(ans)


Fixed submission:
n = int(input())
ans = 0
for i in range(1,n):
    ans += (n-1)//i
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
  
n = int(input())
c = 1
ans = 0
while n-c>0:
  #print(make_divisors(n-c))
  ans += len(make_divisors(n-c))
  c += 1
print(ans)


Fixed submission:
n = int(input())
ans = 0
for i in range(1,n):
    ans += (n-1)//i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,x,m = map(int,input().split())
a = []
a.append(0)
a.append(x)
isBreak = False
for i in range(1,n):
  #tmp = (a[i]**2)%m
  tmp = (a[i]%m)*(a[i]%m)
  tmp = tmp%m
  if tmp==0:
    break
  if tmp in a:
    isBreak = True
    break
  a.append(tmp)
#print(a)
if isBreak:
  i = 1
  while a[i]!=tmp:
    i+=1
  kurikaeshi = len(a) - i
  goukei = sum(a[i:])
  #print(goukei)
  tmp=(n-(len(a)-1))
  #print(tmp//kurikaeshi)
  a.append(tmp//kurikaeshi * goukei)
  #print(a)
  tmp = tmp%kurikaeshi
  if tmp!=0:
    t = sum(a[i:i+tmp])
    a.append(t)
print(sum(a))

Fixed submission:
n,x,m = map(int,input().split())
a = []
a.append(0)
a.append(x)
isBreak = False
for i in range(1,n):
  #tmp = (a[i]**2)%m
  tmp = (a[i]%m)*(a[i]%m)
  tmp = tmp%m
  if tmp==0:
    break
  if tmp in a:
    isBreak = True
    break
  a.append(tmp)
#print(a)
if isBreak:
  i = 1
  while a[i]!=tmp:
    i+=1
  kurikaeshi = len(a) - i
  goukei = sum(a[i:])
  #print(goukei)
  tmp=(n-(len(a)-1))
  #print(tmp//kurikaeshi)
  a.append(tmp//kurikaeshi * goukei)
  #print(a)
  tmp = tmp%kurikaeshi
  if tmp!=0:
    t = sum(a[i:i+tmp])
    a.append(t)
print(sum(a))

Buggy python submission (verdict: Runtime Error):
n,x,m = map(int,input().split())
a = []
a.append(0)
a.append(x)
for i in range(1,n):
  #tmp = (a[i]**2)%m
  tmp = (a[i]%m)*(a[i]%m)
  tmp = tmp%m
  if tmp==0:
    break
  if tmp in a:
    break
  a.append(tmp)
#print(a)
i = 1
while a[i]!=tmp:
  i+=1
kurikaeshi = len(a) - i
goukei = sum(a[i:])
#print(goukei)
tmp=(n-(len(a)-1))
#print(tmp//kurikaeshi)
a.append(tmp//kurikaeshi * goukei)
#print(a)
tmp = tmp%kurikaeshi
if tmp!=0:
  t = sum(a[i:i+tmp])
  a.append(t)
print(sum(a))

Fixed submission:
n,x,m = map(int,input().split())
a = []
a.append(0)
a.append(x)
isBreak = False
for i in range(1,n):
  #tmp = (a[i]**2)%m
  tmp = (a[i]%m)*(a[i]%m)
  tmp = tmp%m
  if tmp==0:
    break
  if tmp in a:
    isBreak = True
    break
  a.append(tmp)
#print(a)
if isBreak:
  i = 1
  while a[i]!=tmp:
    i+=1
  kurikaeshi = len(a) - i
  goukei = sum(a[i:])
  #print(goukei)
  tmp=(n-(len(a)-1))
  #print(tmp//kurikaeshi)
  a.append(tmp//kurikaeshi * goukei)
  #print(a)
  tmp = tmp%kurikaeshi
  if tmp!=0:
    t = sum(a[i:i+tmp])
    a.append(t)
print(sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
n,x,m = map(int,input().split())
a = []
a.append(0)
a.append(x)
for i in range(1,n):
  #tmp = (a[i]**2)%m
  tmp = (a[i]%m)*(a[i]%m)
  tmp = tmp%m
  a.append(tmp)
  if tmp==0:
    break
print(sum(a))


Fixed submission:
n,x,m = map(int,input().split())
a = []
a.append(0)
a.append(x)
isBreak = False
for i in range(1,n):
  #tmp = (a[i]**2)%m
  tmp = (a[i]%m)*(a[i]%m)
  tmp = tmp%m
  if tmp==0:
    break
  if tmp in a:
    isBreak = True
    break
  a.append(tmp)
#print(a)
if isBreak:
  i = 1
  while a[i]!=tmp:
    i+=1
  kurikaeshi = len(a) - i
  goukei = sum(a[i:])
  #print(goukei)
  tmp=(n-(len(a)-1))
  #print(tmp//kurikaeshi)
  a.append(tmp//kurikaeshi * goukei)
  #print(a)
  tmp = tmp%kurikaeshi
  if tmp!=0:
    t = sum(a[i:i+tmp])
    a.append(t)
print(sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
#D 400

def devide(n):
    tmp = 0
    if 3<=n:
        tmp += 1
    for i in range(3,n+1):
        if n-i>=3:
            tmp += devide(n-i)
    return tmp
    
s = int(input())
print(devide(s)%(10**9+7))



Fixed submission:
#D 400

def devide(n):
    if memo[n]!=-1:
        return memo[n]
    tmp = 0
    if 3<=n:
        tmp += 1
    for i in range(3,n+1):
        if n-i>=3:
            tmp += devide(n-i)
    memo[n] = tmp
    return tmp
    
s = int(input())
memo = [-1 for i in range(s+1)]
print(devide(s)%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = 0

for i in range(n-1):
    for j in range(i+1,n):
        ans += a[i]*a[j]
print(ans%(10**9+7))


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 0

#for i in range(n-1):
#    for j in range(i+1,n):
#        ans += a[i]*a[j]
ans = 0
sum_a = 0
for i in range(n):
    ans += a[i]**2
    sum_a += a[i]
tmp = (sum_a ** 2 - ans)//2
print(tmp%(10**9+7))