diff --git a/OTHERS/800 Codeforces Solutions/110A_Nearly_Lucky_Number.cpp b/OTHERS/800 Codeforces Solutions/110A_Nearly_Lucky_Number.cpp new file mode 100644 index 00000000..4340e87d --- /dev/null +++ b/OTHERS/800 Codeforces Solutions/110A_Nearly_Lucky_Number.cpp @@ -0,0 +1,33 @@ +//code by Nikhil Nagrale +//nikhilnagrale2 on EveryPlatform else nknagrale +#include +using namespace std; + +int main(){ + long long n; + cin>>n; + long long count=0; + while(n!=0){ + int x=n%10; + n/=10; + if(x==4 || x==7){ + count++; + } + } + if(count==0) { + cout<<"NO"< +using namespace std; + +int main(){ + string a,b; + cin>>a>>b; + for(auto &c: a) c=tolower(c); + transform(b.begin(),b.end(),b.begin(),::tolower); + cout< +using namespace std; + +int main(){ + int n; + cin>>n; + int total=0; + int min=0; + while(n--){ + int x; + cin>>x; + total-=x; + cin>>x; + total+=x; + if(total>min) + min=total; + } + cout< +using namespace std; + +int main(){ + int n; + cin>>n; + vector v; + for(int i=0;i>temp; + v.push_back(temp); + } + int a[n]; + int num=1; + for(int x:v){ + a[x-1]=num; + num++; + } + for(int x:a) + cout< +using namespace std; + +int main() +{ + int n; + cin >> n; + int maxindex=0; + int minindex=0; + int maxvalue=INT_MIN; + int minvalue=INT_MAX; + for (int i = 0; i < n; i++) + { + int temp; + cin >> temp; + if(temp>maxvalue){ + maxindex=i; + maxvalue=temp; + } + if(temp<=minvalue){ + minindex=i; + minvalue=temp; + } + } + + int ans=(maxindex)+(n-minindex-1); + if(minindex +using namespace std; + +int main(){ + int a[4],d; + cin>>a[0]>>a[1]>>a[2]>>a[3]>>d; + int j; + set s; + for(int i=0;i<4;i++){ + j=1; + while(a[i]*j<=d){ + if(a[i]*j<=d) s.insert(a[i]*j); + j++; + } + } + cout< +using namespace std; + +int main(){ + int n,k; + cin>>n>>k; + vector a; + for(int i=0;i>temp; + a.push_back(temp); + } + int c=a[k-1]; + int count=0; + for(int x:a){ + if(x>=c && x>0) count++; + } + cout< +#define ll long long int +#define pb push_back +#define mp make_pair +using namespace std; +int main(){ +ll t; +cin>>t; +while(t--){ + ll n; + cin>>n; + ll a[n],i,j; + ll sus=0; + for(i=0;i>a[i]; + } + for(i=0;in){ + a[i]/=2; + } + } + sort(a,a+n); + mapm; + for(i=0;i0){ + if(m[a[i]]==0){ + m[a[i]]++; + break;} + else{ + a[i]/=2; + } + + } + if(a[i]==0){ + sus=1; + break; + } + } + } + for(auto it=m.begin();it!=m.end();it++){ + if(it->second==0){ + sus=1; + break; + } + } + if(sus==0){ + cout<<"YES"< +using namespace std; + +int main(){ + int n; + cin>>n; + double a[n]; + double ans=0; + for(int i=0;i>a[i]; + ans+=a[i]; + } + cout< +using namespace std; + +int main() +{ + set s; + int temp; + int t = 4; + while (t--) + { + cin >> temp; + s.insert(temp); + } + cout<<4-s.size()< +using namespace std; + +int main(){ + int n; + cin>>n; + int count=0; + while(n--){ + int x,y,z; + cin>>x>>y>>z; + if((x+y+z)>=2) count++; + } + cout< +using namespace std; + +int main(){ + string s; + cin>>s; + set a; + for(char x:s) a.insert(x); + if(a.size()%2==0) cout<<"CHAT WITH HER!"< +using namespace std; +#define ll long long +#define FAST1 ios_base::sync_with_stdio(false); +#define FAST2 cin.tie(NULL); +int n, k, ans, num; + string s; +int main(){ + FAST1; + FAST2; + + cin >> n >> k; + for (int i = 0; i < n; i++){ + cin >> s; + for (int j = 0; j < s.size(); j++){ + if (s[j] == '7' || s[j] == '4'){ + num ++; + } + } + if (num <= k){ + ans++; + } + num = 0; + } + cout << ans << endl; + return 0; + +} diff --git a/OTHERS/800 Codeforces Solutions/262B_Roma_and_Changing_Signs.cpp b/OTHERS/800 Codeforces Solutions/262B_Roma_and_Changing_Signs.cpp new file mode 100644 index 00000000..f51585ae --- /dev/null +++ b/OTHERS/800 Codeforces Solutions/262B_Roma_and_Changing_Signs.cpp @@ -0,0 +1,39 @@ +// Problem: B. Roma and Changing Signs +// Contest: Codeforces - Codeforces Round #160 (Div. 2) +// URL: https://codeforces.com/contest/262/problem/B +// Memory Limit: 256 MB +// Time Limit: 2000 ms +// +// Powered by CP Editor (https://cpeditor.org) + +#include +using namespace std; +#define ll long long +#define FAST1 ios_base::sync_with_stdio(false); +#define FAST2 cin.tie(NULL); + + +int main(){ + FAST1; + FAST2; + int n;int k; + cin>>n>>k; + int arr[n]; + for(int i=0;i>arr[i]; + + int mn =INT_MAX; + int sm=0; + for(int i=0;i0) + arr[i] *= -1,k--; + sm+=arr[i]; + } + if(k>0 && k%2==1) + sm -= 2 * mn; + + cout< +using namespace std; + +int main(){ + int a[6][6]; + int n,x,y; + for(int i=1;i<=5;i++){ + for(int j=1;j<=5;j++){ + cin>>n; + if(n){ + x=i; + y=j; + } + } + } + cout<<(abs(3-x)+abs(3-y))< +using namespace std; + +int main(){ + int n; + cin>>n; + string s; + cin>>s; + if(!n){ cout<<0< +using namespace std; + +int main() { + int n,t; + cin>>n>>t; + string a; + cin>>a; + while(t--){ + for(int i=0;i +using namespace std; + +int main() +{ + int n; + cin >> n; + vector> v; + for (int i = 0; i < n; i++) + { + int a, b; + cin >> a >> b; + v.push_back({a, b}); + } + int ans = 0; + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + if (i != j && v[i].first == v[j].second) + ans++; + } + } + cout << ans << endl; + return 0; +} + +//O(n+m) solution is also possible \ No newline at end of file diff --git a/OTHERS/800 Codeforces Solutions/271A_Beautiful_Year.cpp b/OTHERS/800 Codeforces Solutions/271A_Beautiful_Year.cpp new file mode 100644 index 00000000..f8ea8ba7 --- /dev/null +++ b/OTHERS/800 Codeforces Solutions/271A_Beautiful_Year.cpp @@ -0,0 +1,35 @@ +//code by Nikhil Nagrale +//nikhilnagrale2 on EveryPlatform else nknagrale +#include +using namespace std; + +bool areDistinct(int n) +{ + map dis; + int digit; + while (n) + { + digit = n % 10; + if (dis[digit]) + { + return false; + } + dis[digit] = 1; + n /= 10; + } + return true; +} +int main() +{ + int n; + cin >> n; + while (++n) + { + if (areDistinct(n)) + { + cout << n << endl; + break; + } + } + return 0; +} \ No newline at end of file diff --git a/OTHERS/800 Codeforces Solutions/281A_Word_Capitalization.cpp b/OTHERS/800 Codeforces Solutions/281A_Word_Capitalization.cpp new file mode 100644 index 00000000..bb5d0e6d --- /dev/null +++ b/OTHERS/800 Codeforces Solutions/281A_Word_Capitalization.cpp @@ -0,0 +1,12 @@ +//code by Nikhil Nagrale +//nikhilnagrale2 on EveryPlatform else nknagrale +#include +using namespace std; + +int main(){ + string s; + cin>>s; + s[0]=toupper(s[0]); + cout< +using namespace std; + +int main(){ + string a,b; + cin>>a>>b; + for(int i=0;i +using namespace std; + +int main(){ + int w; + cin>>w; + if(w%2==0 && w>2) cout<<"YES"< +using namespace std; + +int main(){ + int m,n; + cin>>m>>n; + cout<<(n*m)/2< +using namespace std; + +int main(){ + string s; + cin>>s; + int u=0,l=0; + for(auto x:s){ + if(isupper(x)) u++; + else l++; + } + if(u>l){ + transform(s.begin(),s.end(),s.begin(),::toupper); + }else transform(s.begin(),s.end(),s.begin(),::tolower); + cout< +using namespace std; + +int main() +{ + string a, b; + cin >> a >> b; + string v = ""; + for (int i = 0; i < a.length(); i++) + { + if (a[i] == b[i]) + v += "0"; + else + v += "1"; + } + cout << v << endl; + return 0; +} \ No newline at end of file diff --git a/OTHERS/800 Codeforces Solutions/71A_Way_Too_Long_Words.cpp b/OTHERS/800 Codeforces Solutions/71A_Way_Too_Long_Words.cpp new file mode 100644 index 00000000..176cf90d --- /dev/null +++ b/OTHERS/800 Codeforces Solutions/71A_Way_Too_Long_Words.cpp @@ -0,0 +1,21 @@ +//code by Nikhil Nagrale +//nikhilnagrale2 on EveryPlatform else nknagrale +#include +using namespace std; + +int main(){ + int n; + cin>>n; + while(n--){ + string s; + cin>>s; + if(s.length()>10){ + string ans; + ans.push_back(s.front()); + ans+=to_string(s.length()-2); + ans+=s.back(); + cout< +using namespace std; + +int main(){ + int n; + cin>>n; + cout<3){ + cout<<2<<" "; + n-=2; + } + cout<