Harryxun/stf_run huggingface dataset:
def insertionSort( nums, n, g ):
	cnt = 0
	i = g
	while i < n:
		v = nums[i]
		j = i - g
		while 0 <= j and v < nums[j]:
			nums[ j+g ] = nums[j]
			j -= g
			cnt += 1
		nums[ j+g ] = v
		i += 1
	return cnt

n = int( input( ) )
nums = []
for i in range( 0, n ):
	nums.append( int( input( ) ) )

cnt = 0
g = []
val = 0
for i in range( n ):
	val = 3*val+1
	if  n < val:
		break
	g.append( val )
	
g.reverse( )
m = len( g )
print( m )
print( " ".join( map( str, g ) ) )
for i in range( m ):
	cnt = cnt  + insertionSort( nums, n, g[i] )
print( cnt )

print( "\n".join( map( str, nums ) ) )

### FIXED CODE ###

import sys
 
def insertionSort( nums, n, g ):
    cnt = 0
    i = g
    while i < n:
        v = nums[i]
        j = i - g
        while 0 <= j and v < nums[j]:
            nums[ j+g ] = nums[j]
            j -= g
            cnt += 1
        nums[ j+g ] = v
        i += 1
    return cnt
         
def shellSort( nums, n ):
    g = []
    val = 1
    while val <= n:
        g.append( val )
        val = 3*val+1
     
    g.reverse( )
    m = len( g )
    print( m )
    print( " ".join( map( str, g ) ) )
    cnt = 0
    for i in range( m ):
        cnt += insertionSort( nums, n, g[i] )
    print( cnt )
     
n = int( sys.stdin.readline( ) )
nums = []
for i in range( n ):
    nums.append( int( sys.stdin.readline( ) ) )
 
shellSort( nums, n )
print( "\n".join( map( str, nums ) ) )
A = list(map(int,input().split()))
N = len(A)
c = 1
for i in N-1:
  c *= A[i]
print(c)
if c >= 10**18:
  print(-1)


### FIXED CODE ###

n=int(input())
ls=[int(s) for s in input().split(" ")]

if 0 in ls:
  print(0)
else:
  num=1
  for i in ls:
    num*=i
    if num>10**18:
      num=-1
      break

  print(num)
N,M=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
A.sort()
B.sort()
import bisect
ans=1
mod=10**9+7
start=0
if len(set(A))!=len(A) or len(set(B))!=len(B):
    ans=0
for k in range(N*M,0,-1):
    if ans==0:break
    Aidx=bisect.bisect_left(A,k)
    Bidx=bisect.bisect_left(B,k)
    if A[Aidx]==k and B[Bidx]==k:
        continue
    elif A[Aidx]==k:
        ans=(ans*(M-Bidx))%mod
    elif B[Bidx]==k:
        ans=(ans*(N-Aidx))%mod
    else:
        if (N-Aidx)*(M-Bidx)-(N*M-k)<=0:
            ans=0
        ans=(ans*((N-Aidx)*(M-Bidx)-(N*M-k)))%mod
    if Aidx==0 and Bidx==0:
        start=k
        break
for i in range(start-1,0,-1):
    ans=(ans*i)%mod
print(ans)

### FIXED CODE ###

N,M=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
A.sort()
B.sort()
import bisect
ans=1
mod=10**9+7
start=0
if len(set(A))!=len(A) or len(set(B))!=len(B):
    ans=0
if A[-1]<N*M or B[-1]<N*M:
    ans=0
for k in range(N*M,0,-1):
    if ans==0:break
    Aidx=bisect.bisect_left(A,k)
    Bidx=bisect.bisect_left(B,k)
    if A[Aidx]==k and B[Bidx]==k:
        continue
    elif A[Aidx]==k:
        ans=(ans*(M-Bidx))%mod
    elif B[Bidx]==k:
        ans=(ans*(N-Aidx))%mod
    else:
        if (N-Aidx)*(M-Bidx)-(N*M-k)<=0:
            ans=0
        ans=(ans*((N-Aidx)*(M-Bidx)-(N*M-k)))%mod
    if Aidx==0 and Bidx==0:
        start=k
        break
for i in range(start-1,0,-1):
    ans=(ans*i)%mod
