Harryxun/stf_run huggingface dataset:
import sys
A,B = map(int,input.split())
if A < 0 or A > 13 or B < 0 or B > 13:
    sys.exit()

if A == 1 or B == 1:
    if A == B:
        print("Draw")
    elif A == 1:
        print("Alice")
    elif B == 1:
        print("Bob")
    sys.exit()

if A > B:
    print("Alice")
elif B > A:
    print("Bob")
else:
    print("Draw")

### FIXED CODE ###

import sys
A,B = map(int,input().split())
if A < 0 or A > 13 or B < 0 or B > 13:
    sys.exit()

if A == 1 or B == 1:
    if A == B:
        print("Draw")
    elif A == 1:
        print("Alice")
    elif B == 1:
        print("Bob")
    sys.exit()

if A > B:
    print("Alice")
elif B > A:
    print("Bob")
else:
    print("Draw")
s = input()

count = len(s) / 2

if s == 'hi' * count:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

s = input()

count = len(s) // 2

if s == 'hi' * count:
  print('Yes')
else:
  print('No')
N = int(input())


def is_prime(n):
    for i in range(1, n):
        if i != 1 and n % i == 0:
            return False
    return True


def prime_numbers():
    num = 2
    while True:
        is_num_prime = is_prime(num)
        if is_num_prime:
            yield num
        num += 1


prime_gene = prime_numbers()
ans = []

while len(ans) < 5:
    prime = next(prime_gene)
    if prime_gene % 5 == 1:
        ans.append(prime)
print(ans)


### FIXED CODE ###

N = int(input())


def is_prime(n):
    for i in range(1, n):
        if i != 1 and n % i == 0:
            return False
    return True


def prime_numbers():
    num = 5
    while True:
        is_num_prime = is_prime(num)
        if is_num_prime and num % 5 == 1:
            yield num
        num += 1


prime_gene = prime_numbers()
ans = [next(prime_gene) for _ in range(N)]
print(*ans)
import re

m = re.match('.*k.*e.*y.*e.*n.*c.*e.*')
if m:
  print("YES")
else:
  print("NO")



### FIXED CODE ###

import re

a = input()

if re.match('^([a-zA-Z]*?)keyence$', a):
  print("YES")
else:
  if re.match('^k([a-zA-Z]*?)eyence$', a):
    print("YES")
  else:
    if re.match('^ke([a-zA-Z]*?)yence$', a):
      print("YES")
    else:
      if re.match('^key([a-zA-Z]*?)ence$', a):
        print("YES")
      else:
        if re.match('^keye([a-zA-Z]*?)nce$', a):
          print("YES")
        else:
          if re.match('^keyen([a-zA-Z]*?)ce$', a):
            print("YES")
          else:
            if re.match('^keyenc([a-zA-Z]*?)e$', a):
              print("YES")
            else:
              if re.match('^keyence([a-zA-Z]*?)$', a):
                print("YES")
              else:
                print("NO")
from collections import defaultdict

n=int(input())
dct=defaultdict(list)

for i in range(n-1):
  a,b,c=map(int,input().split())
  dct[a]+=[[b,c]]
  dct[b]+=[[a,c]]
print(dct)

q,k=map(int,input().split())
lk=[0]*(n)

def dfs(v,p,d):
  lk[v-1]=d
  print(k,v,p,d,lk)
  for l in dct[v]:
    if l[0]==p:
      continue
    else:
      dfs(l[0],v,d+l[1])
  return

dfs(k,-1,0)

print(lk)

for i in range(q):
  x,y=map(int,input().split())
  print(lk[x-1]+lk[y-1])
  
  
  
  
  
  

### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(10**9)

n=int(input())
dct=defaultdict(list)

for i in range(n-1):
  a,b,c=map(int,input().split())
  dct[a]+=[[b,c]]
  dct[b]+=[[a,c]]


q,k=map(int,input().split())
lk=[0]*(n)

def dfs(v,p,d):
  lk[v-1]=d

  for l in dct[v]:
    if l[0]==p or lk[l[0]-1]!=0:
      continue
    else:
      dfs(l[0],v,d+l[1])
  return

