Harryxun/stf_run huggingface dataset:
# ABC044
N, A = map(int, input().split())
X = list(map(int, input().split()))

# 2 ** 50 -> 全探索は厳しい -> DP
# dp[i][k][wa] = i枚まで見て、k枚選んだ時の合計値がwaとなるときの選び方の合計
# max wa = max(X) * N
max_wa = max(X) * N
dp = [[[0] * (max_wa + 5)) for _ in range(N+1)] for __ in range(N+1)]
dp[0][0][0] = 1
for i in range(N):
    for k in range(i+1):
        for wa in range(max_wa):
            # 選ぶとき
            dp[i+1][k+1][wa+X[i]] += dp[i][k][wa]
            # 選ばないとき
            dp[i+1][k][wa] += dp[i][k][wa]

ans = 0
for k in range(1, N+1):
    ans += dp[-1][k][k*A]

print(ans)

### FIXED CODE ###

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

# 2 ** 50 -> 全探索は厳しい -> DP
# dp[i][k][wa] = i枚まで見て、k枚選んだ時の合計値がwaとなるときの選び方の合計
# max wa = max(X) * N
max_wa = max(X) * N
dp = [[[0] * (max(X) * (N+1)) for _ in range(N+1)] for __ in range(N+1)]
dp[0][0][0] = 1
for i in range(N):
    for k in range(i+1):
        for wa in range(max_wa):
            # 選ぶとき
            dp[i+1][k+1][wa+X[i]] += dp[i][k][wa]
            # 選ばないとき
            dp[i+1][k][wa] += dp[i][k][wa]

ans = 0
for k in range(1, N+1):
    if k * A > max_wa:
        break
    ans += dp[-1][k][k*A]

print(ans)
r = float(input())
print '%f %f' % (2*math.pi*r, math.pi*r*r)

### FIXED CODE ###

import math
r = float(input())
print '%f %f' % (math.pi*r*r, 2*math.pi*r)
# AtCoder Beginner Contest 176
# C - Step

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

ans=0

for i in range (1,N):
    if Als[i]>=Als[i-1]:
        pass
    else :
        ans+= max(Als[0:i]-Als[i])
print(ans)

### FIXED CODE ###

# AtCoder Beginner Contest 176
# C - Step

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

ans=0

for i in range (1,N):
    if Als[i]>=Als[i-1]:
        pass
    else :
        step=abs(Als[i]-Als[i-1])
        ans+=step
        Als[i]+=step
print(ans)
N = int(input())
A =  list(map(int, input().split()))
count = 0
flag = 0

while flag == 0:
    for i in range(N):
        if (A[i] % 2 == 0):
            A[i] = A[i] / 2
        else:
            flag = 1
    count += 1

print(count - 1)


### FIXED CODE ###

a, b, c=input()
ans = 0
if a == "1":
    ans += 1
if b == "1":
    ans += 1
if c == "1":
    ans += 1
    
print(ans)
s = input()

oddstring = s[0]
a = (len(s) + 1) // 2

for i in renge(a-1)}:
    oddstring += s[2*i+2]

print(oddstring)


### FIXED CODE ###

s = input()

