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
#A.py import sys; data = sys.stdin.readline(); x = int(data); nr = 0; while x != 0: if (x%10 == 7 or x%10 == 4): nr += 1; x /=10; if (nr == 7 or nr == 4): 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
s=input() cnt=0 for i in range(0,len(s)): if(s[i]=="4" or s[i]=="7"): cnt+=1 p=str(cnt) ans=0 for i in range(0,len(p)): if(p[i]!="4" and p[i]!="7"): ans+=1 break if(ans>0): print("NO") 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
#erfenejmnam# n=int(input()) a=str(n) count=0 for i in a: if(i=='4' or i=='7'): count=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
#include <bits/stdc++.h> using namespace std; int main() { string s; long int c = 0; cin >> s; for (int i = 0; i < s.size(); i++) { if (s[i] == '4' || s[i] == '7') c++; } if (c == 7 || c == 4) cout << "YES" << endl; else cout << "NO" << endl; 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
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Aug 30 16:11:02 2020 @author: anirudhasarmatumuluri """ def isLucky(num): s = set([x for x in num]) if len(s)>2: return False if ('4' in s)& ('7' in s): return True if (('4' in s)or('7' in s))&(len(s)==1): return...
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 numberLucky(n): s=0 k=0 while n!=0: k=n % 10 if(k == 7 or k==4): s+=1 n=n//10 return s n=int(input()) if(numberLucky(n)==4 or numberLucky(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
s=input() s=list(s) flag=0 c=0 for i in s: if i=='4' or i=='7': c+=1 c=str(c) c=list(c) for i in c: if i!='4' and i!='7': flag=1 break if flag==1: print("NO") 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
lucky_numbers = ['4', '7'] n = int(input()) s = str(n) cln = 0 cln += s.count('4') + s.count('7') if (cln == 4) or (cln == 7) or (cln == 74) or (cln == 47) or (cln == 444) \ or (cln == 447) or (cln == 474) or (cln == 744) or (cln == 774) \ or (cln == 777): 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() l = [] for i in num: l.append(int(i)) c = 0 for i in l: 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
number=input() n=number.count('7')+ number.count('4') if(n==4 or 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
n=raw_input() c=n.count('4')+n.count('7') if(str(c).count('4')+str(c).count('7')==len(str(c))): 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
s = input() num = s.count('4') + s.count('7') num = str(num) if len(num) == num.count('4') + num.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
x = str(input("")) c = 0 for i in x: if(int(i) == 7 or int(i) ==4): 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
import sys import os # import math # input = sys.stdin.readline def int_array(): return list(map(int, input().strip().split())) def str_array(): return input().strip().split() def gcd(a,b): if b == 0: return a return gcd(b, a % b); def take_input(): if os.environ.get("check"): sys.stdin ...
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(a): for x in a: if x != '7' and x != '4': return False return True n = long(raw_input()) ans = 0 while n > 0: c = n % 10 n /= 10 if c == 4 or c == 7: ans += 1 if is_lucky(str(ans)): 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() l=0 for i in n: if(i=='4' or i=='7'): l+=1 if(l==4 or l==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() x=0 for c in s: if c is "4" or c is "7": x+=1 if x is 4 or x is 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
x = input() check = 4 checker = 7 a = x.count("4") b = x.count("7") ans = a + b if ans == check: print("YES") elif ans == checker: 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() count = 0 for c in s: if c in ['4', '7']: count += 1 answer = True for c in str(count): if c not in ['4', '7']: answer = False break if answer: 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(x) for x in list(input())] tmp = n flag = False while True: num_four = tmp.count(4) num_seven = tmp.count(7) tmp = [] tmp.append(num_four + num_seven) if len(tmp) == 1: if (tmp[0] == 4 or tmp[0] == 7): flag = True break if flag == True: 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=str(input()) i=0 c=0 for i in range(0,len(x)): if x[i]!='4' and x[i]!='7': c=c+1 l=len(x)-c y=str(l) p=0 i=0 for i in range(0,len(y)): if y[i]!='4' and y[i]!='7': p=1 break if p==1: print("NO"); 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
a=input() n=int(a) count=a.count('4')+a.count('7') 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
four, seven = map(input().count, ("4", "7")) number = int(four) + int(seven) print("YES" if (number == 4 or number == 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
#include <bits/stdc++.h> using namespace std; int main() { long long i = 1, x, y, k = 0; cin >> x; while (x > 0) { y = x % 10; if (y == 4) { k = k++; } if (y == 7) { k = k++; } x = x / 10; } if (k == 4 || k == 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
x=input() y=0 for a in x: if a=='4' or a== '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() b = list(n) a = set(n) # print(b) # print(a) count = 0 for i in b: 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
n=int(input()) c=0 a=0 for i in str(n): if(i=="4" or i=="7"): c=c+1 for i in str(c): if(i=="4" or i=="7"): a=a+1 if(a==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
def main(): n = input() lucky_digits = 0 for digit in n: if digit in ["4", "7"]: lucky_digits += 1 if str(lucky_digits) in ["4", "7"]: print("YES") else: print("NO") if __name__ == "__main__": main()
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 = input() count = inp.count('4')+inp.count('7') print('YES' if count == 4 or 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.*; import java.lang.*; import java.io.*; public class Codechef { public static void main (String[] args) throws java.lang.Exception{ Scanner sc = new Scanner(System.in); long l = sc.nextLong(); int cnt = 0; while(l>0){ if(l%10==4 || l%10==7) cnt++; l/=10; ...
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
ch=input() x=0 for i in range(len(ch)): if(ch[i]=="4" or ch[i]=="7"): x+=1 if(x==4 or x==7 or x==47 or x==74 or x==47 or x==77 or x==447 or x==474 or x==477 or x==744 or x==774 or x==777 or x==7777 or x==7774 or x==7747 or x==7477 or x==4777 or x==4477 or x==4447 or x==4444): print("YES") else: pri...
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): while(n!=0): x=n%10; if(x!=4 and x!=7): return False; n//=10; return True; s=input(); cnt=0; for ch in s: if(ch=="4" or ch=="7"): cnt+=1; if(isLucky(cnt) and cnt!=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
n = int(input()) lis = list(str(n)) c = 0 for i in lis: if i=='7' or i=='4': c=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
if __name__ == '__main__': n = int(input().strip()) lu = [] for i in range(50): bi = bin(i)[2:] nu = "" for x in bi: nu += '7' if x == '0' else '4' lu.append(int(nu)) no = 0 for x in str(n): if x == '4' or x == '7': no += 1 print("Y...
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 n = input() if n.count('4') + n.count('7') 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
number = input() luckycount = 0 almostlucky = True for i in number: if i=="4" or i=="7": luckycount+=1 for s in str(luckycount): if s!="4" and s!="7": almostlucky = False break if almostlucky==True: 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() { int ct = 0; string st; cin >> st; for (int i = 0; i < st.size(); i++) { if (st[i] == '4' || st[i] == '7') { ct++; } else { continue; } } if (ct == 4 || ct == 7) { cout << "YES" << endl; return 0; } else { cout <...
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
num = raw_input() count = 0 for c in num: if c == "4" or c == "7": count += 1 count = str(count) flag = True for c in count: if c!="4" and c!="7": flag = False break if flag: 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
def f(): c, s = 0, input() for i in s: if i=='4' or i=='7': c += 1 for i in str(c): if i not in ['4', '7']: print('NO') return print('YES') f()
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() l=['4','7'] l1=[4,7,44,77,47,74,444,777,447,477,474,774,747,744,7777,4444,7444,7744,7774,7447,] x=[] for i in a: if i in l: x.append(i) length=len(x) c=0 for i in l1: if length == i: c+=1 if c>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
#CKR n = [x for x in input() if x == '7' or x == '4'] print('YES') if len(n) == 7 or len(n) == 4 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() s = 0 for i in N: if i == '4' or i == '7': s += 1 if s == 4 or s == 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() { long long n; cin >> n; int count = 0; while (n != 0) { if (n % 10 == 4 || n % 10 == 7) { count += 1; } n /= 10; } if (count == 4 || count == 7) { cout << "YES" << endl; } else { cout << "NO" << endl; } 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
n=input() lucky=n.count('4')+n.count('7') if lucky 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() n = list(s) if n.count('7') + n.count('4') == 7 or n.count('7') + n.count('4') == 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() c=0 m=0 for i in n: if i=="4": c=c+1 if i=="7": m=m+1 if c+m==4 or c+m==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() lucky= n.count('4')+ n.count('7') if lucky == 4 or lucky == 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
line = input() if line.count('4') + line.count('7') 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
n=list(input()) l=len(n) c=0 if l>1: for i in n: if i == "4" or i == "7": c+=1 if c==7 or c==4: print("YES") else: 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
s = input() a = s.count('4') a += s.count('7') 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
n = raw_input() count = 0 for i in n: if i == "4" or i == "7": count += 1 if count == 7 or count == 4: 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
a = input() count = 0 count2 =0 count3 =0 count4 =0 for i in range(0, len(a)): if(a[i] == '4' or a[i] == '7'): count = count + 1 else: count2 = count2 + 1 b = str(count) for j in range(0,len(b)): if(b[j] == '4' or b[j] == '7'): count3 = count3 + 1 else: count4 = count4 +...
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()) tam=len(n) contador=0 for i in range (tam): if(n[i]=="4") or (n[i]=="7"): contador+=1 if((contador==4) or (contador==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 java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.FileReader; import java.io.FileWriter; //import java.lang.StringBuilder; //import java.util.StringTokenizer; //import java.lang.Comparable; //import jav...
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
st = input() lucky = 0 for i in st: if(i == "7" or i == "4"): lucky += 1 temp_other = 0 for i in str(lucky): if(i != "7" and i != "4"): temp_other += 1 if(temp_other != 0): print("NO") 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
num = input() count = num.count("4") + num.count("7") 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
x=[int(y) for y in input()] i=0 q=0 while i<len(x): if x[i]==7 or x[i]==4: q+=1 i+=1 if q==4 or q==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()) m=0 for i in n: if i=="4" or i=="7": m+=1 if all(i=="4" or i=="7" for i in str(m)): 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() lucky_dig = 0 for x in list(n): if (x == "4") or (x=="7"): lucky_dig += 1 lucky_dig = list(str(lucky_dig)) check_not = [x for x in lucky_dig if (x!= "7") and (x!="4") ] if len(check_not) == 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
inp = raw_input() string = [] for i in inp: string.append(i) count = 0 count_count = 0 for i in string: if i == '4' or i == '7': count+=1 scount = str(count) for i in scount: if i == '4' or i == '7': count_count+=1 if (count_count == len(scount)): 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=input() a=x.count('4') b=x.count('7') if ((a+b)==4) or ((a+b)==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
number = str(input()) four = number.count('4') seven = number.count('7') j = four + seven if j == 4 or j == 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() b = 0 for g in n: if g == '4' or g == '7': b += 1 if b==4 or b==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()) ori=n c=0 while(n!=0): if n%10==4 or n%10==7: c+=1 n=n//10 if c==0: print("NO") elif 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
import collections num = input() cntr = collections.Counter(num) count = cntr['4']+cntr['7'] 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
s = input() count4=0 count7=0 for i in range(len(s)): if s[i] == "4": count4+=1 if s[i] == "7": count7+=1 k = count4+count7 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
from collections import Counter if __name__ == "__main__": num = input() digitMap = Counter(num) c = digitMap['4']+digitMap['7'] 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
number = input() lucky = [4, 7, 47, 74, 477, 747, 774] count = 0 for m in number: if m == '4' or m == '7': count += 1 if count in 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
n = int(input()) num = 0 while n != 0: if n % 10 == 4 or n % 10 == 7: num += 1 n //= 10 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
n=list(input()) c=0 for i in n: if(i=='4' or i=='7'): c=c+1 x=[] while(c>0): d=c%10 x.append(d) c=c//10 z=0 for i in x: if(i==4 or i==7): z=2 else: z=0 print("NO") break if(z==2): print("YES") if(len(x)==0): 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() count=0 for i in n: if i == "7" or i=="4": count+=1 if count in [7,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() n = str(s.count("4") + s.count("7")) for c in n: if c not in "47": print("NO"); 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
n = input() x = n.count("4") y = n.count("7") if x + y == 4 or x + 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
#include <bits/stdc++.h> int main() { int i, f, g; char a[10000]; scanf("%s", a); f = 0; for (i = 0; i < strlen(a); i++) { if (a[i] == '4' || a[i] == '7') f++; } if (f == 0) { printf("NO\n"); } else { g = 0; while (f > 0) { if ((f % 10) != 4 && (f % 10) != 7) { g = 1; ...
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() cnt=0 for i in n: if(i=='4'or 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
n=int(input()) a=[4,7] c=0 while(n>0): if(n%10==4 or n%10==7): c+=1 n//=10 if(c==a[0] or c==a[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
s=input() r=s.count('4')+s.count('7') print('YES' if r==4 or r==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=int(input()) count=0 while(n>0): i=n%10 if(i==4 or i==7): count=count+1 n=n//10 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
#include <bits/stdc++.h> using namespace std; int main() { string s; getline(cin, s); int sz = s.size(), i, l = 0; for (i = 0; i < sz; i++) l += (s[i] == '4') + (s[i] == '7'); if (l == 4 || l == 7) cout << "YES\n"; else cout << "NO\n"; }
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
s = str(input()) x = list(s) if x.count("4") + x.count("7") == 4 or x.count("4") + x.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
a=input() c=0 for l in a: if l=='4' or l=='7': c+=1 c=str(c) b=0 for l in c: if l!='4' and l!='7': print('NO') b=1 break if b==0: 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 = input() x = [a for a in x if a in '47'] if len(x) == 4 or len(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
from sys import stdin, stdout ti = lambda : stdin.readline().strip() ma = lambda fxn, ti : map(fxn, ti.split()) ol = lambda arr : stdout.write(' '.join(str(i) for i in arr) + '\n') os = lambda i : stdout.write(str(i) + '\n') olws = lambda arr : stdout.write(''.join(str(i) for i in arr) + '\n') n = int(ti()) digits = ...
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
def yesorno(n): for i in str(n): if i != '4' and i != '7': return "NO" return "YES" a = str(input()) c = 0 for i in a: if i == '4' or i == '7': c +=1 print(yesorno(c))
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() sum1=n.count('4')+n.count('7') if (sum1==4 or sum1==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();b=0 for i in range(0,len(a)): if(a[i]=='4' or a[i]=='7'): b+=1 if b==4 or b==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
# author : sudoer n = int(raw_input()) lucky = [4,7] count = 0 s = str(n) for i in s: if int(i) in lucky: count += 1 c = str(count) flag = 1 for i in c: if int(i) not in lucky: flag = 0 break if flag == 1: 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; int main() { string str; int num = 0; cin >> str; int len = str.length(); for (int i = 0; i < len; i++) { if (str[i] == '4' || str[i] == '7') { num++; } } if (num == 4 || num == 7) cout << "YES" << endl; else cout << "NO" << endl; ret...
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
print('NYOE S' [sum(i in ('4','7') for i in input()) in (4,7)::2])
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): ls = set(['4', '7']) return set(str(n)).union(ls) == ls def is_nearly_lucky(n): s = str(n) return is_lucky(s.count('4') + s.count('7')) n = int(raw_input()) print 'YES' if is_nearly_lucky(n) 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
import java.io.*; public class Lucky { public static boolean isLucky(long n) { if(n == 0) return false; else { boolean b = true; while(n != 0) { long d = n % 10; if(!(d == 4 || d == 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=str(input()) sum=0 i=0 while(i<len(n)): if(n[i]=='4' or n[i]=='7'): sum+=1 i+=1 if(sum==4 or sum==7): print("YES","\n") else: print("NO","\n")
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() a=sum([int(s[i]=='4' or s[i]=='7') for i in range(len(s))]) if a==4 or a==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
s=str(input()) f=0 for c in s: if(c==str(7) or c==str(4)): f=f+1 if(f==4 or f==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 java.util.*; public class Main { public static boolean isLucky(String count){ for(char ch : count.toCharArray()){ if(ch!='4'&&ch!='7')return false; } return true; } public static String isNearlyLucky(String s){ int count = 0; for(char c : s.toCharAr...
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=input() t=0 t+=n.count('4') t+=n.count('7') if t==7 or t==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=raw_input() c=a.count('7')+a.count('4') print "YES" if c and (c==4 or c==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
number=str(input()) onlyLucky=number.count('4')+number.count('7') if onlyLucky==4 or onlyLucky==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() count=0 for i in range(len(n)): if n[i]=='4' or n[i]=='7': count=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
k=input() lol=str(k.count("4")+k.count("7")) lol=lol.replace("4","A") lol=lol.replace("7","A") if lol.count("A")!=len(lol): print("NO") else: print("YES")
PYTHON3