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

N,M=(int(x) for x in input().split())
As=sorted([int(x) for x in input().split()])
BC=[]
for _ in range(M):
    BC.append([int(x) for x in input().split()])

BC=sorted(BC, key=lambda x: x[1],reverse=True)
for lst in BC:
    if As[lst[0]-1]<=lst[1]:
        As=sorted([lst[1]]*lst[0]+As[lst[0]:])
    else:
        for i in range(lst[0]):
            if As[i]<lst[1]:
                As[i]=lst[1]
            else:
                break
        As.sort()
print(sum(As))


### FIXED CODE ###

import bisect
N,M=(int(x) for x in input().split())
As=sorted([int(x) for x in input().split()])
BC=[]

result=0
for _ in range(M):
    BC.append([int(x) for x in input().split()])

BC=sorted(BC, key=lambda x: x[1],reverse=True)
now=0
for b,c in BC:
    if now+b-1<=len(As)-1:
        if As[now+b-1]<=c:
            result+=c*b
            now+=b
        else:
            pos=bisect.bisect_left(As[now:],c)
            result+=c*pos
            now+=pos
            break
    else:
        if As[-1]<=c:
            result+=c*(N-now)
            As=[]
        else:
            pos=bisect.bisect_left(As[now:],c)
            result+=c*pos
            now+=pos
        break
        
print(result+sum(As[now:]))
### BUGGY CODE ###

n, m = map(int,input().split())
s = list(map(int, input().split()))
for i in range(m):
    s.sort()
    s[-1] = s[-1]//2
print(sum(s))

### FIXED CODE ###

import heapq

n, m = map(int,input().split())
s = list(map(int, input().split()))
s = list(map(lambda x: x * (-1), s))
heapq.heapify(s)

for i in range(m):
    mx = heapq.heappop(s) * (-1)
    mx = mx//2
    heapq.heappush(s, mx*(-1))
    
print(sum(s)*(-1))
### BUGGY CODE ###

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

s = [1] * len(a)
s[0] = a[0]
for i in range(n - 1):
    s[i + 1] = s[i] * a[i + 1]
    
num = [0] * (len(a) - k + 1)
num[0] = s[k - 1]
for i in range(len(a) - k):
    num[i + 1] = s[i + k] // s[i]
    
for i in range(len(a) - k):
    if num[i] < num[i + 1]:
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

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

for i in range(len(a) - k):
    if a[i] < a[i + k]:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

X,K,D=map(int,input().split())
X=abs(X)
if X-K*D>0:
    print(X-K*D)
else:
    i=0
    while X-D*(K-i)<0:
        i=i+1
    if (K-i)%2==1:
        print(abs(X-D*(i+1)))
    else:
        print(abs(X-D*i))

### FIXED CODE ###

X,K,D=map(int,input().split())
X=abs(X)
if X-K*D>0:
    print(X-K*D)
elif (K-X//D)%2==1:
    print(abs(X%D-D))
else:
    print(X%D)
### BUGGY CODE ###

import fractions

n = int(input())
As = sorted(list(map(int, input().split(" "))))
largest = 1

for i in range(n):
  gcd = 0
  for idx, j in enumerate(As):
    if idx == i:
      continue
    gcd = j if gcd==0 else fractions.gcd(gcd, j)
    if gcd <= largest:
      break
  if gcd > largest:
    largest = gcd
    if largest == As[0] or largest == As[1]:
      break
print(largest)



### FIXED CODE ###

def gcd(a, b):
  l = max(a, b)
  s = min(a, b)
  if s == 0:
    return l
  else:
    return gcd(s, l%s)

n = int(input())
A = [0] + list(map(int, input().split())) + [0]
largest = 0
L = [0 for _ in range(n+2)]
R = [0 for _ in range(n+2)]
for i in range(1, n+2):
  L[i] = gcd(A[i], L[i-1])
  R[n-i+1] = gcd(R[n-i+2], A[n-i+1])

print(max(gcd(L[i-1],R[i+1]) for i in range(1, n+1)))
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=0
for ai in a:
  for bi in b:
    for ci in c:
      if ai<bi and bi<ci:
        ans+=1
print(ans)

### FIXED CODE ###

import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort(),c.sort()
x=len(c)
ans=0
for bi in b:
  xa=bisect.bisect_right(c,bi)
  xb=bisect.bisect_left(a,bi)
  ans+=xb*(x-xa)
print(ans)
### BUGGY CODE ###

from functools import reduce
N = int(input())
A = [int(i) for i in input().split()]
s = reduce(lambda x,y: x*y, A)
if s > 10**18:
    print(-1)
else:
    print(s)

### FIXED CODE ###

from functools import reduce
N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse=True)
if A[-1] == 0:
    print(0)
