Harryxun/stf_run huggingface dataset:
num_input = [input() for i in range(2)]
x = int(num_input[0].split()[0])
n = int(num_input[0].split()[1])

num_list = [int(n) for n in num_input[1].split()]
num_list.sort()

ans=x

if n!=0 and n!=1 and n!=100:
    if x in num_list:
        index=num_list.index(x)

        value_left=x-1
        value_right=x+1

        if index!=0:
            index_left=index-1
        if index!=n-1:
            index_right=index+1
        
        if index==0:
            ans=x-1
        elif index==n-1:
            if num_list[index-1]==x-1:
                ans=x+1
            else:
                ans=x-1
        else:
            for i in range(n):
                if num_list[index_left]!=value_left:
                    ans=value_left
                    break
                elif num_list[index_right]!=value_right:
                    ans=value_right
                    break
                if index_left!=0:
                    index_left=index_left-1
                if index_right!=n:
                    index_right=index_right+1
                value_left=value_left-1
                value_right=value_right+1

if n==1
    ans=x-1

if n==100:
    if x<=50:
        ans=0
    if x>50:
        ans=101

print(ans)

### FIXED CODE ###

num_input = [input() for i in range(2)]
x = int(num_input[0].split()[0])
n = int(num_input[0].split()[1])

num_list = [int(n) for n in num_input[1].split()]
num_list.sort()

ans=x

if n!=0 and n!=1 and n!=100:
    if x in num_list:
        index=num_list.index(x)

        value_left=x-1
        value_right=x+1

        if index!=0:
            index_left=index-1
        if index!=n-1:
            index_right=index+1
        
        if index==0:
            ans=x-1
        elif index==n-1:
            if num_list[index-1]==x-1:
                ans=x+1
            else:
                ans=x-1
        else:
            for i in range(n):
                if num_list[index_left]!=value_left:
                    ans=value_left
                    break
                elif num_list[index_right]!=value_right:
                    ans=value_right
                    break
                if index_left!=0:
                    index_left=index_left-1
                if index_right!=n:
                    index_right=index_right+1
                value_left=value_left-1
                value_right=value_right+1

if n==1:
    ans=x-1

if n==100:
    if x<=50:
        ans=0
    if x>50:
        ans=101

print(ans)
import math

a, b = (int(_) for _ in input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a,b))



### FIXED CODE ###

import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

a, b = (int(_) for _ in input().split())

z = lcm(a,b)
print(z)
A,B,C,D = map(int, input().split())
if C < B:
  if D < B:
    print(D-C)
  else:
	print(B-C)
else:
  print(0)


### FIXED CODE ###

A,B,C,D = map(int, input().split())
print(max(min(B,D)-max(A,C), 0))
N = int(input())
TXY = [list(map(int, input().split())) for _ in range(N)]
TXY.insert(0,[0,0,0])

point = 0
for i in range(N+1):
    if TXY[i+1][0] - TXY[i][0] < abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2]):
        point += 1

for i in range(N+1):
    if TXY[i+1][0] - TXY[i][0] % 2 != abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2]) %2 :
        point += 1

if point == 0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

N = int(input())
TXY = [list(map(int, input().split())) for _ in range(N)]
TXY.insert(0,[0,0,0])

point_a, point_b = 0, 0
for i in range(N):
    if TXY[i+1][0] - TXY[i][0] < abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2]):
        point_a += 1

for i in range(N):
    if point_a == 0 and ((TXY[i+1][0] - TXY[i][0]) % 2 != (abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2])) %2) :
        point_b += 1

if point_a == 0 and point_b == 0:
    print('Yes')
else:
    print('No')
Alice = 0
Bob = 0
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
Alice = a[::2]
Bob = a[1::2]
print(Alice-Bob)

### FIXED CODE ###

Alice = 0
Bob = 0
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
Alice = a[::2]
Bob = a[1::2]
print(sum(Alice)-sum(Bob))
from itertools import accumulate
import bisect
n,q = map(int,input().split())
if n%2:
  a = [0]+list(map(int,input().split()))
  n += 1
else:
  a = list(map(int,input().split()))
