akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

  int n = S.size();
  rep(i, n) {
    bool match = true;
    int s = 0;
    int t = i;
    rep(j, n) {
      if (S[s] != T[t]) {
        match = false;
        break;
      }
      s++, t++;
      if (t == n)
        t = 0;
    }
    if (match) {
      puts("Yes");
      return 0;
    }
  }

  puts("No");
}

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    int t = s[0] - '0';
    bool f = true;
    for (int i = 1; i < n; i++) {
        if (s[i] != '9') {
            f = false;
            break;
        }
    }

    cout << (f ? t + 9 * (n - 1) : t + 9 * (n - 1) - 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
const int inf=0x7fffffff;
typedef long long int ll;
using namespace std;
const int N=1000+5;
double A[N];
int main()
{
//#ifdef DEBUG
//	freopen("in", "r", stdin);
////	freopen("out", "w", stdout);
//#endif
	int n;
	while(scanf("%d",&n)!=EOF&&n){
	double sum =0;
	double ans=0;
	for(int i=0;i<n;i++){
		scanf("%lf",&A[i]);
		sum+=A[i];
	}
	sum/=n;
//	cout<<sum<<endl;
	for(int i=0;i<n;i++){
		ans+=(A[i]-sum)*(A[i]-sum);
	}
	ans=sqrt(ans/n);
	printf("%f\n",ans);
	}
	//insert code above
	return 0;
}
//aoj1_10_c.cc

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

int s[200000];

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

int main(void)
{
    int n;
    int q;
    int cnt;
    int i, j;

    scanf("%d", &n);
    for (i = 0; i < n; ++i){
        scanf("%d", s + i);
    }
    qsort(s, n, sizeof(int), compare);

    scanf("%d", &q);
    cnt = 0;
    for (i = 0; i < q; ++i){
        int t;

        scanf("%d", &t);
        if (bsearch(&t, s, n, sizeof(int), compare) != NULL){
            ++cnt;
        }
    }

    printf("%d\n", cnt);

    return (0);
}

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

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define FORW(a, b, c) for(int a = b; a >= c; --a)
#define fi first
#define se second
#define pb push_back
#define int long long

typedef pair<int, int> ii;
typedef pair<int, ii> iii;

const int N = 2e5 + 100;
const int oo = 1e18;
const int mod  = 1e9 + 7;

string s;
int D, ans;
int pw[20];

int calc(int pos, int val)  {
    if(val < 0) val = -val;
    int it = val;
    if(pos == 1) it = val + 1;
    return 9 - it + 1;
}
int btr(int pos, int sum, int len) {
    int cur = 0ll;
    if(len == 0) return (sum == 0);
    if(len == 1) return (sum == 0) * 10;
    FOR(i, -9, 9)  {
        int nex = sum - 1ll * i * (pw[len - 1] - 1ll);
        if(nex % 10 == 0) {
            cur += calc(pos, i) * btr(pos + 1, (nex / 10), len - 2);
        }
    }
    return cur;
}


signed main()  {
//    freopen("test.inp", "r", stdin);
//    freopen("test.out", "w", stdout);
    ios_base::sync_with_stdio(false); cout.tie(0);
    pw[0] = 1; FOR(i, 1, 17) pw[i] = pw[i - 1] * 10;

     cin >> s;
    FOR(i, 0, s.length() - 1) D = D * 10 + s[i] - '0';

    FOR(i, 2, 18) {
        ans += btr(1, D, i);
    }
    return cout << ans, 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, h, w, k);
    vc<vc<bool>> s(h, vc<bool>(w, false));
    For(i, h) For(j, w){
        Cin(char, c);
        if(c == '#') s[i][j] = true;
    }
    vc<vc<int>> c(h, vc<int>(w, -1));
    int t = 1;
    bool y = false;
    For(i, h){
        bool f = false;
        For(j, w){
            if(s[i][j]) y = f = true;
        }

        // イチゴがある
        if(f){
            bool z = false;
            For(j, w){
                if(s[i][j]){
                    if(!z) z = true;
                    else t ++;
                }
                c[i][j] = t;
            }
            t ++;
        }
        
        // イチゴがない
        else{
            if(!y) continue;
            For(j, w) c[i][j] = c[i-1][j];
        }
    }
    
    for(int i = h-1; i >= 0; i --){
        if(c[i][0] == -1){
            For(j, w) c[i][j] = c[i+1][j];
        }
    }

    For(i, h) Couts(c[i]);
}


