Harryxun/stf_run huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << endl
#define print10(ele) cout << fixed << setprecision(10) << (ele) << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  REP(i, 4) {
    if (s[i] == '+')
      ans++;
    else
      ans--;
  }
  print(ans);
  return 0;
}

### FIXED CODE ###

s = input()

ans = 0

for i in range(4):
    if s[i] == '+':
        ans += 1
    else:
        ans -= 1

print(ans)
import sys
input = lambda: sys.stdin.readline().rstrip()

n= int(input())
a=list(input())

v=a.count('1')

ans=[0]*n
A=[0]*n
# n以下の残り回数を記録
for i in range(v+1):
    x=i
    cnt=0
    while x>0:
        cnt+=1
        r = 0
        for j in range(19):
            if (x>>j)&1:
                r+=1
            if x>>j==0:
                break
        x=x%r
    ans[i]=cnt

# 各桁をv＋１で割ったあまり
q = [0]*n
# 各桁をv-1で割ったあまり
r = [0]*n
for i in range(n):
    if a[i]=='1':
        if v!=0:
            q[i] = pow(2, n-i-1) % (v + 1)
        if v!=1:
            r[i] += pow(2, n-i-1) % (v - 1)
qq=sum(q)%(v+1)
rr=sum(r)%(v-1)

for i in range(n):
    if a[i]=='1':
        if v!=1:
            z = rr - pow(2,n-i-1)%(v-1)
            cnt = z % (v - 1)
            A[i] = 1 + ans[cnt]
    else:
        z=qq+pow(2,n-i-1)%(v+1)
        cnt=z%(v+1)
        A[i]=1+ans[cnt]

for i in A:
    print(i)

### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip()

n= int(input())
a=list(input())

v=a.count('1')

ans=[0]*n
A=[0]*n
# n以下の残り回数を記録
for i in range(n):
    x=i
    cnt=0
    while x>0:
        cnt+=1
        r = 0
        for j in range(19):
            if (x>>j)&1:
                r+=1
            if x>>j==0:
                break
        x=x%r
    ans[i]=cnt

# 各桁をv＋１で割ったあまり
q = [0]*n
# 各桁をv-1で割ったあまり
r = [0]*n
for i in range(n):
    if a[i]=='1':
        if v!=0:
            q[i] = pow(2, n-i-1,v+1) 
        if v!=1:
            r[i] += pow(2, n-i-1,v-1) 
qq=sum(q)
rr=sum(r)

for i in range(n):
    if a[i]=='1':
        if v!=1:
            z = rr - pow(2,n-i-1,v-1)
            cnt = z % (v - 1)
            A[i] = 1 + ans[cnt]
    else:
        z=qq+pow(2,n-i-1,v+1)
        cnt=z%(v+1)
        A[i]=1+ans[cnt]

for i in A:
    print(i)
n,h=map(int,input().split())
a=[0]*n
b=[0]*n
for i in range(n):
   a[i],b[i]=map(int,input().split()) 
x=max((a))
y=[i for i in b if i>x]
y.sort(reverse=True)
count=0
for i in range(len(y)):
    if h>0:
        count+=1
        h-=y[i]
    else:
        break

