Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

s=input()
n=int(input())
for i in range(n):
    e=list(map(str,input().split()))
    q=int(e[0])
    if len(e)!=1:
        f=int(e[1])
        c=e[2]
    if q==2:
        if f==1:
            s=c+s
        else:
            s=s+c
    else:
        s=s[::-1]
print(s)


### FIXED CODE ###

s=input()
n=int(input())
cnt=0
l=[]
r=[]
for i in range(n):
    e=list(map(str,input().split()))
    q=int(e[0])
    if len(e)!=1:
        f=int(e[1])
        c=e[2]
    if q==2:
        if (f==1 and cnt%2==0) or (f==2 and cnt%2!=0):
            l.append(c)
        else:
            r.append(c)
    else:
        cnt+=1
if cnt%2==0:
    print(''.join(l[::-1])+s+''.join(r))
else:
    print(''.join(r[::-1])+s[::-1]+''.join(l))
### BUGGY CODE ###

N = int(input())
Stemp = str(input())
S = []
for i in range(N):
  temp = int(Stemp[i])
  S.append(temp)
ans = set([])
for v in range(1000):
  a = v//100
  b = (v-a*100)//10
  c = v-a*100-b*10
  for i in range(N):
    if a != S[i]:
      continue
    for j in range(i+1,N):
      if b != S[j]:
        continue
      for k in range(j+1,N):
        if c == S[k]:
          ans.add(v)
          break
print(len(ans))        

### FIXED CODE ###

N = int(input())
Stemp = str(input())
S = []
for i in range(N):
  temp = int(Stemp[i])
  S.append(temp)
ans = set([])
L = [[] for _ in range(10)]
for i in range(N):
  L[S[i]].append(i)
#print(L)
for v in range(1000):
  a = v//100
  b = (v-a*100)//10
  c = v-a*100-b*10
  if not L[a]:
    continue
  left = min(L[a])
  Flag = False
  for x in L[b]:
    if x > left:
      mid = x
      Flag = True
      break
  if not Flag:
    continue
  Flag = False
  for y in L[c]:
    if y > mid:
      right = y
      Flag = True
      break
  if not Flag:
    continue
  ans.add(v)
  #print(v,left,mid,right)
print(len(ans))
### BUGGY CODE ###

import math
def mon():
    n=int(input())
    a=[int(i) for i in input().split()]
    a.sort()
    za=a[0]

    b=[i for i in a[1:] if i%za!=0]
    if b==[]:
        print(za)
        exit()
    c=[za]

    for i in b:
        c+=[i%za]

    while not len(c)==1:
        c.sort(reverse=True)
        c[0]=c[0]-c[1]
        if c[0]<=0:
            c.pop(0)

    return(c[0])


print(mon())

### FIXED CODE ###

from functools import reduce
import fractions
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
def mon():
    input()
    a=[int(i) for i in input().split()]
    return gcd_list(a)
print(mon())
### BUGGY CODE ###

N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
bits=[[] for i in range(29)]
for i in range(29):
  mod = 2**(i+1)
  for j in b:
    bits[i].append(j%mod)
  bits[i].sort()

ans = 0
for k in range(29):
  al = []
  cnt = 0
  mod = 2**k
  for i in a:
    al.append(i%(2*mod))
  al.sort(reverse=True)
  r1 = r2 = r3 = 0
  for j in al:
    while r1 < N and bits[k][r1]+j < mod:
      r1 += 1
    while r2 < N and bits[k][r2]+j < 2*mod:
      r2 += 1
    while r3 < N and bits[k][r3]+j < 3*mod:
      r3 += 1
    cnt += N-r3+r2-r1
  ans += (cnt%2) << k
print(ans)

### FIXED CODE ###

N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
bits=[[] for i in range(29)]
for i in range(29):
  mod = 2**(i+1)
  for j in b:
    bits[i].append(j%mod)
  bits[i].sort()