dfs(k,-1,0)



for i in range(q):
  x,y=map(int,input().split())
  print(lk[x-1]+lk[y-1])
#79a
n=input().split()
if n[0]==n[1] and n[1]==n[2] :
    print('Yes')
elif n[1]==n[2] and n[2]==n[3] :
    print('Yes')
else:
    print('No')

### FIXED CODE ###

#79a
n=input()
if n[0]==n[1] and n[1]==n[2] :
    print('Yes')
elif n[1]==n[2] and n[2]==n[3] :
    print('Yes')
else:
    print('No')
n = int(input())
a = list(map(int,input().split()))
l =[]
k = 0
for i in range(n):
  if a[i]>=a[i-1]:
    if l[k]:
      l[k] += 1
    else:
      l.append(1)
  else:
    k += 1
print(max(l))
    

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
l = [0]
k = 0
for i in range(n-1):
  if a[i]>=a[i+1]:
    l[k] += 1   
  else:
    k += 1
    l.append(0)
print(max(l))
def solve(n, a_list, s):

    for i in range(n - 1, -1, -1):
        if s[i] == "0":
            r = 2 ** (a_list[i].bit_length() - 1)
            for j in range(i):
                if a_list[j] & r > 0:
                    a_list[j] = a_list[i] ^ a_list[j]
        else:
            if a_list[i] > 0:
                return 1
    return 0


def main():
    t = int(input())
    res_list = []
    for _ in range(t):
        n = int(input())
        a_list = list(map(int, input().split()))
        s = input()
        res = solve(n, a_list, s)
        res_list.append(res)
    for res in res_list:
        print(res)


def test():
    assert solve(2, [1, 2], "10") == 1
    assert solve(2, [1, 1], "10") == 0
    assert solve(6, [2, 3, 4, 5, 6, 7], "111000") == 0


if __name__ == "__main__":
    test()
    main()


### FIXED CODE ###

def solve(n, a_list, s):

    for i in range(n - 1, -1, -1):
        if s[i] == "0":
            if a_list[i] == 0:
                continue
            r = 2 ** (a_list[i].bit_length() - 1)
            for j in range(i):
                if a_list[j] & r > 0:
                    a_list[j] = a_list[i] ^ a_list[j]
        else:
            if a_list[i] > 0:
                return 1
    return 0


def main():
    t = int(input())
    res_list = []
    for _ in range(t):
        n = int(input())
        a_list = list(map(int, input().split()))
        s = input()
        res = solve(n, a_list, s)
        res_list.append(res)
    for res in res_list:
        print(res)


def test():
    assert solve(2, [1, 2], "10") == 1
    assert solve(2, [1, 1], "10") == 0
    assert solve(6, [2, 3, 4, 5, 6, 7], "111000") == 0


if __name__ == "__main__":
    test()
    main()
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0301
WA
"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def main(args):
    # members = deque(list(range(10)))
    # numbers = [2, 6, 5, 18, 3]
    # queries = [3, 0, 5]

    N, M, Q = map(int, input().split(' '))
    members = list(range(N))
    numbers = [int(x) for x in input().split(' ')]
    queries = [int(x) for x in input().split(' ')]


    for n in numbers:
        if n % 2 == 0:
            members.rotate(-n)
            members.popleft()
        else:
            members.rotate(n)
            members.popleft()


    for q in queries:
        ans = 1 if q in members else 0
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0301

"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def main(args):
    # members = deque(list(range(10)))
    # numbers = [2, 6, 5, 18, 3]
    # queries = [3, 0, 5]

    N, M, Q = map(int, input().split(' '))
    members = deque(list(range(N)))
    numbers = [int(x) for x in input().split(' ')]
    queries = [int(x) for x in input().split(' ')]

    for n in numbers:
        if n % 2 == 0:
            # n = n % N
            members.rotate(-n)
            members.popleft()
        else:
            # n = n % N
            members.rotate(n)
            members.popleft()
        N -= 1

    for q in queries:
        ans = 1 if q in members else 0
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
# 累積和の手法をとる
# 簡単にいうと要素が ある区間の和 であるようなリストを先に作成しておき
# 必要な時に取り出すという手法である
# 同じ計算過程を何回も繰り返す（上の解法）ことなく結果がでる
N = int(input())
S = input()
w = [0 for _ in range(N)]       # Wを向いている人の番号に１、逆の方角の人に０を割り当てる
sw = [0 for _ in range(N)]      # リストwの累積和のリスト
e = [0 for _ in range(N)]       # Eを向いている人の番号に１、逆の方角の人に０を割り当てる
se = [0 for _ in range(N)]      # リストeの累積和のリスト
l = []

