akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

ll a[N], ps[N], res[N];
int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    ll n, q;
    cin >> n >> q;
    stack<ll> st;
    st.push(n);
    for (int i = 0; i < q; i ++) {
    	ll x;
    	cin >> x;
    	while (st.size() && st.top() >= x)
    		st.pop();
    	st.push(x);
	}
	vector<ll> vec;
	while (st.size()) {
		vec.pb(st.top());
		st.pop();
	}
	reverse(all(vec));
	ll m = vec.size();
	a[m - 1] = 1;
	for (int i = m - 1; i; i --) {
		ll res = vec[i];
		while (res >= vec[0]) {
			ll x = upper_bound(all(vec), res) - vec.begin();
			x --;
			x -= (x == i);
			a[x] += a[i] * (res / vec[x]);
			res %= vec[x];
		}
		ps[res] += a[i];
	}
	ps[vec[0]] += a[0];
	for (int i = N - 1; ~i; i --)
		res[i] = res[i + 1] + ps[i];
	for (int i = 1; i <= n; i ++)
		cout << res[i] << '\n';
    return (0);
}

Measured memory_bytes: 7472
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main() {
	cout << fixed << setprecision(10);
	int n, m;
	cin >> n >> m;

	cout << n * (n - 1) / 2 + m * (m - 1) / 2;
	return 0;
}

Measured memory_bytes: 256
// #include <iostream>
// #include <cstdio>
// #include <map>
// #include <set>
// #include <vector>
// #include <algorithm>
// #include <queue>
// #include <stack>
// using namespace std;
// typedef long long ll;
// const int mo=1e9+7;
// #define rep(i, n) for (int i = 0; i < n; i++)
// int u[55];
// ll dp[55];
// char in[2][55];
// vector<int> v;
// void solve()
// {
//     int n,i,j;
//     scanf("%d%s%s",&n,in[0],in[1]);
//     for(i=0;i<n;)
//     {
//         if(i+1==n||in[0][i]==in[1][i])
//         {
//             v.emplace_back(1);
//             i++;
//         }
//         else
//         {
//             v.emplace_back(2);
//             i+=2;
//         }
//     }
//     dp[0]=6;
//     if(v[0]==1)dp[0]=3;
//     for(i=1;i<v.size();i++)
//     {
//         if(v[i]==1&&v[i-1]==1)dp[i]=dp[i-1]*2%mo;
//         if(v[i]==1&&v[i-1]==2)dp[i]=dp[i-1];
//         if(v[i]==2&&v[i-1]==1)dp[i]=dp[i-1]*2%mo;
//         if(v[i]==2&&v[i-1]==2)dp[i]=dp[i-1]*3%mo;
//     }
//     printf("%lld\n",dp[v.size()-1]);
// }
// main()
// {
//     cin.tie(0);
//     ios::sync_with_stdio(0);
//     solve();
//     return 0;
// }

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
const int mo = 1e9 + 7;
typedef long long ll;
ll a;
int f[110][30];
int p[110][20];
ll ans=-(1<<30);
void solve()
{
    for(int b=1;b<(1<<10);b++)
    {
        int cc=0;
        rep(i,a)
        {
            int c=0;
            rep(j,10)if((b>>j&1)&&f[i][j])c++;
            cc+=p[i][c];
        }
        ans=max(ans,cc);
    }
}
main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin>>a;
    rep(i,a)rep(j,10)cin>>f[i][j];
    rep(i,a)rep(j,11)cin>>p[i][j];
    solve();
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(n);i++)
int main()
{
    int h,w,n,hh=0,ww=0,nn=1,now=0;
    cin>>h>>w>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    vector<vector<int>> ans(h,vector<int>(w));
    rep(i,h*w)
    {
        ans[hh][ww]=nn;
        a[nn-1]--;
        if(now==0)
        {
            if(ww+1==w)
            {
                hh++;
                now++;
            }
            else ww++;
        }
        else
        {
            if(ww==0)
            {
                hh++;
                now--;
            }
            else ww--;
        }
        if(a[nn-1]==0) nn++;
    }
    rep(i,h)
    {
        rep(j,w) cout<<ans[i][j]<<" ";
        cout<<endl;
    }
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll N;
ll A[200010],B[200010];
vector<P> ps;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin>>N;
  rep(i,N){
    cin>>A[i]>>B[i];
    ps.push_back(P(B[i],A[i]));
  }

  sort(all(ps));

  ll crt=0;
  bool ok=true;
  rep(i,N){
    if(crt>ps[i].fi-ps[i].se){
      ok=false; break;
    }
    crt+=ps[i].se;
  }
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 8176
def resolve():
	x = int(input())
	if 400<= x < 600:
		print(8); return
	elif 600<= x < 800:
		print(7); return
	elif 800<= x < 1000:
		print(6); return
	elif 1000<= x < 1200:
		print(5); return
	elif 1200<= x < 1400:
		print(4); return
	elif 1400<= x < 1600:
		print(3); return
	elif 1600<= x < 1800:
		print(2); return
	elif 1800<= x < 2000:
		print(1); return
resolve()


Measured memory_bytes: 9184
#pragma warning (disable :4996)
#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;

const int M = 1046527;
const int L = 14;
char H[M][L];

int getChar(char ch) {
	if (ch == 'A') return 1;
	if (ch == 'C') return 2;
	if (ch == 'G') return 3;
	if (ch == 'T') return 4;
}
long long getKey(char str[]) {
	long long sum = 0, p = 1;
	for (int i = 0; i < strlen(str); i++) {
		sum += p * (getChar(str[i]));
		p *= 5;
	}
	return sum;
}
int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }
int find(char str[]) {
	long long key, h;
	key = getKey(str);
	for (int i = 0;; i++) {
		h =(h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0) return 0;;
	}
	return 0;
}
int insert(char str[]) {
	long long key, h;
	key = getKey(str);
	for (int i = 0;; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0) {
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}

int main() {
	int i, n, h;
	char str[L], com[9];
	for (int i = 0; i < M; i++) H[i][0] = '\0';
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s %s", com, str);
		if (com[0] == 'i') insert(str);
		else {
			if (find(str)) printf("yes\n");
			else printf("no\n");
		}
	}
	return 0;
}


