Harryxun/stf_run huggingface dataset:
def resolve():
  N, X, M = map(int, input().split(" "))
  checked = [False] * M
  val = X
  ans = val
  val_list = [val]
  checked[val] = val

  base = M
  for i in range(N-1):
    val*=val
    if val >= base:
      val %= base

    if checked[val] != False:
      loop_start_index = checked[val]+1

      loop_val = sum(val_list[loop_start_index:])
      loop_length = len(val_list[loop_start_index:])
      
      ans += ((N - i - 1) // loop_length) * loop_val
      segment = val_list[loop_start_index:loop_start_index + ((N - i - 1) % loop_length) ]
      ans += sum(segment)
      break
    ans += val
    checked[val] = i
    val_list.append(val)


  print(ans)

if __name__ == "__main__":
  resolve()

### FIXED CODE ###


def resolve():
  N, X, M = map(int, input().split(" "))
  checked = [False] * M
  val = X
  ans = 0
  val_list = []

  base = M
  for i in range(N):
    if checked[val] != False:
      loop_start_index = checked[val]
      loop_vals = val_list[loop_start_index:]
      loop_val = sum(loop_vals)
      loop_length = len(val_list[loop_start_index:])
      
      if loop_length != 0:
        ans += ((N - i) // loop_length) * loop_val

        for i in range(((N - i) % loop_length)):
          ans += loop_vals[i]
      break
    ans += val
    checked[val] = i
    val_list.append(val)

    val*=val
    if val >= base:
      val %= base


  print(ans)

if __name__ == "__main__":
  resolve()
a = int(input('A'))
b = int(input('B'))
c = int(input('C'))

count = 0
for i in range(b // a):
    if i >= c:
        break
    count += 1

print(count)

### FIXED CODE ###

A,B,C = map(int,input().split())
ans = 0

while B >= A and C != ans:
    B -= A
    ans += 1
print(ans)
# スペース区切りの整数の入力
p, q, r = map(int, raw_input().split())

n=max(p, q, r)

# 出力
Print(p+q+r-n)



### FIXED CODE ###

p,q,r=map(int,input().split())
print(p+q+r-max(p,q,r))
S = input()
N = len(S)

counter = [0] * 2019
counter[0] = 1
T = 0
R = 1
for i in range(N):
    T = (T + R * int(S[n - i - 1])) % 2019
    R = 10 * R % 2019
    counter[T] += 1

ans = 0
for i in range(2019):
    m = counter[i]
    ans += m * (m - 1) // 2

print(ans)

### FIXED CODE ###

S = input()
N = len(S)
 
counter = [0] * 2019
counter[0] = 1
T = 0
R = 1
for i in range(N):
    T = (T + R * int(S[N - i - 1])) % 2019
    R = 10 * R % 2019
    counter[T] += 1
 
ans = 0
for i in range(2019):
    m = counter[i]
    ans += m * (m - 1) // 2
 
print(ans)
import math
r = int(input())
menseki = r*r*math.pi
syuu = r*2*math.pi
print(str(menseki)+" "+str(syuu))

### FIXED CODE ###

import math
r = float(input())
menseki = r*r*math.pi
syuu = r*2*math.pi
print("%.6f" % (menseki),end=" ")
print("%.6f" % (syuu))
n,k = list(map(int,input().split()))
m = 10**9+7
def inv(x):
  m = 10**9+7
  t = x
  y = 1
  while True:
    if t == 1:
      break
    y *= m // t
    t = m % t
    y *= -1
    y %= m
  return y
def c(x,y):
  t = 1
  for j in range(y):
    t *= x-j
    t *= inv(j+1)
  return t
for i in range(1,k+1):
  print( (c(k-1,i-1) * c(n-k+1,i)) % m )

### FIXED CODE ###

#解説チラ見
n = int(input())
peer = [[] for _ in range(n)]
for _ in range(n-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  peer[a].append(b)
  peer[b].append(a)
now = [0]
scr = list(map(int,input().split()))
scr.sort()
scr.reverse()
ans = [0 for _ in range(n)]
ans[0] = scr[0]
pin = 1
while now:
  last = now
  now = []
  for x in last:
    for y in peer[x]:
      if ans[y] == 0:
        ans[y] = scr[pin]
        pin += 1
        now.append(y)
print(sum(scr[1:]))
print(' '.join(list(map(str,ans))))
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def exp(num):
    return sum(range(1, num+1)) / num

def solve():
    n, k = MI()
    P = LI()

    _max = -1
    idx = None
    for i in range(n-k):
        p = P[i:i+k]
        _sum = sum(p)
        if _max < _sum:
            idx = i

    ans = 0
    for i in range(idx, idx+k):
        ans += exp(P[i])
    print(ans)

if __name__ == '__main__':
    solve()


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def tsum(l, r):
    return (r + l) * (r - l + 1) // 2

def exp(num):
    return tsum(1, num) / num

def solve():
    n, k = MI()
    P = LI()

    E = [0] * n
    pre = 0
    for i in range(n):
        E[i] = pre + exp(P[i])
        pre = E[i]
    # print(E)

    p = E[0]
    mx = E[k-1]
    for j in range(k, n):
        diff = E[j] - E[j-k]
        # print(diff)
        if mx < diff:
            mx = diff
    print(mx)


if __name__ == '__main__':
    solve()
l=int(input())
if l==1:
    print(float(1))
else:
    print(l/3**3):


### FIXED CODE ###

l=float(input())
print((l/3)**3)
while True:
    Lists = [1, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    x = int(input())
    print(Lists[x])

### FIXED CODE ###

Lists = [1, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
x = int(input())
print(Lists[x])
import math
n = int(input())
l = []
for i in range(1, int(math.sqrt(n)//1)):
    if n % i == 0:
        l.append(int(n / i))
print(len(str(l[-1])))

### FIXED CODE ###

import math
n = int(input())
l = []
for i in range(1, int(math.sqrt(n)//1)+1):
    if n % i == 0:
        l.append(int(n / i))
print(len(str(l[-1])))
from math import ceil
def gcd(a,b):
  while b:
    a,b = b,a%b  
  return a

def lcm(a,b):
  return a*b//gcd(a,b)  
  
n,m = map(int,input().split())
A = list(map(int,input().split()))

A = [a//2 for a in A]

pre = None
for a in A:
  c = 0
  while a % 2 ==0:
    a //= 2 
    c += 1    
  if pre is None:    
    pre = c
  elif pre != c:
    print(0)
    exit()
  
ans = lcm(A[0],A[1])  
for i in range(n-2):  
  if ans > m:
    print(0)
    exit()
  ans = lcm(ans,A[i+2])  

print(ceil((m//ans)/2))  

### FIXED CODE ###

from math import ceil
def gcd(a,b):
  while b:
    a,b = b,a%b  
  return a

def lcm(a,b):
  return a*b//gcd(a,b)  
  
n,m = map(int,input().split())
A = list(map(int,input().split()))

A = [a//2 for a in A]

pre = None
for a in A:
  c = 0
  while a % 2 ==0:
    a //= 2 
    c += 1    
  if pre is None:    
    pre = c
  elif pre != c:
    print(0)
    exit()

if n == 1:
  ans = A[0]
else:
  ans = lcm(A[0],A[1])  
  for i in range(n-2):  
    if ans > m:
      print(0)
      exit()
    ans = lcm(ans,A[i+2])  

print(ceil((m//ans)/2))
s = input()
s[3]=7
print(s)

### FIXED CODE ###

s=input()
print(s.replace('2017','2018'))
import numpy as np

N, W = map(int, input().split())
dp = np.zeros(W + 1, dtype=np.int64)
for i in range(N):
    w, v = map(int, input().split())
    np.maximum(dp[: W - w + 1] + v, dp[w:], out=dp[w:])
print(dp[-1])

### FIXED CODE ###

# EduDPD - Knapsack 1
import sys
input = sys.stdin.readline

n, w = list(map(int, input().rstrip().split()))
arr = [tuple(map(int, input().rstrip().split())) for _ in range(n)]
dp = [0] * (w + 1)
for i in range(n):
    for j in range(w, arr[i][0] - 1, -1):
        dp[j] = max(dp[j], dp[j - arr[i][0]] + arr[i][1])
print(max(dp))
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
s=SI()
i=0
state=1
count=0
l=[];r=[]
for i in range(n):
    if state==1:
        if s[i]=="(":
            count+=1
        elif s[i]==")":
            l.append(count)
            state=-1
            count=1
    elif state==-1:
        if s[i]==")":
            count+=1
        elif s[i]=="(":
            r.append(count)
            state=1
            count=1
if s[-1]==")":
    r.append(count)
else:
    l.append(count)
    r.append(0)
'''print(l)
print(r)'''
minus,plus=0,0
for i in range(len(l)):
    if l[i]-r[i]<0:
        minus+=r[i]-l[i]
    else:
        plus+=l[i]-r[i]
for i in range(minus):
    print("(",end="")
print(s,end="")
for j in range(plus):
    print(")",end="")

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

r,g,b=MI()
if (10*g+b)%4==0:
    print("YES")
else:
    print("NO")
N, Y = map(int, input().split())
for x in range(N+1)
	for y in range(N+1-x)
		for z in range(N+1-x-y)			
   			if Y==10000*x+5000*y+1000*z:
    			print(x,y,z)
    			exit()
            
print(-1,-1,-1)

### FIXED CODE ###

N, Y = map(int, input().split())
 
for x in range(N+1):
  for y in range(N-x+1):
    z = N - x - y
    if 10000 * x + 5000 * y + 1000 * z == Y:
      print(x,y,z)
      exit()
print(-1,-1,-1)
S = input()
 
if S = "ABC":
    print("ARC")
else:
    print("ABC")

### FIXED CODE ###

S = input()
 
if S == "ABC":
    print("ARC")
else:
    print("ABC")
S = input()
 
h = int(S/3600)
m = int((S-h*3600)/60)
s = S - h*3600 - m*60
 
print h:m:s

### FIXED CODE ###

S = input()
  
h = S/3600
m = (S%3600)/60
s = (S%3600)%60
  
print '%d:%d:%d' % (h,m,s)
x, n = map(int, input().split())
if n == 0:
    p = input()
    ans = x
else:
    p = list(map(int, input().split()))

d = float('inf')

for i in range(n):
    tmpx = x + n//2 - i
    if not tmpx in p:
        tmpd = abs(x -tmpx) 
        if d >= tmpd:
            d = tmpd
            ans = tmpx

print(ans)




### FIXED CODE ###

x, n = map(int, input().split())
p = list(map(int, input().split()))

if n == 0:
    ans = x
else:
    ans = float('inf')

d = float('inf')

for i in range(n+2):
    tmpx = x + 1 + n//2 - i
    if not tmpx in p:
        tmpd = abs(x -tmpx) 
        if d >= tmpd:
            d = tmpd
            if ans >= tmpx:
                ans = tmpx

print(ans)
import numpy as np
from itertools import permutations

n = int(input())

li = []
for _ in range(n):
    i, j = map(int, input().split())
    li.append(np.array([i, j]))

li2 = permutations(li)

re = []
for a in li2:
    dis = 0 
    for (x1,y1),(x2,y2) in zip(a,a[1:]):
        dis += math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
    re.append(dis)

print(np.average(re))


### FIXED CODE ###

import numpy as np
from itertools import permutations
from math import hypot

n = int(input())

li = []
for _ in range(n):
    i, j = map(int, input().split())
    li.append(np.array([i, j]))

li2 = permutations(li)

re = []
for a in li2:
    dis = 0 
    for (x1,y1),(x2,y2) in zip(a,a[1:]):
        dis += hypot(x1-x2, y1-y2)
    re.append(dis)

print(np.average(re))
import sys
import itertools

sys.setrecursionlimit(3 * 10**5)


class Node:
  def __init__(self, tpl):
    self.id = tpl[0] + 1
    self.c = int(tpl[1])
    self.children = []

  def add_child(self, node):
    self.children.append(node)

  @staticmethod
  def prepare_nodes(n):
    nodes = tuple(map(Node, enumerate(input().split())))
    for _ in range(n - 1):
      a, b = map(lambda x: int(x) - 1, input().split())
      nodes[a].add_child(nodes[b])
      nodes[b].add_child(nodes[a])

    return nodes


def main():
  n = int(input())
  nodes = Node.prepare_nodes(n)

  dp = [0 for _ in range(n)]
  ans_list = [n*(n + 1) // 2 for _ in range(n)]

  def update_ans(s, color):
    ans_list[color] -= (s + dp[color]) * (s + dp[color] + 1) // 2

  def dfs(s, node, parent):
    color = node.c
    pre_s = s + dp[color]
    for child in node.children:
      if child == parent: continue

      dp[color] = -s
      s = dfs(s, child, node)
      update_ans(s, color)

    s += 1
    dp[color] = pre_s - s

    return s

  s = dfs(0, nodes[0], Node((-1, -1)))

  for i in range(n):
    update_ans(s, i)

  print(*ans_list, sep='\n')


main()


### FIXED CODE ###

import sys
import itertools

sys.setrecursionlimit(3 * 10**5)


class Node:
  def __init__(self, color):
    self.color = int(color) - 1
    self.children = []

  def add_child(self, node):
    self.children.append(node)

  @staticmethod
  def prepare_nodes(n):
    nodes = tuple(map(Node, input().split()))
    for _ in range(n - 1):
      a, b = map(lambda x: int(x) - 1, input().split())
      nodes[a].add_child(nodes[b])
      nodes[b].add_child(nodes[a])

    return nodes


def main():
  n = int(input())
  nodes = Node.prepare_nodes(n)

  dp = [0 for _ in range(n)]
  ans_list = [n*(n + 1) // 2 for _ in range(n)]

  def update_ans(s, color):
    ans_list[color] -= (s + dp[color]) * (s + dp[color] + 1) // 2

  def dfs(s, node, parent):
    color = node.color
    pre_s = s + dp[color]
    for child in node.children:
      if child == parent: continue

      dp[color] = -s
      s = dfs(s, child, node)
      update_ans(s, color)

    s += 1
    dp[color] = pre_s - s

    return s

  s = dfs(0, nodes[0], Node(-1))

  for i in range(n):
    update_ans(s, i)
    print(ans_list[i])


main()
n=int(input())

list=[]

for i in range(1,int((n+1)/2)):
    a=n%i
    if(len(list) == 1 and i>n/i):
        ans=(list[-1][0]-1)+(list[-1][1]-1)    
        break
    if a == 0:
        if(i<n/i):
            list.append([i,int(n/i)])
        else:
            list.append([int(n/i),i])
            if len(list) == 1:
                ans=(list[-1][0]-1)+(list[-1][1]-1)
                break
            if list[-1]==list[-2]:
                ans=(list[-1][0]-1)+(list[-1][1]-1)
                break
print(ans)

### FIXED CODE ###

import math

n = int(input())

for i in range(int(math.sqrt(n)), 0, -1):
  if n % i == 0:
    print(int(i + n / i - 2))
    break
D,T,S = inputlist()
time = D//S + int(D%S != 0)
if time <= T:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

#template
def inputlist(): return [int(j) for j in input().split()]
#template
"""
H,W = inputlist()
st = inputlist()
gl = inputlist()
maze = ['0']*H
for i in range(H):
    maze[i] = list(input())
table = [[10**9+7]*W for _ in range(H)]

"""
D,T,S = inputlist()
time = D//S + int(D%S != 0)
if time <= T:
    print("Yes")
else:
    print("No")
import sys
sys.setrecursionlimit(10**10)
N, L = map(int, input().split())
W = []
V = []
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)


dp = [[-1] * 10010 for _ in range(110)]


def knap(i, j):
    if dp[i][j] >= 0:
        return dp[i][j]

    if i == N:
        dp[i][j] = 0
    elif j < W[i]:
        dp[i][j] = knap(i+1, j)
    else:
        dp[i][j] = max(knap(i+1, j), knap(i+1, j - W[i]) + V[i])

    return dp[i][j]


print(knap(0, L))


### FIXED CODE ###

N, W = map(int, input().split())
T = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] + [-1] * W for _ in range(N+1)]
dp[0] = [0] * (W+1)

for i in range(1, N+1):
    for w in range(1, W+1):
        dp[i][w] = max(dp[i-1][w], dp[i-1][w - T[i-1][0]] + T[i-1]
                       [1]) if w - T[i-1][0] >= 0 else dp[i-1][w]

# print(*dp, sep='\n')
print(dp[N][W])
N, M = map(int,input().split())

edges = [[] for _ in range(N)]
for _ in range(M):
    x,y = map(int,input().split())
    edges[y-1].append(x-1)
    
used = [0 for _ in range(N)]
dp = [0 for _ in range(N)]

def dfs(pos):
    if not edges[pos]:
        dp[pos] = 0
        return
    for n_pos in edges[pos]:
        if not used[n_pos]:
            dfs(n_pos)
        used[n_pos] = 1
        dp[pos] = max(dp[pos],dp[n_pos]+1)
    print(dp)
    
for i in range(N):
    if used[i]:
        continue
    used[i] = True
    dfs(i)

print(max(dp))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)

N, M = map(int,input().split())

edges = [[] for _ in range(N)]
for _ in range(M):
    x,y = map(int,input().split())
    edges[y-1].append(x-1)
    
used = [0 for _ in range(N)]
dp = [0 for _ in range(N)]

def dfs(pos):
    if not edges[pos]:
        dp[pos] = 0
        return
    for n_pos in edges[pos]:
        if not used[n_pos]:
            dfs(n_pos)
        used[n_pos] = 1
        dp[pos] = max(dp[pos],dp[n_pos]+1)

    
for i in range(N):
    if used[i]:
        continue
    used[i] = True
    dfs(i)

print(max(dp))
x,y = map(intinput()split())
a = 4x-y
if a/2 = a%2:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

x,y = map(int,input().split())
a = 4 * x - y
b = y - 2*x
if a/2 == a//2 and a >= 0 and b/2 == b//2 and b >= 0:
  print('Yes')
else:
  print('No')
s = input()
print(x * len(s))

### FIXED CODE ###

s = input()
print('x' * len(s))
# n*m?????????A??¨m*1??????????????????b??¨??????????¨????????????°??????

import numpy as np
n, m = map(int, input().split())

A = np.matrix([[0 for i in range(m)] for j in range(n)])
for i in range(n):
    A[i] = list(map(int, input().split()))

b = np.matrix([[0] for i in range(m)])
for i in range(m):
    b[i] = int(input())

c = A.dot(b)            #A??b

for i in range(n):
    print(c[i, 0])

### FIXED CODE ###

# n*m?????????A??¨m*1??????????????????b??¨??????????¨????????????°??????

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

A = [[0 for i in range(m)] for j in range(n)]
for i in range(n):
    A[i] = list(map(int, input().split()))

b = [[0] for i in range(m)]
for i in range(m):
    b[i][0] = int(input())

c = [[0] for i in range(n)]            #A??b
for i in range(n):
    for j in range(m):
        c[i][0] += A[i][j] * b[j][0]

for i in range(n):
    print(c[i][0])
import sys
import random
input = sys.stdin.readline
n = int(input())
ab = [list(map(int,input().split())) for i in range(n-1)]
graph = [[] for i in range(n+1)]
degorigin = [0]*(n+1)
for a,b in ab:
  graph[a].append(b)
  graph[b].append(a)
  degorigin[a] += 1
  degorigin[b] += 1
if n == 2:
  print("Second")
  exit()
stackorigin = []
root = 0
candidate = []
for i in range(1,n+1)[::-1]:
  if degorigin[i] == 1:
    stackorigin.append(i)
  else:
    candidate.append(i)
flg = 0
for _ in range(1):
  if flg:
    break
  stack = stackorigin[:]
  deg = degorigin[:]
  root = candidate[random.randint(0,len(candidate)-1)]
  deg[root] += 1
  dp = [[] for i in range(n+1)]
  parity = [-1]*(n+1)
  while stack:
    x = stack.pop()
    if dp[x]:
      if dp[x].count(0) >= 2:
        flg = 1
        break
      elif dp[x].count(2):
        parity[x] = 2
      elif dp[x].count(1) and dp[x].count(0):
        parity[x] = 2
      elif dp[x].count(1):
        parity[x] = 0
      elif dp[x].count(0):
        parity[x] = 1
    else:
      parity[x] = 0
    for y in graph[x]:
      if deg[y] >= 2:
        dp[y].append(parity[x])
        deg[y] -= 1
        if deg[y] == 1:
          stack.append(y)
if flg:
  print(2/0)
  print("First")
else:
  print("Second")

### FIXED CODE ###


import sys
input = sys.stdin.readline
n = int(input())
ab = [list(map(int,input().split())) for i in range(n-1)]
graph = [[] for i in range(n+1)]
deg = [0]*(n+1)
for a,b in ab:
  graph[a].append(b)
  graph[b].append(a)
  deg[a] += 1
  deg[b] += 1
if n == 2:
  print("Second")
  exit()
stack = []
root = 0
for i in range(1,n+1)[::-1]:
  if deg[i] == 1:
    stack.append(i)
  else:
    root = i
flg = 0
deg[root] += 1
dp = [[] for i in range(n+1)]
dist = [-1]*(n+1)
while stack:
  x = stack.pop()
  if dp[x]:
    if dp[x].count(0)>=2:
      flg = 1
    if dp[x].count(0):
      dist[x] = 1
    else:
      dist[x] = 0
  else:
    dist[x] = 0
  for y in graph[x]:
    if deg[y] >= 2:
      dp[y].append(dist[x])
      deg[y] -= 1
      if deg[y] == 1:
        stack.append(y)
if flg or dist[root]==0:
  print("First")
else:
  print("Second")
n=input()
m=n[0]
for i in range(len(n)-1):
  m+=n[0]
if int(n)>int(m):
  if n[0]!=9:
    a=str(int(n[0]+1))
    for j in range(len(n)-1):
      a+=str(int(n[0]+1))
    print(a)
  else:
    b=str(1)
    for k in range(len(n)):
      b+=str(1)
    print(b)
else:
  print(m)
      
      
              

### FIXED CODE ###

n=input()
m=n[0]
for i in range(len(n)-1):
  m+=n[0]
if int(n)>int(m):
  if n[0]!=str(9):
    a=str(int(n[0])+1)
    for j in range(len(n)-1):
      a+=str(int(n[0])+1)
    print(a)
  else:
    b=str(1)
    for k in range(len(n)):
      b+=str(1)
    print(b)
else:
  print(m)
A,B,K = map(int,input().split())
L = 0
ans = 0
for i in reversed(1,100):
  if A%i == 0:
    if B%i == 0:
      L += 1
    else:
      L += 0
  else:
    L += 0
  if L == K:
    ans = i
    break
print(ans)


### FIXED CODE ###

A,B,K = map(int,input().split())
L = 0
ans = 0
for i in reversed(range(1,2000)):
  if A%i == 0:
    if B%i == 0:
      L += 1
    else:
      L += 0
  else:
    L += 0
  if L == K:
    ans = i
    break
print(ans)
N=int(input())
S=input()
if N%2==0:
  if S[:N/2]==S[N/2:]:
    print("Yes")
    exit()
print("No")

### FIXED CODE ###

N=int(input())
S=input()
if N%2==0:
  if S[:int(N/2)]==S[int(N/2):]:
    print("Yes")
    exit()
print("No")
N,A,B = map(int,input().split())
S = input()

win = 0  
abr = 0 
for c in S:
    if c == a:
        if win<A+B:
            print("Yes") 
            win += 1
        else:
            print("No")
    elif c == b:
        if win < A+B and abr <= B:
            print("Yes")
            win += 1
            abr += 1
        else:
            print("No")
    else:   
        print("No")


### FIXED CODE ###

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

win = 0  
abr = 0 
for c in S:
    if c == "a":
        if win<A+B:
            print("Yes") 
            win += 1
        else:
            print("No")
    elif c == "b":
        if win < A+B and abr < B: 
            print("Yes")
            win += 1
            abr += 1
        else:
            print("No")
    else:   
        print("No")
N, K = map(int, input().split())
ANSlist = [1]*(N)

for i in range(K):
    I = input() #
    S = list(input())
    for j in range(len(S)):
        if S[j] != " ":
            ANSlist[int(S[j])-1] = 0

ANS = 0

for i in range(len(ANSlist[i])):
    if ANSlist[i] != 0:
        ANS += 1

print(ANS)

### FIXED CODE ###

N, K = map(int, input().split())
#ANSlist = [1]*(N)
ANSlist = []
ANS = 0

for i in range(K):
    I = input() #
    S = input().split()
    #print(ANSlist)
    for j in range(len(S)):
        if S[j] != " ":
            #ANSlist[int(S[j])-1] = 0
            if not S[j] in ANSlist:
                ANSlist.append(S[j])
                
            


'''for i in range(len(ANSlist)):
    if ANSlist[i] != 0:
        ANS += 1'''
ANS = N - len(ANSlist)
print(ANS)
def main():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    a.append(10**9+1)
    b.append(10**9+1)
    a, b = a[::-1], b[::-1]
    sum = 0
    for _ in range(400001):
        x = a.pop() if a[-1] < b[-1] else b.pop()
        if x > 10**9:
            break
        k -= x
        if k < 0:
            break
        sum += 1
    print(sum)

if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    a = int(input())
    ans = a + a**2 + a**3
    print(ans)


if __name__ == "__main__":
    main()