Harryxun/stf_run huggingface dataset:
#%%
import sys
sys.setrecursionlimit(10 ** 9)
from collections import deque

class Node:
      
    def __init__(self):
        self.id = -1
        self.parent = -1
        self.children = []    
        self.value = 0
        

def main():
    global instance_list
    N, Q = [int(i) for i in input().split()]
    instance_list = [Node() for _ in range(N)]

    for i in range(N - 1):
        temp1, temp2 = [int(i) - 1 for i in input().split()]
        instance_list[temp1].children.append(temp2)
        instance_list[temp2].parent = temp1

    for i in range(Q):
        start, value = [int(i) for i in input().split()]
        start -= 1
        instance_list[start].value += value
        
    que = deque()
    que.append([instance_list[0], 0])
    while len(que) > 0 :
        node, cost = que.popleft()
        instance_list[node].value += cost
        for i in instance_list[node].children:
            que.append([i, cost])
    

    ans = [instance_list[i].value for i in range(N)]
    print(" ".join(map(str, ans)))

if __name__ == "__main__":
    main()


### FIXED CODE ###

# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

#n = int(input())
n,q = [int(i) for i in readline().split()]

g = [[] for _ in range(n)]
for i in range(n-1):
    a,b = [int(i) for i in readline().split()]
    g[a-1].append(b-1)
    g[b-1].append(a-1)

add = [0]*n
for _ in range(q):
    p,x = [int(i) for i in readline().split()]
    add[p-1] += x

ans = [0]*n
#ans[0] = add[0]

def dfs(v,p,value): #p: parent of v
    value += add[v]
    ans[v] = value
    for c in g[v]:
        if c == p: continue
        dfs(c,v,value)

dfs(0,-1,0)

#print(add)

print(*ans)
a,b = int(input().split())
ans = 0
if  a >= b:
  ans += a
  a -= 1
else:
  ans += b
  b -= 1
if  a >= b:
  ans += a
  a -= 1
else:
  ans += b
  b -= 1
print(ans)

### FIXED CODE ###

a,b = map(int,input().split())
ans = 0
if  a >= b:
  ans += a
  a -= 1
else:
  ans += b
  b -= 1
if  a >= b:
  ans += a
  a -= 1
else:
  ans += b
  b -= 1
print(ans)
L=list(,ap(int,input().split()))
K=sorted(L)
print(L[0]+K[1])

### FIXED CODE ###

L=list(map(int,input().split()))
K=sorted(L)
print(K[0]+K[1])
import math
N = list(map(int,input().strip().split()))
sqrtA = math.sqrt(N[0])
sqrtB = math.sqrt(N[1])
sqrtC = math.sqrt(N[2])
def fl(x):
    digits = 10
    form = '%.'+str(digits-1)+'e'
    return float((form % x))

if fl(sqrtA) + fl(sqrtB) < fl(sqrtC):
    print("Yes")
if fl(sqrtA) + fl(sqrtB) >= fl(sqrtC):
    print("No")



### FIXED CODE ###

k=input()
K=int(k)
array=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(array[K-1])
#!/usr/bin/env python3

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * n

    def sum(self, i):
        s = 0
        i -= 1
        while i >= 0:
            s += self.tree[i]
            i = (i & (i + 1)) - 1
        return s

    def add(self, i, x):
        while i < self.size:
            self.tree[i] += x
            i |= i + 1

a = ord('a')

def make_index(s):

    index = [[] for _ in range(26)]
    for i, ch in enumerate(s):
        index[ord(ch) - a].append(i)

    return index