oddstring = s[0]
a = ((len(s) + 1) // 2) - 1

if a > 0:
    for i in range(a):
        oddstring += s[2*i+2]

print(oddstring)
L=int(input())
ans=0
tmp=0
d=3
for i in range(L*d/2):
  for j in range(L*d-i):
    tmp=(i/d)*(j/d)*(L-(i/d)-(j/d))
    ans=max(ans,tmp,0)
print(ans)

### FIXED CODE ###

L=int(input())
print((L**3)/27)
a = int,input()
print(a+a^2+a^3)

### FIXED CODE ###

a = input()
b = int(a)
print(b+b**2+b**3)
import sys
input = sys.stdin.readline
n = int(input())
c = []
for i in range(n):
  a = [int(i) for i in input().split()]
  c.append(a)

p,q,r = c[0]
c = c[1:]
for i in range(101):
  for j in range(101):
    chk = abs(p-i)+abs(q-j)+r
    for num,k in enumerate(c):
      x,y,h = k
      if abs(x-i)+abs(y-j)+h != chk:
        break
      if num == n-2:
        ans = (i,j,chk)

print(*ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n = int(input())
c = []
for i in range(n):
  a = [int(i) for i in input().split()]
  c.append(a)

from operator import itemgetter
c = sorted(c,key=itemgetter(2),reverse=True)
p,q,r = c[0]
end = c[-1]
c = c[1:]
for i in range(101):
  for j in range(101):
    if r > 0:
      chk = abs(p-i)+abs(q-j)+r
    else:
      chk = 1
    for num,k in enumerate(c):
      x,y,h = k
      if h == 0:
        if abs(x-i)+abs(y-j) < chk:
          break
      else:
        if abs(x-i)+abs(y-j)+h != chk:
          break
      if k == end:
        ans = (i,j,chk)

print(*ans)
import copy

H, W = map(int, input().split())
matrix = [[0] * W for i in range(H)]
for i in range(H):
  line_list = list(input())
  for j in range(W):
    if line_list[j] == ".":  
      matrix[i][j] = 0
    else:
      matrix[i][j] = 1
      
cnt = 0
while(True):
  
  flg = True
  for i in range(H):
    for j in range(W):
      if matrix[i][j] == 0:
        flg = False
        break
  
  if flg:
    print(cnt)
    break
  
  matrix_copy = copy.deepcopy(matrix)
  cnt += 1
  for i in range(H):
    for j in range(W):
      if matrix[i][j] == 1:
        if i > 0:
          matrix_copy[i-1][j] = 1
        if i < H-1:
          matrix_copy[i+1][j] = 1
        if j > 0:
          matrix_copy[i][j-1] = 1
        if j < H-1:
          matrix_copy[i][j+1] = 1
   
  matrix = matrix_copy

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline
 
H, W = map(int, input().split())
mark_matrix = [[True]*(W+2)]
#mark_matrix.extend([[True]+[False]*(W)+[True] for _ in range(H)])
mark_matrix.extend([[True]+[x!='.' for x in input()] for _ in range(H)])
mark_matrix[H].append(True)
mark_matrix.append([True]*(W+2))
#queue = []
queue = deque()
for i in range(1,H+1):
  for j in range(1,W+1):
    if mark_matrix[i][j]:
      queue.append((i,j))
#  line = input()
#  for j,ch in enumerate(line):
#    if ch == "#":
#      mark_matrix[i+1][j+1] = True
#      queue.append((i+1,j+1))
#for i in range(1,H+1):
#  mark_matrix[i][0] = True
#  mark_matrix[i][W+1] = True
#for j in range(W+2):
#  mark_matrix[0][j] = True
#  mark_matrix[H+1][j] = True
#print(mark_matrix)
 
#cnt = 0
#print(queue)
max_value = 0
while(True):
  #print(len(queue))
  if len(queue) == 0:
    break
  
  new_queue = deque()
  for i,j in queue:
  
    if not mark_matrix[i-1][j]:
      mark_matrix[i-1][j] = True
      #queue.append((i-1,j))
      new_queue.append((i-1,j))
    if not mark_matrix[i+1][j]:
      mark_matrix[i+1][j] = True
      #queue.append((i+1,j))
      new_queue.append((i+1,j))
    if not mark_matrix[i][j-1]:
      mark_matrix[i][j-1] = True
      #queue.append((i,j-1))
      new_queue.append((i,j-1))
    if not mark_matrix[i][j+1]:
      mark_matrix[i][j+1] = True
      #queue.append((i,j+1))
      new_queue.append((i,j+1))
 
  if len(new_queue) == 0:
    break
  else:
    queue = new_queue
    max_value += 1
  
#print(cnt)
#print(dist_matrix)
print(max_value)
N = int(input())
b = list(map(int,input().split()))

if 1 not in b:
    print(-1)
else:
    lst = []
    index = -1
    for i in range(N):
        if b[i] == 1:
            lst.append([])
            index += 1
        lst[index].append(b[i])
            
    flag = False
    ans = []
    if N < max(b):
        print(-1)
    else:
        if len(lst) == 0:
            print(-1)
        else:
            lst.reverse()
            for i in range(len(lst)):
                for j in range(len(lst[i])):
                    if lst[i][j] > j+1:
                        flag = True
                        print(-1)
                        break
                if flag:
                    break
            
            for i in range(len(lst)):
                lst[i].reverse()
                cnt = 1
                while(len(lst[i]) > 0 ):
                    
                    if lst[i][0] <= cnt:
                        ans.append(lst[i].pop(0))
                    else:
                        ans.append(cnt)
        
                        lst[i].reverse()
                        lst[i].pop(lst[i].index(cnt))
                        lst[i].reverse()             
                        
                    cnt += 1
            else:
                print(*ans,sep="\n")

### FIXED CODE ###

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

ans = []
while(True):
    if len(b) == 0:
        ans.reverse()
        print(*ans,sep="\n")
        break
    for i in range(len(b)-1,-1,-1):
        if b[i] == i+1:
            ans.append(b.pop(i))
            break
    else:
        print(-1)
        break
x, y = map(int,input().split())
print([x, -1][x%y])

### FIXED CODE ###

x, y = map(int,input().split())
print([x, -1][x%y==0])
N = int(input())
H = list(map(int, input().split()))
flag = True
reach = False

for n in range(N - 1):
  if H[n] > H[n + 1]:
    if H[n] - 1== H[n + 1] and H[n + 1] + 1 <= H[n + 2] and reach == False:
      reach = True
    else:
      flag = False
if flag:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N = int(input())
H = list(map(int, input().split()))
flag = True
maxim = 0

for n in range(N):
  if maxim < H[n]:
    maxim = H[n]
  if H[n] < maxim -1:
      flag = False
if flag:
  print("Yes")
else:
  print("No")
s=input()
k=int(input())

s0=int(s[0])
if s0==1:
    print(s[1])
else:
    print(s0)

### FIXED CODE ###

s=input()
k=int(input())

ans=1
for i in range(min(len(s),k)):
    if int(s[i])!=1:
        ans=s[i]
        break

print(ans)
N,K=map(int,input().split())
h=[int(input()) for i in range(N)]
h.sort()
a=1000
for i in range(N-K):
  if h[i+K]-h[i]<a:
    a=h[i+k]-h[i]
ptint(a)

### FIXED CODE ###

N,K=map(int,input().split())
h=[int(input()) for i in range(N)]
h.sort()
a=10**9
for i in range(N-K+1):
  a=min(a,h[K+i-1]-h[i])
print(a)
x = True
while x == True:

 m = map(int,raw_input().split())

 if m[0] == 0 and m[1] == 0:
     break

 for i in xrange(m[0]):
    print "#" * m[1]
 print ""

### FIXED CODE ###


n = input()
m = map(int,raw_input().split())
a = 0
for i in xrange(n):
    a += m[i]

print min(m),max(m),a
print(input().count(1))

### FIXED CODE ###

print(input().count("1"))
import sys
import numpy as np
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
A = np.insert(A, 0, 0)

flg = [False for _ in range(N + 1)]
town = []
i = 1
cnt = 0
while flg[i] == False or cnt > N:
    town.append(i)
    flg[i] = True
    i = A[i]
    cnt += 1

if len(town) >= K:
    print(town[K])
else:
    s = i
    to_s = town.index(s)
    loop = len(town) - to_s
    print(town[(K - to_s) % loop + to_s])

### FIXED CODE ###

import sys
import numpy as np
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
A = np.insert(A, 0, 0)

flg = [False for _ in range(N + 1)]
town = []
i = 1
cnt = 0
for _ in range(N):
    town.append(i)
    flg[i] = True
    i = A[i]

if len(town) >= K:
    print(town[K])
else:
    s = i
    to_s = town.index(s)
    loop = len(town) - to_s
    print(town[(K - to_s) % loop + to_s])
a = input()
if a == a.upper():
  print(a)
else:
  peint(a.lower())

### FIXED CODE ###

a = input()
if a.isupper():
  print("A")
else:
  print("a")
a,b,c = int(input()).split()
if a+b+c <= 21:
	print("win")
else:
	print("bust")

### FIXED CODE ###

a,b,c = map(int,input().split())
if a+b+c <= 21:
	print("win")
else:
	print("bust")
n,m,k = map(int, input().split())

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

ans = 0
ai = 0
bi = 0
t = 0
while t < k and (ai < len(A) or bi < len(B)):
  if ai < len(A) and bi < len(B):
    a = A[ai]
    b = B[bi]
    if a < b:
      ai += 1
      t += a
      if t =< k:
        ans += 1
    else:
      bi += 1
      t += b
      if t =< k:
        ans += 1
  elif ai < len(A):
    ai += 1
    t += A[ai]
    if t =< k:
      ans += 1
  else:
    bi += 1
    t += B[bi]
    if t =< k:
      ans += 1
print(ans)
    
    


### FIXED CODE ###

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

a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)
weather1 = input().split()
weather2 = input().split()
match = 0
for i in range(0,2):
    if weather1[i] == weather2[i]:
        count += 1
print(count)

### FIXED CODE ###

weather1 = input()
weather2 = input()
match = 0
for i in range(0,3):
    if weather1[i] == weather2[i]:
        match += 1
print(match)
N, M = map(int, input().split())
a = []
b = []
c = []

for i in range(M):
    ai, bi = map(int, input().split())
    a.append(ai)
    b.append(bi)
    ci = list(map(int, input().split()))
    c.append(ci)

c_bin = [0] * M
for j in range(M):
    for k in range(b[j]):
        c_bin[j] |= (1 << (c[j][k] - 1))

ceil = 1 << N
memo = [None] * (ceil * (M + 1))
# print("#", '[' +' '.join(map(lambda x: '0b{:b}'.format(x), c_bin)) + ']', ceil)
def dp(pos, state):
    global M, ceil
    idx = pos * ceil + state
    # print("##", pos, '0b{:b}'.format(state), idx)
    if state == ceil - 1:
        ret = 0
    elif pos == M:
        ret = -1
    elif memo[idx] != None:
        return memo[idx]
    else:
        ret0 = dp(pos + 1, (state | c_bin[pos]))
        ret1 = dp(pos + 1, state)
        if ret0 == ret1 == -1:
            ret = -1
        elif ret1 == -1:
            ret = a[pos] + ret0
        else:
            ret = min(a[pos] + ret0, ret1)
    #
    memo[idx] = ret
    return ret

print(dp(0, 0))

### FIXED CODE ###

N, M = map(int, input().split())
a = []
b = []
c = []

import sys
sys.setrecursionlimit(2000)

for i in range(M):
    ai, bi = map(int, input().split())
    a.append(ai)
    b.append(bi)
    ci = list(map(int, input().split()))
    c.append(ci)

c_bin = [0] * M
for j in range(M):
    for k in range(b[j]):
        c_bin[j] |= (1 << (c[j][k] - 1))

ceil = 1 << N
memo = [None] * (ceil * (M + 1))
# print("#", '[' +' '.join(map(lambda x: '0b{:b}'.format(x), c_bin)) + ']', ceil)
def dp(pos, state):
    global M, ceil
    idx = pos * ceil + state
    # print("##", pos, '0b{:b}'.format(state), idx)
    if state == ceil - 1:
        ret = 0
    elif pos == M:
        ret = -1
    elif memo[idx] != None:
        return memo[idx]
    else:
        ret0 = dp(pos + 1, (state | c_bin[pos]))
        ret1 = dp(pos + 1, state)
        if ret0 == ret1 == -1:
            ret = -1
        elif ret1 == -1:
            ret = a[pos] + ret0
        else:
            ret = min(a[pos] + ret0, ret1)
    #
    memo[idx] = ret
    return ret

print(dp(0, 0))
L,R=map(int,input().split())
min=2019
for i in range(L,R+1):
    for k in range(i+1,R+1):
        mod=(i*k)%2019
        if mod==0:
            min=0
            break
        if mod<min:
            min=mod
        else:
            continue
    	break
print(min)


### FIXED CODE ###

L,R=map(int,input().split())
min=2019
for i in range(L,R+1):
    for k in range(i+1,R+1):
        mod=(i*k)%2019
        if mod<min:
            min=mod
        if mod==0:
            min=0
            break
    else:
        continue
    break
print(min)
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall

H, W = map(int, input().split())
S = [input() for _ in range(H)]

g = [[0] * (H * W) for _ in range(H * W)]
for y in range(H):
    for x in range(W):
        if S[y][x] == '#':
            continue
        if y - 1 >= 0 and S[y - 1][x] != '#':
            g[y * W + x][(y - 1) * W + x] = 1
        if y + 1 < H and S[y + 1][x] != '#':
            g[y * W + x][(y + 1) * W + x] = 1
        if x - 1 >= 0 and S[y][x - 1] != '#':
            g[y * W + x][y * W + x - 1] = 1
        if x + 1 < W and S[y][x + 1] != '#':
            g[y * W + x][y * W + x + 1] = 1
g = floyd_warshall(csgraph_from_dense(g))

result = 0
for i in range(H * W):
    for j in range(H * W):
        if g[i][j] == 0:
            continue
        result = max(result, g[i][j])
print(int(result))


### FIXED CODE ###

H, W = map(int, input().split())
S = [input() for _ in range(H)]


def f(i, j):
    t = [[-1] * W for _ in range(H)]
    t[i][j] = 0
    q = [(i, j)]
    while q:
        y, x = q.pop(0)
        if y - 1 >= 0 and S[y - 1][x] != '#' and t[y - 1][x] == -1:
            t[y - 1][x] = t[y][x] + 1
            q.append((y - 1, x))
        if y + 1 < H and S[y + 1][x] != '#' and t[y + 1][x] == -1:
            t[y + 1][x] = t[y][x] + 1
            q.append((y + 1, x))
        if x - 1 >= 0 and S[y][x - 1] != '#' and t[y][x - 1] == -1:
            t[y][x - 1] = t[y][x] + 1
            q.append((y, x - 1))
        if x + 1 < W and S[y][x + 1] != '#' and t[y][x + 1] == -1:
            t[y][x + 1] = t[y][x] + 1
            q.append((y, x + 1))
    return max(max(tt) for tt in t)


result = 0
for i in range(H):
    for j in range(W):
        if S[i][j] != '#':
            result = max(result, f(i, j))
print(result)
N, M, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
def dfs(a, b, k):
	global ans

	if a == N and b ==M:
		return True

	if a < N and k >= A[a] and dfs(a + 1, b, k - A[a]):
		ans += 1
		return True

	if b < M and k >= B[b] and dfs(a, b + 1, k - B[b]):
		ans += 1
		return True

	if k <= 0:
		return False

	return True

dfs(0, 0, K)
print(ans)

### FIXED CODE ###

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

a = [0]
for i in range(N):
    a.append(a[i] +  A[i])
b = [0]
for i in range(M):
    b.append(b[i] + B[i])

ans = 0
j = M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)
# Author: S Mahesh Raju
# Username: maheshraju2020
# Date: 01/08/2020

