Harryxun/stf_run huggingface dataset:
import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

N, M = map(int, input().split())
s = [list(map(int, input().split()))[1:] for _ in range(M)]
p = list(map(int, input().split()))


def switch(bit, ans):
    check = [(bit >> i) & 1 for i in range(N)]
    light = 0
    for i in range(M):
        num = 0
        for l in s[i]:
            if check[l - 1] == 1:
                num += 1
        if num % 2 == p[i]:
            light += 1
    if light == M:
        ans += 1
    if bit == 1:
        print(ans)
    else:
        switch(bit - 1, ans)


switch(2 ** N, 0)


### FIXED CODE ###

import sys
import math
from collections import deque
import itertools
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()
ans = 0
N, M = map(int, input().split())
ks = [tuple(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))
t = []
for i in range(N):
    tt = list(itertools.combinations(range(1, N+1), i+1))
    for l in tt:
        t.append(l)
t.append(tuple())
for i in range(len(t)):
    pp = 0
    for l in range(M):
        if len(set(ks[l][1:]) & set(t[i])) % 2 == p[l]:
            pp += 1
    if pp == M:
        ans += 1
print(ans)
inputs = [int(x) for x in input().split()]

N = inputs[0]
D = inputs[1]
answer = 0
if N < (D*2) + 1:
  answer = 1
else:
  check = N % ((D*2) + 1)
  answer = N / ((D*2) + 1) 
  answer = int(answer)
if check != 0:
  answer += 1
  
print(answer)

### FIXED CODE ###

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

N = inputs[0]
D = inputs[1]
answer = 0
if N > (D*2) + 1:
  check = N % ((D*2) + 1)
  answer = N / ((D*2) + 1) 
  answer = int(answer)
  if check != 0:
    answer += 1
  
else:
  answer = 1
  
print(answer)
ai=[s]
for i in range(1000000):
    if s%2:
        s =3*s+1
        ai.append(s)
    else:
        s = s//2
        ai.append(s)
    print(ai)
    if len(ai) != len(set(ai)):
        c=0
        for j in range(len(ai)):
            if ai.count(ai[j])==2:
                c +=1
                if c ==2:
                    print(j+1)
                    break
        exit()

### FIXED CODE ###

n = int(input())
ans = 1
while(n != 4 and n != 2 and n != 1):
    ans += 1
    if n%2 == 0:
        n = n//2
    else:
        n = 3*n+1