def solve(s):

    n = len(s)
    index = make_index(s)

    odd = None
    for code, char_pos in enumerate(index):
        if len(char_pos) % 2 == 1:
            if odd is not None:
                return -1
            odd = code

    if odd is not None:
        if index[odd][len(index[odd]) // 2] < n // 2:
            s = s.reverse()
            index = make_index(s)

    bit = Bit(n)

    ans = 0
    cnt = 0
    for i in range(n):
        if bit.sum(i + 1) - bit.sum(i) == 1:
            continue
        cnt += 1
        code = ord(s[i]) - a
        j = index[code].pop()
        ans += n - cnt - (j - bit.sum(j))
        if (n - 1) // 2 <= cnt:
            break

    return ans


def main():
    s = input()

    print(solve(s))


if __name__ == '__main__':
    main()



### FIXED CODE ###

#!/usr/bin/env python3

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * n

    def sum(self, i):
        s = 0
        i -= 1
        while i >= 0:
            s += self.tree[i]
            i = (i & (i + 1)) - 1
        return s

    def add(self, i, x):
        while i < self.size:
            self.tree[i] += x
            i |= i + 1

a = ord('a')

def make_index(s):

    index = [[] for _ in range(26)]
    for i, ch in enumerate(s):
        index[ord(ch) - a].append(i)

    return index

def solve(s):

    n = len(s)
    index = make_index(s)

    odd = None
    for code, char_pos in enumerate(index):
        if len(char_pos) % 2 == 1:
            if odd is not None:
                return -1
            odd = code

    bit = Bit(n)

    ans = 0
    cnt = 0
    for i in range(n):
        if bit.sum(i + 1) - bit.sum(i) == 1:
            continue
        code = ord(s[i]) - a
        if code == odd and index[code][-1] == i:
            continue
        cnt += 1
        j = index[code].pop()
        ans += n - cnt - (j - bit.sum(j))
        bit.add(j, 1)
        if n // 2 <= cnt:
            break

    if odd is not None:
        j = index[odd][-1]
        ans += abs(n // 2 - (j - bit.sum(j)))

    return ans


def main():
    s = input()

    print(solve(s))


if __name__ == '__main__':
    main()
valores = [int(input()), int(input()), int(input())]
valores[valores.index(max(valores))]=0
print(valores[0]+valores[1]+valores[2])


### FIXED CODE ###

x = input().split()
P = int(x[0])
Q = int(x[1])
R = int(x[2])
l = [P+Q,Q+R,R+P]
print(min(l))
from collections import Counter

def gcd(a, b):
    while b: a, b = b, a % b
    return abs(a)

MOD = 1000000007

def main():
    N = int(input())
    d = {}
    d[(1,0)] = (0,0)
    z = 0
    for i in range(N):
      a,b = (int(x) for x in input().split())
      g = gcd(a,b)
      a = a//g
      b = b//g
      if a*b<0: a = -abs(a)
      elif a*b>0: a = abs(a)
      b = abs(b)
      
      if a*b==0:
        if a==b==0:z+=1
        elif b==0: d[(1,0)] = (d[(1,0)][0]+1,d[(1,0)][1])
        elif a==0: d[(1,0)] = (d[(1,0)][0],  d[(1,0)][1]+1)
      else:
        if (a,b) in d: d[(a,b)] = (d[(a,b)][0]+1,d[(a,b)][1])
        elif (b, -a) in d: d[(b,-a)] = (d[(b,-a)][0],d[(b,-a)][1]+1)
        elif (-b, a) in d: d[(-b,a)] = (d[(-b,a)][0],d[(-b,a)][1]+1)
        else: d[(a,b)] = (1,0)
    
    ans = 1
    for i, j in d.values():
      ans *= (pow(2,i,MOD) + pow(2,j,MOD) - 1)
      ans %= MOD

    print(ans-1+z)

if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import Counter

def gcd(a, b):
    while b: a, b = b, a % b
    return abs(a)

MOD = 1000000007

# 2 WA
def main():
    N = int(input())
    d = {}
    d[(1,0)] = (0,0)
    z = 0
    for i in range(N):
      a,b = (int(x) for x in input().split())
      g = gcd(a,b)
      if g != 0:
        a = a//g
        b = b//g
        if a*b<0: a = -abs(a)
        elif a*b>0: a = abs(a)
      b = abs(b)
      
      if a*b==0:
        if a==b==0: z+=1
        elif b==0: d[(1,0)] = (d[(1,0)][0]+1,d[(1,0)][1])
        elif a==0: d[(1,0)] = (d[(1,0)][0],  d[(1,0)][1]+1)
      else:
        if (a,b) in d: d[(a,b)] = (d[(a,b)][0]+1,d[(a,b)][1])
        elif (b, -a) in d: d[(b,-a)] = (d[(b,-a)][0], d[(b,-a)][1]+1)
        elif (-b, a) in d: d[(-b,a)] = (d[(-b,a)][0], d[(-b,a)][1]+1)
        else: d[(a,b)] = (1,0)
    
    ans = 1
    for i, j in d.values():
      ans *= (pow(2,i,MOD) + pow(2,j,MOD) - 1)
      ans %= MOD

    print((ans-1+z)%MOD)

if __name__ == '__main__':
    main()
n = int(input())
m = n ** 0.5 + 3
for i in range(m,,-1):
  if i ** 2 < n:
    print(i ** 2)
    break

### FIXED CODE ###

n = int(input())
m = int(n ** 0.5 + 3)
for i in range(m):
    if i ** 2 > n:
        print((i - 1) ** 2)
        break
def has_path(start, goal):
    for step in range(start, goal):
        if (not isRoad[step]) and (not isRoad[step-1]):
            return False
    return True


N, A, B, C, D = map(int, input().split())
S = input()
isRoad = [True if c == "." else False for c in S]

if C <= B:      # すぬけ・ふぬけの二人が独立になっているとき
    if has_path(A, C) and has_path(B, D):
        print("Yes")
    else:
        print("No")
    exit()
elif C < D:    # ふぬけを動かしてからすぬけを動かせば良いとき
    if has_path(A, C) and has_path(B, D):
        print("Yes")
    else:
        print("No")
    exit()
else:       # どこかでふぬけがすぬけを追い越さなければいけない場合
    for i in range(B - 1, D + 1):   # 追い抜く場所があるかどうかを探索
        if isRoad[i - 1] and isRoad[i] and isRoad[i + 1]:
            print("Yes")
            exit()
    print("No")

### FIXED CODE ###

def has_path(start, goal):
    for step in range(start, goal):
        if (not isRoad[step]) and (not isRoad[step-1]):
            return False
    return True


N, A, B, C, D = map(int, input().split())
S = input()
isRoad = [True if c == "." else False for c in S]

if C <= B:      # すぬけ・ふぬけの二人が独立になっているとき
    if has_path(A, C) and has_path(B, D):
        print("Yes")
    else:
        print("No")
    exit()
elif C < D:    # ふぬけを動かしてからすぬけを動かせば良いとき
    if has_path(A, C) and has_path(B, D):
        print("Yes")
    else:
        print("No")
    exit()
else:       # どこかでふぬけがすぬけを追い越さなければいけない場合
    for i in range(B - 1, D):   # 追い抜く場所があるかどうかを探索
        if isRoad[i - 1] and isRoad[i] and isRoad[i + 1]:
            print("Yes")
            exit()
    print("No")
a = input()
s = input()
d = input()
f = input()
g = input()
h = input()
j = min(int(s), int(d), int(f), int(g), int(h))

if int(a)%j == 0:
    k = int(a)//j + 4
else:
    k = int(a)//j + 5
print(i)



### FIXED CODE ###

a = input()
s = input()
d = input()
f = input()
g = input()
h = input()
j = min(int(s), int(d), int(f), int(g), int(h))

if int(a)%j == 0:
    k = int(a)//j + 4
else:
    k = int(a)//j + 5
print(k)
a = [2, 5, 5, 4, 5, 6, 3, 7, 6]
N, M = list(map(int, input().split()))
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted([a[i-1] for i in A])

dp = [-1] * (N+1)
for b in B:
    dp[b] = 1

for i in range(1, N+1):
    for b in B:
        if i < b:
            break
        else:
            dp[i] = max(dp[i], dp[i-b]+1)
digit = dp[-1]

for n in A:
    x = a[n-1]
    while dp[N-x] == digit-1:
        print(n, end='')
        N -= x
        digit -= 1
    if N == x:
        print(n, end='')
        N -= x

### FIXED CODE ###

a = [2, 5, 5, 4, 5, 6, 3, 7, 6]
N, M = list(map(int, input().split()))
A = sorted(set(list(map(int, input().split()))), reverse=True)
B = sorted([a[i-1] for i in A])

dp = [-1] * (N+1)
for b in B:
    if b < N+1:
        dp[b] = 1

for i in range(1, N+1):
    for b in B:
        if i < b:
            break
        else:
            dp[i] = max(dp[i], dp[i-b]+1)
digit = dp[-1]

for n in A:
    x = a[n-1]
    if N-x >= 0:
        while dp[N-x] == digit-1:
            print(n, end='')
            N -= x
            digit -= 1
        if N == x:
            print(n, end='')
            N -= x
n=int(input())
for i in range(1,50001):
  if (i＊1.08)==n:
    print(i)
    break
  else:
    print(":(")

### FIXED CODE ###

n = int(input().strip())

for i in range(1, 50001):
    if int(i * 1.08) == n:
        print(i)
        break
else:
    print(":(")
N=int(input())
A,B= list(map(int,input().split())),list(map(int,input().split()))

ans = 0
for i,b in enumerate(B):
    temp = min(b,A[i]+A[i+1])
    ans += temp
    A[i+1] -= max(0, temp-A[i]) #有り余った力を次の街で倒す
print(an)


### FIXED CODE ###

N=int(input())
A,B= list(map(int,input().split())),list(map(int,input().split()))

ans = 0
for i,b in enumerate(B):
    temp = min(b,A[i]+A[i+1])
    ans += temp
    A[i+1] -= max(0, temp-A[i]) #有り余った力を次の街で倒す
print(ans)
import math
from functools import reduce


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


n = int(input())
a = list(map(int, input().split()))
print(gcd_list(a))

### FIXED CODE ###

from functools import reduce


def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

def gcd_list(numbers):
    return reduce(gcd, numbers)


n = int(input())
a = list(map(int, input().split()))
print(gcd_list(a))
from numba import njit


class UnionFind:
    __slots__ = ["data"]
    
    def __init__(self, n=0):
        self.data = [-1]*(n+1)
    
    def root(self, x):
        if self.data[x] < 0:
            return x
        self.data[x] = self.root(self.data[x])
        return self.data[x]
    
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            if self.data[x] < self.data[y]:
                self.data[x] += self.data[y]
                self.data[y] = x
            else:
                self.data[y] += self.data[x]
                self.data[x] = y
    
    def same(self, x, y):
        return self.root(x) == self.root(y)
    
    def size(self, x):
        return -self.data[self.root(x)]

@njit
def main():
    n, m = map(int, input().split())
    uf = UnionFind(n)
    for i in range(m):
        a, b = map(int, input().split())
        uf.unite(a, b)
        
    ans = 0
    
    for i in range(1, n+1):
        ans = max(ans, uf.size(i))
        
    print(ans)
        


main()


### FIXED CODE ###

class UnionFind:
    __slots__ = ["data"]
    
    def __init__(self, n=0):
        self.data = [-1]*(n+1)
    
    def root(self, x):
        if self.data[x] < 0:
            return x
        self.data[x] = self.root(self.data[x])
        return self.data[x]
    
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            if self.data[x] < self.data[y]:
                self.data[x] += self.data[y]
                self.data[y] = x
            else:
                self.data[y] += self.data[x]
                self.data[x] = y
    
    def same(self, x, y):
        return self.root(x) == self.root(y)
    
    def size(self, x):
        return -self.data[self.root(x)]


def main():
    n, m = map(int, input().split())
    uf = UnionFind(n)
    for i in range(m):
        a, b = map(int, input().split())
        uf.unite(a, b)
        
    ans = 0
    
    for i in range(1, n+1):
        ans = max(ans, uf.size(i))
    
    print(ans)
        

if __name__ == "__main__":
    main()
n = input()
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])

