Harryxun/stf_run huggingface dataset:
def solve(N,X,M):
    memo = [-1]*(M+3)
    acc = [0]*(M+4)
    x = X
    for i in range(M):
        if memo[x] >= 0:
            break
        acc[i+1] = acc[i]+x
        memo[x] = i
        x = (x*x)%M


    end = i
    start = memo[x]
    cycle = end - start

    if N < end:
        return acc[N]

    cycle_sum = acc[end]-acc[start]

    res = acc[start]

    N -= start
    res += (N//cycle)*cycle_sum
    res += acc[start+(N%cycle)]-acc[start]
    return res


N,X,M = map(int,input().split())
print(solve(N,X,M))


### FIXED CODE ###



def solve(N,X,M):
    if X == 0:
        return 0
    memo = [-1]*(M+3)
    acc = [0]*(M+4)
    x = X
    for i in range(M):
        if memo[x] >= 0:
            break
        acc[i+1] = acc[i]+x
        memo[x] = i
        x = (x*x)%M


    end = i
    start = memo[x]
    cycle = end - start

    if N < end:
        return acc[N]

    cycle_sum = acc[end]-acc[start]

    res = acc[start]

    N -= start
    res += (N//cycle)*cycle_sum
    res += acc[start+(N%cycle)]-acc[start]
    return res


N,X,M = map(int,input().split())
print(solve(N,X,M))
n = int(input())
half = min(n//10**(len(str(n))//2),n%10**(len(str(n))//2))

ans = []
for i in range(half, 0, -1):
    if n%i==0:
        ans.append(max(len(str(i)), len(str(n//i))))
print(min(ans))

### FIXED CODE ###

import math
n = int(input())
half = int(math.sqrt(n))

ans = []
for i in range(half, 0, -1):
    if n%i==0:
        ans.append(max(len(str(i)), len(str(n//i))))
print(min(ans))
import itertools

n,m=map(int, input().split()) 
ab=[list(map(int, input().split())) for _ in range(m)]
#ab=Input.split()
#d：隣接行列
print(ab)
print(type(ab))
d = [[] for i in range(n)]
for i in range(m):
    a = ab[i][0]
    b = ab[i][1]
    d[a-1].append(b-1)
    d[b-1].append(a-1)
    
#per：順列列挙
per= list(itertools.permutations(range(1,n)))
cnt=0
for i in range(len(per)):
    x = [0]+per[i]
    for j in range(n):
        #隣接していなければ終了
        if not x[j+1] in d[x[j]]:
            break
        cnt+=1
print(cnt)
        

### FIXED CODE ###

import itertools

n,m=map(int, input().split()) 
ab=[list(map(int, input().split())) for _ in range(m)]
#ab=Input.split()
#d：隣接行列

d = [[] for i in range(n)]
for i in range(m):
    a = ab[i][0]
    b = ab[i][1]
    d[a-1].append(b-1)
    d[b-1].append(a-1)
    
#per：順列列挙
per= itertools.permutations(range(1,n))
ans=0
for i in per:
    cnt=1
    x = [0]+list(i)
    for j in range(1,n):
        #隣接していなければ終了
        if not x[j] in d[x[j-1]]:
            break
        else:
            cnt+=1
    if(cnt==n):
        ans+=1
print(ans)
s = list(map(str, input()))

change = 0
count = 0
i = 0

while True:
    if not s:
        break
    if i + 1 >= len(s):
        if change != 0:
            i = 0
            change = 0
        else:
            break

    if s[i] != s[i + 1]:
        del s[i: i + 2]
        count += 1
        change += 1
    else:
        i += 1

print(count * 2)


### FIXED CODE ###

s = [int(x) for x in list(map(str, input()))]

x = s.count(0)
y = s.count(1)

print(min(x, y) * 2)
a = x * x * x
print(a)

### FIXED CODE ###

x = int(input())
a = x ** 3
print (a)
nums = input().split()
a = int(nums[0])
b = int(nums[1])
if a < b:
    print('a < b')
elif a > b:
    print('a > b')
elif:
    print('a == b')

### FIXED CODE ###

a, b = map(int, input().split())
if a < b:
  print('a < b')
elif a > b:
  print('a > b')
elif a == b:
  print('a == b')
else:
  pass
def uf_find(x):
  z = x
  while z != p[z]:
    z = p[z]
  p[x] = z
  return z

def uf_unite(x,y):
  global rand
  x = uf_find(x)
  y = uf_find(y)
  if x != y:
    rand += 1
    if rand % 2 ==0:
      p[y] = x
    else:
      p[x] = y

N, M = map(int, input().split())
p = list(range(N))
rand = 0

for i in range(M):
  A, B = [int(j)-1 for j in input().split()]
  uf_unite(A,B)
  print(p)
  
for i in range(N):
  p[i] = uf_find(i)
print(p)

q = [0]*N
for i in range(N):
  q[i] = p.count(i)
  
print(max(q))


### FIXED CODE ###

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

par = list(range(N))
rank = [1]*N
size = [1]*N

def find(x):
  if par[x] == x:
    return x
  else:
    return find(par[x])
  
def unite(x,y):
  x = find(x)
  y = find(y)
  
  if x == y:
    return
  if rank[x]<rank[y]:
    par[x]=y
    size[y]+= size[x]
  else:
    par[y] = x
    size[x] += size[y]
    if rank[x]==rank[y]:
      rank[x]+=1
    
for i in range(M):
  a,b = [int(i)-1 for i in input().split()]
  unite(a,b)
  
print(max(size))
N = int(input())
A = list(map(int,input().split()))
ans = 0

for i in A:
    a += 1/i

print(1/a)


### FIXED CODE ###

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

for i in A:
    ans += 1/i

print(1/ans)
a = [input() for i in range(2)]

sp = "".join(sorted(list(a[0])))
tmp = list(a[1])
tmp.sort()
tmp.reverse()
tp = "".join(tmp)  
if sp < tp:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

import statistics
import math

a = list(map(int,input().split()))
print( math.ceil(statistics.mean(a)))
num = input()
get = num / 15
print((num * 800) - (get * 200))


### FIXED CODE ###

num = int(input())
get = num // 15

print((num * 800) - (get * 200))
N = int(input())
print(math.factorial(N) % MOD)


### FIXED CODE ###

import math
MOD = 10**9 + 7

N = int(input())
print(math.factorial(N) % MOD)
line = input()
A,B,K = [int(n) for n in line.split()]
C = max(A,B)
u = [n for n in range(1,C//2+1) if A/n in range(1,C//2+1) and B/n in range(1,C//2+1)]
u.insert(0,1)
print(u[K-1])

### FIXED CODE ###

li=[int(i) for i in input().split()]
a=li[0]
b=li[1]
k=li[2]
c=[]
for i in range(1,min(a,b)+1):
    if(a%i==0 and b%i==0):
        c+=[i]

print(c[-k])
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split(​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))))

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)

### 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)
n,m = map(int, input().split())
aa = [0] * m
bb = [0] * m
cc = [0] * m
dd = [0] * m

for i in range(n):
    aa[i], bb[i] = map(int, input().split())
for i in range(m):
    cc[i], dd[i] = map(int, input().split())

distance = []
for i in range(n):
    d = []
    for j in range(m):
        d_ = abs(aa[i] - cc[j]) + abs(bb[i] - dd[j])
        d.append(d_)
        print('({}, {})  ({}, {}) :{}'.format(aa[i],bb[i],cc[j],dd[j], d_))
    distance.append(d)
for d in distance:
    print(d.index(min(d))+1)

### FIXED CODE ###

n,m = map(int, input().split())
aa = [0] * n
bb = [0] * n
cc = [0] * m
dd = [0] * m

for i in range(n):
    aa[i], bb[i] = map(int, input().split())
for i in range(m):
    cc[i], dd[i] = map(int, input().split())

for i in range(n):
    d = [abs(aa[i] - cc[j]) + abs(bb[i] - dd[j]) for j in range(m)]
    print(d.index(min(d))+1)
import math
a,b= map(int,input().split())
print(a*b//math.gcd(a,b))

### FIXED CODE ###

from fractions import gcd
a,b= map(int,input().split())
print(a*b//gcd(a,b))
def root(x):#親のrootはマイナスのサイズ、子のrootは親のindex
  if par[x]<0:
    return x
  else:
    par[x]=root(par[x])
    return par[x]

def unit(x,y):#xとyをくっつける
  rx=root(x)
  ry=root(y)
  if rx==ry:
    return False
  if par[rx]>par[ry]:#親のサイズの大小比較
    rx,ry=ry,rx#xのサイズのほうが大きくする
  par[rx]+=par[ry]#xのサイズにyのサイズを足す(サイズの変換)
  par[ry]=x#親じゃなくなったroot(y)の値をxの根にする
  return True
 
def same(x,y):
  rx=root(x)
  ry=root(y)
  return rx==ry#真偽を返す
 
def size(x):
  return -par[root(x)]#親のrootはマイナスのサイズなため
 
N,M,K=map(int,input().split())
par=[-1]*N
deg=[0]*N
bro=[[]*N for i in range(N)]
for i in range(M):
  a,b=map(int,input().split())
  a-=1
  b-=1
  deg[a]+=1
  deg[b]+=1
  unit(a,b)
for j in range(K):
  c,d=map(int,input().split())
  c-=1
  d-=1
  bro[c].append(d)
  bro[d].append(c)

for q in range(N):
  ans=size(q)-deg[q]-1
  for w in bro[q]:
    if same(q,w):
      ans-=1
  print(ans,end=" ")

### FIXED CODE ###

class Union_Find():
    def __init__(self,n):
        self.n=n
        self.par=[-1]*n
    def root(self,x):
        if self.par[x]<0:
            return x
        else:
            self.par[x]=self.root(self.par[x])
            return self.par[x]
    def union(self,x,y):
        rx=self.root(x)
        ry=self.root(y)
        if rx==ry:
            return
        if self.par[rx]>self.par[ry]:
            rx,ry=ry,rx
        self.par[rx]+=self.par[ry]
        self.par[ry]=rx

    def size(self,x):
        return -self.par[self.root(x)]

    def same(self,x,y):
        return self.root(x)==self.root(y)
N,M,K=map(int,input().split())
deg=[0]*N
bro=[[]*N for _ in range(N)]
uf=Union_Find(N)
for i in range(M):
    a,b=map(int,input().split())
    a-=1
    b-=1
    deg[a]+=1
    deg[b]+=1
    uf.union(a,b)
for j in range(K):
    a,b=map(int,input().split())
    a-=1
    b-=1
    bro[a].append(b)
    bro[b].append(a)

for q in range(N):
    ans=uf.size(q)-deg[q]-1
    for w in bro[q]:
        if uf.same(q,w):
            ans-=1
    print(ans,end=" ")
N,M = map(int,input().split())
L = list(map(int,input().split()))
L = sorted(L)
left = ""
right = ""

for i in range(N) :
    if i >= M :
        break
    if i == 0 :
        left = L[0]
        L = L[1:]
    elif i == 1 :
        right = L[-1]
        L = L[:-1]
    else :
        if abs(left-L[0]) < abs(right-L[-1]) :
            right = L[-1]
            L = L[:-1]
        else :
            left = L[0]
            L = L[1:]
#print(L)
ans = 0

while len(L) :
    #print(abs(left-L[0]),abs(right-L[-1]))
    if abs(left-L[0]) < abs(right-L[-1]) :
        ans += abs(left-L[0])
        left = L[0]
        L = L[1:]
    else :
        ans += abs(right-L[-1])
        right = L[-1]
        L = L[:-1]

print(ans)
#print(L)


### FIXED CODE ###

N,M = map(int,input().split())
L = list(map(int,input().split()))
if N >= M :
    ans = 0
else :
    L = sorted(L)
    A = []
    for i in range(M-1) :
        A.append(L[i+1]-L[i])
    A = sorted(A)
    ans = sum(A[:M-N])
print(ans)
n = int(input())
tree = [None for i in range(n)]
root = set(range(n))

for i in range(n):
    i, l, r = map(int, input().split())
    left[i] = l
    right[i] = r
    root -= {1, r}

def preorder(i):
    if (i == -1):
        return
    (l, r) = tree[i]
    print(" {}".format(i), end = "")
    preorder(left[i])
    preorder(right[i])
      
def inorder(i):
    if (i == -1):
        return
    (l, r) = tree[i]
    inorder(left[i])
    print(" {}".format(i), end = "")
    inorder(right[i])
      
def postorder(i):
    if (i == -1):
        return
    (l, r) = tree[i]
    postorder(left[i])
    postorder(right[i])
    print(" {}".format(i), end = "")

print('Preorder')
preorder(root)
print()
  
print('Inorder')
inorder(root)
print()
  
print('Postorder')
postorder(root)
print()

### FIXED CODE ###

n = int(input())
left = [None for i in range(n)]
right = [None for i in range(n)]
root = sum(range(n)) - n - 1

for i in range(n):
    i, l, r = map(int, input().split())
    left[i] = l
    right[i] = r
    root -= (l + r)

def Preorder(i):
    if (i == -1):
        return
    print(" {}".format(i), end = "")
    Preorder(left[i])
    Preorder(right[i])
      
def Inorder(i):
    if (i == -1):
        return
    Inorder(left[i])
    print(" {}".format(i), end = "")
    Inorder(right[i])
      
def Postorder(i):
    if (i == -1):
        return
    Postorder(left[i])
    Postorder(right[i])
    print(" {}".format(i), end = "")

print("Preorder")
Preorder(root)
print()
  
print("Inorder")
Inorder(root)
print()
  
print("Postorder")
Postorder(root)
print()
n , m  = list(map(int,input().split()))
counter = 0
if n < m // 2:
    counter = n
    m = m - 2* n
else:
    counter = m //2
    n = n - m //2

counter = counter + m //4 
    
    
print(count)

### FIXED CODE ###

n , m  = list(map(int,input().split()))
counter = 0
if n <= m // 2:
    counter = n
    m = m - 2* n
    n = 0
else:
    counter = m //2
    n = n - m //2
    m = 0

counter = counter + m //4 

kouho = m //4
print(max(counter,kouho))
n = int(input())
s = [input() for i in range(n-1)]
a = []
index = a.find(s[i])
for i in range(n-1):
	if index = -1:
         a.append(i)
print(len(s[i])


### FIXED CODE ###

n = int(input())
ans = len(set([input() for _ in range(n)]))
print(ans)
N, K = map(int, input())
 
calc = 0
for i in range(1, N+1):
  tmp = i
  cnt = 0
  while tmp <= K-1
    tmp*=2
    cnt+=1
  calc += (1/N) * (1/(2**cnt))

print(calc)

### FIXED CODE ###

N, K = map(int, input().split())
 
calc = 0
for i in range(1, N+1):
  tmp = i
  cnt = 0
  while tmp <= K - 1:
    tmp*=2
    cnt+=1
  calc += (1/N) * (1/(2**cnt))

print(calc)
N, M = map(int, input().split())
S = []
for _ in range(M):
    S.append(int(input()))
def fib(n):
  if n==0:
    return 0
  else:
    a, b = 0, 1
    for i in range(n):
        a, b = b, a + b
    return b
if S[0]==1:
  c=1
else:
  c=fib(S[0]-1)
for i in range(M-1):
  c=c*fib(S[i+1]-S[i]-2)
c=c*fib(N-S[M-1]-1)
c=c%1000000007
print(c)

### FIXED CODE ###

N, M = map(int, input().split())
S = []
for _ in range(M):
    S.append(int(input()))
def fib(n):
  if n==-1:
    return 0
  elif n==0:
    return 1
  else:
    a, b = 0, 1
    for i in range(n):
        a, b = b, a + b
    return b
if len(S)==0:
  c=fib(N)
  print(c%1000000007)
else:
  if S[0]==1:
    c=1
  else:
    c=fib(S[0]-1)
  for i in range(M-1):
    c=c*fib(S[i+1]-S[i]-2)
  c=c*fib(N-S[M-1]-1)
  c=c%1000000007
  print(c)
text = input()
    if text[1] == "S":
        if text[0] == "R" or text[2] == "R":
            print(1)
        else:
            print(0)
    else:
        if text[0] == "R" and text[2] == "R":
            print(3)
        elif text[0] == "R" or text[2] == "R":
            print(2)

### FIXED CODE ###

text = input()
if text[1] == "S":
    if text[0] == "R" or text[2] == "R":
        print(1)
    else:
        print(0)
else:
    if text[0] == "R" and text[2] == "R":
        print(3)
    elif text[0] == "R" or text[2] == "R":
        print(2)
    else:
        print(1)
a, b = input().split()
s = "=="
a = abs(a)
b = abs(b)
if a < b: s = "<"
elif a > b: s = ">"
print("a", s, "b")

### FIXED CODE ###

a, b = map(int, input().split())
print("a", ("==" if a == b else "<" if a < b else ">"), "b")
#2
N,K=map(int,input().split())
H=[int(x) for x in input().split()]

diff=[0]*(K+1)
dp=[0]*N


for i in range(1,N):
    
    for k in range(1,K+1):
        if i-k>-1:
            diff[k]=abs(H[i]-H[i-k])
        else:
            break
    
    Min=diff[1]
    for k in range(2,min(i+1,K+1)):
        if diff[k]<Min:
            Min=diff[k]
            Min_p=k

    dp[i]=dp[i-Min_p]+Min
print(dp[-1])   

### FIXED CODE ###

#2
def chmin(a,b):
    if a>b:
        return b
    else:
        return a

N,K=map(int,input().split())
H=[int(x) for x in input().split()]

dp=[float("inf")]*N
dp[0]=0

for i in range(N):
    for j in range(1,K+1):
        if i+j<N:
            dp[i+j]=chmin(abs(H[i+j]-H[i])+dp[i],dp[i+j])
        else:
            break
print(dp[-1])
import sys
import math

x_list = []

for line in sys.stdin.readlines():
  x_list.append(int(line.strip()))

count = 0

x_list.remove(x_list[0])

for i in x_list:
  flag = 0
  for j in range(2, math.sqrt(i)+1):
    if i % j == 0:
      flag = 1
      break
    if flag == 0:
      count ++

print count
    

### FIXED CODE ###

import sys
import math

x_list = []

for line in sys.stdin.readlines():
  x_list.append(int(line.strip()))

count = 0

x_list.remove(x_list[0])

for i in x_list:
  flag = 0
  for j in range(2, int(math.sqrt(i))+1):
    if i % j == 0:
      flag = 1
      break
  if flag == 0:
    count += 1

print count
X="X"
N="0123456789"
for s in sys.stdin:
  i=s.find("=")
  j=s.find("+")
  k=s[0]==X or s[i+1]==X or s[j+1]==X
  f=0
  for c in N[k:]:
    a=s.replace(X,c)
    if eval(a[:i])==eval(a[i+1:]): f=1; break
  print ["NA",c][f]

### FIXED CODE ###

import sys

for s0 in sys.stdin:
  s=s0[:-1]
  d,c=s.split("=")
  a,b=d.split("+")
  f=any([e!=e[0]=="X" for e in [a,b,c]])

  m="NA"
  s=d+"=="+c
  for e in "0123456789"[f:]:
    if eval(s.replace("X",e)): m=e; break
  print m
k, s = map(int, input().split())
n = 0
for i in range(k + 1):
    if (s-i)/2 > k:
        continue
    elif i > s:
        break
    for j in range(s-i+1):
        if s-i-j > k:
            continue
        elif j > k:
            break
        for l in range(s-i-j + 1):
            if i + j + l == s:
                n += 1
            elif i + j + l > s:
                break
print(n)
vv

### FIXED CODE ###

k, s = map(int, input().split())
n = 0
for i in range(k + 1):
    if (s-i)/2 > k:
        continue
    elif i > s:
        break
    for j in range(k+1):
        z = s - i - j
        if 0<= z <= k:
            n += 1
print(n)
def main():
    n,q = map(int,input().split())
    node = [[]for _ in range(n)]
    looked = [1]*n
    for i in range(n-1):
        a,b = map(int,input().split())
        node[b-1].append(a-1)
        node[a-1].append(b-1)
    counter = [0]*n
    for i in range(q):
        p,x = map(int,input().split())
        counter[p-1] += x
    queue = [0]
    looked[0] = 0
    while(queue):
        now = queue.pop(0)
        for i in node[now]:
            if looked[i]:
                queue.append(i)
                counter[i] += counter[now]
                looked[i] = 0
    print(*counter)
main()

### FIXED CODE ###

a = int(input())
s = str(input())
if (a >= 3200):
    print(s)
else:
    print('red')
N = int(input())
A = sorted(map(int, input().split()), reverse=False)
dp = [0] * (max(A)+1)

for i in range(N):
    if dp[A[i]] == 0:
        dp[A[i]] = 1
        for j in range(i+1, N):
            if A[j] != 2 and A[j] % A[i] == 0:
                dp[A[j]] = 2
print(dp.count(1))


### FIXED CODE ###

x = list(map(int, input().split()))
for i in range(5):
    if x[i] == 0:
        print(i+1)
        exit()
## ABC 054 b
import sys
import numpy as np

n,m = (int(_) for _ in input().split())
a = [list(input()) for i in range(n)]
b = [list(input()) for i in range(m)]
aa = np.array(a)
bb = np.array(b)

for i in range(n-m+1):
    for j in range(n-m+1):
        if (bb[:, :] == aa[i:i+m, j:j+m]):
            print('Yes')
            sys.exit(0)

print('No')

### FIXED CODE ###

## ABC 054 b
import sys

n,m = (int(_) for _ in input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]

if(a[::1] == b[::1]):
    print('Yes')
    sys.exit(0)

for i in range(n-m):
    for j in range(n-m):
        if (b[::1] == [ai[j:j+m] for ai in a[i:i+m]]):
            print('Yes')
            sys.exit(0)

print('No')
N = int(input())
C = [0]

prev = -1
for _ in range(N):
    c = int(input())
    if c == prev:
        continue
    else:
        C.append(c)
        prev = c

MOD = 10**9+7
n = len(C)-1
dp = [0]*(n+1)
last = [-1]*(n+1)
dp[0] = 1
for i in range(1, n+1):
    if last[C[i]] == -1:
        last[C[i]] = i
        dp[i] = dp[i-1]
    else:
        dp[i] = dp[i-1]+dp[last[C[i]]]
        dp[i] %= MOD
        last[C[i]] = i
print(dp[-1])


### FIXED CODE ###

N = int(input())
C = [-1]

for _ in range(N):
    c = int(input())
    if c == C[-1]:
        continue
    else:
        C.append(c)

MOD = 10**9+7
dp = 1
prev = [0]*(max(C)+1)

for c in C[1:]:
    dp = (dp+prev[c]) % MOD
    prev[c] = dp
print(dp)
q=input()
x=[int(i) for i in input().split()]
cnt=input()
j=0
y=[int(i) for i in input().split()]

if max(x) >= max(y): MAX=max(x)
else : MAX=max(y)

z=[0]*MAX

for k in x :
    z[k-1] += 1
    
for i in y :
    z[i-1] -= 1
    if z[i-1] == -1 :
        print('NO')
        exit()
        
print('YES')


### FIXED CODE ###


q=input()
x=[int(i) for i in input().split()]
cnt=input()
y=[int(i) for i in input().split()]

if max(x) >= max(y):
    MAX=max(x)
else:
    MAX=max(y)

dic = {}

for k in x :
    if k in dic.keys() :
        dic[k] += 1
    else :
        dic[k] = 1
    
for i in y :
    if i in dic.keys() :
        dic[i] -= 1
        if dic[i] == -1 :
            print('NO')
            exit()
    else :
        print('NO')
        exit()
print('YES')
N,M = list(map(int,input().split()))
A = input().split()

count = 0
A = np.array(A,dtype='int64')
B = np.cumsum(A)
C = np.append([0],B)

L = (1 for i in range(N+1) for t in range(N+1) if i<t and (C[t] - C[i])%M==0)
print(len(list(L)))

### FIXED CODE ###

import collections
import numpy as np

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

A = np.array(A,dtype='int64')
C = np.append([0],np.cumsum(A))
L = [i%M for i in C]
L_c = collections.Counter(L)

ans = 0
for i in L_c.values():
    S = i * (i-1) / 2
    ans+=S
    
print(int(ans))
n,d = list(map(int, input().split(' ')))

a = n // (2*d+1)

if n%((2*d+1)*a) == 0:
    print(a)
else:
    print(a+1)

### FIXED CODE ###

nd = list(map(int, input().split(' ')))

a = nd[0] // (nd[1]*2+1)

if (nd[0]%(nd[1]*2+1)) != 0:
    a += 1

print(a)
A, B, C, K = map(int, input().split())

if K<=A:
  print(str(K))
elif k<=A+B:
  print(str(A))
else:
  print(str(A-(C-(k-(A+B))))


### FIXED CODE ###

A,B,C,K = map(int,input().split())
 
if K <= A:
    print(str(K))
elif K <= A + B:
    print(str(A))
else:
    print(str(A - (C - (A + B + C - K))))
n = input()
a = 100000
while x <= n:
	a * 1.05
	a/1000*1000
	print a

### FIXED CODE ###

import math
n = input()
a = 100000
for val in range(1,n+1):
	a *= 1.05
	A = math.ceil(a/1000) * 1000
	a = A 
print int(a)
n = []
while True:
    try:
        c = list(raw_input().lower())
        n.append(c)

a = ""
for i in n:
    a = a + "".join(i)
n = list(a)
charac = []
for j in range(97,97+26):
    m= 0
    for i in range(0,len(n)):
        if ord(n[i]) == j:
            m += 1
        charac.append("{} : {}".format(chr(j),m))

for i in range(0,26):
    print(charac[i])

### FIXED CODE ###

s =""
while True:
    try:
        s += input().lower()
    except:
        break
    
s = list(map(ord,list(s)))
for i in range(ord("a"),ord("z")+1):
    print(chr(i) + " : " + str(s.count(i)))
import math
N = int(input())
A = sorted(list(map(int, input().split())))

cand = A[0]
 
for i in range(1,N):
    cand = math.gcd(cand, A[i])
    if cand == 1:
        break
print(cand)

### FIXED CODE ###

N = int(input())
A = sorted(list(map(int, input().split())))
 
# 最大公約数を求める関数
def gcd(a,b):
    rem = a % b
    while rem != 0:
        a = b
        b = rem
        rem = a % b
    return b
 
cand = A[0]
 
for i in range(1,N):
    cand = gcd(cand, A[i])
 
    if cand == 1:
        break
 
print(cand)
import sys
import math
import numpy as np
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

N = i()
A = l()
num = sum(A)//2
A = A+A
ans = [0]*N
for i in range(N):
    tmp = num
    for j in range(i,i+N-2,2):
        tmp -= A[j]
    ans[i-1] = tmp*2
for i in ans:
    print(i)


### FIXED CODE ###

def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))

N = i()
A = l()
num = sum(A)//2
A += A
ans = []
for i in range(1):
    num2 = 0
    for j in range(0,N,2):
        num2 += A[i+j]
    ans.append(abs((num-num2))*2)
    r = abs((num-num2))*2
for i in range(1,N):
    r = A[i-1]*2-r
    ans.append(r)
print(*ans)