for i in range(N):
    if S[i] == "W":
        w[i] = 1
    else:
        e[i] = 1

# 累積和を格納したリストを求める
for i in range(N-1):
    sw[i+1] = sw[i] + w[i]
    se[i+1] = se[i] + e[i]

# 本計算
for i in range(N):
    if i != 0:
        counter = sw[i-1] + (se[N] - se[i])
    else:
        counter = se[N] - se[i]
    l.append(counter)

print(min(l))


### FIXED CODE ###

# 累積和の手法をとる
# 簡単にいうと要素が ある区間の和 であるようなリストを先に作成しておき
# 必要な時に取り出すという手法である
# 同じ計算過程を何回も繰り返す（上の解法）ことなく結果がでる
N = int(input())
S = input()
w = [0 for _ in range(N)]       # Wを向いている人の番号に１、逆の方角の人に０を割り当てる
sw = [0 for _ in range(N+1)]    # リストwの累積和のリスト、つまり sw[i] は 0~i-1 でWを向いている人の累積和
e = [0 for _ in range(N)]       # Eを向いている人の番号に１、逆の方角の人に０を割り当てる
se = [0 for _ in range(N+1)]    # リストeの累積和のリスト
l = []

for i in range(N):
    if S[i] == "W":
        w[i] = 1
    else:
        e[i] = 1

# 累積和を格納したリストを求める
for i in range(N):
    sw[i+1] = sw[i] + w[i]
    se[i+1] = se[i] + e[i]

# 本計算
for i in range(N):      # i 番目がリーダーだとする
    counter = sw[i] + (se[N] - se[i+1])
    l.append(counter)

