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

def main():
    def find(x):
        if par[x] < 0:
            return x
        else:
            par[x] = find(par[x])
            return par[x]
    def unite(x, y):
        x = find(x)
        y = find(y)
        if x == y:
            return False
        else:
            if par[x] > par[y]:
                x, y = y, x
            par[x] += par[y]
            par[y] = x
            return True
    def members(x):
        root = find(x)
        return [i for i in range(n) if find(i) == root]

    def find2(x):
        if par2[x] < 0:
            return x
        else:
            par2[x] = find2(par2[x])
            return par2[x]
    def unite2(x, y):
        x = find2(x)
        y = find2(y)
        if x == y:
            return False
        else:
            if par2[x] > par2[y]:
                x, y = y, x
            par2[x] += par2[y]
            par2[y] = x
            return True
    def members2(x):
        root2 = find2(x)
        return [i for i in range(n) if find2(i) == root2]

    n, k, l = map(int, input().split())
    par = [-1] * (n)
    par2 = [-1] * (n)
    for _ in range(k):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        unite(a, b)
    for _ in range(l):
        c, d = map(int, input().split())
        c -= 1
        d -= 1
        unite2(c, d)
    for i in range(n):
        road = set(members(i))
        train = set(members2(i))
        #print(road, train)
        print(len(road & train), end=' ')

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
from collections import defaultdict
def main():
    def find(x):
        if par[x] < 0:
            return x
        else:
            par[x] = find(par[x])
            return par[x]
    def unite(x, y):
        x = find(x)
        y = find(y)
        if x == y:
            return False
        else:
            if par[x] > par[y]:
                x, y = y, x
            par[x] += par[y]
            par[y] = x
            return True
    def members(x):
        root = find(x)
        return [i for i in range(n) if find(i) == root]

    def find2(x):
        if par2[x] < 0:
            return x
        else:
            par2[x] = find2(par2[x])
            return par2[x]
    def unite2(x, y):
        x = find2(x)
        y = find2(y)
        if x == y:
            return False
        else:
            if par2[x] > par2[y]:
                x, y = y, x
            par2[x] += par2[y]
            par2[y] = x
            return True
    def members2(x):
        root2 = find2(x)
        return [i for i in range(n) if find2(i) == root2]

    n, k, l = map(int, input().split())
    par = [-1] * n
    par2 = [-1] * n
    for _ in range(k):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        unite(a, b)
    for _ in range(l):
        c, d = map(int, input().split())
        c -= 1
        d -= 1
        unite2(c, d)

    root_pairs = defaultdict(int)
    for i in range(n):
        root_pairs[find(i), find2(i)] += 1

    for i in range(n):
        print(root_pairs[find(i), find2(i)], end=' ')

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

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

ans = 1
for a in A:
  ans *= a

if ans > (10 ** 18):
  ans = -1

print(ans)


### FIXED CODE ###

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

ans = 1
A.sort()

ans = 1
for a in A:
  ans *= a
  if ans == 0:
    break
  if ans > 10 ** 18:
    ans = -1
    break

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

k = int(input())
t = 7

for i in range(k):
  if t % k == 0:
    print(i+1)
    break
  t = t * 10 + 7
else:
	print(-1)

### FIXED CODE ###

k=int(input())
n=7%k
for i in range(1,k+1):
  if n == 0:
    print(i)
    exit()
  n=(n*10+7) % k
print(-1)
### BUGGY CODE ###

n,m=map(int,input().split())
M=[1 for i in range(n)]
F=[]
for i in range(m):
    a,b=map(int,input().split())
    a,b=min(a,b),max(a,b)
    if [a,b] not in F:
        F.append([a,b])
        M[a-1]+=1
print(max(M))


### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def size(self, x):
        return -self.parents[self.find(x)]

n, m = map(int,input().split())
uf = UnionFind(n)
for i in range(m):
    a,b = map(int,input().split())
    uf.unite(a-1, b-1)

ans = 0
for i in range(n):
    ans = max(ans,uf.size(i))

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

n=int(input())
lists=[]
for _ in range(n-1):
    s=list(map(int,input().split()))
    lists.append(s)   
for x in range(n):
    nums=x+1
    if nums==n:
        print(0)
    else:
        times=0
        while nums<n:
            if times>=lists[nums-1][1]:
                while (times-lists[nums-1][1])%lists[nums-1][2]!=0:
                    times+=1
                times+=lists[nums-1][0]
                nums+=1
                    
            else:
                times=lists[nums-1][1]
                times+=lists[nums-1][0]   
                nums+=1 
        print(times)
            