print(ans)
from typing import List
import sys

n, u, v = map(int, sys.stdin.readline().split())
graph = [[] for _ in range(n+1)]
for i in range(n-1):
    a, b = map(int, sys.stdin.readline().split())
    graph[a].append(b)
    graph[b].append(a)

def dfs(v: int) -> List[int]:
    dist = [-1] * (n+1)
    dist[v] = 0
    stack = [v]
    while stack:
        now = stack.pop()
        dw = dist[now] + 1
        for ne in graph[now]:
            if dist[ne] >= 0:
                continue
            dist[ne] = dw
            stack.append(ne)
    return dist

Takahashi = dfs(u)
Aoki = dfs(v)

ans = 0
for t, a in zip(Takahashi[1:], Aoki[1:]):
    if t < a:
        ans = max(ans, a - 1)

print(ans)

### FIXED CODE ###

import sys

n, u, v = map(int, sys.stdin.readline().split())
graph = [[] for _ in range(n+1)]
for i in range(n-1):
    a, b = map(int, sys.stdin.readline().split())
    graph[a].append(b)
    graph[b].append(a)

def dfs(v):
    dist = [-1] * (n+1)
    dist[v] = 0
    stack = [v]
    while stack:
        now = stack.pop()
        dw = dist[now] + 1
        for ne in graph[now]:
            if dist[ne] >= 0:
                continue
            dist[ne] = dw
            stack.append(ne)
    return dist

Takahashi = dfs(u)
Aoki = dfs(v)

ans = 0
for t, a in zip(Takahashi[1:], Aoki[1:]):
    if t < a:
        ans = max(ans, a - 1)

print(ans)
import sys
sys.setrecursionlimit(2147483647)
input = sys.stdin.readline
N, M, K = map(int, input().split())
graph = [[] for _ in range(N)]
block = [[] for _ in range(N)]
connected_components = []
count = 0
counts = [0 for _ in range(N)]
seen = [False for _ in range(N)]
def dfs(v, c, seen, origin):
    global count
    seen[v] = True
    for node in graph[v]:
        if seen[node] == True:
            continue
        if node not in block[origin]:
            count += 1
        dfs(node, c+1, seen, origin)
def dfs_connected(v, order):
    seen[v] = True
    connected_components[order].append(v)
    for node in graph[v]:
        if seen[node] == True:
            continue
        dfs_connected(node, order)
 
for Mi in range(M):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
 
for Ki in range(K):
    a, b = map(int, input().split())
    block[a-1].append(b-1)
    block[b-1].append(a-1)
 
for v in range(N):
    if seen[v] == True:
        continue
    connected_components.append([])
    dfs_connected(v, v)
 
for components in connected_components:
    for component in components:
        seen = [False for _ in range(N)]
        count = 0
        dfs(component, count, seen, component)
        counts[component] = count-len(graph[component])
 
print(' '.join(map(str, counts)))

### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)
input = sys.stdin.readline

N, M, K = map(int, input().split())
friends = {i: set() for i in range(N)}
blocks = {i: set() for i in range(N)}

for _ in range(M):
    a, b = map(int, input().split())
    friends[a-1].add(b-1)
    friends[b-1].add(a-1)

for _ in range(K):
    a, b = map(int, input().split())
    blocks[a-1].add(b-1)
    blocks[b-1].add(a-1)

counts = [0] * N
seen = [False] * N
def dfs(v):
    if seen[v] == True:
        return
    seen[v] = True
    for node in friends[v]:
        c.add(node)
        dfs(node)
 
for v in range(N):
    if seen[v] == True:
        continue
    c = set()
    dfs(v)
    l = len(c)
    for i in c:
        counts[i] = l - 1
        counts[i] -= len(c & friends[i])
        counts[i] -= len(c & blocks[i])
print(' '.join(map(str, counts)))
x, k, d = list(map(lambda x: int(x), input().split()))

min_pos = x % d
min_neg = min_pos - d

num_to_min_pos = x // d
if k <= num_to_min_pos:
    print(x - d * k)
    