if a+b+c+d == 7:
    print('{}+{}+{}+{}=7'.format(a, b, c, d))
elif a+b+c-d == 7:
    print(('{}+{}+{}-{}=7'.format(a, b, c, d))
elif a+b-c+d == 7:
    print('{}+{}-{}+{}=7'.format(a, b, c, d))
elif a+b-c-d == 7:
    print('{}+{}-{}-{}=7'.format(a, b, c, d))
elif a-b+c+d == 7:
    print('{}-{}+{}+{}=7'.format(a, b, c, d))
elif a-b+c-d == 7:
    print('{}-{}+{}-{}=7'.format(a, b, c, d))
elif a-b-c+d == 7:
    print('{}-{}-{}+{}=7'.format(a, b, c, d))
elif a-b-c-d == 7:
    print('{}-{}-{}-{}=7'.format(a, b, c, d))

### FIXED CODE ###

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

if a+b+c+d == 7:
    print('{}+{}+{}+{}=7'.format(a, b, c, d))
elif a+b+c-d == 7:
    print('{}+{}+{}-{}=7'.format(a, b, c, d))
elif a+b-c+d == 7:
    print('{}+{}-{}+{}=7'.format(a, b, c, d))
elif a+b-c-d == 7:
    print('{}+{}-{}-{}=7'.format(a, b, c, d))
elif a-b+c+d == 7:
    print('{}-{}+{}+{}=7'.format(a, b, c, d))
elif a-b+c-d == 7:
    print('{}-{}+{}-{}=7'.format(a, b, c, d))
elif a-b-c+d == 7:
    print('{}-{}-{}+{}=7'.format(a, b, c, d))
elif a-b-c-d == 7:
    print('{}-{}-{}-{}=7'.format(a, b, c, d))
package main

import (
	"fmt"
)

func main() {
	var A, B int
	fmt.Scan(&A)
	fmt.Scan(&B)
	if (A + B) % 2 == 0 {
		fmt.Println((A + B) / 2)
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}


### FIXED CODE ###

A, B = [int(i) for i in input().split(" ")]
if (A + B) % 2 == 0: print((A + B) // 2)
else: print("IMPOSSIBLE")
x, y, a, b, c = map(int, input().split())
al = sorted(list(map(int, input().split())), reverse=True)[:x]
bl = sorted(list(map(int, input().split())), reverse=True)[:y]
cl = sorted(list(map(int, input().split())), reverse=True)
ans = 0
xi, yi = 0, 0
for i in cl:
    if al:
        ai = al[-1]
    else:
        ai = 0
    if bl:
        bi = bl[-1]
    else:
        bi = 0
    if ai < bi:
        m = al.pop()
    else:
        m = bl.pop()
    if m < i:
        ans += i
    else:
        ans += m
        break
ans += sum(al)+sum(bl)
print(ans)

### FIXED CODE ###

def main():
    x, y, a, b, c = map(int, input().split())
    al = sorted(list(map(int, input().split())), reverse=True)[:x]
    bl = sorted(list(map(int, input().split())), reverse=True)[:y]
    cl = sorted(list(map(int, input().split())), reverse=True)
    ans = 0
    xi, yi = 0, 0
    for i in cl:
        if al:
            ai = al[-1]
        else:
            ai = 10000000000
        if bl:
            bi = bl[-1]
        else:
            bi = 10000000000
        if ai < bi:
            if al:
                m = al.pop()
            else:
                m = 0
        else:
            if bl:
                m = bl.pop()
            else:
                m = 0
                
        if m < i:
            ans += i
        else:
            ans += m
            break
    ans += sum(al)+sum(bl)
    print(ans)

if __name__ == "__main__":
    main()
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
A = list(map(int, input().split()))

B = [0] * 10001
for a in A:
    B[a] += 1
cnt2 = 0
cnt1 = 0
ans = 0
for b in B:
    if b > 2:
        cnt2 += 1
    if b > 1:
        cnt1 += 1
    if b > 0:
        ans += 1
if cnt1 % 2 == 1 and cnt2 == 0:
    ans -= 1
print(ans)

### FIXED CODE ###

import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
A = list(map(int, input().split()))

B = [0] * 100001
for a in A:
    B[a] += 1
cnt1 = 0
ans = 0
for b in B:
    if b > 1 and b % 2 == 0:
        cnt1 += 1
    if b > 0:
        ans += 1
if cnt1 % 2 == 1:
    ans -= 1
print(ans)
# 2
import sys
sys.setrecursionlimit(10000)
args = sys.stdin.readlines()
N = int(args[0])
xy_list = [[int(y) for y in x.split(' ')] for x in args[1:]]

from collections import Counter, defaultdict

delta_dict = defaultdict(int)

for i in range(N):
    for j in range(N):
        if i != j:
            delta_dict[(xy_list[i][0] - xy_list[j][0], xy_list[i][1] - xy_list[j][1])] += 1

print(N - Counter(delta_dict).most_common()[0][1])

### FIXED CODE ###

# 2
import sys
sys.setrecursionlimit(10000)
args = sys.stdin.readlines()
N = int(args[0])
xy_list = [[int(y) for y in x.split(' ')] for x in args[1:]]

from collections import Counter, defaultdict

delta_dict = defaultdict(int)

if N == 1:
    print(1)
    exit()
for i in range(N):
    for j in range(N):
        if i != j:
            delta_dict[(xy_list[i][0] - xy_list[j][0], xy_list[i][1] - xy_list[j][1])] += 1
    
print(N - Counter(delta_dict).most_common()[0][1])
N = int(input())
A = list(map(int, input().split()))
res = 1

if 0 in A :
    print(0)
    exit()

for x in range(N) :
    res = res*A[x]
    if res > 10E+17
        print(-1)
        break

print(res)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))

limit = 10 ** 18
A.sort()
result = A[0]
for a in A[1:]:
    result *= a
    if result > limit:
        print(-1)
        exit()
print(result)
n = int(input())
a = [int(input()) for i in range(n)]

for i in len(a):
  b = a.copy()
  b.del[i]
  print(max(b))


### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
b = sorted(a, reverse=True)
for i in range(n):
    if b[0] == b[1]:
        print(b[0])
    else:
        if a[i] == b[0]:
            print(b[1])
        else:
            print(b[0])
def knapsack01rec(n, W, weights, values, dp, i, j):
    # i = up until item i, j = up until weight j
    if i == 0 or j <= 0:
        return 0

    if dp[i][j] != -1:
        return dp[i][j]

    if weights[i-1] > j:
        # weights[i] doesn't fit in knapsack
        dp[i][j] = knapsack01rec(n, W, weights, values, dp, i-1, j)
    else:
        dp[i][j] = max(
            knapsack01rec(n, W, weights, values, dp, i-1, j),
            knapsack01rec(n, W, weights, values, dp, i-1, j-weights[i-1]) + values[i-1])
    return dp[i][j]

dp = [[-1 for _ in range(W+1)] for _ in range(n+1)]
res = knapsack01rec(n, W, weights, values, dp, n, W)

print(res)

### FIXED CODE ###


def knapsack01iter(n, W, weights, values, dp):
    for i in range(1,n+1):
        for j in range(0, W+1):
            if j < weights[i-1]: # if knapsack cannot fit item i
                dp[i][j] = dp[i-1][j]
            elif j >= weights[i-1]: # knapsack can fit item i
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-weights[i-1]]+values[i-1])
    
    return dp[-1][-1]
    
    
