Harryxun/stf_run huggingface dataset:
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

def opt(a, b):
    c = gcd(a, b)
    return a//c, b//c

def dot(A, B):
    a = A[0] * B[0]
    b = A[1] * B[1]
    return opt(a, b)

def add(A, B):
    return opt(A[0]*B[1] + B[0]*A[1], A[1] * B[1])

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

A = opt(A, 100)
B = opt(B, 100)
C = opt(C, 100)

g = 1000000007

c = [((1, 1), 0, 0, 0)]
ans = (0, 1)
e = (0, 1)
pi = 0
while pi < len(c):

    PQ, cnt, acnt, bcnt = c[pi]
    pi += 1

    if e[1] > (e[1] - e[0]) * g * 100:
        continue
    if acnt >= N or bcnt >= N:
        e = add(e, PQ)
        ans = add(ans, opt(cnt * PQ[0], PQ[1]))
        continue

    cnt += 1
    c.append((dot(PQ, A), cnt, acnt+1, bcnt))
    c.append((dot(PQ, B), cnt, acnt, bcnt+1))
    c.append((dot(PQ, C), cnt, acnt, bcnt))


print(ans[0] * pow(ans[1], g-2,g)%g)



### FIXED CODE ###

N = int(input())
print("{:.0f}".format((180 -  360 / N) * N))
from collections import deque
s = input()
q = int(input())
ans = deque(s)
rev = 0
for i in range(q):
    qi = input()
    if qi[0] == '1':
        rev += 1
    else:
        if qi[2] == '1' and rev % 2 == 0:
            ans.appendleft(qi[4])
        elif qi[2] == '2' and rev % 2 == 0:
            ans.append(qi[4])
        if qi[2] == '1' and rev % 2 == 1:
            ans.append(qi[4])
        elif qi[2] == '2' and rev % 2 == 1:
            ans.appendleft(qi[4])

parity = rev % 2
if parity:
    for i in ans[::-1]:
        print(i, end='')
else:
    for i in ans:
        print(i, end='')

### FIXED CODE ###

from collections import deque
s = input()
q = int(input())
ans = deque(s)
rev = 0
for i in range(q):
    qi = input()
    if qi[0] == '1':
        rev += 1
    else:
        if qi[2] == '1' and rev % 2 == 0:
            ans.appendleft(qi[4])
        elif qi[2] == '2' and rev % 2 == 0:
            ans.append(qi[4])
        if qi[2] == '1' and rev % 2 == 1:
            ans.append(qi[4])
        elif qi[2] == '2' and rev % 2 == 1:
            ans.appendleft(qi[4])

parity = rev % 2
if parity:
    ans.reverse()
    for i in ans:
        print(i, end='')
else:
    for i in ans:
        print(i, end='')
while True:
    import itertools
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0:
        break
    print([1 if sum(n, x) == x else 0 for i in itertools.combinations(range(1, n + 1), 3)])

### FIXED CODE ###

while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break

    count = 0
    for s in range(1, n - 1):
        for m in range(s + 1, n):
            for e in range(m + 1, n + 1):
                if x == sum([s, m, e]):
                    count += 1

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

w = [[0] for _ in range(10000)]

for i in range(n):
  a, b = map(int, input().split())
  w[a-1].append(b)

money = 0
l = []
for i in range(m):
  l += w[i]
  if len(l) == 0:
    continue
  
  x = max(l)
  l.remove(x)
  money += x

print(money)

### FIXED CODE ###

from heapq import heappush, heappop

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

w = [[] for _ in range(10**5)]

for i in range(n):
  a, b = map(int, input().split())
  w[a-1].append(b)

money = 0
l = []
for i in range(m):
  for item in w[i]:
    heappush(l, item * (-1))
  if len(l) == 0:
    continue

  money += heappop(l) * (-1)

print(money)
t = []
for i in range(5):
    t.append(int(input()))

s = []
for i in range(5):
    s.append(t[i] % 10)

