Problem:


Score : 200 points

Problem Statement

Kurohashi has never participated in AtCoder Beginner Contest (ABC).

The next ABC to be held is ABC N (the N-th ABC ever held).
Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.

What is the earliest ABC where Kurohashi can make his debut?

Constraints

100 \leq N \leq 999

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

If the earliest ABC where Kurohashi can make his debut is ABC n, print n.

Sample Input 1

111

Sample Output 1

111

The next ABC to be held is ABC 111, where Kurohashi can make his debut.

Sample Input 2

112

Sample Output 2

222

The next ABC to be held is ABC 112, which means Kurohashi can no longer participate in ABC 111.
Among the ABCs where Kurohashi can make his debut, the earliest one is ABC 222.

Sample Input 3

750

Sample Output 3

777



Sample input:
111


Sample output:
111

Submission status: Accepted

Solution code:
N = int(input())

for i in range(1,10):
  if N <= i * 111:
    print(i * 111)
    exit(0)

Submission status: Accepted

Solution code:
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


N = int(input())

for i in range(1, 10):
    tmp = int(str(i)*3)
    if N <= tmp:
        print(tmp)
        break

Submission status: Accepted

Solution code:
a = int(input())

d = a//111
f = a%111
if f>0:
    print((d+1)*111)
else:
    print(d*111)

Submission status: Accepted

Solution code:
n = int(input())

while True:
    s = str(n)

    if s[0] == s[1] == s[2]:
        print(s)
        break
    
    n += 1

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect

N = int(input())
li = [111,222,333,444,555,666,777,888,999]

for ans in li:
    if N <= ans:
        print(ans)
        exit()

Submission status: Accepted

Solution code:
N=int(input())
for i in range(9):
    if 111*(1+i)-N>=0:
        print(111*(1+i))
        break

Submission status: Accepted

Solution code:
n = int(input())

if n <= 111:
    print("111")

elif n <= 222:
    print("222")

elif n <= 333:
    print("333")

elif n <= 444:
    print("444")

elif n <= 555:
    print("555")

elif n <= 666:
    print("666")

elif n <= 777:
    print("777")

elif n <= 888:
    print("888")

else:
    print("999")

Submission status: Accepted

Solution code:
N = int(input())
for i in range(N, 1000):
    if len(list(set(str(i)))) == 1:
        print(i)
        break

Submission status: Accepted

Solution code:
#! usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    n = int(input())

    for i in range(10):
        if n <= i * 100 + i * 10 + i:
            print(i * 100 + i * 10 + i)
            exit()


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a=int(input())
for i in range(1,10):
    b=i*111
    if a<=b:
        print(b)
        exit()

Submission status: Accepted

