Harryxun/stf_run huggingface dataset:
def card_game():
    n = int(input())
    a_li = [int(i) for i in input().split()]
    ans = 0
    turn_switch = True

    li = a_li.sorted()

    for i in li:
        if turn_switch:
            ans += i
            turn_switch = False
        else:
            ans -= i
            turn_switch = True

    return ans


if __name__ == '__main__':
    print(card_game())

### FIXED CODE ###

def card_game():
    n = int(input())
    a_li = [int(i) for i in input().split()]
    ans = 0
    turn_switch = True

    li = sorted(a_li, reverse=True)

    for i in li:
        if turn_switch:
            ans += i
            turn_switch = False
        else:
            ans -= i
            turn_switch = True

    return ans


if __name__ == '__main__':
    print(card_game())
from operator import mul
from functools import reduce

N = int(input())
M = []
A = []
R = []
C = []
H = []
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

for _ in range(N):
  tmp = input()[0]
  if tmp == "M":
    M.append(tmp)
  elif tmp == "A":
    A.append(tmp)
  elif tmp == "R":
    R.append(tmp)
  elif tmp == "C":
    C.append(tmp)
  elif tmp == "H":
    H.append(tmp)
X = [len(M),len(A),len(R),len(C),len(H)]
Y = sum(X)
if Y == 0:
  print(0)
  exit()
Sum = cmb(X[0]+X[1]+X[2]+X[3]+X[4],3)

count_A = 0
for x in X:
  if x >= 3:
    count += 1

count_B = 0
for i in X:
  if i >= 2:
    count_B += cmb(i,2) * (Y - i)

print(Sum - count_A - count_B)



### FIXED CODE ###

N = int(input())
M = 0
A = 0
R = 0
C = 0
H = 0

for _ in range(N):
  tmp = input()[0]
  if tmp == "M":
    M += 1
  elif tmp == "A":
    A += 1
  elif tmp == "R":
    R += 1
  elif tmp == "C":
    C += 1
  elif tmp == "H":
    H += 1

ans = 0
ans += M * A * C
ans += M * A * R
ans += M * A * H
ans += M * R * C
ans += M * R * H
ans += M * C * H
ans += A * R * C
ans += A * R * H
ans += A * C * H
ans += R * C * H

print(ans)
import networkx as nx
N, M = map(int, input().split())

edge_list = s = [input().split() for i in range(M)]
G = nx.Graph()
G.add_edges_from(edge_list)

if [] in nx.shortest_path(G, target=str(1)).values():
  print("No")
else:
  print("Yes")
  for i in range(len(list(nx.shortest_path(G, target=str(1)).values()))-1):
    print(nx.shortest_path(G, target=str(1))[str(i+2)][1])
      

### FIXED CODE ###

a = input()
a = int(a)

if a % 10 == 2 or a % 10 == 4 or a % 10 == 5 or a % 10 == 7 or a % 10 == 9:
    print("hon")
elif a % 10 == 0 or a % 10 == 1 or a % 10 == 6 or a % 10 == 8:
    print("pon")
else:
    print("bon")
n = int(input())

m = {}

for i in n:
  x = int(input())
  m.add(x)
  
print(len(m))

### FIXED CODE ###

n = int(input())
 
m = set()
 
for i in range(n):
  x = int(input())
  m.add(x)
  
print(len(m))
from math import gcd
import sys
input = sys.stdin.readline

mod = 10**9 + 7
N = int(input())
cnt = {}
for i in range(N):
    A, B = map(int, input().split())
    neg = False
    if A < 0:
        neg ^= True
        A *= -1
    if B < 0:
        neg ^= True
        B *= -1
    g = gcd(A, B)
    sign = -1 if neg else 1
    A //= g
    B //= g
    frac = (-sign * A, B)
    if frac not in cnt:
        cnt[frac] = 0
    cnt[frac] += 1
ans = 1
used = set()
for frac, c in cnt.items():
    if frac in used:
        continue
    A, B = frac
    sign = 1
    if A < 0:
        A *= -1
        sign = -1
    bad = (B * -sign, A)
    if bad in cnt:
        b = cnt[bad]
        ans = ans * (pow(2, c, mod) + pow(2, b, mod) - 1) % mod
        used.add(bad)
    else:
        ans = ans * 2 % mod
print((ans - 1) % mod)


### FIXED CODE ###

from math import gcd
import sys
input = sys.stdin.readline

