Harryxun/stf_run huggingface dataset:
n = int(input())
c = 0

def count(i):
    h = str(i)
    s = lambda j, k, l: int('{}{}{}'.format(j, k, j))
    if len(set(h)) == 1:
        h = h[0]
        c = 1
        s = h * 1
        while int(s) <= n:
            c += 1
            s = h * c
        return c - 1
    if h[-1] == '0' or s(h[-1], '', h[0]) > n:
        return 0
    d = 1
    while s(h[-1], '0' * d, h[0]) <= n:
        d += 1
    for i in range(10):
        if s(h[-1], i, h[0]) > n:
            break
    return 11 * (d - 1) + 1

s = 0
for i in range(1, n+1):
    c = count(i)
    print(f'{i} = {c}')
    s += c
print(s)


### FIXED CODE ###

n = int(input())
d = {}

for a in range(1, n+1):
    a = str(a)
    f, l = a[0], a[-1]
    if '0' in [f, l]:
        continue
    if (f, l) in d:
        d[(f, l)] += 1
    else:
        d[(f, l)] = 1

ans = 0
for b in range(1, n+1):
    b = str(b)
    f, l = b[-1], b[0]
    if (f, l) in d:
        ans += d[(f, l)]
print(ans)
n= int(input())
ans= ''
trans= {}
for x in range(1, 27):
	trans[x]= chr(x+96)

while n!=0:
	ans= trans[n%26] + ans
	n= n//26
print(ans)

### FIXED CODE ###

n= int(input())
ans= ''
trans= {}
for x in range(1, 27):
	trans[x]= chr(x+96)

while n!=0:
	if n%26==0:
		ans= 'z'+ ans
		n= n//26-1
	else:
		ans= trans[n%26] + ans
		n= n//26
print(ans)
from numpy import*
from itertools import*
n=int(input())
s=input()
t=s.count("#")
r=s.count(".")
 
l=[t,r]
x=[len(list(v))for k,v in groupby(s)if k=="#"]
y=[len(list(v))for k,v in groupby(s)if k=="."]
if len(x)>len(y):
    y=[0]+y
elif len(x)<len(y):
    x=[0]+x
else:
    if s[0]=="#":
        y=[0]+y
        x=x+[0]
    else:
        y=y+[0]
        x=[0]+x
 
x=array([0]+list(accumulate(x)))
y=array(list(accumulate(y[::-1]))[::-1]+[0])
print([min(x+y),t,r]))

### FIXED CODE ###

n=int(input())
s=input()
r=s.count(".")
ans=[r]
for i in s:
    if i=="#":
        r+=1
    else:
        r-=1
    ans.append(r)
print(min(ans))
S = int(input())
A,B = map(int,input().split())
check = false
ans = 0
i = 1
while S <= B:
  ans = S * i
  if A <= ans and B >= ans:
    check = true
    break
if check:
  print('OK')
else:
  print('NG')


### FIXED CODE ###

S = int(input())
A,B = map(int,input().split())
check = False
ans = 0
i = 1
while ans <= B:
  ans = S * i
  if A <= ans and B >= ans:
    check = True
    break
  i += 1
if check:
  print('OK')
else:
  print('NG')
N = int(input())
P,Q = list(map(int,input().split()))
import itertools
L = [list(i) for i in itertools.permutations(range(1, N+1), r=N)]
print(abs(L.index(P) - L.index(Q)))

### FIXED CODE ###

N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
import itertools
L = [list(i) for i in itertools.permutations(range(1, N+1), r=N)]
print(abs(L.index(P) - L.index(Q)))
def actual(s):
    sub_string_list = []

    N = len(s)
    for i in range(N):
        for j in range(N - 1):
            sub_string_list.append(s[i:j])

    set_ACGT = {'A', 'C', 'G', 'T'}
    length_list = []

    for sub_string in sub_string_list:
        if set(sub_string).issubset(set_ACGT):
            length_list.append(len(sub_string))

    return max(length_list)