Measured memory_bytes: 1152
def dp():
    cnt = []
    for i in range(10):
        cnt.append([0] * 10)
    for i in range(10):
        cnt[0][i] = 1
    for i in range(1, 10):
        for j in range(10):
            cnt[i][j] = 0
            for k in range(-1, 2):
                if 0 <= j+k and j+k < 10:
                    cnt[i][j] += cnt[i-1][j+k]
    return cnt


def main():
    k = int(input())
    cnt = dp()
    tot = [0] * 10
    for i in range(10):
        tot[i] = sum(cnt[i][1:])
    # print(*cnt, sep='\n')
    # print(tot)

    res = 0
    length = -1
    digit = -1
    for i in range(10):
        if tot[i] < k:
            k -= tot[i]
        else:
            length = i
            for j in range(1, 10):
                if k > cnt[i][j]:
                    k -= cnt[i][j]
                else:
                    digit = j
                    break
            break

    length -= 1
    res = digit
    while length >= 0:
        # print(length, k, digit, res)
        for i in range(-1, 2):
            # print('#', length, k, digit, digit + i, cnt[length][digit + i])
            if 0 <= digit + i and digit + i <= 9:
                if cnt[length][digit + i] >= k:
                    digit = digit + i
                    break
                else:
                    k -= cnt[length][digit + i]
        length -= 1
        # print(digit)
        res = res * 10 + digit
    print(res)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int c1 = scan.nextInt();
        int c5 = scan.nextInt();
        int c10 = scan.nextInt();
        int c50 = scan.nextInt();
        int c100 = scan.nextInt();
        int c500 = scan.nextInt();

        if (c1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500 < 1000) {
            System.out.println("0");
        } else {
            System.out.println("1");
        }
    }
}



Measured memory_bytes: 26056
from fractions import gcd

N,K = map(int, input().split())
As = list(map(int,input().split()))

if K in As:
  print('POSSIBLE')
  exit()
if K > max(As):
  print('IMPOSSIBLE')
  exit()
  
r = As[0]

for i in range(1,N):
  r = gcd(As[i],r)
  
if K%r != 0:
  print('IMPOSSIBLE')
else:
  print('POSSIBLE')

Measured memory_bytes: 91072
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String x = in.nextLine();
        String[] arr = x.split(" ");
        for (int i = 0; i < arr.length; i++) {
            String s = arr[i];
            System.out.print(s.charAt(0));
        }
    }
}

