text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; int n, a, b, x[101], y[101], s; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a >> b; x[b]++; y[a]++; } for (int i = 1; i <= 100; i++) s = s + x[i] * y[i]; cout << s; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, counter = 0; cin >> n; int arr[n][2]; for (int i = 0; i < n; i++) { for (int j = 0; j < 2; j++) { cin >> arr[i][j]; } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (arr[i][0] == arr[j][1]) counter++; } } cout << counter; return 0; }
#include <bits/stdc++.h> using namespace std; int k, n, p; int a[1000], b[1000]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i] >> b[i]; p = 1; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) if (a[i] == b[j]) { k++; } } cout << k; return 0; }
#include <bits/stdc++.h> using namespace std; int32_t main() { long long n; cin >> n; map<long long, long long> home_freq; map<long long, long long> away_freq; for (long long i = 0; i < n; i++) { long long x, y; cin >> x >> y; home_freq[x]++; away_freq[y]++; } long long sum = 0; for (auto x : away_freq) { long long freq = home_freq[x.first]; if (freq != 0) { sum += freq * x.second; } } cout << sum; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int arr1[n], arr2[n]; for (int i = 0; i < n; i++) { cin >> arr1[i] >> arr2[i]; } int cnt = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) if (arr1[i] == arr2[j]) cnt++; } cout << cnt << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int x[33], y[33]; int main() { int n; cin >> n; for (int i = 0; i < n; ++i) { cin >> x[i] >> y[i]; } int ans = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (i == j) continue; if (x[i] == y[j]) ans++; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; inline void boost() { ios_base::sync_with_stdio(0); cin.tie(0); } template <typename T> void print(T x, char space = ' ', char end = '\n') { for (auto& i : x) cout << i << space; cout << end; } int main() { boost(); int n; cin >> n; vector<int> a(n), b(n); for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } int s = 0; for (int i = 0; i < n; i++) { s += count(b.begin(), b.end(), a[i]); } cout << s; return 0; }
#include <bits/stdc++.h> using namespace std; void initialMethod(); int main() { int teams = 0; int answer = 0; cin >> teams; int colorArr[teams][2]; for (int i = 0; i < teams; i++) { cin >> colorArr[i][0] >> colorArr[i][1]; } for (int i = 0; i < teams; i++) { for (int k = 0; k < teams; k++) { if (k == i) continue; if (colorArr[i][0] == colorArr[k][1]) answer++; } } cout << answer << endl; return 0; } void initialMethod() { int teams; int currentArrayIndex = 0; cin >> teams; int teamsColor[teams * 2]; int totalCount = 0; int arrSize; for (int i = 0; i < teams; i++) { for (int j = 0; j < 2; j++) { cin >> teamsColor[currentArrayIndex]; currentArrayIndex++; } } arrSize = sizeof(teamsColor) / sizeof(teamsColor[0]); for (int i = 0; i < arrSize; i++) { if (i % 2 == 0) { for (int k = 0; k < arrSize; k++) { if (k % 2 != 0) { if (teamsColor[k] == teamsColor[i]) totalCount++; } } } } cout << totalCount; }
#include <bits/stdc++.h> int main() { int n; scanf("%d", &n); int h[n], g[n]; for (int i(0); i < n; i++) { scanf("%d%d", &h[i], &g[i]); } int ans(0); for (int i(0); i < n; i++) { for (int j(i + 1); j < n; j++) { if (h[i] == g[j]) ans++; if (g[i] == h[j]) ans++; } } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, ans = 0; cin >> n; int h[n], a[n]; for (int i = 0; i < n; i++) cin >> h[i] >> a[i]; for (int i = 0; i < n - 1; i++) { for (int j = i + 1; j < n; j++) { if (h[i] == a[j]) ans++; } } for (int i = n - 1; i > 0; i--) { for (int j = i - 1; j >= 0; j--) { if (h[i] == a[j]) ans++; } } cout << ans; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> home, guest; int h, g, i, count = 0; for (i = 0; i < n; i++) { cin >> h >> g; home.push_back(h); guest.push_back(g); } vector<int>::iterator h1 = home.begin(); vector<int>::iterator g1 = guest.begin(); while (h1 != home.end()) { g1 = guest.begin(); while (g1 != guest.end()) { if (*h1 == *g1) count++; g1++; } h1++; } cout << count << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; int ans = 0; cin >> n; vector<int> a(n), b(n); for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i != j && a[i] == b[j]) ans++; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int a[520], b[520], c[520]; int main() { int n, i, j; cin >> n; int x, d = 0, g = 0; x = 2 * n; for (i = 0; i < x; i++) { cin >> a[i]; if (i % 2 == 0) { b[g] = a[i]; g++; } else { c[d] = a[i]; d++; } } int count = 0; for (i = 0; i < g; i++) { for (j = 0; j < d; j++) { if (b[i] == c[j]) count++; } } cout << count << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int **teams = new int *[n]; for (int i = 0; i < n; teams[i] = new int[2], i++) ; for (int i = 0; i < n; cin >> teams[i][0] >> teams[i][1], i++) ; int count = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (teams[i][0] == teams[j][1]) count++; if (teams[i][1] == teams[j][0]) count++; } } cout << count; }
#include <bits/stdc++.h> using namespace std; int main(void) { int n; cin >> n; int h[n], g[n], i, j; for (i = 0; i < n; i++) { cin >> h[i] >> g[i]; } int tot = 0; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { if (h[i] == g[j]) tot++; } } cout << tot; return 0; }
#include <bits/stdc++.h> int main() { int n; scanf("%d", &n); int arr[n][2], *pt2, (*pt1)[2]; pt1 = arr; pt2 = arr[2]; for (int i = 0; i < n; i++) { pt2 = (int*)pt1; scanf("%d", (pt2 + 0)); printf(" "); scanf("%d", (pt2 + 1)); pt1++; } pt1 = arr; int cnt = 0, tem1 = 0, tem2 = 0; int(*pt11)[2]; pt11 = arr; for (int j = 0; j < n - 1; j++) { pt2 = (int*)pt1; tem1 = *(pt2 + 1); pt11 = pt1; for (int k = j + 1; k < n; k++) { pt11++; pt2 = (int*)pt11; tem2 = *(pt2 + 0); if (tem1 == tem2) { cnt++; } } pt1++; } for (int j = n - 1; j >= 0; j--) { pt2 = (int*)pt1; tem1 = *(pt2 + 1); pt11 = pt1; for (int k = j - 1; k >= 0; k--) { pt11--; pt2 = (int*)pt11; tem2 = *(pt2 + 0); if (tem1 == tem2) { cnt++; } } pt1--; } printf("%d\n", cnt); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, l = 0; cin >> n; int a[n], b[n]; for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i] == b[j]) { l++; } } } cout << l; }
#include <bits/stdc++.h> using namespace std; int main() { int n, ar1[40], ar2[40]; int t = 0; cin >> n; for (int i = 0; i < n; i++) cin >> ar1[i] >> ar2[i]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (ar1[i] == ar2[j]) t++; } } cout << t << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[100]; for (int i = 0; i < 2 * n; i++) { cin >> a[i]; } int count = 0; int x; for (int i = 0; i < 2 * n; i += 2) { x = i + 3; for (x; x < 2 * n; x += 2) { if (a[i] == a[x]) count++; } } int y; for (int i = 1; i < 2 * n; i += 2) { y = i + 1; for (y; y < 2 * n; y += 2) { if (a[i] == a[y]) count++; } } cout << count << endl; return 0; }
#include <bits/stdc++.h> using namespace std; struct tform { int h, g; }; int main() { int n, i, j, k; tform a[30]; cin >> n; for (i = 0; i < n; i++) cin >> a[i].h >> a[i].g; k = 0; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { if (a[i].h == a[j].g) k++; } } cout << k; return 0; }
#include <bits/stdc++.h> using namespace std; struct t { int h; int g; t() {} t(int a, int b) { h = a; g = b; } }; int main() { int n; t a[50]; cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i].h; cin >> a[i].g; } int sum = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (a[i].h == a[j].g && i != j) { sum++; } } } cout << sum; return 0; }
#include <bits/stdc++.h> using namespace std; const long long mod7 = 1000000007; long long GCD(long long a, long long b) { return b == 0 ? a : GCD(b, a % b); } long long A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z; long long temp; char tempChar; string tempString; vector<int> homeColors; vector<int> guestColors; int main() { cin >> N; for (long long j = 0; j < N; j++) { cin >> A >> B; homeColors.push_back(A); guestColors.push_back(B); } for (long long i = 0; i < N; i++) { for (long long j = 0; j < N; j++) { if (homeColors[i] == guestColors[j] && i != j) S++; } } cout << S << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, cnt = 0; cin >> n; vector<int> A(n); vector<int> B(n); for (int i = 0; i < n; i++) { cin >> A[i] >> B[i]; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i != j) { if (A[i] == B[j]) { cnt++; } } } } cout << cnt; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, count = 0; cin >> n; int p[n], q[n]; for (int i = 0; i < n; i++) { cin >> p[i]; cin >> q[i]; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i != j && p[i] == q[j]) count++; } } cout << count << endl; }
#include <bits/stdc++.h> const int INF = (int)1e9; const double PI = acos(-1.); using namespace std; int n, ans, a[105], b[105]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i] >> b[i]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (i != j) if (b[i] == a[j]) ans++; cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int *h, *g, n = 0, countx = 0; cin >> n; h = new int[n]; g = new int[n]; for (int i = 0; i < n; i++) { cin >> h[i] >> g[i]; } for (int i = 0; i < n; i++) for (int a = 0; a < n; a++) if (g[i] == h[a]) countx++; cout << countx << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int arr[30][2], n, cnt = 0; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cin >> n; for (int i = 1; i <= n; i++) cin >> arr[i][1] >> arr[i][2]; for (int i = 1; i <= n - 1; i++) { for (int j = i + 1; j <= n; j++) { if (arr[i][1] == arr[j][2]) cnt++; if (arr[i][2] == arr[j][1]) cnt++; } } cout << cnt; }
#include <bits/stdc++.h> using namespace std; int main() { int c = 0; int n; cin >> n; int **a; a = (int **)malloc(sizeof(int *) * n); for (int i = 0; i < n; i++) { a[i] = (int *)malloc(sizeof(int) * 2); cin >> a[i][0] >> a[i][1]; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if ((i == j) && (j < n - 1)) { j++; } if ((i == j) && (j == n - 1)) { break; } if (a[i][0] == a[j][1]) { c++; } } } cout << c; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, count = 0; cin >> n; int arr[n][2]; for (int i = 0; i < n; i++) { cin >> arr[i][0] >> arr[i][1]; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (arr[i][1] == arr[j][0]) { count++; } } } cout << count; }
#include <bits/stdc++.h> using namespace std; int color[60]; int main() { int num = 0, c = 0; cin >> num; for (int i = 0; i < 2 * num; i++) { cin >> color[i]; } for (int i = 0; i < (2 * num) - 2; i++) { for (int j = 0; j <= num - 2; j++) { if (i % 2 == 0) { if (color[i] == color[i + 3 + (2 * j)]) { c++; } } else { if (color[i] == color[i + 1 + (2 * j)]) { c++; } } } } cout << c; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { pair<int, int> p[35]; int n, a, b, ans = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b; p[i] = make_pair(a, b); } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (p[i].first == p[j].second) ans++; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int teams; int currentArrayIndex = 0; cin >> teams; int teamsColor[teams * 2]; for (int i = 0; i < teams; i++) { for (int j = 0; j < 2; j++) { cin >> teamsColor[currentArrayIndex]; currentArrayIndex++; } } int arrSize = sizeof(teamsColor) / sizeof(teamsColor[0]); int lastTeamColor[2] = {teamsColor[0], teamsColor[1]}; int totalCount = 0; for (int i = 0; i < arrSize; i++) { if (i % 2 == 0) { for (int k = 0; k < arrSize; k++) { if (k % 2 != 0) { if (teamsColor[k] == teamsColor[i]) totalCount++; } } lastTeamColor[0] = teamsColor[i - 1]; lastTeamColor[1] = teamsColor[i]; } } cout << totalCount; }
#include <bits/stdc++.h> using namespace std; int main() { int n, b = 0; cin >> n; int a[n][2]; vector<int> h; vector<int> a1; for (int i = 0; i < n; i++) { for (int j = 0; j < 2; j++) { cin >> a[i][j]; if (j % 2 != 0) a1.push_back(a[i][j]); else h.push_back(a[i][j]); } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i != j && h[i] == a1[j]) b++; } } cout << b; }
#include <bits/stdc++.h> using namespace std; int main() { int a, ans(0); scanf("%d", &a); vector<int> home(a), guest(a); for (int i = 0; i < a; ++i) { cin >> home[i] >> guest[i]; for (int j = 0; j < i; j++) { if ((home[i] == guest[j])) ++ans; if (home[j] == guest[i]) ++ans; } } cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, count = 0; cin >> n; pair<int, int> teams[n]; for (int i = 0; i < n; i++) { cin >> teams[i].first >> teams[i].second; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i != j) { if (teams[i].first == teams[j].second) { count++; } } } } cout << count << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int a, i, j = 0, s = 0; cin >> a; long long int b[a], c[a]; for (i = 0; i < a; i++) { cin >> b[i] >> c[j]; j++; } for (i = 0; i < a; i++) { for (j = 0; j < a; j++) { if (b[i] == c[j]) { s++; } } } cout << s; }
#include <bits/stdc++.h> using namespace std; int main() { int n, counter = 0; cin >> n; int arr1[n], arr2[n]; for (int x = 0; x < n; x++) { cin >> arr1[x] >> arr2[x]; } for (int x = 0; x < n; x++) { for (int y = 0; y < n; y++) { if (arr1[x] == arr2[y]) counter++; } } cout << counter << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, p[1001], q[1111], sum = 0; cin >> n; for (int i = 1; i <= n; i++) cin >> p[i] >> q[i]; for (int j = 1; j <= n; j++) for (int i = 1; i <= n; i++) { if (p[i] == q[j] && i != j) sum++; } cout << sum; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int h[n], a[n]; int x = 0; for (int i = 0; i < n; i++) { cin >> h[i] >> a[i]; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i != j) { if (a[i] == h[j]) { x++; } } } } cout << x << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<pair<int, int>> teams(n, make_pair(0, 0)); int sum = 0; for (int i = 0; i < n; i++) cin >> teams[i].first >> teams[i].second; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (teams[i].first == teams[j].second && i != j) sum++; } } cout << sum << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int teams; int host_uniforms[50]; int guest_uniforms[50]; scanf("%d", &teams); for (int i = 0; i < teams; i++) { scanf("%d %d", &host_uniforms[i], &guest_uniforms[i]); } int htwgu = 0; for (int i = 0; i < teams; i++) { for (int j = 0; j < teams; j++) if (host_uniforms[i] == guest_uniforms[j]) { htwgu++; } } cout << htwgu << endl; return 0; }
#include <bits/stdc++.h> int main() { int a, b1[40][2], i, j, t; while (scanf("%d", &a) != EOF) { t = 0; for (i = 0; i < a; i++) for (j = 0; j < 2; j++) { scanf("%d", &b1[i][j]); } for (i = 0; i < a; i++) { for (j = 0; j < a; j++) { if (i == j) continue; if (b1[i][0] == b1[j][1]) t++; } } printf("%d\n", t); } }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = double; using pi = pair<int, int>; using pl = pair<ll, ll>; using pd = pair<ld, ld>; using cd = complex<ld>; using vcd = vector<cd>; using vi = vector<int>; using vl = vector<ll>; using vd = vector<ld>; using vs = vector<string>; using vpi = vector<pi>; using vpl = vector<pl>; using vpd = vector<pd>; template <class T> using min_pq = priority_queue<T, vector<T>, greater<T> >; template <class T> inline int ckmin(T& a, const T& val) { return val < a ? a = val, 1 : 0; } template <class T> inline int ckmax(T& a, const T& val) { return a < val ? a = val, 1 : 0; } template <class T> void remDup(vector<T>& v) { sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), end(v)); } constexpr int pct(int x) { return __builtin_popcount(x); } constexpr int bits(int x) { return x == 0 ? 0 : 31 - __builtin_clz(x); } constexpr int p2(int x) { return 1 << x; } constexpr int msk2(int x) { return p2(x) - 1; } ll ceilDiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); } ll floorDiv(ll a, ll b) { return a / b - ((a ^ b) < 0 && a % b); } void setPrec(int x) { cout << fixed << setprecision(x); } string to_string(char c) { return string(1, c); } string to_string(const char* s) { return (string)s; } string to_string(string s) { return s; } string to_string(bool b) { return to_string((int)b); } template <class T> string to_string(complex<T> c) { stringstream ss; ss << c; return ss.str(); } template <class T> using V = vector<T>; string to_string(V<bool> v) { string res = "{"; for (int i = (0); i <= (int((v).size()) - 1); i++) res += char('0' + v[i]); res += "}"; return res; } template <size_t sz> string to_string(bitset<sz> b) { string res = ""; for (int i = (0); i <= (int((b).size()) - 1); i++) res += char('0' + b[i]); return res; } template <class T, class U> string to_string(pair<T, U> p); template <class T> string to_string(T v) { bool fst = 1; string res = ""; for (const auto& x : v) { if (!fst) res += " "; fst = 0; res += to_string(x); } return res; } template <class T, class U> string to_string(pair<T, U> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } template <class T> void pr(T x) { cout << to_string(x); } template <class T, class... U> void pr(const T& t, const U&... u) { pr(t); pr(u...); } void ps() { pr("\n"); } template <class T, class... U> void ps(const T& t, const U&... u) { pr(t); if (sizeof...(u)) pr(" "); ps(u...); } void DBG() { cerr << "]" << endl; } template <class T, class... U> void DBG(const T& t, const U&... u) { cerr << to_string(t); if (sizeof...(u)) cerr << ", "; DBG(u...); } const ld PI = acos(-1.0); const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; const ld EPS = 1e-9; const ll MODBASE = 1000000007LL; const int INF = 0x3f3f3f3f; const int MAXN = 100005; const int MAXM = 1000; const int MAXK = 16; const int MAXQ = 200010; int n, res = 0, a[35], b[35]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i] >> b[i]; } for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) if (i != j) { if (a[i] == b[j]) res++; } cout << res; }
#include <bits/stdc++.h> using namespace std; int main() { int x, cnt = 0; cin >> x; int arr1[x], arr2[x]; for (int i = 0; i < x; i++) { cin >> arr1[i] >> arr2[i]; } for (int i = 0; i < x; i++) { for (int j = 0; j < x; j++) { if (i == j) { continue; } if (arr1[i] == arr2[j]) { cnt++; } } } cout << cnt; }
#include <bits/stdc++.h> int main() { int n, h[30 + 1], a[30 + 1], ans = 0; std::scanf("%d", &n); for (int i = 1; i <= n; ++i) std::scanf("%d %d", &h[i], &a[i]); for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) if (i != j && h[i] == a[j]) ++ans; std::printf("%d\n", ans); }
#include <bits/stdc++.h> using namespace std; int main() { int n; int sum = 0; cin >> n; int a[n]; int b[n]; for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } for (int j = 0; j < n; j++) { for (int i = j; i < n; i++) { if (a[j] == b[i + 1]) { sum++; } if (b[j] == a[i + 1]) { sum++; } } } cout << sum; return 0; }
#include <bits/stdc++.h> using namespace std; template <typename T> int size(T& a) { return (int)a.size(); } template <typename T> T sqr(T a) { return a * a; } bool isLowercase(char ch) { return ch >= 'a' && ch <= 'z'; } bool isUppercase(char ch) { return !isLowercase(ch); } char toLowercase(char ch) { if (isUppercase(ch)) { ch = ch - 'A' + 'a'; } return ch; } char toUppercase(char ch) { if (isLowercase(ch)) { ch = ch - 'a' + 'A'; } return ch; } int main() { string s; int n; cin >> s >> n; for (int i = (0); i < (size(s)); ++i) { s[i] = toLowercase(s[i]); } for (int i = (0); i < (size(s)); ++i) { if (int(s[i]) < n + 97) { s[i] = toUppercase(s[i]); } } cout << s << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s27; int n16; cin >> s27 >> n16; for (int i = 0; i < s27.size(); i++) { char c = s27[i]; int d = 0; if (c >= 'a' && c <= 'z') d = c - 'a'; else d = c - 'A'; if (d + 'a' < n16 + 97) s27[i] = 'A' + d; else s27[i] = 'a' + d; } cout << s27; }
#include <bits/stdc++.h> using namespace std; const int maxn = 10; void close() { exit(0); } void init() { char s[200]; scanf("%s", s); int n, l; l = strlen(s); scanf("%d", &n); for (int i = 0; i < l; i++) if (s[i] < 97) s[i] += 32; for (int i = 0; i < l; i++) if (s[i] > 96 + n) printf("%c", s[i]); else if (s[i] > 96) printf("%c", s[i] - 32); else printf("%c", s[i]); } int main() { init(); close(); return 0; }
#include <bits/stdc++.h> using namespace std; int i, m, ans, k, l, j, q, x, n, ma, mi; string s; int main() { i = 0; cin >> s; cin >> x; for (i = 0; i < s.size(); i++) if (s[i] <= 'Z') s[i] += 'a' - 'A'; for (i = 0; i < s.size(); i++) { if (s[i] < x + 97) if (s[i] > 'Z') s[i] += 'A' - 'a'; else if (s[i] <= 'Z') s[i] += 'a' - 'A'; } cout << s << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string str; int n; cin >> str >> n; for (int i = 0; i < str.size(); ++i) { if (str[i] >= 'A' && str[i] <= 'Z') { if (str[i] - 'A' >= n) str[i] = str[i] - 'A' + 'a'; } else { if (str[i] - 'a' < n) str[i] = str[i] - 'a' + 'A'; } } cout << str; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string tmp; int n; cin >> tmp >> n; for (int i = 0; i < tmp.length(); i++) { if ((tmp[i] >= 'a') && ((tmp[i] < ('a' + n)))) tmp[i] = (tmp[i] - 'a') + 'A'; else if ((tmp[i] >= 'A' + n) && ((tmp[i] <= ('Z')))) tmp[i] = (tmp[i] - 'A') + 'a'; } cout << tmp; return 0; }
#include <bits/stdc++.h> using namespace std; string s1; int x; int main() { cin >> s1; scanf("%d", &x); for (int i = 0, len = s1.length(); i < len; i++) { if (s1[i] < 'a') s1[i] = s1[i] - 'A' + 'a'; int c = s1[i]; int tmp = c; if ('A' <= c && c <= 'Z') tmp -= 'A'; else tmp -= 'a'; if (c < x + 97) { putchar(tmp + 'A'); } else putchar(tmp + 'a'); } puts(""); return 0; }
#include <bits/stdc++.h> using namespace std; string lower(string s) { for (int i = 0; i < int(s.size()); i++) s[i] |= 32; return s; } int main() { string s, ans; int x, y; cin >> s >> x; s = lower(s); for (int i = 0; i < int(s.size()); i++) { y = s[i]; if (y < x + 97) { ans = ans + char(y & ~32); } else { ans = ans + char(y | 32); } } puts(ans.c_str()); }
#include <bits/stdc++.h> using namespace std; int main() { char s[101]; int n; cin >> s >> n; int len = strlen(s); for (int i = 0; i < len; i++) { if (tolower(s[i]) < n + 97) s[i] = toupper(s[i]); else s[i] = tolower(s[i]); } cout << s << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int n; cin >> s >> n; for (int i = 0; i < s.size(); i++) { if (s[i] <= 'Z') s[i] += 32; if (s[i] < 'a' + n) s[i] -= 32; } cout << s; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int n; cin >> s >> n; for (int i = 0; i < s.length(); i++) { int cn = s.at(i); if (cn >= 97) { if (cn - 'a' + 1 <= n) printf("%c", cn - 'a' + 'A'); else printf("%c", cn); } else { if (cn - 'A' + 1 > n) printf("%c", cn + 'a' - 'A'); else printf("%c", cn); } } printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; string s; int k; int main() { cin >> s >> k; for (int i = 0; i < s.size(); i++) { if (s[i] - 'a' >= 0 && s[i] - 'a' < k) s[i] = toupper(s[i]); if (s[i] - 'A' >= k && s[i] - 'A' < 26) s[i] = tolower(s[i]); } cout << s << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; int n; cin >> n; for (int i = 0; i < s.size(); i++) { s[i] = tolower(s[i]); } string ans = ""; for (int i = 0; i < s.size(); i++) { int m = s[i]; if (m < n + 97) { ans += toupper(s[i]); } else { ans += s[i]; } } cout << ans; }
#include <bits/stdc++.h> using namespace std; const int intmax = 0x3f3f3f3f; const long long lldmax = 0x3f3f3f3f3f3f3f3fll; double eps = 1e-8; template <class T> inline void checkmin(T &a, T b) { if (b < a) a = b; } template <class T> inline void checkmax(T &a, T b) { if (b > a) a = b; } template <class T> inline T sqr(T x) { return x * x; } template <class T> inline T lowbit(T n) { return (n ^ (n - 1)) & n; } template <class T> inline int countbit(T n) { return (n == 0) ? 0 : (1 + countbit(n & (n - 1))); } template <class T> inline T checkmod(T n, T m) { return (n % m + m) % m; } template <class T> inline T gcd(T a, T b) { if (a < 0) return gcd(-a, b); if (b < 0) return gcd(a, -b); return (b == 0) ? a : gcd(b, a % b); } template <class T> inline T euclid(T a, T b, T &x, T &y) { if (a < 0) { T d = euclid(-a, b, x, y); x = -x; return d; } if (b < 0) { T d = euclid(a, -b, x, y); y = -y; return d; } if (b == 0) { x = 1; y = 0; return a; } else { T d = euclid(b, a % b, x, y); T t = x; x = y; y = t - (a / b) * y; return d; } } template <class T> inline int dblcmp(T a, const T b) { a -= b; return a > eps ? 1 : (a < -eps ? -1 : 0); } template <class T> inline int sgn(T a) { return a > eps ? 1 : (a < -eps ? -1 : 0); } int main() { char ch[100]; cin >> ch; int n; cin >> n; int a; for (int i = 0; ch[i]; ++i) { if (ch[i] >= 'a' && ch[i] <= 'z') { a = ch[i] - 'a'; } else { a = ch[i] - 'A'; } if (a < n) { ch[i] = a + 'A'; } else { ch[i] = a + 'a'; } } cout << ch << endl; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); string H = ""; string s; int num; cin >> s >> num; for (unsigned int i = 0; i < s.size(); i++) { if ((int)tolower(s[i]) < num + 97) H += (toupper(s[i])); else H += (tolower(s[i])); cout << H[i]; } }
#include <bits/stdc++.h> using namespace std; int a; string s; int main() { cin >> s >> a; for (int i = 0; i < s.size(); i++) s[i] = tolower(s[i]); for (int i = 0; i < s.size(); i++) if (s[i] - 'a' < a) s[i] = toupper(s[i]); cout << s << endl; return 0; }
#include <bits/stdc++.h> using namespace std; char s[5050]; int n, k; int main() { scanf("%s", &s); scanf("%d", &k); n = strlen(s); for (int i = 0; i < n; ++i) if (('A' <= s[i]) && (s[i] <= 'Z')) { if (s[i] - 'A' < k) printf("%c", s[i]); else printf("%c", s[i] - 'A' + 'a'); } else { if (s[i] - 'a' < k) printf("%c", s[i] - 'a' + 'A'); else printf("%c", s[i]); } puts(""); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, i; string str; cin >> str >> n; for (i = 0; i < str.size(); i++) { if (tolower(str[i]) < n + 97) { str[i] = toupper(str[i]); } else str[i] = tolower(str[i]); } cout << str; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); string s, ans; int n, i, j, k, x, r; cin >> s >> r; n = s.length(); ans = s; for (i = 0; i < n; i++) { if (s[i] >= 'a') x = s[i] - 'a'; else x = s[i] - 'A'; if (x < r) ans[i] = 'A' + x; else ans[i] = 'a' + x; } cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int num; while (cin >> s >> num) { transform(s.begin(), s.end(), s.begin(), ::tolower); for (int i = 0; i < s.size(); ++i) if (s[i] < 97 + num) s[i] = toupper(s[i]); else s[i] = tolower(s[i]); cout << s << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { string str, res; int num; int t; cin >> str; cin >> num; for (int i = 0; i < str.size(); i++) { if (str[i] <= 'z' && str[i] >= 'a') ; else str[i] -= ('A' - 'a'); } for (int i = 0; i < str.size(); i++) { t = str[i]; if (t < num + 97) res += t + 'A' - 'a'; else res += t; } cout << res; return 0; }
#include <bits/stdc++.h> using namespace std; void toLower(string& str) { int offset = 'a' - 'A'; for (int i = 0; i < str.length(); i++) { char c = str[i]; if ('A' <= c && c <= 'Z') { str[i] = c + offset; } } } int main() { string str; int x; cin >> str >> x; toLower(str); string res = ""; int n = str.length(); int offset = 'A' - 'a'; for (int i = 0; i < n; i++) { int c = str[i]; if (c < x + 97) { res += (c + offset); } else { res += c; } } cout << res << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string a; int n, i; cin >> a >> n; for (i = 0; i < a.length(); i++) { if (a[i] >= 'A' && a[i] <= 'Z') a[i] = a[i] - 'A' + 'a'; if (int(a[i]) < 97 + n) a[i] = a[i] - 'a' + 'A'; } cout << a; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string s, ans; cin >> s; scanf("%d", &n); for (int i = 0; i < s.size(); i++) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a'; for (int i = 0; i < s.size(); i++) { char c = s[i]; if (c < n + 97) ans += c - 'a' + 'A'; else ans += c; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { char r[55]; int y = 0; scanf("%s", r); scanf("%d", &y); for (int i = 0; r[i] != '\0'; i++) { if (tolower(r[i]) < y + 97) { r[i] = toupper(r[i]); } else r[i] = tolower(r[i]); } cout << r << endl; return 0; }
#include <bits/stdc++.h> using namespace std; char s1[] = {'0', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}; int main() { int n; string s; cin >> s; cin >> n; for (int i = 0; i < s.size(); i++) if (s[i] >= 'A' && s[i] <= 'Z') s[i] += 32; for (int i = 0; i < s.size(); i++) if (s[i] <= s1[n]) s[i] -= 32; cout << s; return 0; }
#include <bits/stdc++.h> char gao[100]; int x; int main() { scanf("%s", gao); scanf("%d", &x); for (int i = 0; i < strlen(gao); ++i) { int t; if (gao[i] >= 'A' && gao[i] <= 'Z') t = gao[i] - 'A'; else t = gao[i] - 'a'; if (t < x) printf("%c", t + 'A'); else printf("%c", t + 'a'); } puts(""); }
#include <bits/stdc++.h> using namespace std; int main() { string s, s2, s3; int n; cin >> s; cin >> n; s2 = ""; for (int i = 0; i < s.length(); i++) { if (s[i] >= 'a' && s[i] <= 'z') s2 += s[i]; else s2 += (s[i] + 'a' - 'A'); } s3 = ""; for (int i = 0; i < s.length(); i++) { if (s2[i] < n + 97) s3 += (s2[i] + 'A' - 'a'); else s3 += s2[i]; } cout << s3 << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, i; string s; cin >> s; scanf("%d", &n); for (i = 0; i < s.length(); i++) { if (s[i] < 97) s[i] += 32; if (s[i] < 'a' + n) s[i] -= 32; } cout << s << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int t; cin >> s >> t; for (int i = 0; i < s.size(); i++) { s[i] &= ~32; if (s[i] >= 'A' + t) { s[i] ^= 32; } } cout << s << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n; cin >> n; for (int i = 0; i < s.size(); i++) { int a = s[i]; if (a >= 'A' and a <= 'Z') a += 'a' - 'A'; if (a < n + 97) cout << char(a + 'A' - 'a'); else cout << char(a); } cout << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int x, sz; string str, ans = ""; cin >> str; cin >> x; sz = str.size(); for (int i = 0; i < sz; i++) { str[i] = tolower(str[i]); if (str[i] < x + 97) str[i] = toupper(str[i]); } cout << str << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i; string s; cin >> s >> n; for (i = 0; i < s.length(); i++) { if (s[i] < 97) s[i] += 32; if (s[i] < n + 97) s[i] -= 32; } cout << s; return 0; }
#include <bits/stdc++.h> using namespace std; char to_da(char c) { if (c >= 'A' && c <= 'Z') return c; else return c - 32; } char to_xiao(char c) { if (c >= 'A' && c <= 'Z') return c + 32; else return c; } int main() { string s; int a; while (cin >> s >> a) { int len = s.length(); for (int i = 0; i < len; i++) { s[i] = to_xiao(s[i]); if (s[i] < a + 97) s[i] = to_da(s[i]); else s[i] = to_xiao(s[i]); } cout << s << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int a; cin >> a; string out = ""; for (int i = 0; i < s.length(); i++) { if (tolower(s[i]) < a + 97) { out += toupper(s[i]); } else out += tolower(s[i]); } cout << out << endl; }
#include <bits/stdc++.h> using namespace std; string a, ans; int b; string c; int main() { while (cin >> a >> b) { for (int i = 0; i < a.size(); i++) if (a[i] >= 'A' && a[i] <= 'Z') a[i] = a[i] - 'A' + 'a'; for (int i = 0; i < a.size(); i++) { if ((int)a[i] < b + 97) { a[i] = a[i] - 'a' + 'A'; } } cout << a << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { char s[100]; int n; cin >> s >> n; for (int i = 0; i < strlen(s); i++) { if (s[i] >= 'A' && s[i] <= 'Z') { s[i] = s[i] + 32; } if (s[i] < n + 97) { s[i] = s[i] - 32; } } cout << s; return 0; }
#include <bits/stdc++.h> using namespace std; int n; string s; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> s >> n; for (auto i : s) { if (int(tolower(i) - 'a') < n) cout << char(toupper(i)); else cout << char(tolower(i)); } return 0; }
#include <bits/stdc++.h> using namespace std; char sc[100], c; string s, answer; int x, i; int main() { scanf("%s", sc); s = sc; for (i = 0; i < s.length(); i++) s[i] = tolower(s[i]); scanf("%d", &x); answer = ""; for (i = 0; i < s.length(); i++) { c = s[i]; if (c < x + 97) { answer += toupper(c); } else { answer += tolower(c); } } printf("%s\n", answer.c_str()); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; long long n; cin >> n; for (long long i = 0; i < s.size(); i++) s[i] = tolower(s[i]); string ans = ""; for (long long i = 0; i < s.size(); i++) { if (s[i] >= n + 97) ans += tolower(s[i]); else ans += toupper(s[i]); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); string s; cin >> s; string a(s); int n; cin >> n; for (int i = 0; i < int(s.size()); ++i) { if (isupper(s[i])) { s[i] -= 'A'; s[i] += 'a'; } if (s[i] < 'a' + n) { a[i] = s[i] - 'a' + 'A'; } else a[i] = s[i]; } cout << a; return 0; }
#include <bits/stdc++.h> using namespace std; char s[100]; int main() { int i, j; int n; while (scanf("%s", s) != EOF) { scanf("%d", &n); for (i = 0; i < strlen(s); i++) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] + 'a' - 'A'; for (i = 0; i < strlen(s); i++) if (s[i] < n + 97) { if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] + 'A' - 'a'; } printf("%s\n", s); } return 0; }
#include <bits/stdc++.h> using namespace std; vector<int> a[100005]; vector<int> c[100005]; int main() { string s; int n; cin >> s; cin >> n; for (int i = 0; i < s.length(); ++i) s[i] = tolower(s[i]); for (int i = 0; i < s.length(); ++i) { int p = (int)s[i]; if (p < (n + 97)) s[i] = toupper(s[i]); else s[i] = tolower(s[i]); } cout << s; return 0; }
#include <bits/stdc++.h> const double pi = 3.1415926535897932384626433832795; double EPS = 10e-6; const int INF = 2000000000; long long gcd(long long a, long long b) { if (a == 0) return b; return gcd(b % a, a); } using namespace std; void ifd() {} void tme() {} string s, ans; int n; int main() { ifd(); cin >> s >> n; for (int i = (0); i < (s.size()); ++i) if (s[i] >= 'A' && s[i] <= 'Z') s[i] += 32; for (int i = (0); i < (s.size()); ++i) { if ((int)(s[i]) < n + 97) { ans += (s[i] - 32); } else { ans += s[i]; } } cout << ans << endl; tme(); return 0; }
#include <bits/stdc++.h> using namespace std; string ToLower(string sOrigin) { string ans(""); long i; for (i = 0; i <= sOrigin.length() - 1; ++i) { if (sOrigin[i] >= 'A' && sOrigin[i] <= 'Z') ans += char(sOrigin[i] + ('a' - 'A')); else ans += sOrigin[i]; } return ans; } int main() { ios::sync_with_stdio(false); string sOrig; int iNum, iLength, i; getline(cin, sOrig); cin >> iNum; iLength = sOrig.length() - 1; sOrig = ToLower(sOrig); for (i = 0; i <= iLength; ++i) { if (sOrig[i] < 'a' + iNum) sOrig[i] = sOrig[i] + 'A' - 'a'; } cout << sOrig; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> s >> n; for (typeof(0) i = (0); i < (((int)(s).size())); ++i) s[i] = tolower(s[i]); string ans; for (int i = 0; i < ((int)(s).size()); ++i) { char ch = s[i]; if (ch < n + 97) ans += toupper(ch); else ans += tolower(ch); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int a; cin >> s >> a; transform(s.begin(), s.end(), s.begin(), ::tolower); char c = (char)('a' + a); for (int i = 0; i < s.size(); i++) { if (s[i] < c) s[i] = toupper(s[i]); else s[i] = tolower(s[i]); } cout << s << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int x; cin >> s >> x; for (int i = 0; i < s.size(); ++i) { char c = tolower(s[i]); if (c < x + 97) cout << (char)toupper(c); else cout << (char)tolower(c); } cout << endl; return 0; }
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:512000000") using namespace std; template <class T> inline T sqr(T x) { return x * x; } template <class T> inline string tostr(const T& x) { stringstream ss; ss << x; return ss.str(); } const double EPS = 1e-6; const int INF = 1000 * 1000 * 1000; const char CINF = 102; const long long LINF = INF * 1ll * INF; const long double PI = 3.1415926535897932384626433832795; int main() { string s; int a; cin >> s >> a; string r; for (int i = 0; i < (((int)(s).size())); ++i) { if (tolower(s[i]) < 'a' + a) r += toupper(s[i]); else r += tolower(s[i]); } cout << r; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { char c[51]; int n; scanf("%s", c); scanf("%d", &n); for (int i = 0; i < strlen(c); i++) { if (c[i] < 'a') c[i] += 'a' - 'A'; if (c[i] < 97 + n) c[i] += 'A' - 'a'; } printf("%s", c); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { char s[55]; int N, M; string ret; scanf("%s", s); scanf("%d", &N); M = strlen(s); for (int i = 0; i < M; i++) s[i] = tolower(s[i]); for (int i = 0; i < M; i++) { if (s[i] < N + 97) ret += toupper(s[i]); else ret += tolower(s[i]); } printf("%s\n", ret.c_str()); }
#include <bits/stdc++.h> using namespace std; int main() { string s; int n; cin >> s >> n; for (int i = 0; i < s.length(); i++) { if (s[i] < 'a') s[i] += 'a' - 'A'; if (s[i] - 'a' < n) s[i] -= 'a' - 'A'; } cout << s << endl; return 0; }
#include <bits/stdc++.h> using namespace std; char ma[100][100] = { "Washington", "Adams", "Jefferson", "Madison", "Monroe", "Adams", "Jackson", "Van Buren", "Harrison", "Tyler", "Polk", "Taylor", "Fillmore", "Pierce", "Buchanan", "Lincoln", "Johnson", "Grant", "Hayes", "Garfield", "Arthur", "Cleveland", "Harrison", "Cleveland", "McKinley", "Roosevelt", "Taft", "Wilson", "Harding", "Coolidge", "Hoover", "Roosevelt", "Truman", "Eisenhower", "Kennedy", "Johnson", "Nixon", "Ford", "Carter", "Reagan", "Bush", "Clinton"}; char s[100]; int main(int argc, char* argv[]) { std::ios::sync_with_stdio(false); int a; cin >> s; cin >> a; for (int i = 0; i < strlen(s); i++) { if (s[i] <= 90) s[i] = s[i] - 'A' + 'a'; if (s[i] < a + 97) s[i] = s[i] - 'a' + 'A'; } cout << s << endl; return 0; }
#include <bits/stdc++.h> const int maxn = 1010; char a[maxn]; int x, n; int main() { scanf("%s", a); scanf("%d", &x); n = strlen(a); for (int i = 0; i < n; i++) { if (a[i] > 96 && a[i] < 97 + x) a[i] -= 32; else { if (a[i] < 96 && a[i] >= 65 + x) a[i] += 32; } } printf("%s\n", a); return 0; }