s = input()
print(actual(s))

### FIXED CODE ###

def generate_substrings(s):
    N = len(s)

    if N == 0:
        return {''}

    if N == 1:
        return {'', s}

    substrings = set()

    for i in range(N):
        for j in range(1, N + 1):
            substrings.add(s[i:j])

    return substrings


def actual(s):
    sub_strings = generate_substrings(s)
    is_agct = lambda string: set(string).issubset({'A', 'G', 'C', 'T'})

    agct_length_list = [len(s) for s in sub_strings if is_agct(s)]

    return max(agct_length_list)

s = input()
print(actual(s))
from collections import defaultdict
length, types = map(int, input().split(" "))
match = [n for n in input().split(" ")]
cost = defaultdict(int)
cost.update({"1":2, "2":5, "3":5, "4":4, "5":5, "6":6, "7":3, "8":7, "9":6})

dp = ["" for n in range(length + 1)]

def compare_str(a, b):
    if a == "":
        return b
    elif len(a) == len(b):
        return a if a > b else b
    elif len(a) > len(b):
        return a
    return b
        

for m in match:
    dp[cost[m]] = m

for i in range(length):
    # print(dp, i)
    if dp[i]:
        for m in match:
            if i + cost[m] <= length:
                dp[i + cost[m]] = compare_str(dp[i + cost[m]], dp[i] + m)
print(dp[length])

### FIXED CODE ###

from collections import defaultdict
length, types = map(int, input().split(" "))
match = [n for n in input().split(" ")]
cost = {}
cost.update({"1":2, "2":5, "3":5, "4":4, "5":5, "6":6, "7":3, "8":7, "9":6})

dp = ["-" for n in range(10010)]

def compare_str(a, b):
    if a == "":
        return b
    elif len(a) == len(b):
        return a if a > b else b
    elif len(a) > len(b):
        return a
    return b
    
# for m in match:
#     dp[cost[m]] = m
dp[0] = ""
for i in range(length + 1):
    # print(dp, i)
    if dp[i] != "-":
        for m in match:
            # if i + cost[m] <= length:
            dp[i + cost[m]] = compare_str(dp[i + cost[m]], dp[i] + m)
print(dp[length])
N,K = [int(i) for i in input().split()]
n = [int(i) for i in input().split()]
max=0
idx=0
for i in range(N-K+1):
    tmp = sum(n[i:i+K]) 
    if tmp  > max:
        max=tmp 
        idx=i

tmp=0
for i in range(K):
    tmp += sum(range(1,d[i]+1))/d[i]
print(tmp)

### FIXED CODE ###

import numpy as np

N,K = [int(i) for i in input().split()]
n = np.array([int(i) for i in input().split()])
n=(n+1)
t=np.empty(N+1)
t[0] = 0
t[1:]=np.cumsum(n)
print(max(t[K:]-t[:-K])*0.5)
N=int(inpput())
H=list(map(int,input().split()))
ct=0
for i in range(N):
  t=H[i]
  for j in range(i+1,N):
    if H[j]==0:
      break
    H[j]=max(H[j]-t,0)
  ct+=t
print(ct)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

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


def need(L):
    if L == [] or max(L) == 0:
        return 0
    if min(L) > 0:
        l = [L[i]-1 for i in range(len(L))]
        return need(l)+1
    else:
        i = L.index(0)
        l = L[:i]
        m = L[i+1:]
        return need(l)+need(m)


print(need(H))
a = list(input())
ans = []
for b in a:
    if  b == "0":
        ans.append("0")
    elif b == "1":
        ans.append("1")
    else:
        ans.pop()
print("".join(ans))

### FIXED CODE ###

a = list(input())
ans = []
for b in a:
    if  b == "0":
        ans.append("0")
    elif b == "1":
        ans.append("1")
    elif len(ans) != 0:
        ans.pop()
print("".join(ans))
N, P = map(int, input().split())

if N == 1:
    print(P)
