Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
inp=input() cnt=0 for i in list(inp): if i in ["4","7"]: cnt=cnt+1 if(cnt==4 or cnt==7): print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
def islucky(n): s = str(n) for char in s: if char not in ['4','7']: return False return True m = input() if islucky(len([char for char in m if char in ['4','7']])): print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
from Queue import * # Queue, LifoQueue, PriorityQueue from bisect import * #bisect, insort from datetime import * from collections import * #deque, Counter,OrderedDict,defaultdict #set([]) import calendar import heapq import math import copy import itertools import string myread = lambda : map(int,raw_input().split()...
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
a=input() a=str(a) count_four=a.count('4') count_seven=a.count('7') if (count_four+count_seven)==4: print('YES') elif (count_four+count_seven)==7: print('YES') elif (count_four+count_seven)==47: print('YES') elif (count_four+count_seven)==74: print('YES') elif (count_four+count_seven)==744 or (count_fo...
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=input() count=0 for i in n: if (i=='7' or i=='4'): count+=1 if (count==7 or count==4): print ('YES') else: print ('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
d=raw_input() check=0 result='' for i in range(0,len(d)): if (d[i:i+1]=='7')|(d[i:i+1]=='4'): check=check+1 if (check==7)|(check==4): result="YES" if (check!=7)&(check!=4): result="NO" print(result)
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = int(input()) n = str(n) c,c1 = 0,0 c = n.count('4') + n.count('7') while c!=0: if (c%10==4 or c%10==7): c1+=1 c = int(c/10) if (c1==len(str(c))): print ('YES') else: print ('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
number = input() s=0 for x in range(len(number)): if number[x] in"47": s+=1 if str(s) in "47": print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s = input() slen = len(s) count=0 for i in range(slen): if(s[i]=='7' or s[i]=='4'): count+=1 if(count==4 or count==7): print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
def main(): luckyNum = {'4', '7', '44', '47', '74', '77', '444', '777', '447', '474', '744', '477', '774', '747'} n = list(input()) count = 0 for i in range(len(n)): if n[i] == '4' or n[i] == '7': count += 1 if str(count) in luckyNum: print("YES") else: print(...
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; long long len = s.length(); long long count = 0; for (int i = 0; i < len; i++) { if (s[i] == '7' || s[i] == '4') { count++; } } if (count == 4 || count == 7) { cout << "YES" << endl; } else { cout << "NO...
CPP
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
def nearly_lucky_number(): number = str(input()) lucky_digits = [i for i in number if (int(i) == 7 or int(i) == 4)] n_lucky = len(lucky_digits) if n_lucky == 7 or n_lucky == 4: print ('YES') else: print ('NO') if __name__ == '__main__': nearly_lucky_number()
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
str_number = raw_input() count = str_number.count("4") + str_number.count("7") if count != 0: count_str = str(count) if len(count_str) == count_str.count("4") + count_str.count("7"): print "YES" else: print "NO" else: print "NO"
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
from collections import Counter def lucky(): n = list(input().strip()) c = Counter(n) count = c['4'] + c['7'] if count == 4 or count == 7: return "YES" return "NO" print(lucky())
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
import itertools number = input() def is_nearly_lucky(n): lucky_digits = number.count("4") + number.count("7") for i in range(1, lucky_digits): combination_of_len_i = [''.join(x) for x in itertools.product('47', repeat=i)] if str(lucky_digits) in combination_of_len_i: return "YES...
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
number = input() numList = list(number) count = 0 for i in numList: if i == '4' or i == '7': count += 1 if count == 4 or count == 7: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
def is_lucky(): number = [int(i) for i in input()] n = 0 for i in number: if i == 4 or i == 7: n+=1 magic_numbers = [i for i in str(n)] for i in magic_numbers: if i != '4' and i != '7': return False return True if is_lucky(): print("YES") else: p...
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=int(input()) c=0 while n>1: if n%10==4: c=c+1 elif n%10==7: c=c+1 n=n//10 if c==4 or c==7: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
a = input() cnt = 0 for i in a: if i == '7' or i == '4': cnt+=1 if cnt == 7 or cnt == 4: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = input() digit_count = n.count('4') + n.count('7') digit_count = str(digit_count) if digit_count.count('4') != 0 or digit_count.count('7') != 0: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s = input() cnt = 0 for i in range(len(s)): if s[i] == '4' or s[i] == '7': cnt += 1 if cnt == 4 or cnt == 7: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
from collections import Counter n=input() counts=Counter(n) num=counts["4"]+counts["7"] if num==4 or num==7: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s = input() counter = 0 for i in s : if i == '4' or i=='7': counter+=1 stringCounter = str(counter) flag=True for i in stringCounter: if i!='4' and i!='7': flag= False break; if flag: print('YES') else :print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
cnt = 0 for n in input(): if n == '4' or n == '7': cnt += 1 cnt = str(cnt) for n in cnt: if n != '4' and n != '7': print('NO') break else:print('YES')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
x = raw_input() nearlyLucky = True counter = 0 for i in x: if i == '4' or i == '7': counter += 1 counter = str(counter) for i in counter: if i != '4' and i != '7': nearlyLucky = False print "NO" break if nearlyLucky == True: print "YES"
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
import java.util.*; import java.util.stream.IntStream; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); long n = in.nextLong(); String str = String.valueOf(n); int count = 0 ; for(long i = 0 ; i < str.leng...
JAVA
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=int(input()) l=[] while n!=0: r=n%10 l.append(r) n=n//10 f=l.count(4) s=l.count(7) m=f+s if m>7: print("NO") elif m==4 or m==7: print("YES") elif m>4: print("NO") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
number = int(input()) snumber = str(number) x = 1 totL = 0 for i in snumber: if int(i) == 4 or int(i) == 7: totL = totL + 1 stotL = str(totL) for i in stotL: if int(i) != 4 and int(i) != 7 : x = 2 if x == 1: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
import java.util.*;import java.io.*;import java.math.*; public class Main { public static void process()throws IOException { long n = nl(); long sum = 0;int s = 0;int c = 0; while(n>0) { if(n%10==4 || n%10==7) { ...
JAVA
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=int(input()) s=0 while n>0: if n%10==7 or n%10==4: s+=1 n=n//10 if s==7 or s==4: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = input() n = n.replace("1","") n = n.replace("2","") n = n.replace("3","") n = n.replace("5","") n = n.replace("6","") n = n.replace("8","") n = n.replace("9","") n = n.replace("0","") if len(n) == 4 or len(n) == 7: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
def nearly_lucky(numb): count = 0 for i in numb: if int(i) == 4 or int(i) == 7: count +=1 if count == 7 or count == 4: return "YES" return "NO" numb = input() print(nearly_lucky(numb))
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
#list(map(int,input().split())) n = input() if(((n.count('4')+n.count('7')) == 4)or ((n.count('4')+n.count('7')) == 7)): print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = str(input());n=list(n);q = 0 for i in n: if i=='7' or i=='4': q += 1 if q==7 or q==4: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
#include <bits/stdc++.h> using namespace std; const int N = 100001; vector<int> Edge[N]; vector<int> is(N); void DFS(int u, int time) { is[u] = time; if (Edge[u].size()) for (int v : Edge[u]) { if (is[v] == 0) DFS(v, time); } } int main() { string s; cin >> s; int count = 0; for (int i = 0; i ...
CPP
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=input() j=len(n) c=0 f=1 for i in n: if i=='4' or i=='7': c+=1 for j in str(c): if j!='4' and j!='7': f=0 if f==1: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
def is_happy(x): if x < 4: return False s = str(x) if s.find('0') >= 0: return False if s.find('1') >= 0: return False if s.find('2') >= 0: return False if s.find('3') >= 0: return False if s.find('5') >= 0: return False if s.find('6') >= 0...
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s = input(); c =0 for i in range(len(s)): if s[i]=='4' or s[i]=='7': c+=1 if c==4 or c==7: print('YES') else:print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s=str(input()) l=list(s) count = l.count('4')+l.count('7') st=str(count) l2=list(st) if ('0' not in l2) and ('1' not in l2) and ('2' not in l2) and ('3' not in l2)and ('5' not in l2) and ('6' not in l2) and ('8' not in l2) and ('9' not in l2) and (('4' in l2) or ('7' in l2)): print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s = raw_input() n = s.count('4') + s.count('7') if str(n).replace('4', '').replace('7', '') == '': print 'YES' else: print 'NO'
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = input() s = 0 def isLucky(c): return c == '4' or c == '7' for c in n: if isLucky(c): s += 1 if isLucky(str(s)): print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = int(input()) counter = 0 while n>0: d = n%10 if d==7 or d==4: counter+=1 n = n//10 if counter==7 or counter==4: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
def is_lucky(n): if n == 0: return False while n > 0: if (n % 10) not in [4, 7]: return False n /= 10 return True print ("NO", "YES")[is_lucky(len(filter(is_lucky, map(int, raw_input()))))]
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=input() num=('01235689') ans="NO" cnt=0 for i in n: if i in '4' or i in '7': cnt += 1 if cnt==4 or cnt==7: ans="YES" print(ans)
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s=input() d={'4':0,'7':0} for i in s: if i=='4': d[i]+=1 elif i=='7': d[i]+=1 if sum(d.values())==4 or sum(d.values())==7: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = list(input()) c = n.count('7') + n.count('4') if(c == 4 or c == 7): print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n,s=int(input()),"" c=0 a=list(map(int,str(n))) for i in a: if i==4 or i==7: c+=1 if c==4 or c==7: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
inp = raw_input().strip() cnt = 0 for i in inp: if i == '4' or i =='7': cnt += 1 ans = str(cnt) lucky = True for i in ans: if i != '4' and i!='7': lucky = False if lucky: print 'YES' else: print 'NO'
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
# http://codeforces.com/problemset/problem/110/A s = input() count = 0 for i in range(len(s)): if s[i] == '4' or s[i] == '7': count+=1 if count==4 or count==7: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=list(map(int,input())) l=len(n) c=0 for i in range(l): if n[i]==7 or n[i]==4: c=c+1 if c==7 or c==4: print('YES') else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
a=int(input()) counter=0 while(a!=0): if (a%10)==4 or (a%10)==7 : counter=counter+1 a=a//10 if(counter==4 or counter==7): print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
def luck(s): return s.count('4')+s.count('7')==len(s) n = raw_input() print "YES" if luck(str(n.count('4')+n.count('7'))) else "NO"
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
x=input() c=0 for i in list(x): if i == "4" or i == "7": c+=1 if c == 4 or c == 7: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=int(input()) lucky=0 while(n): if n%10==4 or n%10==7: lucky=lucky+1 n=n//10 if lucky==7 or lucky==4: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = input() print(['NO', 'YES'][n.count('4') + n.count('7') in [4, 7]])
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
entrada = raw_input() dicio = {num: 0 for num in "0123456789"} for i in entrada: dicio[i] += 1 soma = dicio["4"] + dicio["7"] soma = str(soma) tam = len(soma) i = 0 while i < tam and (soma[i] == "4" or soma[i] == "7"): i += 1 if i == tam: print "YES" else: print "NO"
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
#include <bits/stdc++.h> using namespace std; long long k, l, m, n, a, b, c, d, i, s, f; int main() { cin >> n; while (n > 0) { a = n % 10; if (a == 4 || a == 7) k++; n = n / 10; } if (k == 4 || k == 7) cout << "YES"; else cout << "NO"; }
CPP
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
import sys s = sys.stdin.readline() k = 0 for i in s: if i == '4' or i == '7': k += 1 if k == 4 or k == 7: print 'YES' else: print 'NO'
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
x=list(input()) a=x.count('4') b=x.count('7') c=list(str(a+b)) print(['NO','YES'][len(c)==c.count('4')+c.count('7')])
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
from collections import Counter string = list(raw_input().strip()) count_keeper = Counter(string) fin_count = count_keeper['4'] + count_keeper['7'] count_keeper = Counter(list(str(fin_count))) if len(set(count_keeper.keys()).difference(set(['4','7']))): print "NO" else: print "YES"
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
x=input() y=0 w=0 for i in range(0,len(x)): if x[i] == '4' or x[i] == '7' : y=y+1 z=str(y) for i in range(0,len(z)): if z[i]=='4' or z[i]=='7' : w=w+1 else : w=0 break if w >0 : print("YES") else : print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
def kindalucky(): x = input() n = 0 count = 0 x = int(x) if 1<=x<=1000000000000000000: x = str(x) while n < len(x): if x[n] == "7" or x[n] == "4": count+=1 n+=1 if count == 4 or count== 7: print("YES") else: print("NO") else: kindalucky() kindalucky()
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
number = input() numlst = [] for i in range(0, len(number)): numlst.append(number[i]) i += 1 l = 0 lucky_digit_collector = 0 for l in range(0, len(numlst)): if numlst[l] == '4' or numlst[l] == '7': lucky_digit_collector += 1 l += 1 else: l += 1 if lucky_digit_collector == 4...
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
x=input() print("YES" if x.count('4')+x.count('7')==4 or x.count('4')+x.count('7')==7 else "NO" )
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=input() a=0 for i in range(len(n)): if n[i]=='4' or n[i]=='7' : a=a+1 if a==4 or a==7: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
def lucky(n): n = str(n) if n.count('7') + n.count('4') == len(n): return True else: return False n = str(input()) Count = 0 for i in range(len(n)): if lucky(int(n[i])): Count += 1 if lucky(Count): print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
print ["NO","YES"][all(e in "47" for e in str(len([d for d in str(int(raw_input())) if d in "47"])))]
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = input() seven=0 four=0 for i in n: if i == '7': seven = seven + 1 if i == '4': four +=1 if seven+four== 7: print("YES") elif seven+four== 4: print('YES') else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s=input() c=s.count k=c('4') + c('7') if k==4 or k==7: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
import re def checkLucky(fnumber): string = str(fnumber) if re.search('[01235689]',string) : return False else: return True number = int(input()) string = str(number) fours = string.count("4") sevens = string.count("7") if checkLucky(fours + sevens) : print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
import sys x = input() c = 0 for i in x: if i == '4' or i == '7': c+=1 for i in str(c): if i!='4' and i!='7': print("NO") sys.exit() print("YES")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
def split(word): return [char for char in word] n = split(input()) x = 0 for i in range(0, len(n)): if n[i] == '4': x += 1 if n[i] == '7': x += 1 else: continue if x == 4: print('YES') elif x == 7: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = raw_input() f=s=0 n=list(n) for i in n: if i=='4' or i=='7': f+=1 q = list(str(f)) if q.count('4') + q.count('7') == len(q): print 'YES' else: print 'NO'
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
num = input() cnt = num.count('4') + num.count('7') if all([x in '47' for x in list(str(cnt))]): print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s = input() br = 0 l = ['4', '7'] l_br = [4, 7] for i in range(len(s)): if s[i] in l: br += 1 if br > 7: break if br in l_br: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s=input() ct1=0 f=0 for i in s: if(i=='4' or i=='7'): ct1+=1 for i in str(ct1): if (not(i=='4' or i=='7')): f=1 if(f==0): print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
from sys import stdin num = stdin.readline().rstrip() lucky_digits = set({"4", "7"}) counter = 0 for d in num: if d in lucky_digits: counter += 1 lucky = True counter = str(counter) for d in counter: if d not in lucky_digits: lucky = False if lucky: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
def isLucky(n): lucky = ['4','7'] for i in str(n): if i not in lucky: return False return True def luckydigits(n): lucky = ['4','7'] counter = 0 for i in str(n): if i in lucky: counter += 1 return counter n = int(input()) print("YES" if isLucky(luckydi...
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
x = input() i = 0 j = 0 z = 0 lst = [] output = "NO" for i in range(len(x)): lst.append(int(x[i])) i += 1 for j in range(len(x)): if(lst[j] == 4): z += 1 elif(lst[j] == 7): z += 1 j += 1 if(z == 7 or z == 4): output = "YES" print(output)
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
number = list(input()) n = number.count('4')+number.count('7') ans = True for i in list(str(n)): if i not in ('4','7'): ans = False break if ans: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
def lucky(s): return set(s).issubset({"4", "7"}) if __name__ == '__main__': s = input() print("YES" if lucky(str(s.count("4")+s.count("7"))) else "NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
import java.util.Scanner; public class A_Lucky_Number { public static void main(String[] args) { Scanner in = new Scanner(System.in); long n = in.nextLong(); String s = String.valueOf(n); int count = 0; String result = "NO"; for (long i = 0; i < s.length(); i++) { ...
JAVA
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s=input() count=0 for i in s: if(i=='4' or i=='7'): count+=1 if(count==0): print("NO") elif(count==4 or count==7): print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
#a = [4, 7, 47, 74, 444, 777, 474, 447, 744, 477, 747, 774, 744] n = int(input()) s = str(n) count = 0 for i in s: if i in '47': count += 1 if count == 7 or count == 4: print('YES') else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
num = input() num4 = num.count('4') num7 = num.count('7') no = str(num4 + num7) n = 0 for i in no: if i != '4' and i != '7': print('NO') break else: n = n + 1 if n == len(no): print('YES')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
num = 0 for i in input(): if i == '4' or i == '7': num+=1 if num == 4 or num == 7: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
#include <bits/stdc++.h> using namespace std; int main() { string s; int ans = 0; cin >> s; for (int i = 0; i < s.size(); i++) { if (s[i] == '4' || s[i] == '7') ans++; } if (ans == 4 || ans == 7) cout << "YES"; else cout << "NO"; return 0; }
CPP
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
import sys s = sys.stdin.readline() cnt = 0 for i in range(len(s)): if (s[i] == '4') or (s[i] == '7'): cnt += 1 if (cnt == 4) or (cnt == 7): print("YES") else: print("NO")
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
num = input() t = sum(i=='4' or i=='7' for i in num) if t == 4 or t == 7: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = input() four = n.count('4') sev = n.count('7') if four+sev == 4 or four+sev == 7: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = int(input()) cnt7 = 0 cnt4 = 0 while n > 0: if n % 10 == 7: cnt7 += 1 elif n % 10 == 4: cnt4 += 1 n //= 10 if (cnt7 + cnt4) in [4, 7]: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s = input() c = 0 for i in s: if i == "4" or i == "7": c += 1 if c == 4 or c == 7: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
a=input() a=str(a.count('4')+a.count('7')) if a.count('4')+a.count('7')==len(a): print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
x = input() y = 0 for i in x: if i == '4' or i == '7': y += 1 if y == 4 or y == 7: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = input() num_of_lucky = len([i for i in n if i == "7" or i == "4"]) if num_of_lucky == 7 or num_of_lucky == 4: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
a=list(input()) n=x=y=0 for i in a: if(i=='4' or i=='7'): n+=1 #print(n,set(list(str(n)))) b=list(str(n)) for i in b: if(i=='4' or i=='7'): x+=1 y+=1 if(x==y): print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
x= int (input()) l=list(str(x)) n1=l.count("7") n2=l.count("4") if (n1+n2) ==7 or (n1+n2) ==4: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
def isLucky(n): #accepts an int if n == 4 or n == 7: return True elif n > 10 and (n % 10 == 4 or n % 10 == 7): return isLucky(n // 10) else: return False def isNearlyLucky(n): #accepts an int/str n = str(n) count = 0 for i in n: if i == '4' or i == '7': count += 1 #print("Count: " + str(count)) retu...
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
ans=0 s=input() for i in s: if i in '47': ans=ans+1 print(["YES","NO"][bool(set(str(ans))&set('01235689'))])
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=input() cnt=c=0 for i in n: if i=='4' or i=='7': cnt+=1 s=str(cnt) for i in s: if i=='4' or i=='7': c+=1 if c==len(s): print('YES') else: print('NO')
PYTHON3