Harryxun/stf_run huggingface dataset:
n = int(input(n))
print(n*(n-1)/2)

### FIXED CODE ###

n = int(input())
print(n*(n-1)//2)
N,M = map(int,input().split())
li = [-1 for i in range(3)]

for i in range(M):
    s,c = map(int,input().split())


    if li[s-1]==-1 or li[s-1]==c:
        li[s-1] = c
    else:
        print(-1)
        break
else:
    ans = 0
    for i in range(N):
        mm = li[i]
        if li[i]==-1 and i!=0:
            li[i] = 0
        elif li[i]==-1 and i==0:
            li[i] = 1
        ans = ans * 10 + li[i]

    if c == 0 and s==1 and N >= 2:
        print(-1)
    elif c == 0 and s==1 and N==1:
        print(0)
    else:
        print(ans)
    
    



### FIXED CODE ###

import sys

N,M = map(int,input().split())
li = [-1 for i in range(3)]

if M==0 and N==1:
    print(0)
elif M==0 and N==2:
    print(10)
elif M==0 and N==3:
    print(100)
if M==0:
    sys.exit()

for i in range(M):
    s,c = map(int,input().split())


    if li[s-1]==-1 or li[s-1]==c:
        li[s-1] = c
    else:
        print(-1)
        break
else:
    ans = 0
    for i in range(N):
        mm = li[i]
        if li[i]==-1 and i!=0:
            li[i] = 0
        elif li[i]==-1 and i==0:
            li[i] = 1
        ans = ans * 10 + li[i]

    if c == 0 and s==1 and N >= 2:
        print(-1)
    elif c == 0 and s==1 and N==1:
        print(0)
    else:
        print(ans)
import math

r = input()

# ??¢???
S = math.pi * r ** 2
# ?????¨
L = math.pi * r * 2

print "%f %f" %(S, L)

### FIXED CODE ###

import math

r = input()

S = math.pi * r ** 2
L = math.pi * r * 2

print "%f %f" %(S, L)
n=int(input())
A=[[] for i in range(n)]
for i in range(n-1):
  a,b = map(int,input().split())
  a,b = a-1,b-1
  A[a].append([b,i])
    
ans = [0]*(n-1)

def col(now,color):
  c=1
  for (b,j) in A[now]:
    if c==color:
      c+=1
    ans[j]=c
    col(b,c)
    c+=1
col(0,0)
print(max(ans))
for a in ans:
  print(a)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

n=int(input())
A=[[] for i in range(n)]
for i in range(n-1):
  a,b = map(int,input().split())
  a,b = a-1,b-1
  A[a].append([b,i])
    
ans = [0]*(n-1)

def col(now,color):
  c=1
  for (b,j) in A[now]:
    if c==color:
      c+=1
    ans[j]=c
    col(b,c)
    c+=1
col(0,0)
print(max(ans))
for a in ans:
  print(a)
n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort(reverse==True):
ans = 0
for i in range(k,n):
  ans += h[i]
print(ans)

### FIXED CODE ###

n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort(reverse=True)
ans = 0
if(k>=n):
  ans = 0
else:
  for i in range(k,n):
    ans += h[i]
print(ans)
from sys import stdin

li = [int(stdin.readline().rstrip()) for _ in range(5)]
k = int(stdin.readline().rstrip())

from itertools import combinations
lin = list(combinations(li, 2))

for i in li:
    if abs(lin[i][0]-lin[i][1]) > k:
        print(":(")
        exit()

print("Yay!")

### FIXED CODE ###

from sys import stdin

li = [int(stdin.readline().rstrip()) for _ in range(5)]
k = int(stdin.readline().rstrip())

from itertools import combinations
lin = list(combinations(li, 2))

for i in range(len(lin)):
    if abs(lin[i][0]-lin[i][1]) > k:
        print(":(")
        exit()

print("Yay!")
N, M = map(int, input().split())
A = list(map(int, input().split()))

s = sum(A)
A = sorted(A)
ans = 'Yes'
for i in M:
  if A[i] < s/(4*M): 
    ans = 'No'
    break
    
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
 
s = sum(A)
A = sorted(A, reverse=True)
ans = 'Yes'
for i in range(M):
  if A[i]*(4*M) < s: 
    ans = 'No'
    break

print(ans)
A = int(input())
B = int(input())
C = int((A + B))

if(C%2 == 1):
    print("IMPOSSIBLE")
else:
    K = C / 2
    print(int(K))

### FIXED CODE ###

A,B=(int(x) for x in input().split())
C = int((A + B))

if(C%2 == 1):
    print("IMPOSSIBLE")
else:
    K = C / 2
    print(int(K))
N = int(input())
S = []
for i in range(N):
  S.append(''.join(sorted(input())))

import collections
import math

c = collections.Counter(S)
ans = 0
for i in c.values():
    if i == 1:
      continue
    else:
      ans += math.factorial(i)/math.factorial(2)
print(int(ans))
    
  


### FIXED CODE ###

N = int(input())
S = []
for i in range(N):
  S.append(''.join(sorted(input())))

import collections
import math

c = collections.Counter(S)
ans = 0
for i in c.values():
    if i == 1:
      continue
    else:
      ans += i*(i-1)//2
print(int(ans))
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        s=input()
        k=int(input())
        if int(s[0])!=1:
            return s[0]
        else:
            cnt=0
            for i in s:
                if int(i)==1:
                    cnt+=1
                    if cnt>=k:
                        return 1
                else:
                    if cnt>=k:
                        return 1
                    else:
                        return i
    print(main())
resolve()

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    a,b=map(int, input().split())
    print(a*b-a-b+1)
resolve()
import numpy as np
n,k=list(map(int,input().split()))
a=np.array(map(int,input().split()))
if k>n:
   k=n-1
dp=np.array([int(0) for _ in range(n)])
dp[1]=abs(a[0]-a[1])
 
for i in range(2,n):
  ind = max(0,i-k)
  dp[i]=np.min(np.add(dp[ind:i],np.abs(a[i]-a[ind:i])))
print(dp[-1])

### FIXED CODE ###

n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
if k>n:
    k=n-1
dp=[int(0) for _ in range(n)]
dp[1]=abs(a[0]-a[1])
 
for i in range(2,n):
  ind = max(0,i-k)
  dp[i]=min([dp[v]+abs(a[i]-a[v]) for v in range(ind,i)])
  #dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]))
#print(dp[n-1])
print(dp[-1])
n=int(input())
a=int(input())
b=int(input())
c=a+b
print("Hello World" if n%2==1 else str(c))

### FIXED CODE ###

n=int(input())
if n==2:
  a=int(input())
  b=int(input())
  c=a+b
print("Hello World" if n%2==1 else str(c))
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m,k = inpl()
value = [[0 for _ in range(m)] for i in range(n)]
for _ in range(k):
    a,b,c = inpl()
    value[a-1][b-1] = c
dp = [0] * (4*(m+5)*(n+5))
def ind(i,j,k): 
    return 4*(n+5)*i + 5*j + k
for i in range(n):
    for j in range(m):
        for k in range(3)[::-1]:
            dp[ind(i,j,k+1)] = max(dp[ind(i,j,k+1)], dp[ind(i,j,k)] + value[i][j])
        for k in range(4):
            dp[ind(i+1,j,0)] = max(dp[ind(i+1,j,0)], dp[ind(i,j,k)])
            dp[ind(i,j+1,k)] = max(dp[ind(i,j+1,k)], dp[ind(i,j,k)])
# print(dp)
mx = 0
for k in range(4):
    mx = max(mx, dp[ind(n-1,m-1,k)])
print(mx)

### FIXED CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m,k = inpl()
value = [[0 for _ in range(m)] for i in range(n)]
for _ in range(k):
    a,b,c = inpl()
    value[a-1][b-1] = c
dp = [0] * (4*(m+1)*(n+1))
def ind(i,j,k): 
    return 4*(m+1)*i + 4*j + k
for i in range(n):
    for j in range(m):
        for k in range(3)[::-1]:
            dp[ind(i,j,k+1)] = max(dp[ind(i,j,k+1)], dp[ind(i,j,k)] + value[i][j])
        for k in range(4):
            dp[ind(i+1,j,0)] = max(dp[ind(i+1,j,0)], dp[ind(i,j,k)])
            dp[ind(i,j+1,k)] = max(dp[ind(i,j+1,k)], dp[ind(i,j,k)])
# print(dp)
mx = 0
for k in range(4):
    mx = max(mx, dp[ind(n-1,m-1,k)])
print(mx)
n = input()

h, w = (input().split() for in range(n))
a=0

if w =="JPY":
  a += h
else:
  a += h * 380000.0

print(a)

### FIXED CODE ###

n = int(input())
A=[]
for i in range(n):
  A.append(list(input().split()))
 
ans=0
for a in A:
    if a[1] =="JPY":
        ans += float(a[0])
    else:
        ans += float(a[0]) * 380000.0
print(ans)
N= map(int, input())
a = list(map(int,input().split()))

counter=0
for i in range(N):
  if (i+1)%2==1:
    if a[i]%2==1:
      counter+=1
print(counter)

### FIXED CODE ###

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

counter=0
for i in range(N):
  if (i+1)%2==1:
    if a[i]%2==1:
      counter+=1
print(counter)
N = int(input())

p = 3.141592653589

S = N**2*p
R = 2*pi*N

print(S, R)

### FIXED CODE ###

import math

r = float(input())

s = r*r*math.pi
v = 2*math.pi*r

S = round(s, 6)
V = round(v, 6)

print(S, V)
N,M = list(map(int,input().split()))
ans = [0 for i in range(N)]
anss = 0

for i in range(M):
    L,R = list(map(int,input().split()))
    if L == R:
        ans[L-1]+=1
    else:
        for j in range(L-1,R,1):
            ans[j]+=1

maxn = 0
for i in range(M):
    if ans[i] > maxn:
        maxn = ans[i]
        
for i in range(M):
    if ans[i] == maxn:
        anss += 1
print(anss)

### FIXED CODE ###

N,M = list(map(int,input().split()))
L = 1
R = N+1
ans = N*2

for i in range(M):
    tL,tR = list(map(int,input().split()))
    if tR < L or R < tL:
        ans = 0
        break
    if tL > L:
        L = tL
    if tR < R:
        R = tR

print(min(ans,R-L+1))
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]