else:
    if (k - num_to_min_pos) % 2 == 0:
        print(min_pos)
    else:
        print(abs(min_neg)


### FIXED CODE ###

x, k, d = list(map(lambda x: int(x), input().split()))


x = abs(x)
min_pos = x % d
min_neg = min_pos - d

num_to_min_pos = x // d
if k <= num_to_min_pos:
    print(x - d * k)
    
else:
    if (k - num_to_min_pos) % 2 == 0:
        print(min_pos)
    else:
        print(abs(min_neg))
def partition(a, p, r):
    x = a[r]
    i = p - 1
    for j in range(p, r):
        if a[j] <= x:
            i += 1
            tmp = a[i]
            a[i] = a[j]
            a[j] = tmp
    tmp = a[i+1]
    a[i+1] = a[r]
    a[r] = tmp
    return i + 1


def quick_sort(a, p, r):
    if p < r:
        q = partition(a, p, r)
        quick_sort(a, p, q-1)
        quick_sort(a, q+1, r)


def make_cyclic(w, v):
    flags = [True] * len(w)

    cyclics = []
    for i in range(len(w)):
        if flags[i]:
            flags[i] = False
            cycle = [w[i]]
            now = w[i]
            while True:
                j = v.index(now)
                if j == i:
                    break
                cycle.append(w[j])
                now = w[j]
                flags[j] = False
            cyclics.append(cycle)

    return cyclics


def min_cost_sort(w):
    v = w.copy()
    quick_sort(v, 0, len(v) - 1)

    cyclics = make_cyclic(w, v)

    ans = 0
    for cycle in cyclics:
        inner_cycle = min(cycle) * (len(cycle) - 2) + sum(cycle)
        if len(set(w) - set(cycle)) >= 1:
            outer_cycle = min(cycle) + min(set(w) - set(cycle)) * (len(cycle) + 1) + sum(cycle)
        else:
            outer_cycle = inner_cycle + 1
        ans += min(inner_cycle, outer_cycle)

    return ans

n = int(input())
w = [int(x) for x in input().split()]

print(min_cost_sort(w))


### FIXED CODE ###

def make_cyclic(w, v):
    flags = [True] * len(w)

    cyclics = []
    for i in range(len(w)):
        if flags[i]:
            flags[i] = False
            cycle = [w[i]]
            now = w[i]
            while True:
                j = v.index(now)
                if j == i:
                    break
                cycle.append(w[j])
                now = w[j]
                flags[j] = False
            cyclics.append(cycle)

    return cyclics


def min_cost_sort(w):
    v = w.copy()
    v.sort()

    cyclics = make_cyclic(w, v)

    ans = 0
    for cycle in cyclics:
        inner_cycle = min(cycle) * (len(cycle) - 2) + sum(cycle)
        if len(set(w) - set(cycle)) >= 1:
            outer_cycle = min(cycle) + min(set(w) - set(cycle)) * (len(cycle) + 1) + sum(cycle)
        else:
            outer_cycle = inner_cycle + 1
        ans += min(inner_cycle, outer_cycle)

    return ans


n = int(input())
w = [int(x) for x in input().split()]

print(min_cost_sort(w))
s=list(input())
k=int(input())
mi=5*(10**14)
i=0
while k>=0:
  k-=s[i]*mi
  i+=1
print(s[i])

### FIXED CODE ###

import sys
s=input()
k=int(input())
for i in range(len(s)):
    if s[i]!="1":
        print(s[i])
        sys.exit()
    if s[i]=="1" and i+1==k:
        print(1)
        sys.exit()
N,K =[int(i) for i in input().split(' ')]

A = [int(i) for i in input().split(' ')]
"""
index_1 = -1

for i in range(len(A)):
    #print(index_1)
    if A[i]==1:
        index_1 = i
        break

ans = 0
if index_1%(K-1)==0:
    ans += index_1 // (K-1)
else:
    ans += index_1 //(K-1) + 1

if (N-index_1 -1)%(K-1)==0:
    ans += (N - index_1-1) // (K-1)
else:
    ans += (N - index_1 -1) //(K-1) + 1
    
print(ans)
"""
ans =0
if (N-1)%(k-1) ==0:
    ans = (N-1)//(k-1)
else:
    ans = (N-1)//(k-1) +1
print(ans)


### FIXED CODE ###

N,K =[int(i) for i in input().split(' ')]

A = [int(i) for i in input().split(' ')]
"""
index_1 = -1

for i in range(len(A)):
    #print(index_1)
    if A[i]==1:
        index_1 = i
        break

ans = 0
if index_1%(K-1)==0:
    ans += index_1 // (K-1)
else:
    ans += index_1 //(K-1) + 1

if (N-index_1 -1)%(K-1)==0:
    ans += (N - index_1-1) // (K-1)
else:
    ans += (N - index_1 -1) //(K-1) + 1
    
print(ans)
"""
ans =0
if (N-1)%(K-1) ==0:
    ans = (N-1)//(K-1)
else:
    ans = (N-1)//(K-1) +1
print(ans)
N = int(input()) 
S = [int(input()) for i in range(N)]
S.sort()
max_ans = sum(S)

if N == 1:
  if max_ans % 10 == 0:
    print(0)
    exit(0)
  else:
    print(max_ans)
    exot(0)
if max_ans % 10 == 0:
  i = 0
  while S[i] % 10 == 0:
    i += 1
    if i == N-1:
      print(0)
      exit(0)
  ans = max_ans - S[i]
  print(ans)
else:
  print(max_ans)

### FIXED CODE ###

N = int(input()) 
S = [int(input()) for i in range(N)]
S.sort()
max_ans = sum(S)

if N == 1:
  if max_ans % 10 == 0:
    print(0)
    exit(0)
  else:
    print(max_ans)
    exit(0)
if max_ans % 10 == 0:
  i = 0
  while S[i] % 10 == 0:
    i += 1
    if i == N-1:
      print(0)
      exit(0)
  ans = max_ans - S[i]
  print(ans)
else:
  print(max_ans)
import numpy as np
a, b = int(input().split())
if b < 10:
  ab = 10 * a + b
else:
  ab = 100 * a +b
c = 11
d = -1

while np.power(c, 2) < ab + 1:
     if np.power(c, 2) != ab:
        c  += 1
     else:
        d = np.power(c, 2) 

if d != -1:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

import numpy as np
a, b= map(str, input().split())
ab = int(a+b)
c = 4
d = -1

while np.power(c, 2) < ab + 1:
     if np.power(c, 2) != ab:
        c  += 1
     else:
        d = np.power(c, 2) 
        break

if d != -1:
  print('Yes')
else:
  print('No')
import sys
a, b = map(int, input().split())

if a*b%2 == 0:
    print('Even')
else
    print('Odd')
sys.exit(0)

### FIXED CODE ###

import sys
a, b = map(int, input().split())

if a*b%2 == 0:
    print('Even')
else:
    print('Odd')
sys.exit(0)
#154 Distinct or not
n = int(input())
a = list(map(int,input().split())
b = set(a)

if len(a) == b:
         print('YES')
else:
    print('NO')

### FIXED CODE ###

#154 Distinct or not
n = int(input())
a = list(map(int,input().split()))
b = len(set(a))

if len(a) == b:
    print('YES')
else:
    print('NO')
# coding: utf-8
a, b, k = map(int, input().split())

if a > b:
    max = a
else:
    max = b
c = 0
for i in range(1, max):
    if a%i == 0 and b%i == 0:
        print(i)
        c += 1
    if c == k:
        break
print(i)

### FIXED CODE ###

# coding: utf-8
a, b, k = map(int, input().split())

mi = min(a, b)
c = 0
for i in range(mi+1, 0, -1):
    if a%i == 0 and b%i == 0:
        c += 1
    if c == k:
        break
print(i)
import copy
def dfs(cur_node, pre_node, Node_num, map, l):
    #全てのノードを見たとき

    if Node_num == N or cur_node <= 0 or cur_node >= N-1:
        return
    elif l[pre_node][cur_node]==0: #飛んだ先が、Trueの時
        return
    elif map[cur_node]==True:
        return

    map[cur_node]=True

    for i in range(N):
        if i != cur_node:
            dfs(i, cur_node, Node_num+1, map, l)


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

N = S[0]
M = S[1]


map = [False]*N
map[0] = True
map[N-1] = True
lst = []

for i in range(N):
    lst.append([0]*N)

for i in range(N):
    S = input()
    S = list(S.split())
    idx1 = int(S[0])
    idx2 = int(S[1])
    lst[idx1-1][idx2-1] = 1

graph_count = 0
#全探索
for i in range(1, N, 1):
    map_copy = copy.copy(map)
    lst_copy = copy.copy(lst)

    dfs(i, 0, 0, map_copy, lst_copy)
    count = 0
    for i in map_copy:
        if i == True:
            count = count + 1
    if count == N-1:
        graph_count = graph_count + 1

print(graph_count)


### FIXED CODE ###

import itertools
N,M=map(int,input().split())
edges={tuple(sorted(map(int,input().split()))) for i in range(M)}
ans=0
for i in itertools.permutations(range(2,N+1),N-1):
    l=[1]+list(i)
    ans+=sum(1 for edge in zip(l,l[1:]) if tuple(sorted(edge)) in edges)==N-1
print(ans)
n = int(input())
a = list(map(int, input().split()))
p=0
f=0
for ai in a:
    if ai%2!=0:
        p+=1
    else:
        if ai/2%2==0:
            f+=1
if f==0:
    print('No')
elif f==1:
    if n>3:
        print('No')
    else:
        print('Yes')
elif p>f:
    if p%2=1 and 2*p-1==n:
        print('Yes')
    else:
        print('No')
else:
    print('Yes')


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
p=0
f=0
for ai in a:
    if ai%2==1:
        p+=1
    else:
        if ai/2%2==0:
            f+=1
if p==0:
    print('Yes')
elif p>f:
    if n%2==1 and 2*f+1==n:
        print('Yes')
    else:
        print('No')
else:
    print('Yes')
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
S = [s[0] for s in S if s[0] in 'MARCH']
counter = Counter(S)
if len(counter) < 3:
  print(0)
else:
  cnt = 0
  mar = 'MARCH'
  for a in range(0,3):
    if mar[a] not in counter:
      continue
    for b in range(a+1, min(a+1+3, N-1)):
      if mar[b] not in counter:
        continue
      for c in range(b+1, min(b+1+3, N)):
        if mar[c] not in counter:
          continue
        # print(mar[a], mar[b], mar[c])
        cnt += counter[mar[a]] * counter[mar[b]] * counter[mar[c]]
  print(cnt)

### FIXED CODE ###

from collections import Counter
N = int(input())
S = [input() for i in range(N)]
S = [s[0] for s in S if s[0] in 'MARCH']
counter = Counter(S)
if len(counter) < 3:
  print(0)
else:
  cnt = 0
  mar = 'MARCH'
  for a in range(0,3):
    if mar[a] not in counter:
      continue
    for b in range(a+1, min(a+1+3, 5-1)):
      if mar[b] not in counter:
        continue
      for c in range(b+1, min(b+1+3, 5)):
        if mar[c] not in counter:
          continue
        # print(mar[a], mar[b], mar[c])
        cnt += counter[mar[a]] * counter[mar[b]] * counter[mar[c]]
  print(cnt)
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
nizi = [0] * (max(A)+1)
for i in range(len(A)):
    print(A[i], A)
    nizi[A[i]] += 1
sumall = sum(A)
for q in range(Q):
    B, C = map(int, input().split())
    sumall += (C-B) * nizi[B]
    nizi[C] =+ nizi[B]
    nizi[B] = 0
    print(sumall)

### FIXED CODE ###



N = int(input())
A = list(map(int, input().split()))
Q = int(input())
nizi = [0] * (10**5+1)
for i in range(len(A)):
    # print(A[i], A)
    nizi[A[i]] += 1
sumall = sum(A)
for q in range(Q):
    # print(nizi)
    B, C = map(int, input().split())
    sumall += (C-B) * nizi[B]
    nizi[C] += nizi[B]
    nizi[B] = 0
    print(sumall)
count = {'AC' : 0,'WA' : 0,'TLE': 0,'RE' : 0 }
n = int(input)
for i in range(0,n):
  count[input()]+=1
ptrint('AC x '+str(count['AC']))
ptrint('WA x '+str(count['WA']))
ptrint('TLE x '+str(count['TLE']))  
ptrint('RE x '+str(count['RE']))

### FIXED CODE ###

N = int(input())
S = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}
for i in range(N):
    S[input()] += 1
for a in S:
    print(a + " x " + str(S[a]))
n = int(input())
box  = []
prime = []

def Prime_Factorization(n):
    i = 2
    prime_factors = []
    while n > 1:
        if n % i == 0:
            prime_factors.append(i)
            n = n / i
        else:
            i += 1
    return prime_factors

for i in range(1,n):
    prime = Prime_Factorization(i)
    box.append(prime.count(2))
    #print(box)

ans = box.index(max(box)) + 1
print(ans)


### FIXED CODE ###

n = int(input())
box  = []
prime = []
ans = 0
def Prime_Factorization(n):
    i = 2
    prime_factors = []
    while n > 1:
        if n % i == 0:
            prime_factors.append(i)
            n = n / i
        else:
            i += 1
    return prime_factors

for i in range(1,n+1):
    prime = Prime_Factorization(i)
    box.append(prime.count(2))
    #print(box)


if n == 1:
    print(1)
else:
    ans = box.index(max(box)) + 1
    print(ans)
s,op,s2 = map(int,input().split(" "))

if op == '+':
  print(s+s2)

else:
  print(s-s2)

### FIXED CODE ###

A,op,B = map(str,input().split(" "))
if op == "+":
  print(int(A)+int(B))
else:
  print(int(A)-int(B))
from itertools import product

s=input()

for op in product(["+","-"],repeat=len(s)-1):
  formula =""
  for i in range(len(s-1)):
    formula+=s[i]+op[i]
  formula+=s[1]
  if eval(formula)==7:
    print(formula+"=7")
    exit()

### FIXED CODE ###

s=input()
a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])