p = 10
for i in range(5):
    if s[i] > 0:
        if p > s[i]:
            o = i
            p = s[i]

m = 0
for i in range(5):
    if i != o:
        if s[i] == 0:
            m += t[i]
        else:
            m += t[i] - t[i] % 10 + 10

m += t[o]
print(m)

### FIXED CODE ###

t = []
for i in range(5):
    t.append(int(input()))

s = []
for i in range(5):
    s.append(t[i] % 10)

o = 5
p = 10
for i in range(5):
    if s[i] > 0:
        if p > s[i]:
            o = i
            p = s[i]

m = 0
for i in range(5):
    if i != o:
        if s[i] == 0:
            m += t[i]
        else:
            m += t[i] - t[i] % 10 + 10

if o != 5:
    m += t[o]
print(m)
x, y = map(int, input().split())
count = 0

for a in range(x+1):
  b = x - a
  if y = a * 2 + b * 4:
    count += 1
if count == 0:
  print("No")
else:
  print('Yes')

### FIXED CODE ###

x, y = map(int, input().split())
count = 0

for a in range(x+1):
  b = x - a
  if y == a * 2 + b * 4:
    count += 1
if count == 0:
  print("No")
else:
  print('Yes')
a = 1

while True:  
  x = raw_input('Case a: ','b')
  
  a += 1
  b = input()
  
  if we have 0
    break
    
      print(x)
    
    

### FIXED CODE ###

count = 0

while True:  
 
  x = raw_input()
  
  count += 1
   
  if x == '0':
    break
    
  print('Case ' + str(count) + ': ' + x)
a = int(input())
b = int(input())
c = int(input())

if a < b < c:
print("Yes")
elif a > b > c:
print("No")

### FIXED CODE ###

a, b, c = map(int, input().split())

if a < b < c:
    print("Yes")
else:
    print("No")
#coding: utf-8

n = raw_input()

def keitai(n1,n2):
    li1 = ['.', ',', '!', '?',' '] 
    li2 = ['a','b','c']
    li3 = ['d','e','f']
    li4 = ['g','h','i']
    li5 = ['j','k','l']
    li6 = ['m','n','o']
    li7 = ['p','q','r','s']
    li8 = ['t','u','v']
    li9 = ['w','x','y','z']
    li = [li1,li2,li3,li4,li5,li6,li7,li8,li9]
    lis = li[n1 - 1]
    n2 = n2 % len(lis)
    a = lis[n2 - 1]
    return a

for k in range(n):
    a = str(raw_input())
    num = 0
    string = ''
    for i in range(len(a)):
        if int(a[i]) == 0:
            string = string + keitai(b,num)
            num = 0
        else:
            num = num + 1
            b = int(a[i])
    print string

### FIXED CODE ###

#coding: utf-8
 
n = int(raw_input())
 
def keitai(n1,n2):
    li1 = ['.', ',', '!', '?',' '] 
    li2 = ['a','b','c']
    li3 = ['d','e','f']
    li4 = ['g','h','i']
    li5 = ['j','k','l']
    li6 = ['m','n','o']
    li7 = ['p','q','r','s']
    li8 = ['t','u','v']
    li9 = ['w','x','y','z']
    li = [li1,li2,li3,li4,li5,li6,li7,li8,li9]
    lis = li[n1 - 1]
    n2 = n2 % len(lis)
    a = lis[n2 - 1]
    return a
 
for k in range(n):
    a = str(raw_input())
    num = 0
    string = ''
    for i in range(len(a)):
        if int(a[i]) == 0:
            if num != 0:
                string = string + keitai(b,num)
                num = 0
            else:
                pass
        else:
            num = num + 1
            b = int(a[i])
    print string
s = input()

ans = 0
for i in range(0, 3):
	if s[i] == 'R':
      ans += 1
      
if ans == 2 and s[1] == 'S':
  	ans -= 1
    
print(ans)

### FIXED CODE ###

s = input()
 