nums = [0]*(N+1)
nums[0] = 1
if 1 not in a:
    nums[1] = 1
for i in range(2, N+1):
    print(nums)
    if not i in a:
      nums[i] = nums[i-1] + nums[i-2]

print(nums[N]%(1000000007))


### FIXED CODE ###

N, M = map(int, input().split())
a = set([int(input()) for _ in range(M)])

nums = [0]*(N+1)
nums[0] = 1
if 1 not in a:
    nums[1] = 1
for i in range(2, N+1):
    if not i in a:
      nums[i] = nums[i-1] + nums[i-2]

print(nums[N]%(1000000007))
import sys

def remove_bit(num, i):
    new_num = (num >> i + 1) << i
    new_num += num & ((1 << i) - 1)
    return new_num

def insert_bit(num1, num2, i):
    new_num = (num1 << 1) & ~(-1 + (1 << i + 1))
    new_num += num1 & (-1 + (1 << i + 1))
    new_num += num2 & (1 << i)
    return new_num

def solve(N, A, B):
    if N == 1:
        return [A, B]

    for i in range(N):
        if A >> i & 1 != B >> i & 1:
            r_bit = i
            break

    AA = remove_bit(A, r_bit)
    BB = remove_bit(B, r_bit)

    for i in range(N - 1):
        if (AA & 1 << i) == (BB & 1 << i):
            CC = AA & (-1 - (1 << i)) + (~AA & (1 << i))
            break
    A_list = solve(N - 1, AA, CC)
    B_list = solve(N - 1, CC, BB)

    A_list = list(map(lambda x: insert_bit(x, A, r_bit), A_list))
    B_list = list(map(lambda x: insert_bit(x, B, r_bit), B_list))

    return A_list + B_list


