Harryxun/stf_run huggingface dataset:
import math
from copy import copy
di = {}
di[0] = 0
for i in range(1, 2*(10**3)+1):
    di[i] = 0
for i in range(1, 2*(10**3)+1):
    count = 0
    for j in range(int(math.log2(i))+4):
        if (i>>j)&1:
            count += 1
    di[i] = di[i%count] + 1
n = int(input())
x = list(input())
x.reverse()
count = 0
for i in x:
    if i =='1':
        count += 1
mod_p = count + 1
mod_m = count - 1
di_p = {}
di_m = {}
for i in range(n):
    di_p[i] = pow(2, i, mod_p)
    di_m[i] = pow(2, i, mod_m)
s_p = 0
s_m = 0
for i in range(n):
    if x[i] == '1':
        s_p += di_p[i]
        s_m += di_m[i]
for i in range(n-1, -1, -1):
    sm = copy(s_m)
    sp = copy(s_p)
    if x[i] == '1':
        sm -= di_m[i]
        sm %= mod_m 
        print(di[sm]+1)
    else:
        sp += di_p[i]
        sp %= mod_p
        print(di[sp]+1)


### FIXED CODE ###

import math
from copy import copy
di = {}
di[0] = 0
for i in range(1, 2*(10**6)+1):
    di[i] = 0
for i in range(1, 2*(10**6)+1):
    count = 0
    for j in range(int(math.log2(i))+4):
        if (i>>j)&1:
            count += 1
    di[i] = di[i%count] + 1
n = int(input())
x = list(input())
x.reverse()
count = 0
for i in x:
    if i =='1':
        count += 1
mod_p = count + 1
mod_m = count - 1
di_p = {}
di_m = {}
for i in range(n):
    di_p[i] = pow(2, i, mod_p)
    if mod_m >= 1:
        di_m[i] = pow(2, i, mod_m)
s_p = 0
s_m = 0
for i in range(n):
    if x[i] == '1':
        s_p += di_p[i]
        if mod_m >= 1:
            s_m += di_m[i]
    else:
        continue
for i in range(n-1, -1, -1):
    sm = copy(s_m)
    sp = copy(s_p)
    if x[i] == '1' and (mod_m == 0 or mod_m == -1):
        print(0)
    elif x[i] == '1':
        sm -= di_m[i]
        sm %= mod_m 
        print(di[sm]+1)
    else:
        sp += di_p[i]
        sp %= mod_p
        print(di[sp]+1)
a = int(input())
b = int(input())
if a*b % 2 == 0:
    print('even')
else:
    print('odd')

### FIXED CODE ###

a,b=map(int,input().split())
 
if a*b%2==0:
  print("Even")
else:
  print("Odd")
n = int(input())
ans = 0
for i in range(1,n+1):
  res = 0
  for j in range(i+1):
    if i % j ==0:
      res +=1
    if res == 8 :
      ans +=1

print(ans)
    

### FIXED CODE ###

n = int(input())
ans = 0
for i in range(1,n+1,2):
  res = 0
  for j in range(1,i+1):
    if i % j == 0:
      res +=1
    if res == 8:
      ans +=1
print(ans)
a,b=map(int,input().split())
if (a*b)%2=0:
  print("Even")
else:
  print("Odd")

### FIXED CODE ###

a,b=map(int,input().split())
if (a*b)%2==0:
  print("Even")
else:
  print("Odd")
A,B,C,D=map(int,input().split())
c_dividable=B//C-(A-1)//C
d_dividable=B//D-(A-1)//D
def gcd(a,b):
  if a==b:
    return q
  else:
    if a%b==0:
      return b
    while a%b!=0:
      return gcd(b,a%b)
v=C*D//gcd(C,D)
cd_dividable=B//v-(A-1)//v
print(B-A+1-(c_dividable+d_dividable-cd_dividable))

### FIXED CODE ###