n,W = [int(x) for x in input().split()]
weights = []
values = []
for i in range(n):
    l = [int(x) for x in input().split()]
    weights += [l[0]]
    values += [l[1]]

# repeatableKnapsack(n, W, weights, values)

# dp = [[-1 for _ in range(W+1)] for _ in range(n+1)]
# res = knapsack01rec(n, W, weights, values, dp, n, W)
# print(dp)
dp = [[0 for _ in range(W+1)] for _ in range(n+1)]
res = knapsack01iter(n, W, weights, values, dp)
# print(dp)
print(res)
S = input()
print('Yes') if len(set(S)) == 2 and S.count(set(S[0]) == S.count(set(S[1])) else print('No')

### FIXED CODE ###

S = input()
S2 = list(set(S))
print('Yes') if len(S2) == 2 and S.count(S2[0]) == S.count(S2[1]) else print('No')
n = int(input())
h_L = list(map(int,input().split()))

#dp = [float("inf")] * (10**4 + 1)
dp = [float("inf")] * 20

dp[0] = 0
dp[1] = abs(h_L[0]-h_L[1])

for i in range(1,len(h_L)):
    #dp[i]
    # 1
    tmp1 = dp[i-1] + abs(h_L[i-1] - h_L[i])
    dp[i] = min(dp[i],tmp1)
    # 2
    tmp2 = dp[i-2] + abs(h_L[i-2] - h_L[i])
    dp[i] = min(dp[i],tmp2)
#print(dp)
print(dp[len(h_L)-1])

### FIXED CODE ###

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

dp = [10**9] * n
dp[0] = 0
dp[1] = abs(h_L[1] - h_L[0])

for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(h_L[i-1] - h_L[i]),dp[i-2]+abs(h_L[i-2] - h_L[i]))

