Harryxun/stf_run huggingface dataset:
n,q = map(int,input().split())
tree = [[] for _ in range(n)]
point = [0] * n

for _ in range(n-1):
    a,b = map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
    
for _ in range(q):
    a,b = map(int,input().split())
    a -= 1
    point[a] += b
    
def dfs(now, prev = -1):
    for next in tree[now]:
        if next == prev:
            continue
        point[next] += point[now]
        
        dfs(next, now)
        
dfs(0)
print(*point)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
import sys
def input():
    return sys.stdin.readline()[:-1]

n,q = map(int,input().split())
tree = [[] for _ in range(n)]
point = [0] * n

for _ in range(n-1):
    a,b = map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
    
for _ in range(q):
    a,b = map(int,input().split())
    a -= 1
    point[a] += b
    
def dfs(now, prev = -1):
    for next in tree[now]:
        if next == prev:
            continue
        point[next] += point[now]
        
        dfs(next, now)
        
dfs(0)
print(*point)
from decimal import Decimal

h, w = input().split()
h_d = Decimal(h)
w_d = Decimal(w)
d_05 = Decimal('0.5')

if int(h) % 2 == 0:
    print(int(h_d*w_d*d_05))
else:
    if int(w) % 2 == 0:
        c = h_d * w * d_05
    else:
        c = d_05 * (h_d * w_d + Decimal('1'))
    print(int(c))

### FIXED CODE ###

from math import ceil
h,w = map(int,input().split())
ans = h * (w // 2)
if w % 2 != 0 :
    ans += ceil(h/2)
if h == 1 or w == 1:
    ans = 1
print(ans)
n, p = map(int, input().split())
import sympy
import math
fac = sympy.factorint(p)
result = 1
for i,j in fac.items():
  result *= i **math.floor(j/n)
print(result)

### FIXED CODE ###

n, p = map(int, input().split())
import math

# 0以上整数x「未満」の素数をリストに格納して返す
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]

PS = primes(1000000)
def factorint(x):
  d = {}
  for k in PS:
    if(x % k== 0):
      m = 1
      while(x % (k**m) == 0):
        m += 1
      d[k] = m - 1
      x = x / (k ** (m - 1))
      if x == 1:
        break
  return d

fac = factorint(p)
result = 1
for i,j in fac.items():
  result *= i **math.floor(j/n)
if n == 1:
  result = p
print(result)
import sys
sys.setrecursionlimit(100000)

N = int(input())
D = []
for _ in range(N):
    a,b,c = map(int, input().split())
    D.append([a,b,c])

def dfs(n, activity):#n日目にactivityを選んだ場合の最大幸福
    if n==1:
        ans = 0
        for i in range(3):
            if i!=activity:
                ans = max(ans, D[1][activity]+D[0][i])
        return ans
    ans = 0
    for i in range(3):
        if i!=activity:
            ans =max(ans, D[n][activity]+dfs(n-1, i))
    return ans
ans = 0
for i in range(3):
    ans = max(ans, dfs(N-1, i))
print(ans)




### FIXED CODE ###

N = int(input())

vacation = []

for i in range(N):
    a,b,c = map(int, input().split())

    vacation.append([a,b,c])

dp = []*N

for i in range(N):
    dp.append([0, 0, 0])

dp[0][0]=vacation[0][0]
dp[0][1]=vacation[0][1]
dp[0][2]=vacation[0][2]

for i in range(0, N-1, 1):

    for j in range(3):
        for k in range(3):
            if j==k:
                continue
            dp[i+1][j] = max(dp[i+1][j], dp[i][k]+vacation[i+1][j])

print(max(dp[N-1]))
import numpy as np
N = int(input())
A = np.array([int(i) for i in input().split()])
A = A - np.arange(N) - 1
B = np.abs(A - np.reshape(A, (-1, 1)))
print(np.sum(B, axis=1).min())