### FIXED CODE ###

n=int(input())
lists=[list(map(int,input().split())) for _ in range(n-1)]  
for x in range(n):
    nums=x+1
    if nums==n:
        print(0)
    elif nums!=n:
        times=0
        while nums<n:
            if times>lists[nums-1][1]:
                if (times-lists[nums-1][1])%lists[nums-1][2]!=0:
                    a=(times-lists[nums-1][1])%lists[nums-1][2]  
                    times=times+lists[nums-1][2]-a
                    times+=lists[nums-1][0]
                    nums+=1  
                else:
                    times+=lists[nums-1][0]
                    nums+=1
            else:
                times=lists[nums-1][1]
                times+=lists[nums-1][0]   
                nums+=1 
        print(times)
### BUGGY CODE ###

import collections
S = input()
cnt = 0

mod = [0]
reverse_S = S[::-1]
for i in range(len(reverse_S)):
  now = int(reverse_S[i]) * pow(10,i,2019)
  mod.append((now + mod[i]) % 2019)

uniques = list(set(mod))
for i in uniques:
  hoge = mod.count(i)
  if hoge != 1:
    cnt += (hoge * (hoge - 1)) // 2


print(cnt)

### FIXED CODE ###

import collections
S = input()
cnt = 0

mod = [0]
reverse_S = S[::-1]
for i in range(len(reverse_S)):
  now = int(reverse_S[i]) * pow(10,i,2019)
  mod.append((now + mod[i]) % 2019)


c = collections.Counter(mod)
hindo = c.values()
for i in hindo:
  if i != 1:
    cnt += i*(i-1)//2


print(cnt)
### BUGGY CODE ###

s=[int(j) for j in input()][::-1]
m=len(s)
from collections import Counter
c=Counter()
tmp=0
c[0]+=1
for i in range(m):
    tmp+=pow(10,i)*s[i]
    c[tmp%2019]+=1
ll=c.most_common()
ans=0
for i,j in ll:
    if j>=2:
        ans+=j*(j-1)//2
    else:
        break
print(ans)


### FIXED CODE ###

s=[int(j) for j in input()][::-1]
c=[0]*2019
tmp=0
c[0]+=1
t=1
import numpy as np
for i in s:
    tmp+=t*i
    c[tmp%2019]+=1
    t=t*10%2019
c=np.array(c)
ans=c*(c-1)//2
print(ans.sum())
### BUGGY CODE ###

from fractions import gcd
from functools import reduce

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

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

