CodeEff/ECCO huggingface dataset:
# Original solution
import random


class Dice(object):
    def __init__(self):
        self.t = 1
        self.s = 2
        self.e = 3
        self.w = 4
        self.n = 5
        self.b = 6

    def __init__(self, faces):
        self.t = faces[0]
        self.s = faces[1]
        self.e = faces[2]
        self.w = faces[3]
        self.n = faces[4]
        self.b = faces[5]

    def roll(self, direct):
        if direct == 0:
            self.t, self.s, self.b, self.n = self.n, self.t, self.s, self.b
        elif direct == 1:
            self.t, self.w, self.b, self.e = self.e, self.t, self.w, self.b
        elif direct == 2:
            self.n, self.w, self.s, self.e = self.w, self.s, self.e, self.n

    def is_equal(self, dice):
        if self.t == dice.t and self.s == dice.s and self.e == dice.e and self.w == dice.w and self.n == dice.n and self.b == dice.b:
            return True
        else:
            return False

n = int(eval(input()))
dice_list = []
flag_list = []
for _ in range(n):
    flag = False
    faces = list(map(int, input().split()))
    dice_list.append(Dice(faces))

    if n == 0:
        continue

    dice_a = dice_list[-1]
    for i in range(len(dice_list) - 1):
        dice_b = dice_list[i]

        for i in range(1000):
            dice_b.roll(random.randint(0, 3))
            if dice_a.is_equal(dice_b):
                flag = True
                break

        flag_list.append(flag)

if any(flag_list):
    print('No')
else:
    print('Yes')



# Optimized solution
import random


class Dice(object):
    def __init__(self):
        self.t = 1
        self.s = 2
        self.e = 3
        self.w = 4
        self.n = 5
        self.b = 6

    def __init__(self, faces):
        self.t = faces[0]
        self.s = faces[1]
        self.e = faces[2]
        self.w = faces[3]
        self.n = faces[4]
        self.b = faces[5]

    def roll(self, direct):
        if direct == 0:
            self.t, self.s, self.b, self.n = self.n, self.t, self.s, self.b
        elif direct == 1:
            self.t, self.w, self.b, self.e = self.e, self.t, self.w, self.b
        elif direct == 2:
            self.n, self.w, self.s, self.e = self.w, self.s, self.e, self.n

    def is_equal(self, dice):
        if self.t == dice.t and self.s == dice.s and self.e == dice.e and self.w == dice.w and self.n == dice.n and self.b == dice.b:
            return True
        else:
            return False

n = int(eval(input()))
dice_list = []
flag_list = []
for _ in range(n):
    flag = False
    faces = list(map(int, input().split()))
    dice_list.append(Dice(faces))

    if n == 0:
        continue

    dice_a = dice_list[-1]
    for i in range(len(dice_list) - 1):
        dice_b = dice_list[i]

        for i in range(500):
            dice_b.roll(random.randint(0, 3))
            if dice_a.is_equal(dice_b):
                flag = True
                break

        flag_list.append(flag)

if any(flag_list):
    print('No')
else:
    print('Yes')
# Original solution
def roll(die, d):
    if d == "E":
        return [die[3], die[1], die[0], die[5], die[4], die[2]]
    if d == "N":
        return [die[1], die[5], die[2], die[3], die[0], die[4]]
    if d == "S":
        return [die[4], die[0], die[2], die[3], die[5], die[1]]
    if d == "W":
        return [die[2], die[1], die[5], die[0], die[4], die[3]]
    if d == "L":
        return [die[0], die[3], die[1], die[4], die[2], die[5]]
    if d == "R":
        return [die[0], die[2], die[4], die[1], die[3], die[5]]

def checkdice(die1, die2):
    ans = False
    for d in "RRRNRRRNRRRSRRRSRRRNRRRR":
        if die1 == die2:
            ans = True
            break
        die2 = roll(die2, d)
    return ans

dice = []
msg = "Yes"
n = int(eval(input()))
for _ in range(n):
    dice.append(list(map(int, input().split())))