print(dp[n-1])
print('Christmas'+' Eve'*(25-int(input)))

### FIXED CODE ###

print('Christmas'+' Eve'*(25-int(input())))
s,t=input()
if s[0]==t[2] and s[1]==t[1] and s[2]==t[0]:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

s=input()
t=input()
if s[0]==t[2] and s[1]==t[1] and s[2]==t[0]:
    print("YES")
else:
    print("NO")
def main():
    while True;
        H, W = tuple(map(int, input().split()))
        if (H, W) == (0, 0):
            break
        for i in range(H):
            print("#"*W)

if __name__ == '__main__':
    main()



### FIXED CODE ###

Rect = []
cnt = 0
while True:
    H, W = map(int, input().split())
    if (H, W) == (0, 0):
        break
    Rect.append((H, W))
    cnt += 1

# print(Rect)
# print(Rect[1][1])
for i in range(cnt):
    for _ in range(Rect[i][0]):
        print("#"*Rect[i][1])
    print()
import re
S = input()
string = re.findall(r'([ACGT]+)', S)

lenst = [len(x) for x in string]
print(max(lenst))

### FIXED CODE ###

import re
S = input()
string = re.findall(r'([ACGT]+)', S)

if len(string) != 0:
  lenst = [len(x) for x in string]
  print(max(lenst))
  
else:
  print(0)