n,m = map(int, input().split())
a = list(map(int, input().split()))
b = [i//2 for i in a]
g = lcm_list(b)
if any((g//(i//2))%2==0 for i in a):
    ans = 0
else:
    ans = (m//g+1)//2
print(ans)

### FIXED CODE ###

from fractions import gcd
def lcm(nums):
    ret = 1
    for i in nums:
        ret = ret*i//gcd(ret, i)
        if ret>m:
            return m+1
    return ret

n,m = map(int, input().split())
a = list(map(int, input().split()))
b = [i//2 for i in a]
g = lcm(b)
if any((g//i)%2==0 for i in b):
    ans = 0
else:
    ans = (m//g+1)//2
print(ans)
### BUGGY CODE ###

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

for i in range(1,n+1):
    print(a.index(i)+1,end=' ')

### FIXED CODE ###

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

b = []

for i in range(n):
    b.append([a[i],i + 1])
    
b.sort()
for j in b:
    print(j[1],end=' ')
print()
### BUGGY CODE ###

S = input()
n= int(input())

for i in range(n):
  Q = [i for i in input().split()]
  if Q[0] =='1':
    S = S[::-1]
    #print(S)
  else:
    if Q[1]=='1':
      S = Q[2]+S
    else:
      S =S+Q[2]
    #print(S)
print(S)

### FIXED CODE ###

from collections import deque

S = deque(input())
n= int(input())
condition=True

for i in range(n):
  Q = [i for i in input().split()]
  if Q[0] =='1':
    if condition ==True:
      condition=False
    else:
      condition=True
  else:
    if Q[1]=='1':
      if condition ==True:
        S.appendleft(Q[2])
      else:
        S.append(Q[2])
    else:
      if condition==True:
        S.append(Q[2])
      else:
        S.appendleft(Q[2])
    #print(S)

if condition ==False:
  S.reverse()

for i in S:
  print(i, end='')
### BUGGY CODE ###

H, W = map(int,input().split())
S = [list(input()) for _ in range(H)]
table = [[0 for _ in range(W)] for _ in range(H)]
def dfsW(n):
  global table
  l = -1
  r = -1
  i = 0
  while i < W:
    if S[n][i] == ".":
      if l == -1:
        l = i
      r = i
    else:
      if l != -1:
        for j in range(l, r + 1):
          table[n][j] += r - l + 1
      l = -1
      r = -1
    i += 1
  if l != -1:
    for j in range(l, r + 1):
      table[n][j] += r - l + 1


def dfsH(n):
  global table
  l = -1
  r = -1
  i = 0
  while i < H:
    if S[i][n] == ".":
      if l == -1:
        l = i
      r = i
    else:
      if l != -1:
        for j in range(l, r + 1):
          table[j][n] += r - l + 1
      l = -1
      r = -1
    i += 1
    
  if l != -1:
    for j in range(l, r + 1):
      table[j][n] += r - l + 1


for i in range(H):
  dfsW(i)
for i in range(W):
  dfsH(i)
print(max(map(max, table)) - 1)

### FIXED CODE ###

H, W = map(int,input().split())
S = [list(input()) for _ in range(H)]
table = [[0 for _ in range(W)] for _ in range(H)]
def dfsW(n):
  global table
  l = -1
  r = -1
  i = 0
  while i < W:
    if S[n][i] == ".":
      if l == -1:
        l = i
      r = i
    else:
      if l != -1:
        for j in range(l, r + 1):
          table[n][j] += r - l + 1
      l = -1
      r = -1
    i += 1
  if l != -1:
    for j in range(l, r + 1):
      table[n][j] += r - l + 1


def dfsH(n):
  global table
  l = -1
  r = -1
  i = 0
  while i < H:
    if S[i][n] == ".":
      if l == -1:
        l = i
      r = i
    else:
      if l != -1:
        for j in range(l, r + 1):
          table[j][n] += r - l + 1
      l = -1
      r = -1
    i += 1
    
  if l != -1:
    for j in range(l, r + 1):
      table[j][n] += r - l + 1


for i in range(H):
  dfsW(i)
for i in range(W):
  dfsH(i)
print(max(map(max, table)) - 1)
### BUGGY CODE ###

modder = int(1e+9 + 7)


def mod(x):
    return x % modder


def explore(i, s, dp={}):
    if i == 0:
        dp = [0 if j < 3 else 1 for j in range(2000 + 1)]
    if not ((i + 2) * 3 <= s):
        return mod(dp[s])
    new_dp = [0] * (2000 + 1)
    for n in range(2000 + 1):
        value = 0
        if n >= 3 * (i + 1):
            for m in range(3, n - 3 * i):
                value = mod(mod(dp[n - m]) + value)

        new_dp[n] = value
    return mod(dp[s] + explore(i + 1, s, new_dp))


if __name__ == '__main__':
    S = int(input())
    print(explore(0, S))


### FIXED CODE ###

def mod(x):
    return int(x % (1e+9 + 7))


def combination_dp(s):
    if s < 3:
        return 0
    dp = []
    dp.append(1)
    for i in range(1, s + 1):
        if i < 3:
            dp.append(0)
        else:
            start = 0
            end = i - 3 + 1
            dp.append(mod(sum(dp[start: end])))
    return dp[-1]


if __name__ == '__main__':
    S = int(input())
    print(combination_dp(S))
### BUGGY CODE ###

import sys
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
ct=[0 for i in range(n)]
fin=0
day=0
count=0
check=[0,0]
while count!=n*(n-1)//2:
  L=[0 for i in range(n)]
  f1=0
  for i in range(n):
    if L[i]==0 and ct[i]!=n-1:
      x=l[i][ct[i]]
      if l[x-1][ct[x-1]]-1==i and L[x-1]==0:
        ct[i]+=1
        ct[x-1]+=1
        L[i]=1
        L[x-1]=1
        count+=1
  day+=1
  check[0]=check[1]
  check[1]=count
  if check[0]==check[1]:
    print(-1)
    sys.exit()
print(day)

### FIXED CODE ###

import sys
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
ct=[0 for i in range(n)]
fin=0
day=0
count=0
check=[0,0]
while count!=n*(n-1)//2 and day<=10**4:
  L=[0 for i in range(n)]
  f1=0
  for i in range(n):
    if L[i]==0 and ct[i]!=n-1:
      x=l[i][ct[i]]
      if l[x-1][ct[x-1]]-1==i and L[x-1]==0:
        ct[i]+=1
        ct[x-1]+=1
        L[i]=1
        L[x-1]=1
        count+=1
  day+=1
  check[0]=check[1]
  check[1]=count
  if check[0]==check[1]:
    print(-1)
    sys.exit()
if day>10**4:
  print(n*(n-1)//2)
  sys.exit()
print(day)
### BUGGY CODE ###

import numpy as np
N,K,Q=map(int, input().split())
A=np.array([int(input()) for _ in range(Q)])
P=np.array([K]*N)
for a in A:
    p=np.array([1]*N)
    p[a-1]=0
    P-=p
for x in P:
    if x>0:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

N,K,Q=map(int, input().split())
A=[int(input()) for _ in range(Q)]
P=[0]*N
for a in A:
    P[a-1]+=1
for x in P:
    if K-Q+x>0:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

import copy


def bfs(x, y, goal_h, goal_w, c, s):
    if x < 0 or y < 0 or x >= H or y >= W or s[x][y] == '#':
        return 10000
    if x == goal_h and y == goal_w:
        return c
    s[x][y] = '#'
    return min([bfs(next_x, next_y,goal_h, goal_w, c+1, copy.deepcopy(s))
                for next_x, next_y in ([x+1, y], [x-1, y], [x, y+1], [x, y-1])])
    
H, W = map(int, input().split())
S = []
cnt = []


for _ in range(H):
    S.append([i for i in input()])
    
for start_h in range(H):
    for start_w in range(W):
        if S[start_h][start_w] == '#':
            continue
        for goal_h in range(H):
            for goal_w in range(W):
                if S[goal_h][goal_w] == '#':
                    continue
                if start_h == goal_h or start_w == goal_w:
                    cnt.append(abs(start_h - goal_h) + abs(start_w - goal_w))
                    continue
                c = 0
                s = copy.deepcopy(S)
                s[start_h][start_w], s[goal_h][goal_w] = 'S', 'G'
                cnt.append(bfs(start_h, start_w, goal_h, goal_w, c, s))

print(max(cnt))

### FIXED CODE ###

from queue import deque
from copy import deepcopy

    
H, W = map(int, input().split())
S = [['#'] * (W + 2)]
cnt = []
Checked = [[0 for _ in range(W+2)] for _ in range(H+2)]


for _ in range(H):
    S.append(['#'] + [i for i in input()] + ['#'])
S.append(['#']*(W + 2))

for start_h in range(1, H+1):
    for start_w in range(1, W+1):
        if S[start_h][start_w] == '#':
            continue
        q = deque([[start_h, start_w]])
        checked = deepcopy(Checked)
        c = 0
        tmp = []
        while q:
            h, w = q.popleft()
            if checked[h][w]:
                 continue
            checked[h][w] = 1
                    
            for dw, dh in ([1, 0], [-1, 0], [0, 1], [0, -1]):
                next_h, next_w = h + dh, w + dw
                if S[next_h][next_w] == '#':
                    continue
                if [next_h, next_w] in tmp or checked[next_h][next_w]:
                    continue
                tmp.append([next_h, next_w])
            if not q:
                q.extend(tmp)
                tmp = []
                c += 1
        cnt.append(c-1)
            
print(max(cnt))
### BUGGY CODE ###

s=list(input())
q=int(input())
for _ in range(q):
  t=list(input().split())
  if len(t)==1:
    s=s[::-1]
  else:
    if int(t[1])==1:
      s=[t[2]]+s
    else:
      s=s+[t[2]]
print(''.join(s))

### FIXED CODE ###

s=list(input())
q=int(input())
t1,t2=[],[]
cnt=0
for _ in range(q):
  t=list(input().split())
  if len(t)==1:
    cnt+=1
    t1,t2=t2,t1
  else:
    if int(t[1])==1:
      t1+=[t[2]]
    else:
      t2+=[t[2]]
if cnt%2==1:
  s=s[::-1]
u=t1[::-1]+s+t2
print(''.join(u))
### BUGGY CODE ###

n=int(input())
c=0
for i in range(n):
    p=int(input())
    for j in range(2,p):
        if p%j==0:
            break
    else:
        c+=1
print(c)


### FIXED CODE ###

n=int(input())
c=0
for i in range(n):
    p=int(input())
    if pow(2,p-1,p)==1 or p==2:
        c+=1
print(c)
### BUGGY CODE ###

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

mod=2019
a=input()

N=len(a)
t=[]
ans=0

for i in range(N-2):
  for j in range(i+3,N+1):
    u=int(a[i:j])
    #print(u)
    if (u % mod)==0:
      ans+=1
      #print(i+1,j)
      break
print(ans)


### FIXED CODE ###

mod=2019
a=input()

N=len(a)
t=[0]*mod
t[0]=1

w=1
u=0

for i in range(N):
  u=int(a[N-1-i]) * w + u
  v=u % mod
  t[v] += 1
  w *=10
  w %= mod

ans=0
for i in t:
  ans += (i-1)*i//2

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

import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


X, Y, Z, K = read_ints()
A = read_ints()
B = read_ints()
C = read_ints()

from itertools import product

AB = [a + b for a, b in product(A, B)]
AB.sort(reverse=True)
AB = AB[:K]

ABC = [ab + c for ab, c in product(AB, C)]
ABC.sort(reverse=True)

ABC = ABC[:K]

print(*ABC, sep='\n')


### FIXED CODE ###

import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


X, Y, Z, K = read_ints()
A = read_ints()
B = read_ints()
C = read_ints()

from itertools import product

AB = [a + b for a, b in product(A, B)]
AB.sort(reverse=True)

ABC = [ab + c for ab, c in product(AB[:K], C)]
ABC.sort(reverse=True)

ABC = ABC[:K]

print(*ABC, sep='\n')
### BUGGY CODE ###

n, m = map(int, input().split())
a = [int(input()) for x in range(m)]

l = [1]
for i in range(1, n+1):
  if len(l) == 2:
    tmp = l[0]
    tmp1 = l[1]
    if i in a:
      if tmp1 == 0:
        print(0)
        exit()
      l[0] = tmp1
      l[1] = 0
    else:
      l[0] = tmp1
      l[1] = tmp + tmp1
  else:
    if i in a:
      l.append(0)
    else:
      l.append(1)

print(l[-1] % 1000000007)


### FIXED CODE ###

n, m = map(int, input().split())
a = set([int(input()) for x in range(m)])

l = [0]*(n+1)
l[0] = 1

for i in range(1, n+1):
  if i in a:
    l[i] = 0
    continue
  else:
    l[i] = l[i-2] + l[i-1]

print(l[-1] % 1000000007)
### BUGGY CODE ###


n,m = map(int,input().split())
s = list(input())
edges = [tuple(map(int,input().split())) for i in range(m)]


edgeset = set()
for i,j in edges:
    edgeset.add((min(i,j),max(i,j)))


def addEdge(graph,u,v):
    graph[u].add(v)


def deleteNode(graph,node):
    graph.pop(node,None)

from collections import defaultdict
graphAB = defaultdict(set)
graphABopp = defaultdict(set)

for i,j in edgeset:
    addEdge(graphAB,i,j)
    addEdge(graphABopp,j,i)

abli = [[0,0] for i in range(n)]

def incrimentAB(j,char):
    if char == 'A':
        abli[j-1][0] += 1
    if char =='B':
        abli[j-1][1] += 1

def decrimentAB(j,char):
    if char == 'A':
        abli[j-1][0] -= 1
    if char =='B':
        abli[j-1][1] -= 1


def adjAB(node):
    if abli[node-1][0] != 0 and abli[node-1][1] != 0:
        return(True)
    else:
        return(False)

for i,j in edgeset:
    incrimentAB(j,s[i-1])
    incrimentAB(i,s[j-1])



visitset = set([i for i in set(graphAB.keys())|set(graphABopp.keys()) if not adjAB(i)])
deleteset = set()
#print(visitset)

while bool(visitset):
    i = visitset.pop()
    deleteset.add(i)
    for j in graphAB[i]:
        decrimentAB(j,s[i-1])
        graphABopp[j].remove(i)
        if not adjAB(j):
            visitset.add(j)
            #print(visitset,'add')
    for j in graphABopp[i]:
        decrimentAB(j,s[i-1])
        graphAB[j].remove(i)
        if not adjAB(j):
            visitset.add(j)
            #print(visitset,'add')
    graphAB.pop(i,None)
    graphABopp.pop(i,None)

#print(graphAB)
#print(graphABopp)


if graphAB == {} and graphABopp == {}:
    print('No')
else:
    print('Yes')






### FIXED CODE ###

#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
GC027 C
"""

n,m = map(int,input().split())
s = list(input())
edges = [tuple(map(int,input().split())) for i in range(m)]
ali = [0 for i in range(n)]
bli = [0 for i in range(n)]


def addEdge(graph,u,v):
    graph[u].add(v)


from collections import defaultdict
graphAB = defaultdict(set)

def incrementAB(node,adj):
    if s[adj-1] == 'A':
        ali[node-1]+=1
    if s[adj-1] == 'B':
        bli[node-1]+=1

def decrementAB(node,adj):
    if s[adj-1] == 'A':
        ali[node-1]-=1
    if s[adj-1] == 'B':
        bli[node-1]-=1

for i,j in edges:
    addEdge(graphAB,i,j)
    addEdge(graphAB,j,i)

def adjAB(node):
    if ali[node-1]!=0 and bli[node-1]!=0:
        return(True)
    else:
        return(False)

graphvers = set(graphAB.keys())
visitset = set()
for i in range(1,n+1):
    if not i in graphvers:
        s[i-1] = 'C'
    else:
        for j in graphAB[i]:
            incrementAB(i,j)
        if not adjAB(i):
            visitset.add(i)


while bool(visitset):
    #print(graphAB)
    #print(graphABopp)
    #print(abli)
    i = visitset.pop()
    for j in graphAB[i]:
        if s[j-1] != 'C':
            decrementAB(j,i)
            if not adjAB(j):
                visitset.add(j)
    s[i-1] = 'C'

#print(graphAB)
#print(graphABopp)

sset= set(s)
sset.add('C')
sset.remove('C')
if bool(sset):
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

N=int(input())


b=[]
k=N%2
for a in list(map(int,input().split())):
    if k==a%2:
        b.insert(0,a)
    else:
        b.append(a)
print(' '.join(map(str,b)))

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
print(' '.join(map(str,A[::-2]+A[N%2::2])))
### BUGGY CODE ###

import math
from functools import reduce
import sys
input = sys.stdin.readline  # 改行コード「\n」を呼んでしまうため、文字数など、注意！！


def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

# print(gcd(100,20,10))

k = int(input().replace("\n",""))
ans = 0

for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ans += gcd(a,b,c)

print(ans)

### FIXED CODE ###

import math
from functools import reduce
import sys
input = sys.stdin.readline  # 改行コード「\n」を呼んでしまうため、文字数など、注意！！


def gcd(*numbers):
    return reduce(math.gcd, numbers)

# print(gcd(100,20,10))

k = int(input().replace("\n",""))
ans = 0

for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ans += gcd(a,b,c)

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

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

lst.sort()

visited = [0 for _ in range(n)]
ans = n
for i in range(n):
  if visited[i] == 0:
    for j in range(i+1,n):
      if lst[j] % lst[i] == 0 and visited[j] == 0:
        ans -= 1
        visited[j] = 1
        if lst[j] == lst[i] and visited[i] == 0:
          ans -= 1
          visited[i] = 1
             
print(ans)

### FIXED CODE ###

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


maxA = max(a)
dp = [0]*(maxA+1)
count = 0

for e in a:
    for i in range(e,maxA+1,e):
        dp[i] += 1

for e in a:
    if dp[e] == 1:
        count += 1

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

from bisect import bisect

#n:shinamono no kazu
#m:waribiki maisuu

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

a=sorted(list(map(int,input().split())))

indexMax=len(a)-1

for _ in range(m):
  maxA=a[indexMax]
  a.pop(indexMax)
  a.insert(bisect(a, maxA/2.0), maxA/2.0)

#print(a)
result=0
for item in a:
  result+=item//1
  
print(int(result))

### FIXED CODE ###

#n:shinamono no kazu
#m:waribiki maisuu
import heapq

n,m=map(int,input().split())
a=list(map(lambda x:int(x)*(-1),input().split()))
#print(temp)
heapq.heapify(a)
for _ in range(m):
  minA=heapq.heappop(a)
  #print(minA)
  heapq.heappush(a,minA/2.0)
  #print(a)
#print(a)
result=0
for item in a:
  result+=item*(-1)//1
  
print(int(result))