for i in range(n):
    for j in range(i + 1, n):
        if checkdice(dice[i], dice[j]):
            msg = "No"
print(msg)

# Optimized solution
def roll(die, d):
    if d == "E":
        return [die[3], die[1], die[0], die[5], die[4], die[2]]
    if d == "N":
        return [die[1], die[5], die[2], die[3], die[0], die[4]]
    if d == "S":
        return [die[4], die[0], die[2], die[3], die[5], die[1]]
    if d == "W":
        return [die[2], die[1], die[5], die[0], die[4], die[3]]
    if d == "L":
        return [die[0], die[3], die[1], die[4], die[2], die[5]]
    if d == "R":
        return [die[0], die[2], die[4], die[1], die[3], die[5]]

def checkdice(die1, die2):
    ans = False
    for d in "RRRNRRRNRRRSRRRSRRRNRRRR":
        if die1 == die2:
            ans = True
            break
        die2 = roll(die2, d)
    return ans

dice = []
msg = "Yes"
n = int(eval(input()))
for _ in range(n):
    dice.append(list(map(int, input().split())))
for i in range(n):
    for j in range(i + 1, n):
        if checkdice(dice[i], dice[j]):
            msg = "No"
            break
    if msg == "No":
        break
print(msg)
# Original solution
class Dice:

    def __init__(self):
        # 初期値がない場合
        # 上, 南、東、西、北、下にそれぞれ1, 2, 3, 4, 5, 6がくる想定
        self.t = 1
        self.s = 2
        self.e = 3
        self.w = 4
        self.n = 5
        self.b = 6
        self.rotway = {"S": 0, "N": 1, "E": 2, "W": 3}

    def __init__(self, t, s, e, w, n, b):
        # 初期値が指定される場合
        self.t = t
        self.s = s
        self.e = e
        self.w = w
        self.n = n
        self.b = b
        self.rotway = {"S": 0, "N": 1, "E": 2, "W": 3}

    def rot(self, way):
        if way == 0:
            self.t, self.s, self.e, self.w, self.n, self.b = self.n, self.t, self.e, self.w, self.b, self.s
        elif way == 1:
            self.t, self.s, self.e, self.w, self.n, self.b = self.s, self.b, self.e, self.w, self.t, self.n
        elif way == 2:
            self.t, self.s, self.e, self.w, self.n, self.b = self.w, self.s, self.t, self.b, self.n, self.e
        elif way == 3:
            self.t, self.s, self.e, self.w, self.n, self.b = self.e, self.s, self.b, self.t, self.n, self.w
        

def main():
    import random

    n = int(eval(input()))
    diceList = [[0 for _ in range(6)] for _ in range(n)]
    for i in range(n):
        diceList[i][0],diceList[i][1],diceList[i][2],diceList[i][3],diceList[i][4],diceList[i][5] = list(map(int, input().split()))

    flag = 0

    # 2つ目以降のさいころが、以前のさいころと一致しているか確認していく。
    for i in range(1, n):
        if flag == 1:
            break
        else:
            dice_a = Dice(diceList[i][0],diceList[i][1],diceList[i][2],diceList[i][3],diceList[i][4],diceList[i][5])
            for j in range(i):
                dice_b = Dice(diceList[j][0],diceList[j][1],diceList[j][2],diceList[j][3],diceList[j][4],diceList[j][5])

                for _ in range(100):
                    if (dice_a.t, dice_a.s, dice_a.e, dice_a.w, dice_a.n, dice_a.b) == (dice_b.t, dice_b.s, dice_b.e, dice_b.w, dice_b.n, dice_b.b):
                        flag = 1
                        break
                    else:
                        seed = random.randint(0, 3)
                        dice_a.rot(seed)

    if flag == 0:
        print("Yes")
    else:
        print("No")



if __name__ == '__main__':
    main()