else:
    s = 1
    for a in A:
        s *= a
        if s == 0:
            print(0)
            break
        if s > 10**18:
            print(-1)
            break
    else:
        print(s)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

h, n = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(n)]
dp = [float("inf")]*(h+1)
dp[0] = 0
for i in range(n):
  a, b = AB[i]
  for j in range(h+1):
    if j <= a:
      dp[j] = min(dp[j], b)
    else:
      dp[j] = min(dp[j], dp[j-a]+b)
print(dp[h])

### FIXED CODE ###

import sys
input = sys.stdin.readline

h, n = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(n)]
dp = [float("inf")]*(h+1)
dp[0] = 0
for i in range(n):
  a, b = AB[i]
  for j in range(h+1):
    if j <= a:
      dp[j] = min(dp[j], b)
    else:
      dp[j] = min(dp[j], dp[j-a]+b)
print(dp[h])
### BUGGY CODE ###

import sys
import math
import bisect
import heapq


def input():
    return sys.stdin.readline().rstrip()


def main():
    H, W = map(int, input().split())
    M = 80
    A = [[0] * W for _ in range(H)]
    K = M * (H + W) + 1
    for i in range(H):
        a = list(map(int, input().split()))
        A[i] = a

    for i in range(H):
        b = list(map(int, input().split()))
        for j in range(W):
            A[i][j] -= b[j]

    dp = [[[False] * K for i in range(W)] for i in range(H)]
    # dp[i][j][k]
    dp[0][0][abs(A[0][0])] = True

    for i in range(H):
        for j in range(W):
            if i != 0:
                for k in range(K):
                    if dp[i - 1][j][k] is True:
                        dp[i][j][abs(k - A[i][j])] = True
                        dp[i][j][abs(k + A[i][j])] = True

            if j != 0:
                for k in range(K):
                    if dp[i][j - 1][k] == True:
                        dp[i][j][abs(k - A[i][j])] = True
                        dp[i][j][abs(k + A[i][j])] = True


    for k in range(K):
        if dp[H-1][W-1][k] ==True:
            print(k)
            exit()

if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
import math
import bisect
import heapq


def input():
    return sys.stdin.readline().rstrip()


def main():
    H, W = map(int, input().split())
    A = [[0] * W for _ in range(H)]
    for i in range(H):
        a = list(map(int, input().split()))
        A[i] = a

    for i in range(H):
        b = list(map(int, input().split()))
        for j in range(W):
            A[i][j] -= b[j]

    dp = [[set() for i in range(W)] for i in range(H)]
    # dp[i][j][k]
    dp[0][0].add(A[0][0])

    for i in range(H):
        for j in range(W):
            if i != 0:
                for k in dp[i-1][j]:
                    dp[i][j].add(abs(k - A[i][j]))
                    dp[i][j].add(abs(k + A[i][j]))
            if j != 0:
                for k in dp[i][j-1]:
                    dp[i][j].add(abs(k - A[i][j]))
                    dp[i][j].add(abs(k + A[i][j]))

    print(min(dp[H-1][W-1]))


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

a, b = map(int, input().split())
nega_cnt = 0
is_zero = False
for x in range(a, b+1):
        if x < 0:
                nega_cnt += 1

        elif x == 0:
                print("Zero")
                is_zero = True

if not is_zero:

        if nega_cnt % 2 == 1:
                print("Negative")
        else:
                print("Positive")
                       

### FIXED CODE ###

a, b = map(int, input().split())
nega_cnt = 0
is_zero = False
if a * b < 0:
        print("Zero")
        is_zero = True
elif b < 0 and (a-b) % 2 == 0:
        print("Negative")
else:
        print("Positive")
### BUGGY CODE ###

from itertools import combinations
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=set()
for i in range(n):
     for j in range(i,n):
          s.add(sum(a[i:j+1]))