print(min(l))
N,X=map(int,input())
m=[int(input()) for _ in range(N)]
print(N+(X-sum(m)//min(m)))

### FIXED CODE ###

N,X=map(int,input().split())
m=[int(input()) for _ in range(N)]
print(N+(X-sum(m))//min(m))
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

A = [0]
B = [0]

for i in range(n):
    A.append(A[i]+a[i])

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

### FIXED CODE ###

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

A = [0]
B = [0]

for i in range(n):
    A.append(A[i]+a[i])

for i in range(m):
    B.append(B[i]+b[i])
    
ans,j = 0,m
for i in range(n+1):
    if A[i] > k:
        break
    while B[j] > k - A[i]:
        j -= 1
    ans = max(ans,i+j)
print(ans)
import numpy as np
N, X = map(int, input().split())
xlist = list(map(int, input().split()))
xlist.append(X)
xlist.sort()
sa = np.array(xlist[1:]) - np.array(xlist[:-1])
print(np.gcd.reduce(sa))

### FIXED CODE ###

import fractions
from functools import reduce
import numpy as np
N, X = map(int, input().split())
xlist = list(map(int, input().split()))
xlist.append(X)
xlist.sort()
sa = list(np.array(xlist[1:]) - np.array(xlist[:-1]))
print(reduce(fractions.gcd, sa))
k = input()
str = input()
l = len(str)
if l <= k:
  print(str)
  else:
    print(s[:k])


### FIXED CODE ###

k = int(input())
s = input()
if int(len(s)) <= k:
  	print(str(s))
else:
  	print(((str(s))[0:k]) + "...")
a

### FIXED CODE ###

c=input()
print(chr(ord(c)+1))
X = int(input())
t = int(input())
if t < X:
  print(X-t)
else:
  print (0)

### FIXED CODE ###

x,t=list(map(int,input().split(" ")))
print(max(x-t, 0))
input_line = input()
S = int(input_line[0])
W = int(input_line[1])
if S > W:
  print("safe")
else:
  print("unsafe")


### FIXED CODE ###

input_line = input().split(" ")
S = int(input_line[0])
W = int(input_line[1])
if S > W:
  print("safe")
else:
  print("unsafe")
N = int(input())
LR = [list(map(int, input().split())) for i in range(N)]
a = 0
for i in range(N):
    a += (LR[i][1] - LR[i][0] + 1)
print(a)


### FIXED CODE ###

A, B, X = map(int, input().split())
print('YES' if A <= X <= (A+B) else 'NO')
from sys import stdin
from itertools import accumulate
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    a=list(map(int,readline().split()))

    d=dict()
    for s in accumulate(a):
        x=s%m
        if x not in d:
            d[x]=1
        else:
            d[x]+=1

    ans=d[0]
    for v in d.values():
        ans+=v*(v-1)//2

    print(ans)

if __name__=="__main__":
    main()

### FIXED CODE ###

from sys import stdin
from itertools import accumulate
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    a=list(map(int,readline().split()))

    d=dict()
    for s in accumulate(a):
        x=s%m
        if x not in d:
            d[x]=1
        else:
            d[x]+=1

    if 0 in d:
        ans=d[0]
    else:
        ans=0
    for v in d.values():
        ans+=v*(v-1)//2

    print(ans)

if __name__=="__main__":
    main()
# 凸包 Monotone Chain O(nlogn)
# 参考: https://matsu7874.hatenablog.com/entry/2018/12/17/025713
def get_convex_hull(points):
    from itertools import itemgetter
    def det(p, q):
        return p[0] * q[1] - p[1] * q[0]
    def sub(p, q):
        return (p[0] - q[0], p[1] - q[1])
    points.sort(key=itemgetter(0))
    ch = []
    for p in points:
        while len(ch) > 1:
            v_cur = sub(ch[-1], ch[-2])
            v_new = sub(p, ch[-2])
            if det(v_cur, v_new) > 0:
                break
            ch.pop()
        ch.append(p)
    t = len(ch)
    for p in points[-2::-1]:
        while len(ch) > t:
            v_cur = sub(ch[-1], ch[-2])
            v_new = sub(p, ch[-2])
            if det(v_cur, v_new) > 0:
                break
            ch.pop()
        ch.append(p)
    return ch[:-1]
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
ps = [(0, 0)]
for x, y in XY:
    ps_new = ps[:]
    for x_, y_ in ps:
        ps_new.append((x+x_, y+y_))
    ps = get_convex_hull(ps_new)
ans = 0
for x, y in ps:
    ans = max(ans, x*x+y*y)
print(ans ** 0.5)

### FIXED CODE ###

# 凸包 Monotone Chain O(nlogn)
def det(p, q):
    return p[0]*q[1] - p[1]*q[0]
def sub(p, q):
    return (p[0]-q[0], p[1]-q[1])
def get_convex_hull(points):
    n = len(points)
    points.sort()
    size_convex_hull = 0
    ch = []
    for i in range(n):
        while size_convex_hull > 1:
            v_cur = sub(ch[-1], ch[-2])
            v_new = sub(points[i], ch[-2])
            if det(v_cur, v_new) > 0:
                break
            size_convex_hull -= 1
            ch.pop()
        ch.append(points[i])
        size_convex_hull += 1

    t = size_convex_hull
    for i in range(n-2, -1, -1):
        while size_convex_hull > t:
            v_cur = sub(ch[-1], ch[-2])
            v_new = sub(points[i], ch[-2])
            if det(v_cur, v_new) > 0:
                break
            size_convex_hull -= 1
            ch.pop()
        ch.append(points[i])
        size_convex_hull += 1

    return ch[:-1]

N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
ps = [(0, 0)]
for x, y in XY:
    ps_new = ps[:]
    for x_, y_ in ps:
        ps_new.append((x+x_, y+y_))
    ps = get_convex_hull(ps_new)
ans = 0
for x, y in ps:
    ans = max(ans, x*x+y*y)
print(ans ** 0.5)
N, M = map(int,input().split())
tree = {}

for i in range(M):
    a, b, c = map(int, input().split())
    v= tree.get(a,[])
    v.append([b, c])
    tree[a] = v

def has_loop(tree):
    pass

m = []
def cost(v, c, visited):
    if v in visited:
        print('inf')
        exit()
    b = tree.get(v, None)
    if b is None:
        return 
    elif len(b) == 1 and tree.get(b[0][0],None) == None:
        j = c+b[0][1]
        m.append(j)
    else:
        for b, c2 in b: 
            cost(b, c+c2, visited + [v])

if has_loop(tree):
    print('inf')
    exit()

cost(1, 0, [])
print(max(m))


### FIXED CODE ###

N, M = map(int,input().split())
dist = [0] + [float('inf')] * (N - 1)

a = []
b = []
c = []

for i in range(M):
    i,j,k = map(int,input().split())
    a.append(i)
    b.append(j)
    c.append(-1*k)

INF = float('inf')

for i in range(N-1):
    for j in range(M):
        if dist[a[j] - 1] == INF: continue
        if dist[b[j] - 1] > dist[a[j] - 1] + c[j]:
            dist[b[j] - 1] = dist[a[j] - 1] + c[j]
        
ans = dist[N -1]

negative = [False] * N

for i in range(N):
    for j in range(M):
        if dist[a[j] - 1] == INF: continue
        if dist[b[j] - 1] > dist[a[j] - 1] + c[j]:
            dist[b[j] - 1] = dist[a[j] - 1] + c[j]
            negative[b[j] - 1] = True

        if negative[a[j] - 1] == True:
            negative[b[j] - 1] = True

if negative[N - 1]:
    print('inf')
else:
    print(-1 * ans)
n,m,k=map(int,input().split())
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
t=0
for p in range(n):
    if t+a[p]>k:
        p-=1
        break
    t+=a[p]
for q in range(m):
    if t+b[q]>k:
        q-=1
        break
    t+=b[q]
ans=p+q+2
if q==m-1:
    print(ans)
else:
    z=ans
    r=0
    for r in range(p,-1,-1):
        t-=a[q]
        z-=1
        while r<m and t+b[r]<=k:
            t+=b[r]
            r+=1
            z+=1
        if z>ans:
            ans=z
        if r==m-1:
            break
    print(ans)

### FIXED CODE ###

n,m,k=map(int,input().split())
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
t=0
for p in range(n):
    if t+a[p]>k:
        p-=1
        break
    t+=a[p]
for q in range(m):
    if t+b[q]>k:
        q-=1
        break
    t+=b[q]
ans=p+q+2
if q<m-1:
    z=ans
    q+=1
    for s in range(p,-1,-1):
        t-=a[s]
        z-=1
        while q<m and t+b[q]<=k:
            t+=b[q]
            q+=1
            z+=1
        if z>ans:
            ans=z
        if q==m:
            break
print(ans)
n,d=map(int,input().split())
count=0
for i in range(n):
  x,y = map(int, input().split())
  if x**2+y**2<=d**2:
   a.count=+1
print(a)

### FIXED CODE ###

import math
 
n,d=map(int,input().split())
count=0
for i in range(n):
  x,y = map(int, input().split())
  if math.sqrt((x**2)+(y**2))<=d:
   count+=1
print(count)
def solve():
    n, m = map(int, input().split())
    d = m // n
    p = m % n
    res = max(1, gcd(d, d + p))
    while d > 1:
        d -= 1
        q = m - n * d
        res = max(res, gcd(d, d + q))
    print(res)


solve()

### FIXED CODE ###

from math import gcd

def solve():
    n, m = map(int, input().split())
    d = m // n
    p = m % n
    res = max(1, gcd(d, d + p))
    if p == 0:
        print(res)
        exit()
    while d > res:
        d -= 1
        p += n
        if p % d == 0:
            res = max(res, d)
    print(res)


solve()
N, M = map(int, input().split())
D = [None] * M
for i in range(M):
  a, b = map(int, input().split())
  D[i] = (a, b)
D.reverse()

V = list(range(N))
C = [1] * N
def root(x):
  px = V[x]
  if px == x:
    return px
  else:
    return root(px)

def find(x, y):
  return root(x) == root(y)

def union(x, y):
  rx = root(x)
  ry = root(y)
  if rx != ry:
    V[ry] = rx
    C[rx] += C[ry]

def size(x):
  return C[root(x)]

f = N * (N - 1) // 2
F = []
for a, b in D:
  a -= 1
  b -= 1
  #print(V)
  #print(a, b)
  F.append(f)
  f = max(0, f - size(a) * size(b))
  union(a, b)
F.reverse()
for f in F:
  print(f)

### FIXED CODE ###

N, M = map(int, input().split())
D = [None] * M
for i in range(M):
  a, b = map(int, input().split())
  D[i] = (a, b)
D.reverse()

P = list(range(N))
C = [1] * N
R = [1] * N
def root(x):
  if P[x] == x:
    return x
  else:
    rx = root(P[x])
    P[x] = rx
    return rx

def find(x, y):
  return root(x) == root(y)

def union(x, y):
  rx = root(x)
  ry = root(y)
  if rx != ry:
    if R[ry] > R[rx]:
      rx, ry = ry, rx
    P[ry] = rx
    C[rx] += C[ry]
    R[rx] = max(R[rx], R[ry] + 1)

def size(x):
  return C[root(x)]

f = N * (N - 1) // 2
F = []
for a, b in D:
  a -= 1
  b -= 1
  F.append(f)
  if not find(a, b):
    f = max(0, f - size(a) * size(b))
    union(a, b)

F.reverse()
for f in F:
  print(f)
import fractions
n,m=map(int,input().split())
A=list(map(int,input().split()))
A=list(map(lambda x: x//2, A))

x=0 #2で割れる回数が同じかどうかの判定
T=A
while x==0:
    if (t%2 for t in T) == 0:
        T=list(map(lambda x: x/2, T))
    elif (t%2 for t in T) != 0:
        break
    else:
        x=1

def lcm(a,b):
    return a*b//fractions.gcd(a,b)

if x==1:
    print(0)
else:
    for i in range(n-1):
        l=lcm(A[i],A[i+1])
        if l>m:
            print(0)
            break
    if l<=m:
        print(int((m/l+1)/2))

### FIXED CODE ###

import sys
import fractions
n,m=map(int,input().split())
A=list(map(int,input().split()))
A=list(map(lambda x: x//2, A))

def dev2(x):
    c=0
    while x%2==0:
        x=x//2
        c+=1
    return c

def lcm(a,b):
    return a*b//fractions.gcd(a,b)

if n==1:
    if A[0]<=m:
        print(int((m/A[0]+1)/2))
    else:
        print(0)
else:
    d=dev2(A[0])
    for i in range(n-1):
        if dev2(A[i+1]) != d:
            print(0)
            sys.exit()
    l=A[0]
    for i in range(n-1):
        l=lcm(l,A[i+1])
        if l>m:
            print(0)
            sys.exit()
    print(int((m/l+1)/2))
import numpy as np
n = int(input())
a = list(map(int,input().split()))
r =np.prod(a)
if r >= 10**18:
  print(-1)
else:
  print(r)

### FIXED CODE ###

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

print(a*b)
def main():
    n, m = map(int, input().split())
    w = [0] * n
    v = [0] * n
    for i in range(n):
        wt, vt = list(map(int, input().split()))
        w[i] = wt
        v[i] = vt
    l = [0] * (m + 1)
    for i in range(n):
        l= [max(v[i] + l[j-w[i]], l[j]) if j - w[i] >= 0 else l[j] for j in range(m+1)]
    print(l[-1])
main()


### FIXED CODE ###

#dame datta
def main():
    N = int(input())
    A = list(map(int, input().split()))
    l = 0
    ans = 0
    t = 0
    for i, v in enumerate(A):
        if t & v == 0:
            t |= v
        else:
            while t & v > 0:
                t ^= A[l]
                l += 1
            t |= v
        ans += i - l + 1
    return ans
print(main())
import numpy as np

n, W = map(int, input().split())
value = np.empty(110)
weight = np.empty(110)

dp = np.empty(110,10010)

for el in range(n):
    value[el], weight[el] = map(int, input().split())

for w in range(W):
    dp[0][w] = 0

for i in range(n):
    for w in range(W + 1):
        if w >= weight[i]:
            #dp[i + 1][w]はi番目の品物の中から重さがwを超えないように選んだ時の、価値の総和の最大値
            dp[i + 1][w] = max(dp[i][w - weight[i]] + value[i] , dp[i][w])
            #その品物を選ぶか選ばないか判定する前のその重さの時の価値の最大値が既に分かっているので、判定するものの重量を差し引いた時の価値の最大値と判定しているものの価値を足し合わせて、
            #判定する前のその時点(w)での元からある価値の最大値（dp[i][w]と比べている
            #DP表には価値の最大値が書いてあり、組み合わせを記述するわけではない
        else:
            dp[i + 1][w] = dp[i][w]

print(dp[n][W])



### FIXED CODE ###

n, W = map(int, input().split())
#item =[]
# for i in range[n]:
#     item = list(map(int, input().split()))
value =[]
weight = []
dp = [[0 for i in range(W + 1)]for j in range(n + 1)]

for el in range(n):
    x, y = map(int, input().split())
    value.append(x)
    weight.append(y)

for w in range(W):
    dp[0][w] = 0

for i in range(n):
    for w in range(W + 1):
        if w >= weight[i]:
            #dp[i + 1][w]はi番目の品物の中から重さがwを超えないように選んだ時の、価値の総和の最大値
            dp[i + 1][w] = max(dp[i][w - weight[i]] + value[i] , dp[i][w])
            #その品物を選ぶか選ばないか判定する前のその重さの時の価値の最大値が既に分かっているので、判定するものの重量を差し引いた時の価値の最大値と判定しているものの価値を足し合わせて、
            #判定する前のその時点(w)での元からある価値の最大値（dp[i][w]と比べている
            #DP表には価値の最大値が書いてあり、組み合わせを記述するわけではない
        else:
            dp[i + 1][w] = dp[i][w]

print(dp[n][W])
n = int(input())
plist = list(map(int, input().split()))
counter = 0

for i in range(2, n):
    a = plist[i - 1]
    b = plist[i]
    c = plist[i+1]
    if a < b < c or c < b < a:
        counter += 1

print(counter)


### FIXED CODE ###

n = int(input())
plist = list(map(int, input().split()))
counter = 0

for i in range(1, n-1):
    a, b, c = plist[i-1:i+2]
    if a < b < c or c < b < a:
        counter += 1

print(counter)
i = input()

if i = i.upper():
  print("A")
else:
  print("a")
  

### FIXED CODE ###

i = input()
 
if i == i.upper():
  print("A")
else:
  print("a")
n, m, l = map(int, input().split())
A = []
B = []
C = [[0] * l for i in range(n)]
for x in range(n):
	for y in range(m):
		A[x].append(list(map(int, input().split())))

for x in range(m):
	for y in range(l):
		B[x].append(list(map(int, input().split())))

for x in range(n):
	for y in range(l):
		sum = 0
		for z in range(m):
			sum += A[x][z] * B[z][y]
		C[x][y] = sum

for x in range(n):
	for y in range(l-1):
		print("{0} ".format(C[x][y], end = '')
	print(C[x][l-1])

		

### FIXED CODE ###

n, m, l = map(int, input().split())
A = []
B = []
C = [[0] * l for i in range(n)]
for x in range(n):
	A.append(list(map(int, input().split())))

for x in range(m):
	B.append(list(map(int, input().split())))

for x in range(n):
	for y in range(l):
		sum = 0
		for z in range(m):
			sum += A[x][z] * B[z][y]
		C[x][y] = sum

for x in range(n):
	for y in range(l-1):
		print("{0} ".format(C[x][y]), end = '')
	print(C[x][l-1])