if h>0:
     count +=int(h//x)+1
print(count)

### FIXED CODE ###

s=list(str(input()))
s[3]=str(int(s[3])+1)
print("".join(s))
import heapq
def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappop_max(heap):
    lastelt = heap.pop()    
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt

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

heapq._heapify_max(price)

for i in range(M):
    a = heapq._heappop_max(price)
    a //= 2
    _heappush_max(price, a)

print(sum(price))

### FIXED CODE ###

import heapq

def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
    
def _heappop_max(heap):
    lastelt = heap.pop()    
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt

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

heapq._heapify_max(p)

for i in range(M):
    a = _heappop_max(p)
    a //= 2
    _heappush_max(p, a)

print(sum(p))
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 18 17:04:29 2017

@author: goto
"""

moji=map(int, input().split())

t=moji[0]*moji[1]
if t<moji[2]:
    minmoji=t
else:
    minmoji=moji[2]
    

print(minmoji)    



### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 18 17:04:29 2017

@author: goto
"""

int1,int2,int3=map(int, input().split())

t=int1*int2

if t<int3:
    minmoji=t
else:
    minmoji=int3
    

print(minmoji)
S = input()
K = int(input())
for i, s in enumerate(S):
  if s != '1':
    c = i + 1
    break
if K < c:
  print(1)
else:
  print(S[c - 1])

### FIXED CODE ###

S = input()
K = int(input())
c = 0
for i, s in enumerate(S):
  if s != '1':
    c = i + 1
    break
  
if K < c:
  print(1)
else:
  print(S[c - 1])
N=int(input())
A=[int(input()) for _ in range(N)]

ans=0
for i in range(N):
  if A[i]==0:
    idx.append(i+1)
n=0
idx.append(N)
for iidx in idx:
  ans+=sum(A[n:iidx])//2
  n=iidx
print(ans)

### FIXED CODE ###

N=int(input())
A=[int(input()) for _ in range(N)]

ans=0
idx=[]
for i in range(N):
  if A[i]==0:
    idx.append(i+1)
n=0
idx.append(N)
for iidx in idx:
  ans+=sum(A[n:iidx])//2
  n=iidx
print(ans)
a, b, c, x = map(int, [input() for i in range(4)])
count = 0
for i in a:
    for j in b:
        for k in c:
            if 500*i + 100*j + 50*k == x:
                count += 1
print(count)

### FIXED CODE ###

a, b, c, x = map(int, [input() for i in range(4)])
count = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                count += 1
print(count)
a,b,c = map(int, input().split())
print('Yes' ifa<=c<=b else 'No')

### FIXED CODE ###

a,b,c = map(int, input().split())
print('Yes' if a<=c<=b else 'No')
N=int(input())
X=[]
U=[]
for i in range(N):
    x,u=input().split()
    X.append(int(x))
    U.append(u)
    if u=='BTC':
        X[i]=380000*x
print(sum(X))

### FIXED CODE ###

N=int(input())
X=[]
U=[]
for i in range(N):
    x,u=input().split()
    X.append(float(x))
    U.append(u)
    if U[i]=='BTC':
        X[i]=380000*X[i]
print(sum(X))
# -*- coding: utf-8 -*-
# abc127/abc127_d
import sys
from itertools import chain

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, M = i2nn()
    A = i2nn()
    A.sort()
    for j in range(M):
        B, C = i2nn()
        if A[0] < C:
            for k in range(B):
                A[k] = C
                if A[k + 1] >= C:
                    break
        A.sort()
    print(sum(A))
    return

main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
# abc127/abc127_d
import sys
from operator import itemgetter

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

      


def main():
    N, M = i2nn()
    A = [(1, x) for x in i2nn()]
    S = [0] * M
    for j in range(M):
        S[j] = tuple(i2nn())
    S.extend(A)
    R = sorted(S, key=itemgetter(1))
    sum = 0
    while True:
        p = R.pop()
        if N - p[0] > 0:
            sum += p[0] * p[1]
            N -= p[0]
        else:
            sum += p[1] * N
            break
    print(sum)
    return

main()
h,w = map(int,input().split())
li,li2,li3 = [],[],[]
for i in range(h):
    li.append(list(input()))
li = [x for x in li if "#"  in x]

for i in range(w):
    li2.append([])
    for j in range(len(li)):
        li2[-1].append(li[j][i])
li2 = [x for x in li2 if "#"  in x]
for i in range(len(li2)):
    li3.append([])
    for j in range(len(li2[i])):
        li3[-1].append(li2[j][i])
for i in range(len(li3)):
    print("".join(li3[i]))

### FIXED CODE ###

h,w = map(int,input().split())
li,li2 = [],[]
for i in range(h):
    a = list(input())
    if "#" in a:
        li.append(a)
for i in range(len(li)):
    for j in range(w):
        if li[i][j] == ".":
            li[i][j] = 0
        elif li[i][j] == "#":
            li[i][j] = 1

li = list(zip(*li))
for i in range(len(li)):
    if 1 in li[i]:
        li2.append(li[i])
li2 = list(zip(*li2))
for i in range(len(li2)):
    li2[i] = list(li2[i])
for i in range(len(li2)):
    for j in range(len(li2[i])):
        if li2[i][j] == 0:
            li2[i][j] = "."
        elif li2[i][j] == 1:
            li2[i][j] = "#"
for i in range(len(li2)):
    print("".join(li2[i]))
#残り1種類のグループとそうでないグループに分けておく，残り1種類になったら移動
#判定のため，各tごとにdのリスト（ソート済み）と，dのリストを参照する番号を持っておく

import heapq

N,K=map(int,input().split())
dt=[[0,0] for _ in range(N)]
gr=[[] for _ in range(N+1)]#tの種類ごとにまとめる
x=0#種類数
ans=0#先に全部食べたことにして，いらないものを除く

for i in range(N):
    dt[i][1],dt[i][0]=map(int,input().split())
    dt[i][1]-=1
    ans+=dt[i][0]
    if gr[dt[i][1]]==[]:
        x+=1
    gr[dt[i][1]].append(dt[i])
ans+=x*x

single=[]
multi=[]
heapq.heapify(single)
heapq.heapify(multi)

num_i=[0]*N#各tに対してどこを見るか

for i in range(N):
    gr[i].sort()
    if gr[i]!=[]:
        if len(gr[i])==1:
            heapq.heappush(single,gr[i][0])
        else:
            heapq.heappush(multi,gr[i][0])
    
inf=10**19
heapq.heappush(single,[inf,N])#絶対に選ばないものを入れておく
heapq.heappush(multi,[inf,N])
    
    
    
for i in range(N-K):
    a=heapq.heappop(single)
    b=heapq.heappop(multi)
    if a[0]+(2*x-1)<=b[0]:#種類ボーナスも含めて小さい方を取り除く
        ans-=a[0]+(2*x-1)
        x-=1
        heapq.heappush(multi,b)
    else:
        ans-=b[0]
        heapq.heappush(single,a)
        tt=b[1]
        num_i[tt]+=1
        if num_i[tt]==len(gr[tt])-1:
            heapq.heappush(single,gr[tt][-1])
        else:
            heapq.heappush(multi,gr[tt][num_i[tt]])
                                       
print(ans)a

    

### FIXED CODE ###

#残り1種類のグループとそうでないグループに分けておく，残り1種類になったら移動
#判定のため，各tごとにdのリスト（ソート済み）と，dのリストを参照する番号を持っておく

import heapq

N,K=map(int,input().split())
dt=[[0,0] for _ in range(N)]
gr=[[] for _ in range(N+1)]#tの種類ごとにまとめる
x=0#種類数
ans=0#先に全部食べたことにして，いらないものを除く

for i in range(N):
    dt[i][1],dt[i][0]=map(int,input().split())
    dt[i][1]-=1
    ans+=dt[i][0]
    if gr[dt[i][1]]==[]:
        x+=1
    gr[dt[i][1]].append(dt[i])
ans+=x*x

single=[]
multi=[]
heapq.heapify(single)
heapq.heapify(multi)

num_i=[0]*N#各tに対してどこを見るか

for i in range(N):
    gr[i].sort()
    if gr[i]!=[]:
        if len(gr[i])==1:
            heapq.heappush(single,gr[i][0])
        else:
            heapq.heappush(multi,gr[i][0])
    
inf=10**19
heapq.heappush(single,[inf,N])#絶対に選ばないものを入れておく
heapq.heappush(multi,[inf,N])
    
    
    
for i in range(N-K):
    a=heapq.heappop(single)
    b=heapq.heappop(multi)
    if a[0]+(2*x-1)<=b[0]:#種類ボーナスも含めて小さい方を取り除く
        ans-=a[0]+(2*x-1)
        x-=1
        heapq.heappush(multi,b)
    else:
        ans-=b[0]
        heapq.heappush(single,a)
        tt=b[1]
        num_i[tt]+=1
        if num_i[tt]==len(gr[tt])-1:
            heapq.heappush(single,gr[tt][-1])
        else:
            heapq.heappush(multi,gr[tt][num_i[tt]])
                                       
print(ans)
N, A, B,C,D = map(int,input().split())
S = list(input())

a = A-1
b = B-1
c = C-1
d = D-1

ans = 1

for i_a in range(a,C):
  #2連続の##がa~Cにないことを確認
  if S[i_a] == "#":
    if S[i_a+1] == "#":
      ans =0

for i_b in range(b,D):
  #2連続の##がb~Dにないことを確認
  if S[i_b] == "#":
    if S[i_b+1] == "#":
      ans =0

if D < C:
  ans = 0
  for i in range(b-1,D+1):
    #3連続があるなら1
    if S[i] == ".":
      if S[i+1] == ".":
        if S[i+2] == ".":
          ans = 1

if ans =1:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

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

a = A-1
b = B-1
c = C-1
d = D-1

ans = 1

for i_a in range(a,C):
  #2連続の##がa~Cにないことを確認
  if S[i_a] == "#":
    if S[i_a+1] == "#":
      ans =0

for i_b in range(b,D):
  #2連続の##がb~Dにないことを確認
  if S[i_b] == "#":
    if S[i_b+1] == "#":
      ans =0

if D < C:
  ans = 0
  for i in range(b,D):
    #3連続があるなら1
    if S[i-1] == ".":
      if S[i] == ".":
        if S[i+1] == ".":
          ans = 1

if ans ==1:
  print("Yes")
else:
  print("No")
s = map(int(input().split()))
if s.count('7') == 1 and s.count('5') == 2:
  print('YES')
else:
  print('NO')

### FIXED CODE ###


s = input().split()
if s.count('7') == 1 and s.count('5') == 2:
  print('YES')
else:
  print('NO')
S = set(list(input()))

for c in string.ascii_lowercase:
  if c not in S:
    print(c)
    exit()

print('None')

### FIXED CODE ###

import string

S = set(list(input()))

for c in string.ascii_lowercase:
  if c not in S:
    print(c)
    exit()

print('None')
N,M=map(int,input().split())
d={}
for i in range(M):
  s,t=map(int,input().split())
  if s in d:
    if d[s]!=t:
      print('-1')
      exit()
  if s==1:
    if t==0:
      print('-1')
      exit()
  
  d[s]=t
if N==1:
    if s==1:
      if t==0:
        print('0')
        exit()
if 1 not in d:
  d[1]=1
for i in range(2,N):
  if i not in d:
    d[i]=0
L=[]
for i in d.values():
  L.append(str(i))
print(''.join(L))

### FIXED CODE ###

N,M=map(int,input().split())
SC=[list(map(int,input().split())) for i in range(M)]

def check(x):
  x=str(x)#文字に変換
  if len(x)!=N:
    return False
  for s,c in SC:
    if x[s-1]!=str(c):
      return False
  return True

for i in range(1000):
  if check(i):
    print(i)
    exit()
print(-1)
import numpy as np

a = list(map(int, input().split()))
arr = np.array(a[1:])

print(len(np.unuque(arr)))

### FIXED CODE ###

n = int(input())
print(len(set(map(int, [input() for i in range(n)]))))
from fractions import gcd

N = int(input())
Num_list = [int(i) for i in input().split()]

odd_list = []
even_list = []

for i in range(N):
    
    if Num_list[i] % 2 == 0:
        even_list.append(Num_list[i])
        
    else:
        odd_list.append(Num_list[i])
        
even_max = max(even_list)
even_min = min(even_list)
odd_max = max(odd_list)
odd_min = min(odd_list)

if len(even_list) < 2:
    even_max = 1
    
elif len(odd_list) < 2:
    odd_max = 1

frac_1 = gcd(even_max,even_min)
frac_2 = gcd(odd_max, odd_min)
frac_3 = gcd(even_max, odd_min)
frac_4 = gcd(odd_max, even_min)

max_frac = max([frac_1, frac_2, frac_3, frac_4])

print(max_frac)

### FIXED CODE ###

from fractions import gcd

N = int(input())
A = [int(i) for i in input().split()]

gcd_l = [0]
gcd_r = [0]
for i in range(N):
    gcd_l.append(gcd(gcd_l[i], A[i]))
    gcd_r.append(gcd(gcd_r[i], A[-(i+1)]))
gcd_r = gcd_r[::-1]

ans = []
for i in range(N):
    ans.append(gcd(gcd_l[i], gcd_r[i+1]))

print(max(ans))
S = input()
T = input()

cout = 0
for i in range(len(S)):
	if S[i] != T[i]:
		count = count + 1

print(count)

### FIXED CODE ###

S = input()
T = input()
 
count = 0
for i in range(len(S)):
	if S[i] != T[i]:
		count = count + 1
 
print(count)
import math

r = 100
n = input()
for i in range(n):
    r = math.ceil(r * 1.05)
print(r * 1000)


### FIXED CODE ###

import math

r = 100
n = int(input())
for i in range(n):
    r = math.ceil(r * 1.05)
print(r * 1000)
from sys import exit

n,m = map(int,input().split())
A=[-1]*3

cnt=0
for _ in range(m):
	s,c=map(int,input().split())
	if A[s-1]!=c and A[s-1]!=-1:
		cnt=1
	else:
		A[s-1]=c

if cnt==1 or A[0]==0:
	print("-1")
	exit()
	
if A[0]==-1:
	if n==1:
		A[0]=0
	else:
		A[0]=1

res=0
for i in range(n):
	if A[i]==-1:
		A[i]=0
	res+=A[i]*(10**(n-i-1))

print(res)

### FIXED CODE ###

N=int(input())
if N%2 == 1:
	print(N//2+1)
else:
	print(N//2)
n = int(raw_input())
s = ["" for i in range(n)]

while True:
    a = raw_input().split()
    if a[0] == "quit"
        break

    i = int(a[1]) - 1
    if a[0] == "push":
        s[i] += a[2]

    elif a[0] == "pop":
        l = len(s[i]) - 1
        print s[i][l]
        s[i] = s[i][:l]

    elif a[0] == "move":
        j = int(a[2]) - 1 
        l = len(s[i]) - 1
        s[j] += s[i][l]
        s[i] = s[i][:l]

### FIXED CODE ###

n = int(raw_input())
s = ["" for i in range(n)]

while True:
    a = raw_input().split()
    if a[0] == "quit":
        break

    i = int(a[1]) - 1
    if a[0] == "push":
        s[i] += a[2]

    elif a[0] == "pop":
        l = len(s[i]) - 1
        print s[i][l]
        s[i] = s[i][:l]

    elif a[0] == "move":
        j = int(a[2]) - 1 
        l = len(s[i]) - 1
        s[j] += s[i][l]
        s[i] = s[i][:l]
import math

A,B = (int(x) for x in input().split())

if A==B:
    print(A)
else:
    ans = 0
    if A*2 <= B+1 and B > 4:
        n = int(math.log2(A))
        m = int(math.log2(B))

        if n <= 1:
            for i in range(A,4):
                ans = ans ^ i
            A=4
            n=2
            
        if 2**n != A:
            n += 1
            for i in range(A,2**n):
                ans = ans ^ i

        for i in range(2**m,B+1):
            ans = ans ^ i

    else:
        for i in range(A,B+1):
            ans = ans ^ i

    print(ans)


### FIXED CODE ###

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

if A == B:
    print(A)
elif B - A == 1:
    print(A^B)
else:
    ans = 0
    if A % 2 != 0:
        ans ^= A
        A += 1
    if B % 2 == 0:
        ans ^= B
        B -= 1
    ans ^= ((B-A+1)//2)%2

    print(ans)
INF = 10**18

N,M = map(int,input().split())
edge = [list(map(int,input().split())) for i in range(M)]

graph = [[] for _ in range(N)]

for e in edge:
    graph[e[0]-1].append([e[1]-1,-e[2]])
    
dist = [INF for _ in range(N)]
dist[0] = 0

for _ in range(N):
    flag = False
    for node,g in enumerate(graph):
        for adj,cost in g:
            if dist[node] != INF and dist[node]+cost < dist[adj]:
                dist[adj] = dist[node]+cost
                if _==N-1:
                    update = adj
                flag = True
    if not flag:
        print(-dist[N-1])
        break
else:
    visited = [0 for _ in range(N)]
    visited[update] = 1
    stack = [update]
    while stack:
        node = stack.pop()
        for adj in graph[node][0]:
            if not visited[adj]:
                visited[adj] = 1
                stack.append(adj)
    if visited[N-1]:
        print('inf')
    else:
        print(-dist[N-1])
        

### FIXED CODE ###

INF = 10**18

N,M = map(int,input().split())
edge = [list(map(int,input().split())) for i in range(M)]

graph = [[] for _ in range(N)]

for e in edge:
    graph[e[0]-1].append([e[1]-1,-e[2]])
    
dist = [INF for _ in range(N)]
dist[0] = 0

for _ in range(N):
    flag = False
    for node,g in enumerate(graph):
        for adj,cost in g:
            if dist[node] != INF and dist[node]+cost < dist[adj]:
                dist[adj] = dist[node]+cost
                if _==N-1:
                    update = adj
                flag = True
    if not flag:
        print(-dist[N-1])
        break
else:
    visited = [0 for _ in range(N)]
    visited[update] = 1
    stack = [update]
    while stack:
        node = stack.pop()
        for adj,c in graph[node]:
            if not visited[adj]:
                visited[adj] = 1
                stack.append(adj)
    if visited[N-1]:
        print('inf')
    else:
        print(-dist[N-1])
from itertools import*
a,b=map(int,input().split())
L=[]
for i in range(100):
    if a<=2**i<=b:
        L.append(2**i)
l=[]
for s in L:
    if (b-s)%2==0:
        l.append(1)
for s in range(a,l[0]+1):
    

### FIXED CODE ###

a,b=map(int,input().split())
def f(x):
    if x%4==0:
        return x
    elif x%4==1:
        return 1
    elif x%4==3:
        return 0
    else:
        return x+1
print(f(a-1)^f(b))
N=int(input())
l=[]
for i in range(N):
    l.append(int(input()))
import fraction
from functools import reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
print(lcm_list(l))

### FIXED CODE ###

N=int(input())
l=[]
for i in range(N):
    l.append(int(input()))
import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
print(lcm_list(l))
import itertools

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

comb = list(itertools.combinations(l, 3))

result = 0

for i in range(len(comb)):
    a, b, c = comb[i]
    if a < b + c:
        if b < c + a:
            if c < a + b:
                result += 1

print(result)


### FIXED CODE ###

n = input()
s = str(input())

result = []

for i in range(int(n)):
    if s[i:i + 1] != s[i + 1:i + 2]:
        result.append(s[i:i + 1])

print(len(result))
N=int(input())
X=list(map(int, input().split()))

ans=1
if 0 in X:
    print(0)
else:
    X.sorted(reverse = True)
    for i in range(N):
        ans *= X[i]
        if 10**18<ans:
            print(-1)
            break
    else:
        print(ans)    

### FIXED CODE ###

N=int(input())
X=list(map(int, input().split()))
ans=1
if 0 in X:
    print(0)
else:
    for i in range(N):
        ans *= X[i]
        if 10**18<ans:
            print(-1)
            break
    else:
        print(ans)
from numpy import max
from array import array
def main():
  n = int(input())
  As = list(map(int, input().split()))
  r = 0
  max_a = max(array('L', As))
  for i in range(n-1, 0, -1):
    if i == 0:
      break
    if As[i] < As[i-1]:
      if(max_a not in As[0:i-1]):
        max_a = As[i-1]
      r += max_a - As[i]
  print(r)

main()


### FIXED CODE ###

def main():
  n = int(input())
  As = list(map(int, input().split()))
  r = 0
  max_a = 0
  for i in range(n):
    max_a = max(max_a, As[i])
    r += max_a - As[i]
  print(r)

main()
N = int(input())

a_list = []
for _ in range(N):
    a_list.append(int(input())

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

res = 1
for i in range(N):
    d = gcd(res, a_list[i])
    res = res // d
    res = res * a_list[i]

print(res) 
 

### FIXED CODE ###

N = int(input())
 
a_list = []
for _ in range(N):
    a_list.append(int(input()))
 
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
 
res = 1
for i in range(N):
    d = gcd(res, a_list[i])
    res = res // d
    res = res * a_list[i]
 
print(res)
n,m=map(int, input().split())
d = {}
flag = True
for _ in range(m):
    s, c = input().split()
    if d.get(s):
        if d.get(s) == c:
            continue
        else:
            flag = False
            break
    else:
        d[s] = c
if flag:
    if max(map(int, d.keys())) == n:
        l = ['0']*n
        for i in range(1,n+1):
            if d.get(str(i)):
                l[i-1] = d.get(str(i))
        print(''.join(l))
    else:
        print(-1)
else:
    print(-1)

### FIXED CODE ###

n,m=map(int, input().split())
l = [None]*n
msg=''
for _ in range(m):
    s, c = input().split()
    index = int(s)-1
    if l[index] is None:
        l[index] = c
    else:
        if l[index] == c:
            continue
        else:
            msg=-1
            break
if l[0] is None and len(l) != 1:
    l[0]='1'
l = list(map(lambda x: '0' if x is None else x, l))
if msg == -1:
    print(msg)
elif l[0] == '0' and len(l) != 1:
    print(-1)
else:
    print(msg.join(l))
from collections import deque

S = input()
Q = int(input())

q = deque()
rev = 0

for s in S:
  q.append(S)
  
for _ in range(Q):
  TFC = input()
  if len(TFC) == 1: # T == 1
    rev ^= 1
  else:
    T, F, C = (i for i in TFC.split())  
    if F == '1' and rev:
      q.append(C)
    else:
      q.appendleft(C)
      
if rev:
  q.reverse()

print(''.join(q))

### FIXED CODE ###

from collections import deque

S = input()
Q = int(input())

q = deque()
rev = 0

for s in S:
  q.append(s)

for _ in range(Q):
  TFC = input()
  if len(TFC) == 1: # T == 1
    rev ^= 1
  else:
    T, F, C = (i for i in TFC.split())  
    if (F == '2' and not rev) or (F == '1' and rev):
      q.append(C)
    else:
      q.appendleft(C)
      
ans = ''.join(q)

if rev:
  print(ans[::-1])
else:
  print(ans)