ans = 0
for k in range(29):
  al = []
  cnt = 0
  mod = 2**k
  for i in a:
    al.append(i%(2*mod))
  al.sort(reverse=True)
  r1 = r2 = r3 = 0
  for j in al:
    while r1 < N and bits[k][r1]+j < mod:
      r1 += 1
    while r2 < N and bits[k][r2]+j < 2*mod:
      r2 += 1
    while r3 < N and bits[k][r3]+j < 3*mod:
      r3 += 1
    cnt += N-r3+r2-r1
  ans += (cnt%2) << k
print(ans)
### BUGGY CODE ###

def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
B, W = map(int,input().split())
Mod = 10**9+7
magick = 500000004

inv_t = [0]+[1]
for i in range(2,B+W+1):
   inv_t += [inv_t[Mod % i] * (Mod - int(Mod / i)) % Mod]

consts_B, consts_W = [0]*(B-1)+ [1], [0]*(W-1)+[1]
for i in range(B+W):
  if i >= B: consts_B += [consts_B[-1]*(i)*inv_t[i-B+1]%Mod]
  if i >= W: consts_W += [consts_W[-1]*(i)*inv_t[i-W+1]%Mod]

p, q = 0, 0
inv = 1
for i in range(B+W):
  print((1-p+q)*magick%Mod)
  inv *= magick
  p += consts_B[i]*inv
  q += consts_W[i]*inv

### FIXED CODE ###

B, W = map(int,input().split())
Mod = 10**9+7
magick = 500000004

inv_t = [0]+[1]
inv_2 = [0]+[magick]
for i in range(2,B+W+1):
  inv_t += [inv_t[Mod % i] * (Mod - int(Mod / i)) % Mod]
  inv_2 += [inv_2[-1]*magick % Mod]

consts_B, consts_W = [0]*(B-1)+ [1], [0]*(W-1)+[1]
for i in range(B+W):
  if i >= B: consts_B += [consts_B[-1]*(i)*inv_t[i-B+1]%Mod]
  if i >= W: consts_W += [consts_W[-1]*(i)*inv_t[i-W+1]%Mod]

p, q = 0, 0
for i in range(B+W):
  print((1-p+q)*magick%Mod)
  p += consts_B[i]*inv_2[i+1]
  q += consts_W[i]*inv_2[i+1]
### BUGGY CODE ###

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

l = []

for i in range(n):
    a, b = map(int, input().split())
    for j in range(b):
        l.append(a)

    
l.sort()

print(l[k-1])


### FIXED CODE ###

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

l = [0 for _ in range(1000000)]

rui = 0

for i in range(n):
    a, b = map(int, input().split())
    l[a] += b


for i in range(len(l)):
    rui += l[i]

    if rui >= k:
        print(i)
        break

#print()
### BUGGY CODE ###

N, M, Q = [int(v) for v in input().split()]
p = []
q = []
x = [[0] * (N+1) for i in range(N+1)]
c = [[0] * (N+1) for i in range(N+1)]

for i in range(M):
    l, r = [int(v) for v in input().split()]
    x[l][r] += 1
for i in range(1, N+1):
    for j in range(1, N+1):
        c[i][j] = c[i][j-1] + x[i][j]
for i in range(Q):
    a, b = [int(v) for v in input().split()]
    p.append(a)
    q.append(b)

for i in range(Q):
    ans = 0
    for j in range(p[i], q[i]+1):
        ans += c[j][q[i]] - c[j][p[i]-1]
    print(ans)

### FIXED CODE ###

N, M, Q = [int(v) for v in input().split()]
p = []
q = []
x = [[0] * (N+1) for i in range(N+1)]
c = [[0] * (N+1) for i in range(N+1)]

for i in range(M):
    l, r = [int(v) for v in input().split()]
    x[l][r] += 1
for i in range(1, N+1):
    for j in range(1, N+1):
        c[i][j] = c[i][j-1] + x[i][j]
for i in range(Q):
    a, b = [int(v) for v in input().split()]
    p.append(a)
    q.append(b)