ans = 0
for i in range(0, 3):
	if s[i] == 'R':
			ans += 1
      
if ans == 2 and s[1] == 'S':
  	ans -= 1
    
print(ans)
n,k= (map(int,input().split()))
a = input().split()
cost = [0]*n
c1 = 0
c2 =0
for i in range(n):
    a[i] = int(a[i])
    if(i==0):
        cost[i] =0
    elif(k>i):
        
        mini = 10**5
        change = 0
        for j in range(i):
            change = abs(a[i] - a[j]) + cost[j]
            # print(change)
            if(mini > change):
                mini = change

        cost[i] = mini
    else:
       
        mini = 10**5
        change = 0
        for j in range(1,k+1):
            change = abs(a[i] - a[i-j]) + cost[i-j]
            if(mini > change):
                mini = change
            # print(change)
        cost[i] = mini


# print(a)
# print(cost)
print(cost[n-1])

### FIXED CODE ###

n= int(input())
a = input().split()
cost = [0]*n
c1 = 0
c2 =0
for i in range(n):
    a[i] = int(a[i])
i = 0
for i in range(1,n):
    if(i==1):
        cost[i] = abs(a[i] - a[i-1])
    else:
        c1 = abs(a[i] - a[i-1]) + cost[i-1]
        c2 = abs(a[i] - a[i-2]) + cost[i-2]
        cost[i] = min(c1,c2)

print(cost[n-1])
c = 10**9+7

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

def combinations_count_mod(n, r, c):
  r = min(n-r,r)
  if r == 0: return 1
  ret = 1
  for j in range(r):
    ret *= (n-j)/(r-j) % c
  return ret

for i in range(1, k+1):
  a = combinations_count_mod(k-1, i-1, c) 
  if n-k >= i-1:
    b = (combinations_count_mod(n-k+1, i, c))
  else:
    b = 0
  print(int((a*b) % c))


### FIXED CODE ###

import math
c = 10**9+7

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

def combinations_count(n, r):
  if n <= r:
    return 1
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(1, k+1):
  a = combinations_count(k-1, i-1) 
  if n-k >= i-1:
    b = combinations_count(n-k+1, i)
  else:
    b = 0
  print(int((a*b) % c))
import bisect
N=input()
S=list(input())
alphabet=[[] for _ in range(26)]
for i,s in enumerate(S):
    alphabet[ord(s)-ord('a')].append(i)
Q=int(input())
for _ in range(Q):
    Type,A,B=input().split()
    if Type=="1":
        A=int(A)
        s=S[A-1]
        if s==B:
            continue
        o=ord(s)-ord("a")
        alphabet[o].pop(bisect.bisect_left(alphabet[o],A-1))
        index=bisect.bisect(alphabet[o],A-1)
        #alphabet[o]=alphabet[o][:index]+[A-1]+alphabet[o][index:]
        #bisect.insort(alphabet[o],A-1)
        alphabet[B-1].insert(index,A-1)
        S[A-1]=B
    else:
        A=int(A)
        B=int(B)
        ans=0
        for i in range(26):
            indexL=bisect.bisect_left(alphabet[i],A-1)
            #indexR=bisect.bisect_right(alphabet[i],B-1)
            #ans+=(indexL!=indexR)
            if indexL==len(alphabet[i]):
                continue
            ans+=(alphabet[i][indexL]<=B-1)
        print(ans)


### FIXED CODE ###

from bisect import bisect_left

n = int(input())
s = list(input())
q = int(input())
query = [input() for _ in range(q)]

p = [[] for _ in range(26)]

for i, x in enumerate(s):
    p[ord(x) - ord('a')].append(i)