def main(N, A, B):
    if (bin(A).count('1') + bin(B).count('1')) % 2 == 0:
        print('NO')
        sys.exit()

    print('YES')
    ans_list = solve(N, A, B)

    assert A == ans_list[0]
    assert B == ans_list[-1]
    for i in range(len(ans_list) - 1):
        assert bin(ans_list[i] ^ ans_list[i+1]).count('1') == 1

    for num in ans_list:
        sys.stdout.write('%d '%num)
    print()



if __name__ == '__main__':
    N, A, B = map(int, input().split())
    main(N, A, B)


### FIXED CODE ###

import sys

def remove_bit(num, i):
    high = (num >> (i + 1)) << i
    low = num & ((1 << i) - 1)
    return high + low

def insert_bit(num1, num2, i):
    high = num1 >> i << (i + 1)
    low = num1 & (-1 + (1 << i))
    insert = num2 & (1 << i)
    return high + insert + low

def solve(N, A, B):
    if N == 1:
        return [A, B]

    r_bit = -1
    for i in range(N):
        if (A >> i) & 1 != (B >> i) & 1:
            r_bit = i
            break
    if r_bit == -1:
        import pdb; pdb.set_trace()

    AA = remove_bit(A, r_bit)
    BB = remove_bit(B, r_bit)

    C = -1
    for C in range(2**(N-1)):
        if bin(AA ^ C).count('1') % 2 == 1 and  bin(AA ^ C).count('1') % 2 == 1:
            break
    A_list = solve(N - 1, AA, C)
    B_list = solve(N - 1, C, BB)

    A_list = list(map(lambda x: insert_bit(x, A, r_bit), A_list))
    B_list = list(map(lambda x: insert_bit(x, B, r_bit), B_list))

    return A_list + B_list