if a+b+c+d==7:
  print("%d+%d+%d+%d=7"%(a,b,c,d))
  exit()
if a+b+c-d==7:
  print("%d+%d+%d-%d=7"%(a,b,c,d))
  exit()
if a+b-c+d==7:
  print("%d+%d-%d+%d=7"%(a,b,c,d))
  exit()
if a+b-c-d==7:
  print("%d+%d-%d-%d=7"%(a,b,c,d))
  exit()  
if a-b+c+d==7:
  print("%d-%d+%d+%d=7"%(a,b,c,d))
  exit()
if a-b+c-d==7:
  print("%d-%d+%d-%d=7"%(a,b,c,d))
  exit()
if a-b-c+d==7:
  print("%d-%d-%d+%d=7"%(a,b,c,d))
  exit()
if a-b-c-d==7:
  print("%d-%d-%d-%d=7"%(a,b,c,d))
  exit()
a, b = map(int, input().split())
print(math.floor((a+b)/2))

### FIXED CODE ###

import math
a, b = map(int, input().split())
print(math.ceil((a+b)/2))
# -*- coding: utf-8 -*-
from pprint import pprint
import itertools

N, K = map(int, input().split())
an = list(map(int, input().split()))

rui = [0]
tmp = 0
for a in an:
    rui.append(tmp+a)
    tmp += a