# Optimized solution
def main():
    n = int(eval(input()))
    dices=[]
    same = 0
    for _ in range(n):
        dices.append(list(map(int, input().split())))

    for i in range(n-1):
        for j in range(i+1,n):
            same += check_dice(dices[i], dices[j])
        if same >= 1:
            print('No')
            break

    if same == 0:
        print('Yes')


def check_dice(f, s):
    yes = 0
    for _ in range(4):
        s[0],s[2],s[5],s[3] = s[2],s[5],s[3],s[0]
        for _ in range(4):
            s[1],s[2],s[4],s[3] = s[2],s[4],s[3],s[1]
            if f == s:
                yes = 1

    for _ in range(4):
        s[0],s[1],s[5],s[4] = s[1],s[5],s[4],s[0]
        for _ in range(4):
            s[1],s[2],s[4],s[3] = s[2],s[4],s[3],s[1]
            if f == s:
                yes = 1

    return yes

if __name__ == '__main__':
    main()
# Original solution
def check(x, y): 
    z = [0, 1, 2]
    for i in range(6):
        order = [0, 0, 0]
        for j in range(3):
            if {x[j], x[-j-1]} != {y[z[j]], y[-z[j]-1]}:
                break
            if x[j] == y[z[j]]:
                order[j] = 1 
                if x[j] == x[-j-1]:
                    order[j] = 2 
        else:
            if 2 in order or (i < 3) == sum(order) % 2:
                return True
        z = [z[2], z[0], z[1]]
        if i == 2:
            z = [z[0], z[2], z[1]]
    return False

n = int(eval(input()))
x = [[] for i in range(n)]
for i in range(n):
    x[i] = input().split()
for i in range(n):
    for j in range(i+1, n, 1): 
        if check(x[i], x[j]):
            break
    else:
        continue
    print('No')
    break
else:
    print('Yes')

# Optimized solution
def check(x, y):
    for i in range(6):
        order = [0, 0, 0]
        for j in range(3):
            if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}:
                break
            if x[j] == y[z[i][j]]:
                order[j] = 1
                if x[j] == x[-j-1]:
                    order[j] = 2
        else:
            if 2 in order or z[i][3] == sum(order) % 2:
                return True
    return False

n = int(eval(input()))
x = [[] for i in range(n)]
for i in range(n):
    x[i] = list(map(int, input().split()))
z = [[0, 1, 2, 1], [0, 2, 1, 0], [2, 1, 0, 0], [1, 0, 2, 0], [2, 0, 1, 1], [1, 2, 0, 1]]
different = True
for i in range(n):
    for j in range(i+1, n, 1):
        if check(x[i], x[j]):
            break
    else:
        continue
    print('No')
    break
else:
    print('Yes')
# Original solution
mask = [[i for i in range(6)], (1, 5, 2, 3, 0, 4), (2, 1, 5, 0, 4,3),(3, 1, 0, 5, 4, 2), (4, 0, 2, 3, 5, 1)]
mask += [[mask[1][i] for i in mask[1]]]

def set_top(dice, top):
    return [dice[i] for i in mask[top]]

def twist(dice):
    return [dice[i] for i in (0, 3, 1, 4, 2, 5)]

def equal(dice1, dice2):
    for i in range(6):
        tmp_dice = set_top(dice2, i)
        for _ in range(4):
            if dice1 == tmp_dice:
                return True
            tmp_dice = twist(tmp_dice)
    return False

def diff_check_all(dices, n):
    for i in range(n -1):
        for j in range(i + 1, n):
            if equal(dices[i], dices[j]):
                return False
    return True
            

n = int(eval(input()))
dices = [input().split() for _ in range(n)]

print(('Yes' if diff_check_all(dices, n) else 'No'))

# Optimized solution
mask = [[i for i in range(6)], (1, 5, 2, 3, 0, 4), (2, 1, 5, 0, 4,3),(3, 1, 0, 5, 4, 2), (4, 0, 2, 3, 5, 1)]
mask += [[mask[1][i] for i in mask[1]]]