fs = [a[i] if i%2 else 0 for i in range(n)]
accss = [0]*n
accff = list(accumulate(a))
accfs = list(accumulate(fs))
xls = []
xpt = []
print(accff)
print(accfs)
for i in range(n//2):
  xls.append((a[2*i+1]+a[i+n//2])/2)
  if i == 0:
    xpt.append(accff[n-1]-accff[n//2-1])
  else:
    xpt.append(accff[n-1]-accff[i+n//2-1]+accfs[2*i-1])
for _ in range(q):
  x = bisect.bisect_left(xls,int(input()))
  if x >= n-1:
    print(xpt[-1])
  else:
    print(xpt[x])

### FIXED CODE ###

import sys
input = sys.stdin.readline
from itertools import accumulate
import bisect
n,q = map(int,input().split())
if n%2:
  a = [0]+list(map(int,input().split()))
  n += 1
else:
  a = list(map(int,input().split()))
fs = [a[i] if i%2 else 0 for i in range(n)]
accss = [0]*n
accff = list(accumulate(a))
accfs = list(accumulate(fs))
xls = []
xpt = []
for i in range(n//2):
  xls.append((a[2*i+1]+a[i+n//2])/2)
  if i == 0:
    xpt.append(accff[n-1]-accff[n//2-1])
  else:
    xpt.append(accff[n-1]-accff[i+n//2-1]+accfs[2*i-1])
for _ in range(q):
  x = bisect.bisect_left(xls,int(input()))
  if x >= n//2:
    print(xpt[-1])
  else:
    print(xpt[x])
t=int(input())
S=0
for i in list(range(t+1)):
  if i%5!=0 and i%3!=0:
    sum += i
print(S)

### FIXED CODE ###

string = input()
found = False
for i in string:
  if i == '7':
    found=True
    break
    
    
if found:
  print("Yes")
else:
  print("No")
import numpy as np
from operator import itemgetter
N,M=(int(x) for x in input().split())
A=[]

for i in range(N):
  D=[int(x) for x in input().split()]
  A=A.append([D])    
result=A.sort(key=itemgetter(0))
count=M
sum=0
for i in range(N):
  if count-A[i][1]>0:
    count=count-A[i][1]
    sum+=A[i][0]*A[i][1]
  else:
    sum+=count*A[i][0]
    break
print(sum)    

### FIXED CODE ###

import numpy as np
from operator import itemgetter
N,M=(int(x) for x in input().split())
A=[]
 
for i in range(N):
  D=[int(x) for x in input().split()]
  A+=[D]    
result=A.sort(key=itemgetter(0))
count=M
sum=0
for i in range(N):
  if count-A[i][1]>0:
    count=count-A[i][1]
    sum+=A[i][0]*A[i][1]
  else:
    sum+=count*A[i][0]
    break
print(sum)
n = int(input())
red =[]
for i in range(n):
  l = str(input())
  red.append(l)

m = int(input())
blue =[]
for i in range(m):
  l = str(input())
  blue.append(l)
  
import collections

cr = collections.Counter(red)
red_name = cr.most_common()[0][0]
red_count = cr.most_common()[0][1]
cb = collections.Counter(blue)
blue_name = cb.most_common()[0][0]
blue_count = cb.most_common()[0][1]

if blue_name == red_name:
  if red_count - blue_count < 0:
    if len(red)==1:
      print(0)
    else:
      if cr.most_common()[1][0]==cb.most_common()[1][0]:
        print(cr.most_common()[1][1]-cb.most_common()[1][1])
      else:
        print(cr.most_common()[1][1])
  else:
    print(red_count - blue_count)
else:
  print(red_count)

### FIXED CODE ###

n = int(input())
red =[]
for i in range(n):
  l = str(input())
  red.append(l)

m = int(input())
blue =[]
for i in range(m):
  l = str(input())
  blue.append(l)
  
import collections

cr = collections.Counter(red)
crs = list(cr.most_common())
cb = collections.Counter(blue)
cbs = list(cb.most_common())

result =[]

for i in range(len(cbs)):
  for j in range(len(crs)):
    if cbs[i][0]==crs[j][0]:
      result.append(crs[j][1]-cbs[i][1])
    else:
      flag = False
      count = 0
      for k in range(len(cbs)):
        if cbs[k].count(crs[j][0]) == 0:
          count+=1
      if count == len(cbs):
        result.append(crs[j][1])
        flag = False
        count = 0

if max(result)>0:
  print(max(result))
else:
  print(0)
import math

"""
def gcd(a, b):
    if a < b:
        a, b = b, a

    if b == 0:
        return a

    c = a % b
    return gcd(b, c)
"""

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

b = a[0]
for i in range(n - 1):
    b = math.gcd(a[i + 1], b)

print(b)


### FIXED CODE ###

def gcd(a, b):
    if a < b:
        a, b = b, a

    if b == 0:
        return a

    c = a % b
    return gcd(b, c)

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

b = a[0]
for i in range(n - 1):
    b = gcd(a[i + 1], b)

print(b)
S = int(input())
T = int(input())

t = word.rstrip(T)

if S == T:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

S = input()
T = input()
 
t = T[:-1]
 
if S == t:
  print("Yes")
else:
  print("No")
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
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()))

x,k,d = inpl()
x = abs(x)
if x - k*d >= 0:
    print(x - k*d)
    quit()
res1 = x - x//d*d0 
res2 = abs(x - (x//d+1) *d)
if (k-x//d)%2:
    print(res2)
else:
    print(res1)

### FIXED CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
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()))

x,k,d = inpl()
x = abs(x)
if x - k*d >= 0:
    print(x - k*d)
    quit()
res1 = x - x//d*d
res2 = abs(x - (x//d+1) *d)
if (k-x//d)%2:
    print(res2)
else:
    print(res1)
n = int(input())
h = list(map(int, input().split()))

cnt = [0]*(n-1)
for i in range(0, len(h)-2):
    for j in range(i, len(h)-1):
        if h[j] >= h[j+1]:
            cnt[i] += 1
        else:
            break

print(max(cnt))


### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))

out, cnt = 0, 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        cnt += 1
        out = max(out, cnt)
    else:
        cnt = 0

print(out)
import math
N,K=map(int, input().split()) 

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(1, K+1):
    print((combinations_count(N-K+1, i) * combinations_count(K-i+(i-1), i-1))%(10**9+7))

### FIXED CODE ###

import math
n,k=map(int,input().split()) 

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

mod_num = 10 ** 9 + 7
for i in range(1, k+1):
    if i > n - k + 1:
        print(0)
    else:
        print(comb(n-k+1, i) * comb(k-i+(i-1), i-1) % mod_num)
# import sys
# sys.setrecursionlimit(2000)

N = int(input())
COR = [tuple((map(int, input().split()))) for _ in range(N)]


class Group:
    
    def __init__(self):
        self.n = 0
        self.x = []
        self.y = []
        
    def new_cor_n(self):
        return len(self.x) * len(self.y) - self.n
    
    
def grouping(group, x, xcor, ycor):
    xcor[x][1] = True
    group.x.append(x)
    for y in xcor[x][0]:
        if ycor[y][1]:
            continue
        group.n += 1
        ycor[y][1] = True
        group.y.append(y)
        for x_ in ycor[y][0]:
            if xcor[x_][1]:
                continue
            group.n += 1
            grouping(group, x_, xcor, ycor)
            
if False:
    print(0)
else:
    xcor, ycor = {}, {}
    for xi, yi in COR:
        if xi in xcor:
            xcor[xi][0].append(yi)
        else:
            xcor[xi] = [[yi], False]
        if yi in ycor:
            ycor[yi][0].append(xi)
        else:
            ycor[yi] = [[xi], False]
    group_list = []
    for x, v in xcor.items():
        if v[1]:
            continue
        group = Group()
        group_list.append(group)
        grouping(group, x, xcor, ycor)
    s = 0
    for group in group_list:
        s += group.new_cor_n()
    print(s)


### FIXED CODE ###

# import sys
# sys.setrecursionlimit(20000)


N = int(input())
COR = [tuple((map(int, input().split()))) for _ in range(N)]


class Group:
    
    def __init__(self):
        self.n = 0
        self.x = 0
        self.y = 0
        self.xy = {}
        
    def new_cor_n(self):
        return self.x * self.y - self.n
        

def grouping(group, x, xcor, ycor):
    x_list = []
    group.x += 1
    for y in xcor[x][0]:
        if (x, y) not in group.xy:
            group.n += 1
            group.xy[(x, y)] = None
        if ycor[y][1]:
            continue
        ycor[y][1] = True
        group.y += 1
        for x_ in ycor[y][0]:
            if (x_, y) not in group.xy:
                group.n += 1
                group.xy[(x_, y)] = None
            if xcor[x_][1]:
                continue
            xcor[x_][1] = True
            x_list.append(x_)
    return x_list

if N <= 2:
    print(0)
else:
    xcor, ycor = {}, {}
    for xi, yi in COR:
        if xi in xcor:
            xcor[xi][0].append(yi)
        else:
            xcor[xi] = [[yi], False]
        if yi in ycor:
            ycor[yi][0].append(xi)
        else:
            ycor[yi] = [[xi], False]
    group_list = []
    for i, v in xcor.items():
        if v[1]:
            continue
        group = Group()
        group_list.append(group)
        xcor[i][1] = True
        x_list = [i]
        while True:
            new_x_list = []
            for x in x_list:
                new_x_list += grouping(group, x, xcor, ycor)
            if new_x_list == []:
                break
            x_list = new_x_list
    s = 0
    for group in group_list:
        s += group.new_cor_n()
    print(s)
from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
MOD = 10**9+7
def prime_table(n):
  prime = [2]
  limit = int(n**0.5)
  data = [i+1 for i in range(2,n,2)]
  isprime = [0]*(n+1)
  isprime[2] = 1
  min_factor = [0 if i%2 != 0 else 2 for i in range(n+1)]
  while True:
    p = data[0]
    prime.append(p)
    isprime[p] = 1
    pdata,data = data,[]
    for e in pdata:
      if e%p != 0:
        data.append(e)
      else:
        min_factor[e] = p
    if limit <= p:
      for i in data:
        isprime[i] = 1
        min_factor[i] = i
      return prime + data,isprime,min_factor
def modinv(a,m=MOD):
  b,u,v = m,1,0
  while b:
    t = a//b
    a,u = a-t*b,u-t*v
    a,b,u,v = b,a,v,u
  u %= m
  if u < 0:
    u += m
  return u
ma = max(a)
data,isprime,min_factor = prime_table(ma)
prime = [0] * (ma+1)
for i in a:
  d = defaultdict(int)
  while isprime[i] == 0:
    d[min_factor[i]] += 1
    i = i // min_factor[i]
  d[i] += 1
  for j,k in d.items():
    prime[j] = max(prime[j],k)
lcm = 1
for i in range(ma+1):
  if prime[i] != 0:
    lcm = (lcm*pow(i,prime[i],MOD))%MOD
c = 0
for i in a:
  c += lcm*modinv(i,MOD)
  c %= MOD
print(c)

### FIXED CODE ###

from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
MOD = 10**9+7
def prime_table(n):
  if n <= 1:
    return [],[],[]
  prime = [2]
  limit = int(n**0.5)
  data = [i+1 for i in range(2,n,2)]
  isprime = [0]*(n+1)
  isprime[2] = 1
  min_factor = [0 if i%2 != 0 else 2 for i in range(n+1)]
  while True:
    p = data[0]
    prime.append(p)
    isprime[p] = 1
    pdata,data = data,[]
    for e in pdata:
      if e%p != 0:
        data.append(e)
      else:
        min_factor[e] = p
    if limit <= p:
      for i in data:
        isprime[i] = 1
        min_factor[i] = i
      return prime + data,isprime,min_factor
def modinv(a,m=MOD):
  b,u,v = m,1,0
  while b:
    t = a//b
    a,u = a-t*b,u-t*v
    a,b,u,v = b,a,v,u
  u %= m
  if u < 0:
    u += m
  return u
ma = max(a)
data,isprime,min_factor = prime_table(ma)
prime = [0] * (ma+1)
for i in a:
  if i == 1:
    continue
  d = defaultdict(int)
  while isprime[i] == 0:
    d[min_factor[i]] += 1
    i = i // min_factor[i]
  d[i] += 1
  for j,k in d.items():
    prime[j] = max(prime[j],k)
lcm = 1
for i in range(ma+1):
  if prime[i] != 0:
    lcm = (lcm*pow(i,prime[i],MOD))%MOD
c = 0
for i in a:
  c += lcm*modinv(i,MOD)
  c %= MOD
print(c)
a b = input()
if a < b:
    print("a < b")
elif a > b:
    print("a > b")
elif a == b:
    print("a == b")

### FIXED CODE ###

memo = input().split()
a,b = [int(i) for i in memo]
if a < b:
    print("a < b")
elif a > b:
    print("a > b")
elif a == b:
    print("a == b")
# -*- coding: utf-8 -*-
import math
n = list(map(int, input().split()))
print('{0:.6f} {1: .6f}'.format(n[0] * 2 * math.pi, n[0] * n[0] * math.pi))


### FIXED CODE ###

# -*- coding: utf-8 -*-
import math
n = list(map(float, input().split()))
print('{0:.6f} {1: .6f}'.format(n[0] * n[0] * math.pi, n[0] * 2 * math.pi))
def get_second(a):
	if len(a) == 1:
		return 0
	else:
		a[1][0]

n = int(input())
a = [int(v) for v in input().split()]
nums = [{}, {}]
for i, v in enumerate(a):
	if v in nums[i % 2]:
		nums[i % 2][v] += 1
	else:
		nums[i % 2][v] = 1
evens = sorted([(v, k) for k, v in nums[0].items()], reverse=True)
odds = sorted([(v, k) for k, v in nums[1].items()], reverse=True)
if evens[0][1] != odds[0][1]:
	print(n - evens[0][0] - odds[0][0])
else:
	print(n - max(evens[0][0] + get_second(odds), get_second(evens) + odds[0][0]))

### FIXED CODE ###

def get_second(a):
	if len(a) == 1:
		return 0
	else:
		return a[1][0]

n = int(input())
a = [int(v) for v in input().split()]
nums = [{}, {}]
for i, v in enumerate(a):
	if v in nums[i % 2]:
		nums[i % 2][v] += 1
	else:
		nums[i % 2][v] = 1
evens = sorted([(v, k) for k, v in nums[0].items()], reverse=True)
odds = sorted([(v, k) for k, v in nums[1].items()], reverse=True)
if evens[0][1] != odds[0][1]:
	print(n - evens[0][0] - odds[0][0])
else:
	print(n - max(evens[0][0] + get_second(odds), get_second(evens) + odds[0][0]))
from decimal import *
import numpy as np
n=input()
ans=list(map(Decimal,input().split()))
ans = np.prod(ans)

if ans>10**18:
  print(-1)
else:
  print(ans)

### FIXED CODE ###

n=input()
A=list(map(int,input().split()))
ans=1
if A.count(0)==0:
  for i in A:
    ans*=i
    if ans>10**18:
      ans=-1
      break
else:
  ans=0
print(ans)
import numpy as np
goukei = 0

N = int(input()) * (-1)
Ai = list(map(int, input().split()))
array_Ai = np.array(Ai)
number = np.array([j for j in range(0, N, -1)])
number_1 = np.array([1 for k in range(-N)])
new_ai = number + array_Ai
new_ai = new_ai - number_1
for i in range(len(Ai)):
    new_ai = new_ai + number_1
    goukei += np.count_nonzero(new_ai == -Ai[i])
print(goukei)

### FIXED CODE ###

import collections
goukei = 0

N = int(input())
Ai = list(map(int, input().split()))
number = [j for j in range(1, N+1, 1)]
plus_Ai = [x + y for (x, y) in zip(Ai, number)]
minus_Ai = [x - y for (y, x) in zip(Ai, number)]
c = collections.Counter(plus_Ai)

for i in minus_Ai:
    goukei += c[i]
print(goukei)
import sys

def add_char(l, string):
    for s in string:
        l.append(s)

n = int(sys.stdin.readline().strip())
common_list = []

for i in range(n):
    s = sys.stdin.readline().strip()
    if i == 0:
        add_char(common_list, s)
    else:
        tmp = []
        add_char(tmp, s)
        for c in common_list:
            if c in tmp:
                tmp.pop(c)
            else:
                common_list.pop(c)
if len(common_list) == 0:
    print("")
else:
    common_list = sorted(common_list)
    s = ""
    for c in common_list:
        s += c
    print(s)


### FIXED CODE ###

import sys

def add_char(l, string):
    for s in string:
        l.append(s)

n = int(sys.stdin.readline().strip())
common_list = []

for i in range(n):
    s = sys.stdin.readline().strip()
    if i == 0:
        add_char(common_list, s)
    else:
        tmp = []
        add_char(tmp, s)
        tmp_c = list(common_list)
        for c in tmp_c:
            if c in tmp:
                tmp.remove(c)
            else:
                common_list.remove(c)
if len(common_list) == 0:
    print("")
else:
    common_list = sorted(common_list)
    s = ""
    for c in common_list:
        s += c
    print(s)
a, b = map(int,input().strip().split(' '))
a_rev = ""
i = 0
j = 0
cnt = 0

#chk = []

for i in range(b - a):
    a+=1
    
    for j in range(len(str(a))):
        a_rev = a_rev + str(a)[len(str(a)) - 1 - j]   

    if str(a_rev) == str(a):
        cnt+=1
        #chk.append(a_rev)   #test
    else:
        pass
    
    a_rev =""
    
print(cnt)
#print(chk)

### FIXED CODE ###

N = 3
c = []
i = 0

for i in range(N):
	c.append(input().strip())

out = ""

for i in range(N):
    out = out + c[i][i]
    
print(out)
n,m,x=map(int,input().split())
s=sum(int(i)<x for i in input().split())
print(min(s,m-s))


### FIXED CODE ###

n,m=map(int,input().split())
S=set(range(1,m+1))
for i in range(n):
    K,*A=map(int,input().split())
    S&=set(A)
print(len(S))
class Node:
    def __init__(self, value):
        self.value = value
        self.next = None
        self.prev = None
 
 


def run():
    n = int(input())
    tail = Node(None)
    node = tail
 
    for _ in range(n):
        command = input()
        if command.startswith('0'):
            nn = Node(int(command[2:]))
            nn.prev, nn.next = node.prev, node
            if node.prev is not None:
                node.prev.nex
't = nn
            node.prev = nn
            node = node.prev
        elif command.startswith('1'):
            i = int(command[2:])
            if i > 0:
                for _ in range(i):
                    node = node.next
            else:
                for _ in range(-i):
                    node = node.prev
        elif command.startswith('2'):
            p, n = node.prev, node.next
            node.prev, node.next = None, None
            node = n
            if p is None:
                n.prev = None
            else:
                n.prev, p.next = p, n
        else:
            raise ValueError('invalid command')
 
    st = []
    node = tail.prev
    while node is not None:
        st.append(node.value)
        node = node.prev
 
    while len(st) > 0:
        print(st.pop())
 
 
if __name__ == '__main__':
    run()


### FIXED CODE ###

class Node:
    def __init__(self, value):
        self.value = value
        self.next = None
        self.prev = None
 
 
def run():
    n = int(input())
    tail = Node(None)
    node = tail
 
    for _ in range(n):
        command = input()
        if command.startswith('0'):
            nn = Node(int(command[2:]))
            nn.prev, nn.next = node.prev, node
            if node.prev is not None:
                node.prev.next = nn
            node.prev = nn
            node = node.prev
        elif command.startswith('1'):
            i = int(command[2:])
            if i > 0:
                for _ in range(i):
                    node = node.next
            else:
                for _ in range(-i):
                    node = node.prev
        elif command.startswith('2'):
            p, n = node.prev, node.next
            node.prev, node.next = None, None
            node = n
            if p is None:
                n.prev = None
            else:
                n.prev, p.next = p, n
        else:
            raise ValueError('invalid command')
 
    st = []
    node = tail.prev
    while node is not None:
        st.append(node.value)
        node = node.prev
 
    while len(st) > 0:
        print(st.pop())
 
 
if __name__ == '__main__':
    run()