for i in range(Q):
    ans = 0
    for j in range(p[i], q[i]+1):
        ans += c[j][q[i]] - c[j][p[i]-1]
    print(ans)
### BUGGY CODE ###

N, W = map(int, input().split())
w = []
v = []
max_v = 1000
for _ in range(N):
    a, b = map(int, input().split())
    w.append(a)
    v.append(b)
INF = int(1e9+1)*(N+1)
dp = [INF for _ in range(max_v*N+1)]
max_sum = max_v*N
dp[0] = 0

ans=0

for i in range(N):
  for j in range(max_v*N,v[i]-1,-1):
    res = dp[j-v[i]]+w[i]
    if res > W: continue
    if j > ans:ans=j
    dp[j]=min(dp[j],res)


print(ans)


### FIXED CODE ###

N, W = map(int, input().split())
w = []
v = []
max_v = 1000
for _ in range(N):
    a, b = map(int, input().split())
    w.append(a)
    v.append(b)
INF = int(1e9)*(N+1)
dp = [[INF] * (max_v * N+1) for _ in range(N+1)]
max_sum = max_v*N
dp[0][0] = 0

for i in range(N):
    for j in range(max_v * N+1):
        if j+v[i] > max_sum:
            break
        dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]], dp[i][j]+w[i])
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])

ans = 0
for i in range(max_v * N + 1):
    if dp[N][i] <= W:
        ans = max(ans, i)
print(ans)
### BUGGY CODE ###

x,y = map(int,input().split())
if x > y:
    greater = x
else:
    greater = y
while(True):
    if((greater % x == 0) and (greater % y == 0)):
        lcm = greater
        break
    greater += 1
print(lcm)


### FIXED CODE ###

def gcd(A,B): 
    if A == 0: 
        return B 
    return gcd(B % A, A) 
  
def lcm(A,B): 
    return (A*B) / gcd(A,B)

A,B = map(int,input().split())
print(int(lcm(A,B)))
### BUGGY CODE ###

n = int(input())
# a*b + c=n (a,b,c) いくつ？
cnt = 0
for a in range(1, n+1):
    bn = (n) // a
    for b in range(1, bn+1):
        c = n-(a*b)
        if c<=0: break
        if a*b + c == n:
            cnt += 1


print(cnt)


### FIXED CODE ###

n = int(input())
cnt = 0
for a in range(1, n):
    bn = (n-1) // a
    for b in range(1, bn+1):
        c = n-(a*b)
        if c<=0: break
        if a*b + c == n:
            cnt += 1
print(cnt)
### BUGGY CODE ###

import heapq

H, W, M = map(int, input().split())

bn_h = {}
bn_v = {}

for i in range(M):
    h, w = map(int, input().split())
    bn_h.setdefault(h, set())
    bn_h[h].add(w)
    bn_v.setdefault(w, set())
    bn_v[w].add(h)

b1 = sorted(bn_h.items(), key = lambda x:len(x[1]), reverse=True)
b2 = sorted(bn_v.items(), key = lambda x:len(x[1]), reverse=True)

m1 = len(b1[0][1])
m2 = len(b2[0][1])

max_result = 0
for i in b1:
    h, sh = i
    if len(sh) < m1:
        break
    for j in b2:
        v, sv = j
        if len(sv) < m2:
            break
        result = len(sh) + len(sv) - 1
        if h not in sv:
            result += 1
        max_result = max(max_result, result)
print(max_result)


### FIXED CODE ###

import heapq
def main():
    H, W, M = map(int, input().split())

    bn_h = {}
    bn_v = {}

    for i in range(M):
        h, w = map(int, input().split())
        bn_h.setdefault(h, set())
        bn_h[h].add(w)
        bn_v.setdefault(w, set())
        bn_v[w].add(h)

    b1 = sorted(bn_h.items(), key = lambda x:len(x[1]), reverse=True)
    b2 = sorted(bn_v.items(), key = lambda x:len(x[1]), reverse=True)

    m1 = len(b1[0][1])
    m2 = len(b2[0][1])

    flag = False
    max_result = 0
    for i in b1:
        h, sh = i
        if len(sh) < m1:
            break
        for j in b2:
            v, sv = j
            if len(sv) < m2:
                break
            result = len(sh) + len(sv) - 1
            if h not in sv:
                result += 1
                flag = True
            max_result = max(max_result, result)
            if flag == True:
                break
        if flag == True:
            break
    print(max_result)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