A,B,C,D=map(int,input().split())
c_dividable=B//C-(A-1)//C
d_dividable=B//D-(A-1)//D
def gcd(a,b):
  if a==b:
    return a
  else:
    if a%b==0:
      return b
    while a%b!=0:
      return gcd(b,a%b)
v=C*D//gcd(C,D)
cd_dividable=B//v-(A-1)//v
print(B-A+1-(c_dividable+d_dividable-cd_dividable))
def binary_search(list, item):
    low = 0
    high = len(list) - 1
    while low <= high:
        mid = (low + high) //2
        guess = list[mid]
        if guess == item:
            return mid
        if guess > item:
            high = mid -1
        else:
            low = mid + 1

    return mid


n= int(input())
a=list(map(int, input().split()))
ans=0
a.sort(reverse=True)
for i in range(n-1):
    if a[i]:
        bi=format(a[i], 'b')
        x=2**len(bi)-a[i]
        if a[i]==x and a[i+1]==x:
            ans+=1
            a[i]=None
            c=binary_search(a,x)
            a[c]=None
print(ans)

### FIXED CODE ###

import collections
import bisect
n= int(input())
a=list(map(int, input().split()))
c=collections.Counter(a)
ans=0
des=sorted(a,reverse=True)
# asc=sorted(a)

for i in des:
    if c[i]>0:
        bi=format(i, 'b')
        x=2**len(bi)-i
        c[i]-=1
        if c[x]>0:
            c[x]-=1
            ans+=1
print(ans)
N = int( input() )

L = list(range(1,N+1))



if len(L)==1:
    print(L[0]%1)

elif len(L)==2:
    print(L[0]%2)

    


elif L[len(L)-1] % 2 == 0:
    print(sum(L[1:len(L)-1]))

else:
    print(sum(L[0:len(L)-1]))


### FIXED CODE ###

