Harryxun/stf_run huggingface dataset:
n = int(input())
A = tuple(int(input()) for _ in range(n))
S = sum(A)
mod = 998244353
ans = pow(3, n, mod) - (pow(2, n, mod)-2)*3 - 3
cnt = 0
dp = [[[0]*(S+1) for j in range(n+2)] for i in range(n+1)]
dp[0][0][0] = 1
for i, a in enumerate(A):
  for j in range(i+2):
    for k in range(S+1):
      if k >= a and j:
        dp[i+1][j][k] = dp[i][j][k] + dp[i][j-1][k-a]
      else:
        dp[i+1][j][k] = dp[i][j][k]
for j in range(n-1):
  for k in range((S+1)//2, S+1):
    cnt += dp[n][j][k] * (pow(2, n-j, mod) - 2)
    cnt %= mod
ans -= cnt*3
ans %= mod
print(ans)

### FIXED CODE ###

n = int(input())
A = tuple(int(input()) for _ in range(n))
S = sum(A)
mod = 998244353
ans = pow(3, n, mod)
cnt = 0
dp = [[0]*(S+1) for _ in range(n+1)]
dp[0][0] = 1
for i, a in enumerate(A):
  for k in range(S+1):
    if k >= a:
      dp[i+1][k] = dp[i][k]*2 + dp[i][k-a]
    else:
      dp[i+1][k] = dp[i][k]*2
    dp[i+1][k] %= mod
for k in range((S+1)//2, S+1):
  ans -= dp[n][k]*3
  ans %= mod
if S%2 == 0:
  dp = [0]*(S//2+1)
  dp[0] = 1
  for i, a in enumerate(A):
    for k in range(S//2, -1, -1):
      if k >= a:
        dp[k] += dp[k-a]
  ans += dp[S//2]*3
  ans %= mod
print(ans)
n = int( raw_input() )
A = map( int , raw_input().split() )
q = int( raw_input() )
m = map( int , raw_input().split() )

for i in n-1
  def solve(i, m)
    if m == 0
      return true
    if i >= n
      return false
    res = solve( i+1 , m ) || solve( i+1 , m-A[i] )
    return res

### FIXED CODE ###

n = input()
A = map( int , raw_input().split() )
q = input()
mi = map( int , raw_input().split() )

def solve(i, m):
  if m == 0:
    return True
  elif i >= n or m > sum(A):
    return False

  res = solve( i+1 , m ) or solve( i+1 , m-A[i] )
  return res

for m in mi:
  if solve( 0 , m ): print "yes"
  else: print "no"
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
g = [[] for i in range(n)]

for i in range(n-1):
    u,v,w = na()
    g[u-1].append((v-1,w))
    g[v-1].append((u-1,w))

dp = [0]*n

def f(a,b,c):
    dp[b] = c
    for i,j in g[b]:
        if i != a:
            f(b,i,c+j)

f(0,0,0)
print(dp)
for k in dp:
    print(k%2)

### FIXED CODE ###

import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
g = [[] for i in range(n)]

for i in range(n-1):
    u,v,w = na()
    g[u-1].append((v-1,w))
    g[v-1].append((u-1,w))

dp = [0]*n

def f(a,b,c):
    dp[b] = c
    for i,j in g[b]:
        if i != a:
            f(b,i,c+j)

f(0,0,0)

for k in dp:
    print(k%2)
def depth_dp(v):
    if point[v] == float('inf'):
        point[v] = 0
    flag[v] = True
    for e in E[v]:
        if point[e[0]] == float('inf'):
            point[e[0]] = point[v] + e[1]
        elif point[e[0]] != point[v] + e[1]:
            return False
    for e in E[v]:
        if not flag[e[0]]:
            if not depth_dp(e[0]):
                return False
    return True

N,M = list(map(int,input().split()))
E = [[] for _ in range(N)]
flag = [False]*N
ans = True
point = [float('inf')]*N
for i in range(M):
    L,R,D = list(map(int,input().split()))
    E[L-1].append((R-1,D))
    E[R-1].append((L-1,-D))
for i in range(N):
    if not flag[i]:
        if not depth_dp(i):
            ans = False
            break
if ans:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)
def depth_dp(v):
    if point[v] == float('inf'):
        point[v] = 0
    flag[v] = True
    for e in E[v]:
        if point[e[0]] == float('inf'):
            point[e[0]] = point[v] + e[1]
        elif point[e[0]] != point[v] + e[1]:
            return False
    for e in E[v]:
        if not flag[e[0]]:
            if not depth_dp(e[0]):
                return False
    return True

N,M = list(map(int,input().split()))
E = [[] for _ in range(N)]
flag = [False]*N
ans = True
point = [float('inf')]*N
for i in range(M):
    L,R,D = list(map(int,input().split()))
    E[L-1].append((R-1,D))
    E[R-1].append((L-1,-D))
for i in range(N):
    if not flag[i]:
        if not depth_dp(i):
            ans = False
            break
if ans:
    print('Yes')
else:
    print('No')
from sys import stdin, stdout
n,m = map(int, stdin.readline().rstrip().split(' '))
l = list(map(int, stdin.readline().rstrip().split(' ')))
sum = sum(l)
k = sum/(4*m)
ans = "Yes"
l.sort(reverse = True)
for i in (0,m):
  if l[i]<k:
      ans="No"
      break
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
a = list(map(int, input().split()))
ans = "Yes"
 
a.sort(reverse=True)
 
for i in range(m):
    if a[i] < sum(a)*(1/(4*m)):
        ans = "No"
        break
 
print(ans)
nums = input().split()
W = int( nums[0])
H = int( nums[1])
x = int( nums[2])
y = int( nums[3])
r = int( nums[4])
????????
if (x - r) >= 0 and (x + r) <= W:
????????if (y - r) >= 0 and (y + r) <= H:
????????????????print( "Yes")
????????else:
????????????????print( "No")
else:
????????print( "No")

### FIXED CODE ###

nums = input().split()
W = int( nums[0])
H = int( nums[1])
x = int( nums[2])
y = int( nums[3])
r = int( nums[4])
if (x - r) >= 0 and (x + r) <= W:
    if (y - r) >= 0 and (y + r) <= H:
        print("Yes")
    else:
        print("No")
else:
    print("No")
S=set(["A","C","G","T"])
L=list(input())
A=[]
M=0
for i in L :
  if i in S :
    M+=1
  else :
    A.append(M)
    M=0
print(max(A))

### FIXED CODE ###

S=set(["A","C","G","T"])
L=list(input())
A=[]
M=0
for i in L :
  if i in S :
    M+=1
  else :
    A.append(M)
    M=0
A.append(M)
print(max(A))
n, k = map(int, input().split())
A = []
for _ in range(n):
    t, d = map(int, input().split())
    A.append((d, t))
A.sort(reverse=True)
X = []
Y = []
st = set()
for i in range(k):
    d, t = A[i]
    if t in st:
        X.append(d)
    else:
        Y.append(d)
        st.add(t)
x = sum(X)
y = sum(Y)
v = len(Y)
ans = x + y + v ** 2
for i in range(k, n):
    if not X:
        break
    d, t = A[i]
    if t in st:
        continue
    st.add(t)
    x -= X.pop()
    y += d
    v += 1
    ans = max(ans, x + y + v ** 2)
print(ans)
n, k = map(int, input().split())
A = []
for _ in range(n):
    t, d = map(int, input().split())
    A.append((d, t))
A.sort(reverse=True)
X = []
Y = []
st = set()
for i in range(k):
    d, t = A[i]
    if t in st:
        X.append(d)
    else:
        Y.append(d)
        st.add(t)
x = sum(X)
y = sum(Y)
v = len(Y)
ans = x + y + v ** 2
for i in range(k, n):
    if not X:
        break
    d, t = A[i]
    if t in st:
        continue
    st.add(t)
    x -= X.pop()
    y += d
    v += 1
    ans = max(ans, x + y + v ** 2)
print(ans)


### FIXED CODE ###

N,K = map(int,input().split())
td = [[int(i) for i in input().split()] for _ in range(N)]
td.sort(key=lambda x:x[1],reverse=True)
ans = 0
ls = set()
dl = []
for i in range(K):
    ans += td[i][1]
    if not td[i][0] in ls:
        ls.add(td[i][0])
    else:
        dl.append(td[i][1])
ans = ans + len(ls)**2
res = ans
for i in range(K,N):
    if not dl:
        break
    if td[i][0] in ls:
        continue
    ans += len(ls)*2+1
    ans += td[i][1]
    ans -= dl[-1]
    del dl[-1]
    res = max(res,ans)
    ls.add(td[i][0])
print(res)
n,m=map(int,input().split())
p=sorted([list(map(int,input().split()))for i in range(m)])
a=2**(n-1).bit_length()
b=2**31-1
s=[b]*(2*a)
def f(k,x):
    k+=a-1
    s[k]=x
    while k>=0:
        k=(k-1)//2
        s[k]=min(s[2*k+1],s[2*k+2])
def g(l,r):
    L,R=l+a,r+a
    t=b
    while L<R:
        if R&1:
            R-=1
            t=min(t,s[R-1])
        if L&1:
            t=min(t,s[L-1])
            L+=1
        L>>=1
        R>>=1
    return s
f(0,0)
for l,r,c in p:
    q=g(l-1,r-1)
    if s[r+a-2]>q+c
        f(r-1,c+q)
print(-1 if s[n+a-2]==b else s[n+a-2])

### FIXED CODE ###

from heapq import heappush,heappop
n,m=map(int,input().split())
a=[[[i-1,0]]for i in range(n+1)]
a[0]=[]
for i in range(m):
    l,r,c=map(int,input().split())
    a[l].append([r,c])
q=[float("INF")]*(n+1)
q[1]=0
c=[]
heappush(c,[0,1])
while c:
    s,t=heappop(c)
    if t==n:
        print(s)
        break
    for i,j in a[t]:
        if q[i]>s+j:
            q[i]=s+j
            heappush(c,[s+j,i])
else:
    print(-1)
n = input()
s = sum([int(i) for i in n])
if n%s == 0:
  print('Yes')
else:
  print('No')


### FIXED CODE ###

n = input()
s = sum([int(i) for i in n])
if int(n)%s == 0:
  print('Yes')
else:
  print('No')
import sys
l=[list(map(float,i.split(","))) for i in sys.stdin]
bmi=lambda i:i[1]/(i[2]**2)
[print(int(i[0])) for i in l bmi(i)>=25]


### FIXED CODE ###

import sys
l=[list(map(float,i.split(","))) for i in sys.stdin]
bmi=lambda i:i[1]/(i[2]**2)
[print(int(i[0])) for i in l if bmi(i)>=25]
import math
r=float(input())
print(float(r*r*pi),float(2*r*pi))


### FIXED CODE ###

from math import pi
r=float(input())
print("{0:.6f}".format(r*r*pi),"{0:.6f}".format(2*r*pi))
N = int(input())
for i in range(1,N):
    if i*1000>=N:
        ans = i*1000-N
        break
print(ans)



### FIXED CODE ###


N = int(input())
ans = 0
for i in range(0,N):
    if i*1000>=N:
        ans = i*1000-N
        break
    if N < 1000:
        ans = 1000 - N
print(ans)
n, y = map(int, input().split())
for i in range(n + 1):
  for j in range(n - j + 1):
    if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
      print(i, j, n - i -j)
    exit()
    else:
      print(-1, -1, -1)
    exit()

### FIXED CODE ###

n, y = map(int, input().split())
for i in range(n + 1):
  for j in range(n - i + 1):
    if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
      print(i, j, n - i - j)
      exit()
print("-1 -1 -1")
import itertools
import math
import sys
from collections import Counter
from fractions import gcd
from functools import reduce

n = int(input())
a = list(map(int, input().split()))
cnt = [0] * 10 ** 5
for i in a:
    cnt[i - 1] += 1
    cnt[i] += 1
    cnt[i + 1] += 1
print(max(cnt))



### FIXED CODE ###

import itertools
import math
import sys
from collections import Counter
from fractions import gcd
from functools import reduce

n = int(input())
a = list(map(int, input().split()))
cnt = [0] * (10 ** 5)
for i in a:
    if i - 1 >= 0:
        cnt[i - 1] += 1
    cnt[i] += 1
    if i + 1 <= 10 ** 5 - 1:
        cnt[i + 1] += 1
print(max(cnt))
a, b = map(int, input().split())
count = 1

for i in range(20):
    if b > count:
        count += a-1
    else:
        break
if -(-count // a) >= 1:
    print(-(-count // a))
else:
    print(0)

### FIXED CODE ###

a,b,c = input()
d,e,f = input()
count = 0
if a == d:
    count+= 1
if b == e:
    count+= 1
if c == f:
    count+= 1
print(count)
n, m = map(int, input().split())
c = []
for i in range(n):#h:高さ
    c.append([int(m) for m in input().split()])


graph = {}
for i in range(n):
    graph[i + 1] = []
for i in range(n):
    graph[c[i][0]] = graph[c[i][0]] + [c[i][1]]
    graph[c[i][1]] = graph[c[i][1]] + [c[i][0]]
stack = []
start = 1
i = start
visited = set()
visited.add(i)
root = [i]
while True:
    for j in graph[i]:
        if j not in visited:
            i = j
            root += [i]
            visited.add(i)
            break
    else:
        break

ver = len(root)
print(ver)
for i in root:
    print(i, "", end="")

### FIXED CODE ###

n, m = map(int, input().split())
c = []
for i in range(m):#h:高さ
    c.append([int(m) for m in input().split()])


graph = {}
for i in range(n):
    graph[i + 1] = []
for i in range(m):
    graph[c[i][0]] = graph[c[i][0]] + [c[i][1]]
    graph[c[i][1]] = graph[c[i][1]] + [c[i][0]]
stack = []
start = 1
i = start
visited = set()
visited.add(i)
root = [i]
while True:
    for j in graph[i]:
        if j not in visited:
            i = j
            root += [i]
            visited.add(i)
            break
    else:
        break
i = 1
root2 = []
while True:
    for j in graph[i]:
        if j not in visited:
            i = j
            root2 += [i]
            visited.add(i)
            break
    else:
        break
ver = len(root2) + len(root)
print(ver)
root = root2[::-1] + root
for i in root:
    print(i, "", end="")
from collections import defaultdict
import bisect

n = int(input())
s = input()
S = []
cnt_ch = defaultdict(list)
for i in range(n):
    S.append(s[i])
    cnt_ch[s[i]].append(i)
    
    
    
    
q = int(input())
for i in range(q):
    qw = input()
    if qw[0] == "1":
        qw = qw[2:]
        i, ch = map(str, qw.split())
        if S[int(i) - 1] == ch:
            continue
        remove = bisect.bisect_left(cnt_ch[S[int(i) - 1]], int(i) - 1)
        del cnt_ch[S[int(i) - 1]][remove]
        bisect.insort(cnt_ch[ch], int(i) - 1)
        
    else:
        #print(cnt_ch)
        qw = qw[2:]
        l, r = map(int, qw.split())
        cnt = 0
        for i in range(ord("a"),ord("a") + 26):
            if not cnt_ch[chr(i)]:
                continue
            edge = bisect.bisect_left(cnt_ch[chr(i)], l)
            #print(cnt_ch[chr(i)][edge - 1:])
            #if bisect.bisect_left(cnt_ch[chr(i)][edge:], i) < r:
            #print(cnt_ch[chr(i)])
            #print(l, r)
            #print(edge)
            if edge < len(cnt_ch[chr(i)]):
                if cnt_ch[chr(i)][edge] < r:
                    cnt += 1
            #print(cnt, "cnt", chr(i))
        print(cnt)
        
        


### FIXED CODE ###

from collections import defaultdict
import bisect

n = int(input())
s = input()
S = []
cnt_ch = defaultdict(list)
for i in range(n):
    S.append(s[i])
    cnt_ch[s[i]].append(i)
    
    
    
    
q = int(input())
for i in range(q):
    qw = input()
    if qw[0] == "1":
        qw = qw[2:]
        i, ch = map(str, qw.split())
        if S[int(i) - 1] == ch:
            continue
        remove = bisect.bisect_left(cnt_ch[S[int(i) - 1]], int(i) - 1)
        del cnt_ch[S[int(i) - 1]][remove]
        S[int(i) - 1] = ch
        if not cnt_ch[ch]:
            cnt_ch[ch].append(int(i) - 1)
            continue
        bisect.insort_left(cnt_ch[ch], int(i) - 1)
        
        
    else:
        #print(cnt_ch)
        qw = qw[2:]
        l, r = map(int, qw.split())
        cnt = 0
        for i in range(ord("a"),ord("a") + 26):
            if not cnt_ch[chr(i)]:
                continue
            edge = bisect.bisect_left(cnt_ch[chr(i)], l - 1)
            #print(cnt_ch[chr(i)][edge - 1:])
            #if bisect.bisect_left(cnt_ch[chr(i)][edge:], i) < r:
            #print(cnt_ch[chr(i)])
            #print(l, r)
            #print(edge)
            if edge < len(cnt_ch[chr(i)]):
                if cnt_ch[chr(i)][edge] < r:
                    cnt += 1
            #print(cnt, "cnt", chr(i))
        print(cnt)
n = int(input())
s = input()
x = 0
for i in range(n):
    a = s[0:i]
    b = s[i:]
    x = max(x, len(set(a) & set(b)))

print(x)

### FIXED CODE ###

a, b = map(int, input().split())
calcs = [a + b, a - b, a * b]
print(max(calcs))
n,m=map(int, input().split())
a=[False]*(n+1)
for i in range(m):
    A=int(input())
    a[A]=True
mod=10**9+7
dp=[0]*(n+1)

if not a[1]:
    dp[1]=1

if not a[2]:
    dp[2]=dp[1]+1

for i in range(3,n+1):
    if not a[i-2]:
        dp[i]+=dp[i-2]
        dp[i]%=mod
    if not a[i-1]:
        dp[i]+=dp[i-1]
        dp[i]%=mod
    if a[i]:
        dp[i]=0

print(dp[n]%mod)

### FIXED CODE ###

n,m=map(int, input().split())
a=[False]*(n+1)
for i in range(m):
    A=int(input())
    a[A]=True
mod=10**9+7
dp=[0]*(n+1)

if not a[1]:
    dp[1]=1

if n>1:
    if not a[2]:
        dp[2]=dp[1]+1

for i in range(3,n+1):
    if not a[i-2]:
        dp[i]+=dp[i-2]
        dp[i]%=mod
    if not a[i-1]:
        dp[i]+=dp[i-1]
        dp[i]%=mod
    if a[i]:
        dp[i]=0

print(dp[n]%mod)
W =input()

count = 0
while True:
    line = input()
    if line == 'END_OF_TEXT':
        break

    for s in line.lower().split():
        if s = W:
            count += 1

print(count)
        

### FIXED CODE ###

W = input()

count = 0
while True:
    line = input()
    if line == 'END_OF_TEXT':
        break

    for s in line.lower().split():
        if s == W:
            count += 1

print(count)
a,b,n = map(int,input().split())
ans = 0

for i in range(n+1,n-a,-1):
    ans = max(ans,(a*i)//b) - a*(i//b))

print(ans)

### FIXED CODE ###

a,b,n = map(int,input().split())
i = min(b-1,n)
ans = a*i//b - a*(i//b)
print(ans)
import numpy as np
import sys
input = sys.stdin.readline


def main():

    h, n = map(int, input().split())
    # h = list(map(int, input().split()))

    A = []
    B = []
    for _ in range(n):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)

    m = 2 * 10**4 + 10
    dp = [0] * m
    for a, b in zip(A, B):
        dp[a] = b
    for i in range(10**4 + 1):
        for a, b in zip(A, B):
            # if i + a < 10**4:
            # print(i + a)
            # print(dp[i], dp[i + a], b, i + a)
            if i + a < m and dp[i] > 0:
                if dp[i + a] > 0:
                    dp[i + a] = min(dp[i + a], dp[i] + b)
                else:
                    dp[i + a] = dp[i] + b
    k = h
    # print(dp[:20])
    # while (flag):
    #     if dp[k] > 0:
    #         ans = dp[k]
    #         flag = 0
    #     k += 1
    d = np.array(dp[k:])
    print(np.min(d[d.nonzero()]))


main()


### FIXED CODE ###

#import numpy as np
import sys
input = sys.stdin.readline


def main():
    h, n = map(int, input().split())
    # A = []
    # B = []
    # for _ in range(n):
    #     A.append(a)
    #     B.append(b)
        
    m = 2 * 10**4 + 10
    dp = [float("inf")] * (h+1)
    dp[0] = 0
    # for a, b in zip(A, B):
    #     dp[a] = b
    for _ in range(n):
        a, b = map(int, input().split())
        for i in range(h):
            # for a, b in zip(A, B):
            if i + a < m :
                j = min(i+a, h)
                if dp[j] > 0:
                    dp[j] = min(dp[j], dp[i] + b)
                else:
                    dp[j] = dp[i] + b
    k = h
    # print(dp[:20])
    # while (flag):
    #     if dp[k] > 0:
    #         ans = dp[k]
    #         flag = 0
    #     k += 1
    # d = np.array(dp[k:])
    # print(np.min(d[d.nonzero()]))
    print(dp[h])
    
    
main()
N=int(input())
d=[input() for i in range(N)]
d_uni=list(set(d))
print(len(d_uni))

### FIXED CODE ###

S=input()
S1='2018'+S[4:]
print(S1)
def main():
    if(1 <= b and b <= a and a <= 20 and 1 <= c and c <= 20): 
        i = list(map(int, input().split()))
        a = i[0]
        b = i[1]
        c = i[2]

        

        k = c - a + b

        print(k)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():

    i = list(map(int, input().split()))
    a = i[0]
    b = i[1]
    c = i[2]

    if  not (1 <= b and b <= a and a <= 20 and 1 <= c and c <= 20):      
        return

    if c >= a - b:
        k = c - a + b
    else:
        k = 0

    print(k)


if __name__ == "__main__":
    main()
n = int(input())

count1 = 0

for i in range(1,n):
  a = i%2
  b = i/2
  count = 1
  while a ==0:
    a = b%2
    b = b/2
    count += 1
  if count > count1:
    count1 = count
    max_num = i
print(max_num)

### FIXED CODE ###

n = int(input())

count1 = 0

for i in range(1,n+1):
  a = i%2
  b = i/2
  count = 1
  while a ==0:
    a = b%2
    b = b/2
    count += 1
  if count > count1:
    count1 = count
    max_num = i
print(max_num)
from collections import defaultdict, Counter

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

c_al = Counter(al)
mod = 10**9 + 7

if n % 2 == 0 and 0 not in c_al.values():
    print(int((2 ** (n / 2)) % mod))
elif n % 2 != 0 and c_al[0] == 1:
    print(int((2 ** (n // 2)) % mod))
else:
    print(0)


### FIXED CODE ###

from collections import Counter

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

c_al = Counter(al)

if n % 2 == 0:
    for k,v in c_al.items():
        if v != 2:
            print(0)
            exit()
    print(pow(2, n // 2, 10 ** 9 + 7))

elif n % 2 != 0:
    for k, v in c_al.items():
        if k == 0:
            if v != 1:
                print(0)
                exit()
        elif v != 2:
            print(0)
            exit()
    print(pow(2, n // 2, 10 ** 9 + 7))
import sys
input = sys.stdin.readline
def main():
    N, M, Q = map(int, input().split())
    R = [list(map(int, input().split())) for i in range(Q)]
    ARR = [0]*N
    SUM = 0
    ANS = 0
    for i in nums:
        if ARR[R[i][0]-1] != 0:
            A = ARR[R[i][0]-1] 
        else:
            ARR[R[i][0]-1] = 1 
            A = ARR[R[i][0]-1] 
        if ARR[R[i][1]-1] != 0:
            B = ARR[R[i][1]-1]
        else:
            ARR[R[i][1]-1] = ARR[R[i][0]-1] + R[i][2]
        if ARR[R[i][1]-1]-ARR[R[i][0]-1] == R[i][2]:
            SUM += R[i][3]
        if max(ARR) - min(ARR) <= M:
            ANS = max(ANS, SUM)
        SUM = 0
    print(ANS)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
from collections import deque
ANS = 0
SUM = 0
def dfs(arr, l):
    global SUM, ANS
    # print(arr)
    if l == N:
        for i in range(Q):
            # print(arr[A[i][1]-1]-arr[A[i][0]-1])

            if arr[A[i][1]-1]-arr[A[i][0]-1] == A[i][2]:
                SUM += A[i][3]
            ANS = max(SUM, ANS)
        SUM = 0
        return
    else:
        for i in range(arr[l-1], M+1):
            arr.append(i)
            l = len(arr)
            # print(arr)
            dfs(arr,l)
            arr.pop()

    return ANS

if __name__ == '__main__':
    N, M ,Q = map(int, input().split())
    A = [list(map(int, input().split())) for i in range(Q)]
    ARR = deque([1])
    dfs(ARR,1)
    print(ANS)
str=int(input())
a=0
 
if str[0]==1:
  a++
  
if str[1]==1:
  a++
  
if str[2]==1:
  a++
  
print(a)

### FIXED CODE ###

num=input()
a=0
 
if int(num[0])==1:
  a+=1
  
if int(num[1])==1:
  a+=1
  
if int(num[2])==1:
  a+=1
  
print(a)
n = int(input())

if n>=64:
    print(64)
elif 32<=n<64:
    print(32)
elif 16<=n<32:
    print(16)
elif 8<=n<16:
    print(8)
elif 4<=n<8:

### FIXED CODE ###

n = int(input())

if n>=64:
    print(64)
elif 32<=n<64:
    print(32)
elif 16<=n<32:
    print(16)
elif 8<=n<16:
    print(8)
elif 4<=n<8:
    print(4)
elif 2<=n<4:
    print(2)
else:
    print(1)
if S*T > D:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

D,T,S = [int(i) for i in input().split(' ')]
 
if T*S >= D:
  print('Yes')
else:
  print('No')
n,k=map(int,input().split())
def pt(n,k):
  if n==1:
    return k
  else:
    return pt(n-1,k)*(k-1)
print(pt(n,k))

### FIXED CODE ###

n,k=map(int,input().split())
def pt(n,k):
  if n==1:
    return k
  else:
    return pt(n-1,k)*(k-1)
print(k*((k-1)**(n-1)))