from sys import stdin, stdout
from math import gcd, ceil, sqrt
from collections import Counter
from bisect import bisect_left, bisect_right
ii1 = lambda: int(stdin.readline().strip())
is1 = lambda: stdin.readline().strip()
iia = lambda: list(map(int, stdin.readline().strip().split()))
isa = lambda: stdin.readline().strip().split()
mod = 1000000007

n, m = iia()
dp = [-1] * (n + 1)
d = {}
for i in range(m):
    a, b = iia()
    d.setdefault(a, []).append(b)

def dfs(cur):
    if dp[cur] != -1:
        return dp[cur]
    t = 0
    for i in d.get(cur, []):
        t = max(1 + dfs(i), t)
    dp[cur] = t
    return dp[cur]

res = 0
for i in range(1, n + 1):
    res = max(res, dfs(i))
print(res)

### FIXED CODE ###

# Author: S Mahesh Raju
# Username: maheshraju2020
# Date: 01/08/2020

from sys import stdin, stdout
import sys
from math import gcd, ceil, sqrt
from collections import Counter
from bisect import bisect_left, bisect_right
ii1 = lambda: int(stdin.readline().strip())
is1 = lambda: stdin.readline().strip()
iia = lambda: list(map(int, stdin.readline().strip().split()))
isa = lambda: stdin.readline().strip().split()
mod = 1000000007
sys.setrecursionlimit(100000)
n, m = iia()
dp = [-1] * (n + 1)
d = {}
for i in range(m):
    a, b = iia()
    d.setdefault(a, []).append(b)