def main(N, A, B):
    if (bin(A).count('1') + bin(B).count('1')) % 2 == 0:
        print('NO')
        sys.exit()

    print('YES')
    ans_list = solve(N, A, B)

    assert A == ans_list[0]
    assert B == ans_list[-1]
    for i in range(len(ans_list) - 1):
        assert bin(ans_list[i] ^ ans_list[i+1]).count('1') == 1

    for num in ans_list:
        sys.stdout.write('%d '%num)
    print()



if __name__ == '__main__':
    N, A, B = map(int, input().split())
    main(N, A, B)
number = int(intput())
print(number + number**2 + number**3)


### FIXED CODE ###

number = int(input())
print(number + number**2 + number**3)
a,b,c = tuple(map(int,input().split()))
if len(set((a,b,c)))<3:
  print(-1)
else:
  ans = 0
  while True:
    if a%2==0 and b%2==0 and c%2==0:
      a,b,c == b//2+c//2,c//2+a//2,a//2+b//2
      ans+=1
    else:
      break
    if len(set((a,b,c)))<3:
  print(-1)
      
  print(ans)


### FIXED CODE ###

a,b,c = tuple(map(int,input().split()))
if len(set((a,b,c)))==1 and a%2==1:
    print(0)
    exit()
ans = 0
while True:
  if len(set((a,b,c)))==1:
    print(-1)
    exit()
  if a%2==0 and b%2==0 and c%2==0:
    a,b,c = b//2+c//2,c//2+a//2,a//2+b//2
    ans+=1
  else:
    break
print(ans)
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    a = na()

    for _ in range(k):
        imos = [0 for _ in range(n)]

        for i, ai in enumerate(a):
            imos[max(0, i - ai)] += 1
            if i + ai + 1 < n:
                imos[i + ai + 1] -= 1

        val = 0
        for i, im in enumerate(imos):
            val += im
            a[i] = min(val, n)

        if min(a) == n:
            break

    print(*a, sep=" ")


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    a = na()

    for _ in range(min(k,42)):
        imos = [0 for _ in range(n)]

        for i, ai in enumerate(a):
            imos[max(0, i - ai)] += 1
            if i + ai + 1 < n:
                imos[i + ai + 1] -= 1

        val = 0
        for i, im in enumerate(imos):
            val += im
            a[i] = min(val, n)

        # if min(a) == n:
        #     break

    print(*a, sep=" ")


if __name__ == '__main__':
    main()
a, b, c = sorted(map(int.input().split()))

print("YES" if a+b == c else "No")

### FIXED CODE ###

a, b, c = sorted(map(int, input().split()))
print("Yes" if a+b == c else "No")
a,b=map(str,input().split())
if a=="H" and b="H" or a=="D" and b="D":
  print("H")
else:
  print("D")

### FIXED CODE ###

a,b=map(str,input().split())
if a==b:
  print("H")
else:
  print("D")
import numpy as np

n=int(input())
rain=np.array([int(i)*2 for i in input().split()])

a=np.eye(n,dtype=np.int64)
for i in range(n-1):
  a[i][i+1]=1
a[-1][0]=1

ans=np.linalg.solve(a,rain)
ans=ans.astype(np.int64)
print(*ans)

### FIXED CODE ###

def main():
  n=int(input())
  rain=[int(i) for i in input().split()]
  
  test=0
  for i in range(n):
    test=rain[i]-test
  ans=test
  
  fall=[0]*n
  fall[0]=test
  for i in range(n-1):
    tmp=rain[i]-fall[i]//2
    fall[i+1]=2*tmp
  
  print(*fall)
if __name__=='__main__':
  main()
s = input()

if 'hi' in s:
  print('Yes')