x=combinations(s,k)
m=0
for x_ in x:
     p=x_[0]
     for x__ in x_:
          p&=x__
     m=max(m,p)
print(m)

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
s=set()
for i in range(n):
     su=0
     for j in range(i,n):
          su+=a[j]
          s.add(su)
s=list(s)
x=0
for i in range(40):
     x_=x+2**(39-i)
     cnt=0
     for a in s:
          if x_&a==x_:
               cnt+=1
     if cnt>=k:
          x=x_
print(x)
### BUGGY CODE ###

N = int(input())
import numpy as np
#max=int(np.sqrt(N))

for n in range(1,N+1):
    j=0
    min = 1
    max = int(np.sqrt(n/3))+2
    #print(f'max:{max}')
    for x in range(min,max):
        #print(f'max:{max}')
        for y in range(min, max):
            for z in range(min, max):
                if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x > n:
                    break
                if x**2+y**2+z**2+x*y+y*z+z*x==n:
                    #print(f'n!!:{n}')
                    if x == y == z:
                        max=x
                        min=x
                        j += 1
                        #print(x, y, z)
                        #print(f'n:{n}')
                        break
                    if j==0:
                        max = z+1
                        min += 1
                        #min = x
                        #print(x, y, z)
                        #print(f'n:{n}')
                        j += 3
                    # else:
                    #     j += 3

    print(j)

### FIXED CODE ###

n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
	for j in range(1,105):
		for k in range(1,105):
			v = i*i+j*j+k*k+i*j+j*k+k*i;
			if v<10050:
				ans[v]+=1

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

#D    高橋君と見えざる手 / An Invisible Hand
N,T = [int(i) for i in input().split(" ")]
A=[int(i) for i in input().split(" ")]
Max = 0
count = 1
for i in range(N-1,0,-1):
    for j in range(i-1,-1,-1):
        temp = A[i]-A[j]
        if temp>Max:
            Max = temp
            count = 1
        elif temp==Max:
            count +=1

print(count)

### FIXED CODE ###

#D    高橋君と見えざる手 / An Invisible Hand
N,T = [int(i) for i in input().split(" ")]
A=[int(i) for i in input().split(" ")]
Max = 0
count = 1
Min = A[0]
for i in range(N):
    if A[i] <= Min :
        Min = A[i]
    else :
        temp = A[i]-Min
        if temp > Max:
            Max = temp 
            count = 1
        elif temp == Max :
            count += 1
print(count)
### BUGGY CODE ###

import numpy as np
s = input()
S = []
for i in s:
  if i =='B':
    S.append(1)
  else:
    S.append(0)
idx = [i for i,x in enumerate(S) if x ==0]
S = np.array(S)
count = 0
for i in idx:
  count += S[0:i].sum()
  
print(count)

### FIXED CODE ###

s = input()

count = 0
black = 0
for i in s:
  if i=='W':
    count += black
  else:
    black+=1

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

n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]

f = [0]*(n-1)
for i in range(n-1):
    if s[i:i+2] == "AC":
        f[i] = 1

for l, r in lr:
    print(sum(f[l-1:r-1]))

### FIXED CODE ###

n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]

f = [0]*(n)
x = 0
for i in range(n):
    f[i] = x
    if s[i:i+2] == "AC":
        x += 1
        
for l, r in lr:
    print(f[r-1] - f[l-1])
### BUGGY CODE ###

n=int(input(""))
s=0
i=1
while(n>i):
    
    i+=1
    if (n%i!=0):
        continue
    t=0
    while(n%i==0):
        n/=i
        t+=1
    k=1
    while(t>=k):
    
        t-=k
        s+=1
        k+=1

print(s)

### FIXED CODE ###