def dfs(cur):
    if dp[cur] != -1:
        return dp[cur]
    t = 0
    for i in d.get(cur, []):
        t = max(1 + dfs(i), t)
    dp[cur] = t
    return dp[cur]

res = 0
for i in range(1, n + 1):
    res = max(res, dfs(i))
print(res)
A=int(input())
B=int(input())
C=int(input())
X=int(input())
ans = 0
for i in range(A):
  for j in range(B):
    for k in range(C):
      if 500*i+100+j+50*k==X:
        ans++
print(ans)

### FIXED CODE ###

A=int(input())
B=int(input())
C=int(input())
X=int(input())
ans = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i+100*j+50*k==X:
        ans+=1
print(ans)
N = int(input())
a = list(map(int, input().split()))
ans = 0
if N%2==0:
  print(a[N]-a[N-1])
else:
  print(0)

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
a.sort()
if N%2==0:
  print(a[int(N/2)]-a[int(N/2-1)])
else:
  print(0)
N, M=map(int,input().split())
alist = list(map(int,input().split()))
alist.sort(reverse = True)
sum = 0
correct = True
for i in alist:
    sum += i
for i in range[M-1]:
    if alist[i] < 1/(4*M) :
        print("No")
        correct = False
if correct:
    print("Yes")

### FIXED CODE ###

