├── .gitattributes ├── README.md ├── 50A-Domino piling.cpp ├── 1370A-Maximum GCD.cpp ├── 281A-Word Capitalization.cpp ├── 4A-Watermelon.cpp ├── 96A-Football.cpp ├── 1335A-Candies and Two Sisters.cpp ├── 630A-Again Twenty Five!.cpp ├── 617A-Elephant.cpp ├── 151A-Soft Drinking .cpp ├── 224A-Parallelepiped.cpp ├── 1551A-Polycarp and Coins.cpp ├── 1371A-Magical Sticks.cpp ├── 1A-Theatre Square.cpp ├── 71A-Way Too Long Words.cpp ├── 959A-Mahmoud and Ehab and the even-odd game.cpp ├── 1328A-Divisibility Problem.cpp ├── 1742A-Sum.cpp ├── 492A-Vanya and Cubes.cpp ├── 486A-Calculating Function.cpp ├── 996A-Hit the Lottery.cpp ├── 1283A-Minutes Before the New Year.cpp ├── 1360A-Minimal Square.cpp ├── 1426A-Floor Number.cpp ├── 231A-Team.cpp ├── 1358A-Park Lighting.cpp ├── 1374A-Required Remainder.cpp ├── 791A-Bear and Big Brother.cpp ├── 41A-Translation.cpp ├── 1337A-Ichihime and Triangle.cpp ├── 1760A-Medium Number.cpp ├── 1703A-YES or YES.cpp ├── 1791A-Codeforces Checking.cpp ├── 266A-Stones on the table.cpp ├── 344A-Magnets.cpp ├── 158A-Next Round.cpp ├── 723A-The New Year Meeting Friends.cpp ├── 977A-Wrong Subtraction.cpp ├── 1722A-Spell Check.cpp ├── 467A-George and Accommodation.cpp ├── 935A-Fafa and his Company.cpp ├── 1367A-Short Substrings.cpp ├── 282A-Bit++.cpp ├── 443A-Anton and Letters.cpp ├── 116A-Tram.cpp ├── 546A-Soldier and Bananas.cpp ├── 509A-Maximum in Table.cpp ├── 677A-Vanya and Fence.cpp ├── 133A-HQ9+.cpp ├── 1353A-Most Unstable Array.cpp ├── 1372A-Omkar and Completion.cpp ├── 139A-Petr and Book.cpp ├── 1676A-Lucky.cpp ├── 228A-Is your horseshoe on the other hoof .cpp ├── 427A-Police Recruits.cpp ├── 141A-Amusing Joke.cpp ├── 1369A-FashionabLee.cpp ├── 703A-Mishka and Game.cpp ├── 136A-Presents.cpp ├── 1692A-Marathon.cpp ├── 61A-Ultr-Fast Mathematician.cpp ├── 69A-Young Physicist.cpp ├── 1030A-In Search of an Easy Problem.cpp ├── 112A-Petya and Strings.cpp ├── 266B-Queue at the school.cpp ├── 1409A-Yet Another Two Integers Problem.cpp ├── 200B-Drinks.cpp ├── 1624A-Plus One on the Subset.cpp ├── 318A-Even Odds.cpp ├── 1092B-Teams Forming.cpp ├── 148A-Insomnia cure.cpp ├── 705A-Hulk.cpp ├── 732A-Buy a Shovel.cpp ├── New Year and Hurry.cpp ├── 1593A-Elections.cpp ├── 1389A-LCM Problem.cpp ├── 1512A-Spy Detected!.cpp ├── 1535A-Fair Playoff.cpp ├── 581A-Vasya the Hipster.cpp ├── 1294A-Collecting Coins.cpp ├── 1520B-Ordinary Numbers.cpp ├── 1325B-CopyCopyCopyCopyCopy.cpp ├── 263A-Beautiful Matrix.cpp ├── 339A-Helpful Maths.cpp ├── 1454A-Special Permutation.cpp ├── 1742B-Increasing.cpp ├── 1385A-Three Pairwise Maximums.cpp ├── 1619A-Square String.cpp ├── 260A-Adding Digits.cpp ├── 472A-Design Tutorial Learn from Math.cpp ├── 9A-Die Roll.cpp ├── 59A-Word.cpp ├── 32A-Reconnaissance 2.cpp ├── 785A-Anton and Polyhedrons.cpp ├── 155A-I_love_%username%.cpp ├── 448A-Rewards.cpp ├── 758A-Holiday Of Equality.cpp ├── 1360B-Honest Coach.cpp ├── 315A-Sereja and Bottles.cpp ├── 520A-Pangram.cpp ├── 734A-Anton and Danik.cpp ├── 1296A-Array with Odd Sum.cpp ├── 749A-Bachgold Problem.cpp ├── 707A-Brain's Photos.cpp ├── 1234A-Equalize Prices Again.cpp ├── 1352A-Sum of Round Numbers.cpp ├── 1560A-Dislike of Threes.cpp ├── 1472A-Cards for Friends.cpp ├── 80A-Panoramix's Prediction.cpp ├── 1669A-Division.cpp ├── 1520A-Do Not Be Distracted!.cpp ├── 1343B-Balanced Array.cpp ├── 32B-Borze.cpp ├── 490A-Team Olympiad.cpp ├── 1367B-Even Array.cpp ├── 469A-I wanna be the guy.cpp ├── 1348A-Phoenix and Balance.cpp ├── 236A-Boy or Girl.cpp ├── 431A-Black Square.cpp ├── 144A-Arrival of the General.cpp ├── 510A-Fox and Snake.cpp ├── 1154A-Restoring Three Number.cpp ├── 271A-Beautiful Year.cpp ├── 268A-Games.cpp ├── 1385B-Restore the Permutation by Merger.cpp ├── 1399A-Remove Smallest.cpp ├── 1462A-Favorite Sequence.cpp ├── 1353B-Two Arrays And Swaps.cpp ├── 381A-Sereja and Dima.cpp ├── 1472B-Fair Division.cpp ├── 432A-Choosing Teams.cpp ├── 451B-Sort The Array.cpp ├── 275A-Lights Out.cpp ├── 248A-Cupboards.cpp ├── 110A-Nearly Lucky Number.cpp └── 1433A-Boring Apartments.cpp /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # All of the problems are under copyright of https://codeforces.com 2 | Refer solutions wrt the question no. provided. 3 | 4 | Codeforces Profile Link:-https://codeforces.com/profile/Lucifer_Hanu 5 | 6 | -------------------------------------------------------------------------------- /50A-Domino piling.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/50/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int m,n; 6 | cin>>m>>n; 7 | cout<<(m*n)/2; 8 | } 9 | int main(){ 10 | ios::sync_with_stdio(0); 11 | cin.tie(0); 12 | int t=1; 13 | //cin>>t; 14 | while(t--){ 15 | solve(); 16 | } 17 | return 0; 18 | } -------------------------------------------------------------------------------- /1370A-Maximum GCD.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1370/A 2 | //Maximum GCD 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | long long n; 9 | cin>>n; 10 | cout<>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /281A-Word Capitalization.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/281/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | string s; 6 | cin>>s; 7 | s[0]=toupper(s[0]); 8 | cout<>t; 15 | while(t--) 16 | solve(); 17 | return 0;} -------------------------------------------------------------------------------- /4A-Watermelon.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/4/A 2 | #include 3 | using namespace std; 4 | 5 | void solve(){ 6 | long long n; 7 | cin>>n; 8 | if (n>2&&n%2==0) 9 | printf("YES"); 10 | else 11 | printf("NO"); 12 | } 13 | 14 | int main(){ 15 | ios::sync_with_stdio(0); 16 | cin.tie(0); 17 | int t; 18 | t=1; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /96A-Football.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/96/A 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | string s; 8 | cin >> s; 9 | 10 | if (s.find("0000000") != string::npos || s.find("1111111") != string::npos) { 11 | cout << "YES" << endl; 12 | } else { 13 | cout << "NO" << endl; 14 | } 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /1335A-Candies and Two Sisters.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1335/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | long long n; 6 | cin>>n; 7 | cout<<(n-1)/2; 8 | } 9 | int main(){ 10 | ios_base::sync_with_stdio(0); 11 | cin.tie(0); cout.tie(0); 12 | int t; 13 | cin>>t; 14 | while(t--) 15 | { 16 | solve();cout< 4 | using namespace std; 5 | void solve(){ 6 | long long int n; 7 | cin>>n; 8 | if(n>=2) 9 | cout << "25" << endl; 10 | } 11 | 12 | int main() 13 | { 14 | ios::sync_with_stdio(0); 15 | cin.tie(0); 16 | int t=1; 17 | //cin>>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /617A-Elephant.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/617/A 2 | #include 3 | using namespace std; 4 | 5 | void solve(){ 6 | int n; 7 | cin>>n; 8 | if(n%5==0) 9 | cout<>t; 18 | while(t--) 19 | { 20 | solve(); 21 | } 22 | return 0; 23 | } -------------------------------------------------------------------------------- /151A-Soft Drinking .cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/151/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n,k,l,c,d,p,nl,np; 6 | cin>>n>>k>>l>>c>>d>>p>>nl>>np; 7 | cout<<(min(min(((k*l)/nl),(c*d)),(p/np)))/n; 8 | } 9 | int main(){ 10 | ios::sync_with_stdio(0); 11 | cin.tie(0); 12 | int t=1; 13 | //cin>>t; 14 | while(t--) 15 | solve(); 16 | return 0; 17 | } -------------------------------------------------------------------------------- /224A-Parallelepiped.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/224/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int xy,yz,zx; 6 | cin>>xy>>yz>>zx; 7 | cout<<4*(sqrt((xy*zx)/yz)+sqrt((xy*yz)/zx)+sqrt((yz*zx)/xy)); 8 | } 9 | int main(){ 10 | ios::sync_with_stdio(0); 11 | cin.tie(0); 12 | int t=1; 13 | //cin>>t; 14 | while(t--){ 15 | solve(); 16 | } 17 | return 0; 18 | } -------------------------------------------------------------------------------- /1551A-Polycarp and Coins.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1551/A 2 | //Polycarp and Coins 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | long n; 9 | cin>>n; 10 | long d=n/3; 11 | cout<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /1371A-Magical Sticks.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1371/A 2 | //Magical Sticks 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | int n,ans=0; 9 | cin>>n; 10 | ans=n/2; 11 | if(n%2==1)ans++; 12 | cout<>t; 20 | while(t--) 21 | solve(); 22 | return 0; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /1A-Theatre Square.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1/A 2 | #include 3 | using namespace std; 4 | #define ll unsigned long long int 5 | void solve() 6 | { 7 | ll n,m,a,res; 8 | cin>>n>>m>>a; 9 | res=ceil((double)m/a)*ceil((double)n/a); 10 | cout<>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /71A-Way Too Long Words.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/71/A 2 | #include 3 | using namespace std; 4 | 5 | void solve(){ 6 | string s,res; 7 | cin>>s; 8 | int c; 9 | if(s.length()>10) 10 | cout<>t; 20 | while(t--) 21 | solve(); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /959A-Mahmoud and Ehab and the even-odd game.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/959/A 2 | //Mahmoud and Ehab and the even-odd game 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | long n; 9 | cin>>n; 10 | cout<<(n%2?"Ehab":"Mahmoud"); 11 | } 12 | int main() 13 | { 14 | ios::sync_with_stdio(0); 15 | cin.tie(0); 16 | long long t=1; 17 | //cin>>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /1328A-Divisibility Problem.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long int 4 | void solve(){ 5 | ll a,b; 6 | cin>>a>>b; 7 | if(a%b==0) 8 | { 9 | cout<<'0'<>t; 19 | while(t--){ 20 | solve(); 21 | } 22 | return 0; 23 | } -------------------------------------------------------------------------------- /1742A-Sum.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1742/A 2 | //Sum 3 | #include 4 | using namespace std; 5 | 6 | void solve(){ 7 | int a,b,c; 8 | cin>>a>>b>>c; 9 | if((a+b==c) || (a+c==b) || (b+c==a))cout<<"YES"<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /492A-Vanya and Cubes.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/492/A 2 | //Vanya and Cubes 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | long n,a=0; 9 | cin>>n; 10 | while(a*(a+1)*(a+2)<=6*n) 11 | ++a; 12 | --a; 13 | cout<>t; 21 | while(t--) 22 | solve(); 23 | return 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /486A-Calculating Function.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/486/A 2 | #include 3 | using namespace std; 4 | #define ll long long int 5 | void solve(){ 6 | ll n,s=0; 7 | cin>>n; 8 | if(n%2==0) 9 | cout<>t; 18 | while(t--){ 19 | solve(); 20 | } 21 | return 0; 22 | } -------------------------------------------------------------------------------- /996A-Hit the Lottery.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/996/A 2 | //Hit the Lottery 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n; 7 | cin>>n; 8 | int ans=n/100+(n%100)/20+((n%100)%20)/10+(((n%100)%20)%10)/5+(((n%100)%20)%10)%5; 9 | cout<>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /1283A-Minutes Before the New Year.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1283/A 2 | //Minutes Before the New Year 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | int h,m,day,time=0; 9 | cin>>h>>m; 10 | day=24*60; 11 | time=h*60+m; 12 | cout<>t; 20 | while(t--) 21 | solve(); 22 | return 0; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /1360A-Minimal Square.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1360/A 2 | //Minimal Square 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | int a,b; 9 | cin>>a>>b; 10 | if(a > b){ 11 | swap(a,b); 12 | } 13 | cout<>t; 21 | while(t--) 22 | solve(); 23 | return 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /1426A-Floor Number.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1426/A 2 | //Floor Number 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | int n,x; 9 | cin>>n>>x; 10 | int c = 2,ans = 1; 11 | while(c < n){ 12 | c += x; 13 | ans++; 14 | } 15 | cout<>t; 23 | while(t--) 24 | solve(); 25 | return 0; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /231A-Team.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/231/A 2 | #include 3 | using namespace std; 4 | int s=0,ct=0; 5 | int solve(){ 6 | int a,b,c; 7 | cin>>a>>b>>c; 8 | if(a==1 && b==1 || a==1 && c==1 || b==1 && c==1) 9 | ct++; 10 | return ct; 11 | } 12 | int main(){ 13 | ios::sync_with_stdio(0); 14 | cin.tie(0); 15 | int t; 16 | cin>>t; 17 | while(t--) 18 | { ct=0; 19 | solve(); 20 | s=s+ct; 21 | } 22 | cout< 5 | using namespace std; 6 | 7 | void solve(){ 8 | int n,m; 9 | double A,B; 10 | cin>>n>>m; 11 | A=n,B=m; 12 | long long ans=0; 13 | ans=ceil((A*B)/2); 14 | cout<>t; 22 | while(t--) 23 | solve(); 24 | return 0; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /1374A-Required Remainder.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1374/A 2 | //Required Remainder 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x,y,n; 7 | cin>>x>>y>>n; 8 | int k=x*(n/x)+y; 9 | if (k>n) { 10 | k-=x; 11 | } 12 | cout<>t; 20 | while(t--) 21 | solve(); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /791A-Bear and Big Brother.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/791/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int a,b,c=0; 6 | cin>>a>>b; 7 | while(a<=b) 8 | { a=a*3; 9 | b=b*2; 10 | c++; 11 | } 12 | cout<>t; 19 | while(t--) 20 | solve(); 21 | return 0;} -------------------------------------------------------------------------------- /41A-Translation.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/41/A 2 | #include 3 | 4 | using namespace std; 5 | void solve(){ 6 | string s,t,u; 7 | cin>>s; 8 | cin>>t; 9 | reverse(s.begin(),s.end()); 10 | if(s==t) 11 | cout<<"YES"; 12 | else 13 | cout<<"NO"; 14 | } 15 | int main(){ 16 | ios::sync_with_stdio(0); 17 | cin.tie(0); 18 | int t=1; 19 | //cin>>t; 20 | while(t--) 21 | solve(); 22 | return 0;} -------------------------------------------------------------------------------- /1337A-Ichihime and Triangle.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1337/A 2 | //Ichihime and Triangle 3 | 4 | #include 5 | #define ll long long 6 | #define pb push_back 7 | using namespace std; 8 | 9 | void solve(){ 10 | int a,b,c,d; 11 | cin>>a>>b>>c>>d; 12 | cout<>t; 20 | while(t--) 21 | solve(); 22 | return 0; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /1760A-Medium Number.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1760/A 2 | //Medium Number 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | int a,b,c; 9 | cin>>a>>b>>c; 10 | int arr[3]; 11 | arr[0]=a; 12 | arr[1]=b; 13 | arr[2]=c; 14 | sort(arr,arr+3); 15 | cout<>t; 23 | while(t--) 24 | solve(); 25 | return 0; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /1703A-YES or YES.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1703/A 2 | //YES or YES? 3 | #include 4 | using namespace std; 5 | 6 | void solve(){ 7 | string s; 8 | cin>>s; 9 | transform(s.begin(), s.end(), s.begin(), ::tolower); 10 | if(s=="yes")cout<<"YES"<>t; 20 | while(t--) 21 | solve(); 22 | return 0; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /1791A-Codeforces Checking.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1791/A 2 | //Codeforces Checking 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | string c; 9 | cin>>c; 10 | if(c=="c" || c=="o" || c=="d" || c=="e" || c=="f" || c=="r" || c=="s") cout<<"YES"<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /266A-Stones on the table.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/266/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n,c=0; 6 | cin>>n; 7 | string s; 8 | cin>>s; 9 | for(int i=0;i>t; 21 | while(t--) 22 | solve(); 23 | return 0;} -------------------------------------------------------------------------------- /344A-Magnets.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/344/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n,c=0; 6 | cin>>n; 7 | int a[n]; 8 | for(int i=0;i>a[i]; 11 | } 12 | for(int i=0;i>t; 25 | while(t--) 26 | solve(); 27 | return 0; 28 | } -------------------------------------------------------------------------------- /158A-Next Round.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/contest/158/problem/A 2 | #include 3 | using namespace std; 4 | 5 | void solve(){ 6 | int n,k,i,c=0; 7 | cin>>n>>k; 8 | int a[n]; 9 | for (i=0;i>a[i]; 12 | } 13 | int val=a[k-1]; 14 | for(i=0;i=val && a[i]>0) 17 | c++; 18 | } 19 | cout<>t; 26 | while(t--) 27 | { 28 | solve(); 29 | } 30 | return 0;} -------------------------------------------------------------------------------- /723A-The New Year Meeting Friends.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/723/A 2 | //The New Year: Meeting Friends 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | int x1, x2, x3; 8 | cin >> x1 >> x2 >> x3; 9 | 10 | int points[] = {x1, x2, x3}; 11 | sort(points, points + 3); 12 | 13 | int median = points[1]; 14 | 15 | int total_distance = abs(median - x1) + abs(median - x2) + abs(median - x3); 16 | 17 | cout << total_distance << endl; 18 | 19 | return 0; 20 | } -------------------------------------------------------------------------------- /977A-Wrong Subtraction.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/977/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | long long int n,k; 6 | cin>>n>>k; 7 | for(int i=0;i>t; 20 | while(t--) 21 | solve(); 22 | return 0;} -------------------------------------------------------------------------------- /1722A-Spell Check.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/contest/1722/problem/A 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int n; 7 | cin>>n; 8 | string s; 9 | cin>>s; 10 | string s1="Timur"; 11 | sort(s1.begin(),s1.end()); 12 | sort(s.begin(),s.end()); 13 | if(s==s1) 14 | cout<<"YES"<>t; 24 | while(t--) 25 | solve(); 26 | return 0; 27 | } -------------------------------------------------------------------------------- /467A-George and Accommodation.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/467/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n; 6 | cin>>n; 7 | int a[n],b[n],c=0; 8 | for (int i = 0; i < n; ++i) 9 | { 10 | cin>>a[i]>>b[i]; 11 | if(abs(a[i]-b[i])>=2) 12 | c++; 13 | } 14 | cout<>t; 21 | while(t--) 22 | { 23 | solve(); 24 | } 25 | return 0; 26 | } -------------------------------------------------------------------------------- /935A-Fafa and his Company.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/935/A 2 | //Fafa and his Company 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | long n,cnt=1; 9 | cin>>n; 10 | for(long i= 2;i*i<=n;i++){ 11 | if(n%i) continue; 12 | cnt+=2-(i*i==n); 13 | } 14 | cout<>t; 23 | while(t--) 24 | solve(); 25 | return 0; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /1367A-Short Substrings.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1367/A 2 | //Short Substrings 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | string b, a; 7 | cin >> b; 8 | for (int i = 0; i < b.length() - 1; i += 2) { 9 | a += b[i]; 10 | } 11 | a += b[b.length() - 1]; 12 | cout << a << endl; 13 | } 14 | int main() 15 | { 16 | ios::sync_with_stdio(0); 17 | cin.tie(0); 18 | int t; 19 | cin>>t; 20 | while(t--) 21 | solve(); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /282A-Bit++.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/282/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n,res=0,c=0; 6 | cin>>n; 7 | for (int i = 0; i < n; ++i) 8 | { string s; 9 | cin>>s; 10 | if(s[0]=='+' || s[2]=='+') 11 | c=c+1; 12 | else 13 | c=c-1; 14 | }cout<>t; 21 | while(t--) 22 | solve(); 23 | return 0; 24 | } -------------------------------------------------------------------------------- /443A-Anton and Letters.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/contest/1722/problem/A 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int n; 7 | cin>>n; 8 | string s; 9 | cin>>s; 10 | string s1="Timur"; 11 | sort(s1.begin(),s1.end()); 12 | sort(s.begin(),s.end()); 13 | if(s==s1) 14 | cout<<"YES"<>t; 24 | while(t--) 25 | solve(); 26 | return 0; 27 | } -------------------------------------------------------------------------------- /116A-Tram.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/116/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n; 6 | cin>>n; 7 | int a[n],b[n],sum=0,max=0; 8 | for(int i=0;i>a[i]>>b[i]; 11 | sum=sum+b[i]-a[i]; 12 | if(sum>max) 13 | max=sum; 14 | } 15 | cout<>t; 22 | while(t--) 23 | { 24 | solve(); 25 | } 26 | return 0; 27 | } -------------------------------------------------------------------------------- /546A-Soldier and Bananas.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/status?my=on 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int k,n,w,sum=0; 6 | cin>>k>>n>>w; 7 | for (int i = 1; i <=w; ++i) 8 | { 9 | sum=sum+(i*k); 10 | } 11 | if(sum>=n) 12 | cout<<(sum-n); 13 | else 14 | cout<<"0"; 15 | } 16 | int main(){ 17 | ios::sync_with_stdio(0); 18 | cin.tie(0); 19 | int t=1; 20 | //cin>>t; 21 | while(t--) 22 | solve(); 23 | return 0;} -------------------------------------------------------------------------------- /509A-Maximum in Table.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/509/A 2 | //Maximum in Table 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | int n; 9 | cin>>n; 10 | vector a(n,1); 11 | for(int i=1;i>t; 24 | while(t--) 25 | solve(); 26 | return 0; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /677A-Vanya and Fence.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/677/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n,h,sum=0; 6 | cin>>n>>h; 7 | int a[n]; 8 | for (int i = 0; i < n; ++i) 9 | { 10 | cin>>a[i]; 11 | if(a[i]>h) 12 | sum+=2; 13 | else 14 | sum++; 15 | } 16 | cout<>t; 23 | while(t--) 24 | { 25 | solve(); 26 | } 27 | return 0; 28 | } -------------------------------------------------------------------------------- /133A-HQ9+.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/133/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | string p; 6 | cin>>p; 7 | int flag=0; 8 | for(int i=0;i>t; 21 | while(t--){ 22 | solve(); 23 | } 24 | return 0; 25 | } -------------------------------------------------------------------------------- /1353A-Most Unstable Array.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1353/A 2 | //Most Unstable Array 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | long long int m,n; 9 | cin>>n>>m; 10 | if(n==1){ 11 | cout<<0<2){ 17 | cout<>t; 26 | while(t--) 27 | solve(); 28 | return 0; 29 | } 30 | 31 | -------------------------------------------------------------------------------- /1372A-Omkar and Completion.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1372/A 2 | //Omkar and Completion 3 | 4 | #include 5 | #define ll long long 6 | #define pb push_back 7 | using namespace std; 8 | 9 | void solve(){ 10 | int n; 11 | cin>>n; 12 | for(int i=0; i>t; 23 | while(t--) 24 | solve(); 25 | return 0; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /139A-Petr and Book.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/139/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n,i,s=0,a[7]; 6 | cin>>n; 7 | label: 8 | for( i=0;i<7;i++) 9 | { 10 | cin>>a[i]; 11 | s=s+a[i]; 12 | if(s>=n) 13 | break; 14 | } 15 | if(s>t; 25 | while(t--){ 26 | solve(); 27 | } 28 | return 0; 29 | } -------------------------------------------------------------------------------- /1676A-Lucky.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1676/A 2 | //Lucky? 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | string s; 9 | cin >> s; 10 | long c=0; 11 | for(long i=0;i<6;i++) 12 | { 13 | c+=(i<3 ? -1 : 1)*(s[i]-'0'); 14 | } 15 | cout<<(c?"NO":"YES")<>t; 23 | while(t--) 24 | solve(); 25 | return 0; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /228A-Is your horseshoe on the other hoof .cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/228/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | long long a,b,c,d,count=0; 6 | cin>>a>>b>>c>>d; 7 | if(a==b || a==c || a==d) 8 | count++; 9 | if(b==c || b==d) 10 | count++; 11 | if(c==d) 12 | count++; 13 | cout<>t; 20 | while(t--) 21 | { 22 | solve(); 23 | } 24 | return 0; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /427A-Police Recruits.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/427/A 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int n; 7 | cin>>n; 8 | int a[n],s=0,c=0,f=0; 9 | for(int i=0;i>a[i]; 11 | if(a[i]>0) 12 | c=c+a[i]; 13 | else 14 | { 15 | if(c<1) 16 | f++; 17 | else 18 | c--; 19 | } 20 | } 21 | cout<>t; 30 | while(t--) 31 | solve(); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /141A-Amusing Joke.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/141/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | string a,b,c,d; 6 | cin>>a; 7 | cin>>b; 8 | cin>>c; 9 | d=a+b; 10 | sort(d.begin(),d.end()); 11 | sort(c.begin(),c.end()); 12 | if(c==d) 13 | cout<<"YES"; 14 | else 15 | cout<<"NO"; 16 | } 17 | int main(){ 18 | ios::sync_with_stdio(0); 19 | cin.tie(0); 20 | int t=1; 21 | //cin>>t; 22 | while(t--) 23 | solve(); 24 | return 0; 25 | } -------------------------------------------------------------------------------- /1369A-FashionabLee.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1369/A 2 | //FashionabLee 3 | 4 | #include 5 | #define ll long long 6 | #define pb push_back 7 | using namespace std; 8 | 9 | void solve(){ 10 | int n; 11 | cin>>n; 12 | if(n%4==0){ 13 | cout<<"YES"<>t; 25 | while(t--) 26 | solve(); 27 | return 0; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /703A-Mishka and Game.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/703/A 2 | #include 3 | using namespace std; 4 | int a,b,c=0,c1=0; 5 | void solve(){ 6 | cin>>a>>b; 7 | if(a>b) 8 | c++; 9 | else if(a>t; 17 | while(t--) 18 | { 19 | solve(); 20 | } 21 | if(c>c1) 22 | cout<<"Mishka"; 23 | else if(c1>c) 24 | cout<<"Chris"; 25 | else 26 | cout<<"Friendship is magic!^^"; 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /136A-Presents.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/136/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n; 6 | cin>>n; 7 | int a[n],x[n]; 8 | for (int i = 0; i < n; ++i) 9 | { 10 | cin>>a[i]; 11 | x[a[i]]=i+1; 12 | } 13 | for (int i = 1; i < n+1; ++i) 14 | { 15 | cout<>t; 23 | while(t--) 24 | { 25 | solve(); 26 | } 27 | return 0; 28 | } -------------------------------------------------------------------------------- /1692A-Marathon.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1692/A 2 | //Marathon 3 | #include 4 | using namespace std; 5 | 6 | void solve(){ 7 | int a,b,c,d; 8 | cin>>a>>b>>c>>d; 9 | int count=0; 10 | if (b>a) 11 | count++; 12 | if (c>a) 13 | count++; 14 | if (d>a) 15 | count++; 16 | cout<>t; 24 | while(t--) 25 | solve(); 26 | return 0; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /61A-Ultr-Fast Mathematician.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/61/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | string a,b; 6 | cin>>a; 7 | cin>>b; 8 | for(int i=0;i>t; 20 | while(t--) 21 | solve(); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /69A-Young Physicist.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/69/A 2 | #include 3 | using namespace std; 4 | int main(){ 5 | ios::sync_with_stdio(0); 6 | cin.tie(0); 7 | int t,s1=0,s2=0,s3=0; 8 | cin>>t; 9 | while(t--) 10 | { 11 | int a[3]; 12 | for(int i=0;i<3;i++) 13 | { 14 | cin>>a[i]; 15 | } 16 | s1=s1+a[0]; 17 | s2=s2+a[1]; 18 | s3=s3+a[2]; 19 | } 20 | if(s1==0 && s2==0 && s3==0) 21 | cout<<"YES"; 22 | else 23 | cout<<"NO"; 24 | return 0;} -------------------------------------------------------------------------------- /1030A-In Search of an Easy Problem.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1030/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n; 6 | cin>>n; 7 | int s[n]; 8 | int flag=0; 9 | for (int i = 0; i < n; ++i) 10 | { 11 | cin>>s[i]; 12 | if(s[i]==1) 13 | {flag=1;break;} 14 | }if(flag==0) 15 | cout<<"EASY"; 16 | else 17 | cout<<"HARD"; 18 | } 19 | int main(){ 20 | ios::sync_with_stdio(0); 21 | cin.tie(0); 22 | int t=1; 23 | //cin>>t; 24 | while(t--){ 25 | solve(); 26 | } 27 | return 0; 28 | } -------------------------------------------------------------------------------- /112A-Petya and Strings.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/112/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | string a,b; 6 | cin>>a>>b; 7 | transform(a.begin(), a.end(), a.begin(), ::toupper); 8 | transform(b.begin(), b.end(), b.begin(), ::toupper); 9 | if(a==b) 10 | cout<<'0'; 11 | else if(a>b) 12 | cout<<'1'; 13 | else 14 | cout<<"-1"; 15 | } 16 | int main(){ 17 | ios::sync_with_stdio(0); 18 | cin.tie(0); 19 | int t=1; 20 | //cin>>t; 21 | while(t--){ 22 | solve(); 23 | } 24 | return 0; 25 | } -------------------------------------------------------------------------------- /266B-Queue at the school.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/266/B 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n,t; 6 | cin>>n>>t; 7 | string s; 8 | cin>>s; 9 | for (int j = 0; j < t; ++j) 10 | { 11 | 12 | for(int i=0;i>t; 24 | while(t--){ 25 | solve(); 26 | } 27 | return 0; 28 | } -------------------------------------------------------------------------------- /1409A-Yet Another Two Integers Problem.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1409/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int a, b; 6 | cin >> a >> b; 7 | 8 | int diff = abs(a - b); 9 | int moves = diff / 10; 10 | int rem = diff % 10; 11 | 12 | if (rem != 0) { 13 | moves += 1; 14 | } 15 | 16 | cout << moves << endl; 17 | } 18 | int main() 19 | { 20 | ios::sync_with_stdio(0); 21 | cin.tie(0); 22 | int t; 23 | cin>>t; 24 | while(t--) 25 | solve(); 26 | return 0; 27 | } -------------------------------------------------------------------------------- /200B-Drinks.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/200/B 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n; 6 | float sum=0; 7 | cin>>n; 8 | float a[n]; 9 | for(int i=0;i>a[i]; 12 | } 13 | for(int i=0;i>t; 25 | while(t--) 26 | solve(); 27 | return 0; 28 | } -------------------------------------------------------------------------------- /1624A-Plus One on the Subset.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1624/A 2 | //Plus One on the Subset 3 | #include 4 | using namespace std; 5 | 6 | void solve(){ 7 | long n; 8 | cin>>n; 9 | long mx(0), mn(1e9 + 7); 10 | for(long p = 0; p < n; p++){ 11 | long x; 12 | cin>>x; 13 | mn = (mn < x) ? mn : x; 14 | mx = (mx > x) ? mx : x; 15 | } 16 | cout<>t; 24 | while(t--) 25 | solve(); 26 | return 0; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /318A-Even Odds.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/contest/318/problem/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | long long int n,k; 6 | cin>>n>>k; 7 | if(n%2==0) 8 | { if(k<=(n/2)) 9 | cout<<2*k-1; 10 | else 11 | cout<<2*(k-(n/2)); 12 | } 13 | else 14 | { 15 | if(k<=(n/2)+1) 16 | cout<<2*k-1; 17 | else 18 | cout<<2*(k-((n/2)+1)); 19 | } 20 | } 21 | int main(){ 22 | ios::sync_with_stdio(0); 23 | cin.tie(0); 24 | int t=1; 25 | //cin>>t; 26 | while(t--){ 27 | solve(); 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /1092B-Teams Forming.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1092/B 2 | //Teams Forming 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n; 7 | cin >> n; 8 | int a[n]; 9 | for (int i = 0; i < n; i++) { 10 | cin >> a[i]; 11 | } 12 | sort(a, a+n); 13 | int problems = 0; 14 | for (int i = 0; i < n; i += 2) { 15 | problems += abs(a[i] - a[i+1]); 16 | } 17 | cout << problems << endl; 18 | } 19 | int main() 20 | { 21 | ios::sync_with_stdio(0); 22 | cin.tie(0); 23 | int t=1; 24 | //cin>>t; 25 | while(t--) 26 | solve(); 27 | return 0; 28 | } -------------------------------------------------------------------------------- /148A-Insomnia cure.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/148/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int k,l,m,n,d; 6 | cin>>k>>l>>m>>n>>d; 7 | int c=0; 8 | if((k==1)||(l==1)||(m==1)||(n==1)) 9 | {cout<>t; 22 | while(t--) 23 | { 24 | solve(); 25 | } 26 | return 0; 27 | } -------------------------------------------------------------------------------- /705A-Hulk.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/705/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n; 6 | cin>>n; 7 | string s1="I hate"; 8 | string s2="I love"; 9 | for (int i = 0; i < n; ++i) 10 | { 11 | if (i%2==0) 12 | cout << "I hate "; 13 | else 14 | cout << "I love "; 15 | if(i==(n-1)) 16 | cout<<"it "; 17 | else 18 | cout<<"that "; 19 | } 20 | } 21 | int main(){ 22 | ios::sync_with_stdio(0); 23 | cin.tie(0); 24 | int t=1; 25 | //cin>>t; 26 | while(t--){ 27 | solve(); 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /732A-Buy a Shovel.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/732/A 2 | //Buy a Shovel 3 | #include 4 | using namespace std; 5 | int main() { 6 | int k, r; 7 | cin >> k >> r; 8 | 9 | int cnt = 1; // Polycarp needs to buy at least one shovel 10 | int price = k; // price of the first shovel 11 | while (price % 10 != r && price % 10 != 0) { // while he can't pay without change 12 | cnt++; 13 | price += k; // buy one more shovel 14 | } 15 | cout << cnt << endl; // print the minimum number of shovels he needs to buy 16 | return 0; 17 | } 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /New Year and Hurry.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/750/A 2 | //New Year and Hurry 3 | #include 4 | using namespace std; 5 | int main() { 6 | int n, k; 7 | cin >> n >> k; 8 | int total_time = 0; 9 | for (int i = 1; i <= n; i++) { 10 | int problem_time = 5 * i; 11 | if (total_time + problem_time + k <= 240) { 12 | total_time += problem_time; 13 | } else { 14 | cout << i - 1 << endl; 15 | return 0; 16 | } 17 | } 18 | cout << n << endl; 19 | return 0; 20 | } 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /1593A-Elections.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | long a, b, c; 6 | cin>>a>>b>>c; 7 | long mx = (a > b) ? a : b; mx = (mx > c) ? mx : c; 8 | bool tie = (((a == mx) + (b == mx) + (c == mx)) > 1); 9 | long u = (a == mx) ? tie : (mx + 1 - a); 10 | long v = (b == mx) ? tie : (mx + 1 - b); 11 | long w = (c == mx) ? tie : (mx + 1 - c); 12 | cout<>t; 20 | while(t--) 21 | solve(); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /1389A-LCM Problem.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1389/A 2 | //LCM Problem 3 | 4 | #include 5 | #define ll long long 6 | #define pb push_back 7 | using namespace std; 8 | 9 | void solve(){ 10 | ll l,r,x=0,y=0; 11 | cin>>l>>r; 12 | if(l*2<=r){ 13 | x=l; 14 | y=l*2; 15 | } 16 | else{ 17 | x=-1; 18 | y=-1; 19 | } 20 | cout<>t; 28 | while(t--) 29 | solve(); 30 | return 0; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /1512A-Spy Detected!.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1512/A 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int n,b,f=1; 7 | cin>>n; 8 | int a[n]; 9 | for(int i=0;i>a[i]; 11 | for(int i=1;i>t; 33 | while(t--) 34 | solve(); 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /1535A-Fair Playoff.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1535/A 2 | //Fair Playoff 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | vector > a(4); 9 | for(long p = 0; p < 4; p++) 10 | { 11 | cin>>a[p].first; 12 | a[p].second=p; 13 | } 14 | sort(a.rbegin(),a.rend()); 15 | long x=a[0].second; 16 | long y=a[1].second; 17 | x/=2; 18 | y/= 2; 19 | cout<<(x==y?"NO":"YES")<>t; 27 | while(t--) 28 | solve(); 29 | return 0; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /581A-Vasya the Hipster.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/581/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int a,b; 6 | cin>>a>>b; 7 | int n=0,m=0; 8 | if(a==1 || b==1) 9 | n=1; 10 | if(a==b) 11 | n=a; 12 | if(a>b) 13 | {n=b; 14 | m=(a-b)/2;} 15 | if(a>t; 27 | while(t--) 28 | { 29 | solve(); 30 | } 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /1294A-Collecting Coins.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/contest/1294/problem/A 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | long long int a,b,c,n; 7 | cin>>a>>b>>c>>n; 8 | long long int m=max(a,max(b,c)); 9 | long long int s1=m-a; 10 | long long int s2=m-b; 11 | long long int s3=m-c; 12 | if(n-(s1+s2+s3)<0) 13 | cout<<"NO"<>t; 26 | while(t--) 27 | solve(); 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /1520B-Ordinary Numbers.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1520/B 2 | //Ordinary Numbers 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | long long n; 9 | cin>>n; 10 | long long c=0; 11 | for(long long i=1;i<=9;i++){ 12 | long long cur=i; 13 | for(long long j=1;j<=10;j++) 14 | { 15 | if(cur<=n) c++; 16 | else 17 | break; 18 | cur=10*cur+i; 19 | } 20 | } 21 | cout<>t; 29 | while(t--) 30 | solve(); 31 | return 0; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /1325B-CopyCopyCopyCopyCopy.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1325/B 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n; 6 | cin>>n; 7 | int c=n; 8 | int a[n]; 9 | for (int i = 0; i < n; ++i) 10 | { 11 | cin>>a[i]; 12 | } 13 | sort(a,a+n); 14 | for (int i = 0; i < n; ++i) 15 | { 16 | if(a[i]==a[i+1]) 17 | c--; 18 | } 19 | if(c==0) 20 | cout<<'1'<<"\n"; 21 | else 22 | cout<>t; 29 | while(t--){ 30 | solve(); 31 | } 32 | return 0; 33 | } 34 | 35 | -------------------------------------------------------------------------------- /263A-Beautiful Matrix.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/263/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int a[5][5],x=0,y=0; 6 | for(int i=0;i<5;i++) 7 | { 8 | for(int j=0;j<5;j++) 9 | cin>>a[i][j]; 10 | } 11 | for(int i=0;i<5;i++) 12 | { 13 | for(int j=0;j<5;j++) 14 | if(a[i][j]==1) 15 | { 16 | x=abs(i-2); 17 | y=abs(j-2); 18 | break; 19 | } 20 | } 21 | cout<>t; 28 | while(t--){ 29 | solve(); 30 | } 31 | return 0; 32 | } -------------------------------------------------------------------------------- /339A-Helpful Maths.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/339/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | string s; 6 | cin>>s; 7 | int a[s.length()/2-1]; 8 | int j=0; 9 | for (int i = 0; i < s.length(); ++i) 10 | { 11 | if(isalnum(s[i])) 12 | a[j++]=s[i]-'0'; 13 | } 14 | sort(a,a+j); 15 | for (int i = 0; i < j; ++i) 16 | { 17 | if(i>t; 28 | while(t--){ 29 | solve(); 30 | } 31 | return 0; 32 | } -------------------------------------------------------------------------------- /1454A-Special Permutation.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1454/A 2 | //Special Permutation 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | long long n; 9 | cin>>n; 10 | vectorv; 11 | for(int i=n; i>0; i--) 12 | v.push_back(i); 13 | for(int i=0; i>t; 27 | while(t--) 28 | solve(); 29 | return 0; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /1742B-Increasing.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/contest/1742/problem/B 2 | //Increasing 3 | #include 4 | using namespace std; 5 | #include 6 | using namespace std; 7 | void solve(){ 8 | setst; 9 | int a,f=1; 10 | cin>>a; 11 | for(int i=0;i>x; 14 | auto it =st.emplace(x); 15 | if(it.second){int w=0;} 16 | else f=0; 17 | } 18 | if(f) cout<<"YES"<>t; 28 | while(t--) 29 | solve(); 30 | return 0; 31 | } -------------------------------------------------------------------------------- /1385A-Three Pairwise Maximums.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1385/A 2 | //Three Pairwise Maximums 3 | 4 | #include 5 | #define ll long long 6 | #define pb push_back 7 | using namespace std; 8 | 9 | void solve(){ 10 | ll x,y,z; 11 | cin>>x>>y>>z; 12 | if(x > y)swap(x,y); 13 | if(x > z)swap(x,z); 14 | if(y > z)swap(y,z); 15 | if(y == z){ 16 | cout<<"YES"<>t; 27 | while(t--) 28 | solve(); 29 | return 0; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /1619A-Square String.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1619/A 2 | //Square String? 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | string s; 9 | cin >> s; 10 | if(s.size()%2){ 11 | cout<<"NO"<>t; 33 | while(t--) 34 | solve(); 35 | return 0; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /260A-Adding Digits.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/contest/260/problem/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int a,b,n; 6 | cin>>a>>b>>n; 7 | int flag=0; 8 | for(int k=0;k<=9;k++) 9 | { if((a*10+k)%b==0) 10 | {a=a*10+k;flag=1;break;} 11 | } 12 | if(flag==1) 13 | {cout<>t; 24 | while(t--) 25 | { 26 | solve(); 27 | } 28 | return 0; 29 | } 30 | 31 | -------------------------------------------------------------------------------- /472A-Design Tutorial Learn from Math.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/472/A 2 | //Design Tutorial: Learn from Math 3 | #include 4 | using namespace std; 5 | 6 | bool is_composite(int n) { 7 | for (int i = 2; i <= sqrt(n); i++) { 8 | if (n % i == 0) { 9 | return true; 10 | } 11 | } 12 | return false; 13 | } 14 | 15 | int main() { 16 | int n; 17 | cin >> n; 18 | 19 | for (int i = 4; i < n; i++) { 20 | if (is_composite(i) && is_composite(n - i)) { 21 | cout << i << " " << n - i << endl; 22 | break; 23 | } 24 | } 25 | 26 | return 0; 27 | } 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /9A-Die Roll.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/9/A 2 | //Die Roll 3 | 4 | #include 5 | using namespace std; 6 | 7 | int gcd(int a,int b) 8 | { 9 | return (b==0) ? a:gcd(b, a%b); 10 | } 11 | 12 | void solve(){ 13 | int f,s; 14 | cin>>f>>s; 15 | if(f>t; 33 | while(t--) 34 | solve(); 35 | return 0; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /59A-Word.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/59/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | string s; 6 | int l=0,u=0; 7 | cin>>s; 8 | for(int i=0;i=u) 16 | transform(s.begin(), s.end(), s.begin(), ::tolower); 17 | else 18 | transform(s.begin(), s.end(), s.begin(), ::toupper); 19 | cout<>t; 26 | while(t--) 27 | solve(); 28 | return 0;} -------------------------------------------------------------------------------- /32A-Reconnaissance 2.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/34/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n; 6 | cin>>n; 7 | int a[n],i=0,m=0,x=0; 8 | for( i=0;i>a[i]; 11 | } 12 | m=abs(a[0]-a[n-1]); 13 | for( i=1;i>t; 30 | while(t--){ 31 | solve(); 32 | } 33 | return 0; 34 | } -------------------------------------------------------------------------------- /785A-Anton and Polyhedrons.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/785/A 2 | #include 3 | using namespace std; 4 | #define ll long long int 5 | void solve(){ 6 | int n,c=0; 7 | cin>>n; 8 | string s; 9 | for(int i=0;i>s; 12 | if(s=="Tetrahedron") 13 | c+=4; 14 | if(s=="Cube") 15 | c+=6; 16 | if(s=="Octahedron") 17 | c+=8; 18 | if(s=="Dodecahedron") 19 | c+=12; 20 | if(s=="Icosahedron") 21 | c+=20; 22 | } 23 | cout<>t; 30 | while(t--) 31 | solve();{ 32 | 33 | } 34 | return 0; 35 | } -------------------------------------------------------------------------------- /155A-I_love_%username%.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/155/A 2 | //I_love_%username% 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n, a, best, worst, amazing = 0; 7 | cin >> n >> best; 8 | worst = best; 9 | for(int i=1; i> a; 11 | if(a > best){ 12 | best = a; 13 | amazing++; 14 | } 15 | else if(a < worst){ 16 | worst = a; 17 | amazing++; 18 | } 19 | } 20 | cout << amazing << endl; 21 | 22 | } 23 | int main() 24 | { 25 | ios::sync_with_stdio(0); 26 | cin.tie(0); 27 | int t=1; 28 | //cin>>t; 29 | while(t--) 30 | solve(); 31 | return 0; 32 | } -------------------------------------------------------------------------------- /448A-Rewards.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/448/A 2 | //Rewards 3 | #include 4 | using namespace std; 5 | 6 | void solve(){ 7 | int a1, a2, a3, b1, b2, b3, n; 8 | cin >> a1 >> a2 >> a3 >> b1 >> b2 >> b3 >> n; 9 | 10 | int totalCups = a1 + a2 + a3; 11 | int totalMedals = b1 + b2 + b3; 12 | int remainingShelves = n - ((totalCups + 4) / 5 + (totalMedals + 9) / 10); 13 | 14 | if (remainingShelves >= 0) { 15 | cout << "YES" << endl; 16 | } else { 17 | cout << "NO" << endl; 18 | } 19 | } 20 | int main() 21 | { 22 | ios::sync_with_stdio(0); 23 | cin.tie(0); 24 | int t=1; 25 | //cin>>t; 26 | while(t--) 27 | solve(); 28 | return 0; 29 | } -------------------------------------------------------------------------------- /758A-Holiday Of Equality.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/758/A 2 | //Holiday Of Equality 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n; 7 | cin >> n; 8 | 9 | vector a(n); 10 | for (int i = 0; i < n; i++) { 11 | cin >> a[i]; 12 | } 13 | 14 | int max_welfare = *max_element(a.begin(), a.end()); 15 | int total_spending = 0; 16 | for (int i = 0; i < n; i++) { 17 | total_spending += max_welfare - a[i]; 18 | } 19 | 20 | cout << total_spending << endl; 21 | 22 | } 23 | int main() 24 | { 25 | ios::sync_with_stdio(0); 26 | cin.tie(0); 27 | int t=1; 28 | //cin>>t; 29 | while(t--) 30 | solve(); 31 | return 0; 32 | } -------------------------------------------------------------------------------- /1360B-Honest Coach.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1360/B 2 | //Honest Coach 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | int n,dif=0; 9 | cin>>n; 10 | int a[n]; 11 | for(int i=0;i>a[i]; 13 | } 14 | sort(a,a+n); 15 | vectorv; 16 | for(int i=1;i>t; 30 | while(t--) 31 | solve(); 32 | return 0; 33 | } 34 | 35 | -------------------------------------------------------------------------------- /315A-Sereja and Bottles.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/contest/315/problem/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n; 6 | cin>>n; 7 | int c=n; 8 | int a[n],b[n]; 9 | for (int i = 0; i < n; ++i) 10 | { 11 | cin>>a[i]>>b[i]; 12 | } 13 | for (int i = 0; i < n; ++i) 14 | { 15 | for (int j = 0; j < n; ++j) 16 | { 17 | if((b[j]==a[i])&&(j!=i)) 18 | {c--;break;} 19 | } 20 | } 21 | cout<>t; 28 | while(t--) 29 | { 30 | solve(); 31 | } 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /520A-Pangram.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/520/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n; 6 | string s; 7 | cin>>n; 8 | cin>>s; 9 | char j='A'; 10 | transform(s.begin(),s.end(),s.begin(),::toupper); 11 | if(n>=26) 12 | { 13 | for (int i = 0; i <26; ++i) 14 | { 15 | if(s.find(j)!=-1) 16 | j++; 17 | else {cout<<"NO";return;} 18 | } cout<<"YES"; 19 | } 20 | else 21 | cout<<"NO"; 22 | } 23 | int main(){ 24 | ios_base::sync_with_stdio(0); 25 | cin.tie(0); cout.tie(0); 26 | int t=1; 27 | //cin>>t; 28 | while(t--) 29 | { 30 | solve(); 31 | } 32 | return 0; 33 | } -------------------------------------------------------------------------------- /734A-Anton and Danik.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/734/A 2 | #include 3 | 4 | using namespace std; 5 | void solve(){ 6 | string s; 7 | int n,ca=0,cd=0; 8 | cin>>n; 9 | cin>>s; 10 | for (int i = 0; i < s.length(); ++i) 11 | { 12 | if(s[i]=='A') 13 | ca++; 14 | if(s[i]=='D') 15 | cd++; 16 | } 17 | if(ca>cd) 18 | cout<<"Anton"; 19 | else if(ca==cd) 20 | cout<<"Friendship"; 21 | else 22 | cout<<"Danik"; 23 | } 24 | int main(){ 25 | ios::sync_with_stdio(0); 26 | cin.tie(0); 27 | int t=1; 28 | //cin>>t; 29 | while(t--) 30 | solve(); 31 | return 0;} -------------------------------------------------------------------------------- /1296A-Array with Odd Sum.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1296/A 2 | //Array with Odd Sum 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | int odd,even,n; 9 | int a[10000]; 10 | odd=even=0; 11 | cin>>n; 12 | for(int i=0; i>a[i]; 15 | if(a[i]%2==0) 16 | even++; 17 | else 18 | odd++; 19 | } 20 | if (odd & 1 or (odd > 0 and even > 0)) 21 | cout<<"YES"<>t; 31 | while(t--) 32 | solve(); 33 | return 0; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /749A-Bachgold Problem.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/749/A 2 | //Bachgold Problem 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | int n,div=0; 9 | cin>>n; 10 | if(n%2==1){ 11 | div=(n/2); 12 | cout<>t; 31 | while(t--) 32 | solve(); 33 | return 0; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /707A-Brain's Photos.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/707/A 2 | //Brain's Photos 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | long n,m; 9 | cin>>n>>m; 10 | bool color=false; 11 | for(int i=0;i>x; 16 | if(x=='C'||x=='M'||x=='Y') 17 | { 18 | color=true; 19 | break; 20 | } 21 | } 22 | } 23 | cout<<(color?"#Color":"#Black&White")<>t; 31 | while(t--) 32 | solve(); 33 | return 0; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /1234A-Equalize Prices Again.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1234/A 2 | //Equalize Prices Again 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n; 7 | cin >> n; 8 | int a[n]; 9 | for(int i = 0; i < n; i++) { 10 | cin >> a[i]; 11 | } 12 | int sum = accumulate(a, a + n, 0); 13 | int minPrice = *min_element(a, a + n); 14 | int newPrice = (sum + n - 1) / n; 15 | if(newPrice < minPrice) { 16 | newPrice = minPrice; 17 | } 18 | cout << newPrice << endl; 19 | } 20 | int main() 21 | { 22 | ios::sync_with_stdio(0); 23 | cin.tie(0); 24 | int t; 25 | cin>>t; 26 | while(t--) 27 | solve(); 28 | return 0; 29 | } -------------------------------------------------------------------------------- /1352A-Sum of Round Numbers.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1352/A 2 | //Sum of Round Numbers 3 | #include 4 | using namespace std; 5 | int main() { 6 | int t; 7 | cin >> t; 8 | while (t--) { 9 | string n; 10 | cin >> n; 11 | vector ans; 12 | for (int i = n.size()-1; i >= 0; i--) { 13 | if (n[i] != '0') { 14 | int d = n[i] - '0'; 15 | ans.push_back(d * pow(10, n.size()-i-1)); 16 | } 17 | } 18 | cout << ans.size() << endl; 19 | for (int x : ans) { 20 | cout << x << " "; 21 | } 22 | cout << endl; 23 | } 24 | return 0; 25 | } 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /1560A-Dislike of Threes.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1560/A 2 | //Dislike of Threes 3 | #include 4 | using namespace std; 5 | 6 | bool is_disliked(int n) { 7 | return n % 3 == 0 || n % 10 == 3; 8 | } 9 | 10 | int get_kth_liked_integer(int k) { 11 | int count = 0; 12 | int n = 1; 13 | while (true) { 14 | if (!is_disliked(n)) { 15 | count++; 16 | if (count == k) { 17 | return n; 18 | } 19 | } 20 | n++; 21 | } 22 | } 23 | 24 | int main() { 25 | int t; 26 | cin >> t; 27 | while (t--) { 28 | int k; 29 | cin >> k; 30 | cout << get_kth_liked_integer(k) << endl; 31 | } 32 | return 0; 33 | } 34 | 35 | -------------------------------------------------------------------------------- /1472A-Cards for Friends.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1472/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int w, h, n; 6 | cin >> w >> h >> n; 7 | 8 | int cnt = 1; 9 | while (w % 2 == 0 || h % 2 == 0) { 10 | if (w % 2 == 0) { 11 | w /= 2; 12 | } else { 13 | h /= 2; 14 | } 15 | cnt *= 2; 16 | } 17 | 18 | if (cnt >= n) { 19 | cout << "YES" << endl; 20 | } else { 21 | cout << "NO" << endl; 22 | } 23 | } 24 | int main() 25 | { 26 | ios::sync_with_stdio(0); 27 | cin.tie(0); 28 | int t; 29 | cin>>t; 30 | while(t--) 31 | solve(); 32 | return 0; 33 | } -------------------------------------------------------------------------------- /80A-Panoramix's Prediction.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/80/A 2 | #include 3 | using namespace std; 4 | bool prime(int n) 5 | { 6 | for(int i=2;i>n>>m; 14 | for(int i=n+1;i<=50;i++) 15 | { 16 | if(prime(i)==true) 17 | { 18 | p=i; 19 | break; 20 | } 21 | } 22 | if(p==m) 23 | cout<<"YES"; 24 | else 25 | cout<<"NO"; 26 | } 27 | int main(){ 28 | ios::sync_with_stdio(0); 29 | cin.tie(0); 30 | int t=1; 31 | //cin>>t; 32 | while(t--) 33 | solve(); 34 | return 0; 35 | } -------------------------------------------------------------------------------- /1669A-Division.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/contest/1669/problem/A 2 | //Division? 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | long r; 9 | cin>>r; 10 | int res=1; 11 | if(r<=1399) 12 | { 13 | res=4; 14 | } 15 | else if(r<=1599) 16 | { 17 | res=3; 18 | } 19 | else if(r<=1899) 20 | { 21 | res=2; 22 | } 23 | else if(1900<=r) 24 | { 25 | res=1; 26 | } 27 | cout<<"Division "<>t; 35 | while(t--) 36 | solve(); 37 | return 0; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /1520A-Do Not Be Distracted!.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1520/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n,c=0; 6 | cin>>n; 7 | char s[1000]; 8 | char s1[1000]; 9 | cin>>s; 10 | int j=0; 11 | for(int i=0;i>t; 33 | while(t--) 34 | { 35 | solve(); 36 | } 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /1343B-Balanced Array.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1343/B 2 | //Balanced Array 3 | #include 4 | long long int a[1000000]; 5 | using namespace std; 6 | int main() 7 | { 8 | int t; 9 | long long int n,sum1,sum2,d,i,j; 10 | cin>>t; 11 | while(t--) 12 | { 13 | sum1=sum2=0; 14 | cin>>n; 15 | 16 | if(n%4!=0){ 17 | cout<<"NO\n"; 18 | } 19 | else{ 20 | cout<<"YES\n"; 21 | for(int i=2; i<=n; i+=2){ 22 | cout< 3 | using namespace std; 4 | void solve(){ 5 | string s; 6 | cin>>s; 7 | for(int i=0;i>t; 30 | while(t--) 31 | solve(); 32 | return 0; 33 | } -------------------------------------------------------------------------------- /490A-Team Olympiad.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/490/A 2 | //Team Olympiad 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n; 7 | cin>>n; 8 | vector math,prog,eu; 9 | for(int i=1;i<=n;i++){ 10 | int x; 11 | cin>>x; 12 | if(x==1) prog.push_back(i); 13 | else if(x==2) math.push_back(i); 14 | else if(x==3) eu.push_back(i); 15 | } 16 | int ans=min(math.size(),min(prog.size(),eu.size())); 17 | cout<>t; 29 | while(t--) 30 | solve(); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /1367B-Even Array.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1367/B 2 | //Even Array 3 | #include 4 | using namespace std; 5 | 6 | void solve(){ 7 | int n,c=0,f=0; 8 | cin>>n; 9 | int a[n]; 10 | for(int i=0;i>a[i]; 12 | } 13 | int o=0,e=0; 14 | for(int i=0;i>t; 33 | while(t--) 34 | solve(); 35 | return 0; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /469A-I wanna be the guy.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/469/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n,c=1; 6 | cin>>n; 7 | int p; 8 | cin>>p; 9 | int a[1000]; 10 | for(int i=0;i>a[i]; 13 | } 14 | int q; 15 | cin>>q; 16 | for(int j=p;j>a[j]; 19 | } 20 | sort(a,a+p+q); 21 | for (int i = 1; i < p+q; ++i) 22 | { 23 | if(a[i-1]!=a[i]){ 24 | c++; 25 | } 26 | }if(p==0&&q==0){ 27 | cout<<"Oh, my keyboard!"<<"\n"; 28 | return; 29 | } 30 | if(c==n){ 31 | cout<<"I become the guy."<<"\n"; 32 | return; 33 | } 34 | 35 | cout<<"Oh, my keyboard!"<<"\n"; 36 | } 37 | int main(){ 38 | ios::sync_with_stdio(0); 39 | cin.tie(0); 40 | int t=1; 41 | //cin>>t; 42 | while(t--) 43 | solve(); 44 | return 0;} -------------------------------------------------------------------------------- /1348A-Phoenix and Balance.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1348/A 2 | //Phoenix and Balance 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | int n,a[10000]; 9 | long long int ans=0,sum1=0,sum2=0; 10 | int div=0; 11 | cin>>n; 12 | int k=0; 13 | for(int i=1;i<=n;i++){ 14 | a[k++]=pow(2,i); 15 | } 16 | div=n/2; 17 | sum1=a[n-1]; 18 | for(int i=0;i<=div-2;i++){ 19 | sum1+=a[i]; 20 | } 21 | for(int i=div-1;i>t; 33 | while(t--) 34 | solve(); 35 | return 0; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /236A-Boy or Girl.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/236/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | string s; 6 | long long c=0,flag=0; 7 | cin>>s; 8 | for (int i = 0; i < s.length(); ++i) 9 | { 10 | flag=0; 11 | for (int j = 0; j < i; ++j) 12 | { 13 | if(s[i]==s[j]){ 14 | flag=1; 15 | break; 16 | } 17 | 18 | } 19 | if(flag==0){ 20 | c++; 21 | } 22 | } 23 | if((c%2)==0) 24 | cout<<"CHAT WITH HER!"; 25 | else 26 | cout<<"IGNORE HIM!"; 27 | } 28 | int main(){ 29 | ios::sync_with_stdio(0); 30 | cin.tie(0); 31 | int t=1; 32 | //cin>>t; 33 | while(t--) 34 | solve(); 35 | return 0;} -------------------------------------------------------------------------------- /431A-Black Square.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/contest/431/problem/A 2 | //Black Square 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | int main() { 9 | int a1, a2, a3, a4; 10 | cin >> a1 >> a2 >> a3 >> a4; 11 | 12 | string s; 13 | cin >> s; 14 | 15 | int totalCalories = 0; 16 | for (char c : s) { 17 | switch (c) { 18 | case '1': 19 | totalCalories += a1; 20 | break; 21 | case '2': 22 | totalCalories += a2; 23 | break; 24 | case '3': 25 | totalCalories += a3; 26 | break; 27 | case '4': 28 | totalCalories += a4; 29 | break; 30 | } 31 | } 32 | 33 | cout << totalCalories << endl; 34 | 35 | return 0; 36 | } -------------------------------------------------------------------------------- /144A-Arrival of the General.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/144/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n; 6 | cin>>n; 7 | int a[n]; 8 | int pos1=0,pos2=0; 9 | for (int i = 0; i < n; ++i) 10 | { 11 | cin>>a[i]; 12 | } 13 | auto min=min_element(a,a+n); 14 | auto max=max_element(a,a+n); 15 | for (int i = 0; i < n; ++i) 16 | { 17 | if(a[i]==*min) 18 | { 19 | pos1=i;} 20 | } 21 | for (int i = 0; i < n; ++i) 22 | { 23 | if(a[i]==*max) 24 | { 25 | pos2=i;break;} 26 | } 27 | if (pos1>t; 37 | while(t--){ 38 | solve(); 39 | } 40 | return 0; 41 | } -------------------------------------------------------------------------------- /510A-Fox and Snake.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/510/A 2 | //Fox and Snake 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int a,b; 7 | cin>>a>>b; 8 | for(int i=1; i<=a; i++) 9 | { 10 | for(int j=0; j>t; 37 | while(t--) 38 | solve(); 39 | return 0; 40 | } -------------------------------------------------------------------------------- /1154A-Restoring Three Number.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1154/A 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | long long int w,x,y,z,mx,a,b,c; 7 | cin>>w>>x>>y>>z; 8 | mx=max(max(max(w,x),y),z); 9 | if(mx==x) 10 | { 11 | a=mx-z; 12 | b=mx-y; 13 | c=mx-w; 14 | cout<>t;<< 45 | while(t--) 46 | solve(); 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /271A-Beautiful Year.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/271/A 2 | #include 3 | 4 | using namespace std; 5 | int check(int n) 6 | { int f=0; 7 | string s=to_string(n); 8 | for(int i=0;i>n; 23 | for(i=n+1;i<=10000;i++) 24 | { 25 | if(check(i)==1) 26 | { 27 | flag=1; 28 | break; 29 | } 30 | } 31 | cout<>t; 38 | while(t--) 39 | solve(); 40 | return 0;} -------------------------------------------------------------------------------- /268A-Games.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/268/A 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | int n; 8 | cin >> n; 9 | 10 | 11 | map> colors; 12 | 13 | 14 | for (int i = 1; i <= n; i++) { 15 | int home_color, guest_color; 16 | cin >> home_color >> guest_color; 17 | colors[i] = make_pair(home_color, guest_color); 18 | } 19 | 20 | int count = 0; 21 | 22 | for (int i = 1; i <= n; i++) { 23 | for (int j = 1; j <= n; j++) { 24 | if (i != j) { 25 | int host_color = colors[i].first; 26 | int guest_color = colors[j].second; 27 | if (host_color == guest_color) { 28 | count++; 29 | } 30 | } 31 | } 32 | } 33 | 34 | 35 | cout << count << endl; 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /1385B-Restore the Permutation by Merger.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1385/B 2 | //Restore the Permutation by Merger 3 | 4 | #include 5 | #define ll long long 6 | #define pb push_back 7 | using namespace std; 8 | 9 | void solve(){ 10 | ll n,a[110]; 11 | cin>>n; 12 | n *= 2; 13 | for(int i=0; i>a[i]; 15 | } 16 | int pos[110]; 17 | fill(pos,pos+110,0); 18 | 19 | vectorv; 20 | for(int i=n-1; i>=0; i--){ 21 | if(pos[a[i]]==0){ 22 | pos[a[i]]=1; 23 | v.push_back(a[i]); 24 | } 25 | } 26 | int s; 27 | s=v.size(); 28 | for(int i=s-1; i>=0; i--) 29 | cout<>t; 38 | while(t--) 39 | solve(); 40 | return 0; 41 | } 42 | 43 | -------------------------------------------------------------------------------- /1399A-Remove Smallest.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1399/A 2 | //Remove Smallest 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n; 7 | cin >> n; 8 | 9 | vector a(n); 10 | for (int i = 0; i < n; i++) { 11 | cin >> a[i]; 12 | } 13 | 14 | sort(a.begin(), a.end()); 15 | 16 | while (a.size() > 1) { 17 | int i = 0; 18 | while (i < a.size()-1 && abs(a[i] - a[i+1]) > 1) { 19 | i++; 20 | } 21 | if (i == a.size()-1) { 22 | break; 23 | } 24 | a.erase(a.begin()+i); 25 | } 26 | 27 | if (a.size() == 1) { 28 | cout << "YES" << endl; 29 | } else { 30 | cout << "NO" << endl; 31 | } 32 | } 33 | int main() 34 | { 35 | ios::sync_with_stdio(0); 36 | cin.tie(0); 37 | int t; 38 | cin>>t; 39 | while(t--) 40 | solve(); 41 | return 0; 42 | } -------------------------------------------------------------------------------- /1462A-Favorite Sequence.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1462/A 2 | //Favorite Sequence 3 | 4 | #include 5 | #define ll long long 6 | #define pb push_back 7 | using namespace std; 8 | 9 | void solve(){ 10 | ll n,a[305]; 11 | cin>>n; 12 | for(ll i=1; i<=n; i++){ 13 | cin>>a[i]; 14 | } 15 | ll div = 0; 16 | vectorv; 17 | div = (n/2) + (n%2); 18 | for(ll i=1; i<=div; i++){ 19 | if(n&1){ 20 | if(i == div){ 21 | v.pb(a[i]); 22 | continue; 23 | } 24 | } 25 | v.pb(a[i]); 26 | v.pb(a[n-i+1]); 27 | } 28 | for(ll i=0; i>t; 39 | while(t--) 40 | solve(); 41 | return 0; 42 | } 43 | 44 | -------------------------------------------------------------------------------- /1353B-Two Arrays And Swaps.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1353/B 2 | //Two Arrays And Swaps 3 | #include 4 | using namespace std; 5 | 6 | void solve(){ 7 | int n,k; 8 | cin>>n>>k; 9 | int a[101],b[101]; 10 | for(int i=0; i>a[i]; 12 | } 13 | for(int i=0; i>b[i]; 15 | } 16 | sort(a,a+n); 17 | sort(b,b+n,greater()); 18 | for(int i=0; i a[j]){ 21 | swap(a[j],b[j]); 22 | break; 23 | } 24 | } 25 | } 26 | int sum=0; 27 | for(int i=0; i>t; 38 | while(t--) 39 | solve(); 40 | return 0; 41 | } 42 | 43 | -------------------------------------------------------------------------------- /381A-Sereja and Dima.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/contest/381/problem/A 2 | //Sereja and Dima 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | int n; 8 | cin >> n; 9 | 10 | vector cards(n); 11 | for (int i = 0; i < n; i++) { 12 | cin >> cards[i]; 13 | } 14 | 15 | int left = 0, right = n - 1; 16 | int sereja_score = 0, dima_score = 0; 17 | 18 | bool sereja_turn = true; 19 | while (left <= right) { 20 | int card_to_play; 21 | if (cards[left] > cards[right]) { 22 | card_to_play = cards[left]; 23 | left++; 24 | } else { 25 | card_to_play = cards[right]; 26 | right--; 27 | } 28 | 29 | if (sereja_turn) { 30 | sereja_score += card_to_play; 31 | } else { 32 | dima_score += card_to_play; 33 | } 34 | 35 | sereja_turn = !sereja_turn; 36 | } 37 | 38 | cout << sereja_score << " " << dima_score << endl; 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /1472B-Fair Division.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1472/B 2 | //Fair Division 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | int div=0,sum=0,one=0,n,a; 9 | cin>>n; 10 | for(int i=0;i>a; 12 | if(a==1){ 13 | one++; 14 | sum++; 15 | } 16 | else 17 | sum+=2; 18 | } 19 | if(sum%2==0){ 20 | div=sum/2; 21 | if(div%2==0){ 22 | cout<<"YES"<>t; 43 | while(t--) 44 | solve(); 45 | return 0; 46 | } 47 | 48 | -------------------------------------------------------------------------------- /432A-Choosing Teams.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/432/A 2 | //Choosing Teams 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n, k; 7 | cin >> n >> k; 8 | 9 | vector y(n); 10 | for (int i = 0; i < n; i++) { 11 | cin >> y[i]; 12 | } 13 | 14 | int cnt = 0; 15 | for (int i = 0; i < n; i++) { 16 | if (y[i] + k <= 5) { 17 | cnt++; 18 | } 19 | } 20 | 21 | vector eligible(cnt); 22 | int j = 0; 23 | for (int i = 0; i < n; i++) { 24 | if (y[i] + k <= 5) { 25 | eligible[j++] = i; 26 | } 27 | } 28 | 29 | sort(eligible.begin(), eligible.end(), [&](int i, int j) { return y[i] > y[j]; }); 30 | 31 | int teams = 0; 32 | for (int i = 0; i < cnt; i += 3) { 33 | if (i + 2 < cnt) { 34 | teams++; 35 | } 36 | } 37 | 38 | cout << teams << endl; 39 | } 40 | int main() 41 | { 42 | ios::sync_with_stdio(0); 43 | cin.tie(0); 44 | int t=1; 45 | //cin>>t; 46 | while(t--) 47 | solve(); 48 | return 0; 49 | } -------------------------------------------------------------------------------- /451B-Sort The Array.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/451/B 2 | //Sort the Array 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | int n; 8 | cin >> n; 9 | 10 | vector a(n); 11 | for (int i = 0; i < n; i++) { 12 | cin >> a[i]; 13 | } 14 | 15 | int start = -1, end = -1; 16 | for (int i = 0; i < n-1; i++) { 17 | if (a[i] > a[i+1]) { 18 | start = i; 19 | break; 20 | } 21 | } 22 | 23 | if (start == -1) { 24 | cout << "yes" << endl; 25 | cout << "1 1" << endl; 26 | return 0; 27 | } 28 | 29 | for (int i = start+1; i < n-1; i++) { 30 | if (a[i] < a[i+1]) { 31 | end = i; 32 | break; 33 | } 34 | } 35 | 36 | if (end == -1) { 37 | end = n-1; 38 | } 39 | 40 | reverse(a.begin()+start, a.begin()+end+1); 41 | for (int i = 0; i < n-1; i++) { 42 | if (a[i] > a[i+1]) { 43 | cout << "no" << endl; 44 | return 0; 45 | } 46 | } 47 | 48 | cout << "yes" << endl; 49 | cout << start+1 << " " << end+1 << endl; 50 | return 0; 51 | } -------------------------------------------------------------------------------- /275A-Lights Out.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/275/A 2 | //Lights Out 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int grid[3][3]; 7 | for (int i = 0; i < 3; i++) { 8 | for (int j = 0; j < 3; j++) { 9 | cin >> grid[i][j]; 10 | } 11 | } 12 | 13 | int lights[3][3] = {{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}; 14 | 15 | for (int i = 0; i < 3; i++) { 16 | for (int j = 0; j < 3; j++) { 17 | if (grid[i][j] % 2 == 1) { 18 | lights[i][j] = 1 - lights[i][j]; 19 | if (i > 0) lights[i-1][j] = 1 - lights[i-1][j]; 20 | if (j > 0) lights[i][j-1] = 1 - lights[i][j-1]; 21 | if (i < 2) lights[i+1][j] = 1 - lights[i+1][j]; 22 | if (j < 2) lights[i][j+1] = 1 - lights[i][j+1]; 23 | } 24 | } 25 | } 26 | 27 | for (int i = 0; i < 3; i++) { 28 | for (int j = 0; j < 3; j++) { 29 | cout << lights[i][j]; 30 | } 31 | cout << endl; 32 | } 33 | } 34 | int main() 35 | { 36 | ios::sync_with_stdio(0); 37 | cin.tie(0); 38 | int t=1; 39 | //cin>>t; 40 | while(t--) 41 | solve(); 42 | return 0; 43 | } -------------------------------------------------------------------------------- /248A-Cupboards.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/248/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n,sa=0,sb=0; 6 | cin>>n; 7 | int a[n],b[n]; 8 | for(int i=0;i>a[i]>>b[i]; 11 | sa=sa+a[i]; 12 | sb=sb+b[i]; 13 | } 14 | cout<<(min(sa,n-sa)+min(sb,n-sb)); 15 | } 16 | int main(){ 17 | ios::sync_with_stdio(0); 18 | cin.tie(0); 19 | int t=1; 20 | //cin>>t; 21 | while(t--){ 22 | solve(); 23 | } 24 | return 0; 25 | } 26 | 27 | 28 | 29 | //ANOTHER APPROACH:- 30 | 31 | 32 | /*#include 33 | using namespace std; 34 | void solve(){ 35 | int n,c2=0,c1=0,c=0,cc=0,d=0,b=0; 36 | cin>>n; 37 | int a[n][2]; 38 | for(int i=0;i>a[i][j]; 42 | } 43 | for(int i=0;ic1) 55 | d=n-c2; 56 | else 57 | d=n-c1; 58 | if(c>cc) 59 | b=n-c; 60 | else 61 | b=n-cc; 62 | cout<>t; 69 | while(t--){ 70 | solve(); 71 | } 72 | return 0; 73 | } 74 | */ -------------------------------------------------------------------------------- /110A-Nearly Lucky Number.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/110/A 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | string s; 6 | int c=0; 7 | cin>>s; 8 | for(int i=0;i1 &&(c%4==0 || c%7==0))||(c==4 || c==7)) 16 | cout<<"YES"; 17 | else 18 | cout<<"NO"; 19 | } 20 | int main(){ 21 | ios::sync_with_stdio(0); 22 | cin.tie(0); 23 | int t=1; 24 | //cin>>t; 25 | while(t--) 26 | solve(); 27 | return 0;} 28 | 29 | 30 | ANOTHER SOLUTION:- 31 | #include 32 | using namespace std; 33 | void solve(){ 34 | string s; 35 | long long c=0; 36 | cin>>s; 37 | for(int i=0;i>t; 62 | while(t--) 63 | solve(); 64 | return 0;} -------------------------------------------------------------------------------- /1433A-Boring Apartments.cpp: -------------------------------------------------------------------------------- 1 | //https://codeforces.com/problemset/problem/1433/A 2 | //Boring Apartments 3 | 4 | #include 5 | using namespace std; 6 | 7 | void solve(){ 8 | long long n; 9 | cin>>n; 10 | vectorv; 11 | v.push_back(1); 12 | v.push_back(11); 13 | v.push_back(111); 14 | v.push_back(1111); 15 | for(int i=2;i<10;i++){ 16 | for(int j=0;j<4;j++){ 17 | int d=v[j]*i; 18 | v.push_back(d); 19 | } 20 | } 21 | int c = 0; 22 | for(int i=0;i>t; 60 | while(t--) 61 | solve(); 62 | return 0; 63 | } 64 | 65 | --------------------------------------------------------------------------------