print(ans+3)
a,b = input().split()
a = int(a)
b = int(b.replace(".","")
print(a*b//100)

### FIXED CODE ###

a,b = input().split()
a = int(a)
b = int(b.replace(".",""))
print(a*b//100)
N = input()
X = list(map(int, input().split()))
for a in X:
    sum = sum + a
C = sum/N
for b in X:
    ans = (b-C)**2
print(ans)

### FIXED CODE ###

N = int(input())
X = list(map(int, input().split()))
sum = 0
all = True
for a in X:
    sum = sum + a
C = int(sum / N + 0.5)
ans = 0
for b in X:
    ans = ans + (b-C)**2
print(ans)
S = input()
if S[2] == S[3] and S[4] == S[5]:
  print(Yes)
else:
  print(No)


### FIXED CODE ###

S = input()
if S[2] == S[3] and S[4] == S[5]:
  print('Yes')
else:
  print('No')
n,m,k = list(map(int,input().split()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))

from collections import deque
sa = deque([x for x in a])
sb = deque([x for x in b])
sa.append(10**9+1)
sb.append(10**9+1)
ans = 0
def cnt(a,b,time):
  global ans
  #print(ans, time,a,b)
  if (time <= k) & ( (len(a) > 1) | (len(b) > 1)):
    if a[0] < b[0]:
      #time += a[0]
      a.popleft()
    else:
      #time += b[0]
      b.popleft()
    if time <= k:
      ans += 1
      cnt(a,b,time)

cnt(sa,sb,0)
print(ans)

### FIXED CODE ###

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sa = [0] * (n + 1)
sb = [0] * (m + 1)
for i in range(n):
  sa[i + 1] = sa[i] + a[i]
for i in range(m):
  sb[i + 1] = sb[i] + b[i]
r = m
ans = 0
for i in range(n + 1):
  if sa[i] > k:
    break
  while sa[i] + sb[r] > k:
    r -= 1
  ans = max(ans, i + r)
print(ans)
N = int(input())
A = map(int, input().split())

ans = 0

while A % 2 == 0:
    A = A / 2
    ans = ans +1
return ans

print(ans)

### FIXED CODE ###

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

def x(n):
    ans = 0
    while n % 2 == 0:
        n /= 2
        ans += 1
    return ans

ans = min(map(x, A))

print(ans)
N = input()
A = input()
if (N % 500) <= A:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N = int(input())
A = int(input())
if (N % 500) <= A:
  print("Yes")
else:
  print("No")
a,b,c = map(int,input().split())
L = [a,b,c]
M = L.sorted()
ptint(int(str(M[2])+str(M[1]))+int(M[0]))

### FIXED CODE ###

a,b,c = (map(int,input().split()))
L = [a,b,c]
M = L.sort()

print(L[-1]*10 + L[0] + L[1])
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
  int a, b;
  char op;
  cin >> a >> op >> b;
  if (op == '+') {
    //    printf("%d\n", a+b);
    cout << a+b << "\n";
  }else {
    cout << a-b << "\n";
    //printf("%d\n", a-b);
  }
  return 0;
}


### FIXED CODE ###

C = list( input().split())
if C[1] == '-':
    print( int(C[0]) - int(C[2]))
else:
    print( int(C[0]) + int(C[2]))
n,m=map(int,input().split())
l=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    l[a-1].append(b-1)
    l[b-1].append(a-1)

p=[0]*n
p[0]=1
now=1
cnt=0
while 0 in p and k>0:
    for to in l[now-1] and cnt<=m:
        if p[to]==0:
            p[to]=now
            cnt+=1
    now=to+1
    k-=1
if 0 in p:
    print("No")
else:
    print("Yes")
    for i in range(1,n):
        print(p[i])



### FIXED CODE ###

n,m=map(int,input().split())
l=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    l[a-1].append(b-1)
    l[b-1].append(a-1)

from collections import deque

p=[0]*n
ans=[0]*n
d=deque()
d.append(0)
while len(d)!=0:
    now=d.popleft()
    for to in l[now]:
        if p[to]==0:
            p[to]=p[now]+1
            d.append(to)
            ans[to]=now
print("Yes")
for i in range(1,n):
    print(ans[i]+1)
import math


def main() -> None:
    a, b = input().split()

    print((int(a) * (int(b)*100)) // 100)
    retz


if __name__ == '__main__':
    main()


### FIXED CODE ###

import math


def main() -> None:
    a, b = input().split()

    print((int(a)*int(b.replace('.', ''))) // 100)

    return


if __name__ == '__main__':
    main()
n=int(input())
a=list(map(int,input().split()))
pl = [0]*(n+5)

for i in range(n):
    num = a[i]
    pl[num-1] += 1
    pl[num+2] -= 1

for i in range(1,n+4):
    pl[i] += pl[i-1]

print(max(pl))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
pl = [0]*100005

for i in range(n):
    num = a[i]
    pl[num-1 + 2] += 1
    pl[num+2 + 2] -= 1

for i in range(1,100004):
    pl[i] += pl[i-1]

print(max(pl))
a,b=map(int, input().split())

n_list = []
c = a + b
d = a - c
e = a * b

n_list.append(c)
n_list.append(d)
n_list.append(e)

sorted_list = sorted(n_list)

if sorted_list[2] > sorted_list[1]:
    print(sorted_list[2])
elif sorted_list[2] == sorted[1] & sorted_list[1] > sorted_list[0]:
    print(sorted_list[2], sorted_list[1])
else:
    print(sorted_list[2], sorted_list[1], sorted_list[0])

### FIXED CODE ###

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

n_list = []
c = a + b
d = a - b
e = a * b

n_list.append(c)
n_list.append(d)
n_list.append(e)

print(max(n_list))
while 1:
    H, W = map(int,raw_input().split())
??????if H == W == 0:
       break
    print (('#' * W + '/n') * H)

### FIXED CODE ###

while 1:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  print (("#" * W + "\n") * H)
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
mod=10**9+7
ans=1

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

begin=0
end=a[0]-1
for i in range(m):
    end=a[i]-1
    ans*=dp[end-begin]
    
    if(i+1<m and a[i+1]==a[i]+1):
        ans=0
        break
        
    else:
        begin=end+2

ans*=dp[n-a[m-1]-1]

print(ans%mod)

### FIXED CODE ###

n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
mod=10**9+7
ans=1

dp=[0]*(n+1)
dp[0]=1
dp[1]=1
for i in range(2,n+1):
    dp[i]=dp[i-1]+dp[i-2]
    dp[i]%=mod
if m==0:
    ans=dp[n]
else:
    begin=0
    end=a[0]-1
    for i in range(m):
        end=a[i]-1
        ans*=dp[end-begin]
        
        if(i+1<m and a[i+1]==a[i]+1):
            ans=0
            break
            
        else:
            begin=end+2

    ans*=dp[n-a[m-1]-1]

print(ans%mod)
_=input()
s=set(map(input().split()))
if len(s) == 3:
  print('Three')
else:
  print('Four')

### FIXED CODE ###

_=input()
s=set(input().split())
if len(s) == 3:
  print('Three')
else:
  print('Four')
import math
num,query = (int(n) for n in input().split(' '))
table = [2**31 - 1 for n in range(num)]
sqrttable = []
sqrtnum = math.floor(math.sqrt(num))
tempmin = float("inf")
for t in range(num):
    if t % sqrtnum == sqrtnum - 1:
        tempmin = min(table[t],tempmin)
        sqrttable.append(tempmin)
    elif t == num - 1:
        tempmin = min(table[t],tempmin)
        sqrttable.append(tempmin)
    else:
        tempmin = min(table[t],tempmin)

for q in range(query):
    #print(sqrtnum,table,sqrttable)
    temp = [int(n) for n in f.readline().split(' ')]
    if temp[0] == 0:
        table[temp[1]] = temp[2]
        tempmin = float("inf")
        for tm in range(sqrtnum*(temp[1]//sqrtnum),min(num,sqrtnum*(temp[1]//sqrtnum + 1))):
            tempmin = min(table[tm],tempmin)
        sqrttable[temp[1]//sqrtnum] = tempmin
    else:
        tempmin = float("inf")
        if temp[1] % sqrtnum != 0:
            for ini in range(temp[1],min(temp[2]+1,sqrtnum * math.ceil(temp[1] / sqrtnum))):
                tempmin = min(tempmin,table[ini])
        newtemp2 = temp[2] + 1
        for sqt in range(math.ceil(temp[1] / sqrtnum),newtemp2 // sqrtnum):
            tempmin = min(sqrttable[sqt],tempmin)
        if temp[2] % sqrtnum != sqrtnum -1:
            for end in range(max(temp[1],sqrtnum * (temp[2]//sqrtnum)),temp[2]+1):
                tempmin = min(tempmin,table[end])
        #print(tempmin,sqrtnum,temp[1],temp[2],table,sqrttable)
        print(tempmin)

### FIXED CODE ###

class RMQ:
    def __init__(self, length, ini_num = float("inf")):
        self.length = 1
        self.ini_num = ini_num
        while self.length < length:
            self.length <<= 1
        self.segtree = [ini_num] * (2 * self.length - 1)

    def update(self, index, n):
        leaf_index = index + self.length - 1
        self.segtree[leaf_index] = n
        while leaf_index > 0:
            leaf_index = (leaf_index - 1) // 2
            self.segtree[leaf_index] = min(self.segtree[leaf_index * 2 + 1], self.segtree[leaf_index * 2 + 2])

    def find(self, a, b, index, l, r):
        if a <= l <= r <= b:
            return self.segtree[index]
        elif b < l or r < a:
            return self.ini_num
        else:
            return min(self.find(a, b, index * 2 + 1, l, (l + r) // 2), self.find(a, b, index * 2 + 2, (l + r) // 2 + 1, r))

v_num, query = map(int, input().split(" "))
rmq = RMQ(v_num, 2147483647)
for _ in [0] * query:
    com, i, n = map(int, input().split(" "))
    if com == 0:
        rmq.update(i, n)
    else:
        print(rmq.find(i, n, 0, 0, rmq.length - 1))
n = list(map(int, input().split()))
h = list(map(int, input().split()))
c = 0
for i in range(n[1]):
  if h[i] >= n[0]:
    c += 1
    
print(c)

### FIXED CODE ###

n = list(map(int, input().split()))
h = list(map(int, input().split()))
c = 0
for i in range(n[0]):
  if h[i] >= n[1]:
    c += 1
    
print(c)
cnt,ans = 0,[]
agct = ["A","G","C","T"]
for i in range(len(s)):
    if s[i] in agct:
        cnt += 1
    else:
         ans.append(cnt)
         cnt = 0
if ans == []:
    ans.append(0)
print(max(ans))

### FIXED CODE ###

s = list(input())
cnt,ans = 0,[]
agct = ["A","G","C","T"]
for i in range(len(s)):
    if s[i] in agct:
        cnt += 1
    else:
        ans.append(cnt)
        cnt = 0
if cnt > 0:
  ans.append(cnt)
print(max(ans))
n, k, l = map(int, input().split())
roads = list(range(n))
railways = list(range(n))
ans = []
for _ in range(k):
    a, b = map(lambda x : int(x) - 1, input().split())
    i = min(roads[a], roads[b])
    roads[roads[a]] = roads[a] = i
    roads[roads[b]] = roads[b] = i
for _ in range(l):
    a, b = map(lambda x : int(x) - 1, input().split())
    i = min(railways[a], railways[b])
    railways[railways[a]] = railways[a] = i
    railways[railways[b]] = railways[b] = i

roads_dic = dict()
railways_dic = dict()
for i in range(n):  
    if roads[i] == i:
        roads_dic[i] = {i}
    else:
        roads_dic[roads[i]].add(i)
    if railways[i] == i:
        railways_dic[i] = {i}
    else:
        railways_dic[railways[i]].add(i)

ans = [len(roads_dic[roads[i]] & railways_dic[railways[i]]) for i in range(n)]
print(" ".join(map(str, ans)))

### FIXED CODE ###

class UnionFindTree:
    def __init__(self, n):
        self.nodes = [-1] * n #根にサイズを負の値で格納する。
    def find(self, i):
        if self.nodes[i] < 0: #値が負の場合は根
            return i
        else:
            self.nodes[i] = self.find(self.nodes[i]) #縮約
            return self.nodes[i]

    def union(self, i, j):
        i = self.find(i)
        j = self.find(j)
        if i == j:
            return
        if self.nodes[i] > self.nodes[j]: #サイズ比較してiの方がサイズが大きいようにする
            i, j = j, i
        self.nodes[i] += self.nodes[j] #大きい方に小さい方を統合しサイズを登録する。
        self.nodes[j] = i # jの親はi
    
    def size(self, i): # 所属する集合の大きさを返す
        i = self.find(i)
        return -self.nodes[i]


n, k, l = map(int, input().split())
roads = UnionFindTree(n)
railways = UnionFindTree(n)
ans = []
for _ in range(k):
    a, b = map(lambda x : int(x) - 1, input().split())
    roads.union(a, b)
    
for _ in range(l):
    a, b = map(lambda x : int(x) - 1, input().split())
    railways.union(a, b)

counter = dict()
for i in range(n):
    p = (roads.find(i), railways.find(i))
    if not p in counter:
        counter[p] = 1
    else:
        counter[p] += 1

ans = [counter[(roads.find(i), railways.find(i))] for i in range(n)]
print(" ".join(map(str, ans)))
m=int(input())
import math

N=math.factorial(m)
n= int(N**.5)
res = len(str(N))
arr = []
tmp = N
for i in range(2,n+1):
    if tmp % i == 0:
        while tmp % i == 0:
            arr.append(i)
            tmp //= i
if tmp != 1: arr.append(tmp)
arr += [1, N]
print(len(arr) % (10**9+7))

### FIXED CODE ###

N = int(input())

primes = set()
for i in range(2,N+1):
    for p in primes:
        if i % p == 0:
            break
    else:
        primes.add(i)

len_prime = len(primes)
d = dict(zip(list(primes), [1 for i in range(len_prime)]))

for i in range(2, N+1):
    while i != 1:
        for p in primes:
            if i % p == 0:
                d[p]+= 1
                i //= p
res = 1
for i in d.values():
    res*=i
print(res % 1000000007)
from math import factorial
import sys
N,M=map(int,input().split())
ANS1=1
ANS2=1
ANS3=1
A=int(input())
list1=[A]
DAN=A
B=DAN-DAN//2
for k in range(B):
  a = factorial(B) / factorial(k+1) / factorial(B - (k+1))
  ANS1+=a
for i in range(1,M):
  ans2=1
  A=int(input())
  list1+=[A]
  DAN=A-list1[i-1]-1
  B=DAN-DAN//2
  if A==list1[i-1] or A==list1[i-1]+1 and M!=1:
    print(0)
    sys.exit()
  for k in range(B):
    a = factorial(B) / factorial(k+1) / factorial(B - (k+1))
    ANS2+=a
  ANS3*=ANS2
DAN=N-A-1
B=DAN-DAN//2
for t in range(B):
  a = factorial(B) / factorial(t+1) / factorial(B - (t+1))
  ANS3+=a
ANS=ANS1*ANS2*ANS3  
print(int(ANS)%1000000007)

### FIXED CODE ###

import sys
N,M=map(int,input().split())
dp=[1]*N
listA=[]
for i in range(M):
  a=int(input())
  listA+=[a]
  dp[a-1]=0
for i in range(1,M):
  if listA[i]==listA[i-1]:
    print(0)
    sys.exit()
setA=set(listA)    
if (1 not in setA) and (2 not in setA) and N!=1:
  dp[1]=2
for i in range(2,N):
  if i+1 not in setA:
    dp[i]=dp[i-1]+dp[i-2]
ans=dp[-1]%(10**9+7)
print(ans)
from sys import stdin

n = int(stdin.readline().rstrip())

print(n)

### FIXED CODE ###

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

if (a + b) % 2 == 0:
    print((a + b) // 2)
else:
    print("IMPOSSIBLE")
c=input()
c=c.upper()
c=chr(ord(c+1))
print(c)

### FIXED CODE ###

c=input()
print(chr(ord(c)+1))
MOD = 1e9 + 7

facs = [0 for _ in range(50009)]
facs[1] = 1
for i in range(2, 50009):
	facs[i] = (facs[i-1] * i) % MOD


def choose(n, k):
	if k==1:
		return n
	if n==0:
		return 0
	return facs[n]/facs[k]/facs[n-k]

def main():
	N, K = map(int, input().split())
	numbers = sorted(map(int, input().split()))
	if K==1:
		return 0
	if K==N:
		return numbers[0] - numbers[-1]

	score = 0
	for i, x in enumerate(numbers):
		score = (score + (choose(i, K-1) - choose(N-1-i, K-1)) * x) % MOD

	return int(score)
	
	
print(main())


### FIXED CODE ###

import time
MOD =  1000000007
MOD2 = 1000000005
MAX = 100001

facs = [1 for _ in range(MAX)]
inv = [1 for _ in range(MAX)]


for i in range(1, MAX):
	facs[i] = (facs[i-1] * i) % MOD

for i in range(1, MAX):
	inv[i] = pow(facs[i], MOD2, MOD)


def get_facs(x):
	return facs[x]


def get_inv(x):
	return inv[x]

def choose(n, k):

	if k==0 or n==k:
		return 1
	if n==0:
		return 0
	if k>n:
		return 0
	r = (get_facs(n)*get_inv(k)) % MOD
	r = (r*get_inv(n-k)) % MOD
	return r



def main():
	N, K = map(int, input().split())
	numbers = sorted(map(int, input().split()))
	if K==1:
		return 0
	if K==N:
		return abs(numbers[0] - numbers[-1])

	score = 0
	for i, x in enumerate(numbers):
		score += ((choose(i, K-1) - choose(N-1-i, K-1)) * x)

	return score%MOD
	
	
print(main())
a=list(input().split())
if sum(a)>=22:
  print("bust")
elif sum(a)<=21:
  print("win")

### FIXED CODE ###

a=list(map(int,input().split()))
if sum(a)>=22:
  print("bust")
elif sum(a)<=21:
  print("win")
number = int(input())

ac = 0
wa = 0
tle = 0
re = 0
for i in range(number):
  character = input()
  if character == 'AC':
    ac += 1
  if character == 'WA':
    wa += 1
  if character == 'TLE':
    tle += 1
  if character == 'RE':
    re += 1

print("AC x " + ac)
print("WA x " + wa)
print("TLE x " + tle)
print("RE x " + re)

### FIXED CODE ###

number = int(input())
 
ac = 0
wa = 0
tle = 0
re = 0
for i in range(number):
  character = input()
  if character == 'AC':
    ac += 1
  if character == 'WA':
    wa += 1
  if character == 'TLE':
    tle += 1
  if character == 'RE':
    re += 1
 
print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))
h, w = map(int, input().split())
s = [0] * w
for i in range(h):
    s[i] = list(input())

h_cnt = [[0] * w for _ in range(h)]
w_cnt = [[0] * w for _ in range(h)]

for i in range(h):
    dot_cnt, beg_sec = 0, 0
    for j in range(w):
        if s[i][j] == '#':
            if dot_cnt > 0:
                for k in range(beg_sec, j):
                    w_cnt[i][k] = dot_cnt
                beg_sec = j+1
                dot_cnt = 0
            else:
                w_cnt[i][j] = 0
                beg_sec += 1
        else:
            dot_cnt += 1
    if dot_cnt > 0:
        for k in range(beg_sec, w):
            w_cnt[i][k] = dot_cnt

for i in range(w):
    dot_cnt, beg_sec = 0, 0
    for j in range(h):
        if s[j][i] == '#':
            if dot_cnt > 0:
                for k in range(beg_sec, j):
                    h_cnt[k][i] = dot_cnt
                beg_sec = j+1
                dot_cnt = 0
            else:
                h_cnt[j][i] = 0
                beg_sec += 1
        else:
            dot_cnt += 1
    if dot_cnt > 0:
        for k in range(beg_sec, h):
            h_cnt[k][i] = dot_cnt

ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, h_cnt[i][j] + w_cnt[i][j] - 1)
print(ans)

### FIXED CODE ###

h, w = map(int, input().split())
s = [0] * h
for i in range(h):
    s[i] = list(input())

h_cnt = [[0] * w for _ in range(h)]
w_cnt = [[0] * w for _ in range(h)]

for i in range(h):
    dot_cnt, beg_sec = 0, 0
    for j in range(w):
        if s[i][j] == '#':
            if dot_cnt > 0:
                for k in range(beg_sec, j):
                    w_cnt[i][k] = dot_cnt
                beg_sec = j+1
                dot_cnt = 0
            else:
                w_cnt[i][j] = 0
                beg_sec += 1
        else:
            dot_cnt += 1
    if dot_cnt > 0:
        for k in range(beg_sec, w):
            w_cnt[i][k] = dot_cnt

for i in range(w):
    dot_cnt, beg_sec = 0, 0
    for j in range(h):
        if s[j][i] == '#':
            if dot_cnt > 0:
                for k in range(beg_sec, j):
                    h_cnt[k][i] = dot_cnt
                beg_sec = j+1
                dot_cnt = 0
            else:
                h_cnt[j][i] = 0
                beg_sec += 1
        else:
            dot_cnt += 1
    if dot_cnt > 0:
        for k in range(beg_sec, h):
            h_cnt[k][i] = dot_cnt

ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, h_cnt[i][j] + w_cnt[i][j] - 1)
print(ans)
K, S = map(int, input().split())

count = 0
for x in range(0,K):
    for y in range(0,K):
        a = S-x-y
        if a <= K and a>= 0:
            count += 1
print (count)

### FIXED CODE ###

S = input().split(',')
print (S[0]+' '+S[1]+' '+S[2])
import sys

intMaxValue = sys.maxsize


def problem():
    N = int(input.split())
    activityList = []
    for i in range(N):
      row = list(map(int, input().split()))
      activityList.append(row)

    print(algorithm(N,activityList))

def algorithm(N, activityList):
  dp = [[0, 0, 0] for i in range(N+ 1)]

  for index in range(1, N + 1):
    for j in range(3):
      for k in range(3):
        if j == k:
          continue
        if dp[index][j] < dp[index - 1][k] + activityList[index-1][j]:
          dp[index][j] = dp[index - 1][k] + activityList[index-1][j]
      
  return max(dp[N])


problem()

### FIXED CODE ###


import sys


def problem():
    N = int(input())
    activityList = []
    for i in range(N):
      row = list(map(int, input().split()))
      activityList.append(row)

    print(algorithm(N,activityList))

def algorithm(N, activityList):
  dp = [[0, 0, 0] for i in range(N+ 1)]

  for index in range(1, N + 1):
    for j in range(3):
      for k in range(3):
        if j == k:
          continue
        if dp[index][j] < dp[index - 1][k] + activityList[index-1][j]:
          dp[index][j] = dp[index - 1][k] + activityList[index-1][j]
      
  return max(dp[N])

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

AB = "b" * A + "r" * B

o = N // len(AB) + 1
l = AB * o

print(l[:N].count("b"))


### FIXED CODE ###

N, A, B = map(int, input().split())
ans = 0
amari = N % (A + B)
o = N // (A + B)
if amari > A:
    amari = A

print(amari + A * o)
def pypri(p,y):print(str(p).zfill(6)+str(y).zfill(6))
n,m=map(int,input().split())
a=[[]for _ in range(n)]
b=[]
for i in range(m):
  p,y=map(int,input.split())
  b.append(p-1)
  a[p-1].append([y,len(a[p-1])+1])
for i in range(n):
  a[i].sort()
  for j in range(len(a[i])):
    a[i][j]=[a[i][j][1],j]
    a.sort()
for i in b:
  pypri(i+1,a[i][0][1]+1)
  del a[i][0]

### FIXED CODE ###

n,m = map(int,input().split())
py = []
for i in range(m):
    py.append(list(map(int,input().split())))
    py[i].append(i)
py.sort(key=lambda x:x[1])
py.sort(key=lambda x:x[0])
x = py[0][0]
j=0
for i in range(m):
    if x != py[i][0]:
        j = 1
        x = py[i][0]
    else:
        j+=1
    s = str(py[i][0]).zfill(6) + str(j).zfill(6)
    py[i].append(s)
py.sort(key=lambda x:x[2])
for i in range(m):
    print(py[i][3])