else:
    prime = [0] * (10**6+1)
    index = 2
    tmp = 0
    while P > 1:
        if P % index == 0:
            tmp += 1
            P //= index
            if P == 1:
                prime[index] = tmp
        else:
            prime[index] = tmp
            tmp = 0
            if index == 2:
                index += 1
            else:
                index += 2
    
    
    if prime[2] >= N:
        ans = 2 ** (prime[2]//N)
    else:
        ans = 1
    for i in range(3, 10**6+1, 2):
        ans *= max(1, i ** (prime[i]//N))
    
    print(ans)

### FIXED CODE ###

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

if N == 1:
    print(P)
else:
    prime = [0] * (10**6+1)
    index = 2
    tmp = 0
    while P > 1 and index < 10**6+1:
        if P % index == 0:
            tmp += 1
            P //= index
            if P == 1:
                prime[index] = tmp
        else:
            prime[index] = tmp
            tmp = 0
            if index == 2:
                index += 1
            else:
                index += 2
    
    
    if prime[2] >= N:
        ans = 2 ** (prime[2]//N)
    else:
        ans = 1
    for i in range(3, 10**6+1, 2):
        ans *= max(1, i ** (prime[i]//N))
    
    print(ans)
N,M=map(int,input().split())

pn_num=0
WA_list=[0]*N
AC_list=[0]*N

for _ in range(M):
    pi,Si=input().split()
    pi=int(pi-1)
        
    if Si=='AC':
        pn_num+=WA_list[pi-1]
    
    else:
        WA_list[pi-1]+=1
    
print(sum(AC_list),pn_num)

### FIXED CODE ###

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

pn_num=0
WA_list=[0]*N
AC_list=[0]*N

for _ in range(M):
    pi,Si=input().split()
    pi=int(pi)
        
    if Si=='AC':
        if AC_list[pi-1]==0:
            pn_num+=WA_list[pi-1]
            AC_list[pi-1]=1
    
    else:
        WA_list[pi-1]+=1
    
print(sum(AC_list),pn_num)
S = str（input())

ans = 'Good'

for i in range(3):
  if S[i] == S[i+1]:
    ans = 'Bad'
    break
    
    print(ans)

### FIXED CODE ###

s = input()
if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:
  print("Bad")
else:
  print("Good")
#include <stdio.h>
#include <string.h>

int main(void){
    char s[1000];
    char t[1000];
    scanf("%s",s);
    scanf("%s",t);
    int m[strlen(s)];
    for(int i = 0; i < strlen(s); i++){
        m[i] = 0;
    }
    for(int i = 0; i < strlen(s); i++){
        for(int j = 0; j < strlen(t); j++){
            if(s[i] == t[j] && i>=j && strlen(s)-i>=strlen(t)-j){
                for(int k = j; k < strlen(s); k++){
                    if(s[i+k-j] == t[k]){
                        m[i]++;
                    }
                    else{
                        break;
                    }
                }
            }
        }
    }
    int max = 0;
    for(int i = 0; i < strlen(t); i++){
        if(max < m[i]){
            max = m[i];
        }
    }
    printf("%d",strlen(t)-max);
    return 0;
}

### FIXED CODE ###

s = input()
t = input()
ans = 0
for i in range(len(s)-len(t)+1):
    m = 0
    for j, k in zip(s[i:],t):
        if j==k:
            m += 1
    if m > ans:
        ans = m
print(len(t) - ans)
S = input()
N = len(S)
c
ount = 0
for i in range(N):
    for j in range(i,N):
        if int(S[i:j+1]) % 2019 == 0:
            count = count + 1
        else:
            continue
print(count)

### FIXED CODE ###

S = input()[::-1]
N = len(S)
l = [0]*2019
l[0] = 1
n = 0
d = 1

for i in range(N):
    n += int(S[i]) * d
    r = n % 2019
    l[r] += 1
    d = 10*d % 2019
    
out = 0    
for m in l:
    out += (m*(m-1))//2 
print(out)
p,q,r = map(int, raw_input().split())


Print(p+q+r-max(p, q, r))

### FIXED CODE ###

p,q,r=map(int,input().split())
print(p+q+r-max(p,q,r))
def shuffle(text, n):
    return text[n+1:] + text[:n]

while True:
    sent = input()
    if sent == '-': break
    m = int(input())
    hs = [int(input()) for i in range(m)]

    for h in hs:
        sent = shuffle(sent)

    print(sent)


### FIXED CODE ###

#! python3
# shuffle.py

def shuffle(text, n):
    return text[n:] + text[:n]

while True:
    sent = input()
    if sent == '-': break
    m = int(input())

    h = 0
    for i in range(m):
        h += int(input())
    h = h % len(sent)

    sent = shuffle(sent, h)
    print(sent)
from itertools import*
from numpy import*
n,k=map(int,input().split())
k2=k+1
s=input()
if len(s)==1:
    if s=="1":
        print(1)
    else:
        print(0)
    exit()
x=[len(list(v))for k,v in groupby(s)if k=="0"]
y=[len(list(v))for k,v in groupby(s)if k=="1"]
x1=array(x[:-k])
x2=array(x[k:])
x3=sum(x[:k])
t=x3+cumsum(x2-x1)
y1=array(y[:-k2])
y2=array(y[k2:])
y3=sum(y[:k2])
f=y3+cumsum(y2-y1)
print(max(max(t+f),x3+y3))

### FIXED CODE ###

from itertools import*
from numpy import*
n,k=map(int,input().split())
k=2*k+1
s=input()
x=[0]*(s[0]=="0")+[len(list(v))for k,v in groupby(s)]+[0]*(s[-1]=="0")
#print(x)
x1=array(x[k:])
x2=array(x[:-k])
x3=sum(x[:k])
y=[x3]+list(x3+cumsum(x1-x2))
print(max(y[::2]))
import functools

n, k = map(int, input().split())
s = input()

before = s[0]
count = 1
lst = []
head = True if before == '1' else False
tail = True if s[-1] == '1' else False

for i in s[1:]:
    if i == before:
        count += 1
    else:
        lst.append(count)
        count = 1
        before = i
lst.append(count)

S = 0

lst1 = lst
if not head:
    S = sum(lst1[:2*k])
    lst1 = lst1[1:]
if not tail:
    S = max(S, sum(lst1[-2*k:]))
    lst1 = lst1[:-1]

lst1.insert(0,0)
accum_lst = list(itertools.accumulate(lst1))

#print('accum_lst :', accum_lst)
N = len(lst1)
if N <= 2*k + 1:
    S = max(S, accum_lst[-1])
else:
    K = 2*k+1
    for i in range(0, N-K, 2):
        S = max(S, accum_lst[i+K] - accum_lst[i])
        #print(S, accum_lst[i+K], accum_lst[i])

print(S)

### FIXED CODE ###

import itertools

n, k = map(int, input().split())
s = input()

before = s[0]
count = 1
lst = []
head = True if before == '1' else False
tail = True if s[-1] == '1' else False

for i in s[1:]:
    if i == before:
        count += 1
    else:
        lst.append(count)
        count = 1
        before = i
lst.append(count)

S = 0

lst1 = lst
if not head:
    S = sum(lst1[:2*k])
    lst1 = lst1[1:]
if not tail:
    S = max(S, sum(lst1[-2*k:]))
    lst1 = lst1[:-1]

lst1.insert(0,0)
accum_lst = list(itertools.accumulate(lst1))

#print('accum_lst :', accum_lst)
N = len(lst1)
if N <= 2*k + 1:
    S = max(S, accum_lst[-1])
else:
    K = 2*k+1
    for i in range(0, N-K, 2):
        S = max(S, accum_lst[i+K] - accum_lst[i])
        #print(S, accum_lst[i+K], accum_lst[i])

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

p1 = (n[0] + n[1]j)
p2 = (n[2] + n[3]j)

p3 = (p1 - p2) * j + p2
p4 = p3 + (p1 - p2)

print(real(p3),img(p3),real(p4)img(p4))

### FIXED CODE ###

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

p1 = (int(n[0]) + int(n[1]) * 1j)
p2 = (int(n[2]) + int(n[3]) * 1j)

p3 = (p2 - p1) * 1j + p2
p4 = p3 + (p1 - p2)

print(int(p3.real), int(p3.imag), int(p4.real), int(p4.imag))
A,B,C=int(input()),int(input()),int(input())
if (A-B)>=C:
    print(0)
else:
    print(C-(A-B))

### FIXED CODE ###

A,B,C=map(int,input().split())
if (A-B)>=C:
    print(0)
else:
    ans=C-A+B
    print(ans)
x = raw_input("x = ")
print x ** 3

### FIXED CODE ###

#!/usr/bin/env python

# coding: utf-8


if __name__ == '__main__':
    x = int(raw_input())
    print x ** 3
# -*- coding: utf-8 -*-

r, g, b, n = map(int, input().split())

count = 0

for i in range(n//r+1):
    for j in range((n-i*r)//g+1):
        if (n - i*r - j*g) % b == 0:
            count += 1

# やってはいけないやつ
# for i in range(0, n+1):
#     for j in range(0, n+1):
#         for k in range(0, n+1):
#             if r*i + g*j + b*k == n:
#                 count += 1

print(count)


### FIXED CODE ###

# -*- coding: utf-8 -*-

n, k = map(int, input().split())

print(n-k+1)
n = int(input())
v = list(map(int, input().split()))

even = {}
odd = {}

for i in range(n):
    if i % 2 == 0:
        if v[i] not in even:
            even[v[i]] = 0
        even[v[i]] += 1
    else:
        if v[i] not in odd:
            odd[v[i]] = 0
        odd[v[i]] += 1

even_sorted = sorted(even.items(), key=lambda x:x[1])[::-1]
odd_sorted = sorted(odd.items(), key=lambda x:x[1])[::-1]

ans = 0
if even_sorted[0][0] != odd_sorted[0][0]:
    ans += n - even_sorted[0][1] - odd_sorted[0][1]
else:
    x = n - even_sorted[0][1] - odd_sorted[1][1]
    y = n - even_sorted[1][1] - odd_sorted[0][1]
    ans += min(x, y)

print(ans)

### FIXED CODE ###

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

even = {}
odd = {}

for i in range(n):
    if i % 2 == 0:
        if v[i] not in even:
            even[v[i]] = 0
        even[v[i]] += 1
    else:
        if v[i] not in odd:
            odd[v[i]] = 0
        odd[v[i]] += 1

even_sorted = sorted(even.items(), key=lambda x:x[1])[::-1]
odd_sorted = sorted(odd.items(), key=lambda x:x[1])[::-1]

ans = 0
if even_sorted[0][0] != odd_sorted[0][0]:
    ans += n - even_sorted[0][1] - odd_sorted[0][1]
else:
    if len(even_sorted) == 1 or len(odd_sorted) == 1:
        even_sorted.append((-1, 0))
        odd_sorted.append((-1, 0))
    x = n - even_sorted[0][1] - odd_sorted[1][1]
    y = n - even_sorted[1][1] - odd_sorted[0][1]
    ans += min(x, y)

print(ans)
import collections

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
ans = N
pq = []

for i in range(N):
  for j in range(N):
    pq.append((xy[j][0]-xy[i][0], xy[j][1]-xy[i][1]))
c = collections.Counter(pq)
if c.most_common()[0][0] == (0,0):
  ans -= c.most_common()[1][1]
else:
  ans -= c.most_common()[0][1]
print(ans)

### FIXED CODE ###

import collections

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
ans = N
if N == 1:
  print(1)
  exit()
pq = []

for i in range(N):
  for j in range(N):
    pq.append((xy[j][0]-xy[i][0], xy[j][1]-xy[i][1]))
c = collections.Counter(pq)
if c.most_common()[0][0] == (0,0):
  ans -= c.most_common()[1][1]
else:
  ans -= c.most_common()[0][1]
print(ans)
# -*- coding:utf-8 -*-
import sys
sys.setrecursionlimit(100000000)

def dfs(x, y, sym):
	tile[x][y] = '.'
	for i in range(len(DX)):
		nx = x + DX[i]
		ny = y + DY[i]
		if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym:
			dfs(nx, ny, sym)

def solve():
	res = 0
	for i in range(N):
		for j in range(M):
			if not tile[i][j] == '.':
				if tile[i][j] == '@':
					dfs(i, j, '@')
					res += 1
				elif tile[i][j] == '#':
					dfs(i, j, '#')
					res += 1
				elif tile[i][j] == '*':
					dfs(i, j, '*')
					res += 1
	return res
	
res=0	
counter=0
DX = [-1, 0, 1, 0]
DY = [0, -1, 0, 1]
while True:
	counter+=1
	line = input()
	if ' ' in line:
		nums = line.split(' ')
		N = int(nums[0])
		M = int(nums[1])
		tile = [[0 for i in range(N)]for j in range(M)]
		if N==0 and M==0:
			break
	else:
		tile[counter-2] = list(line)
	if (counter-1)==M:
		res = solve()
		counter = 0
		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
import sys
import collections
input = lambda: sys.stdin.readline().rstrip("\r\n")

class DFS:

    def __init__(self):
        self.adj = collections.defaultdict(list)
        self.ans = []

    def addEdge(self, u, v):
        self.adj[u].append(v)
        self.adj[v].append(u)

    def dfs_helper(self, src, visited):
        self.ans.append(src)
        visited[src] = True
        for i in self.adj[src]:
            if not visited[i]:
                self.dfs_helper(i, visited)

    def dfs(self, src):
        res = []
        visited = collections.defaultdict(lambda: False)
        for k, v in self.adj.items():
            visited[k] = False
        for k, v in self.adj.items():
            if not visited[k]:
                self.dfs_helper(k, visited)
                res.append(self.ans)
                self.ans = []
        return res


def solve():
    d = DFS()
    n, m = map(int, input().split())
    if m != 0:
        for _ in range(m):
            u, v = map(int, input().split())
            d.addEdge(u, v)
        ans = d.dfs(1)
        print(len(max(ans, key=lambda i: len(i))))
    else:
        print(1)

solve()


### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip('\r\n')

class DSU(object):
    
    def __init__(self, n):
        self.parent = [i for i in range(n)]
        self.rank = [1] * n
        self.cycle = False

    def find(self, key):
        if self.parent[key] != key:
            self.parent[key] = self.find(self.parent[key])
        return self.parent[key]

    def union(self, a, b):
        s1, s2 = self.find(a), self.find(b)
        if s1 != s2:
            if self.rank[s1] < self.rank[s2]:
                self.parent[s1] = s2
                self.rank[s2] += self.rank[s1]
            else:
                self.parent[s2] = s1
                self.rank[s1] += self.rank[s2]
        else:
            self.cycle = True
        
    def has_cycle(self):
        return self.cycle
    
    def show_parent(self):
        return self.parent

    def show_rank(self):
        return self.rank

def solve():
    n, m = map(int, input().split())
    d = DSU(n + 1)
    if m > 0:
        for _ in range(m):
            a, b = map(int, input().split())
            d.union(a, b)
        # print(d.show_parent())
        print(max(d.show_rank()))
    else:
        print(1)

solve()
import math
A, B, H, M = map(int, open(0).split())


arg_b = math.pi * float(M) / 30
arg_a = (math.pi / 6) * (float(H) + float(M)/60) 
K = abs(arg_b - arg_a)
C = math.sqrt(A*A+B*B - 2*A*B*math.cos(K))
print(C)


### FIXED CODE ###

import math
A, B, H, M = map(int, input().split())


arg_b = math.pi * float(M) / 30
arg_a = (math.pi / 6) * (float(H) + float(M)/60) 
K = abs(arg_b - arg_a)
C = math.sqrt(A*A+B*B - 2*A*B*math.cos(K))
print(C)
s = list(input())
k = int(input())

ans = 0

for i in range(len(s)-1):
    if s[i] == 0:
        pass
    elif s[i] == s[i+1]:
        s[i+1] = 0
        ans += 1
ans2 = 0
if s[0] == s[-1]:
    ans2 = 1
    s[-1] = 0
if len(s) == 1:
    print(k//2)
else:
    print(ans*k + ans2*(k-1))


### FIXED CODE ###

h,w,a,b = map(int,input().split())
for i in range(h):
    if i < b:
        print("".join(["0"]*a+["1"]*(w-a)))
    else:
        print("".join(["1"]*a+["0"]*(w-a)))
n = int(input())
a = list(map(int, input().split()))
cnt = 0
flag = True

while flag:
    ans = []
    for i in a:
        if i%2 == 1:
            flag = False
            break
        else:
            ans.append(i/2)
    if len(ans) == n:
        cnt += 1
        a = ans

print(cnt)

### FIXED CODE ###

a = str(input())
print(a.count('1'))
N = int(input())
S = input()
S = S[::-1]

cnt = 0

for i in range(1,N-1):
    for j in range(i+1,N):
        k = 2*j-i
        if S[i-1]==S[j-1] or S[i-1]==S[k-1] or S[j-1]==S[k-1] :
            cnt += 1


print(N-cnt)

### FIXED CODE ###



N = int(input())
S = input()
S = S[::-1]

cnt = S.count('B')*S.count('G')*S.count('R')

for i in range(N-2):
    for j in range(i,N-1):
        k = 2*j-i
        if  k<=N-1:
            if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k] :
                cnt -= 1


print(cnt)
s=input()
t=input()
print(sum(1 for i in range(len(s)) if s[i] == t[i] else 0))

### FIXED CODE ###

s=input()
t=input()
print(sum(1 for i in range(len(s)) if s[i] == t[i]))
a,b = map(int,raw.input().split())
if a + b == 15:
    print("+")
elif a * b  == 15:
    print("*")
else:
    print("x")

### FIXED CODE ###

a,b = map(int,raw_input().split())
if a + b == 15:
    print("+")
elif a * b  == 15:
    print("*")
else:
    print("x")
n=int(input())
l=[]
for i in range(n):
    l.append(int(input()))
a=l.sorted(reverse=True)
for v in l:
    if v==a[0]:
        print(a[1])
    else:
        print(a[0])


### FIXED CODE ###

n=int(input())
l=[]
for i in range(n):
    l.append(int(input()))
a=sorted(l)
a.reverse()
for v in l:
    if v==a[0]:
        print(a[1])
    else:
        print(a[0])
a = int(input())
b = iny(input())
h = int(input())

print((a + b)*h/2)

### FIXED CODE ###

a = int(input())
b = int(input())
h = int(input())

print(int((a + b) * h / 2))
n,m=map(int,input().split())
s_c=[list(map(str,input().split())) for _ in range(m)]

ans=["0"]*n
for i in s_c:
    ans[int(i[0])-1]=i[1]

if m>1:
    for i in range(m-1):
        for k in range(i+1,m):
            if s_c[i][0]==s_c[k][0] and s_c[i][1]!=s_c[k][1]:
                ans = -1
                break

if n>1:
    if ["1","0"] in s_c:
        ans = -1
    if ans[0]=="0":
        ans=-1

print(int("".join(ans)) if ans != -1 else -1)

### FIXED CODE ###

n,m=map(int,input().split())
sc=[list(map(int,input().split())) for _ in range(m)]
ans=-1
for i in range(10**3):
    if (len(str(i))==n):
        flag=1
        for s,c in sc:
            if str(i)[s-1] != str(c):
                flag=0
        if flag==1:
            ans =i
            break
print(ans)