solution
stringlengths 11
983k
| difficulty
int64 0
21
| language
stringclasses 2
values |
---|---|---|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
string s;
cin >> s;
int c = 0;
for (int i = 0; s[i] != '\0'; i++) {
if (s[i] == '8') c++;
}
cout << min(n / 11, c);
return 0;
}
| 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int k = n;
string s;
cin >> s;
int cn = 0;
for (int i = 0; i < n; i++) {
if (s[i] == '8') cn++;
}
int rem = n / 11;
if (rem <= cn)
cout << rem;
else
cout << cn;
return 0;
}
| 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
string s;
while (cin >> n) {
cin >> s;
int cnt8 = 0;
for (int i = 0; i < n; i++)
if (s[i] == '8') cnt8++;
int n8 = n - cnt8;
int ans = min(n / 11, cnt8);
cout << ans << endl;
}
return 0;
}
| 7 | CPP |
a=int(input(""))
digs=[int(i) for i in input("")]
e=0
res=0
for dig in digs:
if dig==8:
e+=1
while e>0 and a>0:
e-=1
if a>10:
a-=11
else : break
res+=1
print(res)
| 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
int n;
string second;
int cnt[1111];
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
cin >> n >> second;
for (int i = 0; i < n; ++i) {
cnt[second[i] - '0']++;
}
int x = cnt[8];
int sum = 0;
for (int i = 0; i <= 9; ++i) {
sum += cnt[i];
}
int ans = 0;
for (int i = 1; i <= x; ++i) {
if ((sum - i) >= 10 * i) ans = i;
}
cout << ans << endl;
}
| 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
int count = 0;
int n;
string s;
cin >> n;
cin >> s;
for (int i = 0; i < n; ++i)
if (s[i] == '8') ++count;
printf("%d\n", min(n / 11, count));
}
| 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
string str;
cin >> str;
int temp = 0;
for (int i = 0; i < n; i++) {
if (str[i] == '8') temp++;
}
int ans = min(n / 11, temp);
cout << ans;
}
| 7 | CPP |
n=int(input())
s=input()
print(min(s.count('8'), (len(s))//11)) | 7 | PYTHON3 |
n=int(input())
s=input()
c=0
for i in range(0,len(s)):
if(s[i]=='8'):
c=c+1
k=len(s)//11
print(min(c,k))
| 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
void swap(char *x, char *y) {
char temp;
temp = *x;
*x = *y;
*y = temp;
}
bool isPalindrome(char str[]) {
long long int l = 0;
long long int h = strlen(str) - 1;
while (h > l) {
if (str[l++] != str[h--]) {
return false;
}
}
return true;
}
long long int anagram(char input[], long long int n) {
long long int cnt = 0;
sort(input, input + n);
do {
cout << input << endl;
if (isPalindrome(input)) cnt++;
} while (next_permutation(input, input + n));
return cnt;
}
long long int permute(char *a, long long int l, long long int r) {
long long int i, cnt = 0;
if (l == r) {
cout << a << endl;
if (isPalindrome(a)) cnt++;
} else {
for (i = l; i <= r; i++) {
swap((a + l), (a + i));
permute(a, l + 1, r);
swap((a + l), (a + i));
}
}
return cnt;
}
int binarySearch(long long int arr[], int l, int r, int x) {
int last = r;
if (r >= l) {
int mid = l + (r - l) / 2;
if (x < arr[mid] && x >= arr[mid - 1]) {
return mid;
}
if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x);
return binarySearch(arr, mid + 1, r, x);
}
return -1;
}
int quadratic(int a, int b, int c) {
int x1, x2, discriminant;
discriminant = b * b - 4 * a * c;
if (discriminant > 0) {
x1 = (-b + sqrt(discriminant)) / (2 * a);
x2 = (-b - sqrt(discriminant)) / (2 * a);
if (x1 > 0)
return x1;
else
return x2;
}
}
void print_arr(unsigned long long int arr[], long long int n) {
long long int i;
for (i = 0; i < n; i++) {
cout << arr[i] << ' ';
}
cout << endl;
}
long long int bsearch(long long int prefixsum[], long long int n,
long long int k) {
long long int ans = -1;
long long int left = 1, right = n;
while (left <= right) {
long long int mid = (left + right) / 2;
long long int i, s = 0, dd;
for (i = mid; i <= n; i++) {
dd = prefixsum[i] - prefixsum[i - mid];
if (dd <= k) {
s = 1;
break;
}
}
if (s) {
left = mid + 1;
ans = max(mid, ans);
s = 0;
} else
right = mid - 1;
}
if (ans == -1) ans++;
return ans;
}
void scn_arr(long long int arr[], long long int n) {
long long int i;
for (i = 0; i < n; i++) {
scanf("%lld", &arr[i]);
}
}
long long int maxSizeBelowK(long long int arr[], long long int n,
long long int k) {
long long int prefixsum[n + 1], i;
memset(prefixsum, 0, sizeof(prefixsum));
for (i = 0; i < n; i++) prefixsum[i + 1] = prefixsum[i] + arr[i];
return bsearch(prefixsum, n, k);
}
long long int GCD(long long int a, long long int b) {
if (b == 0) return a;
return GCD(b, a % b);
}
long long int LCM(long long int a, long long int b) {
return b * a / GCD(a, b);
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
return (a.second < b.second);
}
bool *SieveOfEratosthenes(int n, bool *prime) {
for (int p = 2; p * p <= n; p++) {
if (prime[p] == true) {
for (int i = p * 2; i <= n; i += p) prime[i] = false;
}
}
return prime;
}
bool isPrime(long long int n) {
long long int i, h;
if (n <= 1) return false;
if (n == 2) return true;
if (n % 2 == 0) return false;
h = sqrt(n);
for (i = 3; i <= h; i += 2) {
if (n % i == 0) {
return false;
}
}
return true;
}
void combinationUtil(long long int arr[], long long int n, long long int r,
long long int index, long long int data[],
long long int i) {
if (index == r) {
for (int j = 0; j < r; j++) printf("%d ", data[j]);
printf("\n");
return;
}
if (i >= n) return;
data[index] = arr[i];
combinationUtil(arr, n, r, index + 1, data, i + 1);
combinationUtil(arr, n, r, index, data, i + 1);
}
long long int countBits(long long int number) {
return (long long int)log2(number) + 1;
}
void printCombination(long long int arr[], long long int n, long long int r) {
long long int data[r];
combinationUtil(arr, n, r, 0, data, 0);
}
long long int ASCIIofString(string str) {
long long int sum = 0;
long long int len = str.length();
for (long long int i = 0; i < len; i++) sum += (int)str[i];
return sum;
}
bool isPowerOfTwo(long long int x) { return (x && !(x & (x - 1))); }
int leftRotate(int n, unsigned int d) { return (n << d) | (n >> (7 - d)); }
void leftRotatebyOne(string s, long long int n) {
long long int i;
char temp = s[0];
for (i = 0; i < n - 1; i++) s[i] = s[i + 1];
s[i] = temp;
}
long long int lowestSetBit(long long int num) { return (num & (-num)); }
long long int countSetBits(long long int num) {
long long int cnt = 0;
while (num) {
num &= (num - 1);
cnt++;
}
return cnt;
}
long long int toggleBit(long long int num, long long int pos) {
return num ^ (1 << pos);
}
int _lis(int arr[], int n, int *max_ref) {
if (n == 1) return 1;
int res, max_ending_here = 1;
for (int i = 1; i < n; i++) {
res = _lis(arr, i, max_ref);
if (arr[i - 1] < arr[n - 1] && res + 1 > max_ending_here)
max_ending_here = res + 1;
}
if (*max_ref < max_ending_here) *max_ref = max_ending_here;
return max_ending_here;
}
int lis(int arr[], int n) {
int max = 1;
_lis(arr, n, &max);
return max;
}
int lds(int arr[], int n) {
int lds[n];
int i, j, max = 0;
for (i = 0; i < n; i++) lds[i] = 1;
for (i = 1; i < n; i++)
for (j = 0; j < i; j++)
if (arr[i] < arr[j] && lds[i] < lds[j] + 1) lds[i] = lds[j] + 1;
for (i = 0; i < n; i++)
if (max < lds[i]) max = lds[i];
return max;
}
void factArr(long long int n, unsigned long long int *arr, long long int mod) {
for (long long int i = 0; i <= n; i++) {
if (!i || i == 1)
arr[i] = 1;
else if ((arr[i - 1] * i) % mod == 0)
arr[i] = 1;
else
arr[i] = (arr[i - 1] * i) % mod;
}
}
unsigned long long int fastPow(long long int x, unsigned long long int y,
long long int p) {
long long int res = 1;
x = x % p;
while (y > 0) {
if (y & 1) res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
int main() {
long long int cnt8 = 0, n, i, num;
string nums;
cin >> n;
cin >> nums;
num = n / 11;
for (i = 0; i < n; i++) {
if (nums[i] == '8') cnt8++;
}
if (n < 11 || !cnt8)
cout << "0";
else
cout << min(cnt8, num);
return 0;
}
| 7 | CPP |
def solve(n, s):
n = int(n)
s = list(map(int, s))
l = len(list(filter(lambda r: r==8, s)))
return min(l, len(s)//11)
if __name__=='__main__':
n = int(input())
s = input()
print(solve(n, s)) | 7 | PYTHON3 |
#!/usr/bin/env python3
n = int(input())
s = input()
a = s.count('8')
b = n - a
cnt = 0
while a >= 1 and a + b >= 11:
a -= 1
b -= 10
if b < 0:
a += b
b = 0
cnt += 1
print(cnt)
| 7 | PYTHON3 |
n=int(input())
x=input().count('8')
print(min(x,int(n/11))) | 7 | PYTHON3 |
_ = input()
N = input()
Num = N.count('8')
div = len(N) // 11
print(min(Num, div)) | 7 | PYTHON3 |
n = int(input())
inp = input()
a = 0
for i in range(n):
if inp[i] == "8": a+=1
b = n//11
print(a) if b>a else print(b)
| 7 | PYTHON3 |
n = int(input())
s = input()
e = s.count('8')
a = divmod(n, 11)
if e == 0:
print(0)
else:
print(min(a[0], e))
| 7 | PYTHON3 |
n = int(input())
s = input()
k = 0
d = n // 11
for i in s:
if i == "8": k +=1
print(min(k,d)) | 7 | PYTHON3 |
n=int(input())
s=list(input())
count_8=s.count('8')
total=len(s)
if len(s)<11:
print(0)
elif count_8==0:
print(0)
else:
cnt=0
for i in range(count_8):
s.remove('8')
s=s[::-1]
for i in range(count_8):
s.append('8')
for i in range(count_8):
if s[-1]=='8' and total>=11:
total-=11
cnt+=1
s.pop()
else:
break
print(cnt)
| 7 | PYTHON3 |
n = int(input())
s = input()
eight_cnt = s.count('8')
cnt = len(s) // 11
print(cnt if cnt < eight_cnt else eight_cnt)
| 7 | PYTHON3 |
n=int(input())
s=input()
if '8' in s:
t=int(n/11)
if t<=s.count('8'):
print(int(n/11))
else:
print(s.count('8'))
else:
print(0)
| 7 | PYTHON3 |
# https://codeforces.com/problemset/problem/1060/A
n = int(input())
input = [int(x) for x in input().strip()]
num_8 = len(list(filter(lambda x: x == 8, input)))
max_numbers = n / 11
print(int(min(num_8, max_numbers))) | 7 | PYTHON3 |
n = int(input())
s = input()
cnt8 = 0
for x in s:
if(x == '8'):
cnt8 += 1
print(min(cnt8, n // 11))
| 7 | PYTHON3 |
n = int(input())
a = list(input())
k = 0
if n < 11:
print(0)
exit()
else:
p = 0
for i in range(len(a)):
if a[i] == "8":
p += 1
f = len(a) // 11
print(min(f,p)) | 7 | PYTHON3 |
n = input()
m = input()
counter = 0
for i in range(len(m)):
if m[i] == "8":
counter += 1
c = len(m) // 11
print(min(c, counter)) | 7 | PYTHON3 |
n = int(input())
ai = input().count("8")
print(min(n//11,ai))
| 7 | PYTHON3 |
n=int(input())
ch=input()
print(min(n//11,ch.count('8')))
| 7 | PYTHON3 |
while True:
try:
n = eval(input().strip())
str = input().strip()
counter = 0
for i in str:
if i == '8':
counter += 1
size = len(str)
ans = 0
for i in range(1,counter + 1):
sum = int(10) * int(i)
sum += int(i)
if size >= sum:
ans = max(ans,i)
else:
break
print(ans)
except:
break | 7 | PYTHON3 |
digits = int(input())
phn_number = input()
print(min((digits // 11) , phn_number.count('8')))
| 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
void dance() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
void file() {
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
}
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
template <typename t>
void printV(vector<t> v) {
for (int i = 0; i < v.size(); i++) {
cout << v[i] << ' ';
}
cout << endl;
}
bool isPrime(int n) {
if (n == 2) return true;
if (n < 2 || n % 2 == 0) return false;
for (int i = 3; i * i <= n; i += 2)
if (n % i == 0) return false;
return true;
}
int main() {
dance();
int n;
cin >> n;
string s;
cin >> s;
int e = 0;
for (int i = 0; i < n; i++) {
if (s[i] == '8') e++;
}
cout << min(e, n / 11) << endl;
return 0;
}
| 7 | CPP |
n=int(input())
l=list(input())
print(min(n//11,l.count('8'))) | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e5 + 5;
const long long int M = 1e9 + 7;
queue<pair<long long int, long long int> > pq;
vector<long long int> v;
map<long long int, long long int> mpp;
set<pair<long long int, long long int> > st;
long long int a[N], h[N], indx[N][2];
long long int val[N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
long long int n, l;
cin >> n;
string s;
cin >> s;
long long int a = 0;
long long int b = 0;
for (int i = int(0); i <= int(n - 1); i++) {
if (s[i] == '8') a++;
}
long long int x = n / 11;
if (a < x)
cout << a;
else
cout << x;
}
| 7 | CPP |
x = int(input())
x = x//11
s = input()
a = s.count('8')
b = min(x, a)
print(b) | 7 | PYTHON3 |
N = int(input())
eight_amount = input().count("8")
print(min(N // 11, eight_amount)) | 7 | PYTHON3 |
# 1060A => Phone Numbers
# https://codeforces.com/problemset/problem/1060/A
n = int(input())
s = input()
print(min(s.count("8"), n // 11))
| 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double maxn = 1e10 + 10;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int main() {
int n, sum = 0;
cin >> n;
string s;
cin >> s;
for (int i = 0; i <= n - 1; i++) {
if (s[i] == '8') {
sum++;
}
}
int t = n / 11;
cout << min(t, sum) << endl;
return 0;
}
| 7 | CPP |
n=int(input())
list=input()
x=0
for i in range (len(list)):
if list[i]=='8':
x=x+1
print(min(n//11,x))
| 7 | PYTHON3 |
n=int(input())
s=input()
c1=n//11
c2=0
for i in s:
if(i=='8'):
c2+=1
print(min(c1,c2))
| 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, count = 0;
cin >> n;
string cards;
if (n < 11) {
cout << "0" << endl;
return 0;
} else {
cin >> cards;
for (int i = 0; i < n; i++) {
if (cards[i] == '8') count++;
}
int k = n / 11;
if (count >= k)
cout << k << endl;
else
cout << count << endl;
}
}
| 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
string s;
int b[10];
int main() {
int t, n, i, j;
scanf("%d", &n);
cin >> s;
int c = 0;
for (i = 0; i < n; i++) {
if (s[i] == '8') {
c++;
}
}
if (c == 0) {
printf("0\n");
} else {
printf("%d\n", min(c, n / 11));
}
return 0;
}
| 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
clock_t clk_begin = clock();
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
string s;
cin >> s;
int c = 0;
for (int i = 0; i < n; ++i)
if (s[i] == '8') c++;
n /= 11;
cout << min(n, c) << '\n';
;
cerr << "Time taken: " << (double)(clock() - clk_begin) / CLOCKS_PER_SEC
<< '\n';
return 0;
;
}
| 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int sum = 0;
char s;
for (int i = 0; i < n; i++) {
cin >> s;
if (s == '8') sum++;
}
sum = min(sum, n / 11);
cout << sum << endl;
return 0;
}
| 7 | CPP |
n = int(input())
numbers = input()
eights = numbers.count('8')
print(min(eights, n // 11))
| 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int n, cnt8;
char s[110];
int main() {
cin >> n;
cnt8 = 0;
scanf("%s", s + 1);
for (int i = 1; i <= n; ++i)
if (s[i] == '8') ++cnt8;
int ans = 0;
while (cnt8 > 0 && n >= 11) ++ans, --cnt8, n -= 11;
printf("%d\n", ans);
return 0;
}
| 7 | CPP |
n = int(input())
str = input()
print(int(min(str.count('8'), n/11)))
| 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int n, temp = 0, num = 0;
char x[105];
int main() {
cin >> n;
scanf("%s", &x);
for (int i = 0; i < n; i++) {
if (x[i] == '8') temp++;
}
num = min(n / 11, temp);
cout << num;
return 0;
}
| 7 | CPP |
n=int(input())
r=n//11
b=list(input())
c=b.count('8')
#print(c,r)
if c>=r:
print(r)
if c<r:
print(c) | 7 | PYTHON3 |
n = int(input())
b = input()
ate = b.count("8")
o = n - ate
f = min(ate, o // 10)
r = f
ate -= f
o -= 10 * f
if ate != 0 and ate + o >= 11:
rr = 11 - o
ate -= rr
r += 1
r += ate // 11
print(r)
| 7 | PYTHON3 |
N = int(input())
eight_amount = input().count("8")
if eight_amount == 0:
print(0)
elif N // 11 >= eight_amount:
print(eight_amount)
else:
print(N // 11) | 7 | PYTHON3 |
#-------------Program--------------
#----Kuzlyaev-Nikita-Codeforces----
#-------------Training-------------
#----------------------------------
n=int(input())
a=list(str(input()))
v=a.count("8");r=n-v
answer=0
for i in range(n):
if v==0:
break
if r>=10:
v-=1;r-=10;answer+=1
else:
if v>=(10-r)+1:
v-=11-r
r=0
answer+=1
else:
break
print(answer) | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int n, eight;
string s;
int main() {
ios::sync_with_stdio(false);
cin >> n >> s;
for (char c : s) eight += (c == '8');
cout << min(n / 11, eight) << endl;
}
| 7 | CPP |
n = int(input())
a = list(input())
a = [int(x) for x in a]
print(min(a.count(8), n // 11))
| 7 | PYTHON3 |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "inline", "-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
using namespace std;
int n;
int ans;
string s;
int main() {
cin >> n >> s;
for (auto c : s) ans += c == '8';
cout << min(ans, n / 11) << endl;
}
| 7 | CPP |
n=int(input());m=input();a=m.count('8');k=n//11;print(min(a,k)) | 7 | PYTHON3 |
n=int(input())
s=input()
k=n//11
k1=s.count('8')
print(min(k,k1)) | 7 | PYTHON3 |
n = int(input())
s = input()
output = 0
if s.count('8')>0:
num = s.count('8')
if num*11 <= n:
output = num
else:
output = n//11
print(output)
| 7 | PYTHON3 |
a = int(input())
n = input()
b = n.count('8')
if a // 11 < b:
print(a // 11)
else:
print(b) | 7 | PYTHON3 |
int(input())
s = input()
count = 0
if len(s) < 11 or '8' not in s : print(0)
else:
for i in s:
if i == '8': count += 1
while count > 0:
if (len(s) - count) >= count * 10:
print(count)
break
else: count -= 1
| 7 | PYTHON3 |
T_ON = 0
DEBUG_ON = 0
MOD = 998244353
def solve():
n = read_int()
s = input()
eight = s.count('8')
print(min(eight, n // 11))
def main():
T = read_int() if T_ON else 1
for i in range(T):
solve()
def debug(*xargs):
if DEBUG_ON:
print(*xargs)
from collections import *
import math
#---------------------------------FAST_IO---------------------------------------
import os
import sys
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
#----------------------------------IO_WRAP--------------------------------------
def read_int():
return int(input())
def read_ints():
return list(map(int, input().split()))
def print_nums(nums):
print(" ".join(map(str, nums)))
def YES():
print("YES")
def Yes():
print("Yes")
def NO():
print("NO")
def No():
print("No")
def First():
print("First")
def Second():
print("Second")
#----------------------------------FIB--------------------------------------
def fib(n):
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
return a
def fib_ns(n):
assert n >= 1
f = [0 for _ in range(n + 1)]
f[0] = 0
f[1] = 1
for i in range(2, n + 1):
f[i] = f[i - 1] + f[i - 2]
return f
#----------------------------------MOD--------------------------------------
def gcd(a, b):
if a == 0:
return b
return gcd(b % a, a)
def xgcd(a, b):
"""return (g, x, y) such that a*x + b*y = g = gcd(a, b)"""
x0, x1, y0, y1 = 0, 1, 1, 0
while a != 0:
(q, a), b = divmod(b, a), a
y0, y1 = y1, y0 - q * y1
x0, x1 = x1, x0 - q * x1
return b, x0, y0
def lcm(a, b):
d = gcd(a, b)
return a * b // d
def is_even(x):
return x % 2 == 0
def is_odd(x):
return x % 2 == 1
def modinv(a, m):
"""return x such that (a * x) % m == 1"""
g, x, _ = xgcd(a, m)
if g != 1:
raise Exception('gcd(a, m) != 1')
return x % m
def mod_add(x, y):
x += y
while x >= MOD:
x -= MOD
while x < 0:
x += MOD
return x
def mod_mul(x, y):
return (x * y) % MOD
def mod_pow(x, y):
if y == 0:
return 1
if y % 2:
return mod_mul(x, mod_pow(x, y - 1))
p = mod_pow(x, y // 2)
return mod_mul(p, p)
def mod_inv(y):
return mod_pow(y, MOD - 2)
def mod_div(x, y):
# y^(-1): Fermat little theorem, MOD is a prime
return mod_mul(x, mod_inv(y))
#---------------------------------PRIME---------------------------------------
def is_prime(n):
if n == 1:
return False
for i in range(2, int(n ** 0.5) + 1):
if n % i:
return False
return True
def gen_primes(n):
"""
generate primes of [1..n] using sieve's method
"""
P = [True for _ in range(n + 1)]
P[0] = P[1] = False
for i in range(int(n ** 0.5) + 1):
if P[i]:
for j in range(2 * i, n + 1, i):
P[j] = False
return P
#---------------------------------MAIN---------------------------------------
main()
| 7 | PYTHON3 |
n = int(input())
s = input()
b = 0
for i in range(len(s)):
if(s[i] == "8"):
b += 1
if(b >= (n//11)):
print (n//11)
else:
print (b)
| 7 | PYTHON3 |
import math
n=int(input())
l=str(input())
x=l.count("8")
y=math.floor(n/11)
if x==0 or n<11:
print(0)
elif y>x:
print(x)
else:
print(y)
| 7 | PYTHON3 |
n=int(input())
r=input()
c=0
for i in r:
if i=='8':
c=c+1
print (min(n//11,c)) | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
void cases() {
long long int n;
cin >> n;
string s;
cin >> s;
long long int c = 0;
for (long long int i = 0; i < n; i++) c += (s[i] == '8');
cout << min(c, n / 11);
}
int32_t main() {
std::ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long int tc = 1;
while (tc--) {
cases();
}
}
| 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
const long double pi = 2 * acos(0.0);
template <class T>
bool umin(T& a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <class T>
bool umax(T& a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T, class TT>
bool pal(T a, TT n) {
int k = 0;
for (int i = 0; i <= n / 2; i++) {
if (a[i] != a[n - i - 1]) {
k = 1;
break;
}
}
return k ? 0 : 1;
}
int main() {
int n;
cin >> n;
string s;
cin >> s;
int cnt = 0;
for (int i = 0; i < s.size(); i++) cnt += (s[i] == '8');
cout << min(cnt, n / 11);
getchar();
getchar();
return 0;
}
| 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
char num[200];
int main() {
int n, ans = 0;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> num[i];
if (num[i] == '8') ans++;
}
int sum = min(ans, n / 11);
cout << sum << endl;
}
| 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, count = 0;
cin >> n;
for (int i = 0; i < n; i++) {
char ch;
cin >> ch;
if (ch == '8') count++;
}
if (count == 0)
cout << 0;
else
cout << (count >= n / 11 ? n / 11 : count);
}
| 7 | CPP |
x=int(input())
if(x<11):
y=input()
print(0)
else:
x=x//11
y=input()
Y=len(y)
N=0
for k in range (0,Y):
if(y[k]=="8"):
N+=1
if(N>=x):
print(x)
else:
print(N)
| 7 | PYTHON3 |
'''
Amirhossein Alimirzaei
Telegram : @HajLorenzo
Instagram : amirhossein_alimirzaei
University of Bojnourd
'''
N=int(input())
CART=list(input())
C=0
if "8" not in CART:
print(0)
else:
X=N//11
print(X if CART.count("8")>=X else CART.count("8")) | 7 | PYTHON3 |
n = int(input())
s = input()
print(min(s.count('8'), n // 11))
| 7 | PYTHON3 |
import sys
input=sys.stdin.readline
n=int(input())
s=input()
print(min(s.count('8'),n//11))
| 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, cnt = 0;
string s;
cin >> n >> s;
for (int i = 0; i < s.size(); ++i) {
if (s[i] == '8') ++cnt;
}
cout << min(cnt, n / 11) << endl;
return 0;
}
| 7 | CPP |
n = int(input())
from collections import Counter
s = Counter(input())
digs = 0
eights = None
for i in range(10):
if str(i) == '8':
if str(i) in s:
eights = s[str(i)]
else:
eights = 0
else:
if str(i) in s:
digs += s[str(i)]
ans = 0
for i in range(15):
if i > eights:
break
eightz = i
oth = digs + (eights - i)
ans = max(ans, min(oth//10, eightz))
print(ans)
| 7 | PYTHON3 |
n=int(input())
s=input()
print(min(sum([1 if i == '8' else 0 for i in s]), len(s)//11))
| 7 | PYTHON3 |
n = input()
s = input()
a = 0
for i in s:
a += i == '8'
print(min(a, len(s)//11))
| 7 | PYTHON3 |
n= int(input())
s= input()
count8=0
for i in s:
if i=='8':
count8+=1
if count8==0:
print('0')
else:
print(min(count8, n//11))
| 7 | PYTHON3 |
def find_eights():
sum = 0
for i in range(len(y)):
if y[i] == "8":
sum += 1
return sum
k = int(input())
y = input()
find_e = find_eights()
ll = k // 11
if k < 11 or find_e == 0:
print(0)
exit()
if (find_e >= ll):
print(ll)
else:
print(find_e)
| 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const int N = 111;
char s[N];
int main() {
int n;
scanf("%d %s", &n, s);
int ans = 0;
for (int i = 0; i < n; i++)
if (s[i] == '8') ans++;
ans = min(ans, n / 11);
printf("%d\n", ans);
return 0;
}
| 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int maxi = 1e6 + 10;
int a[maxi];
string s;
int n;
int cnt[maxi];
int main() {
cin >> n;
cin >> s;
for (int i = 0; i < n; i++) cnt[s[i] - '0']++;
int mm = n / 11;
mm = min(mm, cnt[8]);
cout << mm << endl;
return 0;
}
| 7 | CPP |
from math import factorial
from math import floor
n = int(input())
nums = input()
if '8' in nums:
cm = min(floor(n/11), nums.count('8'))
print(cm)
else: print(0)
| 7 | PYTHON3 |
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import random
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def main():
n = I()
c = collections.Counter(S())
return min(n//11, c['8'])
print(main())
| 7 | PYTHON3 |
n = int(input())
s = input()
c = 0
for i in range(s.count('8')):
n -= 11
if n < 0:
break
c += 1
print(c) | 7 | PYTHON3 |
def Str2List(string):
a = [digit for digit in string]
return a
def findEight(List):
a = 0
for d in List:
if d=="8":
a+=1
return a
cards = int(input())
digits = input()
numbers = 0
digits = Str2List(digits)
eights = findEight(digits)
lenofDigits = len(digits)
while lenofDigits >= 11 and eights>=1:
eights -= 1
lenofDigits -= 11
numbers += 1
print(numbers)
| 7 | PYTHON3 |
n = int(input())
s = input()
ans = 0;
for i in s:
if i=='8':
ans+=1
ans = min(ans, n//11);
print(ans)
| 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
int main() {
int n;
string s;
cin >> n >> s;
int cnt = 0;
for (auto i : s) {
if (i == '8') cnt++;
}
int ans = 0;
while (cnt--) {
if (n < 11) break;
ans++;
n -= 11;
}
cout << ans << endl;
return 0;
}
| 7 | CPP |
n = int(input())
s = input()
temp = 0
for i in range(len(s)):
if(s[i]=='8'):
temp+=1
print(min(temp,n//11)) | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cerr.tie(nullptr);
int n;
cin >> n;
string s;
cin >> s;
int a = 0, b = 0;
for (auto& i : s) {
if (i == '8')
++a;
else
++b;
}
int sol = 0;
while (a) {
if (b >= 10) {
b -= 10;
--a;
++sol;
} else {
if (b + a - 1 >= 10) {
a -= (11 - b);
b = 0;
++sol;
} else {
break;
}
}
}
cout << sol << '\n';
}
| 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, check = 0;
cin >> n;
char a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == '8') check++;
}
int k = n / 11;
if (k < check)
cout << k;
else
cout << check;
}
| 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, cnt = 0;
string s;
cin >> n >> s;
for (int i = 0; i < n; i++)
if (s[i] == '8') cnt++;
cout << min(cnt, (n / 11));
return 0;
}
| 7 | CPP |
n = int(input())
a = [int(_) for _ in input()]
num = len([_ for _ in a if _ == 8])
length = len(a)
print(min(length // 11, num))
| 7 | PYTHON3 |
a=int(input())
print(min(a//11,input().count('8')))
#author:SK__Shanto__㋛
#code__define__your__smartness | 7 | PYTHON3 |
n = int(input())
string = input()
cnt = 0
for c in string:
if c == "8":
cnt += 1
print(min(cnt, n // 11))
| 7 | PYTHON3 |
from collections import Counter
def can_make(e, n, x):
return e >= x and (n - x) // 10 >= x
n = int(input())
e = sum(c == '8' for c in input())
ans = 0
while can_make(e, n, ans):
ans += 1
print(ans - 1)
| 7 | PYTHON3 |
def sum(a):
s=0
for i in a:
s=s+i
return s
n=int(input())
a=list(input())
b=['0','1','2','3','4','5','6','7','8','9']
c=[0,0,0,0,0,0,0,0,0,0]
d=dict(zip(b,c))
for i in range(len(a)):
d[a[i]]+=1
e=list(d.values())
z=sum(e)//11
x=e[8]
print(min(x,z)) | 7 | PYTHON3 |
n = int(input())
s = input()
cnt = 0
for i in s:
if i == '8':
cnt += 1
ans = 0
for i in range(0, cnt+1):
if i*11 <= n:
ans = i
else:
break
print(ans)
| 7 | PYTHON3 |
n = int(input())
s=input()
l = [int(x) for x in str(s)]
nc = l.count(8)
c=n//11
if c<=nc:
print(c)
else:
print(nc) | 7 | PYTHON3 |
def phone(n, string):
maximumPhone = n//11
numberEight = string.count('8')
if numberEight == 0:
return 0
elif numberEight >= maximumPhone:
return maximumPhone
else:
return numberEight
if __name__ == "__main__":
n = int(input())
string = input()
print(phone(n, string)) | 7 | PYTHON3 |
n=int(input())
num=str(int(input()))
cnt1=n//11
cnt2=num.count('8')
print(min(cnt1,cnt2))
| 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
string str;
cin >> str;
int i, ans = 0;
for (i = 0; i < t; i++) {
if (str.at(i) == '8') ans++;
}
int k = t / 11;
if (ans > k || ans == k)
cout << k << endl;
else
cout << ans << endl;
return 0;
}
| 7 | CPP |
#include <bits/stdc++.h>
int main() {
int n, count = 0, i, len;
char num[105];
scanf("%d ", &n);
gets(num);
len = strlen(num);
if (n >= 11) {
for (i = 0; i < len; i++) {
if (num[i] == '8') {
n -= 11;
if (n >= 0) {
count++;
continue;
} else
break;
}
}
printf("%d\n", count);
} else
printf("%d\n", 0);
return 0;
}
| 7 | CPP |
n = int(input())
num = input()
print (min( (n// 11) , num.count("8") ))
| 7 | PYTHON3 |
n = int(input())
s = (input())
c = 0
for i in s:
if i=="8":
c=c+1
print(min(c,len(s)//11)) | 7 | PYTHON3 |