N, M=map(int,input().split())
alist = list(map(int,input().split()))
alist.sort(reverse = True)
abc = sum(alist)
if alist[M-1] >= abc/(4*M):
    print("Yes")
else:
    print("No")
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
n,q=LI()
ab=[LI() for _ in range(n-1)]
px=[LI() for _ in range(q)
ans=[0]*(n+1)
graph={i:collections.deque() for i in range(1,n+1)}
for a,b in ab:
    graph[a].append(b)
    graph[b].append(a)
for p,x in px:
    ans[p]+=x
seen=[0]*(n+1)
stack=[]
def dfs():
    seen[1]=1
    stack.append(1)
    while stack:
        s=stack.pop()
        if not graph[s]:
            continue
        for j in range(len(graph[s])):
            gno=graph[s].popleft()
            if seen[gno]:
                continue
            seen[gno]=1
            stack.append(gno)
            ans[gno]+=ans[s]
dfs()
print(*ans[1:])

### FIXED CODE ###

import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
n,q=LI()
ab=[LI() for _ in [None]*(n-1)]
px=[LI() for _ in [None]*q]
ans=[0]*(n+1)
graph={i:collections.deque() for i in range(1,n+1)}
for a,b in ab:
    graph[a].append(b)
    graph[b].append(a)
for p,x in px:
    ans[p]+=x
seen=[0]*(n+1)
stack=[]
def dfs():
    seen[1]=1
    stack.append(1)
    while stack:
        s=stack.pop()
        if not graph[s]:
            continue
        for j in range(len(graph[s])):
            gno=graph[s].popleft()
            if seen[gno]:
                continue
            seen[gno]=1
            stack.append(gno)
            ans[gno]+=ans[s]
dfs()
print(*ans[1:])
import sys,math
input = sys.stdin.readline

A,B,C,D = map(int,input().split())
lcm =  (C*D)/math.gcd(C,D)
c=0
End = (B//C)+(B//D)-(B//(lcm))
if A != 1:
  Start = ((A-1)//C)+((A-1)//D)-((A-1)//(lcm))
else :
  Start = 1
print(int((B-A+1)-(End-Start)))


### FIXED CODE ###

import sys,fractions
input = sys.stdin.readline

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


lcm =  (C*D)//fractions.gcd(C,D)
c=0
End = (B//C)+(B//D)-(B//(lcm))

Start = ((A-1)//C)+((A-1)//D)-((A-1)//(lcm))

print(int((B-A+1)-(End-Start)))
a=set(list(input.split()))
print(len(a))

### FIXED CODE ###

a=list(input().split())
print(len(set(a)))
n,m,x = map(int,input().split())
for i in range(n):
  c.append(list(map(int,input().split())))
print(c)
result = -1
for i in range(2 ** n):
  ct = 0
  t = [0] * m
  for b in range(1, n + 1):
    if i & b > 0:
      ct += c[b - 1][0]
      for j in range(1, m + 1):
        t[j - 1] += c[b - 1][j]
  if result == -1 or ct < result:
    r = 1
    for ti in t:
      if ti < x:
        r = 0
    if r == 1:
      print(ct)
      print(t)
      result = ct
print(result)

### FIXED CODE ###

n,m,x = map(int,input().split())
c = []
a = []
for i in range(n):
  l = list(map(int,input().split()))
  c.append(l[0])
  a.append(l[1:])
result = -1
for i in range(2 ** n):
  ct = 0
  at = [0] * m
  for b in range(0, n):
    bb = 1 << b 
    if i & bb > 0:
      ct += c[b]
      for j in range(0, m):
        at[j] += a[b][j]
  if result == -1 or ct < result:
    r = 1
    for ati in at:
      if ati < x:
        r = 0
    if r == 1:
      result = ct
print(result)
n = int(inout())
time_list = [ int(v) for v in input().split() ]
total_time = sum(time_list)
m = int(input())

for i in range(m):
  p, t = [ int(v) for v in input().split() ]
  print(total_time - time_list[p-1] + t)

### FIXED CODE ###

n = int(input())
time_list = [ int(v) for v in input().split() ]
total_time = sum(time_list)
m = int(input())

for i in range(m):
	p, t = [ int(v) for v in input().split() ]
	print(total_time - time_list[p-1] + t)
N, Y = map(int, input().split())
for x in range(N+1):
	for y in range(N+1-x):
		for z in range(N+1-x-y)			:
   			if (Y==10000*x+5000*y+1000*z):
    			print(x,y,z)
    			exit()
print(-1,-1,-1)

### FIXED CODE ###

N, Y = map(int, input().split())
 
for x in range(N+1):
  for y in range(N-x+1):
    z = N - x - y
    if 10000 * x + 5000 * y + 1000 * z == Y:
      print(x,y,z)
      exit()
print(-1,-1,-1)
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
for i in A if i < N-1:
  B[i]=A[i+1]-A[i]

B[N-1] = A[0] + K - A[N-1]

print(K-max(B))

### FIXED CODE ###

K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
k = 0
for i in A:
  k += 1
  if k != N:
    B[k-1]=A[k]-A[k-1]
  else:
    B[N-1] = A[0] + K - A[N-1]

print(K-max(B))
N = input()
W = list(map(int, input().split()))
print(min([abs(sum(W[:i]) - sum(W[i:])) for i in range(N)]))


### FIXED CODE ###

N = int(input())
W = list(map(int, input().split()))
print(min([abs(sum(W[:i]) - sum(W[i:])) for i in range(N)]))
a,b,c=map(int,inpput().split('/'))
a=2018
print(a,'/',b,'/',c)


### FIXED CODE ###

a,b,c=map(str,input().split('/'))
a='2018'
print(a,b,c,sep='/')