Harryxun/stf_run huggingface dataset:
a = int(input())

b = list(map(int,input().split()))
d = max(b)
c = [0 for i in range(pow(10,5)+100)]
cc = [0 for i in range(pow(10,5)+100)]
for i in range(a):
    if i % 2 == 0:
        c[b[i]] += 1
    else:
        cc[b[i]] += 1

one = 0
onee = 0
two = 0
twoo = 0
k = 0
kk = 0
for i in range(len(c)):
    if one <= c[i]:
        onee = one
        one = c[i]
        k = i
    if two <= cc[i]:
        twoo = two
        two = cc[i]
        kk = i

t = max(one+twoo,onee+two)

print(a-one-two)



### FIXED CODE ###

a = list(input())
for i in range(3):
	a[i] = int(a[i])
	if a[i] ==1:
		a[i] = 9
	else:
		a[i] = 1
print(a[0]*100+a[1]*10+a[2])
n=int(input())
l=[0 for i in range(n)]
L=[list(map(int,input().split())) for i in range(n-1)]
ct=0
for i in range(n-1):
  l[L[i][0]-1]+=1
  l[L[i][1]-1]+=1
x=1
for i in range(n):
  if l[i]%2==1 and l[i]>x:
    x=l[i]
xn=l.index(x)
ctx=0
for j in range(n-1):
  if L[j][0]==xn+1:
    if l[L[j][1]-1]%2==1:ctx+=1
  elif L[j][1]==xn+1:
    if l[L[j][0]-1]%2==1:ctx+=1

if ctx%2==1 or x<3:print('First')
else:print('Second')

### FIXED CODE ###

n=int(input())
l=[list(map(int,input().split())) for i in range(n-1)]
connection=[[] for i in range(n)]
for i in range(n-1):
  connection[l[i][0]-1].append(l[i][1]-1)
  connection[l[i][1]-1].append(l[i][0]-1)
 
distance1=[-1 for i in range(n)]
distance1[0]=0
next=connection[0]
next2=[]
check=[-1 for i in range(n)]
check[0]=1
checkct=1
ct=0
while len(next)!=0 and checkct!=n:
  ct+=1
  for i in range(len(next)):
    distance1[next[i]]=ct
    check[next[i]]=1
    checkct+=1
    for j in range(len(connection[next[i]])):
      if check[connection[next[i]][j]]==-1:
        next2.append(connection[next[i]][j])
  next=next2
  next2=[]

x=max(distance1)
x=distance1.index(x)

distance2=[-1 for i in range(n)]
distance2[x]=0
next=connection[x]
next2=[]
check=[-1 for i in range(n)]
check[x]=1
checkct=1
ct=0
while len(next)!=0 and checkct!=n:
  ct+=1
  for i in range(len(next)):
    distance2[next[i]]=ct
    check[next[i]]=1
    checkct+=1
    for j in range(len(connection[next[i]])):
      if check[connection[next[i]][j]]==-1:
        next2.append(connection[next[i]][j])
  next=next2
  next2=[]

if max(distance2)%3==1:
  print('Second')
else:
  print('First')
import sys
sys.setrecursionlimit(10**12+1)

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

def f(a,b) :
    if a < b :
        return 2*a + f(a,b-a)
    elif a > b :
        a,b = b,a
        return 2*a + f(a,b-a)
    else :
        return a

ans = N + f(X,N-X)

print(ans)


### FIXED CODE ###

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