### FIXED CODE ###

import numpy as np
N = int(input())
A = np.array([int(i) for i in input().split()])
A = np.sort(A - np.arange(N) - 1)
b = A[N//2]
print(np.sum(np.abs(A - b)))
n = int(input())
a = list(map(int, input().split()))
negative = []
positive = []
cnt=0
for i in range(n):
  if a[i] < 0:
    cnt += 1
    negative.append(a[i])
  else:
    positive.append(a[i])
if cnt % 2 == 0:
  print(sum(map(lambda x: abs(x), a)))
else:
  negative.sort()
  positive.sort()
  if abs(negative[-1]) < positive[0]:
    a.remove(negative[-1])
    print(negative[-1]+sum(map(lambda x: abs(x), a)))
  else:
    a.remove(positive[0])
    print(-positive[0]+sum(map(lambda x: abs(x), a)))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
negative = []
positive = []
cnt=0
for i in range(n):
  if a[i] < 0:
    cnt += 1
    negative.append(a[i])
  else:
    positive.append(a[i])
if cnt % 2 == 0:
  print(sum(map(lambda x: abs(x), a)))
elif cnt == len(a):
  a.sort()
  b = a[-1]
  a.remove(a[-1])
  print(b+sum(map(lambda x: abs(x), a)))
else:
  negative.sort()
  positive.sort()
  if abs(negative[-1]) < positive[0]:
    a.remove(negative[-1])
    print(negative[-1]+sum(map(lambda x: abs(x), a)))
  else:
    a.remove(positive[0])
    print(-positive[0]+sum(map(lambda x: abs(x), a)))
S = input()
K = int(input())
if S[:K] == '1'*K:
    print(1)
else:
    print(S.replace('1', '')[0])


### FIXED CODE ###

S = input()
K = int(input())
if K < 110 and S[:K] == '1'*K:
    print(1)
else:
    print(S.replace('1', '')[0])
A = int(input())
B = int(input())

print(A * B)

### FIXED CODE ###

a, b = map(int, input().split())
 
answer = a * b
 
print(answer)
import itertools
n,x = map(int,input().split())
lst_l = [0] + list(map(int,input().split()))
lst_wa = list(accumulate(lst_l))
cnt = 0
for i in lst_wa:
    if i < x:
        cnt += 1
print(cnt)

### FIXED CODE ###

from itertools import accumulate
n,x = map(int,input().split())
lst_l = [0] + list(map(int,input().split()))
lst_wa = list(accumulate(lst_l))
cnt = 0
for i in lst_wa:
    if i <= x:
        cnt += 1
print(cnt)
a = [list(input().split()) for i in range(1)]
b=0
a = float(a[0]/a[1])
print(b)

### FIXED CODE ###

a = [list(input().split()) for i in range(1)]
b=0
c=0
b = int(a[0][0])
c =int(a[0][1])
print(b/c)
color = [int(i) for i in input()]
n = len(color)
ans = 0

if n%2==1:
    arfa = [10]*n//2 + [1]
    beta = [01]*n//2 + [0]
else:
    arfa = [10]*n//2
    beta = [01]*n//2

ansa=0;ansb=0
for i in range(n):
    if color[i]!=arfa[i]:
        ansa += 1
    if color[i]!=beta[i]:
        ansb += 1
print(min([ansa,ansb]))


### FIXED CODE ###

color = [int(i) for i in input()]
n = len(color)
ans = 0

if n%2==1:
    arfa = [1,0]*(n//2) + [1]
    beta = [0,1]*(n//2) + [0]
else:
    arfa = [1,0]*(n//2)
    beta = [0,1]*(n//2)

ansa=0;ansb=0
for i in range(n):
    if color[i]!=arfa[i]:
        ansa += 1
    if color[i]!=beta[i]:
        ansb += 1
print(min([ansa,ansb]))
from fractions import gcd


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


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

L = lcm(N, M)
X = {}

for i in range(0, L, L // N):
    X[i] = S[i]

for i in range(0, L, L // M):
    if i not in X:
        continue
    if X[i] != T[i]:
        print(-1)
        exit()
print(L)


### FIXED CODE ###

from fractions import gcd


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


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

L = lcm(N, M)
X = {}

for i in range(N):
    X[(L // N) * i] = S[i]

for i in range(M):
    if (L // M) * i in X and X[(L // M) * i] != T[i]:
        print(-1)
        exit()
print(L)
s=list(input())


for i in range(len(s)//2):
  s.pop(2*i-1)
  
ss=''.join(map(str,s))

print(ss)

### FIXED CODE ###

s=list(input())

for i in range(len(s)):
  if i%2==1:
    s[i]=''
  
ss=''.join(map(str,s))

print(ss)
S =[]
T =[]
i = random.choice(S,C,R)
S[0] ='i'
q = random.choice(S,C,R)
S[1] ='q'
g = random.choice(S,C,R)
S[2] ='g'
 
h = random.choice(S,C,R) 
T[0] ='h'
k = random.choice(S,C,R)
T[1] ='k'
m = random.choice(S,C,R)
T[2] ='m'
 
if S[0]=T[0]:
  correct += 1
  if S[1]=T[1]:
    correct += 1
    if S[2]=S[2]:
      correct += 1
 
print(correct)

### FIXED CODE ###

S=input()
T=input()

ans=0
for s,t in zip(S,T):
  if s==t:
    ans+=1
print(ans)
n=int(input())
s=input()
for i in range(len(s)):
  s[i]+=n
print(s)

### FIXED CODE ###

n=int(input())
s=input()
a="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
s=list(s)
a=list(a)
for i in range(len(s)):
    if a.index(s[i]) + n >= 26:
        s[i]=a[int(a.index(s[i])+n-26)]
    else:
        s[i]=a[int(a.index(s[i])+n)]
s="".join(s)
print(s)
x = int(input())
	for i in range(2,10):
	    if i <= x/200 < i+1:
    	    print(10-i)

### FIXED CODE ###

x = int(input())
if 400 <= x <= 599:
    print ("8")
if 600 <= x <= 799:
    print ("7")
if 800 <= x <= 999:
    print ("6")
if 1000 <= x <= 1199:
    print ("5")
if 1200 <= x <= 1399:
    print ("4")
if 1400 <= x <= 1599:
    print ("3")
if 1600 <= x <= 1799:
    print ("2")
if 1800 <= x <= 1999:
    print ("1")
a,b,c,d,e,k = map(int,input().split())
 
if e - a > k:
	print(":(")
else:
	print("Yay!")

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if e - a > k:
	print(":(")
else:
	print("Yay!")
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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


class FactMod():
    '''
    modの値が素数の時のfactと組み合わせを求める
    フェルマーの小定理を用いているため、modが素数以外の時は使えない
    '''

    def __init__(self, n, mod):
        '''
        コンストラクタ
        f:nまでの i!の値を　配列に入れる
        inv: (i!)^-1　の値を配列に入れる
        '''
        self.mod = mod
        self.f = [1]*(n+1)
        for i in range(1, n+1):
            self.f[i] = self.f[i-1]*i % mod

        self.inv = [pow(self.f[-1], mod-2, mod)]
        for i in range(1, n+1)[::-1]:
            self.inv.append(self.inv[-1]*i % mod)
        self.inv.reverse()

    def fact(self, n):
        '''
        n!の値を返す
        '''
        return self.f[n]

    def comb(self, n, r):
        '''
        nCrの値を返す
        '''
        ret = self.f[n] * self.inv[n-r]*self.inv[r]
        ret %= self.mod
        return ret

    def perm(self, n, r):
        """
        nPrの値を返す
        """
        ret = self.f[n] * self.inv[n-r]
        ret %= self.mod
        return ret


X, Y = map(int, input().split())

x = (2*Y-X)/3
y = (2*X-Y)/3

if 0 <= x and x == int(x) and 0 <= y and y == int(y):
    F = FactMod(x+y+1, 10**9+7)
    ans = F.comb(x+y, x)
else:
    ans = 0
print(ans)


### FIXED CODE ###


import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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


class FactMod():
    '''
    modの値が素数の時のfactと組み合わせを求める
    フェルマーの小定理を用いているため、modが素数以外の時は使えない
    '''

    def __init__(self, n, mod):
        '''
        コンストラクタ
        f:nまでの i!の値を　配列に入れる
        inv: (i!)^-1　の値を配列に入れる
        '''
        self.mod = mod
        self.f = [1]*(n+1)
        for i in range(1, n+1):
            self.f[i] = self.f[i-1]*i % mod

        self.inv = [pow(self.f[-1], mod-2, mod)]
        for i in range(1, n+1)[::-1]:
            self.inv.append(self.inv[-1]*i % mod)
        self.inv.reverse()

    def fact(self, n):
        '''
        n!の値を返す
        '''
        return self.f[n]

    def comb(self, n, r):
        '''
        nCrの値を返す
        '''
        ret = self.f[n] * self.inv[n-r]*self.inv[r]
        ret %= self.mod
        return ret

    def perm(self, n, r):
        """
        nPrの値を返す
        """
        ret = self.f[n] * self.inv[n-r]
        ret %= self.mod
        return ret


X, Y = map(int, input().split())

x = (2*Y-X)/3
y = (2*X-Y)/3

if 0 <= x and x == int(x) and 0 <= y and y == int(y):
    x = int(x)
    y = int(y)
    F = FactMod(x+y+1, 10**9+7)
    ans = F.comb(x+y, x)
else:
    ans = 0
print(ans)
N = input()

N = N.split(',')

AC_num = 0
WA_num = 0
TLE_num = 0
RE_num = 0


N_num = int(N[0])

for i in range(N_num):
    print(i+1)
    
    if 'AC' == N[i+1]:
        AC_num =+ 1
    
    elif 'WA' == N[i+1]:
        WA_num =+ 1

    elif 'TLE' == N[i+1]:
        TLE_num =+ 1
    
    elif 'RE' == N[i+1]:
        RE_num =+ 1
        
    else:
        print('nun')

print('AC','x',AC_num)
print('WA','x',WA_num)
print('TLE','x',TLE_num)
print('RE','x',RE_num)

### FIXED CODE ###

N_num = int(input())

N = []

for i in range(N_num):
    N.append(input())
    

AC_num = 0
WA_num = 0
TLE_num = 0
RE_num = 0

for i in range(N_num):
    #print(i+1)
    
    if 'AC' == N[i]:
        AC_num += 1
        #print(AC_num)
    
    elif 'WA' == N[i]:
        WA_num += 1
        #print(WA_num)

    elif 'TLE' == N[i]:
        TLE_num += 1
        #print(TLE_num)
    
    elif 'RE' == N[i]:
        RE_num += 1
        #print(RE_num)


print('AC x {}'.format(AC_num))
print('WA x {}'.format(WA_num))
print('TLE x {}'.format(TLE_num))
print('RE x {}'.format(RE_num))
n = int(input())
cards = [int(i) for i in input().split()]
cards.sort(reverse=True)
a = 0
b = 0
for i, num in enumerate(cards):
    if(i % 2 == 0):
        a = a + num
    else:
        b = b + num
print a - b


### FIXED CODE ###

n = int(input())
cards = [int(i) for i in input().split()]
cards.sort(reverse=True)
a = 0
b = 0
for i, num in enumerate(cards):
    if(i % 2 == 0):
        a = a + num
    else:
        b = b + num
print(a - b)
import queue
h,w,n = map(int,input().split())
factrys = [None] * (n + 1)
ss = ["X" * (w + 2)]
for i in range(h):
  s = "X" + input() + "X"
  if "S" in s:
    factrys[0] = (i + 1,s.index("S"))
  for j in range(1,n + 1):
    if str(j) in s:
      factrys[j] = (i + 1,s.index(str(j)))
  ss.append(s)
ss.append("X" * (w + 2))
mp = []
que = queue.Queue()
def bfs(i):
  (x,y) = que.get()
#  print(i,x,y)
#  print(mp[x][y])
  if (x,y) == factrys[i + 1]:
    return mp[x][y]
  count = mp[x][y]
  if ss[x + 1][y] != "X" and mp[x + 1][y] == None:
    mp[x + 1][y] = count + 1
    que.put((x + 1, y))
  if ss[x - 1][y] != "X" and mp[x - 1][y] == None:
    mp[x - 1][y] = count + 1
    que.put((x - 1, y))
  if ss[x][y + 1] != "X" and mp[x][y + 1] == None:
    mp[x][y + 1] = count + 1
    que.put((x, y + 1))
  if ss[x][y - 1] != "X" and mp[x][y - 1] == None:
    mp[x][y - 1] = count + 1
    que.put((x, y - 1))
  return bfs(i)
ans = 0
for i in range(n):
  mp = [[None] * (w + 2) for j in range(h + 2)]
  x,y = factrys[i]
  mp[x][y] = 0
  que = queue.Queue()
  que.put((x,y))
  ans += (bfs(i))
print(ans)


### FIXED CODE ###

from collections import deque

def main():
  h, w, n = map(int, input().split())
  mp = ["X" + input() + "X" for _ in range(h)]
  mp.insert(0, "X" * (w + 2))
  mp.append("X" * (w + 2))
  
  poss = [None] * (n + 1)
  for y in range(1, h + 1):
    for x in range(1, w + 1):
      if mp[y][x] == "S":
        poss[0] = (x, y)
      elif "1" <= mp[y][x] <= "9":
        poss[int(mp[y][x])] = (x, y)
  
  ans = 0
  vec = ((1, 0), (0, -1), (-1, 0), (0, 1))
  for i in range(n):
    sx, sy = poss[i]
    gx, gy = poss[i + 1]
    used = [[False] * (w + 2) for _ in range(h + 2)]
    used[sy][sx] = True
    que = deque()
    push = que.append
    pop = que.popleft
    push((0, sx, sy))
    while que:
      cnt, x, y = pop()
      if (x, y) == (gx, gy):
        ans += cnt
        break
      
      for dx, dy in vec:
        nx, ny = x + dx, y + dy
        if used[ny][nx] or mp[ny][nx] == "X":continue
        used[ny][nx] = True
        push((cnt + 1, nx, ny))
  
  print(ans)

main()
circle_1 = 1 * 1 * 3.16

if r < 1 or r > 100:
  False
else:
  circle_r = r * r * 3.16
  return circle_r / circle_1


### FIXED CODE ###

r = int(input())
print (r * r)
s = list(input())
k = int(input())
n = len(s)
c = ord("z") + 1
i = 0
for i in range(n):
    tmp = c - ord(s[i])
    if k >= tmp:
        s[i] = "a"
        k -= tmp
if k > 0:
    s[n-1] = chr(ord(s[n-1])+k)
print("".join(s))


### FIXED CODE ###

s = list(input())
k = int(input())
n = len(s)
map = {(chr(ord("a") + i)): (26-i)%26 for i in range(26)}
for i in range(n):
    if k >= map[s[i]]:
        k -= map[s[i]]
        s[i] = "a"
if k > 0:
    s[n-1] = chr((ord(s[n-1])+k%26)%123)
print("".join(s))
import collections

n = input()
line = input().split()
odd = line[::2]
even = line[1::2]
o = collections.Counter(odd)
e = collections.Counter(even)
maxoddcnt = o.most_common()[0][1]
maxevencnt = e.most_common()[0][1]

#すべての値が同じときは半分を置換する
if odd == even:
    print(len(odd))
    exit(0)

#奇数列，偶数列それぞれの最頻の文字が同じ場合は，いずれかを2番目に多い文字に置換しなければならない
if o.most_common()[0][0] == e.most_common()[0][0]:
    if len(o.most_common()) > 1 and len(e.most_common()) <= 1:
        maxoddcnt = o.most_common()[1][1]
    if len(o.most_common()) <= 1 and len(e.most_common()) > 1:
        maxevencnt = e.most_common()[1][1]
    if o.most_common()[1][1] + e.most_common()[0][1] >= o.most_common()[0][1] + e.most_common()[1][1]:
        maxoddcnt = o.most_common()[1][1]
    else: #if o.most_common()[1][1] + e.most_common()[0][1] <= o.most_common()[0][1] + e.most_common()[1][1] :
        maxevencnt = e.most_common()[1][1]
        input()

print(len(odd)-maxoddcnt+len(even)-maxevencnt)


### FIXED CODE ###

n = input()
n = n.replace('9','x')
n = n.replace('1','9')
n = n.replace('x','1')
print(n)
A, B, C, K = map(int, input().split())

A = [1] * A
B = [0] * B
C = [-1] * C

sum = A + B + C

count = 0
for i in range(K):
    count += sum[i]

print(count)

### FIXED CODE ###

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

sum = 0
if A >= K:
    print(K)
    exit()
else:
    K = K - A
    sum += A

if B >= K:
    print(sum)
    exit()
else:
    K = K - B

print(sum - K)
from math import factorial
n,k=map(int,input().split())
print(["NO","YES"][factorial(n)/factorial(k)-(n-1)*factorial(n-2)/factorial(k-2)>1])

### FIXED CODE ###

n,k=map(int,input().split())
print(["NO","YES"][n+n%2>=k*2])
a,b=input().split()
print(a*round(b*100)//100)

### FIXED CODE ###

a,b=input().split()
print(int(a)*round(float(b)*100)//100)
import sys
input = sys.stdin.readline

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

def yakusu(x,X):
    for i in range(1,int(x**0.5)+1):
        if x%i==0:
            X.append(i)
            if x!=i:
                X.append(x//i)
    
A=[]
B=[]
yakusu(a,A)
yakusu(b,B)
A.sort()
B.sort()
#print(A,B)
kouyakusu=[]
i=0
j=0
while i<len(A) and j<len(B):
    if A[i]==B[i]:
        kouyakusu.append(A[i])
        i+=1
        j+=1
    elif A[i]>B[j]:
        j+=1
    else:
        i+=1

ans=0
for i in range(1,len(kouyakusu)):
    if not(kouyakusu[i]): continue
    ans+=1
    for j in range(i+1,len(kouyakusu)):
        if kouyakusu[j]%kouyakusu[i]==0:
            kouyakusu[j]=False
#print(kouyakusu)
print(ans+1)

### FIXED CODE ###

import sys
input = sys.stdin.readline

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

def yakusu(x,X):
    for i in range(1,int(x**0.5)+1):
        if x%i==0:
            X.append(i)
            if x!=i:
                X.append(x//i)
    
A=[]
B=[]
yakusu(a,A)
yakusu(b,B)
A.sort()
B.sort()
#print(A,B)
kouyakusu=[]
i=0
j=0
while i<len(A) and j<len(B):
    if A[i]==B[j]:
        kouyakusu.append(A[i])
        i+=1
        j+=1
    elif A[i]>B[j]:
        j+=1
    else:
        i+=1

ans=0
for i in range(1,len(kouyakusu)):
    if not(kouyakusu[i]): continue
    ans+=1
    for j in range(i+1,len(kouyakusu)):
        if kouyakusu[j]%kouyakusu[i]==0:
            kouyakusu[j]=False
#print(kouyakusu)
print(ans+1)
import re
N,Q = map(int,input().split())	

S = input()

for _ in range(N):
    l,r = map(int,input().split())	
    print(len(re.findall('AC', S[l-1:r])))


### FIXED CODE ###

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

S = input()

t = [0] * N
for i in range(1, N):
    if S[i-1:i+1] == 'AC':
        t[i] = t[i-1] + 1
    else:
        t[i] = t[i-1]
#    print(t)

for _ in range(Q):
    l,r = map(int,input().split())	
    print(t[r-1]-t[l-1])
s = input()
for x in s:
  if x != '0':
    count = count + 1
print(count)

### FIXED CODE ###

s = input()
count = 0
for x in s:
  if x != '0':
    count = count + 1
print(count)
n,c,k=map(int,input().split())
if ' '.join(str(x) for x in [n,c,k])=='5 3 5':
  exit()
l=[]
for i in range(n):
  l.append(int(input()))
l.sort()
cnt=0
ind=0
while True:
  cnt+=1
  if ind+1>=n:
    break
  a=l[ind]
  start=a+k
  for i in range(1,c):
    ind+=1
    if l[ind]>start:
      break
  ind+=1
print(cnt)

### FIXED CODE ###

N,C,K=map(int,input().split())
l=[]

for i in range(N):
  l.append(int(input()))

l.sort()

bus_c=0
t_lim=0
jou_c=0

for x in l:
  if t_lim==0:
    t_lim=x+K
    bus_c+=1
    jou_c+=1
  else:
    if x>t_lim or C==jou_c:
      bus_c+=1
      jou_c=1
      t_lim=x+K
    else:
      jou_c+=1

print(bus_c)
|AB|,|BC|,|CA|=map(int,input().split())
print(|AB|*|BC|*1/2)


### FIXED CODE ###

l=list(map(int,input().split()))
print(l[0]*l[1]//2)
from collections import deque
from copy import copy,deepcopy
from itertools import permutations,combinations
from pprint import pprint

def myinput():
    return map(int,input().split())

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    data.sort(key=lambda x:x[col],reverse=False)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

n = int(input())
ab = [ list(myinput()) for _ in range(n) ]
cd = [ list(myinput()) for _ in range(n) ]

ab_sorted = ab.sort(key=lambda x:x[1],reverse=True)

count = 0
for i in range(n):
    cd_sorted = mysort(cd,0)
    bx = cd[0][0]
    by = cd[0][1]
    cd.remove([bx,by])
    for j in range(len(ab)):
        rx = ab_sorted[j][0]
        ry = ab_sorted[j][1]
        if rx<bx and ry<by:
            count += 1
            break
        else:
            pass
    ab_sorted.remove([rx,ry])
print(count)            

### FIXED CODE ###

from collections import deque
from copy import copy,deepcopy
from itertools import permutations,combinations
from pprint import pprint

def myinput():
    return map(int,input().split())

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    data.sort(key=lambda x:x[col],reverse=False)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

n = int(input())
ab = [ list(myinput()) for _ in range(n) ]
cd = [ list(myinput()) for _ in range(n) ]

count = 0
for i in range(n):
    cd_sorted = mysort(cd,0)
    bx = cd[0][0]
    by = cd[0][1]
    cd.remove([bx,by])
    ab.sort(key=lambda x:x[1],reverse=True)
    # print(cd)
    # print(ab)
    for j in range(len(ab)):
        rx = ab[j][0]
        ry = ab[j][1]
        if rx<bx and ry<by:
            count += 1
            ab.remove([rx,ry])
            break
        else:
            pass
print(count)
# -*- 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 = [] 

# print(rui)
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(32)] 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(32):
    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)

if len(ans_list) == 0:
    print(0)
else:
    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)