Measured memory_bytes: 26924
#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
    int r, c;
    int t[101][101];

    scanf("%d %d\n", &r, &c);
    for (int i = 0; i < r; i++) {
        int s  = 0;
        for (int j = 0; j < c; j++) {
            scanf("%d", &t[i][j]);
            s += t[i][j];
        }
        t[i][c] = s;
    }
    
    for (int i = 0; i < c + 1; i++) {
        int s = 0;
        for (int j = 0; j < r; j++) {
            s += t[j][i];
        }
        t[r][i] = s;
    }
    
    for (int i = 0; i < r + 1; i++) {
        for (int j = 0; j < c + 1; j++) {
            printf("%s%d", j == 0 ? "" : " ", t[i][j]);
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2092
#include<stdio.h>

static const int N = 100;

int min(int a,int b){
  return a<b ? a : b;
}

int main(){
  int i,j,k,l;
  int n,p[N+1],m[N+1][N+1];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }
  for(i=1;i<=n;i++){
    m[i][i]=0;
  }
  for(l=2;l<=n;l++){
    for(i=0;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=(1<<21);
      for(k=i;k<=j-1;k++){
	m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }
  printf("%d\n",m[1][n]);
  return 0;
}



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


int main(){
        int a,b,c,min,max;
        cin>>a>>b>>c;

        min=a;
        max=a;

        if(min>b){
                min=b;
        }else{
                max=b;
        }

        if(min>c){
                min=c;
        }else if(max<c){
                max=c;
        }

        cout<<max-min<<endl;
        }

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int P, Q, R;
    cin >> P >> Q >> R;

    if(P >= R && P >= Q){
        cout << R + Q;
    }else if(R >= P && R >= Q){
        cout << P + Q;
    }else{
        cout << R + P;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string.h>
#define rep(i,l,r) for((i)=(l);(i)<(r);(i)++)
#define erep(i,l,r) for((i)=(l);(i)<=(r);(i)++)
#define drep(i,l,r) for((i)=(l);(i)>=(r);(i)--)
#define MOD 1000000007
#define ll long long
#define MAX(a,b) ((a)>(b)?(a):(b))
using namespace std;
int main(){
    ll n,k,q,i,buf;
	cin>>n>>k>>q;
    
    vector<ll> ans(n,0);
    rep(i,0,q){
        cin>>buf;
        ans[buf-1]++;
    }
    rep(i,0,n){
        if(k-q+ans[i]>0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


Measured memory_bytes: 1408
#include<iostream>
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
using namespace std;
int main()
{
    fastio;
    long long n,i;
    cin>>n;
    long long a[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<=n;i++)
    {
        if(a[i]!=i)
        {
            swap(a[i],a[a[i]]);
            break;
        }
    }
    for(i=1;i<=n;i++)
    {
        if(a[i]!=i)
        {
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
    return 0;
}

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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,start,end) for(int i=(start);i<=(end);i++)
#define all(n) begin(n),end(n)

#define DEBUG

int main()
{
	int r;
	cin >> r;
	if(r < 1200) cout << "ABC" << endl;
	else if(r < 2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int N,K;
cin>>N>>K;
vector<int>men(N+1);
vector<vector<int>>num(K, vector<int>(100));
for(int i=0;i<K;i++)
{for (int j=0;j<100;j++)

{num[i][j]=0;}

}

vector<int>d(K);

for(int i=0;i<K;i++)

{cin>>d[i];

for(int j=0;j<d[i];j++)
{cin>>num[i][j];}


}


for(int i=0;i<K;i++)
{for(int j=0;j<100;j++)
{men[num[i][j]]++;}

}

int answer=0;
for(int i=1;i<=N;i++)
{if(men[i]==0){answer++;}}
cout<<answer<<endl;
}



Measured memory_bytes: 3636
/*
AizuOnline A2012
Title:Space Coconut Crab
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
#include <float.h>
#include <math.h>
//#include <limits.h>
//Global data section
int n;
//
int sq_lin(int x)
{
  int q2;

  q2=(int)sqrt(x);
  return(q2+x-q2*q2);
}

main()
{
  int i,j,q3,sum,summin;
 
  while(scanf("%d",&n) && n)
    {
      q3=round(pow((double)n,1.0/3));
      if(q3*q3*q3>n)q3--;

      summin=999999;
      for(i=q3;i>=0;i--)
	{
	sum = sq_lin(n-i*i*i);
        // printf("3j:%d\n",i);
        // printf("sm:%d\n",sum);
	if(sum+i < summin)
	  summin=sum+i;
	}
      printf("%d\n",summin);
    }
return(0);
}

Measured memory_bytes: 668
#include<cstdio>

int n, k, x[100005], ans = 2e9;

int min(int x, int y) {
	return x < y ? x : y;
}

int abs(int x) {
	return x > 0 ? x : -x;
}

int f(int x, int y) {
	return min(abs(x), abs(y)) + abs(x - y);
}

int main() {
	scanf("%d %d", &n, &k);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &x[i]);
	}
	for (int i = 1; i + k - 1 <= n; i++) {
		ans = min(ans, f(x[i], x[i + k - 1]));
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	int size[]={60,80,100,120,140,160,INT_MAX};
	int weight[]={2,5,10,15,20,25,INT_MAX};
	int price[]={600,800,1000,1200,1400,1600,0};
	for(int n;cin>>n,n;){
		int sum=0;
		rep(i,n){
			int x,y,h,w; cin>>x>>y>>h>>w;
			sum+=price[max(lower_bound(size,size+6,x+y+h)-size,lower_bound(weight,weight+6,w)-weight)];
		}
		cout<<sum<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <random>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

llong pow(int x, int n) {
    llong ans = x;
    if (n == 0) return 1;

    for(int i = 0; i < n - 1; i++) {
        ans *= x;
    }

    return ans;
}

void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}

int main() {
    llong h, w, n, a, b, cnt[10], sum = 0;
    cin >> h >> w >> n;
    map<pair<int, int>, int> M;

    rep(i, n) {
        cin >> a >> b;
        for (int j = a - 2; j <= a; ++j) {
            for (int k = b - 2; k <= b; ++k) {
                if (1 <= j && j + 2 <= h && 1 <= k && k + 2 <= w) {
                    M[make_pair(j, k)]++;
                }
            }
        }
    }

    memset(cnt, 0, sizeof(cnt));

    for (auto it = M.begin(); it != M.end(); it++) {
        cnt[it->second]++;
    }

    FOR(i, 1, 10) sum += cnt[i];

    cout << (h - 2) * (w - 2) - sum << endl;

    FOR(i, 1, 10) cout << cnt[i] << endl;

    return 0;
}

Measured memory_bytes: 56448
#include <iostream>
#include <string>

using namespace std;

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

	bool flag = false;
	for(int i = 0; i < S.size(); i++) {
		if(i < S.size() - 1 && S[i] == 'A' && S[i + 1] == 'C') {
			flag = true;
		}
	}

	cout << (flag ? "Yes" : "No") << endl;

	return 0;
}


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

int main() {
  int N, K, S;
  cin >> N >> K >> S;

  int other;
  if (S == 1e9) {
    other = 1;
  }
  else {
    other = 1e9;
  }

  for (int i = 1; i <= N; i++) {
    if (i <= K) cout << S << " ";
    else cout << other << " ";
  }

  cout << endl;
    

  return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>

int main(void)
{
	char S[5];
	scanf("%s", S);

	int i;
	int alp[26] = {0};
	for (i = 0; i < 4; i++) {
		int idx = S[i] - 'A';
		alp[idx]++;
	}

	int cnt = 0;
	for (i = 0; i < 26; i++)
		if (alp[i] == 2)
			cnt++;

	puts(cnt == 2 ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 128
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut b = Vec::new();
    for i in 0..n {
        b.push((a[i], i));
    }
    b.sort();

    let mut ans = 0;
    for i in 0..n {
        ans += (b[i].1 & 1) ^ (i & 1);
    }

    println!("{}", ans >> 1);
}


Measured memory_bytes: 10492
def calc_ABC(a, c, bq, aq):
    ans = 0
    if aq != 0:
        if bq != 0:
            ans = ans + (a*pow(3, bq, MOD) + bq*pow(3, bq-1, MOD)) \
                 * (c*pow(3, aq, MOD) + aq*pow(3, (aq-1), MOD))
        else:
            ans = ans + (a*pow(3, bq, MOD)) \
                 * (c*pow(3, aq, MOD) + aq*pow(3, (aq-1), MOD))
    else:
        if bq != 0:
            ans = ans + (a*pow(3, bq, MOD) + bq*pow(3, bq-1, MOD)) \
                 * (c*pow(3, aq, MOD))
        else:
            ans = ans + (a*pow(3, bq, MOD)) \
                 * (c*pow(3, aq, MOD))
    return ans % MOD


MOD = 10**9 + 7
S = input()
ans = 0
count_a = 0
count_c = S.count('C')
count_afterq = S.count('?')
count_beforeq = 0

for i in range(len(S)):
    if S[i] == 'A':
        count_a += 1
    elif S[i] == 'B':
        ans += calc_ABC(count_a, count_c, count_beforeq, count_afterq)
        ans = ans % MOD
    elif S[i] == 'C':
        count_c -= 1
    elif S[i] == '?':
        count_afterq -= 1
        ans += calc_ABC(count_a, count_c, count_beforeq, count_afterq)
        ans = ans % MOD
        count_beforeq += 1
print(ans)


Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  string s;cin>>s;
  int n=s.length();
  int rem=0;
  rep(i,n){
    rem+=s[i]-'0';
    rem%=9;
  }
  	if(rem==0){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  return 0;
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	ll x, y, z;
	cin >> x >> y >> z;
	ll cnt = 0;
  	ll a=x,b=y,c=z;
	while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
      	x=a,y=b,z=c;
		a = (y+z)/2,b = (x+z)/2,c = (x+y)/2;
		cnt++;
      	if(cnt>10000000){cout<<-1<<endl; return 0;}
	}
	cout << cnt << endl;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')
AZ = "abcdefghijklmnopqrstuvwxyz"

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


#####Shorten#####
def DD(arg): return defaultdict(arg)

#############
# Main Code #
#############

N = I()
words = [w[::-1] for w in SLs(N)]
words.sort()
Lsortwords = sorted([(i,words[i]) for i in range(N)],key = lambda x:-len(x[1]))

class SegmentTree:
  def __init__(self, n, op, e):
    self.n = n
    self.op = op
    self.e = e
    self.size = 2 ** ((n - 1).bit_length())
    self.node = [self.e] * (2 * self.size)
 
  def build(self, array):
    for i in range(self.n):
      self.node[self.size + i] = array[i]
    for i in range(self.size - 1, 0, -1):
      self.node[i] = self.op(self.node[i << 1], self.node[(i << 1) + 1])
 
  def update(self, i, val):
    i += self.size
    self.node[i] += val
    while i > 1:
      i >>= 1
      self.node[i] = self.op(self.node[i << 1], self.node[(i << 1) + 1])
 
  def get(self, l, r):
    l, r = l + self.size, r + self.size
    res_l, res_r = self.e, self.e
    while l < r:
      if l & 1:
        res_l = self.op(res_l, self.node[l])
        l += 1
      if r & 1:
        r -= 1
        res_r = self.op(self.node[r], res_r) 
      l, r = l >> 1, r >> 1
    return self.op(res_l, res_r)
  
ST = {l:SegmentTree(N,lambda a,b:a+b,0) for l in AZ}
check = [DD(int) for i in range(N)]
ans = 0
shori = 0
for i in range(len(Lsortwords[0][1]))[::-1]:
  for j,w in Lsortwords:
    if len(w) <= i: break
    if not check[j][w[i]]:
      ST[w[i]].update(j,1)
      check[j][w[i]] = 1
  while shori < N and len(Lsortwords[shori][1]) == i+1:
    w = Lsortwords[shori][1]
    p = w[:-1]
    q = w[-1]
    l = bisect.bisect_left(words,p)
    r = bisect.bisect(words,p+chr(97 + 26))
    ans += ST[q].get(l,r)-1
    shori += 1
    if shori == N: break
      
print(ans)

Measured memory_bytes: 341384
#include<iostream>
using namespace std;
typedef long long ll;
int main() {
    ll n, m; cin >> n >> m;
    if (m <= 1) {
        cout << 0 << endl;
    } else if (n >= 2 * m) {
        cout << n << endl;
    } else if (m >= 2 * n) {
        cout << n + (m - 2 * n) / 4 << endl;
    } else {
        cout << m / 2 << endl;
    }
    return 0;
}


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

int n;
vector<int> t, v;
template <class T>
void readVector(int n, vector<T> &v){
	for(int i=0; i<n; ++i){
		T t;
		cin >> t;
		v.push_back(t);
	}
}
int l;
double ans;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	readVector(n, t);
	readVector(n, v);
	for(auto i:t)
		l += i;
	l *= 2;
	t.push_back(l);
	vector<int> a(l+1, 0);
	for(int i=0; i<l; ++i)
		a[i] = i;
	for(int i=0; i<l; ++i)
		a[l-i] = min(i, a[l-i]);
//	for(int i=0; i<l; ++i)
//		cout << i << " " << a[i] << "\n";
	int c = 0;
	for(int i=0; i<n; ++i){
		for(int j=0; j<2*t[i]; ++j)
			a[c+j] = min(a[c+j], v[i]*2);
		int p = c;
		while(p > 0){
			a[p] = min(a[p], c-p+v[i]*2);
			--p;
		}
		p = c+2*t[i];
		while(p < l){
			a[p] = min(a[p], p-c-2*t[i]+v[i]*2);
			++p;
		}
		c += 2*t[i];
	}
//	cout << "l = " << l << "\n";
//	for(int i=0; i<l; ++i)
//		cout << i << " " << a[i] << "\n";
	for(int i=0; i<l; ++i)
		ans += (double)a[i] / 4;
	printf("%.5lf\n", ans);
}

Measured memory_bytes: 384
n = int(input())
x = [0]*n
y = [0]*n
for i in range(n):
  x[i],y[i] = map(int,input().split())
ans = 0
for i in range(n):
    for j in range(i+1,n):
        ans += 2/n * ( (x[i]-x[j])**2 + (y[i]-y[j])**2)**0.5
print(ans)

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define PTR2(a,j,N,k,L) for(int i = (j); i <= (N);i++) see(a[i],k,L);

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}
template<typename T> void see(T a[],int from,int to){ _rep(i,from,to) cout << a[i]<<" ";cout << endl;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

int main()
{
    int N,M;
    cin >> N >> M;
    if(N == M) cout << "Yes" <<endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 27;
const double EPS = 1e-10;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
#define repD(i, n) for(int i = n; i >= 0; i--)


int nums[] = { 0, 1, 2, 3, 5, 7, 8, 9};

int main(){
	ll n;
	while(cin >> n && n){
		ll p = 1;
		while(p * 8LL <= n) p *= 8LL;
		while(p > 0){
			int a = n / p;
			n %= p;
			p /= 8LL;
			cout << nums[a] ;
		}
		cout << endl;
	}
	return 0;
}

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


#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
typedef long long int lli;
typedef long long ll;
typedef long double ld;


signed main(){
    fast_IO;
    int t=1;
    //cin>>t;
    while(t--){
      int x;
        for(int i=1;i<=5;i++){
            cin>>x;
          if(x==0)
            cout<<i;
        }
    }   
    return 0;
}


Measured memory_bytes: 3600
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 2019

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}
void hSwap(int x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}
void ShowData(int x[], int left, int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%d  ", x[i]);
	printf("\n");
}
void QSort(int x[], int left, int right, int n) {
	int i, j;	//左端,右端
	int pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		hSwap(x, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort(x, left, i - 1, n);
	if (j + 1 <  right)QSort(x, j + 1, right, n);
}


int main() {
	int n;
	scanf("%d", &n);
	PRINTD(3 * n*n);
}


Measured memory_bytes: 128
#include <cstdio>
#include <utility>
#include <complex>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n';)s+=c;return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;if((c=gcu())=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
	_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

using P = complex<double>;

P read() {
	int x{in}, y {in};
	return P(x, y);
}

int ccw(P a, P b, P c) {
	b -= a; c -= a, a = b * conj(c);
	return imag(a) > 0 ? 1 : imag(a) < 0 ? -1 : real(a) < 0 ? 2 : norm(b) < norm(c) ? -2 : 0;
}

bool intersection(P &p0, P &p1, P &p2, P &p3) {
	return (ccw(p1, p0, p2) * ccw(p1, p0, p3) <= 0) && (ccw(p3, p2, p0) * ccw(p3, p2, p1) <= 0);
}
int main() {
	times(n, in) {
		P p0 {read()}, p1 {read()}, p2 {read()}, p3 {read()};
		outl(intersection(p0, p1, p2, p3));
	}
}


Measured memory_bytes: 2692
import math


def is_prime(x):
    if x < 2:
        return False
    for i in range(2, math.ceil(x ** (1 / 2))):
        if x % i == 0:
            return False
    else:
        return True


X = int(input())
while not is_prime(X):
    X += 1
else:
    print(X)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		double result = arr[0];
		for (int i = 1; i < n; i++) {
			result = (result + arr[i]) / 2.0;
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define REP(i, n) for (int i=0, i##_limit=(n); i<i##_limit; ++i)
#define FOR(i, a, b) for (int i=(a), i##_limit=(b); i<i##_limit; ++i)
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long;
using pi = pair<int, int>;

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

    int ret = 0;
    for (int i=1; i<=N; ++i)
    {
        if ((int)(log10(i)+1)%2 == 1) ++ret;
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
// now

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    } 

    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};


ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}
int ke (int n){
    n--;
    if(n == 1 )return 0;
    int ans = 1;
    while (0 < n){
        ans *= n;
        n--;
    }
    return ans ;

}
int main(){
   string s;
   cin >> s;

   for(int i = 0; i<s.size()/2;i++){
       if(s[i] == s[s.size()-1-i]){
           continue;
       }else{
           cout << "No" <<endl;
           return  0;
       }
   }

   string s1 = "",s2 = "";

    for(int i=0; i < s.size()/2; i++){
        s1+= s[i];
    }
    for(int i= s.size()/2 + 1 ; i<s.size();i++){
        s2 += s[i];
    }

    for(int i = 0;i<s1.size()/2;i++){
        if(s1[i] == s1[s1.size()-1-i] || s2[i] == s2[s2.size()-1-i]){
           continue;
       }else{
           cout << "No"  <<endl;
           return 0;
       }
    }
    
    cout << "Yes" << endl;
}





Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}


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;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

void y() {
    cout << "Yes" << endl;
    exit(0);
}

void n() {
    cout << "No" << endl;
    exit(0);
}

void Y() {
    cout << "YES" << endl;
    exit(0);
}

void N() {
    cout << "NO" << endl;
    exit(0);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}

/*   kokomade  */

int cnt = 0;
bool is_prime[ 50000 + 1 ];
vector<int> P;
void Eratosthenes( const int N )
{
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;//初期化
    }
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
}

int main() {
    IOS;
    int n,x,t;cin>>n;
    // int a,b,c;cin>>a>>b>>c;
    // string str;cin>>str;
    vector<Int> h(n);
    // vector<string> s(n);
    for (int i = 0; i < n; ++i) {
        cin>>h[i];
    }
    Int now=h[0];
    bool ok=1;
    int cnt=0,ans=0;
    for (int i = 0; i < n-1; ++i) {
        now=h[i];
        if(h[i+1]<=now){
            cnt++;
            ans=max(ans,cnt);
        }else{
            ans=max(ans,cnt);

            cnt=0;
        }

    }
    cout<<ans;


    cout<<endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;


int main(void){
   int N;
   cin>>N;
   vector<int> L(N);
   for(int i=0;i<N;i++){
      cin>>L[i];
   }
   sort(L.begin(),L.end());
   int ans=0;
   for(int mid=N-1;mid>=0;mid--){
      for(int low=mid-1;low>=0;low--){
         auto position=lower_bound(L.begin(),L.end(),L[mid]+L[low]);
         int temp=distance(position,L.end());
         ans+=(N-1-mid)-temp;
      }
   }
   cout<<ans<<endl;
   return 0;
}

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

long long calc(long long N, long long X, vector<long long> burger_widths, vector<long long> patty_nums){
  if(N==0) return 1;
  if(X==1) return 0;
  if(X>burger_widths[N-1]+2){
    return patty_nums[N-1]+1+calc(N-1,X-burger_widths[N-1]-2,burger_widths,patty_nums);
  }else if(X==burger_widths[N-1]+2){
    return patty_nums[N-1]+1;
  }else if(X==burger_widths[N-1]+1){
    return patty_nums[N-1];
  }else{
    return calc(N-1,X-1,burger_widths,patty_nums);
  }
}
  

int main(){
  long long N,X;
  long long i;
  long long answer = 0;
  cin >> N >> X;
  long long burger_width=1;
  long long patty_num=1;
  vector<long long> burger_widths(N+1);
  vector<long long> patty_nums(N+1);
  for(i=0;i<=N;i++){
    burger_widths[i]=burger_width;
    patty_nums[i]=patty_num;
    burger_width = 2*burger_width+3;
    patty_num = 2*patty_num+1;
  }
  answer = calc(N,X,burger_widths,patty_nums);
  
  cout << answer << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int N;

// to find index of the least number that is equal to or greater than n         
int binsearch(vector<int> v, int n){
  int lb = 0; int ub = N;
  int mid = (lb + ub)/2;
  while( ub - lb > 1 ){
    //printf("lb:%d mid:%d ub:%d\n", lb, mid, ub);                              
    if(v[mid] >= n){
      ub = mid;
    }
    else {
      lb = mid;
    }
    mid = (lb + ub)/2;
  }
  return ub;
}
int main()
{
  int res=0;
  cin >> N;
  vector<int> l(N);

  rep(i,N) cin >> l[i];
  sort(l.begin(),l.end());

  //a < b < c                                                                   
  FOR(i, 0, N-1){//a                                                            
    FOR(j, i+1, N-1){//b                                                        
      int k = binsearch(l, l[i]+l[j]);
      res += max( k - (j+1) , 0 );
      //printf("(%d,%d): %d@%d ~ %d@%d => %d \n", l[i], l[j], l[j+1], j+1, l[k]\
, k, res);                                                                      
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class G
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		var n = h[0];
		var es = new int[h[1]].Select(_ => Read()).ToArray();

		var map = Array.ConvertAll(new int[n], _ => new List<int>());
		var map_r = Array.ConvertAll(new int[n], _ => new List<int>());
		foreach (var e in es)
		{
			map[e[0]].Add(e[1]);
			map_r[e[1]].Add(e[0]);
		}

		var u = new bool[n];
		var order = new int[n];
		var c = n;
		var gs = new int[n];
		var gi = 0;

		void Dfs(int v)
		{
			u[v] = true;
			foreach (var nv in map[v]) if (!u[nv]) Dfs(nv);
			order[--c] = v;
		}
		for (int v = 0; v < n; v++) if (!u[v]) Dfs(v);

		void Dfs_r(int v)
		{
			u[v] = true;
			foreach (var nv in map_r[v]) if (!u[nv]) Dfs_r(nv);
			gs[v] = gi;
		}
		Array.Clear(u, 0, n);
		foreach (var v in order) if (!u[v]) { gi++; Dfs_r(v); }

		var r = Array.ConvertAll(new int[gi + 1], _ => new List<int>());
		for (int v = 0; v < n; v++) r[gs[v]].Add(v);

		Console.WriteLine(gi);
		Console.WriteLine(string.Join("\n", r.Skip(1).Select(g => string.Join(" ", g.Prepend(g.Count)))));
	}
}


Measured memory_bytes: 181752
#include <stdio.h>
int main(){
  int i,j,N,A[1000],minj,tmp,count=0,k;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

for(i=0;i<N-1;i++){
  minj = i;
  for(j=i;j<N;j++){
    if(A[j]<A[minj]){
      minj = j;
    }
  }
  if(A[i] > A[minj]){
    count++;
  }
  tmp = A[i];
  A[i] = A[minj];
  A[minj] = tmp;

}

for(k=0;k<N-1;k++){
  printf("%d ",A[k]);
}
printf("%d\n",A[N-1]);
printf("%d\n",count);
return 0;
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;

ll n,m,a,b;
vll p;
vector<vll> t;
vector<bool> vis;
bool is;

void dfs()
{
    queue<ll> q;
    q.push(1);
    
    while(!q.empty())
    {
        ll v = q.front();
        vis[v]=true;
        q.pop();

        fa(it,t[v])
        {
            if(!vis[it])
            {
                p[it]=v;
                q.push(it);
                vis[it]=true;
            }
        }
    }

}

void solve()
{
    is=true;   
    cin >> n >> m;
    p.resize(n+5,0);
    t.resize(n+5);
    vis.resize(n+5,false);
    p[1]=1;

    f(i,1,m)
    {
        cin >> a >> b;
        t[a].pb(b);
        t[b].pb(a);
    }

    dfs();

    f(i,1,n)
    {
        if(p[i]==0)
            is=false;
        // cout << i << " " << p[i] << endl;
    }
    if(is)
    {
        cout << "Yes" << endl;
        f(i,2,n)
            cout << p[i] << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}

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

Measured memory_bytes: 12860
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
 long long int n,i,j,k;
 cin>>n>>k;
 vector<long long int> a(n),d(n);
 for (i=0;i<n;i++){
  cin>>a[i];
  d[i]=1000000000000;
 }
 d[0]=0;
 for (i=1;i<n;i++){
  for (j=i-1;j>=0&&j>=i-k;j--){
   d[i]=min(abs(a[i]-a[j])+d[j],d[i]);
  }
 }
 cout<<d[n-1];
 return 0;
}

Measured memory_bytes: 1792
import java.util.*;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a - 2*b < 0) {
            System.out.println(0);
        } else {
            System.out.println(a - 2 * b);
        }
	}
}


Measured memory_bytes: 23764
using System;
using System.Linq;

namespace AtCoderPanasonicContest2020
{
	class Program
	{
		static void Main(string[] args)
		{
			var inputs = ReadIntArray();
			long hmax = inputs[0] % 2 == 0 ? inputs[0] / 2 : inputs[0] / 2 + 1;
			long hmin = inputs[0] / 2;
			long wmax = inputs[1] % 2 == 0 ? inputs[1] / 2 : inputs[1] / 2 + 1;
			long wmin = inputs[1] / 2;

			var result = hmax * wmax + hmin * wmin;
			if (inputs[0] == 1 || inputs[1] == 1)
			{
				Console.WriteLine(1);
			}
			else
			{
				Console.WriteLine(result);
			}
		}

		public static int ReadInt()
			=> int.Parse(Console.ReadLine());

		public static int[] ReadIntArray()
			=> Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

		public static long ReadLong()
			=> long.Parse(Console.ReadLine());

		public static long[] ReadLongArray()
			=> Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

		public static string ReadString()
			=> Console.ReadLine();

		public static string[] ReadStringArray()
			=> Console.ReadLine().Split();
	}
}


Measured memory_bytes: 13268