def set_top(dice, top):
    return [dice[i] for i in mask[top]]

def twist(dice):
    return [dice[i] for i in (0, 3, 1, 4, 2, 5)]

def equal(dice1, dice2):
    if sorted(dice1) != sorted(dice2):
        return False
    
    for i in range(6):
        tmp_dice = set_top(dice2, i)
        for _ in range(4):
            if dice1 == tmp_dice:
                return True
            tmp_dice = twist(tmp_dice)
    return False

def diff_check_all(dices, n):
    for i in range(n -1):
        for j in range(i + 1, n):
            if equal(dices[i], dices[j]):
                return False
    return True
            

n = int(eval(input()))
dices = [input().split() for _ in range(n)]

print(('Yes' if diff_check_all(dices, n) else 'No'))
# Original solution
def move(d, r):
    if r == 'N':
        return (d[1], d[5], d[2], d[3], d[0], d[4])
    if r == 'E':
        return (d[3], d[1], d[0], d[5], d[4], d[2])
    if r == 'W':
        return (d[2], d[1], d[5], d[0], d[4], d[3])
    if r == 'S':
        return (d[4], d[0], d[2], d[3], d[5], d[1])
    return d
     
def gen_all(dice_1):
    dice = {dice_1}
    while True:
        dice2 = {move(d,r) for d in dice for r in list("NEWS")}.union(dice)
        if dice == dice2: break
        dice = dice2
    return dice    


n = int(eval(input()))
count = 0
dice = [0 for i in range(n)]


for i in range(n):
    dice[i] = tuple(map(int,input().split()))

for i in range(n):
    for k in range(i):
        if count == 1: break
        if dice[i] in gen_all(dice[k]):
            print("No")
            count = 1
            break
if count == 0:
    print("Yes")   
    

    
    
    

# Optimized solution
n = int(eval(input()))

def rot(dice,rotation):
    if rotation == "E":
        dice = (dice[3],dice[1],dice[0],dice[5],dice[4],dice[2])
    elif rotation == "W":
        dice = (dice[2],dice[1],dice[5],dice[0],dice[4],dice[3])
    elif rotation == "N":
        dice = (dice[1],dice[5],dice[2],dice[3],dice[0],dice[4])
    elif rotation == "S":
        dice = (dice[4],dice[0],dice[2],dice[3],dice[5],dice[1])
    return dice

def make_all_pattern(dice):
    pattern = {dice}
    pattern2 = pattern
    while True:
        pattern2 = pattern.union({rot(d,r) for d in pattern for r in list("NEWS")})
        if pattern2 == pattern:
            break
        pattern = pattern2
    return pattern

dice = [0 for i in range(n)]
for i in range(n):
    dice[i] = tuple(map(int,input().split()))


pattern = set()
for i in range(n-1):
    pattern = pattern.union(make_all_pattern(dice[i]))
    if dice[i+1] in pattern:
        print("No")
        break

else:
    print("Yes")