for x in query:
    a, b, c = x.split()
    #print(c)
    if a == '1':
        b = int(b) - 1
        if s[b] == c:
            continue
        d = ord(s[b]) - ord('a')
        e = ord(c) - ord('a')
        temp = bisect_left(p[d], b)
        p[d].pop(temp)
        temp = bisect_left(p[e], b)
        p[e].insert(temp, b)
        s[b] = c
    else:
        b = int(b) - 1
        c = int(c) - 1
        #print(b, c)
        ans = 0
        for i in range(26):
            L = bisect_left(p[i], b)
            if L >= len(p[i]):
                continue
            if p[i][L] <= c:
                ans += 1
        print(ans)
N=(input())
a = len(N)
if N[a-3]+N[a-2]+N[a-1] =='000':
    print(0)
    
else:
    if a>=3:
        x = int(N[a-3]+N[a-2]+N[a-1])
        print(1000-x)
    elif a==2:
        x = int(N[a-2]+N[a-1])
        print(1000-x)
    else :
        x = int(N[a-1])
        print(1000-x)


### FIXED CODE ###

N=int((input()))

if N%1000==0:
    print(0)
    
else:
  N=str(N)
  a = len(N)
  if a>=3:
        x = int(N[a-3]+N[a-2]+N[a-1])
        print(1000-x)
  elif a==2:
        x = int(N[a-2]+N[a-1])
        print(1000-x)
  else :
        x = int(N[a-1])
        print(1000-x)
import sys
import math
import numpy as np

if __name__ == '__main__':
    H, W, M = list(map(lambda x: int(x), sys.stdin.readline().split()))

    dic = {}
    # h = [0 for i in range(H)]
    # w = [0 for i in range(W)]
    h = np.zeros(H, dtype=np.int64)
    w = np.zeros(W, dtype=np.int64)
    for i in range(M):
        # P.append(list(map(lambda x: int(x), sys.stdin.readline().split())))
        x, y = list(map(lambda x: int(x), sys.stdin.readline().split()))
        x -= 1
        y -= 1
        h[x] += 1
        w[y] += 1
        dic[x*H+y] = 1
    
    lh = np.where(h == h.max())
    lw = np.where(w == w.max())

    mx = np.max(h)
    my = np.max(w)
    # print(mx, my)

    # print(lh[0])
    # print(lw[0])

    max = 0
    for i in lh[0]:
        for j in lw[0]:
            tmp = h[i] + w[j]
            if i*H+j in dic:
                tmp -= 1
            if tmp > max:
                max = tmp
    print(max)


    # for i in lh[0]:
    #     for j in lw[0]:
    #         if i*H+j not in dic:
    #             print(i, j)
    #             break
    # else:
    #     print(mx+my, 'hi')
    #     exit()
    
    # print(mx+my-1)
    # exit()

### FIXED CODE ###

import sys
import math
import numpy as np

if __name__ == '__main__':
    H, W, M = list(map(lambda x: int(x), sys.stdin.readline().split()))

    dic = {}
    # h = [0 for i in range(H)]
    # w = [0 for i in range(W)]
    h = np.zeros(H, dtype=np.int64)
    w = np.zeros(W, dtype=np.int64)
    for i in range(M):
        # P.append(list(map(lambda x: int(x), sys.stdin.readline().split())))
        x, y = list(map(lambda x: int(x), sys.stdin.readline().split()))
        x -= 1
        y -= 1
        h[x] += 1
        w[y] += 1
        dic[x*H+y] = 1
    
    lh = np.where(h == h.max())
    lw = np.where(w == w.max())

    mx = np.max(h)
    my = np.max(w)
    # print(mx, my)

    # print(lh[0])
    # print(lw[0])


    tmp = mx + my
    for i in lh[0]:
        for j in lw[0]:
            if i*H+j not in dic:
                print(tmp)
                exit()
    print(tmp-1)
    exit()
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

AB = [(a, i, 0) for i, a in enumerate(A)] + [(b, i, 1) for i, b in enumerate(B)]
AB.sort()

X = AB[:N]
Y = AB[N:]

if any(x[0] == y[0] for x, y in zip(X, Y)):
    print('No')
    exit()

ans = [-1] * N
swap = []

