<h1 class = "text-style"> SES0 </h1> <div style="color:green; font-size:150%;"><b>Challenge accepted</b></div> --- >**By NPDang** --- <h1 class = "text-style"> Bài tập </h1> <font size="5" color="cyan"><b>800-Elo Problems</b></font> :::spoiler <b>4A - Watermelon</b> --- https://codeforces.com/problemset/problem/4/A --- ![image](https://hackmd.io/_uploads/H1JOkMArxx.png) --- ```c= #include<stdio.h> int main() { int x; scanf("%d",&x); printf(x>2&&x%2==0?"YES":"NO"); } ``` --- <h1> Giải thích </h1> --- ::: :::spoiler <b>231A - Team</b> --- https://codeforces.com/problemset/problem/231/A --- ![image](https://hackmd.io/_uploads/SJ_eYKJrgg.png) --- ```cpp= #include <iostream> using namespace std; int main() { int n,br=0,count=0; bool b; cin>>n; for (int i=0; i<n;i++){ cin>>b; br+=b; cin>>b; br+=b; cin>>b; br+=b; count+=(br>=2); br=0; } cout<<count; } ``` --- ::: :::spoiler <b>71A - Way Too Long Words<b> --- https://codeforces.com/problemset/problem/71/A --- ![image](https://hackmd.io/_uploads/ryXmKFyBlx.png) --- ```cpp= #include <iostream> #include <string> using namespace std; int main() { string str; int n; cin>>n; for (size_t i = 0;i<n;i++) { cin>>str; if (str.length() > 10) cout<<str[0]<<str.length()-2<<str[str.length()-1]<<'\n'; else cout<<str<<'\n'; } } ``` --- ::: :::spoiler <b>A - Bit++</b> --- codeforces.com/problemset/problem/282/A --- ![image](https://hackmd.io/_uploads/rJg2OtJSgx.png) --- ``` cpp= #include <iostream> #include <string> using namespace std; int main() { short n, x = 0; cin >> n; string str; cin.ignore(); for (int i = 0; i < n; i++) { getline(cin, str); if (str.find("++") != string::npos) x++; else if (str.find("--") != string::npos) x--; } cout << x; } ``` --- ::: :::spoiler 158A - Next Round --- https://codeforces.com/problemset/problem/158/A --- ![image](https://hackmd.io/_uploads/ByIZUklBgx.png) --- ```cpp= #include <iostream> using namespace std; int main() { int n, k; cin>>n>>k; int scores[n]; for (int i=0;i<n;i++){ cin >> scores[i]; } int gioihan=scores[k-1]; int result=0; for (int i = 0; i < n; i++){ if (scores[i]>=gioihan&&scores[i]>0){ result++; } } cout << result << endl; return 0; } ``` --- ::: :::spoiler 50A - Domino piling --- https://codeforces.com/problemset/problem/50/A --- ![image](https://hackmd.io/_uploads/S1qUd1xrgl.png) --- ```cpp= #include <iostream> using namespace std; int main() { int a,b; cin>>a>>b; cout<<(a*b)/2; return 0; } ``` --- ::: :::spoiler 263A - Beautiful Matrix --- https://codeforces.com/problemset/problem/263/A --- ![image](https://hackmd.io/_uploads/S1WNCJxrle.png) --- ```cpp= #include <iostream> #include <cmath> using namespace std; int main() { int num, result; for (int i = 1; i <= 5; i++) { for (int j=1; j<=5;j++){ cin>>num; if (num){ result=abs(3-i)+abs(3-j); cout<<result; } } } } ``` --- ::: :::spoiler 112A - Petya and Strings --- https://codeforces.com/problemset/problem/112/A --- ![image](https://hackmd.io/_uploads/SJhqzlerll.png) --- ```cpp= #include <iostream> #include <string> #include <cctype> using namespace std; int main() { string str,str2; cin>>str>>str2; for(int i =0; i<str.length();i++){ if (tolower(str.at(i))!=tolower(str2.at(i))) { cout<<(tolower(str.at(i))>tolower(str2.at(i))?1:-1); return 0; } } cout<<0; } ``` --- ::: :::spoiler 339A - Helpful Maths --- https://codeforces.com/problemset/problem/339/A --- ![image](https://hackmd.io/_uploads/SkljaWxBgl.png) --- ```cpp= #include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main() { string str; cin>>str; int countnum; vector<int> num; for (int i = 0; i < 3; i++) { for (int j = 0; j<(countnum=count(str.begin(),str.end(),char(49+i))); j++) { num.push_back(i+1); } } for (int i=0; i< num.size();i++) { (i+1==num.size()?printf("%d",num.at(i)):printf("%d+",num.at(i))); } } ``` --- ::: :::spoiler 236A - Boy or Girl --- https://codeforces.com/problemset/problem/236/A --- ![image](https://hackmd.io/_uploads/HJxy6MgBll.png) --- ```cpp= #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { vector<char> array(26,0); char ch; while ((ch=getchar())!=EOF) { if (ch<'a') { break; } array.at(ch-'a')|=1; } cout<<(count(array.begin(),array.end(),1)%2==0?"CHAT WITH HER!":"IGNORE HIM!"); } ``` --- ::: :::spoiler 281A - Word Capitalization --- https://codeforces.com/problemset/problem/281/A --- ![image](https://hackmd.io/_uploads/BJcGHXeHgg.png) --- ```cpp= #include <iostream> #include <cctype> #include <string> using namespace std; int main() { string str; cin>>str; cout<<(str.at(0)<=90?str.at(0):str.at(0)-=32)<<str.substr(1); } ``` --- ::: :::spoiler 791A - Bear and Big Brother --- https://codeforces.com/problemset/problem/791/A --- ![image](https://hackmd.io/_uploads/rJEPkbWSxl.png) --- ```cpp= #include <iostream> using namespace std; int main() { int a,b; cin>>a>>b; for (int y = 1;; y++) { a*=3; b*=2; if (a>b) { cout<<y; break; } } } ``` --- ::: :::spoiler 266A - Stones on the Table --- https://codeforces.com/problemset/problem/266/A --- ![image](https://hackmd.io/_uploads/S1EtQzbSxe.png) --- ```cpp= #include <iostream> #include <algorithm> #include <vector> using namespace std; int main() { int temp; cin >> temp; cin >> ws; vector<char> ch; for (int i = 0; i < temp; i++) { ch.push_back(getchar()); } ch.resize(distance(ch.begin(),unique(ch.begin(),ch.begin()+temp))); cout<<temp-ch.size(); } ``` --- ::: :::spoiler 617A - Elephant --- https://codeforces.com/problemset/problem/791/A --- ![image](https://hackmd.io/_uploads/Hyg-DZbSxg.png) --- ```cpp= #include <iostream> #include <cmath> using namespace std; int main() { int d; cin >> d; cout<<d/5+(d%5==0?0:1); } ``` --- ::: :::spoiler 546A - Soldier and Bananas --- https://codeforces.com/problemset/problem/546/A --- ![image](https://hackmd.io/_uploads/B1-9hWbBeg.png) --- ```cpp= #include <iostream> #include <cmath> using namespace std; int main() { int n,k,w,res; cin >> k>> n>> w; res=n-k*((w+1) * floor(w/2)+(w%2==0?0:floor(w/2+1))); cout<<(res>=0?0:abs(res)); } ``` --- ::: :::spoiler 59A - Word --- https://codeforces.com/problemset/problem/59/A --- ![image](https://hackmd.io/_uploads/HyBTxGWHlx.png) --- ```cpp= #include <iostream> #include <cctype> #include <algorithm> using namespace std; int main() { string str; cin>>str; int lowcount=count_if(str.begin(),str.end(),[](const char &ch){ return islower(ch);}); int uppcount=count_if(str.begin(),str.end(),[](const char &ch){ return isupper(ch);}); if(uppcount>lowcount){ for_each(str.begin(),str.end(),[](const char &ch){ cout<<char(toupper(ch)); }); } else{ for_each(str.begin(),str.end(),[](const char &ch){ cout<<char(tolower(ch)); }); } } ``` --- ::: :::spoiler 977A - Wrong Subtraction --- https://codeforces.com/problemset/problem/977/A --- ![image](https://hackmd.io/_uploads/Skc27G-Hel.png) --- ```cpp= #include <iostream> using namespace std; int main() { int a,b; cin>>a>>b; for (int i = 0; i < b; i++) { a=(a%10==0?a/10:a-1); } cout<<a; } ``` --- ::: :::spoiler 110A - Nearly Lucky Number --- https://codeforces.com/problemset/problem/110/A --- ![image](https://hackmd.io/_uploads/S1diUMZSee.png) --- ```cpp= #include <iostream> #include <algorithm> using namespace std; int main() { int a; string str; cin>>str; a=count_if(str.begin(),str.end(),[](const char &ch){ return ch=='7'||ch=='4'; }); cout<<(7==a||4==a?"YES":"NO"); } ``` --- ::: :::spoiler 734A - Anton and Danik --- https://codeforces.com/problemset/problem/734/A --- ![image](https://hackmd.io/_uploads/r1sPOM-Hex.png) --- ```cpp= #include <iostream> #include <algorithm> using namespace std; int main() { int a,length; cin>>length; string str; cin>>str; a=count(str.begin(),str.end(),'A'); cout<<(a>(length-a)?"Anton":(a==length-a)?"Friendship":"Danik"); } ``` --- ::: :::spoiler 41A - Translation --- https://codeforces.com/problemset/problem/41/A --- ![image](https://hackmd.io/_uploads/HkVJqMbHee.png) --- ```cpp= #include <iostream> #include <algorithm> using namespace std; int main() { string str, str2; cin>>str>>str2; reverse(str.begin(),str.end()); cout<<(str==str2?"YES":"NO"); } ``` --- ::: :::spoiler 2094A - Trippi Troppi --- https://codeforces.com/problemset/problem/2094/A --- ![image](https://hackmd.io/_uploads/rka9E4bSxg.png) --- ```cpp #include <iostream> using namespace std; int main() { string str; int a; cin>>a; cin.ignore(); for(int i=0; i<a;i++){ getline(cin,str); cout<<str.at(0); for(int i=1; i<str.length();i++){ if (str.at(i)==' ') { cout<<str.at(i+1); } } cout<<'\n'; } } ``` --- ::: :::spoiler 677A - Vanya and Fence --- https://codeforces.com/contest/677/problem/A --- ![image](https://hackmd.io/_uploads/HkCDiqzSle.png) --- ```cpp= #include <iostream> using namespace std; int main() { int n,temp,h,count=0; cin>>n>>h; for (int i = 0; i < n; i++) { cin>>temp; count+=(temp>h?2:1); } cout<<count; } ``` --- ::: :::spoiler 116A - Tram --- https://codeforces.com/problemset/problem/116/A --- ![image](https://hackmd.io/_uploads/SkxAQozrel.png) --- ```cpp= #include <iostream> using namespace std; int main() { int n,max=0, a,b,current=0; cin>>n; for (int i = 1; i < n; i++) { cin>>a; cin>>b; current=current-a+b; max=(current>max?current:max); } cout<<max; } ``` --- ::: :::spoiler 271A - Beautiful Year --- https://codeforces.com/problemset/problem/271/A --- ![image](https://hackmd.io/_uploads/Hks5vsfBxg.png) --- ```cpp= #include <iostream> using namespace std; int main() { int y; cin>>y; for (;;) { y++; int temp1=y%10,temp2=y/100%10; if (temp2!=y/10%10&&temp1!=y/10%10&&temp2!=y/1000&&temp1!=temp2&&temp1!=y/1000&&y/10%10!=y/1000%10&&y/100%10!=temp1) { break; } } cout<<y; } ``` --- ::: :::spoiler 1030A - In Search of an Easy Problem --- https://codeforces.com/problemset/problem/1030/A --- ![image](https://hackmd.io/_uploads/ByK3OsGSel.png) --- ```cpp= #include <iostream> using namespace std; int main() { int n,temp; cin>>n; for (int i=0;i<n;i++) { cin>>temp; if (temp) { cout<<"HARD"; return 0; } } cout<<"EASY"; return 0; } ``` --- ::: :::spoiler 266B - Queue at the School --- https://codeforces.com/problemset/problem/266/B --- ![image](https://hackmd.io/_uploads/HJuFnsGrll.png) --- ```cpp= #include <iostream> #include <string> using namespace std; int main() { int n,t; cin>>n>>t; string str; cin>>str; for (int time = 0; time < t; ++time){ for (int i = 0; i < n - 1; ++i){ if (str[i]=='B'&&str[i+1]=='G') { swap(str[i], str[i + 1]); ++i; } } } cout << str; return 0; } ``` --- ::: :::spoiler 467A - George and Accommodation --- https://codeforces.com/problemset/problem/467/A --- ![image](https://hackmd.io/_uploads/HyX-CjzSex.png) --- ```cpp= #include <iostream> using namespace std; int main() { int n, max, count=0, cur; cin >> n; for (int i = 0; i < n; i++) { cin >> cur >> max; if (max - cur >= 2) { count ++; } } cout << count; return 0; } ``` --- ::: :::spoiler 344A - Magnets --- https://codeforces.com/problemset/problem/344/A --- ![image](https://hackmd.io/_uploads/S1Dbl3zSgg.png) --- ```cpp= #include <iostream> using namespace std; int main() { string str,cur=""; int n, count=0; cin >> n; for (int i = 0; i < n; i++) { cin>>str; if (cur != str) { cur = str; count ++; } } cout << count; return 0; } ``` --- ::: :::spoiler 486A - Calculating Function --- https://codeforces.com/problemset/problem/486/A --- ![image](https://hackmd.io/_uploads/SJZrm2zHel.png) --- ```cpp= #include <iostream> using namespace std; int main() { long long n; cin >> n; cout << (n % 2 == 1?(n/2) *-1 - 1 : n/2); return 0; } ``` --- ::: :::spoiler 136A - Presents --- https://codeforces.com/problemset/problem/136/A --- ![image](https://hackmd.io/_uploads/Syojr3zrex.png) --- ```cpp= #include <iostream> using namespace std; int main() { int n; cin >> n; int f[n]; for (int i = 0; i < n; i++) { int temp; cin >> temp; f[temp-1] = i + 1; } for (const int &i : f) { cout<<i<<' '; } return 0; } ``` --- ::: :::spoiler 200B - Drinks --- https://codeforces.com/problemset/problem/200/B --- ![image](https://hackmd.io/_uploads/HJdduhzBlg.png) --- ```cpp= #include <iostream> using namespace std; int main() { double result; short n; cin >> n; for (int i = 0; i < n; i++) { int temp; cin >> temp; result += temp; } cout<<result/n; } ``` --- ::: :::spoiler 228A - Is your horseshoe on the other hoof? --- https://codeforces.com/problemset/problem/228/A --- ![image](https://hackmd.io/_uploads/BkVrw3mBgg.png) --- ```cpp= #include <iostream> #include <set> using namespace std; int main() { int temp = 0; set <int> arr; for (int i = 0; i < 4; i++) { cin >> temp; arr.insert(temp); } cout << 4 - arr.size(); } ``` --- ::: :::spoiler 61A - Ultra-Fast Mathematician --- https://codeforces.com/problemset/problem/61/A --- ![image](https://hackmd.io/_uploads/HJ7ET37rle.png) --- ```cpp= #include <iostream> #include <string> using namespace std; int main() { string str1, str2; cin >> str1 >> str2; for (int i = 0; i < str1.length(); i++) { if ( (str1[i] == '1'|| str2[i] == '1') && str1[i] != str2[i]) { cout << '1'; } else{ cout << '0'; } } return 0; } ``` --- ::: :::spoiler 705A - Hulk --- https://codeforces.com/problemset/problem/705/A --- ![image](https://hackmd.io/_uploads/ryzzJamSle.png) --- ```cpp= #include <iostream> using namespace std; int main() { int lay; cin >> lay; for (int i = 0; i < lay; i++) { if (i % 2 == 0){ cout << "I hate "; } else{ cout << "I love "; } if (i+1==lay) { cout << "it "; } else{ cout << "that "; } } return 0; } ``` --- ::: :::spoiler 1328A - Divisibility Problem --- https://codeforces.com/problemset/problem/1328/A --- ![image](https://hackmd.io/_uploads/rJNHGpQHxg.png) --- ```cpp= #include <iostream> using namespace std; int main() { int n, a, b; cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b; if (a/b * b != a) { cout << (a/b + 1) * b - a << '\n'; } else{ cout << 0 << '\n'; } } return 0; } ``` --- ::: :::spoiler 520A - Pangram --- https://codeforces.com/problemset/problem/520/A --- ![image](https://hackmd.io/_uploads/HkG-U6XBee.png) --- ```cpp= #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { string str; int n; vector <int> alp(26); cin >> n >> str; if (str.length() < 26) { cout << "NO"; } else{ for (const char &ch : str){ alp[tolower(ch) - 97] ++; } if (count(alp.begin(), alp.end(), 0) != 0) { cout << "NO"; } else cout << "YES"; } return 0; } ``` --- ::: :::spoiler 469A - I Wanna Be the Guy --- https://codeforces.com/problemset/problem/469/A --- ![image](https://hackmd.io/_uploads/SyThtp7Hge.png) --- ```cpp= #include <iostream> #include <set> using namespace std; int main() { set <int> lvs; int n; cin >> n; for (int i = 0; i < 2; ++i){ int j; cin >> j; for (j; j>0; --j) { int temp; cin >> temp; lvs.insert(temp); } } cout << (lvs.size() == n ? "I become the guy." : "Oh, my keyboard!"); return 0; } ``` --- ::: :::spoiler 144A - Arrival of the General --- https://codeforces.com/problemset/problem/144/A --- ![image](https://hackmd.io/_uploads/BkyIQ07Sll.png) --- ```cpp= #include <iostream> #include <algorithm> using namespace std; int main() { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++){ int temp; cin >> temp; arr[i] = temp; } int *mp=max_element(arr, arr + n); int minVal = *min_element(arr, arr + n); int *np = arr + n - 1; while (*np != minVal) { --np; } if ( np < mp ) { cout << distance(arr, mp) + distance(np, arr + n - 1) - 1; } else{ cout << distance(arr, mp) + distance(np, arr + n - 1); } return 0; } ``` --- ::: :::spoiler 996A - Hit the Lottery --- https://codeforces.com/problemset/problem/996/A --- ![image](https://hackmd.io/_uploads/BkOaFA7Hxl.png) --- ```cpp= #include <iostream> using namespace std; int main() { int m, count = 0, opt[5] = {1, 5, 10, 20, 100}; cin >> m; for (int i = 0; i < 5; i++){ while (m >= opt[4 - i] && m > 0) { m -= opt[4 - i]; count ++; } } cout << count; return 0; } ``` --- ::: :::spoiler 148A - Isomina cure --- https://codeforces.com/contest/148/problem/A --- ![image](https://hackmd.io/_uploads/ryoqYbtrgg.png) --- ```cpp= #include <iostream> using namespace std; int main() { int k, m, l, d, n, count = 0; cin >> k >> l >> m >> n >> d; for (int i = 1; i <= d; i ++){ count += (i % k == 0 || i % l == 0 || i % m == 0 || i % n == 0); } cout << count; return 0; } ``` --- ::: :::spoiler 443A - Anton and Letters --- https://codeforces.com/problemset/problem/443/A --- ![image](https://hackmd.io/_uploads/rJrCsbKSeg.png) --- ```cpp= #include <iostream> #include <set> using namespace std; int main() { char ch; set<char> str; ch = getchar(); while ((ch = getchar()) != EOF) { if (isalpha(ch)){ str.insert(ch); } } cout << str.size(); return 0; } ``` --- ::: :::spoiler 785A - Anton and Polyhedrons --- https://codeforces.com/problemset/problem/785/A --- ![image](https://hackmd.io/_uploads/SyKoA-YSll.png) --- ```cpp= #include <iostream> #include <set> using namespace std; int main() { int n, count = 0; string str; cin >> n; cin.ignore(); for (int i = 0;i < n; i++){ getline(cin, str); switch (str[0]) { case 'C': count += 6; break; case 'T': count += 4; break; case 'O': count += 8; break; case 'D': count += 12; break; default: count += 20; break; } } cout << count; return 0; } ``` --- ::: :::spoiler 268A - Games --- https://codeforces.com/problemset/problem/268/A --- ![image](https://hackmd.io/_uploads/Sk6xzfKSgg.png) --- ```cpp= #include <iostream> #include <vector> using namespace std; int main() { int n, count = 0; cin >> n; vector<int> home(n), away(n); for (int i = 0; i < n; ++i) cin >> home[i] >> away[i]; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (i != j && home[i] == away[j]) ++count; } } cout << count; return 0; } ``` --- ::: :::spoiler 1335A - Candies and Two Sisters --- https://codeforces.com/problemset/problem/1335/A --- ![image](https://hackmd.io/_uploads/ByfpuMYHxx.png) --- ```cpp= #include <iostream> #include <cmath> using namespace std; int main() { long t, c, count = 0; cin >> t; for (int i = 0; i < t; i++) { cin >> c; cout << fixed << int(round(double(c)/2) - 1); if (i + 1 == t) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 510A - Fox And Snake --- https://codeforces.com/problemset/problem/510/A --- ![image](https://hackmd.io/_uploads/BJUHnMYBxl.png) --- ```cpp= #include <iostream> using namespace std; int main() { int a, b; cin >> a >> b; for (int i = 0; i < a; i++){ switch (i % 4) { case 1: for (int i = 0; i < b - 1; i++) { cout << '.'; } cout << '#'; break; case 3: cout << '#'; for (int i = 0; i < b - 1; i++) { cout << '.'; } break; default: for (int i = 0; i < b; i++) { cout << '#'; } break; } if (i + 1 == a) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 141A - Amusing Joke --- https://codeforces.com/problemset/problem/141/A --- ![image](https://hackmd.io/_uploads/SkdoRGFHxg.png) --- ```cpp= #include <iostream> #include <algorithm> using namespace std; int main() { int luabovaochuong[26] = {0}; char ch; for (int i = 0; i < 2; i++) { while ((ch = getchar()) != '\n') { luabovaochuong[ch - 'A'] ++; } } while ((ch = getchar()) != EOF) { luabovaochuong[ch - 'A']--; } cout << (count(luabovaochuong, luabovaochuong + 26, 0) == 26? "YES" : "NO"); return 0; } ``` --- ::: :::spoiler 1352A - Sum of Round Numbers --- https://codeforces.com/problemset/problem/1352/A --- ![image](https://hackmd.io/_uploads/SJrvMXFBex.png) --- ```cpp= #include <iostream> #include <algorithm> #include <vector> using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; i++){ int temp; cin >> temp; vector <int> slices; int base = 1; while (temp > 0) { int di = temp % 10; if (di != 0) slices.push_back(di * base); temp /= 10; base *= 10; } cout << slices.size() << '\n'; for (const int &i : slices){ cout << i << ' '; } cout << '\n'; } return 0; } ``` --- ::: :::spoiler 723A - The New Year: Meeting Friends --- https://codeforces.com/problemset/problem/723/A --- ![image](https://hackmd.io/_uploads/SygRN7Krlg.png) --- ```cpp= #include <iostream> #include <algorithm> using namespace std; int main() { int n[3]; cin >> n[0]; cin >> n[1]; cin >> n[2]; sort(n, n+3); cout << n[1]-n[0] + n[2]-n[1]; return 0; } ``` --- ::: :::spoiler 1742A - Sum --- https://codeforces.com/problemset/problem/1742/A --- ![image](https://hackmd.io/_uploads/SkQkiQYHle.png) --- ```cpp= #include <iostream> #include <algorithm> using namespace std; int main() { int s, n[3]; cin >> s; for (int i = 0; i < s; i++){ cin >> n[0] >> n[1] >> n[2]; sort(n, n+3); cout << (n[1]+n[0]==n[2] ? "YES" : "NO"); if (i + 1 == s) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 427A - Police Recruits --- https://codeforces.com/problemset/problem/427/A --- ![image](https://hackmd.io/_uploads/SkSa2SqSxe.png) --- ```cpp= #include <iostream> #include <algorithm> using namespace std; int main() { int n, count = 0, temp, policers = 0; cin >> n; for (int i = 0; i < n; i ++){ cin >> temp; if (policers == 0 && temp == -1) count ++; else policers += temp; } cout << count; return 0; } ``` --- ::: :::spoiler 750A - New Year and Hurry --- https://codeforces.com/problemset/problem/750/A --- ![image](https://hackmd.io/_uploads/By5Pw89rgg.png) --- ```cpp= #include <iostream> using namespace std; int main() { int MAX = 240, a, b, base = 5, spent = 0; cin >> a >>b; int remain = MAX - b; for (int i = 1; i < a + 1; i++){ spent += base*i; if (remain < spent){ cout << i - 1; return 0; } } cout << a; return 0; } ``` --- ::: :::spoiler 155A - I_love_\%username\% --- https://codeforces.com/problemset/problem/155/A --- ![image](https://hackmd.io/_uploads/rk6KaIqSel.png) --- ```cpp= #include <iostream> using namespace std; int main() { int n, temp, max, min, count = 0; cin >> n >> max; min = max; for (int i = 1; i < n; i++){ cin >> temp; if (max < temp){ count++; max = temp; } else if (min > temp){ count++; min = temp; } } cout << count; return 0; } ``` --- ::: :::spoiler 151A - Soft Drinking --- https://codeforces.com/problemset/problem/151/A --- ![image](https://hackmd.io/_uploads/Sk3Vmv9Sxl.png) --- ```cpp= #include <iostream> #include <set> using namespace std; int main() { int f, b, bl, c, cd, p, nb, np; cin >> f >> b >> bl >> c >> cd >> p >> nb >> np; set <int> amount; amount.insert(b * bl/nb); amount.insert(c * cd); amount.insert(p / np); cout << *amount.begin()/f; return 0; } ``` --- ::: :::spoiler 1703A - YES or YES? --- https://codeforces.com/problemset/problem/1703/A --- ![image](https://hackmd.io/_uploads/HyqsBw5Sxx.png) --- ```cpp= #include <iostream> using namespace std; int main() { int n; cin >> n; char ch[4]; for (int i = 0; i < n; i++){ cin >> ch; if (tolower(ch[0]) != 'y' || tolower(ch[1]) != 'e' || tolower(ch[2]) != 's') cout << "NO"; else cout << "YES"; if (i + 1 == n) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 732A - Buy a Shovel --- https://codeforces.com/problemset/problem/732/A --- ![image](https://hackmd.io/_uploads/B1PCODqHex.png) --- ```cpp= #include <iostream> using namespace std; int main() { int s, b, i = 1; cin >> s >> b; while ((s * i - b) % 10 != 0 && s * i % 10 != 0){ i ++; } cout << i; return 0; } ``` --- ::: :::spoiler 630A - Again Twenty Five! --- https://codeforces.com/problemset/problem/630/A --- ![image](https://hackmd.io/_uploads/BkUGcP5Sxe.png) --- ```cpp= #include <iostream> using namespace std; int main() { cout << 25; return 0; } ``` --- ::: :::spoiler 1154A - Restoring Three Numbers --- https://codeforces.com/problemset/problem/1154/A --- ![image](https://hackmd.io/_uploads/Bk0fdnqBex.png) --- ```cpp= #include <iostream> #include <algorithm> using namespace std; int main() { int list[4]; cin >> list[0] >> list[1] >> list[2] >> list[3]; sort(list, list + 4); cout << list[3] - list[0] << ' ' << list[3] - list[1] << ' ' << list[3] - list[2]; return 0; } ``` --- ::: :::spoiler 581A - Vasya the Hipster --- https://codeforces.com/problemset/problem/581/A --- ![image](https://hackmd.io/_uploads/H1Pd93cSel.png) --- ```cpp= #include <iostream> using namespace std; int main() { int a, b; cin >> a >> b; if (a > b) cout << b << ' ' << (a - b) /2; else cout << a <<' ' << (b - a) / 2; return 0; } ``` --- ::: :::spoiler 381A - Sereja and Dima --- https://codeforces.com/problemset/problem/381/A --- ![image](https://hackmd.io/_uploads/Byjw6nqSex.png) --- ```cpp= #include <iostream> #include <deque> using namespace std; int main() { int n, temp; cin >> n; deque<int> list; for (int i = 0; i < n; i++) { cin >> temp; list.push_back(temp); } int sum1 = 0, sum2 = 0; for (int i = 0; i < n; i++) { temp = (list.front() > list.back() ? list.front() : list.back()); (i % 2 == 0 ? sum1 : sum2) += temp; if (temp == list.front()) list.pop_front(); else list.pop_back(); } cout << sum1 << ' ' << sum2; return 0; } ``` --- ::: :::spoiler 1669A - Division? --- https://codeforces.com/problemset/problem/1669/A --- ![image](https://hackmd.io/_uploads/ryE1y6qBel.png) --- ```cpp= #include <iostream> using namespace std; int main() { int n, ranking; cin >> n; for (int i = 0; i < n; i++){ cin >> ranking; cout << "Division "; if (ranking >= 1900) cout << "1"; else if (ranking >= 1600) cout << '2'; else if (ranking >= 1400) cout << "3"; else cout << "4"; if (i + 1 == n) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 1692A - Marathon --- https://codeforces.com/problemset/problem/1692/A --- ![image](https://hackmd.io/_uploads/Hke3AqoBge.png) --- ```cpp= #include <iostream> #include <algorithm> using namespace std; int main(){ int temp, n, list[4]; cin >> n; for (int i = 0; i < n; i++){ cin >> temp; list[0] = temp; for (int j = 1; j < 4; j++) { cin >> list[j]; } sort(list, list + 4); cout << distance(find(list, list + 4, temp), list + 4) - 1; if (i + 1 == n) continue; cout <<'\n'; } return 0; } ``` --- ::: :::spoiler 1676A - Lucky? --- https://codeforces.com/problemset/problem/1676/A --- ![image](https://hackmd.io/_uploads/r1arfsiSge.png) --- ```cpp= #include <iostream> using namespace std; int main(){ int n, sum1 = 0, sum2 = 0; cin >> n; cin.ignore(); for (int i = 0; i < n; i++){ sum1 += (_getchar_nolock() - '0'); sum1 += (_getchar_nolock() - '0'); sum1 += (_getchar_nolock() - '0'); sum2 += (_getchar_nolock() - '0'); sum2 += (_getchar_nolock() - '0'); sum2 += (_getchar_nolock() - '0'); if (sum1 == sum2) cout << "YES"; else cout << "NO"; sum1 = sum2 = 0; if (i + 1 == n) continue; cout << '\n'; _getchar_nolock(); } return 0; } ``` --- ::: :::spoiler 1676A - Lucky? --- https://codeforces.com/problemset/problem/1807/A --- ![image](https://hackmd.io/_uploads/ryXEBjoSex.png) --- ```cpp= #include <iostream> using namespace std; int main(){ int n, a, b, c; cin >> n; while (n--) { cin >> a >> b >> c; if (c == b + a) cout << '+'; else cout << '-'; if (n == 0) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 1409A - Yet Another Two Integers Problem --- https://codeforces.com/problemset/problem/1409/A --- ![image](https://hackmd.io/_uploads/rkPshjjrge.png) --- ```cpp= #include <iostream> using namespace std; int main(){ int n, a, b; cin >> n; while (n--){ cin >> a >> b; if (a == b) cout << 0; else { cout << abs(b - a) / 10 + ( (b-a) % 10 != 0); } if (n == 0) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 2065A - Skibidus and Amog'u --- https://codeforces.com/problemset/problem/2065/A --- ![image](https://hackmd.io/_uploads/BknG1hiSll.png) --- ```cpp= #include <iostream> using namespace std; int main(){ string str; int n; cin >> n; while (n--){ cin >> str; cout << str.substr(0, str.length() - 2) + 'i'; if (n == 0) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 1399A - Remove Smallest --- https://codeforces.com/problemset/problem/1399/A --- ![image](https://hackmd.io/_uploads/HysJayhHxg.png) --- ```cpp= #include <iostream> #include <vector> #include <algorithm> int main(){ int t; std::cin >> t; while (t--) { int n; std::cin >> n; std::vector<int> a(n); for (int i = 0; i < n; ++i) { std::cin >> a[i]; } std::sort(a.begin(), a.end()); bool possible = true; for (int i = 0; i < n - 1; ++i) { if (a[i+1] - a[i] > 1) { possible = false; break; } } if (possible) { std::cout << "YES\n"; } else { std::cout << "NO\n"; } } return 0; } ``` --- ::: :::spoiler 2114A - Square Year --- https://codeforces.com/problemset/problem/2114/A --- ![image](https://hackmd.io/_uploads/ryicde2rle.png) --- ```cpp= #include <iostream> #include <cmath> using namespace std; int main(){ int n, y; cin >> n; while (n--) { cin >> y; int res = int(sqrt(y)); if (res * res == y) cout << res << ' ' << 0; else cout << -1; if (n == 0) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 2044A - Easy Problem --- https://codeforces.com/problemset/problem/2044/A --- ![image](https://hackmd.io/_uploads/rJLU5xhrgl.png) --- ```cpp= #include <iostream> using namespace std; int main(){ int n, y; cin >> n; while (n--) { cin >> y; cout << y - 1; if (n == 0) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 2044A - Easy Problem --- https://codeforces.com/contest/1985/problem/A --- ![image](https://hackmd.io/_uploads/rkYdBb2Hex.png) --- ```cpp= #include <iostream> using namespace std; int main(){ int n; string y; cin >> n; cin.ignore(); while (n--) { getline(cin, y); cout << y[4] << y.substr(1,2) << ' ' << y[0] << y.substr(5,2); if (n == 0) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 1999A - A+B Again? --- https://codeforces.com/problemset/problem/1999/A --- ![image](https://hackmd.io/_uploads/BJ4xdb2rxg.png) --- ```cpp= #include <iostream> using namespace std; int main(){ int n, y; cin >> n; cin.ignore(); while (n--) { cin >> y; cout << y % 10 + y / 10; if (n == 0) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 32B - Borze --- https://codeforces.com/problemset/problem/32/B --- ![image](https://hackmd.io/_uploads/rk2JTb2ree.png) --- ```cpp= #include <iostream> using namespace std; int main(){ char temp; while ((temp = _getchar_nolock()) != EOF) { if (temp == '.') cout << 0; else if (temp == '-') { temp = _getchar_nolock(); if (temp == '.') cout << 1; else cout << 2; } } return 0; } ``` --- ::: :::spoiler 1512A - Spy Detected! --- https://codeforces.com/problemset/problem/1512/A --- ![image](https://hackmd.io/_uploads/S184EznBxx.png) --- ```cpp= #include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int n; cin >> n; while (n --){ int size; cin >> size; vector<int> nums(size); for (int i = 0; i < size; i ++){ cin >> nums[i]; } vector<int> nums2 = nums; sort(nums.begin(),nums.end()); if (nums[1] == nums.front()) cout << distance(nums2.begin(),find(nums2.begin(),nums2.end(), nums.back()) + 1); else cout << distance(nums2.begin(),find(nums2.begin(),nums2.end(), nums.front()) + 1); if (n == 0) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 1791A - Codeforces Checking --- https://codeforces.com/problemset/problem/1791/A --- ![image](https://hackmd.io/_uploads/SJQCrGnrle.png) --- ```cpp= #include <iostream> #include <algorithm> using namespace std; int main(){ int n; cin >> n; string cf = "codeforces"; cin.ignore(); while (n --){ char ch = _getchar_nolock(); if (find(cf.begin(), cf.end(), ch) != cf.end()) cout << "YES"; else cout << "NO"; if (n == 0) continue; _getchar_nolock(); cout << '\n'; } return 0; } ``` --- ::: :::spoiler 1760A - Medium Number --- https://codeforces.com/problemset/problem/1760/A --- ![image](https://hackmd.io/_uploads/HJ9kXT3Sel.png) --- ```cpp= #include <iostream> #include <algorithm> using namespace std; int main(){ int a, b, c, n; cin >> n; while (n--) { cin >> a >> b >> c; if ((a < b && b < c ) || (c < b && b < a)) cout << b; else if ((a < c && c < b) || (b < c && c < a)) cout << c; else cout << a; if (n == 0) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 1915A - Odd One Out --- https://codeforces.com/problemset/problem/1915/A --- ![image](https://hackmd.io/_uploads/BJq6XpnHll.png) --- ```cpp= #include <iostream> using namespace std; int main(){ int a, b, c, n; cin >> n; while (n--) { cin >> a >> b >> c; cout << (a ^= b ^= c); if (n == 0) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 758A - Holiday Of Equality --- https://codeforces.com/problemset/problem/758/A --- ![image](https://hackmd.io/_uploads/B10orpnreg.png) --- ```cpp= #include <iostream> using namespace std; int main(){ int temp, n, max = 0, sum = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> temp; sum += temp; max = (max < temp ? temp : max); } cout << max * (n - 1) -(sum - max); return 0; } ``` --- ::: :::spoiler --- https://codeforces.com/problemset/problem/1560/A --- ![image](https://hackmd.io/_uploads/Sy3bppnreg.png) --- ```cpp= #include <iostream> #include <vector> using namespace std; int main(){ vector <int> list; int cur = 1; while (list.size() < 1000) { if (cur % 3 != 0 && cur % 10 != 3) { list.push_back(cur); } cur++; } int n; cin >> n; while (n--) { int k; cin >> k; cout << list[k - 1] << '\n'; } return 0; } ``` --- ::: :::spoiler 472A - Design Tutorial: Learn from Math --- https://codeforces.com/problemset/problem/472/A --- ![image](https://hackmd.io/_uploads/rJ2Jb03Sxl.png) --- ```cpp= #include <iostream> using namespace std; int main(){ int n; cin >> n; if (n % 2 == 0) cout << n - 8 << ' ' << 8; else cout << n - 9 << ' ' << 9; return 0; } ``` --- ::: :::spoiler 1850A - To My Critics --- https://codeforces.com/problemset/problem/1850/A --- ![image](https://hackmd.io/_uploads/Sk-xZyTBel.png) --- ```cpp= #include <iostream> #include <vector> using namespace std; int main(){ int n, a, b, c; cin >> n; while (n--) { cin >> a >> b >> c; if (a + b >= 10 || b + c >= 10 || a + c >= 10) cout << "YES"; else cout << "NO"; if (n == 0) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 432A - Choosing Teams --- https://codeforces.com/problemset/problem/432/A --- ![image](https://hackmd.io/_uploads/HJ-IDJprgg.png) --- ```cpp= #include <iostream> #include <vector> using namespace std; int main(){ int n, t, count = 0; cin >> n >> t; vector<int> p(n); for (int i = 0; i < n; i ++){ cin >> p[i]; } for (const int & i : p){ if (i + t <= 5) count++; } cout << count / 3; return 0; } ``` --- ::: :::spoiler 490A - Team Olympiad --- https://codeforces.com/problemset/problem/490/A --- ![image](https://hackmd.io/_uploads/r1mtxxpHex.png) --- ```cpp= #include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int n, t, count = 0; cin >> n; vector <int> PE, Code, Mat; for (int i = 1; i <= n; i++) { cin >> t; if (t == 1) Code.push_back(i); else if(t == 2) Mat.push_back(i); else PE.push_back(i); } int gmin = min({Code.size(),Mat.size(),PE.size()}); cout << gmin << '\n'; for (int i = 0; i < gmin; i++){ cout << Code.at(i) << ' ' << Mat.at(i) << ' ' << PE.at(i); if (i + 1 == gmin) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 1899A - Game with Integers --- https://codeforces.com/problemset/problem/1899/A --- ![image](https://hackmd.io/_uploads/rJTO5e6Bxl.png) --- ```cpp= #include <iostream> using namespace std; int main(){ int n, t; cin >> n; while(n--){ cin >> t; cout << (t % 3 == 0 ? "Second": "First"); if (n == 0) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 9A - Die Roll --- https://codeforces.com/problemset/problem/9/A --- ![image](https://hackmd.io/_uploads/Bkz_6gTHgx.png) --- ```cpp= #include <iostream> #include <algorithm> using namespace std; int main(){ int t, t2; cin >> t >> t2; if (t > t2){ t ^= t2; t2 ^= t; t ^= t2; } int rem = 6 - t2 + 1; int g = __gcd(rem, 6); rem /= g; cout << rem << '/' << 6/g; return 0; } ``` --- ::: :::spoiler 2009A - Minimize! --- https://codeforces.com/problemset/problem/2009/A --- ![image](https://hackmd.io/_uploads/ry4GJZaSgl.png) --- ```cpp= #include <iostream> using namespace std; int main(){ int n, a, b; cin >> n; while (n--) { cin >> a >> b; cout << -a + b; if (n == 0) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 1873A - Short Sort --- https://codeforces.com/problemset/problem/1873/A --- ![image](https://hackmd.io/_uploads/B1I_fbTHle.png) --- ```cpp= #include <iostream> #include <algorithm> using namespace std; int main(){ int n, count = 2; string str; cin >> n; while (n--) { cin >> str; for (int i = 0; i < str.length(); i++){ count -= (str.at(i) == i + 97); } cout << (count > 1 ? "NO" : "YES"); count = 2; if (n == 0) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 1367A - Short Substrings --- https://codeforces.com/problemset/problem/1367/A --- ![image](https://hackmd.io/_uploads/B1ZTE-aBxx.png) --- ```cpp= #include <iostream> #include <algorithm> using namespace std; int main(){ int n; string str; cin >> n; while (n--) { cin >> str; for (int i = 0; i < str.length(); i++) { if (i % 2 == 0) cout << str.at(i); } cout << str.back(); if (n == 0) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 1950A - Stair, Peak, or Neither? --- https://codeforces.com/problemset/problem/1950/A --- ![image](https://hackmd.io/_uploads/S1jlIb6Bgg.png) --- ```cpp= #include <iostream> #include <algorithm> using namespace std; int main(){ int n, a, b, c; cin >> n; while (n--) { cin >> a >> b >> c; if (c > b && b > a) cout << "STAIR"; else if (c < b && a < b) cout << "PEAK"; else cout << "NONE"; if (n == 0) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 703A - Mishka and Game --- https://codeforces.com/problemset/problem/703/A --- ![image](https://hackmd.io/_uploads/SkxZuWTHgx.png) --- ```cpp= #include <iostream> #include <algorithm> using namespace std; int main(){ int n, a, b, count1 = 0, count2 = 0; cin >> n; while (n--) { cin >> a >> b; count1 += (a > b); count2 += (b > a); } cout << (count1 > count2 ? "Mishka" : (count1 == count2 ? "Friendship is magic!^^" : "Chris")); return 0; } ``` --- ::: :::spoiler 1829A - Love Story --- https://codeforces.com/problemset/problem/1829/A --- ![image](https://hackmd.io/_uploads/HyHHKbpSgl.png) --- ```cpp= #include <iostream> #include <algorithm> using namespace std; int main(){ int n, count = 0; string str; const string cf = "codeforces"; cin >> n; while (n--) { cin >> str; for (int i = 0; i < str.length(); i++){ if (str.at(i) != cf.at(i)) count ++; } cout << count; count = 0; if (n == 0) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 1343B - Balanced Array --- https://codeforces.com/problemset/problem/1343/B --- ![image](https://hackmd.io/_uploads/B1QnzM6Hll.png) --- ```cpp= #include <iostream> #include <vector> int main() { int t; std::cin >> t; while (t--) { int n; std::cin >> n; if ((n / 2) % 2 != 0) { std::cout << "NO\n"; } else { std::cout << "YES\n"; std::vector<long long> a(n); long long sum_even = 0; for (int i = 0; i < n / 2; ++i) { a[i] = (i + 1) * 2; sum_even += a[i]; } long long sum_odd = 0; for (int i = 0; i < n / 2 - 1; ++i) { a[n / 2 + i] = (i * 2) + 1; sum_odd += a[n / 2 + i]; } a[n - 1] = sum_even - sum_odd; for (int i = 0; i < n; ++i) { std::cout << a[i] << (i == n - 1 ? "" : " "); } std::cout << "\n"; } } return 0; } ``` --- ::: :::spoiler 431A - Black Square --- https://codeforces.com/problemset/problem/431/A --- ![image](https://hackmd.io/_uploads/BkPoSUpBxl.png) --- ```cpp= #include <iostream> using namespace std; int main() { int arr[4], sum = 0; cin >> arr[0] >> arr[1] >> arr[2] >> arr[3]; cin.ignore(); char ch; while ((ch = _getchar_nolock()) != EOF && ch != '\n') { sum += arr[ch - 49]; } cout << sum; return 0; } ``` --- ::: :::spoiler 80A - Panoramix's Prediction --- https://codeforces.com/problemset/problem/80/A --- ![image](https://hackmd.io/_uploads/ry_pBPpBge.png) --- ```cpp= #include <iostream> #include <vector> using namespace std; int main() { int a, n; cin >> a >> n; vector<bool> isPrime(n + 1, true); isPrime[0] = isPrime[1] = false; for (int p = 2; p * p <= n + 1; p++) { if (isPrime[p]) { for (int i = p * p; i <= n + 1; i += p) { isPrime[i] = false; } } } int nextPrime = -1; for (int i = a + 1; i <= n + 1; i++) { if (isPrime[i]) { nextPrime = i; break; } } if (nextPrime == n) cout << "YES"; else cout << "NO"; return 0; } ``` --- ::: :::spoiler 1800A - Is It a Cat? --- https://codeforces.com/contest/80/problem/A --- ![image](https://hackmd.io/_uploads/SklP8vTHee.png) --- ```cpp= #include <iostream> using namespace std; int main() { int n, length, currentcharacter; bool can = true; char meow[4]= {'m','e','o','w'}; cin >> n; while (n--){ cin >> length; currentcharacter = 0; string str; cin >> str; // duyet qu tung ky tu nek for (int i = 0; i < length; i ++){ if (char(tolower(str.at(i))) != meow[currentcharacter]){ currentcharacter++; if (i == 0|| currentcharacter > 3 || char(tolower(str.at(i))) != meow[currentcharacter]){ cout << "NO"; can = false; break; } } } if (can && currentcharacter == 3) cout << "YES"; else if (can) cout << "NO"; can = true; currentcharacter = 0; if (n == 0) continue; cout << '\n'; } return 0; } ``` --- ::: :::spoiler 1857A - Array Coloring --- https://codeforces.com/problemset/problem/1857/A --- ![image](https://hackmd.io/_uploads/HkQGsD6Bex.png) --- ```cpp= #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n; cin >> n; while (n--) { int size; vector<int> array; cin >> size; for (int i = 0; i < size; i++){ int val; cin >> val; array.push_back(val); } int even = count_if(array.begin(), array.end(), [](const int &a){ return (a % 2 == 0); }), odd = size - even; if (odd % 2 == 0) cout << "YES"; else cout << "NO"; if (n == 0) continue; cout << '\n'; } } ``` --- ::: :::spoiler 1829B - Blank Space --- https://codeforces.com/problemset/problem/1829/B --- ![image](https://hackmd.io/_uploads/BkPv9y0Sel.png) --- ```cpp= #include <iostream> #include <algorithm> using namespace std; int main() { int n, count = 0, max = 0; cin >> n; while (n--) { int size; cin >> size; while (size --) { bool t; cin >> t; if (!t) count++; else if (t) { max = (count > max ? count : max); count = 0; } } max = (count > max ? count : max); cout << max; max = count = 0; if (n == 0) continue; cout << '\n'; } } ``` --- ::: :::spoiler 1374A - Required Remainder --- https://codeforces.com/problemset/problem/1374/A --- ![image](https://hackmd.io/_uploads/SkuXulRSxe.png) --- ```cpp= #include <iostream> #include <algorithm> using namespace std; int main() { int n, a, b, n2; cin >> n; while (n--) { cin >> a >> b >> n2; if (n2 - n2 % a + b <= n2 ) { cout << n2 - n2 % a + b; } else { cout << n2 - n2 % a - (a - b); } if (n == 0) continue; cout << '\n'; } } ``` --- ::: :::spoiler 1619A - Square String? --- https://codeforces.com/problemset/problem/1619/A --- ![image](https://hackmd.io/_uploads/rkxIAlCHeg.png) --- ```cpp= #include <iostream> using namespace std; int main() { int n, can; cin >> n; while (n--) { string str; cin >> str; if (str.length() % 2 == 0){ for (int i = 0; i < str.length()/2; i++){ if (str[i] != str[i + str.length() / 2]) { can = false; break; } } } else can = 0; if (can) cout << "YES"; else cout << "NO"; can = 1; if (n == 0) continue; cout << '\n'; } } ``` --- ::: :::spoiler 1791C - Prepend and Append --- https://codeforces.com/problemset/problem/1791/C --- ![image](https://hackmd.io/_uploads/BJbPzZ0ree.png) --- ```cpp= #include <iostream> using namespace std; int main() { int n; cin >> n; while (n--) { string str; int n2; cin >> n2 >> str; int count = n2; for (int i = 0; i < n2/2; i++){ if (str.at(i) != str.at(n2 - i - 1)){ count-= 2; } else break; } cout << count; if (n == 0) continue; cout << '\n'; } } ``` --- ::: :::spoiler 1722A - Spell Check --- https://codeforces.com/problemset/problem/1722/A --- ![image](https://hackmd.io/_uploads/rJwDB-0Sex.png) --- ```cpp= #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n; string T = "Trium"; sort(T.begin(), T.end()); cin >> n; while (n--) { string str; int n2; cin >> n2 >> str; sort(str.begin(), str.end()); if (str.length() != 5) cout << "NO"; else if (str == T) cout << "YES"; else cout << "NO"; if (n == 0) continue; cout << '\n'; } } ``` --- ::: :::spoiler 1433A - Boring Apartments --- https://codeforces.com/contest/1433/problem/A --- ![image](https://hackmd.io/_uploads/rkugh-0Hlg.png) --- ```cpp= #include <iostream> using namespace std; int checkdi (int n){ int di = 0; while (n > 0) { n /= 10; di ++; } return di; } int acc(int di){ if (di == 1) return 1; else return (di + acc(di - 1)); } int main() { int n; cin >> n; while (n--) { int t; cin >> t; int di = checkdi(t), base = t % 10; di = acc(di); cout << (base - 1) * 10 + di; if (n == 0) continue; cout << '\n'; } } ``` --- :::