def prime(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a





n=int(input(""))
s=0
if(n!=1):
    

    

    t=0
    lista=prime(n)
    #print(lista)
    
    c=lista[0]
    for i in lista:
        if (c==i):
            t+=1
        else:
            k=1
            while(t>=k):
                t-=k
                s+=1
                k+=1
            t=1
            c=i


    k=1
    while(t>=k):
        t-=k
        s+=1
        k+=1
        


            
        
        
    
    


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

import sys

sys.setrecursionlimit(10**6)
N, Q = map(int, input().split())
connections = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    pa, ki = map(int, input().split())
    connections[pa].append(ki)
    connections[ki].append(pa)

scores = [0 for _ in range(N + 1)]
for _ in range(Q):
    tag, p = map(int, input().split())
    scores[tag] += p

i = 1

def dfs(k=1,bef=-1):
    global scores
    global fins
    kids = connections[k]
    if len(kids)==1 and bef==kids[0]:
        return
    for kid in kids:
        # print(f'k:{k} kids:{kids}')
        if bef==kid:
            continue
        scores[kid]+=scores[k]
        dfs(kid,k)


dfs()



print(*scores[1:])

### FIXED CODE ###

import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.readline

N, Q = map(int, input().split())
connections = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    pa, ki = map(int, input().split())
    connections[pa].append(ki)
    connections[ki].append(pa)

scores = [0 for _ in range(N + 1)]
for _ in range(Q):
    tag, p = map(int, input().split())
    scores[tag] += p

i = 1

def dfs(k=1,bef=-1):
    global scores
    global fins
    kids = connections[k]
    if len(kids)==1 and bef==kids[0]:
        return
    for kid in kids:
        # print(f'k:{k} kids:{kids}')
        if bef==kid:
            continue
        scores[kid]+=scores[k]
        dfs(kid,k)


dfs()



print(*scores[1:])
### BUGGY CODE ###

N=int(input())
A=map(int,input().split())
Q=int(input())
numbers=[]
for _ in range(Q):
    B,C=map(int,input().split())
    numbers.append([B,C])
answers=[0 for _ in range(100001)]
for a in A:
    answers[a]+=a
for number in numbers:
    suuji=answers[number[0]]/number[0]
    answers[number[0]]=0
    answers[number[1]]+=suuji*number[1]
    print(int(sum(answers)))
    

### FIXED CODE ###

import sys
input = sys.stdin.readline

N=int(input())
A=map(int,input().split())
Q=int(input())
numbers=[]
for _ in range(Q):
    B,C=map(int,input().split())
    numbers.append([B,C])
answers=[0 for _ in range(100001)]
for a in A:
    answers[a]+=a
whole=sum(answers)
for number in numbers:
    suuji=answers[number[0]]//number[0]
    answers[number[0]]=0
    answers[number[1]]+=suuji*number[1]
    whole+=(number[1]-number[0])*suuji
    print(whole)
### BUGGY CODE ###

import queue as qu

mod = 10 ** 9 + 7
N, K = map(int, input().split())
D = {n: set() for n in range(N)}
for n in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    D[a].add(b)
    D[b].add(a)

res = 1
F = [0] * N
already = [False] * N

q = qu.Queue()
q.put(0)
for _ in range(N):
    n = q.get()
    res = (res * (K - F[n])) % mod
    already[n] = True

    if res == 0:
        break

    for i in D[n]:
        if not already[i]:
            F[i] += 1
            q.put(i)
        for b in D[i]:
            if not already[b]:
                F[b] += 1
print(res)


### FIXED CODE ###

import queue as qu

mod = 10 ** 9 + 7
N, K = map(int, input().split())
D = {n: set() for n in range(N)}
for n in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    D[a].add(b)
    D[b].add(a)

res = 1
F = [0] * N
already = [False] * N

q = qu.Queue()
q.put(0)
for _ in range(N):
    n = q.get()
    already[n] = True
    d = D[n]

    m = 2 if n else 1
    for b in d:
        if already[b]:
            continue
        F[b] = m
        m += 1
        q.put(b)
        
if max(F) >= K:
    print(0)
else:
    res = 1
    for f in F:
        res = (res * (K - f)) % mod
    print(res)
### BUGGY CODE ###

s = list(input())

ans = 0

for i in range(len(s)):
    if s[i] == 'B':
        ans += s[i+1:].count('W')

print(ans)

### FIXED CODE ###

s = list(input())

ans = 0

cntB = 0

for i in range(len(s)):
    if s[i] == 'B':
        cntB += 1
    else:
        ans += cntB

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

import sys
input=sys.stdin.readline
import heapq
n,q=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
L1=[]
for i in range(n):
  L1.append((l[i][0]-l[i][2],1,l[i][2]))
  L1.append((l[i][1]-l[i][2],-1,l[i][2]))
for i in range(q):
  L1.append((int(input()),2,0))
L1.sort()
L2=[]
heapq.heapify(L2)
L3=[]
L3=set(L3)
for i in range(len(L1)):
  if L1[i][1]==1:
    heapq.heappush(L2,L1[i][2])
    L3.add(L1[i][2])
  elif L1[i][1]==-1:
    L3.remove(L1[i][2])
  else:
    while L2 and L2[0] not in L3:
      heapq.heappop(L2)
    if L2:
      print(L2[0])
    else:
      print(-1)

### FIXED CODE ###

import sys
input=sys.stdin.readline
import heapq
n,q=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
L1=[]
for i in range(n):
  L1.append((l[i][0]-l[i][2],1,l[i][2]))
  L1.append((l[i][1]-l[i][2],-1,l[i][2]))
for i in range(q):
  L1.append((int(input()),2,0))
L1.sort()
L2=[]
heapq.heapify(L2)
L3=[]
L3=set(L3)
for i in range(len(L1)):
  if L1[i][1]==1:
    heapq.heappush(L2,L1[i][2])
    L3.add(L1[i][2])
  elif L1[i][1]==-1:
    L3.remove(L1[i][2])
  else:
    while L2 and L2[0] not in L3:
      heapq.heappop(L2)
    if L2:
      print(L2[0])
    else:
      print(-1)
### BUGGY CODE ###

import math
k = int(input())
ans = 0
 
for i in range(1,k+1):
    for j in range(1,k+1):
        for m in range(1,k+1):
           
            ans +=math.gcd(math.gcd(i,j),m)
 
print(ans)

### FIXED CODE ###

import math
 
K = int(input())
 
lists = []
for i in range(1, K + 1):
    for j in range(1, K + 1):
        mid = math.gcd(i, j)
        for k in range(1, K + 1):
            lists.append(math.gcd(mid, k))
 
print(sum(lists))
### BUGGY CODE ###

st1 = input()
st2 = input()
key1 = list(st1)
key2 = list(st2)

def list_difference(list1, list2):
    result = list1.copy()
    for value in list2:
        if value in result:
            result.remove(value)

    return result

result1 = str(list_difference(key1,key2))
result2 = str(list_difference(key2,key1))



def az_count(s):
	ss = []
	ss.append(s.count('a'))
	ss.append(s.count('b'))
	ss.append(s.count('c'))
	ss.append(s.count('d'))
	ss.append(s.count('e'))
	ss.append(s.count('f'))
	ss.append(s.count('h'))
	ss.append(s.count('i'))
	ss.append(s.count('j'))
	ss.append(s.count('k'))
	ss.append(s.count('l'))
	ss.append(s.count('n'))
	ss.append(s.count('m'))
	ss.append(s.count('o'))
	ss.append(s.count('p'))
	ss.append(s.count('q'))
	ss.append(s.count('r'))
	ss.append(s.count('s'))
	ss.append(s.count('t'))
	ss.append(s.count('u'))
	ss.append(s.count('v'))
	ss.append(s.count('w'))
	ss.append(s.count('x'))
	ss.append(s.count('y'))
	ss.append(s.count('z'))
	return ss

t = az_count(result1)
t1 = az_count(result2)

t.sort()
t1.sort()
if t == t1:
	print("Yes")
else:
	print("No")

### FIXED CODE ###



st1 = input()
st2 = input()
key1 = list(st1)
key2 = list(st2)

def az_count(s):
	ss = []
	ss.append(s.count('a'))
	ss.append(s.count('b'))
	ss.append(s.count('c'))
	ss.append(s.count('d'))
	ss.append(s.count('e'))
	ss.append(s.count('f'))
	ss.append(s.count('g'))
	ss.append(s.count('h'))
	ss.append(s.count('i'))
	ss.append(s.count('j'))
	ss.append(s.count('k'))
	ss.append(s.count('l'))
	ss.append(s.count('n'))
	ss.append(s.count('m'))
	ss.append(s.count('o'))
	ss.append(s.count('p'))
	ss.append(s.count('q'))
	ss.append(s.count('r'))
	ss.append(s.count('s'))
	ss.append(s.count('t'))
	ss.append(s.count('u'))
	ss.append(s.count('v'))
	ss.append(s.count('w'))
	ss.append(s.count('x'))
	ss.append(s.count('y'))
	ss.append(s.count('z'))
	return ss

t = az_count(key1)
t1 = az_count(key2)

t.sort()
t1.sort()
if t == t1:
	print("Yes")
else:
	print("No")
### BUGGY CODE ###


N = int(input())

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

ans = 0
for n in range(1,N+1):
    ans += n * len(make_divisors(n))

print(ans)


### FIXED CODE ###

import sys
import math
import itertools
import collections
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    N = NI()
    ans = 0
    for n in range(1,N+1):
        ans += (N//n)*(2*n+(N//n-1)*n)//2
    print(ans)


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


import math

li = list(map(int,input().split()))
n = li[0]
k = li[3]
a = max(li[1:3:])
b = min(li[1:3:])
def w(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
#コンビネーション


c = 0

for h in range(0,k//(a+b)+1):
    for i in range(0,(k-(a+b)*h)//a+1):
        j = (k-(a+b)*h-a*i)/b
        if j == int(j) and j >= 0 and n >= h+i+j:
            c = c + w(n,h)*w(n-h,i)*w(n-h-i,j)
if c == 0:
    c = 1

print(c%9982443535)

### FIXED CODE ###

mod = 998244353

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

fact = [1]
fact_inv = [1]
for i in range(n+4):
    new_fact = fact[-1]*(i+1)%mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact,mod-2,mod))


def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod


res = 0

for i in range(n+1):
    if k - a*i < 0:
        continue
    
    if (k-a*i)%b != 0:
        continue

    j = (k-a*i)//b

    if j > n:
        continue

    res = (res + mod_comb_k(n,j,mod)*mod_comb_k(n,i,mod)%mod)%mod

print(res%mod)
### BUGGY CODE ###

n = int(input())

list_nm = list(map(int, input().split()))

ans_a = 0

for i in range(n):
    a = list_nm[:i+1]
    a.sort()
    
    if a[0] == list_nm[i]:
        ans_a += 1

print(ans_a)

### FIXED CODE ###

n = int(input())
list_score = list(map(int, input().split()))
min_value = list_score[0]
ans = 0

for i in range(0, n):
    min_value = min(min_value, list_score[i])
    if list_score[i] == min_value:
        ans += 1
print(ans)
### BUGGY CODE ###

import math
from functools import reduce

k = int(input())

def gcd2(*numbers):
    return reduce(math.gcd,numbers)
sum = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            #print(gcd2(a,b,c))
            sum = sum + gcd2(a,b,c)

print(sum)
        

### FIXED CODE ###

import math
from functools import reduce

k = int(input())

def gcd2(*numbers):
    return reduce(math.gcd,numbers)
sum = 0
for a in range(1,k+1):
    for b in range(a,k+1):
        for c in range(b,k+1):
            if len(set([a,b,c]))==2:
                sum = sum + gcd2(a,b,c)*3
            elif len(set([a,b,c]))==1:
                sum = sum + gcd2(a,b,c)
            else:
                sum = sum + gcd2(a,b,c)*6
            #print(gcd2(a,b,c))


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

def resolve():
    X, K, D = map(int, input().split())
    count = min(abs(X//D), K)
    for i in range(count):
        if X > 0:
            X -= D
        else:
            X += D
        K -= 1
    if K > 0:
        if K%2 == 0:
            print(abs(X))
        else:
            print(D-abs(X))
    else:
        print(abs(X))
resolve()

### FIXED CODE ###

def resolve():
    X, K, D = map(int, input().split())
    count = min(abs(X//D), K)
    if X > 0:
        X -= D*count
    else:
        X += D*count
    K -= count
    if K > 0:
        if K%2 == 0:
            print(abs(X))
        else:
            print(D-abs(X))
    else:
        print(abs(X))
resolve()
### BUGGY CODE ###

n=int(input())
l=[]
for i in range(n):
  x=int(input())
  if not x in set(l):
    l.append(x)
  else:
    l.remove(x)
print(len(l))

### FIXED CODE ###

n=int(input())
s=set([])
for i in range(n):
  x=int(input())
  if not x in s:
    s.add(x)
  else:
    s.remove(x)
print(len(s))