for (_, i, sx), (_, j, sy) in zip(X, Y):
    if sx == sy:
        swap.append((min(i, j), max(i, j)))
    else:
        if sx == 0:
            ans[i] = B[j]
        else:
            ans[j] = B[i]

from collections import Counter
assert max(Counter(swap).values()) == 2 or len(swap) == 0, 'error'

print('Yes')
print(*ans)


### FIXED CODE ###

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

AB = [(a, i, 0) for i, a in enumerate(A)] + [(b, i, 1) for i, b in enumerate(B)]
AB.sort()

X = AB[:N]
Y = AB[N:]

if any(x[0] == y[0] for x, y in zip(X, Y)):
    print('No')
    exit()

swapA = []
swapB = []
ans = [-1] * N

for (_, i, sx), (_, j, sy) in zip(X, Y):
    if sx == sy == 0:
        swapA.append((i, j))
    elif sx == sy == 1:
        swapB.append((i, j))
    else:
        if sx == 0:
            ans[i] = B[j]
        else:
            ans[j] = B[i]

for (i, j), (x, y) in zip(swapA, swapB):
    ans[i] = B[x]
    ans[j] = B[y]

    if A[i] == ans[i] or A[j] == ans[j]:
        ans[i], ans[j] = ans[j], ans[i]

print('Yes')
print(*ans)
N = int(input())
if N % 2 ==0:
  ans = 0.5
else:
  ans = (N+1)/2N
print(ans)

### FIXED CODE ###

N = int(input())
if N % 2 ==0:
  ans = 0.5
else:
  ans = (N+1)/(2*N)
print(ans)
# -*- coding: utf-8 -*-
from collections import deque
from heapq import heappush, heappop, heapify, merge
from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)
def inpl(): return tuple(map(int, input().split()))
 
N, M = inpl()
A = inpl()
tree = [[-1, 1]  for _ in range(N)] # [next, rank]

def find(i):
    if tree[i][0] == -1:
        group = i
    else:
        group = find(tree[i][0]) 
        tree[i][0] = group
    return group
  
def unite(x, y):
    px = find(x)
    py = find(y)
      
    if tree[px][1] == tree[py][1]: # rank is same
        tree[py][0] = px
        tree[px][1] += 1
    else:
        if tree[px][1] < tree[py][1]:
            px, py = py, px
        tree[py][0] = px
  
for _ in range(M):
    x, y = tuple(map(int, input().split()))
    if not int(find(x) == find(y)):
        unite(x, y)

D = defaultdict(list)
for n in range(N):
    D[find(n)].append(A[n])

H = []
S = deque([]) # single
for k, v in D.items():
    if len(v) == 1:
        S.append(v)
    else:
        H.append(sorted(v))

heapify(H)

res = 0 
while True:
    if (len(H) == 0) or (len(S) + len(H) <= 1):
        break
    
    if len(S) > 1:
        A = S.popleft()
    else:
        A = heappop(H)

    B = heappop(H)

    res += A[0] + B[0]
    C = list(merge(A[1:], B[1:]))[:len(H)+len(S)+3]

    if len(C) == 1:
        S.append(C)
    else:
        heappush(H, C)

ok = True
if len(S) > 2:
    print("Impossible")
    ok = False
elif len(S) == 2:
    res += S[0][0] + S[1][0]
elif len(S) == 1:
    A = S[0]
    if len(H) == 1:
        B = heappop(H)
        res += A[0] + B[0]
else:
    pass
if ok:
    print(res)

### FIXED CODE ###

# -*- coding: utf-8 -*-
from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)
def inpl(): return tuple(map(int, input().split()))
 
N, M = inpl()
A = inpl()
tree = [[-1, 1]  for _ in range(N)] # [next, rank]
 
def find(i):
    if tree[i][0] == -1:
        group = i
    else:
        group = find(tree[i][0]) 
        tree[i][0] = group
    return group
  
