Harryxun/stf_run huggingface dataset:
a,b,c = map(int,input().split())

if b − a == c − b:
  print('YES')

else:
  print('NO')

### FIXED CODE ###

a,b,c = map(int,input().split())
 
if (b-a) == (c-b):
  print('YES')
else:
  print('NO')
N,A,B = map(int,input.split())
ans = 0
if (B-A)%2 == 0:
    print(int((B-A)//2))
else:
    print(min(A-1,N-B)+1+int((B-A-1)//2))

### FIXED CODE ###

N,A,B = map(int,input().split())
ans = 0
if (B-A)%2 == 0:
    print(int((B-A)//2))
else:
    print(min(A-1,N-B)+1+int((B-A-1)//2))
import sys
n,m=map(int,input().split())
l=[-1]*(n)
for i in range(m):
    s,c=map(int,input().split())
    if l[s-1]==-1 or l[s-1]==c:
        l[s-1]=c
    else:
        print(-1)
        sys.exit()
if l[0]==0 and len(l)!=1:
    print(-1)
    sys.exit()
for i in range(n):
    if l[i]==-1:
        l[i]=0
if l[0]==0:
    l[0]=0

if l[0]==0 and len[l]==1:
    print(0)
else:
    for i in range(n):
        print(l[i],end="")

### FIXED CODE ###

import sys
n,m=map(int,input().split())
l=[-1]*(n)
for i in range(m):
    s,c=map(int,input().split())
    if l[s-1]==-1 or l[s-1]==c:
        l[s-1]=c
    else:
        print(-1)
        sys.exit()
if l[0]==0 and len(l)!=1:
    print(-1)
    sys.exit()
for i in range(n):
    if l[i]==-1:
        l[i]=0
if l[0]==0 and len(l)!=1:
    l[0]=1

if l[0]==0 and len(l)==1:
    print(0)
else:
    for i in range(n):
        print(l[i],end="")
n,k = map(int , input().split( ))
p = list(map(int , input()).split( ))
 
p.sort()
 
temp = 0
for i in p[:k] :
  temp += i
print(temp)

### FIXED CODE ###

n,k = map(int , input().split( ))
p = list(map(int , input().split( )))
 
p.sort()
 
temp = 0
for i in p[:k] :
  temp += i
print(temp)
a,b,c=map(int(),split())
print "YES" if a.last() == b.first() && b.last() == c.first() else "NO"

### FIXED CODE ###

a,b,c=input().split()
print("YES" if a[-1] == b[0] and b[-1] == c[0] else "NO")
from math import ceil, log2
n=int(input())
a=list(map(int,input().split()))
b=[0]*64
for i in range(n):
    for j in range(ceil(log2(a[i]))):
        if a[i]>>j & 1: b[j]+=1
c=0
for i in range(64):
    c+=b[i]*(n-b[i])*2**i
print(c%(10**9+7))


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[0]*64
for i in range(n):
    for j in range(a[i].bit_length()):
        if a[i]>>j & 1: b[j]+=1
c=0
for i in range(64):
    c+=(b[i]*(n-b[i])*2**i) % 1000000007
print(c%1000000007)
def dfs(a, b, c, k)
  
  if k == N
    nil if [a, b, c].min == 0
    return (A-a).abs + (B-b).abs + (C-c).abs - 10 * 3
  end
  
  x = dfs(a+L[k], b, c, k+1) + 10
  y = dfs(a, b+L[k], c, k+1) + 10
  z = dfs(a, b, c+L[k], k+1) + 10
  w = dfs(a, b, c, k+1)
  
  [x, y, z, w].compact.min
end

N, A, B, C = gets.split.map(&:to_i)

L = Array.new(N)
N.times{ |i| L[i] = gets.to_i }

p dfs(0, 0, 0, 0)


### FIXED CODE ###

# 解説コード
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)
print(dfs(0, 0, 0, 0))
a = list(map(input().split()))
if abs(a[2]- a[0]) <= a[3]:
  print("Yes")
elif abs(a[0] - a[1]) <= a[3] and abs(a[1] - a[2]) <= a[3]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a = list(map(int,input().split()))
if abs(a[2] - a[0]) <= a[3]:
  print("Yes")
elif abs(a[0] - a[1]) <= a[3] and abs(a[1] - a[2]) <= a[3]:
  print("Yes")
else:
  print("No")
N = imput()
a = round(N/2)/N
print(a)

### FIXED CODE ###

import math
N = int(input())
a = math.ceil(N/2)/N
print(a)
N = int(input())
X = input()

N_ub = 2 * 10 ** 5
f = [-1] * (N_ub)
f[0] = 0
for n in range(1, N_ub):
    pc = format(n, "b").count("1")
    f[n] = f[n % pc] + 1

X_pc = X.count("1")
X_res_m1 = 0
X_res_p1 = 0
for i, s in enumerate(reversed(X)):
    if s == "1":
        X_res_m1 += pow(2, i, X_pc - 1)
        X_res_m1 %= X_pc - 1

        X_res_p1 += pow(2, i, X_pc + 1)
        X_res_p1 %= X_pc + 1

ans = []
for i, s in enumerate(reversed(X)):
    if s == "1":
        fx = (X_res_m1 - pow(2, i, X_pc - 1)) % (X_pc - 1)
        ans.append(f[fx] + 1)
    else:
        fx = (X_res_p1 + pow(2, i, X_pc + 1)) % (X_pc + 1)
        ans.append(f[fx] + 1)

print(*reversed(ans), sep="\n")


### FIXED CODE ###

N = int(input())
X = input()

X_pc = X.count("1")
X_res_m1 = 0
X_res_p1 = 0
for i, s in enumerate(reversed(X)):
    if s == "1":
        if X_pc > 1:
            X_res_m1 += pow(2, i, X_pc - 1)
            X_res_m1 %= X_pc - 1

        X_res_p1 += pow(2, i, X_pc + 1)
        X_res_p1 %= X_pc + 1

f = [-1] * (X_pc + 1)
f[0] = 0
for n in range(1, X_pc + 1):
    pc = format(n, "b").count("1")
    f[n] = f[n % pc] + 1

ans = []
for i, s in enumerate(reversed(X)):
    if s == "1":
        if X_pc > 1:
            fx = (X_res_m1 - pow(2, i, X_pc - 1)) % (X_pc - 1)
            ans.append(f[fx] + 1)
        else:
            ans.append(0)

    else:
        fx = (X_res_p1 + pow(2, i, X_pc + 1)) % (X_pc + 1)
        ans.append(f[fx] + 1)

print(*reversed(ans), sep="\n")
def resolve():
    '''
    code here
    '''
    import sys
    N = int(input())
    S = sys.stdin.readlines().strip()

    set_S = set([item for item in S])
    res = 1

    for s in set_S:
        cnt = 1
        for letter in S:
            if s == letter:
                cnt += 1
        res *= cnt

    print(res-1)

if __name__ == "__main__":
    resolve()


### FIXED CODE ###

def resolve():
    '''
    code here
    '''
    import sys
    N = int(input())
    S = sys.stdin.readline().strip()
    mod = pow(10, 9) + 7
    set_S = set([item for item in S])
    res = 1

    for s in set_S:
        cnt = 1
        for letter in S:
            if s == letter:
                cnt += 1
        res *= cnt
        res %= mod

    mod = pow(10, 9) + 7
    print(res-1)

if __name__ == "__main__":
    resolve()
n = int(input())
s = [input() for _ in range(n)]
d = {}
for w in s:
    if w not in d:
        d[w] = 0
    d[w] += 1
d2 = sorted(d.items(), key=lambda x:x[1], reverse=True)
maxcnts = [w[0] for w in d2 if w[1] == d2[1]]
maxcnts.sort()
for ans in maxcnts:
    print(ans)

### FIXED CODE ###

l=list(input().split())
if len(set(l))==2:
    print("Yes")
else:
    print("No")
N,W = map(int,input().split())
wv = list(list(map(int,input().split()))for i in range(N))
dp = [[0]*(W+1) for i in range(N+1)]

for i in range(N):
    w,v = wv[i]
    for j in range(1,W+1):
        if w > j:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j],dp[i][j-w]+v)
print(dp[-1][-1])

### FIXED CODE ###

N,W = map(int,input().split())
w1,v = map(int,input().split())
wv = [[v],[],[],[]]
for i in range(N-1):
    w,v = map(int,input().split())
    wv[w-w1].append(v)
for i in range(4):
    wv[i]=[0] + sorted(wv[i],reverse=True)
# 累積和
for i in range(4):
    for j in range(1,len(wv[i])):
        wv[i][j] += wv[i][j-1]
ans = 0
hoge = [0,0,0,0]
for i in range(len(wv[0])):
    hoge[0] = wv[0][i]
    for j in range(len(wv[1])):
        hoge[1] = wv[1][j]
        for k in range(len(wv[2])):
            hoge[2] = wv[2][k]
            for l in range(len(wv[3])):
                hoge[3] = wv[3][l]
                if w1*(i+j+k+l)+j+2*k+3*l > W:
                    break
                else:
                    ans = max(ans,sum(hoge))
print(ans)
list(n,x,y) = map(int,input().split(" "))
print(min(x,y),x+y-n)

### FIXED CODE ###

n,x,y = map(int,input().split())
r = x+y-n
if r < 0:
  r = 0
print(min(x,y),r)
A,B,C,X = map(int, input().split())

cnt = 0
for i in range(A):
        for j in range(B):
                for k in range(C):
                        if 500*A + 100*B + 50*C == X:
                            cnt += 1
                        else:
                            cnt += 0
print(cnt)

### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for i in range(0, A+1):
        for j in range(0, B+1):
                for k in range(0, C+1):
                        if int(500*i + 100*j + 50*k) == X:
                            cnt += 1
                     
print(cnt)
n,k = map(int,input().split())
a = [0]+list(map(int,input().split()))
b = [1]
c = a[1]
d = 0
length = 0
first = 0
ans = 0

while c not in b:
    b += [c]
    c = a[c]
    d = c

length = len(b)-b.index(d)
first = b.index(d)
if k <= first:
    ans = b[k]
elif length == 0:
    ans = 1
else:
    ans = b[(k-first)%length+first]
print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
t = [0 for i in range(n+1)]
b = [1]
c = a[1]
d = 0
e=1
length = 0
first = 0
ans = 0


while t[d] < 1:
    t[d]=e
    b += [c]
    c = a[c]
    d = c
    e+=1

if d != 0:
    length = e - t[d]
    first = b.index(d)
if k <= first:
    ans = b[k]
elif d == 0:
    ans = 1
else:
    ans = b[(k - first) % length + first]
print(ans)
N, K = map(int, input().split())
A = list( map(int, input().split()) ) #ここでN個受け取る

var = [0] * N+1


for i in A:
    var[i] += 1
    
var = sorted(var,  reverse = True )


count = 0
for j in range( K, N+1 ):
    if var[j] == 0:
        break
    
    if var[j] != 0:
        count += var[j]
        
print(count)

### FIXED CODE ###

N, K = map(int, input().split())
A = list( map(int, input().split()) ) #ここでN個受け取る

var = [0] * (N+1)


for i in A:
    var[i] += 1
    
var = sorted(var,  reverse = True )


count = 0
for j in range( K, N+1 ):
    if var[j] == 0:
        break
    
    if var[j] != 0:
        count += var[j]
        
print(count)
import sys
from itertools import permutations
 
def read_int_list():
    return list(map(int, input().split()))
 
 
def main():
    def floyd_warshall():
        for k in range(n):
            for i in range(n):
                for j in range(n):
                    dd = d[i][k] + d[k][j]
                    if dd < d[i][j]:
                        d[i][j] = dd
 
    n, m, r = read_int_list()
    v = read_int_list()
    v = [x - 1 for x in v]
    d = [[float('inf')] * n for i in range(n)]
    for i in range(n):
        d[i][i] = 0
    for i in range(m):
        a, b, c = read_int_list()
        a -= 1
        b -= 1
        d[a][b] = c
        d[b][a] = c
    floyd_warshall()
    res = float('inf')
    for p in permutations(v):
        s = 0
        for i in range(r - 1):
            s += d[p[i]][p[i + 1]]
        if s < res:
            res = s
    print(res)
 
 
main()

### FIXED CODE ###

N = str(input())

if '9' in N:
	print('Yes')
else:
	print('No')
a = input()
a = a.replace(a[0], "")
a = a.replace(a[0], "")
if len(a) == 0:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

a = input()
a = a.replace(a[0], "")
if len(a) == 0:
    print("No")
    exit()
a = a.replace(a[0], "")
if len(a) == 0:
    print("Yes")
else:
    print("No")
S = input()
n = len(S)
flag = 0
for i in range(0,n):
  if i%2==0:
  	if !(S[1]=='L' || S[1]=='U' || S[1]=='D')
    	flag = 1
  else:
    if !(S[1]=='R' || S[1]=='U' || S[1]=='D')
    	flag = 1
      
if flag==1:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

S=input()
flag = 0
for i in range(0,len(S)):
  if (i+1)%2==0 and not (S[i]=='L' or S[i]=='U' or S[i]=='D'):
    flag = 1
  elif (i+1)%2!=0 and not (S[i]=='R' or S[i]=='U' or S[i]=='D'):
    flag = 1
    
if flag==1:
  print("No")
else:
  print("Yes")
from collections import defaultdict as f
n,s=map(int,input().split())
k=f(int)
k[0]=0
g=0
for i in range(n):
    w,v=map(int,input().split())
    c=list(k)
    for i in range(len(c)-1,-1,-1):
        if c[k[i]+v]!=0:
            c[k[i]+v]=min(c[k[i]]+w,c[k[i]+v])
        else:
            c[k[i]+v]=c[k[i]]+w
        if c[k[i]+v]<=s:
            g=max(g,k[i]+v)
print(g)              

### FIXED CODE ###

import numpy as np
n,a=map(int,input().split())
s=np.full(n*1000+1,a+1)
s[0]=0
for i in range(n):
    w,v=map(int,input().split())
    s[v:]=np.minimum(s[v:],s[:-v]+w)
print(np.max(np.where(s<=a)))
def solve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    
    for i in range(K):
        
        arr = [0] * (N + 1)

        for ind,j in enumerate(A):
            arr[max(ind-j,0)] += 1
            arr[min(ind+j+1, N)] -= 1

        A[0] = arr[0]
        for k in range(N-1):
            A[k+1] = A[k] + arr[k+1]

        if arr[0] ==N and arr[-1] == -N:
            return A
    return A


if __name__ == "__main__":
    ans = solve()
    print(*ans)



### FIXED CODE ###

def solve():
    S = input()
    print(S[:3])


if __name__ == "__main__":
    solve()
import sys
n = int(sys.stdin.readline().strip('\n'))
h = list(map(int, sys.stdin.readline().strip('\n').split()))
inf = float('inf')
dp = [inf for _ in range(n)]
# メモ化再帰（一度計算した結果はメモしておく）
def rec(i):
  # 値が既に更新されていたらそのまま返す（計算し直さない）
  if dp[i] < inf: return dp[i]
  if i==0: return 0
  res = inf
  res = min(res, rec(i-1) + abs(h[i]-h[i-1]))
  if i>1: res = min(res, rec(i-2) + abs(h[i]-h[i-2]))
  dp[i] = res
  return res
ans = rec (n-1)
print(ans)

### FIXED CODE ###

import sys
n = int(sys.stdin.readline().strip('\n'))
h = list(map(int, sys.stdin.readline().strip('\n').split()))
dp = [float('inf') for _ in range(n)]
dp[0] = 0
dp[1] = abs(h[0]-h[1])
for i in range(2, n):
  dp[i] = min(dp[i-1] + abs(h[i-1]-h[i]), 
             dp[i-2] + abs(h[i-2]-h[i]))
print(dp[n-1])
x,y = map(int,input().split())
z = int(str(x)+str(y))
for i in range(int(z**0.5)):
  if i**2 = z:
    ans = "Yes"
  else:
    ans = "No"
print(ans)

### FIXED CODE ###

a,b=map(int,input().split())
c=int(str(a)+str(b))
for i in range(int(c**(1/2))+1) :
  if i**2==c :
    print("Yes")
    exit()
print("No")
import numpy as np

N = int(input())

A = []
for i in range(N):
    num = float(input()) * 10000
    if float.is_integer(num):
        A.append(int(num))


def count2(n):
    ret = 0
    while(n % 2 == 0):
        ret += 1
        n /= 2
    return ret


def count5(n):
    ret = 0
    while(n % 5 == 0):
        ret += 1
        n /= 5
    return ret


table = {}
for i in range(9):
    for j in range(9):
        table[i, j] = 0

for a in A:
    c2 = count2(a)
    c5 = count5(a)
    if(c2 > 8):
        c2 = 8
    if(c5 > 8):
        c5 = 8
    for i in range(c2 + 1):
        for j in range(c5 + 1):
            table[i, j] += 1

res = 0
for a in A:
    pair = count2(a), count5(a)
    t, f = pair
    res += table[8 - t, 8 - f]
    if t >= 4 and f >= 4:
        res -= 1

print(res // 2)


### FIXED CODE ###

import numpy as np

N = int(input())

A = []
for i in range(N):
    num = float(input()) * 10 ** 9 + 0.5
    A.append(int(num))


def count2(n):
    ret = 0
    while(n % 2 == 0):
        ret += 1
        n /= 2
    return ret


def count5(n):
    ret = 0
    while(n % 5 == 0):
        ret += 1
        n /= 5
    return ret


table = {}
for i in range(19):
    for j in range(19):
        table[i, j] = 0

for a in A:
    c2 = count2(a)
    c5 = count5(a)
    if(c2 > 18):
        c2 = 18
    if(c5 > 18):
        c5 = 18
    table[c2, c5] += 1

res = 0
for i in range(19):
    for j in range(19):
        for k in range(19):
            for l in range(19):
                if i + k >= 18 and j + l >= 18:
                    if i == k and j == l:
                        res += table[i, j] * (table[i, j] - 1)
                    else:
                        res += table[i, j] * table[k, l]

print(res // 2)
import math
x = int(input())

def f(x,b):
    return math.floor((x+b**5)**(1/5))

b=0
plus=1
while True:
    ans = f(x,b)
    print(ans)
    if ans**5-b**5 == x:
        print(ans, b)
        break
    elif plus == 1:
        b=b*(-1)
        plus = 0
    elif plus == 0:
        b=b*(-1)
        b+=1
        plus = 1

### FIXED CODE ###

def solve():
   x = int(input())
   for a in range(-500,500):
      for b in range(-500,500):
         n = a**5 - b**5
         if n == x:
            print(a,end=" ")
            print(b)
            return
solve()
s = input()
x, y = map(int, input().split())
y = abs(y)

lx, ly = [], []
flag = True
n = 0
s += 'T'
for i in s:
    if i == 'F':
        n += 1
    else:
        if n > 0:
            if flag:
                lx.append(n)
            else:
                ly.append(n)
            n = 0
        flag = not flag

if x != []:
    x = abs(x - lx.pop(0))

lx.sort()
ly.sort()
sx = sum(lx)
sy = sum(ly)

if sx < x or (sx - x) % 2 == 1 or sy < y or (sy - y) % 2 == 1:
    print('No')
    exit()


def main(x, sx, lx):
    if x == sx:
        return True

    goal = (sx - x) // 2
    # return (sum of some lx == goal)
    dp = [False] * (goal + 1)
    dp[0] = True
    for i in lx:
        if i > goal:
            return False
        for j in range(goal - i, -1, -1):
            if dp[j]:
                dp[j+i] = True
        if dp[goal]:
            return True
    return False


if main(x, sx, lx) and main(y, sy, ly):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

s = input()
x, y = map(int, input().split())
y = abs(y)

f = s.find('T')
if f >= 0:
    x = abs(x - f)
    s = s[f:]
else:
    if x == len(s) and y == 0:
        print('Yes')
    else:
        print('No')
    exit()

lx, ly = [], []
flag = True
n = 0
s += 'T'
for i in s:
    if i == 'F':
        n += 1
    else:
        if n > 0:
            if flag:
                lx.append(n)
            else:
                ly.append(n)
            n = 0
        flag = not flag

lx.sort()
ly.sort()
sx = sum(lx)
sy = sum(ly)

if sx < x or (sx - x) % 2 == 1 or sy < y or (sy - y) % 2 == 1:
    print('No')
    exit()


def main(x, sx, lx):
    if x == sx:
        return True

    goal = (sx - x) // 2
    # return (sum of some lx == goal)
    dp = [False] * (goal + 1)
    dp[0] = True
    for i in lx:
        if i > goal:
            return False
        for j in range(goal - i, -1, -1):
            if dp[j]:
                dp[j+i] = True
        if dp[goal]:
            return True
    return False


if main(x, sx, lx) and main(y, sy, ly):
    print('Yes')
else:
    print('No')
N,K=map(int,input().split())
l=[x for x in range(1,N+1)]
S=set(l)
m=int(input())
B=set((map(int,input().strip().split())))
se=list(S-B)
for i in range(1,K):
	d=int(input())
	A=list(map(int,input().strip().split()))
	for i in range(len(A)):
		if A[i] in se:
			del se[A[i]]
print(len(se))

### FIXED CODE ###

N,K=map(int,input().split())
l=[x for x in range(1,N+1)]
for i in range(K):
	d=int(input())
	A=list(map(int,input().strip().split()))
	for j in range(len(A)):
		if A[j] in l:
			l.remove(A[j])
print(len(l))
b=input()

if(b="A"):
    print("T")
else:
    print("G")


### FIXED CODE ###

b=input()

if(b=="A"):
    print("T")
elif(b=="T"):
    print("A")
elif(b=="G"):
    print("C")
else:
    print("G")
N,M=int(input().split())
l=list(map(int,input().split()))
limit=sum(l)/(M*3)
num=0
for i in l:
  if i >= limit:
    num+=0
if num >=M:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N,M=map(int,input().split())
l=list(map(int,input().split()))
limit=sum(l)/(M*4)
num=0
for i in l:
  if i >= limit:
    num+=1
if num >=M:
  print("Yes")
else:
  print("No")
n,a,b = map(int, input().split())
print(min([a*n,b])

### FIXED CODE ###

n, a, b = map(int, input().split())
print(min([n*a,b]))
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

d = [0] * (max(A) + 1)
d = {i: 0 for i in range(1, max(A)+1)}
d = defaultdict(int)


def prime_factorization(n):  # 素因数分解
    res = []
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            cnt = 0
            while n % i == 0:
                cnt += 1
                n //= i
            res.append((i, cnt))
    if n > 1:
        res.append((n, 1))
    return res


for a in A:
    for i in range(2, int(a ** 0.5) + 1):
        if a % i == 0:
            cnt = 0
            while a % i == 0:
                cnt += 1
                a //= i
            d[i] = max(d[i], cnt)
    if a != 1:
        d[a] = 1

ans = 0
for a in A:
    tmpD = d.copy()
    pf = prime_factorization(a)
    for k, v in pf:
        tmpD[k] -= v
    b = 1
    for k, v in tmpD.items():
        if v == 0:
            continue
        b *= pow(k, v, mod)
        v %= mod
    ans += b
    ans %= mod

print(ans % mod)


### FIXED CODE ###

from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

d = defaultdict(int)


def prime_factorization(n):  # 素因数分解
    res = []
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            cnt = 0
            while n % i == 0:
                cnt += 1
                n //= i
            res.append((i, cnt))
    if n > 1:
        res.append((n, 1))
    return res


for a in A:
    for i in range(2, int(a ** 0.5) + 1):
        if a % i == 0:
            cnt = 0
            while a % i == 0:
                cnt += 1
                a //= i
            d[i] = max(d[i], cnt)
    if a != 1:
        d[a] = max(d[a], 1)

ans = 0
lcm = 1
for k, v in d.items():
    lcm *= pow(k, v, mod)
    lcm %= mod

for a in A:
    if a == 1:
        ans += lcm
        continue
    l = lcm*pow(a, mod-2, mod)
    ans += l
    ans %= mod

print(ans % mod)
#!/usr/bin/env python3
# atcoder 
# Türkçe konuşyorum
# Türkler var mı
# memnün oldum

K = int(input())
S = input()


slen = len(S)
if(slen < K):
    print(S)
else: 
    pr = S[:K]
    change = S[K:K+3]
    for i in range(3):
        change = change.replace(change[i], ".")
    print(pr + change)



### FIXED CODE ###

#!/usr/bin/env python3
# atcoder 
# Türkçe konuşyorum
# Türkler var mı
# memnün oldum

K = int(input())
S = input()



if(len(S) <= K):
    print(S)
else:
    print(S[:K] + '.' * 3)
    #for i in range(3):
    #    change = change.replace(change[i], '.')
    #print(S[:K] + change[:3])
N,M=map(int,input().split())
shop=[]
for _ in range(N):
    a=list(map(int,input().split()))
    shop.append(a)
shop.sort(key=lambda x: x[0])
cnt=0
p=0
i=0

while cnt<=M:
    a=shop[i][0]
    b=shop[i][1]
    cnt+=b
    p+=a*b
    i+=1
su=cnt-M

a = shop[i-1][0]
p-=a*su
print(p)


### FIXED CODE ###

N,M=map(int,input().split())
shop=[]
for _ in range(N):
    a=list(map(int,input().split()))
    shop.append(a)
shop.sort(key=lambda x: x[0])
cnt=0
p=0
i=0

while cnt<M:
    a=shop[i][0]
    b=shop[i][1]
    cnt+=b
    p+=a*b
    i+=1
su=cnt-M

a = shop[i-1][0]
p-=a*su
print(p)
# -*- coding: utf-8 -*-
a = int(input())
b = int(input())
h = int(input())
return (a + b) * h / 2

### FIXED CODE ###

# -*- coding: utf-8 -*-
a = int(input())
b = int(input())
h = int(input())
print(int((a + b) * h / 2))
H,W = buf.split()
H = int(H)
W = int(W)
pic = []
 
for i in range(H):
    pic.append(input())
 
#for row in pic:
#    print(row)
 
for i in range(W+2):
    print("#",end="")
print()
 
for i in range(H):
    print("#"+pic[i]+"#")
 
for i in range(W+2):
    print("#",end="")

### FIXED CODE ###

lis = [0,1,3,1,2,1,2,1,1,2,1,2,1]

x,y = (int(i) for i in input().split())

if lis[x] == lis[y] :
    print("Yes")
else:
    print("No")
s = input()
Q = int(input())
query = [input().split() for _ in range(Q)]

cnt = 0
for q in query:
    if q[0] == '1':
        cnt += 1
    else:
        reverse = cnt % 2
        if q[1] == '1':
            if reverse == 0:
                s = q[2] + s
            else:
                s = s + q[2]
        else:
            if reverse == 0:
                s = s + q[2]
            else:
                s = q[2] + s
    print(s)
if cnt % 2 == 0:
    print(s)
else:
    print(s[::-1])


### FIXED CODE ###

from collections import deque
s = input()
Q = int(input())
que = deque(s)
cnt = 0
for i in range(Q):
    q = input().split()
    if q[0] == '1':
        cnt += 1
    else:
        reverse = cnt % 2
        if q[1] == '1':
            if reverse == 0:
                s = que.appendleft(q[2])
            else:
                s = que.append(q[2])
        else:
            if reverse == 0:
                s = que.append(q[2])
            else:
                s = que.appendleft(q[2])

ans = ''.join(que)
if cnt % 2 == 0:
    print(ans)
else:
    print(ans[::-1])