sum_list = [] 

for l in range(1,N+1):
    for r in range(l,N+1):
        tmp = rui[r] - rui[l-1]
        sum_list.append(tmp)

bin_list = [[0 for _ in range(30)] for _ in range(len(sum_list))]

for i,s in enumerate( sum_list):
    tmps = str(bin(s))[2:]
    for j,b in enumerate( reversed(tmps)):
        bin_list[i][j] = int(b)

# pprint(bin_list)

sum_bin = []
for j in range(30):
    tmp_bin = 0
    for i in range(len(sum_list)):
        tmp_bin += bin_list[i][j]
    sum_bin.append(tmp_bin)

# pprint(sum_bin)

max_keta = -1
for i,s in enumerate( sum_bin):
    if s >= K:
        max_keta = i

if max_keta == -1:
    print(0)
    exit()

sub_sum_list = [a for a in sum_list if 2**(max_keta) <= a < 2**(max_keta+1)]

# pprint(sub_sum_list)

ans_list = []
for c in itertools.combinations(sub_sum_list, K):
    ans = c[0]
    for s in c[1:K]:
        ans &= s

    ans_list.append(ans)

print(max(ans_list))


### FIXED CODE ###

# -*- coding: utf-8 -*-
from pprint import pprint
import itertools

N, K = map(int, input().split())
an = list(map(int, input().split()))