N,A,B = map(int,input().split())
trig=True
reds=0
blues=0
while N>0:
	if trig:
		if N<A:
			blues+=N
		else:
			blues+=A
		N-=A
		trig=False
	else:
		reds+=B
		N-=B
		trig=True

print(blues)


### FIXED CODE ###

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

count= N // (A+B)
N = N %(A+B)
blues=A*count
reds=B*count

if N<=A:
	blues+=N
else:
	blues+=A


print(blues)
### BUGGY CODE ###

x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

ns = [p.pop(0), q.pop(0), r.pop(0)]

z = 0
val = 0

while x + y - z > 0:
    if ns[0] >= ns[1] and ns[0] >= ns[2]:
        val += ns[0]
        x -= 1
        if len(p) > 0 and x > 0:
            ns[0] = p.pop(0)
        else:
            ns[0] = 0
    elif ns[0] <= ns[1] and ns[1] >= ns[2]:
        val += ns[1]
        y -= 1
        if len(q) > 0 and y > 0:
            ns[1] = q.pop(0)
        else:
            ns[1] = 0
    else:
        val += ns[2]
        z += 1
        if len(r) > 0:
            ns[2] = r.pop(0)
        else:
            ns[2] = 0

print(val)


### FIXED CODE ###

import heapq

x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p2 = heapq.nlargest(x, p)
q2 = heapq.nlargest(y, q)
r2 = heapq.nlargest(x+y, r)
p2.append(0)
q2.append(0)
r2.append(0)

pi = 0
qi = 0
ri = 0

val = 0

for _ in range(x+y):
    if p2[pi] >= q2[qi] and p2[pi] >= r2[ri]:
        val += p2[pi]
        pi += 1
    elif p2[pi] <= q2[qi] and q2[qi] >= r2[ri]:
        val += q2[qi]
        qi += 1
    else:
        val += r2[ri]
        ri += 1

print(val)
### BUGGY CODE ###

import math

N = int(input())
for i in range(1,N+1):
  ans = 0
  for x in range(1,int(math.sqrt(i))):
    for y in range(1,int(math.sqrt(i))):
      for z in range(1,int(math.sqrt(i))):
        if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
          ans += 1
  print(ans)


### FIXED CODE ###

import math

N = int(input())
ans = [0 for _ in range(10050)]

# for i in range(1,N+1):
for x in range(1,math.ceil(math.sqrt(N))):
  for y in range(1,math.ceil(math.sqrt(N))):
    for z in range(1,math.ceil(math.sqrt(N))):
      v = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if v < 10050:
        ans[v] += 1

for i in range(N):
  print(ans[i+1])
### BUGGY CODE ###

import numpy as np
input()
aa = list(map(int, input().split()))
uu = list(set(aa))
cc = []
for u in list(uu):
    cc += [aa.count(u)]
dic = dict(zip(uu,cc))
total = 0
for v in list(cc):
    total += v * (v-1) / 2
    
for a in aa:
    print(int(total - dic[a] + 1))

### FIXED CODE ###

input()
from collections import Counter
aa = list(map(int, input().split()))
dic = Counter(aa)

total = 0
for v in dic.values():
    total += v * (v-1) / 2

for a in aa:
    print(int(total - dic[a] + 1))
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()

for _ in range(Q):
    l, r = map(int, input().split())
    S_tmp = S[l-1:r]
    S_tmp = S_tmp.replace("AC", "@")
    print(S_tmp.count("@"))


### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
memo = [0]*N
tmp = 0
for i in range(1, len(S)):
    if S[i-1] == "A" and S[i] == "C":
        tmp += 1
        memo[i] = tmp
    else:
        memo[i] = tmp