def unite(x, y):
    px = find(x)
    py = find(y)
      
    if tree[px][1] == tree[py][1]: # rank is same
        tree[py][0] = px
        tree[px][1] += 1
    else:
        if tree[px][1] < tree[py][1]:
            px, py = py, px
        tree[py][0] = px
  
for _ in range(M):
    x, y = tuple(map(int, input().split()))
    if not int(find(x) == find(y)):
        unite(x, y)
 
D = defaultdict(list)
for n in range(N):
    D[find(n)].append(A[n])
 
H = []
res = 0 

for k, v in D.items():
    v = sorted(v)
    res += v[0]
    H.extend(v[1:])
 
if N < 2*(N-M-1):
    print("Impossible")
elif M == N-1:
    print(0)
else:
    res += sum(sorted(H)[:2*(N-M-1) - len(D.keys())])
    print(res)
n,a,b=[int(i) for i in input().split()]
x=A*N
if x>=B:
  print(B)
else :
  print(x)


### FIXED CODE ###

n,a,b=map(int,input().split())
print(min(n*a,b))
def gcd(a, b):
  if a > b:
    a, b = b, a
  while a % b != 0:
    a, b = b, a % b
  return b

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

l = A.pop()
for a in A:
  l = gcd(l, a)

print('POSSIBLE' if k % l == 0 and max(A) >= k else 'IMPOSSIBLE')

### FIXED CODE ###

def gcd(a, b):
  if a > b:
    a, b = b, a
  while a % b != 0:
    a, b = b, a % b
  return b

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

g = A[0]
for i in range(1, n):
  g = gcd(g, A[i])

if k in A or max(A) > k and k % g == 0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')
s=input()
if 'AC' in S:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s=input()
if 'AC' in s:
  print("Yes")
else:
  print("No")
def main():
    num = int(input())
    for i in range(num):
        X = " " + input()
        Y = " " + input()
        lx = len(X)
        ly = len(Y)
        max = 0
        XY = [[0] * ly for i in range(lx)]
        for j in range(1,lx):
            for k in range(1,ly):
                if X[j] == Y[k]:
                    XY[j][k] = XY[j-1][k-1] + 1
                elif XY[j-1][k] > XY[j][k-1]:
                    XY[j][k] = XY[j-1][k]
                else:
                    XY[j][k] = XY[j][k-1]
                if max < XY[j][k]:
                    max = XY[j][k]
        print(max)
 f __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    num = int(input())
    A = []
    for i in range(num):
        X = input()
        Y = " " + input()
        lx = len(X)
        ly = len(Y)
        T = [0] * ly
        for j in range(lx):
            xj = X[j]
            C = T[:]
            for k in range(1,ly):
                k1 = k-1
                if xj == Y[k]:
                    T[k] = C[k1] + 1
                elif T[k] < T[k1]:
                    T[k] = T[k1]
        print(T[k])
if __name__ == '__main__':
    main()
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
L = [[int(v) for v in input().split()] for _ in range(M)]

class UnionFind:
    def __init__(self, n):
        self.data = [0] * N
        for i in range(N):
            self.data[i] = i
            
    def get_root(self, x):
        r = self.data[x]
        if r == x:
            return r
        p = self.get_root(r)
        self.data[x] = p
        return p
    
    def unite(self, x, y):
        rx = self.get_root(x)
        ry = self.get_root(y)
        
        if rx != ry:
            self.data[rx] = ry
            
    def same(self, x, y):
        return self.get_root(x) == self.get_root(y)
    
u = UnionFind(N)
for a, b, _ in L:
    u.unite(a - 1, b - 1)
    
s = set()
for i in range(N):
    s.add(u.get_root(i))

print(len(s))

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline

N, M = map(int, input().split())
L = [[int(v) - 1 for v in input().split()] for _ in range(M)]