rui = [0]
tmp = 0
for a in an:
    rui.append(tmp+a)
    tmp += a

sum_list = [] 

for l in range(1,N+1):
    for r in range(l,N+1):
        tmp = rui[r] - rui[l-1]
        sum_list.append(tmp)

max_val = max(sum_list)
max_2pow = len(bin(max_val)[2:])
ans = 0
# print(ans,max_2pow)
while max_2pow > 0:
    tmp = ans + 2**(max_2pow-1)
    if sum([1 for v in sum_list if v & tmp == tmp]) >= K:
        ans += 2**(max_2pow-1)
    max_2pow -= 1

print(ans)
a,b,k = map(int,input().split())
m = []
for i in range(min(a,b)+1,1,-1):
    if a%i == 0 and b%i == 0:
        m.append(i)

print(m[k-1])

### FIXED CODE ###

A, B, K = map(int, input().split())
 
cand = []
for i in range(100,0,-1):
  if A%i == 0 and B%i == 0:
    cand += [i]
    
    
print(cand[K-1])
a,b=map((int,input()).split())
c,d=map((int,input()).split())
print(a*b-c*b-d*a)

### FIXED CODE ###

a,b=map(int,input().split())
c,d=map(int,input().split())
print((a-c)*(b-d))
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

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

L = [0]*N
R = [0]*N