for _ in range(Q):
    li, ri = map(int, input().split())
    ans = memo[ri-1] - memo[li-1]
    print(ans)
### BUGGY CODE ###

N = int(input())
X = list(map(int, input()))
# N = 2*10**5
# X = list(map(int, "10"*(N//2)))

Xp = sum(X)
        
# print(Xp)
a = 0
b = 0
# c = 0
# :N
for i, x in enumerate(X):
    i_reverse = N-i-1
    if Xp > 1:
        a = (a + x * (1<<i_reverse)) % (Xp-1)
    b = (b + x * (1<<i_reverse)) % (Xp+1)
    # c = (c + x * (1<<i_reverse))
    # print(bin(c))

# print(a, b)

# :N
for i in range(N):
    i_reverse = N-i-1
    if Xp > 1:
        m = ([a, b][X[i]==0] + [-1, 1][X[i]==0] * pow(2, i_reverse, [Xp-1, Xp+1][X[i]==0])) % [Xp-1, Xp+1][X[i]==0]
    else:
        if X[i]==0:
            m = (b + pow(2, i_reverse, Xp+1)) % (Xp+1)
        else:
            print(0)
            continue
    count = 1
    # print(i, ([a, b][X[i]==0], [-1, 1][X[i]==0]*(1<<i_reverse)), [Xp-1, Xp+1][X[i]==0], X[i]==0)
    # print(m)
    while m > 0:
        p = sum([int(c) for c in str(bin(m)[2:])])
        m = m % p
        count += 1
    print(count)


### FIXED CODE ###

N = int(input())
X = list(map(int, input()))
# N = 2*10**5
# X = list(map(int, "10"*(N//2)))

Xp = sum(X)
        
# print(Xp)
a = 0
b = 0
# c = 0
# :N
for i, x in enumerate(X):
    i_reverse = N-i-1
    if Xp > 1:
        a = (a + x * pow(2, i_reverse, Xp-1)) % (Xp-1)
    b = (b + x * pow(2, i_reverse, Xp+1)) % (Xp+1)
    # c = (c + x * (1<<i_reverse))
    # print(bin(c))

# print(a, b)

# :N
for i in range(N):
    i_reverse = N-i-1
    if Xp > 1:
        m = ([a, b][X[i]==0] + [-1, 1][X[i]==0] * pow(2, i_reverse, [Xp-1, Xp+1][X[i]==0])) % [Xp-1, Xp+1][X[i]==0]
    else:
        if X[i]==0:
            m = (b + pow(2, i_reverse, Xp+1)) % (Xp+1)
        else:
            print(0)
            continue
    count = 1
    # print(i, ([a, b][X[i]==0], [-1, 1][X[i]==0]*(1<<i_reverse)), [Xp-1, Xp+1][X[i]==0], X[i]==0)
    # print(m)
    while m > 0:
        p = sum([int(c) for c in str(bin(m)[2:])])
        m = m % p
        count += 1
    print(count)
### BUGGY CODE ###

import sys


input = sys.stdin.readline

N, Q = map(int, input().split())
S = input()
qlist = [(int(n)-1 for n in input().split()) for _ in range(Q)]
for l, r in qlist:
    count = 0
    while l < r:
        if S[l]+S[l+1] == "AC":
            count += 1
        if S[l+1] ==  "A":
            l += 1
        else:
            l += 2
        if S[r-1]+S[r] == "AC":
            count += 1
        if S[r-1] == "C":
            r -= 1
        else:
            r -= 2

    print(count)

### FIXED CODE ###

import sys


input = sys.stdin.readline

N, Q = map(int, input().split())
S = list(input())
anum = [0]*N
for i in range(1, N):
    if S[i-1] == "A" and S[i] == "C":
        S[i-1] = "a"
        anum[i] += 1
    anum[i] += anum[i-1]
qnum = [map(int, input().split()) for _ in range(Q)]
for l, r in qnum:
    print(anum[r-1]-anum[l-1])
