Skip to content

Commit a70a593

Browse files
authored
Add files via upload
1 parent e4cd202 commit a70a593

15 files changed

+1576
-0
lines changed

codechef/practice/BININSC.cpp

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
using namespace std;
7+
typedef long long ll ;
8+
typedef set<pair<int,int>> spi;
9+
typedef set<pair<ll,ll>> spl;
10+
typedef vector<pair<int,int>> vpi;
11+
typedef vector<int> vi;
12+
typedef vector<ll> vl;
13+
typedef vector<bool> vb;
14+
typedef vector<char> vc;
15+
typedef vector<pair<ll,ll>> vpl;
16+
typedef vector<string> vs;
17+
typedef map<int,int>mi;
18+
typedef map<ll,ll> ml;
19+
typedef set<string> ss;
20+
typedef set<char>sc;
21+
typedef set<int> si;
22+
typedef set<ll> sl;
23+
#define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
24+
// define values.
25+
#define mod 1e9+7LL
26+
#define phi 1.618
27+
/* Bit-Stuff */
28+
#define get_set_bits(a) (__builtin_popcount(a))
29+
#define get_set_bitsll(a) ( __builtin_popcountll(a))
30+
#define get_trail_zero(a) (__builtin_ctz(a))
31+
#define get_lead_zero(a) (__builtin_clz(a))
32+
#define get_parity(a) (__builtin_parity(a))
33+
/* Abbrevations */
34+
#define ff first
35+
#define ss second
36+
#define mp make_pair
37+
#define line cout<<endl;
38+
#define pb push_back
39+
#define Endl "\n"
40+
// loops
41+
#define loop(i,start,end) for(ll i=ll(start);i<ll(end);i++)
42+
#define loop0(num) for(ll i=0;i<ll(num);i++)
43+
#define forin(arr,n) for(ll i=0;i<n;i++) cin>>arr[i];
44+
// Some print
45+
#define no cout<<"NO"<<endl;
46+
#define yes cout<<"YES"<<endl;
47+
#define cc ll test;cin>>test;while(test--)
48+
// sort
49+
#define all(V) (V).begin(),(V).end()
50+
#define srt(V) sort(all(V))
51+
#define srtGreat(V) sort(all(V),greater<ll>())
52+
// function
53+
54+
ll power(ll x, ll y, ll p)
55+
{
56+
ll res = 1;
57+
x = x % p;
58+
while (y > 0)
59+
{
60+
if (y & 1)
61+
res = (res*x) % p;
62+
y = y>>1;
63+
x = (x*x) % p;
64+
}
65+
return res;
66+
}
67+
/* ascii value
68+
A=65,Z=90,a=97,z=122 1=49
69+
*/
70+
/* -----------------------------------------------------------------------------------*/
71+
// freopen("input.txt", "r", stdin);
72+
// freopen("output.txt", "w", stdout);
73+
74+
75+
int main()
76+
{
77+
cc
78+
{
79+
string s;
80+
cin>>s;
81+
if(s[0]=='1')
82+
{
83+
ll count=0,pos=0;
84+
loop(i,1,s.length())
85+
{
86+
// cout<<"s[i] "<<s[i]<<" "<<i<<endl;
87+
if(s[i]=='1')
88+
{
89+
pos=i;
90+
}
91+
else
92+
break;
93+
}
94+
loop(i,pos+1,s.length())
95+
{
96+
if(s[i]=='0')
97+
count++;
98+
else
99+
break;
100+
}
101+
cout<<count<<endl;
102+
}
103+
else
104+
{
105+
cout<<0<<endl;
106+
}
107+
}
108+
}

codechef/practice/CHEFCHR.cpp

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
using namespace std;
7+
typedef long long ll ;
8+
typedef set<pair<int,int>> spi;
9+
typedef set<pair<ll,ll>> spl;
10+
typedef vector<pair<int,int>> vpi;
11+
typedef vector<int> vi;
12+
typedef vector<ll> vl;
13+
typedef vector<bool> vb;
14+
typedef vector<char> vc;
15+
typedef vector<pair<ll,ll>> vpl;
16+
typedef vector<string> vs;
17+
typedef map<int,int>mi;
18+
typedef map<ll,ll> ml;
19+
typedef set<string> ss;
20+
typedef set<char>sc;
21+
typedef set<int> si;
22+
typedef set<ll> sl;
23+
#define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
24+
// define values.
25+
#define mod 1e9+7LL
26+
#define phi 1.618
27+
/* Bit-Stuff */
28+
#define get_set_bits(a) (__builtin_popcount(a))
29+
#define get_set_bitsll(a) ( __builtin_popcountll(a))
30+
#define get_trail_zero(a) (__builtin_ctz(a))
31+
#define get_lead_zero(a) (__builtin_clz(a))
32+
#define get_parity(a) (__builtin_parity(a))
33+
/* Abbrevations */
34+
#define ff first
35+
#define ss second
36+
#define mp make_pair
37+
#define line cout<<endl;
38+
#define pb push_back
39+
#define Endl "\n"
40+
// loops
41+
#define loop(i,start,end) for(ll i=ll(start);i<ll(end);i++)
42+
#define loop0(num) for(ll i=0;i<ll(num);i++)
43+
#define forin(arr,n) for(ll i=0;i<n;i++) cin>>arr[i];
44+
// Some print
45+
#define no cout<<"NO"<<endl;
46+
#define yes cout<<"YES"<<endl;
47+
#define cc ll test;cin>>test;while(test--)
48+
// sort
49+
#define all(V) (V).begin(),(V).end()
50+
#define srt(V) sort(all(V))
51+
#define srtGreat(V) sort(all(V),greater<ll>())
52+
// function
53+
54+
ll power(ll x, ll y, ll p)
55+
{
56+
ll res = 1;
57+
x = x % p;
58+
while (y > 0)
59+
{
60+
if (y & 1)
61+
res = (res*x) % p;
62+
y = y>>1;
63+
x = (x*x) % p;
64+
}
65+
return res;
66+
}
67+
/* ascii value
68+
A=65,Z=90,a=97,z=122 1=49
69+
*/
70+
/* -----------------------------------------------------------------------------------*/
71+
// freopen("input.txt", "r", stdin);
72+
// freopen("output.txt", "w", stdout);
73+
74+
75+
int main()
76+
{
77+
cc
78+
{
79+
string s;
80+
cin>>s;
81+
ll count=0;
82+
string temp="chef";
83+
srt(temp);
84+
loop(i,0,s.length()-3)
85+
{
86+
string temp1=s.substr(i,4);
87+
srt(temp1);
88+
if(temp1==temp)
89+
count++;
90+
}
91+
if(count>0)
92+
cout<<"lovely "<<count<<endl;
93+
else
94+
cout<<"normal"<<endl;
95+
}
96+
}