N = int(input())
print( (N *(N-1)) // 2 )
from collections import Counter
def main():
    n = int(input())
    a = list(map(int,input().split()))
    a.sort(reverse=True)
    ac = Counter(a)
    acl = [i for i in ac if ac[i] >= 2]

    if ac[acl[0]] >= 4:
        print(int(acl[0] ** 2))
    else:
        print(int(acl[0]*acl[1]))

if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import Counter
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ac = Counter(a)
    acl = [i for i in ac if ac[i] >= 2]
    acl.sort(reverse=True)

    if len(acl) == 0:
        print(0)
    elif ac[acl[0]] >= 4:
        print(int(acl[0] * acl[0]))
    elif len(acl) <= 1:
        print(0)
    else:
        print(int(acl[0]*acl[1]))

if __name__ == '__main__':
    main()
n = int(input())
d = list(map(int, input().split()))
dic = {}
val = 0

for i in range(n):
    if d[i] in dic.keys():
        dic[d[i]] += 1
    else:
        dic[d[i]] = 1

dic = sorted(dic.items())

for i in range(len(dic) - 1):
    val += dic[i][1]
    if val == n//2:
        ans = (dic[i][0] + 1, dic[i+1][0])
        break
    elif i == len(dic) - 2:
        ans = (1, 0)
        break

print(ans[1] - ans[0] + 1)


### FIXED CODE ###

import sys

n = int(input())
d = list(map(int, input().split()))
dic = {}
val = 0

for i in range(n):
    if d[i] in dic.keys():
        dic[d[i]] += 1
    else:
        dic[d[i]] = 1

dic = sorted(dic.items())

if len(dic) == 1:
    print(0)
    sys.exit() 

for i in range(len(dic) - 1):
    val += dic[i][1]
    if val == n//2:
        ans = (dic[i][0], dic[i+1][0])
        print(ans[1] - ans[0])
        break
    elif val > n//2:
        print(0)
        break
A, B = input().split()


 
print(int(A) * int(B * 100) // 100)

### FIXED CODE ###

A, B = input().split()
print(int(A) * int(B.replace(".", "")) // 100)
h,w=map(int,input().split())
a=[list(map(int,list(input().split()))) for _ in range(h)]

ans=[]
for i in range(h):
    for j in range(w-1):
        if a[i][j]%2==1:
            a[i][j+1]+=1
            ans.append([i+1,j+1,i+1,j+2])

for i in range(h):
    if a[i][-1]%2==1:
        a[i+1][-1]+=1
        ans.append([i+1,j+1,i+2,j+1])

print(len(ans))
for i in ans:
    print(*i)

### FIXED CODE ###

h,w=map(int,input().split())
a=[list(map(int,list(input().split()))) for _ in range(h)]

ans=[]
for i in range(h):
    for j in range(w-1):
        if a[i][j]%2==1:
            a[i][j+1]+=1
            ans.append([i+1,j+1,i+1,j+2])

for i in range(h-1):
    if a[i][w-1]%2==1:
        a[i+1][w-1]+=1
        ans.append([i+1,w,i+2,w])
print(len(ans))
for i in ans:
    print(*i)
n=int(input())
i=1
lis=[]
while(i*i<=n):
  count=0
  while(n%i==0):
    count+=1
    n=n//i
  if(count！=0):lis.append(count)
x=1
for i in lis:
  x*=(i+1)
print(x)

### FIXED CODE ###

import sys
n=int(input())
lis=[0for i in range(n)]
for i in range(2,n+1):
  ib=i
  for j in range(2,ib+1):
    while(ib%j==0):
      lis[j-1]+=1
      ib=ib//j
pat=1
for i in lis:pat*=(i+1)
print(pat%(10**9+7))
a, b, k = map(int,input().split())
n = list(range(b+1))
print(*sorted(set(n[a:(a+k)]) | set(n[-k:])),sep="\n")

### FIXED CODE ###

a, b, k = map(int,input().split())
n = range(a,b+1)
print(*sorted(set(n[:k]) | set(n[-k:])),sep="\n")
#二部グラフになっている時の色の塗り分けを聞いている
n=int(input())
es=[[] for i in range(n)]
for i in range(n-1):
  u,v,w=list(map(int,input().split()))
  es[u-1].append([v,w])
  es[v-1].append([u,w])
import sys
if n==1:
  print(0)
  sys.exit()
colors=[0 for i in range(n)]
#深さ優先探索　頂点vをcolorで塗ることを考える
def dfs(v,color):
  colors[v-1]=color
  for i in es[v-1]:
    if i[1]%2==0 and colors[i[0]-1]==0:
      dfs(i[0],color)
    elif i[1]%2==1 and colors[i[0]-1]==0:
      dfs(i[0],(-1)*color)
  return colors

    
a=dfs(1,-1)
for i in a:
  if i==-1:
    print(0)
  else:
    print(1)
  


### FIXED CODE ###

# 再帰の深さが1000を超えそうなときはこれをやっておく
import sys
sys.setrecursionlimit(10**7)
#二部グラフになっている時の色の塗り分けを聞いている
n=int(input())
es=[[] for i in range(n)]
for i in range(n-1):
  u,v,w=list(map(int,input().split()))
  es[u-1].append([v,w])
  es[v-1].append([u,w])

colors=[0 for i in range(n)]
#深さ優先探索　頂点vをcolorで塗ることを考える
def dfs(v,color):
  colors[v-1]=color
  for i in es[v-1]:
    if i[1]%2==0 and colors[i[0]-1]==0:
      dfs(i[0],color)
    elif i[1]%2==1 and colors[i[0]-1]==0:
      dfs(i[0],(-1)*color)
  return colors

    
a=dfs(1,-1)
for i in a:
  if i==-1:
    print(0)
  else:
    print(1)
import fractions

N,X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()

if N != 1:
    A = [0]*(N-1)
    for i in range(N-1):
        A[i] = x[i+1]-x[i]

    a = A[0]
    for i in range(N-1):
        a = fractions.gcd(a,A[i])
    print(a)
else:
    print(x[1]-x[0])


### FIXED CODE ###

a,b = map(int, input().split())
if a*b % 2 == 1:
  print("Yes")
else:
  print("No")
def main():
    n, m, k = list(map(int, input().split()))
    a_books = list(map(int, input().split()))
    b_books = list(map(int, input().split()))

    sumbooks = sum(a_books) + sum(b_books)
    count = len(a_books) + len(b_books)
    if a_books[0] > k and b_books[0] > k:
        print(0)
        exit()
    elif sumbooks <= k:
        print(len(a_books) + len(b_books))
        exit()

    while sumbooks > k:
        if len(a_books) and a_books[-1] >= b_books[-1]:
            sumbooks -= a_books.pop(-1)
        elif len(b_books) and b_books[-1] >= a_books[-1]:
            sumbooks -= b_books.pop(-1)

        if sumbooks <= k:
            break
        count -= 1
    print(count)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main2():
    n, m, k = list(map(int, input().split()))
    a_books = list(map(int, input().split()))
    b_books = list(map(int, input().split()))

    a, b = [0], [0]
    
    for i in range(len(a_books)):
        a.append(a[i] + a_books[i])

    for i in range(len(b_books)):
        b.append(b[i] + b_books[i])
    ans, j  = 0, len(b_books)
    
    for i in range(len(a)):
        if a[i] > k :
            break
        while b[j] > k - a[i]:
            j -= 1
        ans = max(ans, i+j)
    print(ans)


if __name__ == '__main__':
    main2()
A,op,B=list(map(int, input().split()))
if op=='+:'
  print(A+B)
else:
  print(A-B)

### FIXED CODE ###

A,op,B=input().strip().split()
if op == '+':
  print(int(A)+int(B))
else:
  print(int(A)-int(B))
N,M,Q=map(int,input().split())
A=[]
for i in range(M+Q):
    L,R=map(int,input().split())
    A.append([L,R])
#print(A)
B = [[0 for i in range(500)] for j in range(500)]

for i in range(M):
    B[A[i][0]][A[i][1]] +=1
#print(*B,sep='\n')
C = [[0 for i in range(500)] for j in range(500)]
for i in range(500):
    for k in range(500):
        if k==0:
            C[i][k] = B[i][k]
        else:
            C[i][k] += C[i][k-1]+B[i][k]
#print('\n')
#print(*C,sep='\n')
for i in range(M,M+Q):
    total=0
    for k in range(500):
        if A[i][0]<=k<=A[i][1]:
            total+=C[k][A[i][1]]-C[k][A[i][0]-1]
    print(total)

### FIXED CODE ###

N,M,Q=map(int,input().split())
N=550
A=[]
for i in range(M+Q):
    L,R=map(int,input().split())
    A.append([L,R])
#print(A)
B = [[0 for i in range(N+1)] for j in range(N+1)]

for i in range(M):
    B[A[i][0]][A[i][1]] +=1
#print(*B,sep='\n')
C = [[0 for i in range(N+1)] for j in range(N+1)]
for i in range(N):
    for k in range(N):
        if k==0:
            C[i][k] = B[i][k]
        else:
            C[i][k] += C[i][k-1]+B[i][k]
#print('\n')
#print(*C,sep='\n')
for i in range(M,M+Q):
    total=0
    for k in range(N):
        if A[i][0]<=k<=A[i][1]:
            total+=C[k][A[i][1]]-C[k][A[i][0]-1]
    print(total)
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

X,Y,Z,K = II()
A = III()
B = III()
C = III()

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

a = []
if X*Y*Z <= 10**6:
    for i in range(X):
        for j in range(Y):
            for k in range(Z):
                a.append(A[i]+B[j]+C[k])
    a.sort(reverse=True)
    for i in range(K):
        print(a[i])
else:
    for i in range(X):
        for j in range(min(Y,math.ceil(5000/i))):
            for k in range(min(Z,math.ceil(5000/i/j))):
                a.append(A[i]+B[j]+C[k])
    a.sort(reverse=True)   
    for i in range(K):
        print(a[i])

### FIXED CODE ###

#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

X,Y,Z,K = II()
A = III()
B = III()
C = III()

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

a = []
if X*Y*Z <= 10**6:
    for i in range(X):
        for j in range(Y):
            for k in range(Z):
                a.append(A[i]+B[j]+C[k])
    a.sort(reverse=True)
    for i in range(K):
        print(a[i])
else:
    for i in range(X):
        if i==0: jmax = Y
        else: jmax = min(Y,math.ceil(5000/i))
        for j in range(jmax):
            if i*j==0: kmax = Z
            else: kmax = min(Z,math.ceil(5000/i/j))
            for k in range(kmax):
                a.append(A[i]+B[j]+C[k])
    a.sort(reverse=True)   
    for i in range(K):
        print(a[i])
print('Draw')n, a, b = map(int, input().split())

if (b-a)  % 2 == 0:
    ans = 'Alice'
else:
    ans = 'Borys'

print(ans)

### FIXED CODE ###

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

if (b-a)  % 2 == 0:
    ans = 'Alice'
else:
    ans = 'Borys'

print(ans)
n=int(input())
b=list(map(int,input().split()))
ans=0
w=max(b)
a=[0]*w
for i in b:
  x=i
  while x<w:
    a[x]=1
    x+=i
for i in b:
  if a[i]==0:
    ans+=1

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
max_a = max(a)
cnt_d = [0] * (max_a + 1)

for ai in a:
    for multi in range(ai, max_a + 1, ai):
        cnt_d[multi] += 1

print(sum(cnt_d[ai] == 1 for ai in a))
n = int(input())
x = int(input(),2)
zuru = [0, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 3, 1, 2, 1, 2, 1, 1, 2, 3, 1, 2, 2, 3, 2, 2, 2, 2, 1, 2, 1, 2, 1, 2, 2, 3, 1, 2, 1, 3, 2, 2, 2, 2, 1, 2, 2, 3, 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 3, 1, 2, 1, 2, 1, 1, 2, 3, 1, 2, 2, 3, 2, 2, 2, 2, 1, 1, 2, 3, 1, 2, 2, 2, 2, 2, 2, 2, 1, 3, 2, 3, 1, 2, 2, 3, 2, 2, 2, 3, 2, 2, 2, 2, 1, 2, 1, 3, 2, 2, 2, 1, 1, 2, 3, 3, 1, 2, 2, 3, 2, 3, 1, 2, 1]

_max = pow(2, n-1)
while 1:
  n = x ^ _max
  count = 0
  while n != 0:
    if 0 <= n <=1024:
      count += zuru[n]
      break
    n = n % bin(n).count("1")
    count += 1
  print(count)
  n = x ^ _max
  _max = _max // 2
  if _max == 0:
    break

### FIXED CODE ###

N=int(input())
X=input()
Y=int(X,2)
Z=Y
C=X.count('1')
if C==1:
  for i in range(N):
    if X[i]=='1':
      print(0)
    elif i==N-1:
      print(2)
    else:
      print(1)
  exit()
Y,Z=Y%(C+1),Z%(C-1)

def f(x):
  if x==0:
    return 0
  return 1+f(x%bin(x).count('1'))

for i in range(N):
  if X[i]=='1':
    print(1+f((Z-pow(2,N-i-1,C-1))%(C-1)))
  else:
    print(1+f((Y+pow(2,N-i-1,C+1))%(C+1)))
A, B, C = map(int, input().split())
print(sum(A, B, C) - min(A, B, C))

### FIXED CODE ###

l = list(map(int, input().split()))
l.sort()

print(l[2] * 10 + sum(l[:2]))
n,m=map(int,input().split())
lists=[list(map(int,input().split())) for x in range(n)]
ans=[0]*m
for x in range(n):
  k=lists[x][0]
  for t in range(k):
    ans[lists[x][t+1]-1]+=1
count=0
for x in range(n):
  if ans[x]==n:
    count+=1
print(count)

### FIXED CODE ###

n,m=map(int,input().split())
lists=[list(map(int,input().split())) for x in range(n)]
ans=[0]*m
for x in range(n):
  k=lists[x][0]
  for t in range(k):
    ans[lists[x][t+1]-1]+=1
count=0
for y in range(m):
  if ans[y]==n:
    count+=1
print(count)
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

manzoku=0;

for i in range(len(A)):
	a=A[i]
	manzoku+=B[a-1]
	if i+1<n and A[i+1]-A[i]==1 :
		manzoku+=C[a-1]
	i+=1
print(manzoku)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
sum =0;
for i in range(len(a)):
    sum += b[a[i]-1]
    if i +1 < n and a[i+1] - a[i] == 1:
        sum += c[a[i]-1]
print(sum)
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
exits = False

for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(n):
            match = False
            if a[i][k: k+m] == b[j] and not exits:
                for l in range(1, m):
                    if a[l][k: k+m] == b[l]:
                        match = True
                    else:
                        match = False
                        break
            if match:
                exits = True

print('Yes' if exits else 'No')


### FIXED CODE ###

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

for i in range(n-m+1):
    for j in range(n-m+1):
        p = []
        for k in range(m):
            p.append(a[i:i+m][k][j:j+m])
        if p == b:
            exits = True

print('Yes' if exits else 'No')
n=int(input())
res=[]
for i in range(n):
	s,p=max(str,input().split())
    res.append([s,int(p)])
res1=res
res=sorted(res,key=lambda x:(x[0], -x[1]))
for i in range(n):
	print(res1.index(res[i])+1)

### FIXED CODE ###

n=int(input())
res = []
for i in range(n):
    s,p=map(str, input().split())
    res += [(s,int(p))]
res1=res
res = sorted(res, key=lambda x:(x[0],-x[1]))
for i in range(n):
    print(res1.index(res[i])+1)
import numpy as np

N, W = map(int, input().split())
w, v = [], []
for i in range(N):
    a, b = map(int, input().split())
    w += [a]
    v += [b]

DP = np.zeros(W + 1)

for i in range(N):
    # print(DP[w[i]:])
    # print(DP[:-w[i]])
    # print(DP[:-w[i]] + v[i])
    DP[w[i]:] = np.maximum(DP[:-w[i]] + v[i], DP[w[i]:])
    # print(DP)
print(DP[-1])

### FIXED CODE ###

N,W=map(int,input().split())
k=[[0,0] for i in range(N)]
dp=[[0]*(W+1) for j in range(N+1)]
for i in range(N):
    k[i][0],k[i][1]=map(int,input().split())



for i in range(N):
    for w in range(W+1):
        if k[i][0]>w:
            dp[i+1][w]=dp[i][w]
        else:
            dp[i+1][w] = max(dp[i][w-k[i][0]]+k[i][1],dp[i][w])


print(dp[N][W])
n,u,v=(map(int,input().split()))
Graph=[]
for i in range(n):
    Graph.append([])
for i in range(n-1): #隣接頂点の登録
    a,b=map(int,input().split())
    Graph[a-1].append(b-1)
    Graph[b-1].append(a-1)

def dfs(G,s,d): #深さ優先探索(グラフ,スタート,深さ)
    mark[s]=1 #訪問済みを0から1にする
    depth[s]=d #今の深さを記録
    for i in Graph[s]: #隣接点に対して
        if mark[i]==0: #未訪問なら
            dfs(G,i,d+1) #深さを増やし、スタートを更新して再探索

depth=[0]*n
mark=[0]*n
for i in range(n):
    dfs(Graph,u-1,0)
dT=depth

depth=[0]*n
mark=[0]*n
for i in range(n):
    dfs(Graph,v-1,0)
dA=depth

dArrest=0
for i in range(n):
    if dA[i]>dT[i]>=dArrest: #Tが先に着ける点のうち
        dArrest=dA[i] #一番Aから遠い点
print(dArrest-1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

n,u,v=map(int,input().split())
Graph=[]
for i in range(n):
    Graph.append([])
for i in range(n-1): #隣接頂点の登録
    a,b=map(int,input().split())
    Graph[a-1].append(b-1)
    Graph[b-1].append(a-1)

def dfs(s,b=-1): #深さ優先探索(グラフ,スタート,深さ)
    for i in Graph[s]: #隣接点に対して
        if i!=b: #前の点と一緒じゃないとき
            depth[i]=depth[s]+1
            dfs(i,s) #深さを増やし、スタートを更新して再探索

depth=[0]*n
dfs(u-1)
dT=depth

depth=[0]*n
dfs(v-1)
dA=depth

dArrest=0
for i in range(n):
    if dA[i]>dT[i]: #Tが先に着ける点のうち
        dArrest=max(dArrest,dA[i]) #一番Aから遠い点
print(dArrest-1)
a = int(input())
b = int(input())
if a*b%2 ==0:
    print('Even')
else:
    print('0dd')

### FIXED CODE ###

a,b = map(int, input().split())
c = a*b
if c % 2 == 0 :
    print('Even')
else:
    print('Odd')
n,m,x = map(int,input().split())
costlst = []
scorelst = []
ans = float("inf")
for _ in range(m):
    cost,*score = map(int,input().split())
    costlst.append(cost)
    scorelst.append(score)
for i in range(2**n):
    cost = 0
    defaultscore = [0]*m
    for j in range(n):
        if (i>>j)&1:
            cost += costlst[j]
            for k in range(m):
                defaultscore[k] += scorelst[j][k]
        if all([defaultscore[p] >= x for p in range(m)]):
            ans = min(ans,cost)
        
            
                
                
                 
print(ans if ans != float("inf") else "-1")            
    

### FIXED CODE ###

n,m,x = map(int,input().split())
costlst = []
scorelst = []
ans = float("inf")
for _ in range(n):
    cost,*score = map(int,input().split())
    costlst.append(cost)
    scorelst.append(score)
for i in range(2**n):
    cost = 0
    defaultscore = [0]*m
    for j in range(n):
        if (i>>j)&1:
            cost += costlst[j]
            for k in range(m):
                defaultscore[k] += scorelst[j][k]
    if all([defaultscore[p] >= x for p in range(m)]):
            ans = min(ans,cost)
        
            
                
                
                 
print(ans if ans != float("inf") else "-1")
a = input()
if a == 1:
  print("Hello World")
else:
  a = int(input())
  b = int(input())
  print(a+b)

### FIXED CODE ###

if input() == "1":
  print("Hello World")
else:
  print(int(input()) + int(input()))
n = int(input())
a_list = list(map(int,input().split()))

#min_indexlist = [a_list.index(min(a_list))]

min_indexlist = []

m = min(a_list)

#print(m)

#ここがおかしい
"""
for i in range(len(a_list)):
    if( a_list[i] == m+1):
        m = a_list[i]
        min_indexlist.append(i)
"""


f = False

for i in range(len(a_list)):

    if(f==False):
        if(a_list[i] == 1):
            min_indexlist.append(i)
            f = True

    if(f==True):
        if( a_list[i] == m+1):
            m = a_list[i]
            min_indexlist.append(i)
            
if(len(min_indexlist)==0):
    min_indexlist.append(1)



#print(min_indexlist)

#砕いたレンガの後のリスト
crash_list = []
for i in range(len(min_indexlist)):
    crash_list.append(a_list[min_indexlist[i]])

#print(crash_list)

#砕いたレンガの数
crash = n - len(min_indexlist)


frag=True

for i in range(len(crash_list)):
    if(crash_list[i] != i+1):
        frag = False


if(frag == True):
    print(crash)
elif(frag == False):
    print(-1)












### FIXED CODE ###

a=int(input())
b=int(input())

for i in range(3):
    if((i+1 != a) and (i+1 != b)):
        c = i+1
    
print(c)