├── 84A-toyArmy.cpp ├── 50A-DominoPiling.cpp ├── 221A-LittleElephantAndFunction.cpp ├── 268B-Buttons.cpp ├── 82A-doubleCola.cpp ├── 124A-NumberOfPositions.cpp ├── 200B-Drinks.cpp ├── 224A-Parallelepiped.cpp ├── 9A-dieRoll.cpp ├── 41A-Translation.cpp ├── 114A-cifera.cpp ├── 379A-NewYearCandel.cpp ├── 38A-Army.cpp ├── 546A-SoldierAndBananas.cpp ├── 92A-chips.cpp ├── 158A-NextRound.cpp ├── 228AIsYourHorseShoe.cpp ├── HQ9+.cpp ├── 233A-PerfectPermutation.cpp ├── 1A-TheatreSquare.cpp ├── 851A-ArpaAndAResearchInMexicanWave.cpp ├── 118A-StringTask.cpp ├── 69A-YoungPhysist.cpp ├── 208A-Dubstep.cpp ├── 670BGameOfRobots.cpp ├── 11A-IncreasingSequence.cpp ├── 239A-TwoBagsOfPotatoes.cpp ├── 669A-LittleArtemAndPresents.cpp ├── 61A-ultraFastMathematician.cpp ├── 237A-FreeCash.cpp ├── 439B-Devu,TheDumbGuy.cpp ├── 131C-TheWorldIsTheatre.cpp ├── 151A-SoftDrinking.cpp ├── 573B-BearAndBlocks.cpp ├── 466A-CheapTravel.cpp ├── 4A-watermelon.cpp ├── 6A-Triangle.cpp ├── 263A-BeautifulMatrix.cpp ├── 339A-HelpFulMath.cpp ├── 670AHolidays.cpp ├── 495B-MudularEq.cpp ├── 158B_Taxi.cpp ├── 282A-Bit++.cpp ├── 112A-PatyaAndString.cpp ├── 231A-Team.cpp ├── 320A-MagicNumbers.cpp ├── 149A-BusinessTrip.cpp ├── 266A-StonesOnTheTable.cpp ├── 47A-TriangularNumber.cpp ├── 220A-LittleElephantAndProblem.cpp ├── 127B-CanvasFrameImpoRevision.cpp ├── 148A-InsomniaCure.cpp ├── 255A-GregsWorkOut.cpp ├── 59A-Words.cpp ├── 219A-K-string.cpp ├── 139A_petterAndBook.cpp ├── 141A-AmusingJoke.cpp ├── 573A-BearAndPoker.cpp ├── 216A-TilingWithHexagons.cpp ├── 190A-VasyaAndBus.cpp ├── 467A-GeorgeAndAccomodation.java ├── 146A-LuckyTicket.cpp ├── 281A-WordCapitalization.java ├── 570B-SimpleGame.java ├── CutRibbon.cpp ├── 248A-CupBoards.cpp ├── 119A-EpicGame.cpp ├── 270A-FancyFence.java ├── 80A-PanoramixPrediction.cpp ├── 845A-Chess_Tourney.cpp ├── 376A-Lever.cpp ├── 560ACurrency.java ├── 71A-WayToLongWords.java ├── 110A-NearlyLuckyNumber.cpp ├── 96A-FootBall.cpp ├── 349A-CinemaHall.cpp ├── 116A-Tram.cpp ├── 131A-capsLock.cpp ├── 350A-Tl.cpp ├── 467B-FedorAndNewGame.cpp ├── 144A-ArrivalOfGeneral.cpp ├── 460B-LittleDimaAndEquation.cpp ├── 298A-SnowFootPrint.cpp ├── 476A-DreamoonAndStairs.java ├── 75A-LifeWithoutZeros.cpp ├── 165A-SuperCentralPoint.cpp ├── 131B-OppositeAttract.cpp ├── 595A-VitalyAndNight.java ├── 245B-InternetAddress.cpp └── 387A-GeorgeAndSleep.cpp /84A-toyArmy.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main(){ 4 | int val; 5 | cin>>val; 6 | cout<<3*val/2< 2 | using namespace std; 3 | 4 | int main() { 5 | int n,m; 6 | cin>>n>>m; 7 | int s=2; 8 | cout< 2 | using namespace std; 3 | 4 | int main() { 5 | int n; 6 | cin>>n; 7 | cout< 2 | using namespace std; 3 | int main(){ 4 | int n,sum=0; 5 | cin>>n; 6 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() { 5 | int n; 6 | cin>>n; 7 | char ch[][30]={"Sheldon", "Leonard", "Penny", "Rajesh", "Howard"}; 8 | while(n>5) 9 | n=(n/2)-2; 10 | cout< 2 | using namespace std; 3 | int main(){ 4 | int n,a,b,c,r; 5 | cin>>n>>a>>b; 6 | c=n-a-1; 7 | if(c>b){ 8 | r=b+1; 9 | }else{ 10 | r=c+1; 11 | } 12 | cout< 2 | using namespace std; 3 | 4 | int main() { 5 | int n; 6 | cin>>n; 7 | long double res=0; 8 | for(int i=0;i>p; 11 | res+=p/100; 12 | } 13 | cout< 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int x,y,z; 7 | cin>>x>>y>>z; 8 | int a=sqrt((x*y)/z); 9 | int b=sqrt((x*z)/y); 10 | int c=sqrt((y*z)/x); 11 | int val=(a+b+c)*4; 12 | cout< 2 | using namespace std; 3 | int gcd(int n,int m){ 4 | return m==0?n:gcd(m,n%m); 5 | } 6 | int main() { 7 | int y,z; 8 | cin>>y>>z; 9 | int max=(y 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string s,t; 7 | string l; 8 | cin>>s>>t; 9 | reverse(t.begin(),t.begin()+t.size()); 10 | if(s==t) 11 | cout<<"YES"; 12 | else 13 | cout<<"NO"; 14 | 15 | return 0; 16 | } -------------------------------------------------------------------------------- /114A-cifera.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | int main() { 5 | ll a,b; 6 | cin>>a>>b; 7 | ll temp=a; 8 | ll count=0; 9 | while(temp 2 | using namespace std; 3 | //code Belong to Niraj Sazzie 4 | int main() { 5 | int a,b; 6 | cin>>a>>b; 7 | int sum=a; 8 | int mod; 9 | int div1; 10 | while(a>=b){ 11 | div1=a/b; 12 | sum+=div1; 13 | mod=(a%b); 14 | a=div1+mod; 15 | } 16 | cout< 2 | using namespace std; 3 | 4 | int main() { 5 | int arr[101]; 6 | int n; 7 | cin>>n; 8 | for(int i=0;i>arr[i]; 10 | } 11 | int a,b; 12 | cin>>a>>b; 13 | int result=0; 14 | for(int i=a-1;i 2 | using namespace std; 3 | typedef long long ll; 4 | int main() { 5 | ll k,n,w; 6 | cin>>k>>n>>w; 7 | ll dollar=0; 8 | for(int i=1;i<=w;i++){ 9 | dollar+=k*i; 10 | } 11 | if((dollar-n)<0){ 12 | cout<<"0"; 13 | }else 14 | cout< 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, m; 8 | cin >> n >> m; 9 | m %= (n * (n + 1) / 2); 10 | for (int i = 1; i <= n; ++i) 11 | { 12 | if (m < i) 13 | { 14 | break; 15 | } 16 | m -= i; 17 | } 18 | cout << m << endl; 19 | return 0; 20 | } -------------------------------------------------------------------------------- /158A-NextRound.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int arr[51]; 6 | int n,k,result=0; 7 | cin>>n>>k; 8 | for(int i=0;i>arr[i]; 10 | } 11 | k-=1; 12 | int val=arr[k]; 13 | for(int i=0;i=val && arr[i]!=0) 15 | result++; 16 | } 17 | cout< 2 | #include 3 | using namespace std; 4 | typedef long long ll; 5 | int main() { 6 | ll arr[4]; 7 | for(int i=0;i<4;i++){ 8 | cin>>arr[i]; 9 | } 10 | sort(arr,arr+4); 11 | int count=0; 12 | for(int i=0;i<3;i++){ 13 | if(arr[i]==arr[i+1]) 14 | count++; 15 | } 16 | cout< 2 | using namespace std; 3 | 4 | int main() { 5 | string str; 6 | cin>>str; 7 | int flag=0; 8 | for(int i=0;i=33&&str[i]<=126){ 10 | if(str[i]=='H'||str[i]=='Q'||str[i]=='9') 11 | flag=1; 12 | } 13 | } 14 | if(flag){ 15 | cout<<"YES"; 16 | }else{ 17 | cout<<"NO"; 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /233A-PerfectPermutation.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main(){ 4 | int n; 5 | cin>>n; 6 | if(n%2){ 7 | cout<<"-1"; 8 | }else{ 9 | for(int i=1;i<=n;i++){ 10 | if(i%2){ 11 | cout< 2 | using namespace std; 3 | 4 | int main() { 5 | long long m,n,a; 6 | cin>>m>>n>>a; 7 | long long rows; 8 | long long colm; 9 | if(n%a==0){ 10 | rows=n/a; 11 | }else{ 12 | rows=n/a; 13 | rows++; 14 | } 15 | if(m%a==0){ 16 | colm=m/a; 17 | }else{ 18 | colm=m/a; 19 | colm++; 20 | } 21 | cout< 2 | //http://codeforces.com/problemset/problem/851/A 3 | using namespace std; 4 | typedef long long ll; 5 | int main() { 6 | ll n,k,t; 7 | cin>>n>>k>>t; 8 | if(t < k) 9 | cout< 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string s; 7 | cin>>s; 8 | string result; 9 | for(int i=0;i 2 | using namespace std; 3 | typedef long long ll; 4 | int main() { 5 | int arr[101][101]; 6 | int n; 7 | cin>>n; 8 | ll a=0,b=0,c=0; 9 | ll a1,a2,a3; 10 | for(int i=0;i>a1>>a2>>a3; 12 | a+=a1; 13 | b+=a2; 14 | c+=a3; 15 | } 16 | if(a==0 && b==0 && c==0){ 17 | cout<<"YES"; 18 | }else{ 19 | cout<<"NO"; 20 | } 21 | return 0; 22 | } -------------------------------------------------------------------------------- /208A-Dubstep.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | string s; 6 | int flag=1; 7 | cin>>s; 8 | for(int i=0;i 2 | typedef unsigned long long ll; 3 | using namespace std; 4 | 5 | int main() { 6 | ll n,k; 7 | cin>>n>>k; 8 | ll arr[100001]; 9 | for(int i=1;i<=n;i++){ 10 | cin>>arr[i]; 11 | } 12 | ll i=1; 13 | ll temp=0; 14 | while(temp+i 2 | using namespace std; 3 | 4 | int main() { 5 | int n,d; 6 | cin>>n>>d; 7 | int ans=0; 8 | int arr[2001]; 9 | for(int i=0;i>arr[i]; 11 | if(i){ 12 | if(arr[i-1]>=arr[i]){ 13 | ans=ans+(arr[i-1]-arr[i])/d+1; 14 | arr[i]=arr[i]+((arr[i-1]-arr[i])/d+1)*d; 15 | } 16 | } 17 | } 18 | cout< 2 | using namespace std; 3 | typedef long long ll; 4 | int main() { 5 | ll y,k,n; 6 | // NIraj sazzie 7 | cin>>y>>k>>n; 8 | ll x=k-y%k;// kitna number chaiye div ke lia.. 9 | ll top=n-y; 10 | if(x<=top){ 11 | cout< 2 | typedef long long ll; 3 | using namespace std; 4 | 5 | int main() { 6 | // your code goes here 7 | ll n; 8 | cin>>n; 9 | ll s=n/3; 10 | if(n%3==0){ 11 | cout<3){ 14 | if((n-1)%3==0) 15 | cout< 2 | using namespace std; 3 | // niraj Sazzie 4 | int main() { 5 | int arr1[100],arr2[100]; 6 | string s,s1; 7 | int val; 8 | cin>>s>>s1; 9 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() { 5 | int n; 6 | int cash=1; 7 | int max=1; 8 | cin>>n; 9 | int h0,m0; 10 | cin>>h0>>m0; 11 | int h,m; 12 | while(--n){ 13 | cin>>h>>m; 14 | if(h0==h && m0==m){ 15 | cash++; 16 | if(cash>max){ 17 | max=cash; 18 | } 19 | }else{ 20 | cash=1; 21 | } 22 | h0=h; 23 | m0=m; 24 | } 25 | cout< 2 | #include 3 | #include 4 | using namespace std; 5 | typedef uint64_t ll; 6 | int main() { 7 | ll n,x; 8 | cin>>n>>x; 9 | int arr[100001]; 10 | for(int i=0;i>arr[i]; 12 | } 13 | sort(arr,arr+n); 14 | ll res=0; 15 | for(int i=0;i1) 18 | x--; 19 | } 20 | cout< 2 | using namespace std; 3 | typedef long long ll; 4 | ll value; 5 | ll f(ll p,ll r){ 6 | value=1; 7 | for(ll i=0;i>n>>m>>t; 17 | 18 | for(ll i=4;i 3 | using namespace std; 4 | int min(int a,int b,int c){ 5 | if(a<=b&&a<=c) 6 | return a; 7 | else if(b<=c&&b<=a) 8 | return b; 9 | else 10 | return c; 11 | } 12 | int main() { 13 | int n,k,l,c,d,p,nl,np; 14 | cin>>n>>k>>l>>c>>d>>p>>nl>>np; 15 | k*=l; 16 | int toast1=k/nl; 17 | c*=d; 18 | int toast2=c; 19 | int toast3=p/np; 20 | int val=min(toast1,toast3,toast2); 21 | val/=n; 22 | cout< 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | // your code goes here 7 | int arr[100001]; 8 | int n; 9 | cin>>n; 10 | arr[0]=arr[n+1]=0; 11 | for(int i=1;i<=n;i++){ 12 | cin>>arr[i]; 13 | } 14 | for(int i=1;i<=n;i++){ 15 | arr[i]=min(arr[i],arr[i-1]+1); 16 | } 17 | for(int i=n;i>=0;i--){ 18 | arr[i]=min(arr[i],arr[i+1]+1); 19 | } 20 | sort(arr,arr+n+1); 21 | cout< 2 | using namespace std; 3 | int min(int a,int b){ 4 | return a>b?b:a; 5 | } 6 | int main() { 7 | int m,n,a,b,result; 8 | cin>>n>>m>>a>>b; 9 | if(b<=m*a){ 10 | if(n%m==0){ 11 | result=n/m; 12 | result*=b; 13 | }else{ 14 | int div1=n/m; 15 | int rem=n%m; 16 | int res=min(rem*a,b); 17 | result=div1*b+res; 18 | } 19 | }else{ 20 | result=n*a; 21 | } 22 | cout< 2 | using namespace std; 3 | 4 | int main() { 5 | int w; 6 | int flag=0; 7 | cin>>w; 8 | for(int i=1;i<=100;i++){ 9 | for(int j=1;j<=100;j++){ 10 | if((i+j)==w){ 11 | if(i%2==0 && j%2==0){ 12 | flag=1; 13 | } 14 | } 15 | else if((i+j)>w){ 16 | break; 17 | } 18 | } 19 | } 20 | if(flag) 21 | cout<<"YES"< 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int tri=0,seg=0; 7 | int arr[4]; 8 | for(int i=0;i<4;i++){ 9 | cin>>arr[i]; 10 | } 11 | sort(arr,arr+4); 12 | if(arr[0]+arr[1]>arr[2]||arr[1]+arr[2]>arr[3]||arr[0]+arr[2]>arr[3]){ 13 | cout<<"TRIANGLE"; 14 | } 15 | else if(arr[0]+arr[1]==arr[2]||arr[1]+arr[2]==arr[3]||arr[0]+arr[2]==arr[3]){ 16 | cout<<"SEGMENT"; 17 | } 18 | else cout<<"IMPOSSIBLE"; 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /263A-BeautifulMatrix.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int i,j; 7 | int a; 8 | int flag=0; 9 | // int arr[6][6]; 10 | for(i=1;i<=5;i++){ 11 | for(j=1;j<=5;j++){ 12 | cin>>a; 13 | if(a==1){ 14 | flag=1; 15 | break; 16 | } 17 | } 18 | if(flag==1) 19 | break; 20 | } 21 | int res=abs(3-i)+abs(3-j); 22 | cout< 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int arr[1001]; 7 | string s; 8 | cin>>s; 9 | int count=0; 10 | for(int i=0;i 2 | typedef long long ll; 3 | using namespace std; 4 | 5 | int main() { 6 | ll n; 7 | cin>>n; 8 | ll maxdiv,maxrem,mindiv,minrev; 9 | mindiv=n/7; 10 | minrev=n%7; 11 | if(minrev==6){ 12 | cout< 2 | #include 3 | #include 4 | using namespace std; 5 | typedef long long ll; 6 | // this is different 7 | int main() { 8 | ll a,b,count=0,x,i; 9 | cin>>a>>b; 10 | if(a==b){ 11 | cout<<"infinity"; 12 | }else{ 13 | ll x=abs(a-b); 14 | for(i=1;i*ib)count++; 17 | if(x/i>b)count++; 18 | } 19 | } 20 | if(i*i==x&&i>b)count++; 21 | cout< 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int arr[100001]; 7 | int n; 8 | cin>>n; 9 | for(int i=0;i>arr[i]; 11 | } 12 | sort(arr,arr+n,greater()); 13 | int i=0; 14 | int j=n-1; 15 | int ans=0; 16 | while(i<=j){ 17 | ans+=1; 18 | int four=4-arr[i]; 19 | while(arr[j]<=four && i<=j){ 20 | four=four-arr[j]; 21 | j--; 22 | } 23 | i++; 24 | } 25 | cout< 2 | using namespace std; 3 | 4 | int main() { 5 | int n; 6 | cin>>n; 7 | int x=0; 8 | string s; 9 | while(n--){ 10 | cin>>s; 11 | if(s[0]=='+' && s[1]=='+' && s[2]=='X'){ 12 | x+=1; 13 | }else if(s[0]=='X' && s[1]=='+' && s[2]=='+'){ 14 | x+=1; 15 | }else if(s[0]=='X' && s[1]=='-' && s[2]=='-'){ 16 | x-=1; 17 | } 18 | else if(s[0]=='-' && s[1]=='-' && s[2]=='X'){ 19 | x-=1; 20 | } 21 | } 22 | cout< 2 | using namespace std; 3 | 4 | int main() { 5 | string s,s1; 6 | cin>>s>>s1; 7 | int val=0; 8 | int res=0; 9 | for(int i=0;ich1){ 15 | res=1; 16 | break; 17 | }else{ 18 | res=-1; 19 | break; 20 | } 21 | } 22 | if(res){ 23 | cout< 2 | using namespace std; 3 | 4 | int main() { 5 | int arr[1000][3]; 6 | int n; 7 | cin>>n; 8 | for(int i=0;i>arr[i][j]; 11 | } 12 | } 13 | int count=0; 14 | int result=0; 15 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() { 5 | string s; 6 | cin>>s; 7 | int i; 8 | for(i=0;i 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int arr[12]; 7 | int n; 8 | cin>>n; 9 | for(int i=0;i<12;i++){ 10 | cin>>arr[i]; 11 | } 12 | sort(arr,arr+12); 13 | int i=11; 14 | int count=0; 15 | int val=0; 16 | while(val 2 | using namespace std; 3 | 4 | int main() { 5 | int n; 6 | cin>>n; 7 | string s; 8 | cin>>s; 9 | int countr=0; 10 | int countg=0; 11 | int countb=0; 12 | for(int i=0;i 2 | #include 3 | using namespace std; 4 | typedef long long ll; 5 | int main() { 6 | //https://en.wikipedia.org/wiki/Triangular_number 7 | //Niraj Sazzie 8 | //first take out 8x+1 take root and -1 and divide by 2 then again calculate the number 9 | // if that number is same as the given input it means bingo 10 | ll n; 11 | ll set=0; 12 | cin>>n; 13 | ll val=8*n+1; 14 | ll fix=sqrt(val)-1; 15 | fix/=2; 16 | fix*=(fix+1); 17 | fix/=2; 18 | if(fix==n) 19 | cout<<"YES"; 20 | else 21 | cout<<"NO"; 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /220A-LittleElephantAndProblem.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | typedef long long ll; 5 | int main() { 6 | int n; 7 | ll arr[100001]; 8 | ll arr1[100001]; 9 | cin>>n; 10 | for(int i=0;i>arr[i]; 12 | arr1[i]=arr[i]; 13 | } 14 | int count=0; 15 | sort(arr,arr+n); 16 | for(int i=0;i4){ 21 | break; 22 | } 23 | } 24 | if(count<=2){ 25 | cout<<"YES"; 26 | }else{ 27 | cout<<"NO"; 28 | } 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /127B-CanvasFrameImpoRevision.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | int arr[101]; 8 | int count[102]; 9 | memset(count,0,sizeof(count)); 10 | int n; 11 | cin>>n; 12 | for(int i=0;i>arr[i]; 14 | } 15 | for(int i=0;i0){ 22 | count[i]=count[i]-1; 23 | } 24 | temp+=count[i]; 25 | } 26 | cout< 2 | using namespace std; 3 | //code belong to Niraj Sazzie 4 | int main() { 5 | int arr[100001]={0}; 6 | int k,l,m,n,d; 7 | int count=0; 8 | cin>>k>>l>>m>>n>>d; 9 | for(int i=0+k-1;i 2 | using namespace std; 3 | 4 | int main() { 5 | int arr[1001]; 6 | int n; 7 | cin>>n; 8 | for(int i=0;i>arr[i]; 10 | } 11 | int chest=0,bices=0,back=0; 12 | for(int i=0;ibices && chest>back){ 22 | cout<<"chest"; 23 | }else if(bices>chest && bices>back){ 24 | cout<<"biceps"; 25 | }else{ 26 | cout<<"back"; 27 | } 28 | return 0; 29 | } -------------------------------------------------------------------------------- /59A-Words.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string s; 7 | cin>>s; 8 | int countup=0,countlow=0; 9 | for(int i=0;icountlow){ 17 | char ch; 18 | for(int i=0;i 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int k,count=0; 7 | char ch; 8 | cin>>k; 9 | string s; 10 | cin>>s; 11 | int l=s.size(); 12 | sort(s.begin(),s.begin()+s.size()); 13 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() { 5 | int arr[8]; 6 | int n,result,sum=0,i; 7 | cin>>n; 8 | for(i=1;i<=7;i++){ 9 | cin>>arr[i]; 10 | sum+=arr[i]; 11 | } 12 | i=1; 13 | if(n%sum>0){ 14 | n%=sum; 15 | while(n>0){ 16 | if(i==8) 17 | i=1; 18 | n-=arr[i]; 19 | result=i; 20 | i++; 21 | } 22 | }else{ 23 | while(n>0){ 24 | if(i==8) 25 | i=1; 26 | n-=arr[i]; 27 | result=i; 28 | i++; 29 | } 30 | } 31 | cout< 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int flag=0; 7 | string str1,str2,str3; 8 | cin>>str1>>str2>>str3; 9 | str1.append(str2); 10 | sort(str1.begin(),str1.end()); 11 | sort(str3.begin(),str3.end()); 12 | int n=str1.size(); 13 | int k=str3.size(); 14 | //cout< 2 | typedef long long ll; 3 | using namespace std; 4 | 5 | int main() { 6 | int n; 7 | ll x; 8 | int flag=0; 9 | ll arr[100001]; 10 | cin>>n; 11 | for(int i=0;i>arr[i]; 13 | } 14 | for(int i=0;i=1 && x!=arr[i]){ 25 | flag=1; 26 | break; 27 | } 28 | } 29 | if(flag){ 30 | cout<<"NO"; 31 | }else{ 32 | cout<<"YES"; 33 | } 34 | return 0; 35 | } -------------------------------------------------------------------------------- /216A-TilingWithHexagons.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int a,b,c; 6 | //Niraj sazzie 7 | //The given hexagonal array HH of beads can be viewed (in two ways) 8 | //as the union of three parallelogram shaped arrays containing abab, bcbc, and caca beads respectively, 9 | //any two of them sharing an edge of length aa, bb, or cc, 10 | //and all three of them having one bead in the interior of HH in common. 11 | //By the inclusion-exclusion principle the total number NN of beads is therefore given by 12 | //N=(a*b+b*c+c*a)-(a+b+c)+1. 13 | cin>>a>>b>>c; 14 | cout<<(a*b+b*c+c*a)-(a+b+c)+1; 15 | return 0; 16 | } -------------------------------------------------------------------------------- /190A-VasyaAndBus.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | // jugaad by Niraj Sazzie 4 | int main() { 5 | int child,gUp,mV,mnV; 6 | cin>>gUp>>child; 7 | if(gUp>=1){ 8 | if(child>1) 9 | mV=gUp+(child-1); 10 | else 11 | mV=gUp; 12 | if(child>1){ 13 | if(gUp>child){ 14 | mnV=gUp; 15 | }else{ 16 | int mreRt=child/gUp; 17 | int mdlo=child%gUp; 18 | mnV=gUp+(mreRt-1)*gUp+mdlo; 19 | } 20 | } 21 | cout<=2) 20 | result++; 21 | } 22 | System.out.println(result); 23 | } 24 | } -------------------------------------------------------------------------------- /146A-LuckyTicket.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int arr[51]; 6 | int n,flag=0,sum1=0,sum2=0; 7 | cin>>n; 8 | int z=n; 9 | string s; 10 | cin>>s; 11 | for(int i=0;i 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | int max_cuts[4001], cuts[3]; 7 | 8 | int main() { 9 | int n, a, b, c; 10 | scanf("%d %d %d %d", &n, &cuts[0], &cuts[1], &cuts[2]); 11 | sort(cuts, cuts + 3); 12 | for (int i = 0; i <= n; i++) { 13 | max_cuts[i] = -4000; 14 | } 15 | 16 | max_cuts[0] = 0; 17 | max_cuts[cuts[0]] = 1; 18 | max_cuts[cuts[1]] = 1; 19 | max_cuts[cuts[2]] = 1; 20 | 21 | for (int i = 1; i <= n; i++) { 22 | for (int j = 0; j < 3; j++) { 23 | if (cuts[j] > i) break; 24 | max_cuts[i] = max(max_cuts[i - cuts[j]] + 1, max_cuts[i]); 25 | } 26 | } 27 | printf("%d\n", max_cuts[n]); 28 | return 0; 29 | } -------------------------------------------------------------------------------- /248A-CupBoards.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int min(int a,int b){ 4 | return a>b?b:a; 5 | } 6 | int main() { 7 | int n; 8 | cin>>n; 9 | int left[10001],right[10001]; 10 | for(int i=0;i>left[i]>>right[i]; 12 | } 13 | int r0=0,r1=0,l0=0,l1=0; 14 | for(int i=0;i 2 | using namespace std; 3 | int gcd(int a,int b){ 4 | return a?gcd(b%a,a):b; 5 | } 6 | int main() { 7 | int a,b,n; 8 | cin>>a>>b>>n; 9 | int flag1=0; 10 | int val; 11 | // cout<0){ 13 | if(flag1==0){ 14 | // this is for simon 15 | val=gcd(a,n); 16 | n-=val; 17 | flag1=1; 18 | }else{ 19 | // this is for the antisimon 20 | val=gcd(b,n); 21 | n-=val; 22 | flag1=0; 23 | } 24 | // cout< 2 | using namespace std; 3 | //code belong to Niraj Sazzie 4 | int main() { 5 | int n,m; 6 | cin>>n>>m; 7 | int flag=0; 8 | int counter=0; 9 | for(int p=n+1;p<=m;p++){ 10 | counter=0; 11 | for(int i=2;i<=(p/2)+1;i++){ 12 | if(p%i==0){ 13 | counter++; 14 | } 15 | } 16 | if(counter==0){ 17 | if(p==m){ 18 | cout<<"YES"< 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int a,b[100001]; 7 | int result1 = 0; 8 | int result2 = 0; 9 | cin>>a; 10 | for ( int i = 0 ; i < 2*a ; i++){ 11 | cin>>b[i]; 12 | } 13 | sort(b,b + 2*a); 14 | for( int i = 0 ; i < a ;i++ ){ 15 | result1+=b[i]; 16 | } 17 | for(int i = a ; i < 2*a ; i++ ){ 18 | result2+=b[i]; 19 | } 20 | int intersectvalue = b[a-1]; 21 | int intersectvalue1 = b[a ]; 22 | 23 | if((result1 < result2) && (intersectvalue < intersectvalue1)){ 24 | cout<<"YES"< 2 | using namespace std; 3 | typedef long long ll; 4 | int main() { 5 | string s; 6 | cin>>s; 7 | ll level=s.find('^');// this is used to return the index of the specified char in the format of int index 8 | ll left=0,right=0; 9 | for(int k=0;kright)cout<<"left"; 21 | else cout<<"right"; 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /560ACurrency.java: -------------------------------------------------------------------------------- 1 | /* package codechef; // don't place package name! */ 2 | 3 | import java.util.*; 4 | import java.lang.*; 5 | import java.io.*; 6 | 7 | /* Name of the class has to be "Main" only if the class is public. */ 8 | public class Codechef 9 | { 10 | public static void main (String[] args) throws java.lang.Exception 11 | { 12 | int arr[]=new int[1001]; 13 | Scanner sc=new Scanner(System.in); 14 | int n=sc.nextInt(); 15 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() { 5 | string s; 6 | int arr[21]; 7 | cin>>s; 8 | 9 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() { 5 | int arr[1001]; 6 | string s; 7 | cin>>s; 8 | for(int i=0;i=7){ 30 | cout<<"YES"; 31 | }else{ 32 | cout<<"NO"; 33 | } 34 | return 0; 35 | } -------------------------------------------------------------------------------- /349A-CinemaHall.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int arr[100001]; 6 | int n; 7 | cin>>n; 8 | int l; 9 | for(int i=0;i>l; 11 | arr[i]=l/25; 12 | } 13 | int flag1=0,flag2=0,flag4=0; 14 | int b=0; 15 | for(int i=0;i0){ 23 | flag4++; 24 | flag2--; 25 | flag1--; 26 | }else{ 27 | flag1-=3; 28 | } 29 | } 30 | if(flag1<0){ 31 | b=1; 32 | break; 33 | } 34 | } 35 | if(b==1){ 36 | cout<<"NO"; 37 | }else{ 38 | cout<<"YES"; 39 | } 40 | return 0; 41 | } -------------------------------------------------------------------------------- /116A-Tram.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int arr[1001][2]; 6 | int n; 7 | cin>>n; 8 | for(int i=0;i>arr[i][j]; 11 | } 12 | int max=0; 13 | for(int i=0;i 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string s; 7 | char ch; 8 | int flag=0; 9 | cin>>s; 10 | int count=0; 11 | for(int i=0;i 2 | using namespace std; 3 | int maxee(int a,int b){ 4 | return a>b?a:b; 5 | } 6 | int main() { 7 | int arr[101],arr1[101]; 8 | int n,m; 9 | cin>>n>>m; 10 | int flag=0; 11 | for(int i=0;i>arr[i]; 13 | } 14 | for(int i=0;i>arr1[i]; 16 | } 17 | int max=arr[0]; 18 | int min1=arr[0]; 19 | for(int i=0;iarr[i]){ 24 | min1=arr[i]; 25 | } 26 | } 27 | int val=maxee(2*min1,max); 28 | int min=arr1[0]; 29 | for(int i=0;iarr1[i]){ 31 | min=arr1[i]; 32 | } 33 | } 34 | if(val 2 | typedef long long ll; 3 | using namespace std; 4 | int mycount(int a){ 5 | int count=0; 6 | while(a){// here we are counting the number of 1's 7 | a=a&(a-1); 8 | count++; 9 | } 10 | return count;// returning the count 11 | } 12 | int main() { 13 | int arr[100001]; 14 | ll n,m,k; 15 | cin>>n>>m>>k; 16 | for(int i=0;i<=m;i++){ 17 | cin>>arr[i]; 18 | } 19 | ll result=0; 20 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() { 5 | int n; 6 | int arr[10001]; 7 | cin>>n; 8 | for(int i=0;i>arr[i]; 10 | } 11 | int max=arr[0],min=arr[0]; 12 | int maxindex=0,minindex=0; 13 | for(int i=0;imax){ 19 | max=arr[i]; 20 | maxindex=i; 21 | } 22 | } 23 | for(int i=0;iminindex) 27 | minindex=i; 28 | } 29 | if(maxindex 2 | #include 3 | #include 4 | using namespace std; 5 | typedef long long LL; 6 | int main() 7 | { 8 | ios_base::sync_with_stdio(0); 9 | LL a,b,c,id=0; 10 | LL arr[45]; 11 | cin>>a>>b>>c; 12 | for(int i=1;i<=81;++i) 13 | { 14 | LL tmp=1,tmp2=0,tmp3,tmp4=0; 15 | for(int j=1;j<=a;++j)tmp*=i; 16 | tmp=tmp*b+c; 17 | tmp3=tmp; 18 | while(tmp3>0) 19 | { 20 | tmp2+=(tmp3%10); 21 | tmp3/=10; 22 | tmp4++; 23 | } 24 | if(tmp4>9)continue; 25 | if(tmp2==i) 26 | arr[id++]=tmp; 27 | } 28 | cout<0)cout< 2 | using namespace std; 3 | 4 | int main() { 5 | int n; 6 | int r1,r2,l1,l2; 7 | cin>>n; 8 | string s; 9 | cin>>s; 10 | int i; 11 | for(i=0;i=0;j--){ 16 | if(s[j]=='R'){r2=j; break;} 17 | } 18 | } 19 | } 20 | for(i=0;i=0;j--){ 25 | if(s[j]=='L'){l2=j; break;} 26 | } 27 | } 28 | } 29 | if(r1==-1){ 30 | cout<0){ 30 | System.out.println(res); 31 | }else{ 32 | System.out.println("-1"); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /75A-LifeWithoutZeros.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | // int arr[100],arr1[100]; 6 | string s,s1; 7 | cin>>s>>s1; 8 | long long val1=0,res=0,val2=0,res1=0; 9 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() { 5 | int arr[201][2]; 6 | int n; 7 | cin>>n; 8 | for(int i=0;i>arr[i][j]; 11 | } 12 | } 13 | int count=0; 14 | for(int i=0;iarr[j][0] && y==arr[j][1]){ 22 | left++; 23 | }else if(x==arr[j][0] && yarr[j][1]){ 26 | below++; 27 | } 28 | if(right>0 && left>0 && up>0 && below>0){ 29 | if((left+right+up+below)>=4){ 30 | count++; 31 | break; 32 | } 33 | } 34 | } 35 | } 36 | cout< 2 | #include 3 | using namespace std; 4 | typedef long long ll; 5 | int main() { 6 | ll n; 7 | ll arr[22]; 8 | memset(arr,0,sizeof(arr)); 9 | ll countZero=0; 10 | ll ans=0; 11 | cin>>n; 12 | // this is my first idea but got the TLE 13 | /* for(int i=0;i>t; 23 | if(t==0){ 24 | countZero+=1; 25 | } 26 | // now the idea is to do this in llinear time 27 | else if(t>0){ 28 | arr[t]++; 29 | // convert the value on the array of 1 to 20 30 | } 31 | else { 32 | arr[-t+10]++; 33 | } 34 | } 35 | for(int i=1;i<=10;i++){ 36 | ans+=arr[i]*arr[10+i]; 37 | }// for special condition we are taking here 38 | ans+=countZero*(countZero-1)/2; 39 | cout< 2 | using namespace std; 3 | 4 | int main() { 5 | string s; 6 | cin>>s; 7 | int flag=1; 8 | int flag1=1; 9 | int flag2=1; 10 | for(int i=0;i4){ 24 | flag=0; 25 | cout<<"."<3 ){ 32 | flag=0; 33 | cout<<"."< 2 | using namespace std; 3 | 4 | int main() { 5 | string s,t; 6 | cin>>s>>t; 7 | int hh1=0,mm1=0,hh2=0,mm2=0,hour1=0,res1=0,res2=0; 8 | for(int i=0;i=mm2){ 32 | hh1=0; 33 | }else if(hh1==0){ 34 | hh1=24; 35 | } 36 | if(mm1