else:
  print('No)

### FIXED CODE ###

s = input()

if len(s.replace('hi', '')) == 0:
  print('Yes')
else:
  print('No')
while True:
    n = int(input())
    if n == 0:break
    a = [input() for _ in range(n)]
    while True:
        if len(a) == 1:break
        c = 0
        s = 0
        for i in range(len(a)):
            if a[i].count('.') > c:
                c = a[i].count('.')
                s = i
        e = s
        while e < len(a) and a[e].count('.') == a[s].count('.'):
            e += 1
        k = a[s - 1].replace('.', '')
        b = [a[i] for i in range(s, e)]
        for i in len(b):
            b[i] = int(b[i].replace('.', ''))
        if k == '+':
            a[s] = '.'*a[s].count('.')+str(sum(b))
            del a[s + 1:e]
        else:
            m = 1
            for i in b:
                m *= i
            a[s] = '.'*a[s].count('.')+str(m)
            del a[s + 1:e]
    print(a[0])
    


### FIXED CODE ###

while True:
    n = int(input())
    if n == 0:break
    a = [input() for _ in range(n)]
    while True:
        if len(a) == 1:break
        c = 0
        s = 0
        for i in range(len(a)):
            if a[i].count('.') > c:
                c = a[i].count('.')
                s = i
        e = s
        while e < len(a) and a[e].count('.') == a[s].count('.'):
            e += 1
        k = a[s - 1].replace('.', '')
        b = [a[i] for i in range(s, e)]
        for i in range(len(b)):
            b[i] = int(b[i].replace('.', ''))
        if k == '+':
            a[s - 1] = '.'*a[s - 1].count('.')+str(sum(b))
            del a[s:e]
        else:
            m = 1
            for i in b:
                m *= i
            a[s - 1] = '.'*a[s - 1].count('.')+str(m)
            del a[s:e]
    print(a[0])
N =  map(int,input().split())
N = N+1
a = []
for i in range(N):
    a.append(map(int, input().split())



for i in range(N):
    v = a[i]
    j = i-1
    while j>=0 and a[j]>v:
        a[j+1] = a[j]
        j = j-1
        a[j+1] = v
    print(a) 


### FIXED CODE ###

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


for i in range(N):
    v = b[i]
    j = i-1
    while j>=0 and b[j]>v:
        b[j+1] = b[j]
        j = j-1
        b[j+1] = v
    print(" ".join([str(n) for n in b]))
import bisect
import copy

N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
A2 = copy.deepcopy(A[N-M:])

for _ in range(M):
  tmp_a = int(A2[-1]/2)
  del A2[-1]
  if A2 <= tmp_a: A2.append(tmp_a)
  else: A2.insert(bisect.bisect_left(A2,tmp_a),tmp_a)
print(sum(A[:N-M])+sum(A2))

### FIXED CODE ###

import heapq

N,M = map(int,input().split())
A = []
for a in map(int,input().split()):
  heapq.heappush(A,-a)

cnt = 0
while cnt < M:
  a = heapq.heappop(A)
  heapq.heappush(A,-((-a)//2))
  cnt += 1
print(-sum(A))
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
d=0

for i in range(N):
  d+=b[a[i]+1]
  if i-1==e:
    d+=c[e]
  e=i
print(d)

### FIXED CODE ###

N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
d=0
ab=0
for i in range(N):
  d+=b[a[i]-1]
  
  if i != 0:
    if ab+1==a[i]:
      d+=c[ab-1]
   
  ab=a[i]
    
print(d)
N=int(input())
s=[]
for i in range(N):
    s.append(input())
print("AC x "+s.count("AC"))
print("WA x "+s.count("WA"))
print("TLE x "+s.count("TLE"))
print("RE x "+s.count("RE"))

### FIXED CODE ###

N=int(input())
s=[]
for i in range(N):
    s.append(input())
print("AC x ",s.count("AC"))
print("WA x ",s.count("WA"))
print("TLE x ",s.count("TLE"))
print("RE x ",s.count("RE"))
A11,A12,A13,A21,A22,A23,A31,A32,A33 = map(int,input().split(" "))
bingo = [A11,A12,A13,A21,A22,A23,A31,A32,A33]
bingo = ",".join(map(str,bingo))
N = int(input())
for i in range(N):
    b = input()
    if b in bingo:
        bingo.replace(b,True)
    else:
        pass
Bingo = bingo.split(",")
Flag = False
if Bingo[0] == Bingo[1] == Bingo[2]==True:
    Flag = True
if Bingo[3] == Bingo[4] == Bingo[6]==True:
    Flag = True
if Bingo[6] == Bingo[7] == Bingo[8]==True:
    Flag = True
if Bingo[0] == Bingo[3] == Bingo[6]==True:
    Flag = True
if Bingo[1] == Bingo[4] == Bingo[7]==True:
    Flag = True
if Bingo[2] == Bingo[5] == Bingo[8]==True:
    Flag = True
if Bingo[0] == Bingo[4] == Bingo[8]==True:
    Flag = True
if Bingo[2] == Bingo[4] == Bingo[6]==True:
    Flag = True
else:
    pass
if flag == True:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

N = int(input())
if N % 2 != 0:
    ans = (N//2)+1
if N % 2 == 0:
    ans = (N//2)
print(round(ans,N))
>>> a,b,c=map(int,input().split())
if a<c and c<b:
	print('Yes')
elif b<c and c<a:
  print('Yes')
else
	print('No')


### FIXED CODE ###

a,b,c=map(int,input().split())
if a<b:
	if a<c and c<b:
		print("Yes")
	else:
		print("No")
elif b<a:
	if b<c and c<a:
		 print("Yes")
	else:
		 print("No")
else:
	 print("No")
n = int(input())
inp = {}
for i in range(n):
  a = input()
  if inp.get(a) is not None:
    inp[a] = 0
  inp[a] += 1

  print(f"AC x {result['AC']}")
  print(f"WA x {result['WA']}")
  print(f"TLE x {result['TLE']}")
  print(f"RE x {result['RE']}")


### FIXED CODE ###

n = int(input())
inp = {}
for i in range(n):
    a = input()
    if inp.get(a) is None:
        inp[a] = 0
    inp[a] += 1
print(f"AC x {0 if inp.get('AC') is None else inp.get('AC')}")
print(f"WA x {0 if inp.get('WA') is None else inp.get('WA')}")
print(f"TLE x {0 if inp.get('TLE') is None else inp.get('TLE')}")
print(f"RE x {0 if inp.get('RE') is None else inp.get('RE')}")
def fill(s,x,y):
	if 0 <= x <= W-1 and 0 <= y <= H-1 and A[y][x] == s:
		A[y][x] = 0
		fill(s,x+1,y); fill(s,x,y+1); fill(s,x-1,y); fill(s,x,y-1)
while 1:
	H,W = map(int,raw_input().split())
	if H == 0: break
	A = [list(raw_input()) for i in range(H)]
	ans = 0
	for y in range(H):
		for x in range(W):
			if A[y][x] != 0:
				fill(A[y][x],x,y)
				ans += 1
	print ans

### FIXED CODE ###

import sys
sys.setrecursionlimit(20000)
def solve(h,w,count,c):
    if 0 <= h < H and 0 <= w < W and A[h][w] == c:
        A[h][w] = count
        for dh,dw in zip([1,0,-1,0],[0,1,0,-1]):
            solve(h+dh,w+dw,count,c)
while 1:
    H,W = map(int,raw_input().split())
    if H == W == 0: break
    A = [list(raw_input()) for _ in range(H)]
    count = 0
    for h in range(H):
        for w in range(W):
            if type(A[h][w]) is not int:
                solve(h,w,count,A[h][w])
                count += 1
    print count
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, sX, mod = mapint()

X = sX
s = set()
s.add(X)
s_loop = set()
ans = X
loop = 0
loops = []
for i in range(min(10**5*2+10, N-1)):
    X = pow(X, 2, mod)
    if X in s:
        if X in s_loop:
            loops.append(X)
            break
        loop += X
        s_loop.add(X)
        loops.append(X)
    s.add(X)
    ans += X

rest = N-i-2
try:
    if rest:
        ans += (rest//len(s_loop))*loop
        amari = rest%len(s_loop)+1
        for i in range(amari):
            ans += loops[i]
        print(ans)
    else:
        print(ans)
except:
    print(0)

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, sX, mod = mapint()

X = sX
s = set()
s.add(X)
s_loop = set()
ans = X
loop = 0
loops = []
i = -1
for i in range(min(10**5*2+10, N-1)):
    X = pow(X, 2, mod)
    if X in s:
        if X in s_loop:
            loops.append(X)
            break
        loop += X
        s_loop.add(X)
        loops.append(X)
    s.add(X)
    ans += X

rest = N-i-2
if rest:
    ans += (rest//len(s_loop))*loop
    amari = rest%len(s_loop)+1
    for i in range(amari):
        ans += loops[i]
    print(ans)
else:
    print(ans)