Measured memory_bytes: 17432
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
for k in range(N):
  for i in range(N):
    for j in range(N):
      if A[i][j]>A[i][k]+A[k][j]:
        print(-1)
        exit()
INF=10**12
D=[[INF]*N for i in range(N)]
for i in range(N):
  D[i][i]=0
X=[]
for i in range(N):
  for j in range(N):
    if i==j:
      continue
    X.append([A[i][j],i,j])
P=0
X.sort()
for i in range(len(X)):
  for j in range(N):
    if X[i][0]==D[X[i][1]][j]+D[j][X[i][2]] and D[j][X[i][2]]!=0 and D[X[i][1]][j]!=0:
      break
    if j==N-1:
      P+=X[i][0]
  D[X[i][1]][X[i][2]]=X[i][0]
  D[X[i][2]][X[i][1]]=X[i][0]
print(P//2)

Measured memory_bytes: 88052
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c,n) for(int i=c;i<n;i++)
 
int main() {
  int n,m;
  long long int x,ans=0;
  cin>>n>>m>>x;
  
  vector<long long int> c(13,0),errans(13,0);
  vector<vector<long long int>> list(13, vector<long long int>(13));

  rep(i,0,n){
  	cin>>c[i];
    ans+=c[i];
    rep(j,0,m){
      cin>>list[i][j];
      errans[j]+=list[i][j];
    }
  }
  
  rep(i,0,m){
    if(errans[i]<x){cout<<-1<<endl;return 0;}
  }
  
  for (int tmp = 1; tmp < (1 << 13); tmp++) {
    bitset<13> s(tmp);
    //cout<<s<<endl;
 
    // ビット列の1のビットに対応する整数を選んだとみなして総和を求める
    long long int sum = 0;
    for (int i = 0; i < n; i++) {
      if (s.test(i)) {
        sum += c[i];
      }
    }
    //cout<<sum<<endl;
    
    vector<long long int> sumchk(13,0);
    rep(j,0,n){
      if(s[j]==1){
        rep(k,0,m){sumchk[k]+=list[j][k];}
      }
    }
    bool empty=0;
    rep(j,0,m){
      if(sumchk[j]<x){empty=1;}
    }
    if(empty!=1){ans=min(ans,sum);}
    
  }
  
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3584
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>

#include <cctype>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  long long h,w;cin>>h>>w;
	if(h==1 || w==1){
		cout << 1 << endl;
		return 0;
	}
	cout << h*w/2 + (h*w)%2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

int n;
int a[100005];

int main()
{
    cin >> n;
    rep(i, n) cin >> a[i];
    int m = infi;
    rep(i,n){
        if (a[i]%2==1){
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
vector<char> Alphabet = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
vector<char> alphabet = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


int main()
{
  cout << fixed << setprecision(10);
  ll N,D;
  cin >> N >> D;
  vector<ll> X(N),Y(N);
  ll cnt = 0;
  rep(i,N) 
  {
    cin >> X[i] >> Y[i];
    if(X[i]*X[i]+Y[i]*Y[i]<=D*D)
    {
      cnt ++;
    }
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 6420
def main():
    N = int(input())
    n = 1
    slist = []
    tlist = []
    while n <= N:
        s,t = input().split()
        s_n = str(s)
        t_n = int(t)
        slist.append(s_n)
        tlist.append(t_n)
        n += 1
    X = str(input())
    x = slist.index(X)
    sec = 0
    if x+1 < len(tlist):
        for i in range(x+1,len(tlist)):
            sec += tlist[i]
    print(sec)



if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;

int main()
{
	string s;
	cin >> s;
	int a, b;
	a = atoi(s.substr(0, 2).c_str());
	b = atoi(s.substr(2, 2).c_str());
	bool atf = 1 <= a && a <= 12;
	bool btf = 1 <= b && b <= 12;
	if (atf && btf)
		cout << "AMBIGUOUS" << endl;
	else if (atf)
		cout << "MMYY" << endl;
	else if (btf)
		cout << "YYMM" << endl;
	else
		cout << "NA" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll k;
int n = 50;
ll a[50];

void solve() {
    ll m = (k + n - 1) / n;
    ll r = m * n - k;
    for (int i = 0; i < n; i++) {
        a[i] = n-1 + m;
    }
    for (int i = 0; i < r; i++) {
        a[i] -= (n-r+1);
    }
    for (int i = r; i < n; i++) {
        a[i] += r;
    }
    
    cout << n << endl;
    for (int i = 0; i < n; i++) {
        cout << a[i];
        if (i == n-1) cout << endl;
        else cout << ' ';
    }
}

void input() {
    cin >> k;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

void solve() {
    long long ans, t_total, a_total;
    int t, a, n;
    cin >> n;
    cin >> t_total >> a_total;
    for (int i=0; i < n-1; ++i) {
        cin >> t >> a;
        long long p;
        p = max((t_total + t - 1) / t, (a_total + a - 1) / a);
        t_total = t*p; a_total = a*p;
    }
    ans = t_total + a_total;
    cout << ans;

}

int main() {

    solve();
    return 0;
}


Measured memory_bytes: 3160
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int w, h, f, m, o;
vector<vector<int> > cell;

class Data
{
public:
    int y, x, left, right, o;
    Data(int y0, int x0, int left0, int right0, int o0)
    {
        y = y0;
        x = x0;
        left = left0;
        right = right0;
        o = o0;
    }
    int toInt()
    {
        return (((y * w + x) * w + left) * w + right) * (m+1) + o;
    }
};

int solve()
{
    vector<int> dp((h+1) * w * w * w * (m+1), INT_MAX);
    multimap<int, Data> mm;

    for(int i=0; i<w; ++i){
        Data d(0, i, 0, w-1, o);
        dp[d.toInt()] = 0;
        mm.insert(make_pair(0, d));
    }

    while(!mm.empty()){
        int cost = mm.begin()->first;
        Data d = mm.begin()->second;
        mm.erase(mm.begin());

        if(cost > dp[d.toInt()])
            continue;
        if(d.y == h)
            return cost;

        for(int i=-1; i<=1; ++i){
            int cost1 = cost;
            Data d1 = d;
            -- d1.o;

            d1.x += i;
            if(d1.x < 0 || d1.x >= w || d1.o <= 0)
                continue;

            if(i == 0){
                ++ d1.y;
                d1.left = d1.x;
                d1.right = d1.x - 1;
            }

            if(d1.x < d1.left || d1.x > d1.right){
                d1.left = min(d1.left, d1.x);
                d1.right = max(d1.right, d1.x);
                if(cell[d1.y][d1.x] < 0){
                    cost1 += -cell[d1.y][d1.x];
                }else{
                    d1.o += cell[d1.y][d1.x];
                    d1.o = min(d1.o, m);
                }
            }

            if(cost1 < dp[d1.toInt()]){
                dp[d1.toInt()] = cost1;
                mm.insert(make_pair(cost1, d1));
            }
        }
    }

    return INT_MAX;
}

int main()
{
    for(;;){
        cin >> w >> h >> f >> m >> o;
        if(w == 0 && h == 0)
            return 0;

        cell.assign(h+1, vector<int>(w, 0));
        for(int i=0; i<h; ++i){
            for(int j=0; j<w; ++j){
                cin >> cell[i+1][j];
            }
        }

        int ret = solve();
        if(ret > f)
            cout << "NA" << endl;
        else
            cout << ret << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;

const int INF = 1e9;

int main() {
  int n;
  long long k;
  cin>>n>>k;
  map<int, long long> m;
  set<int> s;
  for (int i=0; i<n; i++) {
    int ai, bi;
    cin>>ai>>bi;
    s.insert(ai);
    m[ai] += bi;
  }
  vector<int> c(s.begin(), s.end());
  sort(c.begin(), c.end());
  long long cnt = 0;
  for (int ci: c) {
    cnt += m[ci];
    if (cnt >= k) {
      cout<<ci<<endl;
      break;
    }
  }
}

Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io

    int n;
    cin>>n;
    int a[n];
    rep(i,n) cin>>a[i];

    int all=1, bad=1;
    rep(i,n){
        all*=3;
        if(a[i]%2==0) bad*=2;
    }
    cout<<all-bad<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        String s = in.s();
        int N = s.length();
        int ans = 0;
        char t = s.charAt(0);
        for(int i = 1; i < N; i++){
            if (s.charAt(i) != t) {
                ans++;
                t = s.charAt(i);
            }
        }
        out.println(ans);
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }
    }
}


Measured memory_bytes: 23252
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int N, M;
    cin >> N >> M;
    int A[M], B[M];
    REP(i, M) cin >> A[i] >> B[i];

    set<int> s[N + 1];
    REP(i, M) {
        s[A[i]].insert(B[i]);
        s[B[i]].insert(A[i]);
    }

    deque<int> dq;
    dq.push_front(1);
    int visited[N + 1];
    visited[0] = 0;
    visited[1] = 1;
    FOR(i, 2, N + 2) visited[i] = -1;
    while (dq.size() != 0) {
        int v = dq.front();
        dq.pop_front();
        for (auto itr = s[v].begin(); itr != s[v].end(); ++itr) {
            if (visited[*itr] == -1) {
                visited[*itr] = v;
                dq.push_back(*itr);
            }
        }
    }

    bool f = true;
    REP(i, N) {
        if (visited[i + 1] == -1) {
            f = false;
            break;
        }
    }
    if (f) {
        cout << "Yes" << endl;
        REP(i, N - 1) {
            cout << visited[i + 2] << endl;
        }
    }
    else {
        cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 28952
#include<bits/stdc++.h>
using namespace std;
#define Elhabashy ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void input()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
const int N=1e5+5,mod=1e9+7;
typedef long long ll;
int n,k,arr[110],dp[N][3];
int solve(int i=k,bool p=0){
    int &ret=dp[i][p];
    if(~ret)return ret;

    ret=!p;
    for(int x=1;x<=n;x++){
        if(arr[x]<=i){
            if(solve(i-arr[x],!p)==p){
                ret=p;
            }
        }
    }
    return ret;
}
int main()
{
    Elhabashy
    input();
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>arr[i];
    memset(dp,-1,sizeof dp);
    if(solve())cout<<"Second\n";
    else cout<<"First\n";


}


Measured memory_bytes: 12548
#include<bits/stdc++.h>
using namespace std;
string debug_string(const string& s) {
	return '"' + s + '"';
}
string debug_string(bool b) {
	return (b ? "true" : "false");
}
string debug_string(const char* s) {
	return debug_string((string)s);
}
template<class T, class U>
string debug_string(const pair<T, U>& p);
template<class U>
struct can_be_string {
	template<typename...>
	static int f(...) {
		return 0;
	}
	template<typename T>
	static char f(decltype(to_string(T()), char())) { 
		return 'a';
	}
	static const bool value = sizeof(f<U>(char())) == sizeof(char);
};
template<class T> 
typename enable_if<can_be_string<T>::value, string>::type debug_string(const T& a) {
	string s = to_string(a);
	return s;
}
template<class T>
typename enable_if<!can_be_string<T>::value, string>::type debug_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += debug_string(x);
	}
	s += "}";
	return s;
}
template<class T, class U>
string debug_string(const pair<T, U>& p) {
	string s = "(";
	s += debug_string(p.first);
	s += ", ";
	s += debug_string(p.second);
	s += ")";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << debug_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 1e18l + 100;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	string s;
	cin >> s;
	if (s == "Sunny") {
		cout << "Cloudy\n";
	}
	else if (s == "Cloudy") {
		cout << "Rainy\n";
	}
	else {
		cout << "Sunny\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    string S, T, U;
    int A, B;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    if(U == S){
        cout << A-1 << " " << B << endl;
    }else{
        cout << A << " " << B-1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int a[300002], g[300002];

#define gc() getchar()
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int cmp(const void *a, const void *b)
{
	return *(int *)a - *(int *)b;
}

int main()
{
	int i, N, Q, x, y, t, xx, yy;
	int cnt;

	N = in();
	for (i = 1; i <= N; i++) g[i] = a[i] = in();
	qsort(g+1, N, sizeof(int), cmp);
	for (cnt = 0, i = 1; i <= N; i++) {
		if (g[i] != a[i]) cnt++;
	}
	if (cnt == 0) {
		puts("0");
		return 0;
	}
	Q = in();
	for (i = 1; i <= Q; i++) {
		x = in(), y = in();
		xx = a[x], yy = a[y];
		t = a[x], a[x] = a[y], a[y] = t;
		if (xx == g[x] && a[x] != g[x]) cnt++;
		else if (xx != g[x] && a[x] == g[x]) cnt--;
		if (yy == g[y] && a[y] != g[y]) cnt++;
		else if (yy != g[y] && a[y] == g[y]) cnt--;
		if (cnt == 0) {
			printf("%d\n", i);
			break;
		}
	}
	if (cnt) puts("-1");
	return 0;
}



Measured memory_bytes: 5068
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 1e6 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

ll mul(ll a, ll b) {
  return (a * b) % MOD;
}

ll add(ll a, ll b) {
  a += b;
  if(a >= MOD)
    a -= MOD;
  if(a < 0)
    a += MOD;
  return a;
}

ll power(ll a, ll b) {
  ll ret = 1;
  while(b) {
    if(b & 1)
      ret = mul(ret, a);
    b /= 2;
    a = mul(a, a);
  }
  return ret;
}

ll fact[N], invFact[N];

ll C(int n, int r) {
  return mul(fact[n], mul(invFact[n-r], invFact[r]));
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  fact[0] = 1, fact[1] = 1, invFact[0] = 1, invFact[1] = 1;
  for (int i = 2; i < N; ++i) {
    fact[i] = mul(fact[i-1], i);
    invFact[i] = power(fact[i] ,MOD - 2);
  }
  int n, m, k;
  cin >> n >> m >> k;
  ll ans = 0;
  for (int i = 1; i < n; ++i) {
    ans = add(ans, mul(mul(i, n - i), mul(m, m)));
  }
  for (int i = 1; i < m; ++i) {
    ans = add(ans, mul(mul(i, m - i), mul(n, n)));
  }
  ans = mul(ans, C(n * m - 2, k - 2));
  cout << ans;
  return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

// ■ XORの性質1
// 　 0,1,2,3 のXORは0、0,1,...,7のXORは0
// 　 0〜2の冪乗-1までのXORは0になる
// ■ XORの性質2
// 　 区間内に同じ数字が偶数回出現する場合はその要素は打ち消し合うと考えて良い
// ■ XORの性質3
// 　 XORは桁上げの生じない加算であるため、(この問題の制約下では)2の冪乗-1以上の数値にはならない

int main(){
    Init();
    ll m, k; cin >> m >> k;
    ll lim = pow(2, m);

    // kが2^(m+1)_-1より大きい場合（達成不可能な場合）
    if(lim <= k) cout << -1 << endl; 

    // m=0の場合
    else if(m == 0) cout << (k == 0 ? "0 0" : "-1") << endl;
    
    // m=1の場合
    else if(m == 1) cout << (k == 0 ? "0 0 1 1" : "-1") << endl;

    // m>=2の場合
    else{
        // 0〜2の冪乗-1までの数字をkを除いて昇順に並べたものAsce
        // Asceを逆順に並べ替えたものAdes
        // Asce k Ades kが答えとなる
        for(ll i=0; i<lim; i++) if(i != k) cout << i << " ";
        cout << k << " ";
        for(ll i=lim-1; i>=0; i--) if(i != k) cout << i << " ";
        cout << k << endl;
    }
}

Measured memory_bytes: 4036
/*
** author:mahmoud magdy
*/
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"

inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m;
    cin>>m;
    return m;
}
void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
int a[105];
int main()
{
    fast();
    int n=D();
    for(int i=0; i<n; ++i)
        a[i]=D();
    sort(a,a+n);
    ll ans=0;
    for(int i=0; i<n-2; i++)
    {
        for(int j=i+1; j<n-1; j++)
        {
            for(int k=j+1; k<n; k++)
            {
                if((a[i]+a[j])>a[k] && a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i])
                {
                    ans++;
                }
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

typedef long long ll;

const int N = 401;
const vector<int> dx = {0, 0, 1, -1};
const vector<int> dy = {1, -1, 0, 0};

int used[N * N];
vector<int> g[N * N];

int n, m;
int a[N][N];

int get(int i, int j) {
	return i * m + j;
}

int ok(int i, int j) {
	return 0 <= i & i < n && 0 <= j && j < m;
}

void dfs(int cur, int &c0, int &c1) {
	used[cur] = 1;
	if (a[cur / m][cur % m] == 0) {
		c0++;
	} else {
		c1++;
	}
	for (auto t : g[cur]) {
		if (!used[t]) {
			dfs(t, c0, c1);
		}
	}
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			char c;
			cin >> c;
			a[i][j] = (c == '#');
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			for (int f = 0; f < 4; f++) {
				int i1 = i + dx[f];
				int j1 = j + dy[f];
				if (ok(i1, j1) && a[i][j] != a[i1][j1]) {
					g[get(i, j)].push_back(get(i1, j1));
				}
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i < n * m; i++) {
		if (!used[i]) {
			int c0 = 0;
			int c1 = 0;
			dfs(i, c0, c1);
			ans += c0 * c1;
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 20524
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    ll N;
    cin>>N;
    vector<string>v;
    string s;
    ll a[5]={0,0,0,0,0};
    for(int i=0;i<N;i++){
        cin>>s;
        v.push_back(s);
    }
    for(int i=0;i<N;i++){
            if(v[i][0]=='M'){
                a[0]++;
              
            }
            else if(v[i][0]=='A'){
                a[1]++;
                
            }
            else if(v[i][0]=='R'){
                a[2]++;
               
            }
            else if(v[i][0]=='C'){
                a[3]++;
               
        }
            else if(v[i][0]=='H'){
                a[4]++;
                
            }
            
    
    }
    ll sum=0;
    for(int i=0;i<5;i++){
        for(int j=i+1;j<5;j++){
            for(int k=j+1;k<5;k++){
                sum+=a[i]*a[j]*a[k];
            }
        }
    }
    cout<<sum<<endl;




    return 0;
}

Measured memory_bytes: 6132
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, n) for (int i = 0; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

bool dp[30009][4][1009];

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;

    dp[0][0][0] = true;

    rep(p,N)rep(len,4)rep(c,1000){
      if(!dp[p][len][c]) continue;
      int s           = S[p] - '0';
      dp[p+1][len][c] = dp[p][len][c];
      if(len<=2){
        dp[p+1][len+1][c*10+s] = true;
      }
    }

    int ans = 0;
    rep(i,1000) if(dp[N][3][i]) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 118528
from sys import stdin
n,k = map(int,stdin.readline().rstrip().split())
li = list(map(int,stdin.readline().rstrip().split()))
nai = 0
ato = 0
point = 0
for i in range(n):
    for s in range(i+1,n):
        if li[i] > li[s]:
            nai += 1
    for v in range(n):
        if li[i] > li[v]:
            ato += 1
point += (nai*k)+(ato*k*(k-1)//2)
print(point%(10**9+7))


Measured memory_bytes: 3188
N = input()
N0 = int(N[0])
N1 = int(N[1])
N2 = int(N[2])

if N0 > N1 or (N0 == N1 and N2 <= N0):
    answer = str(N0)*3
    print(answer)
else:
    N0 = N0 + 1
    answer = str(N0)*3
    print(answer)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    //int T; cin >> T;
    //while(T--) 
 	//{
  //    
  //}
	int N,M,c=0;
	cin>>N>>M;
	for(int x=0;x+1<M-x+1-M%2;x++)
	{
		cout<<x+1<<' '<<M-x+1-M%2<<'\n';
		c++;
		if(c==M)
		return 0;
	}
	for(int x=M+1-M%2;x+1<2*M+1+M+1-M%2-x;x++)
	{
		cout<<x+1<<' '<<2*M+1+M+1-M%2-x<<'\n';
		c++;
		if(c==M)
		return 0;
	}
	return 0;
}
 


Measured memory_bytes: 3620
#include <bits/stdc++.h>

int main() {
	int a, b, k;
	scanf("%d %d %d", &a, &b, &k);

	int cnt = 0;
	for (int i = 1000;i >= 1;--i)
		if (a % i == 0 && b % i == 0) {
			cnt++;

			if (cnt == k) {
				printf("%d", i);

				return 0;
			}
		}

	return 0;
}

Measured memory_bytes: 256
N = gets.chomp.to_i


def dfs(char, last_char)
  return puts char if char.length == N

  'a'.upto(last_char) do |c|
    # aa -> aaa aab
    # ab -> aba abb abcのように 一つ前の文字の最後の文字の次の文字までしかでない
    next_last_char = c == last_char ? last_char.next : last_char
    dfs(char+c, next_last_char)
  end
end


dfs('', 'a')



Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

#include <bits/stdc++.h>
using namespace std;
signed main(){
    int N; cin>>N;
    vector<int> H(N); 
    REP(i,N) cin>>H[i];
    H.pb(INF);
    int X =0;
    int ans = 0;
    REP(i,N){
        if(H[i]>=H[i+1]) X++;
        else{
            Max(ans,X);
            X =0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  init();
  ll N;
  cin >> N;

  if (N < 1200) {
    COUT("ABC");
    return 0;
  }
  if (N < 2800) {
    COUT("ARC");
    return 0;
  }
  COUT("AGC");
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MOD 998244353
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
int cmp(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

int main()
{
    int n, i, count=0;
    lli sum=0, ans=0, a[100000];
    scanf("%d",&n);
    for(i=0; i<n; i++) {
        scanf("%lld",a+i);
        if(a[i] < 0) {
            a[i] *= -1;
            count++;
        }
        sum += a[i];
    }
    qsort(a, n, sizeof(lli), cmp);
    if(count%2 == 0) {
        ans = sum;
    } else {
        ans = sum - 2*a[0];
    }
    printf("%lld",ans);

    return 0;
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef string str;
const long long INF = INT64_MAX;

#define REP(i, n) for(ll i=0;i<n;i++)
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
str D[1000][1000][100];
void solve() {
    str s;
    ll k;
    cin >> s >> k;
    vector<str> valids;
    for (int l = 1; l <= k; l++)
    {
        for (int st = 0; st <= (ll)s.size() - l; st++)
        {
            str t = s.substr(st, l);
            valids.push_back(t);
        }
    }
    UNIQ(valids);
    cout << valids[k - 1] << endl;
}

int main() {
    FIO;
    solve();
    return 0;
}


Measured memory_bytes: 782844
#include <bits/stdc++.h>
using namespace std;
int mod = 1e9+7;

int visited[200005];
vector<int> ar[200005];
int cc;

void dfs(int employee){
    visited[employee]=1;
    cc++;
    for(int emp:ar[employee]){
        if(!visited[emp]){
            dfs(emp);
        }
    }
}

int main() {
	// your code goes here
	int n,m,a,b;
	    cin>>n>>m;
	    for(int i=1;i<=n;i++){
	        visited[i]=0;
	    }
	    for(int i=1;i<=m;i++){
	        cin>>a>>b;
	        ar[a].push_back(b);
	        ar[b].push_back(a);
	    }
        int ans=-1;
	    for(int i=1;i<=n;i++){
	        if(!visited[i]){
	            cc=0;
	            dfs(i);
	            ans = max(ans,cc);
	        }
	    }
	    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 21492
#include <bits/stdc++.h>
#include <string>
using namespace std;
typedef long long ll;

ll mod=1000000007;

int main(){
    ll n;
    cin>>n;
    ll cnt=0;
    for(ll i=1;i<=n;++i){
        for(ll j=1;j<=(n/i);++j){
            if(n>i*j){
                cnt++;
            }
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 3632
N=int(input())
ans=0
p=2
 
while N>1 and p*p<=N:
  if N%p==0:
    c=0
    while N%p==0:
      N=N/p
      c=c+1
    Y=1
    U=2
    while c>=Y:
      ans=ans+1
      Y=Y+U
      U=U+1
  p=p+1
 
if N>1:
  ans=ans+1
 
print(ans)

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const int mod=1e9+7;
 
int main(){
  int k,x;cin>>k>>x;
  rep(i,2*k-1){
    if(i)cout<<" ";
    cout<<x-k+1+i;
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

int sumDigits (int n) {
    int s;
    while (n < 0) {
        s += n % 10;
        n /= 10;
    }
    return s;
}

int main() {
    int A, B;
    int ans = 0;
    float T;
    cin >> A >> B >> T;
    int n = 1;
    while (A*n <= T+0.5) {
        ans += B;
        n += 1;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main() {
    string s;
    int minc = 100001;
    cin>>s;
    int n=s.length();
    for(int i=0; i<n-1; i++) {
        if(s[i] != s[i+1]) {
            minc = min(minc, max(i+1, n-i-1));
        }
    }
    if(minc > 100000) {
        cout<<n<<endl;
        return 0;
    }
    cout<<minc<<endl;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;
constexpr char newl = '\n';

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define F first
#define S second
#define debug(x) cout << #x << ": " << x << '\n';

#if 1

template<typename F>
struct FixPoint : F {
  FixPoint(F&& f) :F(forward<F>(f)) {}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const {
    return F::operator()(*this, forward<Args>(args)...);
  }
};
template<typename F>
inline decltype(auto) MFP(F&& f) {
  return FixPoint<F>{forward<F>(f)};
}

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;

  vector<vector<int>> G(N, vector<int>());
  F0R(i, M) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    G[x].push_back(y);
  }

  vector<int> dp(N, -1);

  auto dfs = MFP([&](auto dfs, int v) ->int {

    if (dp[v] >= 0) return dp[v];

    int longest = 0;
    for (auto e : G[v]) {
      int l = 1 + dfs(e);
      chmax(longest, l);
    }
    return dp[v] = longest;
  });

  int longest = 0;
  F0R(i, N) {
    if (dp[i] < 0) {
      dfs(i);
    }
    chmax(longest, dp[i]);
  }
  cout << longest;
}
#endif


Measured memory_bytes: 7936
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector <int> A(N);
  vector <int> B(N);
  vector <int> C(N - 1);
  for (int i = 0; i < N; i++) {
	  cin >> A[i];
	}
  for (int i = 0; i < N; i++) {
	  cin >> B[i];
	}
  for (int i = 0; i < N - 1; i++) {
	  cin >> C[i];
	}
  int ans = 0;
  ans += B[A[0] - 1];
  for (int i = 1; i < N; i++) {
	  ans += B[A[i] - 1];
	  if (A[i] - A[i - 1] == 1) {
		  ans += C[A[i - 1] - 1];
		}
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256