class UnionFind:
    def __init__(self, n):
        self.data = [0] * N
        for i in range(N):
            self.data[i] = i
            
    def get_root(self, x):
        r = self.data[x]
        if r == x:
            return r
        p = self.get_root(r)
        self.data[x] = p
        return p
    
    def unite(self, x, y):
        rx = self.get_root(x)
        ry = self.get_root(y)
        
        if rx != ry:
            self.data[rx] = ry
            
    def same(self, x, y):
        return self.get_root(x) == self.get_root(y)
    
u = UnionFind(N)
for a, b, _ in L:
    u.unite(a, b)
    
s = set()
for i in range(N):
    s.add(u.get_root(i))

print(len(s))
x = int(input())
a = 0
b = 0
i = 0
flag = 0
while i < 100 :
  c = i**5
  d = (x-c)**0.2
  e = d.is_integer()
  if e == True:
    flag = 1
    b = int(d)
    a = int(i)
    break
  else:
    pass
  i = i + 1
if flag == 0:
  print("impossible")
elif flag == 1:
  print(a,b)

### FIXED CODE ###

x = int(input())
resA = 0
resB = 0
for a in range(500):
  for b in range(-500,500):
    A = a**5
    B = b**5
    N= A-B
    if A-B==x:
      resA = a
      resB = b
      break
    else:
      pass
  if A-B==x:
    break
print(resA,resB)
a, b = map(int, input().split())
if (a + b) % 2 == 0 :
  print ((a + b) / 2)
else :
  print ("IMPOSSIBLE)

### FIXED CODE ###

a, b = map(int, input().split())
if (a + b) % 2 == 0 :
  print ((a + b) // 2)
else :
  print ("IMPOSSIBLE")
n,a,b,c,d=map(int,input().split())
e=abs(b-a)
if c+d+e==0:
    print("YES")
    exit()
upper=(e+(n-1)*d)//(c+d)
lower=(e+(n-1)*c)//(c+d)
if upper==lower:
    if (e+(n-1)*c) % (c+d) == 0 and 0<=lower and (e+(n-1)*c)/(c+d) <= n-1 and e <= (n-1)*max([c,d]):
        print("YES")
        print(2//0)
    else:
        print("NO")
else:
    print("YES")


### FIXED CODE ###

n,a,b,c,d=map(int,input().split())
e=abs(b-a)
if c+d+e==0:
    print("YES")
    exit()
upper=(e+(n-1)*d)//(c+d)
lower=(e+(n-1)*c)//(c+d)
if upper==lower:
    if (e+(n-1)*c) % (c+d) == 0 and 0<=lower and (e+(n-1)*c)/(c+d) <= n-1 and e <= (n-1)*max([c,d]):
        print("YES")
    else:
        print("NO")
else:
  if 0<=lower and (e+(n-1)*c)/(c+d) <= n-1 and e <= (n-1)*max([c,d]):
	    print("YES")
  else:
        print("NO")
a,b = map(int,split())

if a > b:
 print('a > b')
elif a < b:
 print('a < b')
elif a == b:
 print('a == b')

### FIXED CODE ###

a, b = map(int, input().split())
if a < b:
    print('a < b')
elif a > b:
    print('a > b')
else:
    print('a == b')
n = input()
dish = []
for i in range(int(n)):
    tmp = [int(each) for each in input().split()]
    dish.append((tmp[0] - tmp[1], tmp[1] - tmp[0], tmp[0], tmp[1]))

point = [0, 0]

player = 0
while len(dish) > 0:

    sorted(dish, key=lambda v: dish[player], reverse=True)
    point[player] = dish.pop(0)[player + 2]
    player = int(not player)


print(point[0] - point[1])

### FIXED CODE ###

n = input()
dishes = []
for i in range(int(n)):
    tmp = [int(each) for each in input().split()]
    dishes.append((abs(tmp[0] + tmp[1]), tmp[0], tmp[1]))

dishes = sorted(dishes, key=lambda x: x[0], reverse=True)

point = [0, 0]
player = 0
while len(dishes) > 0:
    dish = dishes.pop(0)
    point[player] += dish[player + 1]
    player = int(not player)
print(point[0] - point[1])