mod = 10**9 + 7
N = int(input())
cnt = {}
zz = 0
az = 0
bz = 0
for _ in range(N):
    A, B = map(int, input().split())
    if A == B == 0:
        zz += 1
        continue
    if A == 0:
        az += 1
        continue
    if B == 0:
        bz += 1
        continue
    neg = False
    if A < 0:
        neg ^= True
        A *= -1
    if B < 0:
        neg ^= True
        B *= -1
    g = gcd(A, B)
    sign = -1 if neg else 1
    A //= g
    B //= g
    frac = (-sign * A, B)
    if frac not in cnt:
        cnt[frac] = 0
    cnt[frac] += 1
ans = 1
used = set()
for frac, c in cnt.items():
    if frac in used:
        continue
    A, B = frac
    sign = 1
    if A < 0:
        A *= -1
        sign = -1
    bad = (B * -sign, A)
    if bad in cnt:
        b = cnt[bad]
        ans = ans * (pow(2, c, mod) + pow(2, b, mod) - 1) % mod
        used.add(bad)
    else:
        ans = ans * pow(2, c) % mod
ans = ans * (pow(2, az, mod) + pow(2, bz, mod) - 1) % mod
print((ans + zz - 1) % mod)
N,K = map(int,input().split())
Max = 2001
#二項係数とその逆元テーブルを作る前処理
fac = [0]*(Max)
finv = [0]*(Max)
inv = [0]*(Max)
fac[0]=fac[1]=1
finv[0]=finv[1]=1
inv[1]=1
for i in range(2,Max):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i]*(mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
#O(1)でmod計算した組合せ数を計算
def Comb(n,r):
    if n < r:
        return 0
    if n < 0 or r < 0 :
        return 0
    return fac[n]*(finv[r]*finv[n-r]%mod)%mod

for i in range(1,K+1):
    print(Comb(K-1,i-1)*Comb(N-K+1,i))

### FIXED CODE ###

from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N,K = map(int,input().split())
Max = 2001
#二項係数とその逆元テーブルを作る前処理
fac = [0]*(Max)
finv = [0]*(Max)
inv = [0]*(Max)
fac[0]=fac[1]=1
finv[0]=finv[1]=1
inv[1]=1
for i in range(2,Max):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i]*(mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
#O(1)でmod計算した組合せ数を計算
def Comb(n,r):
    if n < r:
        return 0
    if n < 0 or r < 0 :
        return 0
    return fac[n]*(finv[r]*finv[n-r]%mod)%mod

for i in range(1,K+1):
    print(Comb(K-1,i-1)*Comb(N-K+1,i)%mod)
n, k = map(int, input().split())
a = list(map(int, input().split())) 

ll = [a[0]]

for i in range(1, n):
    cnt = ll[i-1]
    if cnt = a[cnt-1]:
        print(cnt)
        exit()
    if a[cnt-1] == a[0]:
        break
    else:
        ll.append(a[cnt-1])

print(ll[k%3-1])


### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(lambda x: int(x) - 1, input().split()))

done = [-1]*N
done[0] = 0

tmp = 0
done[0] = 0
for k in range(1, K + 1):
    tmp = A[tmp]
    if done[tmp] >= 0:
        for _ in range((K - done[tmp]) % (k - done[tmp])):
            tmp = A[tmp]
        print(tmp + 1)
        exit()
    else:
        done[tmp] = k
print(tmp + 1)
n = int(input())
as = list(map(int, input().split()))

r = 0
i = 1
while True:
  f = False
  for a in as:
    if a%2 == 0:
      a /= 2
      r += 1
      f = True
  if not f:
    break
print(r)
  

### FIXED CODE ###

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

r = 0
i = 1

while True:
  f = False
  for a in aas:
    if a%2**i == 0:
      r += 1
      f = True
  if not f:
    break
  i += 1
print(r)
b = input()
if b == T:
  print A
elif b == A:
  print T
elif b == G:
  print C
else:
  print G

### FIXED CODE ###

b = input()
if b == "T":
  print ("A")
elif b == "A":
  print ("T")
elif b == ("G"):
  print ("C")
else:
  print ("G")
N = int(input())
A = list(map(int,input().split()))

from fractions import gcd

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

b = 0

for i in A:
    b += lcm_list(A)/i
print(int(b)%(10**9+7))


### FIXED CODE ###

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

import fractions

##def lcm_base(x, y):
##    return (x * y) // fractions.gcd(x, y)

##def lcm_list(numbers):
##    return reduce(lcm_base, numbers, 1)

ans = A[0]
for i in range(1, N):
    ans = ans * A[i] // fractions.gcd(ans, A[i])

b = 0

for i in A:
##    b += lcm_list(A)/i
    b += ans//i
print(int(b)%(10**9+7))
from math import *
a,b,c = map(int,input().split())
c = radians(c)
S = a*b*sin(c)/2
print("%f %f %f" %(S,sqrt(a*a+b*b-2*a*b*cos(c),2*S/a )))


### FIXED CODE ###

from math import *
a,b,c = map(int,input().split())
c = radians(c)
S = a*b*sin(c)/2
print("%.10f %.10f %.10f" %(S,a+b+sqrt(a*a+b*b-2*a*b*cos(c)),2*S/a ))
N, M = map(int, input().split())
ans = [-1]*N
for i in range(M):
    s, c = map(int, input().split())
    if ans[s-1] == -1:
        ans[s-1] = c
    elif ans[s-1] != c:
        print(-1)
        break

if len(ans) == 1:
    print(0)
else:
    if ans[0] == 0:
        print(-1)
    elif ans[0] == -1:
        ans[0] = 1
        for i in range(1, M):
            if ans[i] == -1:
                ans[i] = 0
        print(int(''.join(map(str,ans))))

### FIXED CODE ###

N, M = map(int, input().split())
ans = [-1]*N
for i in range(M):
    s, c = map(int, input().split())
    if ans[s-1] == -1:
        ans[s-1] = c
    elif ans[s-1] != c:
        print(-1)
        exit()
if N == 1:
    if ans[0] == -1:
        print(0)
    else:
        print(int(''.join(map(str,ans))))
else:
    if ans[0] == 0:
        print(-1)
        exit()
    elif ans[0] == -1:
        ans[0] = 1
    for i in range(N):
        if ans[i] == -1:
            ans[i] = 0
    print(int(''.join(map(str,ans))))
s=list(input())
    s.sort()
    if s[0] == s[1] and s[2]==s[3] and s[0]!=s[2]:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

s=list(input())
s.sort()
if s[0] == s[1] and s[2]==s[3] and s[0] != s[2]:
    print("Yes")
else:
    print("No")
a=map(int,input().split())
print("Even" if (a[0]*a[1])%2==0 else "Odd")

### FIXED CODE ###

a,b=map(int,input().split())
print("Even" if (a*b)%2==0 else "Odd")
N, K = map(int, input().split())
As = list(map(int, input().split()))
As = [A-1 for A in As]
Vs = [-1]*N
p = 0
p0 = -1
Rs = [p]
Vs[p] = p
for i in range(N):
  n = As[p]
  Rs.append(n)
  if not Vs[n] < 0:
    p0 = Vs[n]
    break
  p = n
  Vs[p] = p
#print(Rs, p0)
if K <= p0:
  r = Rs[K]
else:
  r = Rs[p0+(K-p0)%(len(Rs)-p0+1)]
print(r+1)


### FIXED CODE ###

N, K = map(int, input().split())
As = list(map(int, input().split()))
As = [A-1 for A in As]
Vs = [False]*N
p = 0
Rs = [p]
Vs[p] = True
for i in range(N+3):
  n = As[p]
  Rs.append(n)
  if Vs[n]:
    break
  p = n
  Vs[p] = True
p0 = Rs.index(Rs[-1])
#print(Rs, p0)
if K <= p0:
  r = Rs[K]
else:
  r = Rs[p0+(K-p0)%(len(Rs)-p0-1)]
print(r+1)
import numpy as np

def solve(n, a, b):
  ab = [(ai, bi) for ai, bi in zip(a, b) if ai < bi]
  dp = [[j for j in range(n+1)] for i in range(len(ab)+1)]
  if len(ab) == 0:
    return n
  if len(ab) == 1:
    a0, b0 = ab[0]
    return (n//a0)*b0 + n%a0
  if len(ab) == 2:
    a0, b0 = ab[0]; a1, b1 = ab[1]
    if a0 < a1: a0, b0, a1, b1 = a1, b1, a0, b0
    t = n // a0
    return max(((n-a0*i)//a1)*b1 + (n-a0*i)%a1 + i*bi for i in range(t+1))
  else:
    dp = np.arange(n+1)
    for ai, bi in ab:
      dp[ai:] = np.maximum(dp[ai:], dp[:-ai]+bi)
    return dp[-1]

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

N = solve(N, A, B)
N = solve(N, B, A)
print(N)

### FIXED CODE ###

def solve(n, a, b):
  ab = [(ai, bi) for ai, bi in zip(a, b) if ai < bi]
  if len(ab) == 0:
    return n
  elif len(ab) == 1:
    a0, b0 = ab[0]
    return (n//a0)*b0 + n%a0
  elif len(ab) == 2:
    (a0, b0), (a1, b1) = ab
    if b0/a0 < b1/a1:
      a0, b0, a1, b1 = a1, b1, a0, b0
    return max(((n-a1*i)//a0)*b0 + (n-a1*i)%a0 + i*b1 for i in range(a0))
  else:
    dp = [j for j in range(n+1)]
    for ai, bi in ab:
      for j in range(ai, n+1):
        dp[j] = max(dp[j], dp[j-ai]+bi)
    return dp[-1]

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

N = solve(N, A, B)
N = solve(N, B, A)
print(N)
n=int(input())
a=[]
r=[]
for i in input().split():
  a.append(int(i))
a.sort()
t=a[-1]
b=a[0]
for i in a[1:-1]:
  if i>=0:
    r.append([b,i])
    b=b-i
  else:
    r.append([t,i])
    t=t-i
print(t-b)
for i in r:
  print(r[0],r[1])


### FIXED CODE ###

n=int(input())
a=[]
r=[]
for i in input().split():
  a.append(int(i))
a.sort()
t=a.pop(-1)
b=a.pop(0)
for i in a:
  if i>=0:
    r.append([b,i])
    b=b-i
  else:
    r.append([t,i])
    t=t-i
print(t-b)
r.append([t,b])
for i in r:
  print(i[0],i[1])
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for i in range(1, len(A)):
    A[i] += A[i - 1]
for i in range(1, len(B)):
    B[i] += B[i - 1]
A.insert(0, 0)
B.insert(0, 0)
r = 0
for i, a in enumerate(A):
    min_idx = 0
    max_idx = len(B) - 1
    while min_idx < max_idx:
        j = (min_idx + max_idx + 1) // 2
        k = K - A[i] - B[j]
        if k < 0:
            max_idx = j - 1
        else:
            min_idx = j
    while K - A[i] - B[j + 1] >= 0:
        j += 1
    k = K - A[i] - B[j]
    if k >= 0:
        r = max(r, i + j)
print(r)

### FIXED CODE ###

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for i in range(1, len(A)):
    A[i] += A[i - 1]
for i in range(1, len(B)):
    B[i] += B[i - 1]
A.insert(0, 0)
B.insert(0, 0)
r = 0
for i, a in enumerate(A):
    min_idx = 0
    max_idx = len(B) - 1
    while min_idx < max_idx:
        j = (min_idx + max_idx + 1) // 2
        k = K - A[i] - B[j]
        if k < 0:
            max_idx = j - 1
        else:
            min_idx = j
    j = min_idx
    while j + 1 < len(B) and K - A[i] - B[j + 1] >= 0:
        j += 1
    if K - A[i] - B[j] >= 0:
        r = max(r, i + j)
print(r)
from queue import Queue
from collections import deque

H, W = map(int, input().split())
C = list(map(int, input().split()))
D = list(map(int, input().split()))
S = ["##"+input()+"##" for _ in range(H)]
for i in range(2):
    S.insert(0, "#"*(W+4))
    S.append("#"*(W+4))

inf = int(1e9)
cost = [[inf for _ in range(W+4)] for _ in range(H+4)]
cost0 = deque()
ans = -1

cost0.append((C[0]+1, C[1]+1, 0))
cost[C[0]+1][C[1]+1] = 0

move = [(1, 0), (0, 1), (-1, 0), (0, -1)]
warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)]+move]

cost1 = deque()

while cost0:
    h, w, c = cost0.popleft()
    cost1.append((h, w, c))

    for i, j in move:
        dh = h+i
        dw = w+j
        if S[dh][dw] == "." and c < cost[dh][dw]:
            cost[dh][dw] = c
            cost0.appendleft((dh, dw, cost[dh][dw]))

    while cost1:
        h, w, c = cost1.popleft()
        for i, j in warp:
            dh = h+i
            dw = h+j
            if S[dh][dw] == "." and c+1 < cost[dh][dw]:
                cost[dh][dw] = c+1
                cost0.append((dh, dw, cost[dh][dw]))

    if cost[D[0]+1][D[1]+1] != inf:
        ans = cost[D[0]+1][D[1]+1]

print(ans)


### FIXED CODE ###

from collections import deque


def solve():
    H, W = map(int, input().split())
    CH, CW = map(int, input().split())
    DH, DW = map(int, input().split())
    S = ["##"+input()+"##" for _ in range(H)]
    for i in range(2):
        S.insert(0, "#"*(W+4))
        S.append("#"*(W+4))

    inf = int(1e9)
    cost = [[inf for _ in range(W+4)] for _ in range(H+4)]
    cost0 = deque()
    ans = -1

    cost0.append((CH+1, CW+1, 0))
    cost[CH+1][CW+1] = 0

    move = [(1, 0), (0, 1), (-1, 0), (0, -1)]
    warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)]+move]

    cost1 = deque()

    while cost0:
        h, w, c = cost0.popleft()
        cost1.append((h, w, c))

        for i, j in move:
            dh = h+i
            dw = w+j
            if S[dh][dw] == "." and c < cost[dh][dw]:
                cost[dh][dw] = c
                cost0.appendleft((dh, dw, cost[dh][dw]))

        if len(cost0) == 0:
            while cost1:
                h, w, c = cost1.popleft()
                for i, j in warp:
                    dh = h+i
                    dw = w+j
                    if S[dh][dw] == "." and c+1 < cost[dh][dw]:
                        cost[dh][dw] = c+1
                        cost0.append((dh, dw, cost[dh][dw]))

        if cost[DH+1][DW+1] != inf:
            ans = cost[DH+1][DW+1]

    print(ans)


if __name__ == "__main__":
    solve()
a, b = map(int, input().split())
if a%3==0 or b%==0 of (a+b)%==0:
    print('Possible')
else:
    print('Impossible')

### FIXED CODE ###

a, b = map(int, input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
    print('Possible')
else:
    print('Impossible')
n = list(int(i) in input().split())
n.sort()
if n[0]+n[1]==n[2]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n=list(int(i) for i in input().split())
n.sort()
if n[0]+n[1]==n[2]:
    print("Yes")
else:
    print("No")
n = int(input())
h = list(map(int, input().split()))
gap = [0]
mt = []
va = []
i = 0
while i+1 <= len(h)-1:
    if h[i+1]-h[i] != 0:
        gap.append(h[i+1]-h[i])
        i += 1
    else:
        h.pop(i+1)
for i in range(h):    
    if gap[i] >= 0: 
        if gap[i+1] < 0:
            mt.append(h[i])
    else:
        if gap[i+1] > 0:
            va.append(h[i])
if gap[-1] > 0 :
    mt.append(h[-1])
if mt == []:
    mt.append(h[0])
ans = 0
for x in mt:
    ans += x
for x in va:
    ans -= x
print(ans)

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
gap = [0]
mt = []
va = []
i = 0
while i+1 <= len(h)-1:
    if h[i+1]-h[i] != 0:
        gap.append(h[i+1]-h[i])
        i += 1
    else:
        h.pop(i+1)
for i in range(len(h)-1):    
    if gap[i] >= 0: 
        if gap[i+1] < 0:
            mt.append(h[i])
    else:
        if gap[i+1] > 0:
            va.append(h[i])
if gap[-1] > 0 :
    mt.append(h[-1])
if mt == []:
    mt.append(h[0])
ans = 0
for x in mt:
    ans += x
for x in va:
    ans -= x
print(ans)
import sys
H, W, M = map(int, sys.stdin.readline().split())
hlst = [0]*(H+1)
wlst = [0]*(M+1)
hwlst = []

for i in :
    h, w = map(int, sys.stdin.readline().split())
    hlst[h] += 1
    wlst[w] += 1
    hwlst.append([h,w])

hmax = max(hlst)
wmax = max(wlst)
ans = hmax + wmax -1
c = False
i = 0
for i in range(H+1):
    if hlst[i] == hmax:
        for j in range(W+1):
            if wlst[j] == wmax:
                if [i, j] not in hwlst:
                    ans += 1
                    c = True
            if c:
                break
    if c:
        break
    
print(ans)

### FIXED CODE ###

import sys
H, W, M = map(int, sys.stdin.readline().split())
hlst = {}
wlst = {}
hwlst = []

for i in range(M):
    h, w = sys.stdin.readline().split()
    if h in hlst:
        hlst[h] += 1
    else:
        hlst[h] = 1

    if w in wlst:
        wlst[w] += 1
    else:
        wlst[w] = 1

    hwlst.append([h, w])

h = max(hlst.values())
w = max(wlst.values())
hmax = [i for i in hlst if hlst[i] == h]
wmax = [i for i in wlst if wlst[i] == w]
num = len(hmax)*len(wmax)
ans = h + w -1


for i in hwlst:
    if hlst[i[0]] == h and wlst[i[1]] == w:
        num -= 1

if num == 0:
    print(h+w-1)
else:
    print(h+w)
x = int(input())
b = int(input())
c = int(input())
x -= a
x -= b*x//b
print(x)

### FIXED CODE ###

x = int(input())
a = int(input())
b = int(input())
x -= a
x -= b*(x//b)
print(x)
S = list(input())
print(String(S[0:3]))


### FIXED CODE ###

S = input()
print(S[0:3])
import heapq
n,m = map(int, input().split())
job_list = []
for i in range(n):
    a,b = map(int, input().split())
    job_list.append((a,b))

hq = []
max_income = 0
j = 0
for i in range(1,m+1):
    while j < n and job_list[j][0] <= i:
        heapq.heappush(hq, (-job_list[j][1],job_list[j][0]))
    if len(hq) < 1:
        continue
    b_i, a_i = heapq.heappop(hq)
    max_income += -b_i

print(max_income)

### FIXED CODE ###

a,b = map(int,input().split())
print(max(a+b,a-b,a*b))
while 1:
    h,w = map(int, raw_input().split())

    if h == 0 and w == 0:
    break

    for i in range(h):
        if i == 0 or i == (h-1):
            print "#" * w
        else :
            print "#" + "." *(w-2)+"#"
        print ""

### FIXED CODE ###

while(True):
    H, W = map(int, raw_input().split())
    if(H == 0 and W == 0):
        break
    for i in range(H):
        if(i == 0 or i == (H - 1)):
            print("#" * W)
        else:
            print("#" + "." * (W - 2) + "#")
    print("")
a,b=(int(x) for x int(input().split()))
if a-b!=0:
  t=max(a,b)
  print(2*t-1)
else:
  print(a+b)
  

### FIXED CODE ###

a,b=map(int,input().split())
if a-b!=0:
  t=max(a,b)
  print(2*t-1)
else:
  print(a+b)
import math 
n,x = map(int,input().split())
ls = list(map(int,input().split()))
new = [0]*n
for i in range(n):
    new[i] = abs(ls[i]-x)
ans = new[0]
for j in range(1,n):
    ans = math.gcd(ans,new[j])
print(ans)

### FIXED CODE ###

from fractions import gcd
n,x = map(int,input().split())
ls = list(map(int,input().split()))
new = [0]*n
for i in range(n):
    new[i] = abs(ls[i]-x)
ans = new[0]
for j in range(1,n):
    ans = gcd(ans,new[j])
print(ans)
import math
I() = input()
II() = int(input())
MII() = map(int, input().split())
LMII() = list(map(int, input().split()))

n, r = MII()
print(r+100*max((10-k), 0))

### FIXED CODE ###

import math
def I():
  return input()
def II():
  return int(input())
def MII():
  return map(int, input().split())
def LMII():
  return list(map(int, input().split()))

n, r = MII()
print(r+100*max((10-n), 0))
n,m = map(int,input().split())

li = [[] for i in range(n+10)]
memo = [0 for i in range(m+10)]

def search(p,y):
    fst = 0
    lst = len(li[p])-1

    while(fst <= lst):
        mid = (fst+lst)//2
        if li[p][mid] == y:
            return mid

        elif li[p][mid] < y:
            fst = mid+1
        
        elif li[p][mid] > y:
            lst = mid-1


for i in range(m):
    p,y=map(int,input().split())
    memo[i] = [p,y]
    li[p].append(y)

for i in range(n):
    li[i].sort()

for i in range(m):
    a = memo[i][0]
    b = search(memo[i][0],memo[i][1])
    print("{:0>6}".format(a),end ="")
    print("{:0>6}".format(b+1))





### FIXED CODE ###

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

li = [[] for i in range(n)]
memo = [0 for i in range(m)]

def search(p,y):
    fst = 0
    lst = len(li[p])-1

    while(fst <= lst):
        mid = (fst+lst)//2
        if li[p][mid] == y:
            return mid

        elif li[p][mid] < y:
            fst = mid+1
        
        elif li[p][mid] > y:
            lst = mid-1


for i in range(m):
    p,y=map(int,input().split())
    p-=1
    memo[i] = [p,y]
    li[p].append(y)

for i in range(n):
    li[i].sort()

for i in range(m):
    a = memo[i][0]+1
    b = search(memo[i][0],memo[i][1])
    print("{:0>6}".format(a),end ="")
    print("{:0>6}".format(b+1))