L[0] = A[0]
r[-1] = A[-1]

for i in range(1, N):
	L[i] = gcd(L[i], A[i])
	idx = N-1-i
	R[i] = gcd(R[idx], A[idx])

#残りの N − 1 個の整数の最大公約数
mx = 0
for i in range(N):
	if i==N-1:	#後ろから1個めが抜かれた時
		v = L[N-2]
	elif i==0:	#前から1個めが抜かれた時
		v = R[1]
	else:		#どれでもない時
		v = gcd(R[i+1], L[i-1])
	mx = max(v, mx)
print(mx)


### FIXED CODE ###

# -*- coding: utf-8 -*-

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

N = int(input())
A = [int(a) for a in input().split()]

# GCDの結合則を利用する
# 左端、右端からの累積GCDを求めておくと、Aiを取り除いた場合のGCDがすぐに計算できる。
# つまり、
# L(i): n=0,...,iまでのGCD 
# R(i): n=i,...,N-1までのGCD
# このとき、Aiを除いた全体のGCDは、GCD(L(i-1), R(i+1))で計算できる。

L = [0] * N
R = [0] * N

L[0] = A[0]
R[-1] = A[-1]
for i in range(1, N):
    L[i] = gcd(L[i-1], A[i])
    idx = N-1-i
    R[idx] = gcd(R[idx+1], A[idx])

mx = 0
for i in range(N):
    if i == N-1:
        v = L[N-2]
    elif i == 0:
        v = R[1]
    else:
        v = gcd(R[i+1], L[i-1])
    mx = max(v, mx)
print(mx)
import itertools

n,m,q =map(int,input().split())
a =[0]*q
b =[0]*q
c =[0]*q
d =[0]*q

for i  in range(q):
    a[i],b[i],c[i],d[i]= map(int,input().split())
    
A=list(itertools.combinations([i for i in range(1,m+1)],n))

e=0

g=[]
for v in A:
    e=0
    for i in range(q):
        
        if v[b[i]-1]-v[a[i]-1] ==c[i]:
            e += d[i]
            
        
    g += [e]
print(max(g))

### FIXED CODE ###

import itertools

n,m,q =map(int,input().split())
a =[0]*q
b =[0]*q
c =[0]*q
d =[0]*q

for i  in range(q):
    a[i],b[i],c[i],d[i]= map(int,input().split())
    
A=list(itertools.combinations_with_replacement([i for i in range(1,m+1)],n))


g=[]
for v in A:
    e=0
    for i in range(q):
        
        if v[b[i]-1]-v[a[i]-1] ==c[i]:
            e += d[i]
            
        
    g += [e]
print(max(g))
A=int(input())
B=int(input())
C=int(input())
X=int(input())
cnt=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
      cnt += 1

print(cnt)

### FIXED CODE ###

A=int(input())
B=int(input())
C=int(input())
X=int(input())
cnt=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:
        cnt += 1

print(cnt)