# Original solution
class Dice:
    def __init__(self,t,f,r,l,b,u):
        self.a=[[t,f,r,l,b,u]]
        self.direction={'S':(4,0,2,3,5,1),'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3),'Y':(0,3,1,4,2,5)}
    def roll(self,d,n):
        self.a[n]=[self.a[n][i] for i in self.direction[d]]
n=int(eval(input()))
for i in range(n):
    if i==0:
        t, f, r, l, b, u = list(map(int, input().split()))
        dice = Dice(t, f, r, l, b, u)
    else:
        a = list(map(int, input().split()))
        dice.a.append(a)
s='SSSWEEE'
w='YYYY'
try:
    for u in range(n - 1):
        for t in range(u + 1, n):
            for j in s:
                for r in w:
                    if dice.a[t] == dice.a[u]:
                        raise Exception
                    dice.roll(r, t)
                dice.roll(j, t)
    else:
        print('Yes')
except Exception:
    print('No')


# Optimized solution
class Dice:
    def __init__(self,t,f,r,l,b,u):
        self.a=[[t,f,r,l,b,u]]
        self.direction={'S':(4,0,2,3,5,1),'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3),'Y':(0,3,1,4,2,5)}
    def roll(self,d,n):
        self.a[n]=[self.a[n][i] for i in self.direction[d]]
n=int(eval(input()))
for i in range(n):
    if i==0:
        t, f, r, l, b, u = list(map(int, input().split()))
        dice = Dice(t, f, r, l, b, u)
    else:
        a = list(map(int, input().split()))
        dice.a.append(a)
s='SSSWEEE'
w='YYYY'
try:
    for u in range(n - 1):
        for t in range(u + 1, n):
            for j in s:
                for r in w:
                    if dice.a[t] == dice.a[u]:
                        raise Exception
                    dice.roll(r, t)
                dice.roll(j, t)
    else:
        print('Yes')
except:
    print('No')
# Original solution
import sys

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

ans=0
for i in range(n-1):
    while(A[i]+A[i+1]>x and A[i+1]>0):
        A[i+1]=A[i+1]-1
        ans=ans+1
    while(A[i]+A[i+1]>x and A[i]>0):
        A[i]=A[i]-1
        ans=ans+1
    if A[i]+A[i+1]>x:
        print((0))
        sys.exit()
print(ans)


# Optimized solution
import sys

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

ans=0
for i in range(n-1):
    next_sum=A[i]+A[i+1]
    if next_sum>x:
        if next_sum-x<=A[i+1]:
            A[i+1]=A[i+1]-(next_sum-x)
            ans=ans+(next_sum-x)
        else:
            ans=ans+A[i+1]
            if next_sum-x-A[i+1]<=A[i]:
                A[i]=A[i]-(next_sum-x-A[i+1])
                ans=ans+(next_sum-x-A[i+1])
            else:
                print((0))
                sys.exit()
            A[i+1]=0
print(ans)
# Original solution
N, x = list(map(int,input().split()))
A = list(map(int,input().split()))

ans = 0
for i in range(0, N-1):
    a = A[i]
    b = A[i+1]
    while a + b > x:
        if b > 0:
            b -= 1
            ans += 1
        elif a > 0:
            a -= 1
            ans += 1
    A[i] = a
    A[i+1] = b

print(ans)

# Optimized solution
N, x = list(map(int,input().split()))
A = list(map(int,input().split()))

ans = 0
for i in range(0, N-1):
    while A[i] + A[i+1] > x:
        tmp = A[i + 1] + A[i] - x
        if A[i+1] > 0:
            if tmp > A[i+1]:
                tmp = A[i+1]
            A[i+1] -= tmp
            ans += tmp
        elif A[i] > 0:
            if tmp > A[i]:
                tmp = A[i]
            A[i] -= tmp
            ans += tmp

print(ans)
# Original solution
n,x=list(map(int,input().split()))
a=list(map(int,input().split()))
i=0
num=0

while i<n-1:
        if a[i] + a[i+1] > x:
                a[i+1]=a[i+1]-1
                num=num+1
        else:
                i=i+1

print(num)

# Optimized solution
n,x=list(map(int,input().split()))
a=list(map(int,input().split()))
i=0
num=0

if a[0] > x:
        ans=a[0]-x
        a[0]=a[0]-ans
        num=num+ans
while i<n-1:
        if a[i] + a[i+1] > x:
                ans=a[i] + a[i+1] - x
                a[i+1]=a[i+1]-ans
                num=num+ans
        else:
                i=i+1

print(num)
# Original solution
n,x = list(map(int,input().split()))
lis = list(map(int,input().split()))
cou = 0
if lis[0] > x:
  cou += (lis[0] - x)
  lis[0] -= (lis[0] -x)
for i in range(n-1):
  if lis[i+1] + lis[i] > x:
    cou += (lis[i+1] + lis[i] -x)
    lis[i+1] -= (lis[i+1] + lis[i] -x)
print(cou)

# Optimized solution
n,k = list(map(int,input().split()))
lis = list(map(int,input().split()))
cou = lis[0]
ans = 0
if cou > k:
    ans += cou-k
    cou = k
for i in range(1,n):
    if cou + lis[i] > k:
        num = cou+lis[i]-k
        cou = lis[i]-num
        ans += num
    else:
        cou = lis[i]
print(ans)
# Original solution
import sys

n, x, *lst1 = list(map(int, sys.stdin.read().split()))
res1 = res2 = 0
lst2 = [0] + lst1
lst1.append(0)
for i in range(n):
  tmpsum = lst2[i] + lst2[i + 1]
  if tmpsum > x:
    res1 += tmpsum - x
    lst2[i + 1] -= tmpsum - x

for i in range(n, 0, -1):
  tmpsum = lst1[i] + lst1[i - 1]
  if tmpsum > x:
    res2 += tmpsum - x
    lst1[i - 1] -= tmpsum - x  
print((min(res1, res2)))

# Optimized solution
import sys

n, x, *lst1 = list(map(int, sys.stdin.read().split()))
res1 = 0
lst2 = [0] + lst1
lst1.append(0)
for i in range(n):
  tmpsum = lst2[i] + lst2[i + 1]
  if tmpsum > x:
    res1 += tmpsum - x
    lst2[i + 1] -= tmpsum - x

print(res1)
# Original solution
N,M = list(map(int,input().split(" ")))
ar = list(map(int,input().split(" ")))
count = 0
for i in range(N):
    if ar[i] > M:
        count += ar[i] - M
        ar[i] = M
for i in range(N-1):
    if ar[i] + ar[i+1] > M:
        while ar[i] + ar[i+1] > M:
            if ar[i+1] == 0:
                ar[i] -= 1
                count += 1
            else:
                ar[i+1] -= 1
                count += 1
print(count)

# Optimized solution
n,m = list(map(int,input().split(" ")))
ar = list(map(int,input().split(" ")))
a = sum(ar)
for i in range(n-1):
    if ar[i] + ar[i+1] > m:
        b = (ar[i] + ar[i+1]) - m
        if ar[i+1] >= b:
            ar[i+1] -= b 
        else:
            ar[i] -= b - ar[i+1]
            ar[i+1] = 0
print((a - sum(ar)))
# Original solution
N,x = list(map(int,input().split()))
A = list(map(int,input().split()))
count = 0
for i in range(1,N):
    diff = A[i-1]+A[i]-x
    if diff > 0:
        if A[i]>=diff:
            A[i]-=diff
            count += diff
        else:
            A[i] = 0
            A[i-1] -= diff - A[i]
            count += diff
print(count)



# Optimized solution
N,x = list(map(int,input().split()))
A = list(map(int,input().split()))
cnt = 0
for i in range(1,N):
    diff = A[i]+A[i-1]-x
    if diff>0:
        cnt += diff
        A[i] -= min(A[i],diff)

print(cnt)
# Original solution
N,x = list(map(int,input().split()))
A = list(map(int,input().split()))
cnt = 0
for i in range(1,N):
    diff = A[i]+A[i-1]-x
    if diff>0:
        cnt += diff
        A[i] -= min(A[i],diff)

print(cnt)

# Optimized solution
N,x = list(map(int,input().split()))
A = list(map(int,input().split()))
cnt = 0
if A[0] > x:
    cnt += (A[0]-x)
    A[0] = x
for i in range(1,N):
    if A[i]+A[i-1] > x:
        cnt += (A[i]+A[i-1]-x)
        A[i] -= (A[i]+A[i-1]-x)
print(cnt)
# Original solution
#! /usr/bin/env python3

N, x = list(map(int, input().split()))
C = list(map(int, input().split()))
cnt = 0
for i in range(N-1):
    while C[i]+C[i+1] > x:
        cnt += 1
        C[i+1] -= 1
print(cnt)

# Optimized solution
#! /usr/bin/env python3

N, x = list(map(int, input().split()))
C = list(map(int, input().split()))
cnt = 0
for i in range(N-1):
    if C[i]+C[i+1] > x:
        a = C[i]+C[i+1] - x
        cnt += a
        C[i] = min(C[i+1]-a, 0)
        C[i+1] = max(C[i+1]-a, 0)
print(cnt)
# Original solution
n, x = list(map(int, input().split()))

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

ans = 0

for i in range(n - 1):
    while a[i] + a[i + 1] > x:
        a[i + 1] -= 1
        ans += 1

print(ans)


# Optimized solution
n, x = list(map(int, input().split()))
a = list(map(int, input().split()))

cnt, a[0] = sum(a), min(a[0], x)
for i in range(1, n):
    if a[i - 1] + a[i] > x:
        a[i] = x - a[i - 1]
print((cnt - sum(a)))
# Original solution
print((-(-int(eval(input()))//111*111)))

# Optimized solution
print((0--int(eval(input()))//111*111))
# Original solution
num = str(eval(input()))
a = []
x=[]
for i in str(num):
    a.append(i)
if a[1] <= a[0] and a[2] < a[0]:
    x.append(a[0])
    x.append(a[0])
    x.append(a[0])
    print((''.join(str(i) for i in x)))
elif a[1] < a[0]:
    x.append(a[0])
    x.append(a[0])
    x.append(a[0])
    print((''.join(str(i) for i in x)))
elif a[0] == a[1] == a[2]:
    x.append(a[0])
    x.append(a[0])
    x.append(a[0])
    print((''.join(str(i) for i in x)))
else:
    z = int (a[0]) +1
    x.append(z)
    x.append(z)
    x.append(z)
    print((''.join(str(i) for i in x)))


# Optimized solution
a=[111,222,333,444,555,666,777,888,999]
i=0
n=int(eval(input()))
while a[i]<n:
    i=i+1
print((a[i]))
# Original solution
from math import ceil
print((ceil(int(eval(input())) / 111) * 111))

# Optimized solution
# ABC111B - AtCoder Beginner Contest 111
def main():
    N = int(eval(input()))
    ans = (N + 110) // 111 * 111
    print(ans)


if __name__ == "__main__":
    main()
# Original solution
n = int(eval(input()))

if n % 111 ==0:
    print(n)
    exit()

while n % 111 != 0:
    n += 1
    if n % 111 == 0:
        print(n)
        exit()

# Optimized solution
import sys
n = int(eval(input()))

for i in range(n,1000):
    a = i//100
    b = (i - a*100)//10
    c = i - a*100-b*10
    if a == b == c:
        print(i)
        sys.exit()
# Original solution
n=int(eval(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))

# Optimized solution
n=int(eval(input()))
num=str(n)[0]*3

if n<=int(num):
  print(num)
  
else:
  print((int(num)+111))
# Original solution
n = int(eval(input()))
ok = False
for i in range(1,10):
    if int(str(i)*3)>=n:
        print((str(i)*3))
        exit()

# Optimized solution
n = int(eval(input()))
for i in range(1, 10):
    if n <= i * 111:
        print((i * 111))
        exit()
# Original solution
A = int(eval(input()))
if A <=111:
  print((111))
elif A<= 222:
  print((222))
elif A <= 333:
  print((333))
elif A <= 444:
  print((444))
elif A <= 555:
  print((555))
elif A <=666:
  print((666))
elif A <= 777:
  print((777))
elif A <= 888:
  print((888))
elif A <=999:
  print((999))

# Optimized solution
A = int(eval(input()))
B = int(A / 111)
C = A % 111 == 0
if not C:
  B = (B+1) * 111
  print(B)
else:
  B = B*111
  print(B)
# Original solution
n = int(eval(input()))
c = 0
while (n+c)%111 != 0:
    c += 1
print((n+c))


# Optimized solution
n = int(eval(input()))
while True:
    if len(set(str(n))) == 1:
        print(n)
        break
    else:
        n += 1