def f(a,b) :
    if a > b :
        a,b = b,a
    if b % a == 0 :
        return 2*(b//a-1)*a + a
    else :
        return 2*(b//a)*a + f(a,b%a)
        
ans = N + f(X,N-X)

print(ans)
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
ii = lambda: int(input())
lmis = lambda: list(mis())
N1097 = 10**9 + 7

def main():
    ii()
    A = lmis()
    l = 1
    for a in A:
        l = lcm(l, a)
    ans = 0
    for a in A:
        ans += l//a
        ans %= N1097
    print(ans)


main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000000)
import math
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#

def main():
    N = ii()
    A = lmis()
    l = 1
    for a in A:
        l = lcm(l, a)
    print(sum(l//a for a in A) % N1097)


main()
# D - Coloring Edges on Tree

n = int(input())
A = []
B = []

# 2次元配列で辺（頂点,遷移先の頂点）を管理する
D = [[] for _ in range(n)]

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

print(max([len(d) for d in D]))

C = {}

def dfs(node, par, col):
    cid = 1
    for chi in D[node]:
        if chi==par:
            continue
        else:
            if cid==col:
                cid += 1
            C[(node, chi)] = cid
            C[(chi, node)] = cid
            dfs(chi, node, cid)
            cid += 1

dfs(0,0,0)

for a, b in zip(A, B):
    print(C[(a,b)])

### FIXED CODE ###

# D - Coloring Edges on Tree
import sys
sys.setrecursionlimit(10**6)

n = int(input())
A = []
B = []

# 2次元配列で辺（頂点,遷移先の頂点）を管理する
D = [[] for _ in range(n)]

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

print(max([len(d) for d in D]))

C = {}

def dfs(node, par, col):
    cid = 1
    for chi in D[node]:
        if chi==par:
            continue
        else:
            if cid==col:
                cid += 1
            C[(node, chi)] = cid
            C[(chi, node)] = cid
            dfs(chi, node, cid)
            cid += 1

dfs(0,0,0)

for a, b in zip(A, B):
    print(C[(a,b)])
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *

def arc079():
    K = int(input())
    k = K//50
    a = [i+k*50 for i in range(50)]
    for i in range(K-k):
        a[i] += 51
    for i in range(50):
        a[i] -= K-k
    print(50)
    print(*a)

arc079()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *

def arc079():
    K = int(input())
    k = K//50
    a = [i+k*50 for i in range(50)]
    for i in range(K%50):
        a[i] += 51
    for i in range(50):
        a[i] -= K-k
    print(50)
    print(*a)

arc079()
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(n):
    if p[i] == i+1:
        p[i], p[i+1] = p[i+1], p[i]
        cnt += 1
print(cnt)

### FIXED CODE ###

n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(n-1):
    if p[i] == i+1:
        p[i], p[i+1] = p[i+1], p[i]
        cnt += 1
if p[-1] == n:
    cnt += 1
print(cnt)
N, Y = map(int, input().split())
for i in (N+1):
  for j in (N+1):
    k = N-i-j
    if (Y == 10000*i + 5000*j + 1000*k and K > 0 ):
      print(i, j, f)
    else: 
      print(-1, -1, -1)

### FIXED CODE ###

n, y = map(int, input().split())
for i in range(n + 1):
  for j in range(n + 1 -i):
    if 10000*i + 5000*j + 1000*(n - i -j) == y:
      print(i, j, n - i -j)
      break
  else:
    continue
  break
else:
  print('-1 -1 -1')
a,op,b = map(input().split())
if op == "+":
    print(int(a) + int(b))
else:
    print(int(a) -int (b))

### FIXED CODE ###

a,op,b = map(str, input().split())
if op == "+":
    print(int(a) + int(b))
else:
    print(int(a) - int(b))
import re
s = input()
if(s.match(r"\d{2}")):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

import re
s = input()
pattern = r"(00|11|22|33|44|55|66|77|88|99)"
if(re.search(pattern, s)):
	print("Bad")
else:
	print("Good")
import math

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

a -= 1
cd = (c * d) // math.gcd(c, d)

a_d_c = a // c
b_d_c = b // c

a_d_d = a // d
b_d_d = b // d

a_d_cd = a // cd
b_d_cd = b // cd

b_d = b_d_c + b_d_d - b_d_cd
a_d = a_d_c + a_d_d - a_d_cd

ans =  b - b_d - a + a_d

print(ans)

### FIXED CODE ###

import fractions as math

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

a -= 1
cd = (c * d) // math.gcd(c, d)

a_d_c = a // c
b_d_c = b // c

a_d_d = a // d
b_d_d = b // d

a_d_cd = a // cd
b_d_cd = b // cd

b_d = b_d_c + b_d_d - b_d_cd
a_d = a_d_c + a_d_d - a_d_cd

ans =  b - b_d - a + a_d

print(ans)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h>
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 2000000;
const int inf = 1000000007;
const ll mod = 1000000007;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
 
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
 
 
 
int n, ans;
int a[2][100005];
 
int main() {
 
cin >> n;
 
rep(i, 2) {
rrep(j, n) {
int tmp;
cin >> tmp;
a[i][j] = a[i][j - 1] + tmp;
}
}
 
rrep(i, n) {
ans = max(ans, a[0][i] + (a[1][n] - a[1][i - 1]));
}
 
cout << ans << endl;
 int heath=4;
return 0;
}

### FIXED CODE ###

#input template
from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
mp = lambda: list(map(int, cin().split()))

def chars(): #function for taking string input as character array since string in python is immutable
    s = cin()
    return(list(s[:len(s) - 1]))

#print list	
def pl(a):	
	for val in a:
		cout(str(val) + ' ')
	cout('\n')
		
#main

n, = mp()
a = mp()
b = mp()

x = sum(b)
ans = a[0] + x
temp = ans
for i in range(1, n):
	temp += a[i] - b[i-1]
	ans = max(ans, temp)
cout(str(ans))
s=input()
K=int(input())

_set=set()

for i in range(len(s)-1):
  for j in range(i+1, len(s)):
    _set.add(s[i:j])

#print(sorted(list(_set)))
print(sorted(list(_set))[K-1])

### FIXED CODE ###

s=input()
K=int(input())

memo=set()
for i in range(len(s)):
  for j in range(1,min(len(s)-i+1,K+1)):
    memo.add(s[i:i+j])
    
memo=list(memo)
memo.sort()
#print(memo)
print(memo[K-1])
S=input()
a=0
for i in range(4):
  if i==='+':
    a+=1
  else:
    a-=1
print(a)
    

### FIXED CODE ###

S=input()
a=0
for i in S:
  if i=='+':
    a+=1
  else:
    a-=1
print(a)
A,B=map(int,input())
if A%3==0 or B%3==0 or (A+B)%3==0:
  print('Possible')
else:
  print('Impossible')

### FIXED CODE ###

A,B=map(int,input().split())
if A%3==0 or B%3==0 or (A+B)%3==0:
  print('Possible')
else:
  print('Impossible')
n,m,x = map(int, input().split())
costs = [list(map(int, input().split())) for _ in range(n)]

'''
n,m,x = [int(i) for i in input().split()]
costs =[]

for i in range(n):
    a = [int(i) for i in input().split()]
    costs.append(a)
'''


INF = 1000000000000000000000000000
ans = INF

for i in range(1<<n):  #n bits all searches
    # 1<<n == 2**n
    c = 0
    sums = [0]*m
    for j in range(n):
        if i>>j & 1: #i>>j %2 == 1  is also fine.
            #apply this candidate. 
            c += costs[j][0]
            for k in range(m):
                sums[k] += costs[j][k+1]    
    '''
    cost = 0
    c = 0
    sums = [0] * m
    use_index=[]
    for j in range(n):
        if i%2==1:
            use_index.append(j)
        i >>= 1
    
    for v in use_index:
        c += costs[v][0]        
        for j in range(m):
            sums[j] += costs[v][j+1]
    '''
    
    #if min(sums) >= x:
    if all(s>=x for x in sums):
        ans = min(ans, c)
'''            
    judge=True
    for j in range(m):
        if sums[j]<x:
            judge=False
            break
    
    if judge:
        ans = min(ans, c)
'''
if ans==INF:
    print(-1)
else:
    print(ans)
 


### FIXED CODE ###

import numpy as np

n,m,x = [int(i) for i in input().split()]
costs =[]
maa = 1000000000000000000000000000
ans = maa

for i in range(n):
    a = [int(i) for i in input().split()]
    costs.append(a)
    
for i in range(1,2**n+1):
    cost = 0
    c = 0
    sums = [0] * m
    use_index=[]
    for j in range(n):
        if i%2==1:
            use_index.append(j)
        i >>= 1
    
    for v in use_index:
        c += costs[v][0]        
        for j in range(m):
            sums[j] += costs[v][j+1]
            
    judge=True
    for j in range(m):
        if sums[j]<x:
            judge=False
            break
    
    if judge:
        ans = min(ans, c)

if ans ==maa:
    print(-1)
else:
    print(ans)
n = int(input())
s = list(input())
ans = [i * 0 for i in range(51)]
if n == 2:
    ans.clear()
    if s[0] == s[1]:
        ans.append(1)
    else:
        ans.append(0)
else:
    for i in range(n-1):
        tmp1 = list(set(s[:i+1]))
        tmp2 = list(set(s[i:]))
        for j in range(len(tmp1)):
            if tmp1[j] in tmp2:
                ans[i] += 1
print(max(ans))


### FIXED CODE ###

n = int(input())
s = list(input())
ans = [i * 0 for i in range(100)]
if n == 2:
    ans.clear()
    if s[0] == s[1]:
        ans.append(1)
    else:
        ans.append(0)
else:
    for i in range(0,n-1):
        tmp1 = list(set(s[:i]))
        tmp2 = list(set(s[i:]))
        for j in range(len(tmp1)):
            if tmp1[j] in tmp2:
                ans[i] += 1
print(max(ans))
import math

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

n = int(input())
t, a = 1, 1
for i in range(n):
    ti, ai = map(int, input().split())
    if ti>=t and ai>=a:
        t, a = ti, ai
    elif ti<t and ai>=a:
        t = ti * math.ceil(t/ti)
        a = ai * math.ceil(t/ti)
    elif ti>=t and ai<a:
        t = ti * math.ceil(a/ai)
        a = ai * math.ceil(a/ai)
    else:
        t_lcm = lcm_base(ti, t)
        a_lcm = lcm_base(ai, a)
        new1 = [t_lcm*math.ceil(a/(t_lcm//ti*ai)), t_lcm//ti*ai*math.ceil(a/(t_lcm//ti*ai))]
        new2 = [a_lcm//ai*ti*math.ceil(t/(a_lcm//ai*ti)), a_lcm*math.ceil(t/(a_lcm//ai*ti))]
        if sum(new1) < sum(new2):
            t, a = new1[0], new1[1]
        else:
            t, a = new2[0], new2[1]
print(t+a)

### FIXED CODE ###

n = int(input())
t_lst, a_lst = [], []
for i in range(n):
    ti, ai = map(int, input().split())
    t_lst.append(ti)
    a_lst.append(ai)

t, a = 1, 1
for i in range(n):
    ti, ai = t_lst[i], a_lst[i]
    n = max((t+ti-1)//ti, (a+ai-1)//ai)
    t = n*ti
    a = n*ai
print(t+a)
def count(b, total, N):
    remain = N%total
    if remain < b:
        return remain
    else:
        return b
      
N, b, r = [int(i) for i in data.split()]

ball = int(N/total) * b + count(b, b+r, N)
print(ball)

### FIXED CODE ###

def count(b, total, N):
  r = N%total
  if r < b:
    return r
  else:
    return b

data = input()
N, b, r = [int(i) for i in data.split()]

total = b + r

ball = int(N/total) * b + count(b, total, N)
print(ball)
N = int(input())

M = [set() for _ in range(N)]

A = [[] for _ in range(N)]
ans = [0] * (N - 1)
for i in range(N - 1):
    a, b = map(int, input().split())
    A[a - 1].append((b - 1, i))
    A[b - 1].append((a - 1, i))

def dfs(x, p, pre):
    cnt = 1
    for a in A[x]:
        if a[0] == pre:
            continue

        if cnt == p:
            cnt += 1
        ans[a[1]] = cnt
        cnt += 1

        dfs(a[0], ans[a[1]], x)

dfs(0, -1, -1)

print(max(ans))
for a in ans:
    print(a)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
N = int(input())

M = [set() for _ in range(N)]

A = [[] for _ in range(N)]
ans = [0] * (N - 1)
for i in range(N - 1):
    a, b = map(int, input().split())
    A[a - 1].append((b - 1, i))
    A[b - 1].append((a - 1, i))

def dfs(x, p, pre):
    cnt = 1
    for a in A[x]:
        if a[0] == pre:
            continue

        if cnt == p:
            cnt += 1
        ans[a[1]] = cnt
        cnt += 1

        dfs(a[0], ans[a[1]], x)

dfs(0, -1, -1)

print(max(ans))
for a in ans:
    print(a)
N,Q = map(int,input().split())
adjacent_list = [[] for _ in range(N+1)]
for _ in range(N-1):
    a,b = map(int,input().split())
    adjacent_list[a].append(b)
cnt = [0]*(N+1)
def dfs(v,x):
    cnt[v] += x
    for nv in adjacent_list[v]:
        dfs(nv,x)

for q in range(Q):
    p,x = map(int,input().split())
    dfs(p,x)
print(*cnt[1:])

### FIXED CODE ###

n,q=map(int,input().split())
ab=[]
for i in range(n-1):
	x,y=map(int,input().split())
	ab.append([x,y])
ab.sort()
ans=[0]*n
cnt=[0]*n
for i in range(q):
	x,y=map(int,input().split())
	ans[x-1]+=y
for i in range(n-1):
	ans[ab[i][1]-1]+=ans[ab[i][0]-1]
print(*ans)
import math
r = float(input())
print '%f %f' % (2*math.pi*r, math.pi*r^2)

### FIXED CODE ###

import math
r = float(input())
print '%f %f' % (math.pi*r*r, 2*math.pi*r)
S = input()
count = 0
answer = "WA"

if S[0] == 'A':
    exception = [0]
    for i in range(2,len(S)-1):
        if S[i] == 'C':
            count += 1

if count == 1:
    C = S.index('C')
    exception.append(C)

if len(exception) > 1:
    for j in range(len(S)):
        if j not in exception and S[j].islower():
            answer = "AC"

print(answer)

### FIXED CODE ###

S = input()
count = 0
exception = [0]
answer = "WA"

if S[0] == 'A' and S[2:-1].count('C') == 1:
    C = S.index('C')
    exception.append(C)

if len(exception) == 2:
    for j in range(len(S)):
        if j not in exception and S[j].islower():
            count += 1

if count == len(S)-2:
    answer = "AC"

print(answer)
v = [int(d) for d in input().split()]
f = []

for e in range(v[0]):
    f.append(input())
re = 0
for d in f:
    re += d.count('AB')
dd = [list(s) for s in f]


b = 0
a = 0
coo= 0

for q in dd:
    if q[0] == 'B':
        b += 1
    if q[-1] == 'A':
        a += 1
        if q[0] == 'B':
            coo += 1

if a > b:
    ss = b
elif a < b:
    ss = a
elif a == b:
    ss == a

if ss == coo:
    if ss == b:
        if ss == a:
            if ss != 0:
                ss -= 1
re = re + ss
print(re)

### FIXED CODE ###


v = [int(d) for d in input().split()]
#f = []

#for e in range(v[0]):
#    f.append(list(input()))

print(v[0]-v[1]+1)
from itertools import accumulate
import sys

def main():
  read = sys.stdin.buffer.read
  N, K, *p = map(int, read().split())
  p = [0] + list(accumulate(p))
  print((max(y - x for x, y in zip(p, p[K:])) + K) / 2)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

def main():
    S,T=input().split()
    A,B=map(int,input().split())
    U=input()
    if S==U:
        A-=1
    else:
        B-=1
    print(A,B)


    return 

if __name__ == '__main__':
    main()
K,S = map(int, input().split())

ans = 0
for i in range(K+1):
    if 0<= S-i <= K:
        ans += (S-i)+1
    elif S-i <= 2K:
        a = (S-i) -K
        ans += (K-a)+1
print(ans)


### FIXED CODE ###

K,S = map(int, input().split())

ans = 0
for i in range(K+1):
    for j in range(K+1):
        z = S-(i+j)
        if 0<= z and z <= K:
            ans += 1
print(ans)
n, m = [int(item) for item in input().split()]
a, b = [], []
for i in range(n):
  a.append(input())
for j in range(m):
  b.append(input())

match_line = 0
for i in range(n):
  for j in range(n-m):
    for k in range(m):
      if a[i+k][j:j+m] == b[k]:
        match_line += 1
        if match_line >= m:
          print("Yes")
          exit()
      else:
        match_line = 0
print("No")

### FIXED CODE ###

n, m = [int(item) for item in input().split()]
a, b = [], []
for i in range(n):
    a.append(input().rstrip())
for i in range(m):
    b.append(input().rstrip())

for i in range(n-m+1):
    for j in range(n-m+1):
        ans = True
        for k in range(m):
            for l in range(m):
                if not a[i+k][j+l] == b[k][l]:
                    ans = False
                    break
        if ans:
            print("Yes")
            exit()
print("No")
Last login: Thu Apr 27 19:24:49 on ttys001
[@toshiki-s ~ 20:56:20]
$cd Desktop/
.DS_Store             Mendeley Desktop.app/ OTHER/                
.localized            NAIST/                Readme.webloc         
[@toshiki-s ~ 20:56:20]
$cd Desktop/NAIST/
.DS_Store       advancedCource/ procon/         
[@toshiki-s ~ 20:56:20]
$cd Desktop/NAIST/procon/
[@toshiki-s ~/Desktop/NAIST/procon 20:56:35]
$vim aoj0118.py 


















# -*- coding:utf-8 -*-
import sys

sys.setrecursionlimit(100000)

def dfs(x, y, sym):
    field[x][y] = '.'
    for dx in range(-1,2):
        if dx==-1 or dx==1:
            nx = x + dx
            ny = y
            if(nx>=0 and nx<N and 0<=ny and ny<M and field[nx][ny]==sym):
                dfs(nx, ny, sym)
        else:
            nx = x 
            for dy in [-1,1]:
                ny = y + dy
                if(nx>=0 and nx<N and 0<=ny and ny<M and field[nx][ny]==sym):
                    dfs(nx, ny, sym)
def solve():
    res = 0
    flg=0 
    for i in range(N):
        for j in range(M):
            if not field[i][j] == '.':
                if field[i][j] == '@':
                    dfs(i, j, '@')
                    res += 1
                elif field[i][j] == '#':
                    dfs(i, j, '#')
                    res += 1
                else:
                    dfs(i, j, '*')
                    res += 1
    print(res)
    

### FIXED CODE ###

# -*- coding:utf-8 -*-
import sys
def dfs(x, y, sym):
	tile[x][y] = "."
	for i in range(len(DX)):
		nx = x + DX[i]
		ny = y + DY[i]
		if (0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym):
			dfs(nx, ny, sym)

def solve():
	res = 0
	for i in range(N):
		for j in range(M):
			sym = tile[i][j]
			if tile[i][j] != ".":
				if tile[i][j] is sym:
					dfs(i, j, sym)
					res += 1
	print(res)

counter=0
DX = [-1,0,1,0]
DY = [0,-1,0,1]
sys.setrecursionlimit(10**7)
while True:
	line = input()
	if " " in line:
		nums = line.split(" ")
		N = int(nums[0])
		M = int(nums[1])
		tile = [[0 for i in range(M)] for j in range(N)]
	else:
		tile[counter-1] = list(line)
	if N is 0 and M is 0:
		break
	counter += 1
	if counter-1 is N:
		solve()
		counter = 0
(N,M) = list(map(int,input().split()))
Aorg = list(map(int,input().split()))

A = Aorg

A.sort(reverse=True)

for m in range(M):
  #print(int(A[0]/2))
  A[0] = int(A[0]/2)
  if A[0]<A[1]:
    A.sort(reverse=True)

print(sum(A))

### FIXED CODE ###

S = input()

if S=='Sunny':
  print('Cloudy')
else:
  if S=='Cloudy':
    print('Rainy')
  else:
    print('Sunny')
a,b,c,d,e,f=map(int,input().split())
q=[[0,0]]
k=0
ans=0
while len(q)>0:
  x,y=q.pop()
  if x!=0 and y/(x+y)>k:
    k=y/(x+y)
    ans=[x,y]
  if x+y+100*a<=f:
    q+=[[x+100*a,y]]
  if x+y+100*b<=f:
    q+=[[x+100*b,y]]
  if y+c<=(x-y)*e/100 and x+y+c<=f:
    q+=[[x+c,y+c]]
  if y+d<=(x-y)*e/100 and x+y+d<=f:
    q+=[[x+d,y+d]]
print(ans[0],ans[1])
    

### FIXED CODE ###

a,b,c,d,e,f=map(int,input().split())
aa=-1
ans=[0,0]
for i in range(0,f+1,a*100):
  for j in range(0,f+1-i,b*100):
    for k in range(0,int(e*(i+j)/100)+1,c):
      for l in range(0,int(e*(i+j)/100)+1-k,d):
        if i+j+k+l>f:
          continue
        if i+j>0 and aa<(k+l)/(i+j+k+l):
          aa=(k+l)/(i+j+k+l)
          ans=[i+j+k+l,k+l]
print(ans[0],ans[1])
h, w = map(int, input().split())
a = []
for i in range(H):
    a.append(list(map(int, input().split())))

ans = []
def operate(i, j, k, l):
    a[i][j] -= 1
    a[k][l] += 1
    ans.append([i+1, j+1, k+1, l+1])

for j in range(0, w):
    for i in range(0, h-1):
        if a[i][j]%2 == 1:
            operate(i, j, i+1, j)
for j in range(0, w-1):
    if a[h-1][j]%2 == 1:
       operate(h-1, j, h-1, j+1)

print(len(ans))
for i in ans:
    print("{} {} {} {}".format(i[0], i[1], i[2], i[3]))

### FIXED CODE ###

h, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]

ans = []
ope = []
def operate(i, j, k, l):
    a[i][j] -= 1
    a[k][l] += 1
    ans.append([i+1, j+1, k+1, l+1])

for j in range(0, w):
    for i in range(0, h-1):
        if a[i][j]%2 == 1:
            operate(i, j, i+1, j)
for j in range(0, w-1):
    if a[h-1][j]%2 == 1:
        operate(h-1, j, h-1, j+1)

print(len(ans))
for i in range(0, len(ans)):
    print(ans[i][0],ans[i][1],ans[i][2],ans[i][3],end="")
    print()