output
stringlengths
52
181k
instruction
stringlengths
296
182k
#include <bits/stdc++.h> using namespace std; int a[200000]; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int odd = 0, even = 0; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] & 1) odd++; else even++; } if (odd == 0 or (even == 0 and n...
### Prompt Develop a solution in cpp to the problem described below: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices in differe...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false), cin.tie(0); long long t, n, a, odds = 0, evens = 0; cin >> t; while (t--) { evens = 0; odds = 0; cin >> n; for (long long i = 0; i < n; i++) { cin >> a; if (a % 2 == 0) evens++; else...
### Prompt Please formulate a Cpp solution to the following problem: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices in differe...
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t--) { long long int i, n, e = 0, o = 0; cin >> n; vector<long long int> v(n); for (i = 0; i < n; i++) cin >> v[i], o += v[i] % 2, e += 1 - v[i] % 2; if (!o) cout << "NO\n"; else if (o - n) ...
### Prompt Your task is to create a Cpp solution to the following problem: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices in d...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int v[2010]; int n; cin >> n; int sum = 0; for (int i = 0; i < n; i++) { int s; cin >> s; sum += s; v[i] = s; } if (sum % 2 == 0) { bool flag = false; if (v[0] ...
### Prompt In Cpp, your task is to solve the following problem: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices in different op...
#include <bits/stdc++.h> using namespace std; long long int modInverse(long long int n, long long int p) { long long int x = n; long long int y = p - 2; long long int res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } long long int ...
### Prompt Construct a CPP code solution to the problem outlined: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices in different ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int a, x = 0, y = 0, i; for (i = 0; i < n; i++) { cin >> a; if (a % 2 == 0) x++; else y++; } if (y == 0) cout << "NO\n"; else if (x == 0 &&...
### Prompt Please provide a CPP coded solution to the problem described below: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices ...
#include <bits/stdc++.h> using namespace std; void Nhap(int &n) { cin >> n; } void Nhapmang(int a[], int n) { int i; for (i = 0; i < n; i++) { cin >> a[i]; } } int KQ(int a[], int n) { int i; if (n % 2 == 0) { for (i = 0; i < n - 1; i++) { if (a[i] % 2 != a[i + 1] % 2) return 0; } return...
### Prompt Generate a CPP solution to the following problem: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices in different opera...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int i = 0; i < t; i++) { int n; cin >> n; int sum = 0, odd = 0, even = 0; for (int i = 0; i < n; i++) { int x; cin >> x; if (x % 2 == 0) { even++; } else { odd++; } ...
### Prompt Your challenge is to write a CPP solution to the following problem: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices ...
#include <bits/stdc++.h> using namespace std; int a[2020]; int main() { int t, n; bool f1, f2; ifstream in("in"); cin >> t; while (t > 0) { f1 = false; f2 = false; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] % 2 == 0) f1 = true; else f2 = tru...
### Prompt Your challenge is to write a CPP solution to the following problem: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, a, odd = 0, ok = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a; if (a & 1) { odd++; } } if (n % 2 == 1) { if (odd) ok = 1; else ok = 0; ...
### Prompt Please formulate a cpp solution to the following problem: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices in differe...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; int odd = 0, even = 0; for (int i = 0; i < n; i++) { int aux; cin >> aux; if (aux % 2 == 0) even++; else ...
### Prompt Please provide a Cpp coded solution to the problem described below: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int t; cin >> t; while (t--) { int even = 0; int odd = 0; int n; cin >> n; for (int i = 0; i < n; i++) { int num; cin >> num; if (num % 2 == 0) { even++; } else { o...
### Prompt Your task is to create a Cpp solution to the following problem: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices in d...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long t; cin >> t; while (t--) { long long n; cin >> n; long long a[n]; long long odd = 0, even = 0; for (long long i = 0; i < n; i++) { cin >> a[i]; if (a[i] % 2...
### Prompt Develop a solution in CPP to the problem described below: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices in differe...
#include <bits/stdc++.h> using namespace std; int d[100000]; int main() { int a, c, i, n, m, p, t; cin >> t; while (t--) { cin >> n; p = 0; for (i = 0; i < n; i++) cin >> d[i]; for (i = 0; i < n; i++) { if (d[i] % 2 != 0) p++; } if (p == 0 || (p == n && n % 2 == 0)) { printf("N...
### Prompt Please formulate a CPP solution to the following problem: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices in differe...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int a, f1 = 0, f2 = 0; for (int i = 0; i < n; i++) { cin >> a; if (a % 2 == 1) f1 = 1; if (a % 2 == 0) f2 = 1; } if (f1 == 1 && f2 == 1) cout << "YES" << endl; i...
### Prompt Please create a solution in CPP to the following problem: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices in differe...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int a[n]; int odd = 0, even = 0; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] & 1) odd++; else even++; } if (odd == 0 or (even == 0 and n ...
### Prompt Please provide a CPP coded solution to the problem described below: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; int n, a[2000]; for (int i = 0; i < t; i++) { cin >> n; int sum = 0; for (int j = 0; j < n; j++) { cin >> a[j]; if (a[j] % 2 == 1) sum += 1; } if (sum) { if (sum % 2 == 1 || sum < n) cout <<...
### Prompt Generate a CPP solution to the following problem: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices in different opera...
#include <bits/stdc++.h> using namespace std; int main() { int t, n; cin >> t; while (t--) { cin >> n; int num[n]; int sum = 0, even = 0, odd = 0; for (int i = 0; i < n; i++) { cin >> num[i]; sum += num[i]; if (num[i] % 2 == 0) even++; if (num[i] % 2 != 0) odd++; } ...
### Prompt Generate a Cpp solution to the following problem: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices in different opera...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; int sum = 0; bool odd = false, even = false; for (int i = 0; i < n; i++) { int temp; cin >> temp; if (temp & 1) { ...
### Prompt Create a solution in CPP for the following problem: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices in different ope...
#include <bits/stdc++.h> using namespace std; bool check_odd(long long num) { if (num % 2 == 0) { return false; } return true; } int main() { long long t; cin >> t; while (t--) { long long n; cin >> n; long long arr[n]; long long sum = 0; long long ev = 0, od = 0; for (long long ...
### Prompt Create a solution in cpp for the following problem: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices in different ope...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int odd_cnt = 0; vector<int> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; if (v[i] % 2 == 1) odd_cnt++; } if (odd_cnt == 0) { cout << "NO" << endl; } els...
### Prompt Your challenge is to write a Cpp solution to the following problem: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices ...
#include <bits/stdc++.h> using namespace std; int main() { int cases; cin >> cases; for (int iter = 0; iter < cases; ++iter) { int n; cin >> n; bool all_even = true; bool all_odd = true; for (int i = 0; i < n; ++i) { int k; cin >> k; if (k % 2 == 0) all_odd = false; ...
### Prompt Your task is to create a Cpp solution to the following problem: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices in d...
#include <bits/stdc++.h> using namespace std; int main() { long t; cin >> t; while (t--) { int n; cin >> n; int ctr = 0; for (int i = 0; i < n; i++) { long x; cin >> x; if (x % 2 != 0) { ctr++; } } if (ctr % 2 != 0) { cout << "YES" << endl; } else ...
### Prompt Create a solution in cpp for the following problem: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices in different ope...
#include <bits/stdc++.h> using namespace std; int n, t, l, r; set<int> d; map<int, int> mp; int a[300005]; int main() { cin >> t; while (t--) { memset(a, 0, sizeof(a)); int pr = 0; int pr2 = 0; int s = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; s += a[i]; if (a...
### Prompt Your task is to create a Cpp solution to the following problem: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices in d...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7, N = 1e5 + 10; void solve() { long long n, sum = 0, even = 0, odd = 0; cin >> n; long long a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] % 2) { odd++; } else { even++; } } if (odd % 2) { cout <<...
### Prompt Please provide a CPP coded solution to the problem described below: You are given an array a consisting of n integers. In one move, you can choose two indices 1 ≀ i, j ≀ n such that i β‰  j and set a_i := a_j. You can perform such moves any number of times (possibly, zero). You can choose different indices ...
#include <bits/stdc++.h> int main() { int n, i, j, m, sum, len; char a[101]; while (scanf("%s", a) != EOF) { len = strlen(a); for (i = 1; i < len; i++) { if (a[i] < 'a') ; else break; } if (i != len) printf("%s\n", a); else { for (i = 0; i < len; i++) ...
### Prompt Your challenge is to write a CPP solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passag...
#include <bits/stdc++.h> using namespace std; string S; int main() { bool State = true; cin >> S; for (int i = 1; i < S.length(); i++) { if (S[i] >= 'a' && S[i] <= 'z') { State = false; } } if (State) { for (int i = 1; i < S.length(); i++) { S[i] = tolower(S[i]); } if (S[0] >= ...
### Prompt Your challenge is to write a CPP solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passag...
#include <bits/stdc++.h> int main() { std::string s; std::cin >> s; if (s.size() == 1) { if (std::islower(s[0])) { s[0] = std::toupper(s[0]); } else { s[0] = std::tolower(s[0]); } std::cout << s; return 0; } else { if (std::islower(s[0])) { for (int i = 1; i != s.size()...
### Prompt Develop a solution in cpp to the problem described below: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int p = s.length(), cnt = 0, flag = 0, j; if (s[0] >= 'a' && s[0] <= 'z') flag = 1; for (int i = 0; i < p; i++) { if (s[i] >= 'A' && s[i] <= 'Z') cnt++; } if (cnt == p || (flag == 1 && cnt == p - 1)) { for (int i = 0; i...
### Prompt Generate a cpp solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's conside...
#include <bits/stdc++.h> using namespace std; int main() { string str; cin >> str; int n = str.length(); int flag = 0; if (str.length() > 1) { for (int i = 1; i < n; i++) { if (str[i] > 96) { flag = 0; break; } else flag = 1; } } else flag = 1; if (flag == 1...
### Prompt Develop a solution in CPP to the problem described below: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int r = 0; for (int i = 1; s[i] != '\0'; i++) { if (s[i] >= 'A' && s[i] <= 'Z') r++; } if (r == s.size() - 1) { for (int i = 0; s[i] != '\0'; i++) { if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 32; el...
### Prompt Please create a solution in cpp to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> using namespace std; int main() { string str; getline(cin, str); bool OK = true; for (int i = 1; i < str.size(); i++) { if (str[i] >= 'a' && str[i] <= 'z') { OK = false; break; } } if (OK) { for (int i = 0; i < str.size(); i++) { if (str[i] >= 'A' && st...
### Prompt Develop a solution in CPP to the problem described below: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { return b == 0 ? a : gcd(b, a % b); } const long long MOD = 1000000007; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL); string s; cin >> s; int i, c = 0, len; l...
### Prompt Please create a solution in Cpp to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; void read(vector<int> &a) { for (auto &it : a) cin >> it; } void Solve() { string s; cin >> s; int cnt = 0; for (int i = 0; i < s.size(); i++) { if (s[i] >= 'A' && s[i] <= 'Z') { cnt++; } } if (cnt == s.size()) { for ...
### Prompt Your task is to create a CPP solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. ...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int ok = 1; for (int i = 1; i < s.length(); i++) { if (islower(s[i])) { ok = 0; } } if (ok == 0) cout << s << endl; else { for (int i = 0; i < s.length(); i++) { if (isupper(s[i])) s[i] = tol...
### Prompt Please formulate a Cpp solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> using namespace std; int main() { string x, f = "", r = ""; int c = 0; char l; cin >> x; if (x[0] >= 'a' && x[0] <= 'z') { for (int i = 1; i < (x.length()); i++) { if (x[i] >= 'A' && x[i] <= 'Z') { c++; } } if (c == (x.length() - 1)) { l = x[0]; ...
### Prompt Your challenge is to write a CPP solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passag...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; stringstream ss(s); char ch; bool isFirstSmall = false; bool isAllCapital = true; ss >> ch; if (int(ch) >= 97) isFirstSmall = true; if (isFirstSmall) { stringstream ss1(s); ss1 >> ch; while (ss1 >> ch) { i...
### Prompt Please provide a Cpp coded solution to the problem described below: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passag...
#include <bits/stdc++.h> using namespace std; int main() { int l, i, flag = 0; char str[101]; cin >> str; l = strlen(str); if (l == 1 && str[0] <= 'z' && str[0] >= 'a') str[0] -= 32; else { for (i = 1; i < l; ++i) { if (str[i] <= 'z' && str[i] >= 'a') { flag = 1; break; }...
### Prompt Develop a solution in cpp to the problem described below: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> int main() { int i, count = 1; char a[100]; scanf("%s", &a); for (i = 1; a[i] != '\0'; i++) { if (a[i] >= 'A' && a[i] <= 'Z') count = count + 1; } if (count == i) { for (i = 0; a[i] != '\0'; i++) { if (a[i] >= 'A' && a[i] <= 'Z') a[i] = a[i] + 32; else if...
### Prompt Your task is to create a Cpp solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. ...
#include <bits/stdc++.h> using namespace std; int check(char a) { if ((int)a < 123 && (int)a > 96) return true; else return false; } char anticaps(char a) { int a1 = (int)a + 32; return a1; } int main() { string A; int tmp = 0; getline(cin, A); for (int i(0); i < A.length(); i++) if (!check(...
### Prompt Your challenge is to write a Cpp solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passag...
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string s; cin >> s; if (isupper(s[0])) { int counter = 0; for (int i = 1; i < s.length(); i++) { if (isupper(s[i])) counter++; } if (c...
### Prompt Develop a solution in cpp to the problem described below: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; char u; bool c = true; for (int i = 1; i < s.length(); i++) { if (islower(s[i])) c = false; } if (c == true) { for (int j = 0; j < s.length(); j++) { if (islower(s[j])) u = toupper(s[j]); else ...
### Prompt Your task is to create a CPP solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. ...
#include <bits/stdc++.h> using namespace std; int main() { string x; cin >> x; int t = 0, t1 = 0; for (int i = 0; i < x.size(); i++) { if (x[i] >= 97 && x[i] <= 122) t1++; else if (x[i] >= 65 && x[i] <= 90) t++; } if (t1 == 1 && x[0] >= 97 && x[0] <= 122) { x[0] = x[0] - 32; cout...
### Prompt Please provide a cpp coded solution to the problem described below: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passag...
#include <bits/stdc++.h> using namespace std; string change_case(string data, int i) { if (i == 0) transform(data.begin(), data.end(), data.begin(), ::tolower); else transform(data.begin(), data.end(), data.begin(), ::toupper); return data; } int main() { string s; int upcase = 0, lowcase = 0, i, test...
### Prompt Please create a solution in Cpp to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> using namespace std; int main() { string s, k; int z = 0; getline(cin, s); k = s; for (int i = 1; i < s.length(); ++i) { if (int(s[i]) < 97) { s[i] = int(s[i]) + 32; } else if (i != 0) { z = 1; cout << k; break; } } if (z != 1) { if (int(s[0...
### Prompt Construct a Cpp code solution to the problem outlined: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's co...
#include <bits/stdc++.h> const double PI = acos(-1.0); const double e = exp(1.0); const int INF = 0x7fffffff; ; template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; } template <class T> inline T Min(T a, T b) { return a < b ? a : b; } ...
### Prompt Please create a solution in cpp to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> using namespace std; int main() { int q = 0; char s[100]; scanf("%s", s); for (int i = 1; i < strlen(s); i++) { if (s[i] >= 65 && s[i] <= 90) { q++; } } if (q == strlen(s) - 1) { for (int i = 0; i < strlen(s); i++) { if (s[i] >= 65 && s[i] <= 90) s[i]...
### Prompt Generate a cpp solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's conside...
#include <bits/stdc++.h> using namespace std; long long m, n; string s; int CapsLock(string s) { for (int i = 0; i < s.size(); i++) { if (s[i] > 92) { s[i] -= 32; } else if (s[i] < 92) { s[i] += 32; } } cout << s; return 0; } int main() { cin >> s; if (s.size() == 1) { CapsLock(s...
### Prompt Please create a solution in cpp to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> using namespace std; int main() { string s; getline(cin, s); for (int i = 1; i < s.length(); i++) { if (islower(s[i])) cout << s, exit(0); } for (int i = 0; i < s.length(); i++) { if (s[i] >= 65 && s[i] <= 90) { s[i] = tolower(s[i]); continue; } if (s[i] >=...
### Prompt In Cpp, your task is to solve the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's cons...
#include <bits/stdc++.h> using namespace std; int main() { int n = 1; string str, temp; cin >> str; if (str[0] <= 'Z' && str[0] >= 'A') temp.push_back(str[0] + 'a' - 'A'); else temp.push_back(str[0] - ('a' - 'A')); if (str.length() == 1) { str = temp; cout << str << endl; return 0; } ...
### Prompt Please formulate a cpp solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> using namespace std; int main() { char str[101]; int i, count = 0; cin >> str; for (i = 0; i < strlen(str); i++) { if (str[i] >= 65 && str[i] <= 90) count++; } if (str[0] >= 97 && count == strlen(str) - 1) { str[0] -= 32; for (i = 1; i < strlen(str); i++) str[i] += 32; ...
### Prompt Please create a solution in CPP to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> using namespace std; int main() { int i, len = 0; char str[1000]; cin >> str; for (i = 1; i < strlen(str); i++) { if (str[i] >= 65 && str[i] <= 90) { len++; } } if (len == strlen(str) - 1) { for (i = 0; i < strlen(str); i++) { if (str[i] >= 65 && str[i] <= 90...
### Prompt In CPP, your task is to solve the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's cons...
#include <bits/stdc++.h> int main() { char s[110]; scanf("%s", s); int len = strlen(s); if (len == 1) { if (s[0] >= 'A' && s[0] <= 'Z') s[0] = tolower(s[0]); else s[0] = toupper(s[0]); puts(s); return 0; } int acnt = 0, bcnt = 0; if (s[0] >= 'A' && s[0] <= 'Z') acnt++; for (i...
### Prompt Generate a Cpp solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's conside...
#include <bits/stdc++.h> int main() { char ch[106]; int i, j, ck = 1; scanf("%s", ch); for (i = 1; ch[i] != '\0'; i++) { if (ch[i] >= 97 && ch[i] <= 122) { ck = 0; break; } } if (ck == 1) { if (ch[0] >= 65 && ch[0] <= 90) ch[0] = ch[0] + 32; else ch[0] = ch[0] - 32; ...
### Prompt Develop a solution in cpp to the problem described below: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; if (isupper(s[0])) { string tem; for (int i = 0; i < s.size(); ++i) { if (!isupper(s[i])) { cout << s << '\n'; return 0; } tem += tolower(s[i]); } cout << tem << '\n'; return 0; }...
### Prompt Generate a Cpp solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's conside...
#include <bits/stdc++.h> using namespace std; int main() { char a[101]; bool f = 0; cin >> a; for (int i = 1; a[i] != NULL; i++) { if (a[i] >= 'a' && a[i] <= 'z') f = 1; } if (f == 0) { for (int i = 0; a[i] != NULL; i++) { if (a[i] >= 'A' && a[i] <= 'Z') a[i] += 'a' - 'A'; else i...
### Prompt Your challenge is to write a cpp solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passag...
#include <bits/stdc++.h> using namespace std; int main() { int flag = 1; char s[101]; scanf("%s", s); for (int i = 1; i < strlen(s); i++) { if (islower(s[i])) { flag = 0; } } if (flag == 0) printf("%s", s); else { if (isupper(s[0])) s[0] = tolower(s[0]); else s[0] = t...
### Prompt Your task is to create a cpp solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. ...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; bool ch = true; for (int i = 1; i < s.size(); i++) { if (toupper(s[i]) != s[i]) { ch = false; break; } } if (ch) { for (int i = 1; i < s.size(); i++) { s[i] = tolower(s[i]); } if (s[0] == tou...
### Prompt Your challenge is to write a Cpp solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passag...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int i, n = s.length(); int k = 0; for (i = 1; i < n; i++) { if (s[i] >= 'a' && s[i] <= 'z') { k = k + 1; } } if (k == 0) { for (i = 0; i < n; i++) { if (s[i] >= 'a' && s[i] <= 'z') { s[i] = s[i] ...
### Prompt Generate a cpp solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's conside...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; string s; cin >> s; int temp, x; temp = 1; x = 0; if (s.length() == 1) { if ((int)s[0] > 93) x = 1; } else { for (int i(1); i < s.length(); i++) { if ((int)s[i] > 93) t...
### Prompt Please provide a CPP coded solution to the problem described below: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passag...
#include <bits/stdc++.h> int main() { int l = 0, u = 0; char input[120]; scanf("%s", &input); for (int i = 0; i < strlen(input); i++) { if (islower(input[i]) != 0) l++; else u++; } if (l == 1 && !u) printf("%c", toupper(input[0])); else if (l == 1 && u && islower(input[0])) for...
### Prompt Please create a solution in CPP to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> using namespace std; int xuli() { string s; cin >> s; for (int i = 1; i < s.size(); i++) if (s[i] >= 97) { for (int i = 0; i < s.size(); i++) cout << s[i]; return 0; } if (s[0] >= 97) s[0] -= 32; else s[0] += 32; for (int i = 1; i < s.size(); i++) if ...
### Prompt Construct a Cpp code solution to the problem outlined: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's co...
#include <bits/stdc++.h> using namespace std; int main() { string s; while (getline(cin, s)) { int n = s.length(); int count = 0; for (int i = 1; i < s.length(); i++) { if (s[i] >= 65 && s[i] <= 90) count++; } if (count != (n - 1)) cout << s << endl; else { transform(s.begi...
### Prompt Your challenge is to write a Cpp solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passag...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int m = 0; for (int i = 1; i < s.size(); i++) { if (s[i] >= 65 and s[i] <= 91) { m++; } } if (m == s.size() - 1) { if (s[0] >= 97 and s[0] <= 123) { s[0] -= 32; } else if (s[0] >= 65 and s[0] <= 91) { ...
### Prompt Construct a Cpp code solution to the problem outlined: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's co...
#include <bits/stdc++.h> using namespace std; int a, c, n, m; string s; int main() { string s; cin >> s; int d = 0; for (int i = 0; i < s.size(); i++) if (i > 0 && islower(s[i])) d = 1; if (d == 1) { cout << s; return 0; } for (int i = 0; i < s.size(); i++) { if (isupper(s[i])) cout ...
### Prompt Create a solution in Cpp for the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's consi...
#include <bits/stdc++.h> using namespace std; int main() { bool is = true; string s; cin >> s; if (isupper(s[0])) { for (int i = 1; i < s.length(); i++) { if (islower(s[i])) { is = false; break; } } } else { for (int i = 1; i < s.length(); i++) { if (islower(s[i])...
### Prompt Construct a CPP code solution to the problem outlined: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's co...
#include <bits/stdc++.h> int main() { char s[200]; int i, count = 0, l; scanf("%s", s); l = strlen(s); for (i = 0; s[i]; i++) { if (s[i] >= 65 && s[i] <= 90) { count++; } } if (l == count) { for (i = 0; s[i]; i++) printf("%c", s[i] + 32); } else if (s[0] >= 97 && count == l - 1) { ...
### Prompt Generate a cpp solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's conside...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int a; for (int i = 1; i < s.size(); i++) { a = s[i]; if (a > 90) { cout << s; return 0; } } a = s[0]; if (a > 90) { s[0] = toupper(s[0]); } else s[0] = tolower(s[0]); for (int i = 1; i < s.s...
### Prompt Develop a solution in cpp to the problem described below: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> char string[100]; void do_change_string(int first_char_is_high, int is_remain) { int i, j, temp; char criteria = 'a'; int char_offset = 'a' - 'A'; if (first_char_is_high + is_remain == is_remain + 1) { i = 0; j = is_remain + 1; } else if (!first_char_is_high && is_remain != 0)...
### Prompt Generate a Cpp solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's conside...
#include <bits/stdc++.h> using namespace std; int main() { char str[100]; int i, l = 0; cin >> str; for (i = 1; i < strlen(str); i++) { if (str[i] >= 'A' && str[i] <= 'Z') l++; } if (l == strlen(str) - 1) { for (i = 0; i < strlen(str); i++) { if (str[i] >= 'A' && str[i] <= 'Z') str[i] ...
### Prompt Create a solution in cpp for the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's consi...
#include <bits/stdc++.h> using namespace std; int main() { string s; int i, cnt = 0; cin >> s; for (i = 0; i < s.size(); i++) { if (s[i] >= 'A' && s[i] <= 'Z') { cnt++; } } if (cnt == s.size() || ((s[0] >= 'a' && s[0] <= 'z') && cnt == s.size() - 1)) { for (i = 0; i < s.size(); i++) ...
### Prompt Develop a solution in Cpp to the problem described below: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> const long long OO = 1e9 + 7; using namespace std; string s; int d1 = 0, d2 = 0; void kurumi() { cin >> s; for (int i = 0; i < s.size(); i++) { if (s[i] - 0 >= 65 && s[i] - 0 <= 90) d1++; else d2++; } if ((d2 == 1 && s[0] - 0 >= 95 && s[0] - 0 <= 122) || d1 == s.size...
### Prompt Your task is to create a CPP solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. ...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; bool change = true; for (int i = 1; i < s.length(); ++i) { if (s[i] >= 'a') { change = false; break; } } if (change) { for (int i = 0; i < s.length(); ++i) { if (s[i] >= 'a') { s[i] -= ('a' -...
### Prompt Your task is to create a Cpp solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. ...
#include <bits/stdc++.h> int main() { char a[111]; int i, l; int flag1, flag2; while (gets(a) != NULL) { l = strlen(a); flag2 = 0; if (a[0] >= 'A' && a[0] <= 'Z') flag1 = 1; else flag1 = 0; for (i = 1; i < l; i++) { if (a[i] >= 'a' && a[i] <= 'z') { flag2 = 1; ...
### Prompt Develop a solution in cpp to the problem described below: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int acc = 1; for (int i = 1; i < s.length(); i++) { if (s[i] > 96) { acc = 0; break; } } if (acc) { cout << ((s[0] < 91) ? char(s[0] + 32) : char(s[0] - 32)); for (int i = 1; i < s.length(); i++) { ...
### Prompt Construct a CPP code solution to the problem outlined: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's co...
#include <bits/stdc++.h> using namespace std; int main() { string str; int cnt = 0; cin >> str; int len = str.length(); for (int i = 0; i < len; ++i) { if (str[i] >= 'A' && str[i] <= 'Z') cnt++; } if (cnt == len) { for (int i = 0; i < len; ++i) { putchar(str[i] - 'A' + 'a'); } cout <...
### Prompt Construct a Cpp code solution to the problem outlined: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's co...
#include <bits/stdc++.h> using namespace std; bool mayus(string s) { for (int i = 0; i < s.size(); i++) if (toupper(s[i]) != s[i]) return false; return true; } bool mayus2(string s) { for (int i = 1; i < s.size(); i++) if (toupper(s[i]) != s[i]) return false; return true; } int main() { string s; ge...
### Prompt Create a solution in cpp for the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's consi...
#include <bits/stdc++.h> using namespace std; int main() { string word; int x = 0; int y = 0; while (cin >> word) { if (isupper(word[0])) { for (int i = 0; i < word.length(); i++) { if (isupper(word[i])) { x++; } } if (x == word.length()) { for (int i = 0;...
### Prompt Your challenge is to write a Cpp solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passag...
#include <bits/stdc++.h> using namespace std; string fixCaps(string str) { string res; for (int i = 1; i < str.size(); i++) { if (str[i] >= 65 && str[i] <= 90) { res += (char)(str[i] + 32); } else { return str; } } if (str[0] >= 65 && str[0] <= 90) { res = (char)(str[0] + 32) + res; ...
### Prompt Construct a cpp code solution to the problem outlined: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's co...
#include <bits/stdc++.h> using namespace std; string qq(string s) { for (long long i = 0; i < s.size(); i++) { if (s[i] >= 'A' && s[i] <= 'Z') { s[i] = (char)(s[i] - 'A' + 'a'); } else { s[i] = (char)(s[i] - 'a' + 'A'); } } return s; } int main() { ios::sync_with_stdio(0); cin.tie(0); ...
### Prompt Construct a cpp code solution to the problem outlined: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's co...
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; long long n = s.size(); long long u = 0, l = 0; for (long long i = 0; i < n; i++) { if (s[i] >= 'A' and s[i] <= 'Z') u++; else l++; } if (n == 1) { if (u) cout << char(tolower(s[0])) << "\n"; ...
### Prompt Develop a solution in cpp to the problem described below: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> using namespace std; int main() { string input; cin >> input; string output; if (isupper(input[0])) { output.push_back(tolower(input[0])); } else { output.push_back(toupper(input[0])); } for (int i = 1; i < input.length(); ++i) { if (isupper(input[i])) { output.p...
### Prompt Construct a cpp code solution to the problem outlined: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's co...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; bool c = true; for (int i = 1; i < s.size(); ++i) if (s[i] > 91) { c = false; break; } if (char(s[0] > 91) && c) { s[0] = s[0] - ' '; for (int i = 1; i < s.size(); ++i) s[i] = s[i] + ' '; } else if (ch...
### Prompt Please create a solution in Cpp to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> int main() { int i, j, k, l, m, n, c = 5; char ara[1000]; scanf("%[^\n]", ara); l = strlen(ara); for (i = 1; i < l; i++) { if (ara[i] >= 'a' && ara[i] <= 'z') { c = 10; break; } } if (c == 5) { for (i = 1; i < l; i++) { ara[i] += 32; } if ((ar...
### Prompt Please provide a cpp coded solution to the problem described below: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passag...
#include <bits/stdc++.h> using namespace std; int main() { string s; int i, j, x, flag = 0; cin >> s; x = s.length(); if (x == 1 && (s[0] >= 'a' && s[0] <= 'z')) { s[0] = s[0] - 32; cout << s; } else if (x == 1 && (s[0] >= 'A' && s[0] <= 'Z')) { s[0] = s[0] + 32; cout << s; } if (x > 1) ...
### Prompt Please formulate a CPP solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> int main() { char w[101]; int i, len, flag = 0, flag1 = 0; scanf("%s", w); len = strlen(w); if (islower(w[0])) flag1 = 1; for (i = 1; i < len; i++) if (islower(w[i])) { flag++; flag1 = 1; } if (flag == 0 && flag1 == 1) { if (islower(w[0])) w[0] = toupper(w[...
### Prompt Please create a solution in Cpp to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> using namespace std; string FixedString(string s) { string str = ""; for (int i = 0; i < s.length(); i++) { if (islower(s[i])) str += toupper(s[i]); else str += tolower(s[i]); } return str; } int main() { string s; cin >> s; if (islower(s[0])) { bool fail =...
### Prompt Please formulate a cpp solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> using namespace std; int main() { int i, l = 0; string s; cin >> s; for (i = 1; i < s.size(); i++) if (s[i] >= 65 && s[i] <= 90) l++; if (l == s.size() - 1) { for (i = 0; i < s.size(); i++) { if (s[i] >= 65 && s[i] <= 90) s[i] = s[i] + 32; else if (s[i] >= ...
### Prompt Develop a solution in Cpp to the problem described below: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> using namespace std; string s; void ReadInput() { cin >> s; } bool check(string s) { for (int i = 1; i < s.size(); i++) { if (s[i] >= 97) return false; } return true; } void Solve() { if (check(s)) { for (int i = 0; i < s.size(); i++) { if (s[i] < 97) s[i] += 32; ...
### Prompt In Cpp, your task is to solve the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's cons...
#include <bits/stdc++.h> using namespace std; int main() { string a; int t = 0; getline(cin, a); for (int i = 0; i < a.length(); i++) { if (a[i] >= 97 && i != 0) { t = 1; } } if (t == 1) cout << a; else { for (int i = 0; i < a.length(); i++) { a[i] ^= 32; } cout << a; ...
### Prompt In CPP, your task is to solve the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's cons...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, e, f, g, h, i, j, k; string A; ios::sync_with_stdio(false); cin.tie(0); getline(cin, A); a = A.length(); d = 1; for (b = 1; b < a; b++) { c = A[b]; if (c >= 65 and c <= 90) continue; else { d = 0; br...
### Prompt Please formulate a CPP solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> using namespace std; int main() { string a; cin >> a; bool flag = true; for (int i = 1; i < a.length(); i++) { if (islower(a[i])) { flag = 0; } if (!flag) { break; } } if (!flag && a.length() > 1) { cout << a; } else { for (int i = 0; i < a.leng...
### Prompt Your task is to create a CPP solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. ...
#include <bits/stdc++.h> using namespace std; int main() { char a[101]; int i; int flag; scanf("%s", &a); flag = 0; if (a[1] == '\0') { if (a[0] >= 'a' && a[0] <= 'z') { a[0] = a[0] - 32; } else if (a[0] >= 'A' && a[0] <= 'Z') { a[0] = a[0] + 32; } printf("%c\n", a[0]); } else ...
### Prompt Your challenge is to write a Cpp solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passag...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int l = s.length(); bool p = false, q = false; for (int i = 0; i < l; i++) { if (s[i] >= 'a' && s[i] <= 'z') { p = true; break; } } if (s[0] >= 'a' && s[0] <= 'z') { q = true; } bool z = false; if ...
### Prompt Generate a cpp solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's conside...
#include <bits/stdc++.h> using namespace std; const int INF = 1000 * 1000 * 1000; const long double EPS = 1e-10; const int MAX = 1000 * 1000; const int MOD = 1000; int main() { string s, gl = "aoyeui", ans = ""; cin >> s; int n = int(s.length()); bool is_caps = true; for (int i = 1; i < n; i++) { if ('A' ...
### Prompt Please create a solution in cpp to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> int main() { int i; char st[101] = {'\0'}; scanf("%s", st); for (int i = 1; st[i] != '\0'; i++) { if (st[i] >= 'a' && st[i] <= 'z') { printf("%s", st); return 0; } } for (int i = 0; st[i] != '\0'; i++) printf("%c", st[i] ^ 32); }
### Prompt In CPP, your task is to solve the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's cons...
#include <bits/stdc++.h> using namespace std; int main() { char ar[100]; int len, count = 0, i, j; gets(ar); len = strlen(ar); if (isupper(ar[0]) && islower(ar[1])) { cout << ar; } else { for (i = 0; ar[i] != '\0'; i++) { if (isupper(ar[i])) { count++; } } if (len == 1) {...
### Prompt Please create a solution in CPP to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> int main() { int i, flag = 1; char s[105]; scanf("%s", &s); for (i = 1; i < strlen(s); i++) { if (s[i] >= 97) { flag = 0; break; } } if (flag) { for (i = 0; i < strlen(s); i++) { if (s[i] < 97) { s[i] = s[i] + 32; } else { s[i] = s...
### Prompt Please create a solution in CPP to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int cl = 0, cu = 0; for (int i = 0; i < s.length(); i++) { if (isupper(s[i])) cu++; else cl++; } if (cl == 0) { for (int i = 0; i < s.length(); i++) s[i] = tolower(s[i]); } else if (cl == 1 && cu == s.le...
### Prompt Please create a solution in CPP to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's...
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k, a, b, c, n, t, f, d; string s, v; map<char, int> ma, sa; vector<int> vv; map<char, int>::iterator it, ki; cin >> s; f = 0; c = 0; for (j = 0; j < s.size(); j++) { if ((s[j] >= 'A' && s[j] <= 'Z')) { c++; } } if (...
### Prompt Your task is to create a CPP solution to the following problem: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. ...