Solution code:
n = int(input())
a = 111 * ((n-1)//111+1)
print(a)

Submission status: Accepted

Solution code:
n = int(input())
ans = 111
while ans < n:
  ans += 111
print(ans)

Submission status: Accepted

Solution code:
a = int(input())
print(111 * ((a - 1) // 111 + 1))

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-

def main():
    n = int(input())
    for i in range(n, 1000):
        s = str(i)
        if s[0] == s[1] and s[1] == s[2]:
            print(i)
            break
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

ans = n
while True:
    if len(set(str(ans))) == 1:
        break
    else:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
def solve(N):
    for i in range(N, 1000):
        if str(i)[2] == str(i)[1] == str(i)[0]:
            return i

if __name__ == "__main__":
    l = input()
    print(solve(int(l)))

Submission status: Accepted

Solution code:
N = int(input())
i = 0
while True:
    if (N + i)%111 == 0:
        print(N + i)
        break
    else:
        i += 1

Submission status: Accepted

Solution code:
t = 111
n = int(input())
while t < n:
    t += 111
print(t)

Submission status: Accepted

Solution code:
N = int(input())

for i in range(N, 1000):
    if i%111 == 0:
        res = i
        break
print(res)

Submission status: Accepted

Solution code:
n = int(input())
print(111 * (int((n-1)/111)+1))

Submission status: Accepted

Solution code:
s=input()
for i in range(int(s),1000):
    t=str(i)
    if t[0]==t[1] and t[1]==t[2]:
        print(t)
        break

Submission status: Accepted

Solution code:
N = int(input())
for i in range(N, 1000):
    n = str(i)
    if n[0] == n[1] and n[1] == n[2]:
        print(n)
        break

Submission status: Accepted

Solution code:
n = int(input())
m = int(n/100)
a = 100*m + 10*m + m
if(n <= a):
  print(a)
else:
  print(a + 111)

Submission status: Accepted

Solution code:
N=int(input())
A=[111 * i for i in range(1, 10)]
for a in A:
    if N <= a:
        print(a)
        exit()

Submission status: Accepted

Solution code:
n = int(input())

for i in range(111, 1000, 111):
    if i >= n:
        print(i)
        break

Submission status: Accepted

Solution code:
N = int(input())
r = N%111
if r == 0:
    print(N)
else:
    print(N+111-r)

Submission status: Accepted

Solution code:
N = int(input())
for i in range(N, 1000):
    if i % 111 == 0:
        print(i)
        exit(0)

Submission status: Accepted

Solution code:
array = [111,222,333,444,555,666,777,888,999]
n = int(input())
for i in array:
    if n <= i:
        print(i)
        break

Submission status: Accepted

Solution code:
n = int(input())

if n%111 == 0:
    print(n)
else:
    print(111*(n//111+1))

Submission status: Accepted

Solution code:
N = int(input())
for i in range(N, 1000):
    a = str(i)
    if len(set(a)) == 1:
        print(i)
        break

Submission status: Accepted

Solution code:
a = int(input())
if a % 111 == 0:
    print(a)
else:
    temp = a // 111
    print((temp+1)*111)

Submission status: Accepted

Solution code:

def inputN(typ=str):
    return map(typ, raw_input().split())

N = inputN(int)[0]
print ((N - 1) / 111 + 1) * 111

Submission status: Accepted

Solution code:
import math
a = int(input())
b = math.ceil(a/111)
print (b*111)

Submission status: Accepted

Solution code:
num = int(input())

print(111*((num+110)//111))

Submission status: Accepted

Solution code:
n = int(input())
if n % 111 == 0:
    print(n)
else:
    print((n//111+1)*111)

Submission status: Accepted

Solution code:
n = int(input())

a = -(-n//111)

print(a*111)

Submission status: Accepted

Solution code:
N = int(input())

for x in range(N, 1000):
    if x % 111 == 0:
        print(x)
        exit()

Submission status: Runtime Error

Solution code:
import math
# import statistics
# a=input()
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#    c.append(i)
e1,e2 = map(int,input().split())
#f = list(map(int,input().split()))
#g = [input() for _ in range(a)]
z = a//9
af= a%9
if af==0:
    print(str(9)*(z))
 
else :
    print(str(af)*(z+1))

Submission status: Runtime Error

Solution code:
n=input()
l=len(n)
k=0
for i in range(l):
    for j in range(i,l):
        if n[i]!=n[j]:
            k=1
            
if k==1:
    if n[0]>n[1]:
        print(n[0]*l)
    else:
        print((n[0]+1)*l)
        
else:
    print(n)

Submission status: Runtime Error

Solution code:
a=int(input())
b=a%100
c=a//100
if b<=c*11:
  print(c*111)
else:
  print()c+1)*111)

Submission status: Runtime Error

Solution code:
contests = [i for i in range(100,1000) if i % 111 == 0]
N = int(input())
for contest in contests:
  if contests >= N:
    print(contest)
    break
  else:
    continue

Submission status: Runtime Error

Solution code:
n = int(input())
a = -(-n//111)
if a = 10:
    print(1111)
else:
    print(a*111)

Submission status: Runtime Error

Solution code:
n = int(input())
li = [int(str(i)*3) for i in range(9)]
import bisect
x = bisect.bisect_left(li,n)
print(li[x])

Submission status: Runtime Error

Solution code:
n = int(input())
for i in range(1, 10):
    if 100*i + 10*i + i => n:
        print(100*i + 10*i + i)

Submission status: Runtime Error

Solution code:
n = int(input())
for i in range(10):
    if 100*i + 10*i + i => n:
        print(100*i + 10*i + i)

Submission status: Runtime Error

Solution code:
n = input()
for i in range(int(n), 1000):
  if i.count(n[0]) == 3:
    print(i)
    exit()

Submission status: Runtime Error

Solution code:
number = int(input())
i = int(number / 111)
if number % 111 != 0:
  i += 1
 print(i * 111)

Submission status: Runtime Error

Solution code:
# abc111_b.py
# https://atcoder.jp/contests/abc111/tasks/abc111_b

# B - AtCoder Beginner Contest 111 /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 黒橋君は，AtCoder Beginner Contest (ABC) にまだ参加したことがありません．
# 次に行われる ABC は第 N回です． 
# 黒橋君は，初めて参加する ABC を第 x 回としたときに，xの十進法表記でのすべての桁の数字が同じであるようにしたいです．
# 黒橋君が初めて参加する ABC としてふさわしいもののうち，最も早いものは第何回でしょうか？

# 制約
#     100≤N≤999
#     Nは整数

# 入力
# 入力は以下の形式で標準入力から与えられる．
# N

# 出力
# 黒橋君が初めて参加する ABC としてふさわしいもののうち，最も早いものは第何回かを出力せよ．

# 入力例 1
# 111

# 出力例 1
# 111

# 次に行われる ABC は第 111回です． これは黒橋君が初めて参加する ABC としてふさわしいです．

# 入力例 2
# 112

# 出力例 2
# 222

# 次に行われる ABC は第 112回です．そのため，第 111 回の ABC にはもう参加することはできません． 
# 黒橋君が初めて参加する ABC としてふさわしいもののうち，最も早いものは第 222回です．

# 入力例 3
# 750

# 出力例 3
# 777


def calculation(lines):
    N = int(lines[0])
    # X, Y = list(map(int, lines[0].split()))
    # n = lines[0]

    if N % 111 == 0:
        result = N
    else:
        result = -(-N//111) * 111 

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['111']
        lines_export = [111]
    if pattern == 2:
        lines_input = ['112']
        lines_export = [222]
    if pattern == 3:
        lines_input = ['750']
        lines_export = [777]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N=int(input())
X=set(str(N))
Y=len(X)
if Y==1
  print(N)
if Y!=1:
  Z=0
  for i in range(111,1000,111):
    if N-i<0:
      Z+=i
      break
  print(Z)

Submission status: Runtime Error

Solution code:
import sys
import time
import math
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N = int(input())
for i in range(N, 1000):
	if N//100==N//10 ans N//10==N%10:
		print(N)
		sys.exit()

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)

Submission status: Runtime Error

Solution code:
check=[111, 222, 333, 444, 555, 666, 777, 888, 999]

n=int(input())

if n in check:
    print(n)
else:
    for i in range(10):
        if check[i]<n<check[i+1]:
            print(check[i+1])
            exit()

Submission status: Runtime Error

Solution code:
n = int(input())
l = list(range(111,1000,111))

print(l[n // 111])

Submission status: Runtime Error

Solution code:
n =  list(input())
N = [int(n[i]) for i in range(len(n))]
if N[0] == max(N):
  print(max(N) * 100 + max(N)*10 + max(N))
else:
  m = N+1
  print(m * 100 + m * 10 + m)

Submission status: Runtime Error

Solution code:
n=int(input())
if n[0]=<n[1] or (n[0]==n[1] and n[0]=<n[2]):
  print(str(n[0]+1)*3)
else:
  print(str(n[0])*3)

Submission status: Runtime Error

Solution code:
n = input()
l = [111, 222, 333, 444, 555, 666, 777, 888, 999]
for i in l:
    if n<=i:
        print(i)
        break

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int i = n; i <= 999; i++) {
    string str = to_string(i);
    set<char> st;
    for (int i = 0; i < str.size(); i++) {
      st.insert(str[i]);
    }
    if (st.size() == 1) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Submission status: Runtime Error

Solution code:
n = input()
n.sort(reverse=True)
print(int(n[0]+n[0]+n[0]))

Submission status: Runtime Error

Solution code:
n = int(input())
apple = []

number = [111, 222, 333, 444, 555, 666, 777, 888, 999]
for i in number:
    if i - n > 0:
        apple.append(i)
    else:
        pass

print(min(apple))

Submission status: Runtime Error

Solution code:
n = int(input())

while True:
  for i in range(len(str(n))-1):
    if str(n)[i] == str(n)[i+1]:
      flag = True
    else:
      break
  if flag:
    print(n)
    break
  n +=1

Submission status: Runtime Error

Solution code:
N = int(input())

if N < 111:
  print(111)
elif N < 222:
  print(222)
elif N < 333:
  print(333)
elif N < 444:
  print(444)
elif N < 555:
  print(555)
elif N < 666:
  print(666)
elif N < 777:
  print(777)
elif N < 888:
  print(888)
elif N =< 999:
  print(999)

Submission status: Runtime Error

Solution code:
n = int(input)

if n>888:
  print(999)
elif n>777:
  print(888)
elif n>666:
  print(777)
elif n>555:
  print(666)
elif n>444:
  print(555)
elif n>333:
  print(444)
elif n>222:
  print(333)
elif n>111:
  print(222)
else:
  print(111)

Submission status: Runtime Error

Solution code:
n = int(input())
ans = 111
print([111*i for i in range(9) if 111*i>=n][0])

Submission status: Runtime Error

Solution code:
n = input()

x = False

while x = False:
  for i in range(1,len(n)):
    if n[i-1] == n[i]:
      x =True
    else:
      x = False
  if x = True:
    print(n)
    break
  else:
    n = int(n) + 1

Submission status: Runtime Error

Solution code:
n=input()
if n[0]>n[1] or (n[0]=n[1] and n[1]>=n[2]):
    print(int(n[0])*111)
else:
    print(int(n[0])*111+111)

Submission status: Runtime Error

Solution code:
n=input()
if n[0]>n[1] or (n[0]=n[1] and n[1]>=n[2]):
    print(int(n[0])*111
else:
    print(int(n[0])*111+111)

Submission status: Runtime Error

Solution code:
S = input()
if len(set(S)) == 1:
    print(S)
    exit()
for i in range(int(S), 1000):
    if len(set(i)) == 1:
        print(i)
        exit()

Submission status: Runtime Error

Solution code:
N = int(input())
if N % 111 == 0:
  print(N)
for i in range(10):
  if N // 111 = i:
    print(111 * (i + 1) )

Submission status: Runtime Error

Solution code:
N=int(input())
a=N//100
b=(N-a*100)//10
c=N-a*100-b*10
if a<b:
    N=(a+1)*111
elif a>b:
    N=a*111
elif a=b and a>=c:
    N=a*111
elif :
    N=(a+1)*111
print(N)

Submission status: Runtime Error

Solution code:
print(111 if (int(input())//111)==0 else 111*(int(input())//111+1) )

Submission status: Runtime Error

Solution code:
n = input()
a = ['111','222','333','444','555','666','777','888','999']

for i in a:
	if i >= n:
    	print(i)
        break

Submission status: Runtime Error

Solution code:
n = int(input())
ans == 0
for i in range(1,10):
    count = 100*i + 10*i + i
    if n <= count:
        ans = count
    else: break

Submission status: Runtime Error

Solution code:
n = int(input())

while True:
  s = str(n)
  if s.count(s[0])==len(s):
    print(m)
    exit()
  else:
    n += 1

Submission status: Runtime Error

Solution code:
print(100*x+10*x+x)

Submission status: Runtime Error

Solution code:
N=int(input())
x=-(-N//111)
print(100x+10x+x)

Submission status: Runtime Error

Solution code:
n = int(input())
while n % 111 != 0:
    x = n+1
    n += 1
print(x)

Submission status: Runtime Error

Solution code:
import bisect
n=int(input())
li=[111,222,333,444,555,666,777,888]

print(li[bisect.bisect_left(li,n)])

Submission status: Runtime Error

Solution code:
n = int(input())
li = list(111,222,333,444,555,666,777,888,999)

for i in range(9):
    if n <= li[i]:
        print(li[i])
        break

Submission status: Runtime Error

Solution code:
n = int(input())
if n//111 = n/111:
  print(n)
else:
  print(((n//111)+1) * 111)

Submission status: Runtime Error

Solution code:
n=int(input())
a_list=[str(i)*3 for i in range(1,10)]
flag=False

for i in range(1,10):
  if int(a_list[i])==n:
    print(a_list[i])
    flag=True
    break
if flag==False:
  for i in range(1,9):
    if int(a_list[i])< n < int(a_list[i+1]):
      print(a_list[i+1])
      break

Submission status: Runtime Error

Solution code:
n=int(input())
a_list=[str(i)*3 for i in range(1,10)]

for i in range(1,9):
  if a_list[i]< n <= a_list[i+1]:
    print(a_list[i+1])
    break
  elif a_list[i]==n:
    print(a_list[i])
    break

Submission status: Runtime Error

Solution code:
n=int(input())
a_list=[str(i)*3 for i in range(1,10)]

for i in range(1,9):
  if a_list[i]< n <= a_list[i+1]:
    print(a_list[i+1])
    break
  elif a_list[i]= n:
    print(a_list[i])
    break

Submission status: Runtime Error

Solution code:
n=int(input())
a_list=[str(i)*3 for i in range(1,10)]

for i in range(1,9):
  if a_list[i]< n <= a_list[i+1]:
    print(a_list[i+1])
    break
  elif a_list[i]= n:
    print(a_list[i])

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
input = sys.stdin.readline
N = int(input())
ans = [111,222,333,444,555,666,777,888,999]
for i in ans:
    if ans >= N:
        print(ans)
        sys.exit()

Submission status: Runtime Error

Solution code:
N=int(input())
for i in range(10):
  if N<=eval(str(i)+str(i)+str(i)):
    print(evar(str(i)+str(i)+str(i)))
    break

Submission status: Runtime Error

Solution code:
N=int(input())
for i in range(10):
  if N<=evarl(str(i)+str(i)+str(i)):
    print(evar(str(i)+str(i)+str(i)))
    break

Submission status: Runtime Error

Solution code:
N=int(input())
for i in range(10):
  if N<=evar(str(i)+str(i)+str(i)):
    print(evar(str(i)+str(i)+str(i)))
    break

Submission status: Runtime Error

Solution code:
print((int(input() - 1) // 111 + 1) * 111)

Submission status: Runtime Error

Solution code:
N = int(input())

list_aaa = [111,222,333,444,555,666,777,888,999]
cnt =0

for i in range(len(list_aaa)):
    if N >= list_aaa[i]:
        cnt +=1

if cnt ==0:
    print(111)
else:
    print(list_aaa[cnt])

Submission status: Runtime Error

Solution code:
N = int(input())

list_aaa = [111,222,333,444,555,666,777,888,999]
cnt =0

for i in range(len(list_aaa)):
    if N >= list_aaa[i]:
        cnt +=1

if cnt ==0:
    print(111)
    exit()
else:
    print(list_aaa[cnt])

Submission status: Runtime Error

Solution code:
n=int(input()
print((((n-1)//111)+1)*111)

Submission status: Runtime Error

Solution code:
n=int(input()
print(((n-1)//111)*111+111)

Submission status: Runtime Error

Solution code:
n=int(input()
print((n-1)//111+111))

Submission status: Runtime Error

Solution code:
n=int(input())
m==111
for i in range(1,10):
    if 111*i>=n:
        m=min(m,111*i)
print(m)

Submission status: Runtime Error

Solution code:
import bisect
x=int(input())
a=[i*111 for i in range(1,9)]
print(a[bisect.bisect_left(a,x)])

Submission status: Runtime Error

Solution code:
import math


n = int(input())
print(111 * math.ceil(n / 111)

Submission status: Runtime Error

Solution code:
from math import ceil


n = int(input())
print(111 * ceil(n // 111)

Submission status: Runtime Error

Solution code:
from math import ceil


n = int(input())
print(111 * ceil(n / 111)

Submission status: Runtime Error

Solution code:
n = list(int(input()))
for i in range(3):
  print(max(n))

Submission status: Runtime Error

Solution code:
a = input()
print((((a-1)//111)+1)*111)

Submission status: Runtime Error

Solution code:
n = input()
li = list(n)
same = li[0]*len(li)
if int(n) <= int(same):
    print(same)
else:
    print(str(int(li[0]+1))*len(li))

Submission status: Runtime Error

Solution code:
n = int(input())
if n%111 = 0:
  print(n)
else:
  print((n//111+1)*111)

Submission status: Runtime Error

Solution code:
n = int(input())
for i in range(n,1000):
  if i[0]==i[1]==i[2]:
    return i
print(i)

Submission status: Runtime Error

Solution code:
N = input()
x = N[0]
xxx = int(3*x)
if N <= XXX:
  print(xxx)
else:
  x = int(x)+1
  print(100*x + 10*x + x)

Submission status: Runtime Error

Solution code:
N = int(input())
print(lst)
for i in range(1000):
    if N in lst:
        print(N)
        break
    else:
        N += 1

Submission status: Runtime Error

Solution code:
input_line = input()
n = int(input_line / 111)
print(111 + n * 111)

Submission status: Runtime Error

Solution code:
input_line = input()
n = int(input_line / 111)
print(n*111)

Submission status: Runtime Error

Solution code:
str = input()
n = str / 111

print(n*111)

Submission status: Runtime Error

Solution code:

n=int(input())
for x in range(n, 1000):
    if set(list(x)) == 1:
        print(x)
        break

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = S()
    for i in n:
        if i == "1":
            print(9, end="")
        else:
            print(1, end="")
    print()
    return

#B
def B():
    n = II()
    for i in range(111, , 111):
        if n <= i:
            print(i)
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()

Submission status: Runtime Error

Solution code:
N = int(input())
A = [str(i) * 3 for i in range(10)[1:]]
for j in range(10)[1:]:
  if N >= A[j]:
    print(A[j])
    break

Submission status: Runtime Error

Solution code:
n =input()
lst = []
ans = []
for i in range(3):
    num = int(n[i]*3)
    lst.append(num)
for i in range(3):
    if lst[i] > int(n):
        ans.append(lst[i])
print(min(ans))

Submission status: Runtime Error

Solution code:
n = input()
if n[0]*3 == n:
    print(n)
elif int(n[0]) > int(n[1]) and int(n[0]) > int(n[3]):
    print(n[0] * 3)
else:
    print(str(int(n[0]) +1) * 3)

Submission status: Runtime Error

Solution code:
n = int(input())
for i in range(9):
    if 111*i >= n:
        result = i
        break

print(result*111)

Submission status: Runtime Error

Solution code:
n=int(input())
l=[111,222,333,444,555,666,777,888,999]
ans=[]
for i in range(8):
    if l[i]-n>=0:
        ans.append(i)
        
print(l[ans[0]])

Submission status: Runtime Error

Solution code:
a=input()
if int(a) <= int(a[0])*111:
  print(int(a[0])*111)
else:
  print((int(a[0])+1)*111

Submission status: Runtime Error

Solution code:
a=input()
if int(a) < int(a[0])*111:
  print(int(a[0])*111)
else:
  print((int(a[0])+1)*111

Submission status: Runtime Error

Solution code:
n=int(input())
     
a=(n-n%100)//100
b=(n-a*100-n%10)//10
c=n%10
     
if a>b or a=b and b>=c::
	print(a*100+a*10+a)
else:
	print((a+1)*100+(a+1)*10+a+1)

Submission status: Runtime Error

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def ok(n):
    s = str(n)
    if len(set(s)) == 1:
        return True
    return False

def solve():
    n = f()
    for i in range(n, 1000):
        if ok(i):
            print(i)
            return

solve()

Submission status: Runtime Error

Solution code:
N = int(input())
for i in range(1, 10):
    num = int("i"*3)
    if N <= num:
        print(num)
        break

Submission status: Runtime Error

Solution code:
n = int(input())
a = 111
for i in range(9):
  if a*i < n <= a*(i+1)
  print(a*(i+1))

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
    N = int(input())

    answer = -1
    for i in range(N, 999):
        i_str = str(i)
        if i_str[0] == i_str[1] and i_str[1] == i_str[2]:
            answer = i_str
            break
    print(i_str)

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<numeric>
#include<string>
#include<vector>
using namespace std;
int main(){
    int N;
    cin>>N;
    for(int i=111;i<=999;i+=111){
        if(N<=i){
            cout<<i<<endl;
            return 0;
        }
    }
}

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<numeric>
#include<string>
#include<vector>
using namespace std;
int main(){
    int N;
    cin>>N;
    for(int i=100;i<=999;i+111){
        if(N<=i){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}

Submission status: Runtime Error

Solution code:
a=list(str(input()))
e=int(''.join(a))


b=int(a[1])-int(a[1]*111)
c=a[0]
c=int(c)
b = e-c*111
if b =<0:
  print(c*111)
else:
  c+=1
  print(c*111)

Submission status: Runtime Error

Solution code:
input_int = input()
if input_int[0] >= input_int[1]:
  print(input_int[0] * 3)
else:
  print(str(int(input_int[0] + 1)) * 3)

Submission status: Runtime Error

Solution code:
input_int = input()
if input_int[0] >= input[1]:
  print(input_int[0] * 3)
else:
  print(str(int(input_int[0] + 1)) * 3)

Submission status: Runtime Error

Solution code:
n = int(input())
print(min([i for i in range(100,999) if i >= n and i//100 == (i//10)%10 and i//100 == i%10]))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int):
    for i in range(N, 999):
        s = str(i)
        if s[0] == s[1] == s[2]:
            ret = s
            break
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
x = input()
y = int(x)

a = list(x)
a = [int(x) for x in a]

a1 = set(a)
n = len(a1)
a1 = list(a1)
x = []
for i in range(n):
    b = a1[i]
    c = str(b) + str(b) + str(b)
    c = int(c)
    x.append(c)

d = []
for j in x:
    if j > y:
        d.append(j)

print(min(d))

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
X = int(input)

if 100 <= X <= 111:
  n = 111
elif X <= 222:
  n = 222
elif X <= 333:
  n = 333
elif X <= 444:
  n = 444
elif X <= 555:
  n = 555
elif X <= 666:
  n = 666
elif X <= 777:
  n = 777
elif X <= 888:
  n = 888
elif X <= 999:
  n = 999
else:
  print("error")

print(n)

Submission status: Runtime Error

Solution code:
N = input()
 
if int(N) <= int(N[0] * 3):
    print(int(N[0] * 3))
else:
    print(int((N[0] + 1) * 3))

Submission status: Runtime Error

Solution code:
N = input()

if int(N) < int(N[0] * 3):
    print(int(N[0] * 3))
else:
    print(int((N[0] + 1) * 3))

Submission status: Runtime Error

Solution code:
data = input()

sc = 0
ans = []
if (data[0] == data[1]) & (data[0] == data[2]):
    data = int(data)
    print(*data)
elif int(data[0]) > int(data[1]):
    sc = int(data[0])
    ans = 100 * sc + 10 * sc + sc
    print(ans)
else:
    sc = int(data[0]) + 1
    ans = 100* sc + 10 * sc + sc
    print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
x=list(int(100*i+10*i+i) for i in range(1,9))
y=list(t for t in x if t>=N)
print(min(y))

Submission status: Runtime Error

Solution code:
n=input()
if int(n[0])>int(n[1]):
  out=int(n[0])
elif int(n[0])==int(n[1]):
  if int(n[1])==int(n[2]):
    out=int(n[0])
  else:
    out=int(n[0]+1)
else:
    out=int(n[0]+1)

print(str(out)*3)

Submission status: Runtime Error

Solution code:
import bisect
N = int(input())
candidate = [int(i*111) for i in range(1,10)]
print(candidate[bisect.bisect_right(candidate, N)])

Submission status: Runtime Error

Solution code:
y = int(input())
for i in range(1, 10):
  x = i + i * 10 + i * 100
  if x >= y:
    print(x)
  	break

Submission status: Runtime Error

Solution code:
a,b,c = int(input().split())
if a > b:
  print(a*111)
elif a == b:
  if b >= c:
    print(a*111)
  else:
    print((a+1)*111)
else:
  print((a+1)*111)

Submission status: Runtime Error

Solution code:
a = input()
if (a[-1] == '0' and (int(a[0]) >= int(a[2])) or  (int(a[0]) >= int(a[2]) and int(a[0]) >= int(a[1])):
    ans = int(a[0] * 3)
else:
    ans = str(int(a[0])+1)*3
print(ans)

Submission status: Runtime Error

Solution code:
a = input()
if (a[-1] == '0' and (int(a[0]) >= int(a[2])) or  (int(a[0]) >= int(a[2]) and int(a[0]) >= int(a[1]))::
    ans = int(a[0] * 3)
else:
    ans = str(int(a[0])+1)*3
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
li = [111,222,333,444,555,666,777,888,999]
nn = []
for i in range(len(li)):
  if li[i] - n >= 0:
    nn.append(li[i]-n)
  else:
    nn.append(1000)
  
print(li[index(min(nn))])

Submission status: Runtime Error

Solution code:
n = int(input())
li = [111,222,333,444,555,666,777,888,999]
nn = []
for i in range(len(li)):
  nn.append(abs(li[i]-n))
  
print(li[min(nn)])

Submission status: Runtime Error

Solution code:
n=int(inp())
a=n%100
m=a*100+a*10+a
if n<=m:
  print(m)
else:
  print(m+111)

Submission status: Runtime Error

Solution code:
N = int(input())
len_N = len(N)
num = int(str(N)[0]) + 1
if int(str(num) * len_N) < N:
  print(str(num) * len_N)
else:
  print(str(num + 1) * (len(str(N))))

Submission status: Runtime Error

Solution code:
N = input()
ans = []
for i in len(N):
  ans.append(N[0])
if int(''.join(ans) > int(N):
    print(''.join(ans))
    exit()
for i in len(N):
  ans.append(str(int(N[0]) + 1))
print(''.join(ans))

Submission status: Runtime Error

Solution code:
n=int(input())
for count in range(10):
    if 100*count+10*count+count>n-1:
        input(100*count+10*count+count)
        break
    else:
        pass

Submission status: Runtime Error

Solution code:
N = int(input())
num_list = [111*i for i in range(1,10)]
nums = [num_list[i]-N for i in range(len(num_list)) if num_list[i]-N > 0]
n = min(nums)
print(N+n)

Submission status: Runtime Error

Solution code:
n = input()

lst = [111,222,333,444,555,666,777,888,999]

for i in lst:
    if n <= i:
        print(i)
        break