### BUGGY CODE ###

import math
X,Y = map(int,input().split())
a,b = (2*Y-X)/3,(2*X-Y)/3
n = 10**9+7
nCr={}
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
def count():
  if not (a//1 == a and b//1==b):
    return 0
  else:
    ahat = int(a%n)
    bhat = int(b%n)
    return cmb(ahat+bhat,ahat)


print(int(count())%(10**9+7))

### FIXED CODE ###

import math
X,Y = map(int,input().split())
a,b = (2*Y-X)/3,(2*X-Y)/3
n = 10**9+7
def cmb(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod
def count():
  if not (a//1 == a and b//1==b):
    return 0
  else:
    ahat = int(a%n)
    bhat = int(b%n)
    return cmb(ahat+bhat,ahat)


print(int(count())%(10**9+7))
### BUGGY CODE ###

from decimal import Decimal
a, b, c = list(map(int, input().split()))


def f(x):
    return Decimal(Decimal(x)**2 + s) / (2 * Decimal(x))


s = a * b   # √s
x = 2   # 初期値（0以外の値）
for i in range(10**4):
    x = f(x)

l = 2 * x + a + b

if l < c:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

from decimal import Decimal
a, b, c = list(map(int, input().split()))


def f(x):
    return Decimal(Decimal(x)**2 + s) / (2 * Decimal(x))


s = a * b   # √s
x = 2   # 初期値（0以外の値）
while True:
    newX = f(x)
    if abs(newX - x) < 1e-7:
        x = newX
        break
    x = newX

l = 2 * x + a + b

if l < c:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
b = [list(map(int, input().split())) for i in range(h)]
diff = [[0]*w for i in range(h)]
for i in range(h):
    for j in range(w):
        diff[i][j] = abs(a[i][j] - b[i][j])

n = 80 * w * h + 1
dp = [[[False]*n for i in range(w)] for i in range(h)]
dp[0][0][diff[0][0]] = True

for i in range(h):
    for j in range(w):
        for cnt in range(n):
            if dp[i][j][cnt]:
                if i+1 < h:
                    dp[i+1][j][cnt + diff[i+1][j]] = True
                    dp[i+1][j][abs(cnt - diff[i+1][j])] = True
                if j+1 < w:
                    dp[i][j+1][cnt + diff[i][j+1]] = True
                    dp[i][j+1][abs(cnt - diff[i][j+1])] = True 

for i, boo in enumerate(dp[h-1][w-1]):
    if boo:
        print(i)
        exit()
print(a[10*9])

### FIXED CODE ###

import sys
input = sys.stdin.readline


h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
b = [list(map(int, input().split())) for i in range(h)]

diff = [[0]*(w) for i in range(h)]
for i in range(h):
    for j in range(w):
        diff[i][j] = abs(a[i][j] - b[i][j])

dp = [0] * (h*w)
dp[0] |= 1 << (13000 + diff[0][0])
dp[0] |= 1 << (13000 - diff[0][0])

for k in range(h*w):
    i = k // w
    j = k % w
    if i+1 < h:
        tmp1 = diff[i+1][j]
        dp[k + w] |= dp[k] << tmp1
        dp[k + w] |= dp[k] >> tmp1       
    if j+1 < w:
        tmp2 = diff[i][j+1]
        dp[k + 1] |= dp[k] << tmp2
        dp[k + 1] |= dp[k] >> tmp2


ans = 10**9
for i in range(81):
    if dp[w*h - 1] >> 13000 + i & 1:
        ans = min(ans, i)
for i in range(81):
    if dp[w*h - 1] >> 13000 - i & 1:
        ans = min(ans, i) 
print(ans)
### BUGGY CODE ###

N,Q = map(int,input().split())

s = list(input())

ans = 0

for _ in range(Q):
    L,R = map(int,input().split())
    for i in range(L-1,R-1):
        if s[i] == 'A' and s[i+1] == 'C': 
            ans += 1
    print(ans)
    ans = 0

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
### BUGGY CODE ###

N = int(input())
AList = [input() for i in range(N)]

for i in range(N) :
    print(max(AList[0:i] + AList[i+1:N]))

### FIXED CODE ###

N = int(input())
AList = [int(input()) for i in range(N)]
max_AList = max(AList)
max2nd_AList = sorted(AList, reverse = True)[1]

for i in range(N) :
    if AList[i] == max_AList :
        print(max2nd_AList)
    else :
        print(max_AList)
### BUGGY CODE ###

n,m=map(int,input().split())
k=n
ans=0
for i in range(k):
    if m>=2:
        n-=1
        m-=2
        ans+=1

k=m
for i in range(k):
    if m>=4:
        m-=4
        ans+=1

print(ans)




### FIXED CODE ###

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

ans=0
if 2*n<=m:
    ans+=n
    n=0
    m-=2*ans
elif 1<=n and 2<=m:
    ans+=m//2
    n-=m
    m-=(m//2)*2
   

ans+=m//4

print(ans)
### BUGGY CODE ###

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

count = 0

for i in range(n):
    if p[i] == min(p[:i+1]):
        count += 1
print(count)

### FIXED CODE ###

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

count = 0
m = p[0]

for i in p:
    m = min(m, i)
    if m == i:
        count += 1
print(count)
### BUGGY CODE ###

from itertools import permutations

N, M, R = map(int, input().split())
r = list(map(int, input().split()))
ARSP = [[float('inf')] * (N+1) for i in range(N+1)]
for i in range(M):
    a, b, c = map(int, input().split())
    ARSP[a][b] = c
    ARSP[b][a] = c


def warshall_floyd(adj_array):
    for k in range(len(adj_array)):
        for i in range(len(adj_array)):
            for j in range(len(adj_array)):
                adj_array[i][j] = min(adj_array[i][j], adj_array[i][k] + adj_array[k][j])
    return adj_array


ARSP = warshall_floyd(ARSP)

# 訪れ方の全列挙(max 8! = 40320)
journey = list(permutations(r))

ans = float('inf')
for j in journey:
    cost = 0
    for i in range(1, len(j)):
        if ARSP[j[i]][j[i-1]] == float('inf'):
            break
        cost += ARSP[j[i]][j[i-1]]
        if cost >= ans:
            break
    else:
        ans = cost

print(ans)

### FIXED CODE ###

from itertools import permutations

N, M, R = map(int, input().split())
r = list(map(int, input().split()))
ARSP = [[float('inf')] * (N+1) for i in range(N+1)]
for i in range(M):
    a, b, c = map(int, input().split())
    ARSP[a][b] = c
    ARSP[b][a] = c


def warshall_floyd(adj_array):
    for k in range(len(adj_array)):
        for i in range(len(adj_array)):
            for j in range(len(adj_array)):
                if adj_array[i][k] + adj_array[k][j] < adj_array[i][j]:
                    adj_array[i][j] = min(adj_array[i][j], adj_array[i][k] + adj_array[k][j])
    return adj_array


ARSP = warshall_floyd(ARSP)

# 訪れ方の全列挙(max 8! = 40320)
journey = list(permutations(r))

ans = float('inf')
for j in journey:
    cost = 0
    for i in range(1, R):
        if ARSP[j[i]][j[i-1]] == float('inf'):
            break
        cost += ARSP[j[i]][j[i-1]]
        if cost >= ans:
            break
    else:
        ans = cost

print(ans)
### BUGGY CODE ###

a, b, k = list(map(int, input().rstrip().split()))
for i in range(k):
    if a >= 1:
        a -= 1
    elif b >= 1:
        b -= 1
    else:
        break

print('{} {}'.format(a, b))



### FIXED CODE ###

a, b, k = list(map(int, input().rstrip().split()))
if a > k:
    a -= k
    k = 0
else:
    # a <= k
    k -= a
    a = 0

if b > k:
    b -= k
else:
    # b <= k
    b = 0


print('{} {}'.format(a, b))