codechef/practice/CLFIBD.cpp

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
using namespace std;
7+
typedef long long ll ;
8+
typedef set<pair<int,int>> spi;
9+
typedef set<pair<ll,ll>> spl;
10+
typedef vector<pair<int,int>> vpi;
11+
typedef vector<int> vi;
12+
typedef vector<ll> vl;
13+
typedef vector<bool> vb;
14+
typedef vector<char> vc;
15+
typedef vector<pair<ll,ll>> vpl;
16+
typedef vector<string> vs;
17+
typedef map<int,int>mi;
18+
typedef map<ll,ll> ml;
19+
typedef set<string> ss;
20+
typedef set<char>sc;
21+
typedef set<int> si;
22+
typedef set<ll> sl;
23+
#define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
24+
// define values.
25+
#define mod 1e9+7LL
26+
#define phi 1.618
27+
/* Bit-Stuff */
28+
#define get_set_bits(a) (__builtin_popcount(a))
29+
#define get_set_bitsll(a) ( __builtin_popcountll(a))
30+
#define get_trail_zero(a) (__builtin_ctz(a))
31+
#define get_lead_zero(a) (__builtin_clz(a))
32+
#define get_parity(a) (__builtin_parity(a))
33+
/* Abbrevations */
34+
#define ff first
35+
#define ss second
36+
#define mp make_pair
37+
#define line cout<<endl;
38+
#define pb push_back
39+
#define Endl "\n"
40+
// loops
41+
#define loop(i,start,end) for(ll i=ll(start);i<ll(end);i++)
42+
#define loop0(num) for(ll i=0;i<ll(num);i++)
43+
#define forin(arr,n) for(ll i=0;i<n;i++) cin>>arr[i];
44+
// Some print
45+
#define no cout<<"NO"<<endl;
46+
#define yes cout<<"YES"<<endl;
47+
#define cc ll test;cin>>test;while(test--)
48+
// sort
49+
#define all(V) (V).begin(),(V).end()
50+
#define srt(V) sort(all(V))
51+
#define srtGreat(V) sort(all(V),greater<ll>())
52+
// function
53+
54+
ll power(ll x, ll y, ll p)
55+
{
56+
ll res = 1;
57+
x = x % p;
58+
while (y > 0)
59+
{
60+
if (y & 1)
61+
res = (res*x) % p;
62+
y = y>>1;
63+
x = (x*x) % p;
64+
}
65+
return res;
66+
}
67+
/* ascii value
68+
A=65,Z=90,a=97,z=122 1=49
69+
*/
70+
/* -----------------------------------------------------------------------------------*/
71+
// freopen("input.txt", "r", stdin);
72+
// freopen("output.txt", "w", stdout);
73+
74+
75+
int main()
76+
{
77+
cc
78+
{
79+
string s;
80+
cin>>s;
81+
map<char,ll>m;
82+
loop0(s.length())
83+
{
84+
m[s[i]]++;
85+
}
86+
vl v;
87+
for(auto s:m)
88+
v.pb(s.ss);
89+
srt(v);
90+
ll flag=0,flag1=0;
91+
if(v.size()>=3)
92+
{
93+
loop(i,2,v.size())
94+
{
95+
if(v[i]!=v[i-1]+v[i-2])
96+
{
97+
flag=1;
98+
break;
99+
}
100+
}
101+
swap(v[0],v[1]);
102+
loop(i,2,v.size())
103+
{
104+
if(v[i]!=v[i-1]+v[i-2])
105+
{
106+
flag1=1;
107+
break;
108+
}
109+
}
110+
if(flag==0||flag1==0)
111+
cout<<"Dynamic"<<endl;
112+
else
113+
cout<<"Not"<<endl;
114+
}
115+
else
116+
cout<<"Dynamic"<<endl;
117+
}
118+
}

0 commit comments

Comments
 (0)