akhauriyash/Code-Regression huggingface dataset:
n,k = map(int,input().split())

l = list(map(int,input()))
ll = []
p = l[0]
co = 1
ppp = 0
su = 0
lll = []
for i in range(n-1):
    if p == l[i+1]:
        co += 1
    else:
        if p == 0:
            ppp += 1
        ll.append([p,co])
        p = l[i+1]
        co = 1
if p == 0:
    ppp += 1
ll.append([p,co])
co = 0

if len(ll) == 1:
    print(n)
    exit(0)
if ppp <= k:
    print(n)
    exit(0)
if ll[0][0] == 0:
    if ll[-1][0] == 0:
        for i in range(2*k):
            co += ll[i][1]
        lll.append(co)
        co -= ll[0][1]
        for i in range(ppp-k):
            if ppp-k-1 == i and i == 0:
                co += ll[-1][1]
                lll.append(co)
            elif ppp-k-1 == i:
                co += ll[-1][1] - (ll[i*2-1][1] + ll[i*2][1])
                lll.append(co)
            elif i == 0:
                co += ll[i*2+1+2*k][1] + ll[i*2+2*k][1]
                lll.append(co)
            else:
                co += ll[i*2+1+2*k][1] + ll[i*2+2*k][1] - (ll[i*2-1][1] + ll[i*2][1])
                lll.append(co)

    else:
        for i in range(2*k):
            co += ll[i][1]
        lll.append(co)
        co -= ll[0][1]
        for i in range(ppp-k):
            if i == 0:
                co += ll[i*2+1+2*k][1] + ll[i*2+2*k][1]
                lll.append(co)
            else:
                co += ll[i*2+1+2*k][1] + ll[i*2+2*k][1] - (ll[i*2-1][1] + ll[i*2][1])
                lll.append(co)
else:
    if ll[-1][0] == 1:
        for i in range(2*k+1):
            co += ll[i][1]
        lll.append(co)
        co -= ll[0][1] + ll[1][1]
        for i in range(ppp-k):
            if i == 0:
                co += ll[i*2+1+2*k][1] + ll[i*2+2+2*k][1]
                lll.append(co)
            else:
                co += ll[i*2+1+2*k][1] + ll[i*2+2+2*k][1] - (ll[i*2][1] + ll[i*2+1][1])
                lll.append(co)
    else:
        for i in range(2*k+1):
            co += ll[i][1]
        lll.append(co)
        co -= ll[0][1] + ll[1][1]
        for i in range(ppp-k):
            if ppp-k-1 == i and i == 0:
                co += ll[-1][1]
                lll.append(co)
            elif ppp-k-1 == i:
                co += ll[-1][1] - (ll[i*2][1] + ll[i*2+1][1])
                lll.append(co)
            elif i == 0:
                co += ll[i*2+1+2*k][1] + ll[i*2+2+2*k][1]
                lll.append(co)
            else:
                co += ll[i*2+1+2*k][1] + ll[i*2+2+2*k][1] - (ll[i*2][1] + ll[i*2+1][1])
                lll.append(co)
print(max(lll))



Measured memory_bytes: 56796
N, M, X, Y = map(int,input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

for z in range(-100,100+1):
    if X < z <=Y:
        if max(x) < z:
            if min(y) >= z:
                print('No War')
                break
else:
    print('War')

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

inline int gi()
{
    char c = getchar();
    while(c < '0' || c > '9') c = getchar();
    int sum = 0;
    while('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
    return sum;
}

typedef long long ll;
const int maxn = 55, maxm = 105, mod = 1e9 + 7;

int n, m, col, fac[maxm << 1], ifac[maxm << 1];

struct edge
{
    int to, next;
} e[maxm * 2];
int h[maxn], tot;

inline void add(int u, int v)
{
    e[++tot] = (edge) {v, h[u]}, h[u] = tot;
    e[++tot] = (edge) {u, h[v]}; h[v] = tot;
}

int dfn[maxn], low[maxn], Time, top, bccno[maxn], cnt, siz_p[maxn], siz_e[maxn];
pair<int, int> stk[maxm];
vector<int> vec[maxn];

void dfs(int u, int fa)
{
    dfn[u] = low[u] = ++Time;
    for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
        if (v != fa) {
            if (!dfn[v]) {
                stk[++top] = make_pair(u, v);
                dfs(v, u);
                low[u] = min(low[u], low[v]);
                if (dfn[u] <= low[v]) {
                    ++cnt;
                    while (1) {
                        int x = stk[top].first, y = stk[top].second;
                        ++siz_e[cnt];
                        if (bccno[x] != cnt) bccno[x] = cnt, ++siz_p[cnt], vec[cnt].push_back(x);
                        if (bccno[y] != cnt) bccno[y] = cnt, ++siz_p[cnt], vec[cnt].push_back(y);
                        --top;
                        if (x == u && y == v) break;
                    }
                }
            } else if (dfn[v] < dfn[u]) stk[++top] = make_pair(u, v), low[u] = min(low[u], dfn[v]);
        }
}

inline int fpow(int x, int k)
{
    int res = 1;
    while (k) {
        if (k & 1) res = (ll)res * x % mod;
        x = (ll)x * x % mod; k >>= 1;
    }
    return res;
}

inline int C(int n, int m)
{
    return (ll)fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}

int main()
{
    n = gi(); m = gi(); col = gi();

    for (int i = 1; i <= m; ++i) add(gi(), gi());

    for (int i = 1; i <= n; ++i)
        if (!dfn[i]) dfs(i, 0);

    fac[0] = ifac[0] = ifac[1] = 1;
    for (int i = 1; i <= m + col; ++i) fac[i] = (ll)fac[i - 1] * i % mod;
    for (int i = 2; i <= m + col; ++i) ifac[i] = (ll)(mod - mod / i) * ifac[mod % i] % mod;
    for (int i = 2; i <= m + col; ++i) ifac[i] = (ll)ifac[i - 1] * ifac[i] % mod;

    int ans1 = 1, ans2 = 1, ans3 = 1;
    for (int i = 1; i <= cnt; ++i)
        if (siz_e[i] == 1) ans1 = (ll)ans1 * col % mod;
        else if (siz_e[i] == siz_p[i]) {
            int sum = 0;
            for (int j = 1; j <= siz_e[i]; ++j) {
                sum += fpow(col, __gcd(j, siz_p[i]));
                if (sum >= mod) sum -= mod;
            }
            ans2 = (ll)ans2 * sum % mod * fpow(siz_e[i], mod - 2) % mod;
        } else ans3 = (ll)ans3 * C(siz_e[i] + col - 1, col - 1) % mod;

    printf("%lld\n", (ll)ans1 * ans2 % mod * ans3 % mod);

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main(void){
  char x[200];
  int h,i,j,m,n;
  char t;
 scanf("%s",x);
  n=strlen(x);
  while (x[0]!='-'){
    scanf("%d",&m);
    for (i=0;i<m;i++){
      scanf("%d",&h);
   while(h-->0){
     t=x[0];
     for (j=1;j<n;j++){
     x[j-1]=x[j];
      }
        x[n-1]=t;
    }
  }
    for (i=0;i<n;i++)
      printf("%c",x[i]);
    printf("\n");
    scanf("%s",x);
    n=strlen(x);
  }
return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
using pii = pair<int, int>;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
int main()
{
	/*
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
	//*/

	ll N, i, j, k, d;
	ll a[6];
	ll m[32];
	ll M[32];
	for (i = 0; i < 32; i++)
	{
		m[i] = 9000000000;
		M[i] = -9000000000;
	}
	// scanf("%d %d", &N, &d);
	cin >> N;
	d = 2;
	//fix();
	for (i = 0; i < N; i++)
	{
		for (j = 0; j < d; j++)
			cin >> a[j];
		for (j = 0; j < 1 << (d - 1); j++)
		{
			ll x = a[0];
			for (k = 0; k < d - 1; k++)
				if (j & (1 << k))
					x += a[k + 1];
				else
					x -= a[k + 1];
			if (m[j] > x)
				m[j] = x;
			if (M[j] < x)
				M[j] = x;
		}
	}
	ll ans = 0;
	for (i = 0; i < 1 << (d - 1); i++)
		if (ans < M[i] - m[i])
			ans = M[i] - m[i];
	cout << ans << "\n";
	//printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
string str[101];
int n,idx=0;

int cal(char ch,int a,int b){
  if(ch=='*') return a*b;
  return a+b;
}

int get_cnt(string a){
  int res=0;
  while(a[res]=='.')res++;
  return res;
}

int dfs(){
  int cnt=get_cnt(str[idx]);
  char ch=str[idx][cnt];
  if(isdigit(ch))return str[idx++][cnt]-'0';
  int res =(ch=='*');
  idx++,cnt++;
  while(idx<n)
    if(get_cnt(str[idx])>=cnt)res=cal(ch,res,dfs());
    else break;
  return res;
}

int main(){
  while(cin>>n,n){
    for(int i=0;i<n;i++) cin>>str[i];
    idx=0;
    cout <<dfs()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n,k;
    cin >> n >> k;
    vi v(n);
    rep(i,n)cin >> v[i];
    int ans = 0;
    rep(x,n+1)rep(y,n+1)if(x+y <= n && x + y <= k){
        int z = k - x - y;
        vi t;
        rep(i,x)t.push_back(v[i]);
        rep(i,y)t.push_back(v[n-1-i]);
        sort(all(t));
        reverse(all(t));
        int tmp = 0;
        while(z && t.size()){
            if(t.back() < 0)z--,t.pop_back();
            else break;
        }
        rep(i,t.size())tmp += t[i];
        //cout << x << " " << y << " " << z << " " << tmp << endl;
        //rep(i,t.size())cout << " " << t[i];cout << endl;
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second

using ll = long long ;
using namespace std;
using pii = pair<int,int>;
char s[10];
int main(){
	scanf("%s", s);
	printf("%c%c%c",s[0], (s[1] == 'B' ? 'R' : 'B'), s[2]);


}

Measured memory_bytes: 3752
n,k = map(int, input().split())
P = list(map(int, input().split()))
P = [(1+p)/2 for p in P]

#期待値の累積和
S = [0]*(n+1)
for i in range(1, n+1):
    S[i] = S[i-1]+P[i-1]

ans = max([S[x]-S[x-k] for x in range(k,n+1)])
print(ans)

Measured memory_bytes: 25060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    string s,t;
    cin>>s;
    int ans=100;
    int Z=1;
    rep(i,s.size()) if(s[i]!=s[0]) Z=0;
    if(Z){
        cout<<0;
        return 0;
    }
    rep(i,s.size()){
        t=s;
        char a=s[i];
        int z=0,c=0;
        while(z==0){
            rep(i,t.size()) if(t[i+1]==a) t[i]=a;
            t.erase(t.size()-1);
            int x=1;
            rep(i,t.size()) if(t[i]!=a) x=0;
            if(x) z=1;
            c++;
        }
        ans=min(ans,c);
    }
    cout<<ans;
}

Measured memory_bytes: 256
from math import factorial

N = int(input())
N = factorial(N)

i = 2
num = 1
ans = 1

while N != 1:
    if N % i == 0:
        N //= i
        num += 1
    else:
        ans *= num
        num = 1
        i += 1
ans *= num
ans %= (10**9) + 7

print(ans)

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

int main() {
  long double a,b,x;
  cin >> a >> b >> x;

  long double p; 

  if (x==a*a*b){
    cout << 0.0 << endl;
    return 0;
  }

  if (x>=a*a*b/2){
    p = (a*a*b - x)*2.0/a/a;
    cout << setprecision(12) << atan2l(p,a)*180.0/M_PI << endl;
  }
  else{
    p = 2.0*x/a/b;
    cout << setprecision(12) << 90.0-atan2l(p,b)*180.0/M_PI << endl;
  }



  return 0;
}


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

using namespace std;
const int MOD = 1000000007,MAX = 510000;
long int pow107 = (int)pow(10, 9) + 7,llimit = LONG_MAX,fac[MAX], finv[MAX], inv[MAX];
int ilimit = INT_MAX;

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long int COM(long int n,long int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool comp(pair<int, int> a, pair<int, int> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

long int Func2(long int n,long int m){
    long int s2 = 1,
        r = 1;
    for(long int i = 1; i <= m; ++i){
        s2 = (s2*(n - (i - 1))/i) % (pow107);
    }
    return s2;
}

bool secsort(pair<int, int> a, pair<int, int> b){
    if(a.second == b.second)return a.first > b.first;
    else return a.second > b.second;
}

long int GCD(long int a,long int b){
    if(b == 0)return a;
    return GCD(b,a%b);
}

long int LCM(long int a,long int b){
    return a/GCD(a,b)*b;
}

//long intの最大llimit
//intの最大ilimit
//10^9+7    pow107
//素数pn
//n乗jou
//階乗factorial
//コンビネーションFunc2
//コンビネーションCOMinit(),COM(n,m)

int main(){
    COMinit();
    int n;
    cin >> n;
    int x[1000000] = {};
    for(int i = 0; i < n; ++i){
        cin >> x[i];
    }
    sort(x,x+n);
    /*for(int i = 0; i < n ; ++i){
        cout << x[i] << endl;
    }*/
    int a;
    for(int i = 1; i < n; ++i){
        if(abs(x[i] - x[n - 1]/2.0) > abs(x[i - 1] - x[n - 1]/2.0)){
            a = i - 1;
            break;
        }
    }
    cout << x[n - 1] << " " << x[a] << endl;
}

Measured memory_bytes: 16128
A, B = map(int, input().split(" "))

def xor_sum(N):
    mod4 = N % 4
    if mod4 == 0:
        return N
    elif mod4 == 1:
        return 1
    elif mod4 == 2:
        return N + 1
    else: 
        return 0

print(xor_sum(A-1) ^ xor_sum(B))

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
const int N=200005;
char a[N],b[N];
int main (){
    scanf ("%s",b+1);
    int n=strlen(b+1),m=0,ans=n;
    for (int i=1;i<=n;i++){
        if (a[m]=='S'&&b[i]=='T') ans-=2,--m;
        else a[++m]=b[i];
    }
    printf ("%d",ans);
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  int ans=0;
  for(int i=0;i<N;i++){
    if(i%2==0)ans+=A[i];
    else ans-=A[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

#define ll long long

int main()
{
	int n, k;
	cin >> n >> k;

	ll ans = 0;
	ll t = 1ll * n / k;

	ans = t * t * t;
	t = 0;
	if (k % 2 == 0)
	{
		for (int i = k / 2; i <= n; i += k)
		{
			t++;
		}
	}

	cout << ans + t * t * t << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
using namespace std;
typedef map<string, int> m;

m price;
map<string,vector<string> > renkin;
string p[100];

int main() {
  int n;
  int m;
  while(cin >> n) {
    if(n==0) break;
    for(int i=0;i<n;i++) {
      string name;
      int p;
      cin >> name >> p;
      price.insert( pair<string,int>(name,p) );
    }

    cin >> m;
    for(int i=0;i<m;i++) {
      int sozai;
      cin >> p[i] >> sozai;
      for(int k=0;k<sozai;k++) {
        string name;
        cin >> name;
        renkin[p[i]].push_back(name);
      }
    }

    bool update = true;
    while(update) {
      update = false;
      for(int i=0;i<m;i++) {
        int sum = 0;
        for(int j=0;j<renkin[p[i]].size();j++) {
          sum += price[renkin[p[i]][j]];
        }
        if(sum < price[p[i]]) {
          price[p[i]] = sum;
          update = true;
        }
      }
    }
    string str;
    cin >> str;
    cout << price[str] << endl;
    price.clear();
    renkin.clear();
  }
}

Measured memory_bytes: 0
#define k 1024
#define r(a) for(i=0;i<a;i++)
#define s(a) scanf("%d",a);
#define m(a,b) a=a<b?a:b
i,w,n,m,c[k],d[k],p[k];main(){s(&n)s(&m)r(n)s(d+i)r(m)s(c+i)r(n)p[i]=1e9;r(m*n)w=i%n,m(p[w],p[w+1]+c[i/n]*d[n-w-1]);printf("%d\n",p[0]),exit(0);}

Measured memory_bytes: 608
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  int cnt = 0,ind = 1;
  for(int i=0;i<n;i++){
    if(v[i]==ind){
      ind++;
    }else{
      cnt++;
    }
  }
  if(ind==1) cout << -1 << endl;
  else cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <sstream>
#include <vector>

using namespace std;

int main() {
    int n, tmp;
    long long ans;
    vector<int> a;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> tmp;
        a.push_back(tmp - 1);
    }
    for (int i = 0; i < n; ++i)
    {
        if (a[a[i]] == i)
        {
            ans++;
        }
    }

    cout << ans / 2 << "\n";

    return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define INF 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

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

	ll N;
	cin >> N;

	vector<ll> t(5);		
	ll mint = INF;
	rep(i,5){
		cin >> t[i];
		mint = min(mint,t[i]);
	}
	
	ll ans = 4 + (ll)ceil((double)N / mint);

	cout << ans << endl;

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int tmp = x2 - x1;
    int tmp2 = y2 - y1;
    
    int x3 = x2 - tmp2, y3 = y2 + tmp;
    int x4 = x1 - tmp2, y4 = y1 + tmp;

    cout << x3 << " " <<  y3 << " " <<  x4 << " " <<  y4 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#include <cmath>

using namespace std;

int const N = 10001;
int n,d[N],c[N],v[N],e[N],res[N],a,b,i,j,ans,s;
bool vi[N],vsi[N];
vector<vector<int> > edg(int(1e5)+5);
vector<pair<int,int> > pv;
set<pair<int,int> > st;
pair<int,int> p;

void solve(int r,int s){
    vsi[r] =  true;
    s++;
    for(int i=0;i<edg[r].size();i++){
        int t = edg[r][i];
        if(!vsi[t]){
            ans += min(res[r],res[t]);
            solve(t,s);
        }
    }
    return;
}

int main(){
    cin>>n;
   
    for(int i=1;i<n;i++){
        cin>>a>>b;
        c[a]++;
        c[b]++;
        edg[a].push_back(b);
        edg[b].push_back(a);
    }
    //for(i=1;i<=n;i++) pv.push_back({c[i],i});
    //sort(pv.begin(),pv.end());
    for(int i=0;i<n;i++) cin>>d[i];
    sort(d,d+n);
    
   
           
    for(i=1;i<=n;i++) st.insert({c[i],i});
    while(!st.empty() && s<n ){
    	p = *st.begin();
    	int r = p.second;
    	st.erase(*st.begin());
    	if(!vi[r]) { res[r] = d[s]; s++; }
    	for(int i=0;i<edg[r].size();i++){
    		int t = edg[r][i];
    		if(!vi[t]){
    			if(c[t]>1) { c[t]--; st.insert({c[t],t}); }
    		}
    	}
    }
    
    solve(1,0);
    
    cout<<ans<<endl;
    for(int i=1;i<=n;i++) cout<<res[i]<<" ";
    
    return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

//????????°???n
//SCC sc(n);
//sc.comp()??§?????£?????????????§£
//sc.make_graph()??§?????£?????????????§£????????°??????????§????

#define rep(i,n) for(int i=0;i<(int)(n);++i)

class SCC {
public:
	vector<vector<int> > G,rG;
	vector<int> post_order; //??°?????????????????????
	vector<bool> used; //?????§????????????????????????
	vector<int> cmp;	//?±????????????£????????????????????????????????????
	vector<vector<int> > graph;	//?????£?????????????§£????????°??????
	int V,VV;	//?????£?????????????§£?????????????????°
	SCC(int node_size){
		V = node_size;
		G.resize(node_size),rG.resize(node_size),used.resize(node_size,false);
		cmp.resize(node_size);
	}
	void add_edge(int from,int to){
		G[from].push_back(to), rG[to].push_back(from);
	}
	void dfs(int v){
		used[v] = true;
		for(int i=0;i<(int)G[v].size();i++){
			if(!used[G[v][i]]){
				dfs(G[v][i]);
			}
		}
		post_order.push_back(v);
	}
	void rdfs(int v,int k){
		used[v] = true;
		cmp[v] = k;
		for(int i=0;i<(int)rG[v].size();i++){
			if(!used[rG[v][i]]){
				rdfs(rG[v][i],k);
			}
		}
	}
	void solve(){
		fill(used.begin(),used.end(),0);
		post_order.clear();
		for(int v=0;v<V;v++){
			if(!used[v]){
				dfs(v);
			}
		}
		fill(used.begin(),used.end(),0);
		int k=0;
		for(int i=(int)post_order.size()-1;i>=0;i--){
			if(!used[post_order[i]]){
				rdfs(post_order[i],k++);
			}
		}
		VV = k;
	}
	void make_graph(){
		graph.resize(VV);
		rep(i,V){
			rep(j,G[i].size()){
				if(cmp[i] != cmp[G[i][j]]){
					graph[i].push_back(G[i][j]);
				}
			}
		}
	}
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    SCC scc(n);
    rep(i,m){
        int s,t;
        cin >> s >> t;
        scc.add_edge(s,t);
    }
    int q;
    cin >> q;
    scc.solve();
    rep(i,q){
        int u,v;
        cin >> u >> v;
        if(scc.cmp[u] == scc.cmp[v]){
            cout << "1\n";
        }else{
            cout << "0\n";
        }
    }
    return 0;
}

Measured memory_bytes: 4440
using System;

public class AOJ1
{
    static void Main()
    {
        long n = long.Parse(Console.ReadLine());
        for (long cnt = 1; cnt <= n; cnt++)
        {
            Console.WriteLine("Case {0}:",cnt);
            long x = long.Parse(Console.ReadLine());
            for (int j = 0; j < 10; j++)
            {
                x *= x;
                string str = "";
                string tmp = x.ToString();
                if (tmp.Length < 8) for (int i = 0; i < 8 - tmp.Length; i++) str += "0";
                str += tmp;
                str = str.Substring(2, 4);
                x = long.Parse(str);
                Console.WriteLine(x);
            }
        }
    }
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long int ll;
typedef pair<int, int> P;
#define INF 1e9 + 7

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

    ll N, T;
    cin >> N >> T;
    ll t[N];
    rep(i,N) cin >> t[i];
    
    ll diff[N - 1];
    rep(i, N-1){
        diff[i] = t[i+1] - t[i];
    }
    
    ll ans = 0;
    ll now = 0;
    
    for(int i=0; i<N-1; i++){
        if(diff[i] <= T){
            now += diff[i];
        }
        else{
            ans += T + now;
            now = 0;
        }
    }
    
    ans += T + now;
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3328
import sys
readline = sys.stdin.readline

P = 10 ** 9 + 7
def mod_prod(a,b):
    return (a % P) * (b % P) % P

def mod_fact(a):
    ret = 1
    for i in range(a):
        ret = ret * (i + 1) % P
    return ret

def mod_pow(a, n):
    ret = 1
    while n > 0:
        if n % 2 == 1:
            ret = ret * a % P
        a = a * a % P
        n = n >> 1
    return ret

def mod_div(a, b):
    b_inv = mod_pow(b, P - 2)
    return a * b_inv % P

def mod_comb(a,b):
    ret = 1
    b = min(b, a - b)
    for i in range(b):
        ret *= a - i
        ret %= P
    ret = mod_div(ret, mod_fact(b))
    return ret

def solve():
    K = int(readline())
    S = readline().rstrip()

    N = len(S)

    ans = 0
    cb = 1
    for i in range(K + 1):
        ans += mod_pow(25, i) * cb * mod_pow(26, K-i)
        cb = cb * mod_div(i + N - 1 + 1, i + 1) % P
        # mod_comb(i+N-1, i)
        ans %= P
    print(ans)

solve()

Measured memory_bytes: 70748
#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()
#define INF 1e9
typedef long long ll;

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

int n;
double a[110];
void solve(){
  double sum = 0.0;
  rep(i, n){
    sum += 1/a[i];
  }
  cout << 1/sum << endl;
}

int main(){
  cin >> n;
  rep(i, n){
    cin >> a[i];
  }
  solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int fx4[] = {1 , -1 , 0 , 0};
int fy4[] = {0 , 0 , 1 , -1};
int Kfx[]= {-2,-2,2,2,1,1,-1,-1}; ///knight move x - exis
int Kfy[]= {1,-1,1,-1,2,-2,2,-2}; ///knight move y- exis
int fx8[]= {1,1,1,0,0,-1,-1,-1};
int fy8[]= {0,1,-1,1,-1,0,1,-1};
#define ll long long int
#define pii pair<int,int>
#define llu unsigned long long
#define inf 1<<28
#define gama 0.57721566490
#define PI              acos(-1.0)
#define INF             0x7fffffff
#define MOD             1000000007
#define EPS             1e-7
#define all(r)(r).begin(),(r).end()
/*
bool status[mx];
void sieve(){
   long long int  i,j;
    for(i=2;i<=mx;i++)
    {
        status[i]=0;
    }
    for( i=2;i<=sqrt(mx);i++){
        if(status[i]==0)
        {
            for(j=i*i;j<=mx;j+=i){
                status[j]=1;
            }
        }
    }
}*/
ll BM( ll a , ll b , ll m )
{
    if ( b == 0 ) return 1 ;
    ll x = BM(a,b/2,m);
    x = (( x % m) * (x % m))%m;

    if( b % 2 ) x = (( x % m) * (a %m)) % m ;
    return x ;
}
#define dd double
#define sc scanf
#define pr printf
#define VI vector<int>
#define VS vector<string>
#define VC vector<char>
#define VLL vector<long long int>
#define FILE freopen("input.txt","rt",stdin); freopen("output.txt","w",stdout);
#define p_b push_back
#define mem(x,y) memset(x,y,sizeof(x))
#define F(i,a,b) for(i=a;i<=b;i++)
#define sc1(a) scanf("%d",&a)
#define scL1(a) scanf("%lld",&a)
#define scL2(a,b) scanf("%lld%lld",&a,&b)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define fori(N)          for(int i = 0; i<(N); i++)
#define forj(N)         for(int j = 0; j<(N); j++)
#define fork(N)         for(int k = 0; k<(N); k++)
#define forl(N)         for(int l = 0; l<(N); l++)
#define ford(N)         for(int d = 0; d<(N); d++)
#define fori1(N)          for(int i = 1; i<=(N); i++)
#define forj1(N)         for(int j = 1; j<=(N); j++)
#define fork1(N)         for(int k = 1; k<=(N); k++)
#define ford1(N)         for(int d = 1; d<=(N); d++)
#define sqr(x)           (x)*(x)
#define TEST int test,te=0;cin>>test;
#define segment_tree int l=(n*2),r=(n*2)+1,mid=(l+r)/2
#define Mx 100005
#define mx 10005

int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);///Beware of use it, if u use it dont use scanf or printf
    int L;
    cin>>L;
    printf("%.12lf\n",(dd)L*L*L/27);
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Set<Integer> set = new HashSet<Integer>();
		int N = sc.nextInt();
		for(int i = 0; i < N; i++) {
			int A = sc.nextInt();
			if(set.contains(A)) {
				set.remove(A);
			}else {
				set.add(A);
			}
		}
		sc.close();
		System.out.println(set.size());
	}
}

Measured memory_bytes: 63816
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

struct UnionFind {
    std::vector<int> par, sz;
    int gnum;

    explicit UnionFind(int n)
        : par(n), sz(n, 1), gnum(n) {
        std::iota(par.begin(), par.end(), 0);
    }

    int find(int v) {
        return (par[v] == v) ? v : (par[v] = find(par[v]));
    }

    void unite(int u, int v) {
        u = find(u), v = find(v);
        if (u == v) return;

        if (sz[u] < sz[v]) std::swap(u, v);
        sz[u] += sz[v];
        par[v] = u;
        --gnum;
    }

    bool same(int u, int v) { return find(u) == find(v); }
    bool ispar(int v) { return v == find(v); }
    int size(int v) { return sz[find(v)]; }
};

void solve() {
    int n, m;
    std::cin >> n >> m;

    std::vector<int> xs(n);
    for (auto& x : xs) std::cin >> x;

    std::vector<bool> ok(n, true);
    while (m--) {
        int u, v;
        std::cin >> u >> v;
        --u, --v;
        for (int q = 0; q < 2; ++q) {
            if (xs[u] <= xs[v]) ok[u] = false;
            std::swap(u, v);
        }
    }

    std::cout << std::accumulate(ok.begin(), ok.end(), 0) << std::endl;
}

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

    solve();

    return 0;
}


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

using namespace std;

const int maxn=1e4+5;
const int inf=(1<<20);
const int white=0;
const int gray=1;
const int black=2;

int n;
vector<pair<int,int> >adj[maxn];

void dijkstra()
{
    priority_queue<pair<int,int> >q;
    int book[maxn],d[maxn];
    for(int i=0;i<n;i++){
        d[i]=inf;
        book[i]=0;
    }
    d[0]=0;
    q.push(make_pair(0,0));
    while(!q.empty()){
        pair<int,int>f=q.top();
        q.pop();
        int u=f.second;
        book[u]=1;
        if(d[u]<f.first*(-1)){
            continue;
        }
        for(int j=0;j<adj[u].size();j++){
            int v=adj[u][j].first;
            if(book[v]==1){
                continue;
            }
            if(d[v]>d[u]+adj[u][j].second){
                d[v]=d[u]+adj[u][j].second;
                q.push(make_pair(d[v]*(-1),v));
            }
        }
    }
    for(int i=0;i<n;i++){
        cout<<i<<" "<<(d[i]==inf?-1:d[i])<<endl;
    }
}

int main()
{
    scanf("%d",&n);
    int u,k,v,c;
    for(int i=0;i<n;i++){
        cin>>u>>k;
        for(int i=0;i<k;i++){
            cin>>v>>c;
            adj[u].push_back(make_pair(v,c));
        }
    }
    dijkstra();
    return 0;
}



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

int main(){
  int64_t N;
  cin >> N;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin >> L.at(i);
  }
  sort(L.begin(),L.end());
  reverse(L.begin(),L.end());
  int a,b,c;
  int64_t ans=0;
  for(int i=0;i<N;i++){
    a=L.at(i);
    for(int j=i+1;j<N;j++){
      b=L.at(j);
      for(int k=j+1;k<N;k++){
        c=L.at(k);
        if(a>=b+c){
          break;
        }
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define fr(i,s,e) for(i=s;i<e;i++)

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if((abs(b-a)<=d&&abs(c-b)<=d)||(abs(c-a)<=d))
        cout<<"Yes";
    else
        cout<<"No";

return 0;
}



Measured memory_bytes: 256
import sys
import bisect as bi
import math
from collections import defaultdict as dd
import heapq
import itertools
input=sys.stdin.readline
##import numpy as np
#sys.setrecursionlimit(10**7)
mo=10**9+7
def cin():
    return map(int,sin().split())
def ain():            
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input())
##def power(x, y):
##    if(y == 0):return 1
##    temp = power(x, int(y / 2))%mo
##    if (y % 2 == 0):return (temp * temp)%mo 
##    else:
##        if(y > 0):return (x * temp * temp)%mo 
##        else:return ((temp * temp)//x )%mo
##
for _ in range(1):
    s=sin().strip();k=0
    for i in s:
        k=(k+int(i))%9
    if(k==0):print("Yes")
    else:print("No")

Measured memory_bytes: 9660
let s = stdin.ReadLine() |> Seq.toList
let t = stdin.ReadLine() |> Seq.toList

let rec rotate k xs =
    match (k, xs) with
        |_, [] -> []
        |0, xs -> xs
        |k, x::xs -> rotate (k-1) (xs @ [x])

seq { 1..(List.length s) }
|> Seq.tryFind (fun i -> t = (rotate i s))
|> function | Some _ -> "Yes" | None -> "No"
|> printfn "%s"

Measured memory_bytes: 16984
#include<stdio.h>
int num(int a)
{
	int sum=0;
	while(a>0)
	{	
		sum+=(a%10);
		a/=10;
	}
	return sum;
}
int main()
{
	int n,t;
	scanf("%d",&n);
	t=num(n);
	if(n%t==0)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

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

#define SIZE 200000

using namespace std;

int main() {
    long long int A,B,i,j,k,N,M,K,Q,X;
  //  long long int A[100][100];

 cin >> A >> B;

 cout << A*B << endl;

  return 0;

}


Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int n;
    vector<int> p, q, dy;
    cin >> n;
    for(int i=0;i<n;i++){
        int tmpp;
        cin >> tmpp;
        p.push_back(tmpp);
    }
    for(int i=0;i<n;i++){
        int tmpq;
        cin >> tmpq;
        q.push_back(tmpq);
    }
    for(int i=1;i<=n;i++){
        dy.push_back(i);
    }
    int cnt=0, a=0, b=0;
    while(next_permutation(dy.begin(), dy.end())){
        cnt++;
        if(dy == p)a = cnt;
        if(dy == q)b = cnt;
    }
    cout << abs(a-b) << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# input
h, w = map(int, input().split())

# 縦か横がどちらかの値が1の場合、角はどこにも行けないので常に１
if h == 1 or w == 1:
    print(1)
    exit()

# 総マス数が偶数になる場合、半数が答え
total = h * w
if total % 2 == 0:
    print(int(total / 2))
    exit()

# 問題は奇数の場合
# 高さが奇数の場合、奇数列はh//2+1 偶数列はh//2
if h % 2 != 0:
    odd_column = (h//2 + 1) * (w//2 + 1)
    even_column = (h//2) * (w//2)
    res = odd_column + even_column

print(int(res))



Measured memory_bytes: 38384
<?php


class Math
{

    private int $mod;

    function __construct(int $mod = 1000000007)
    {
        $this->mod = $mod;
    }

    public function pow_mod(int $x, int $n): int
    {
        return (int)gmp_powm($x, $n, $this->mod);
    }

    public function inv_mod(int $x):int
    {
        return (int)gmp_invert($x, $this->mod);
    }

    /**
     * 同じ長さの配列 r, mを渡します。この配列の長さを n とした時、
     * x≡r[i](modm[i]),∀i∈{0,1,⋯,n−1}
     * を解きます。答えは(存在するならば) y, z ( 0 ≤ y < z = lcm(m[i])) を用いて
     * x ≡ y ( mod z )  の形で書けることが知られており、この (y, z) をpairとして返します。
     * 答えがない場合は (0, 0) を返します。n=0 の時は (0, 1) を返します。
     * 計算量
     * O(nlog lcm(m[i]))
     * @param array $r |r| = |m|
     * @param array $m 1 ≤ m[i], lcm(m[i]) ≤ PHP_INT_MAX
     * @return array|int[]
     */
    public function crt(array $r, array $m):array
    {
        assert(count($r) === count($m));
        $n = count($r);
        $r0 = 0;
        $m0 = 1;
        for ($i=0;$i < $n;$i++){
            assert(1 <= $m[$i]);
            $r1 = (int)gmp_mod($r[$i], $this->mod);
            $m1 = $m[$i];
            if($m0 < $m1){
                [$r0, $r1] = [$r1, $r0];
                [$m0, $m1] = [$m1, $m0];
            }
            if($m0 % $m1 === 0){
                if($r0 % $m1 != $r1){
                    return [0,0];

                }
            }

            [$g, $im] = $this->inv_gcd($m0, $m1);
            $u1 = intdiv($m1, $g);
            if(($r1 - $r0) % $g){
                return [0, 0];
            }
            $x = intdiv(($r1 -$r0), $g) % $u1 * $im % $u1;
            $r0 += $x * $m0;
            $m0 *= $u1;
            if($r0 < 0){
                $r0 += $m0;
            }

        }
        return [$r0, $m0];
    }

    public function floor_sum(int $n, int $m, int $a, int $b):int
    {
        $ans = 0;
        if($a >= $m){
            $ans += intdiv(($n - 1) * $n * intdiv($a, $m), 2);
            $a %= $m;
        }
        if($b >= $m){
            $ans += $n * intdiv($b, $m);
            $b %= $m;
        }
        $y_max = intdiv($a * $n + $b, $m);
        $x_max = $y_max * $m - $b;
        if($y_max === 0){
            return $ans;
        }
        $ans += ($n - intdiv($x_max + $a - 1, $a)) * $y_max;
        $ans += $this->floor_sum($y_max, $a, $m, ($a - $x_max % $a) %$a);
        return $ans;
    }

    private function inv_gcd(int $a, int $b):array
    {
        $a = (int)gmp_mod($a, $b);
        if($a === 0){
            return [$b, 0];
        }
        $s = $b;
        $t = $a;
        $m0 = 0;
        $m1 = 1;
        while($t){
            $u = intdiv($s, $t);
            $s -= $t * $u;
            $m0 -= $m1 * $u;
            [$s, $t] = [$t, $s];
            [$m0, $m1] = [$m1, $m0];

        }
        if($m0 < 0 ){
            $m0 += intdiv($b, $s);
        }
        return [$s, $m0];
    }

}

//
////exit;
$a = new Math();
[$T] = fscanf(STDIN, "%d");
while($T--){
    [$N, $M, $A, $B] = fscanf(STDIN, "%d%d%d%d");
    echo $a->floor_sum($N, $M, $A, $B).PHP_EOL;
}


Measured memory_bytes: 16268
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s;

  cin >> s;

  int r, t;
  r = t = 0;
  for (char c : s) {
    if (c == 'A' || c == 'C' || c == 'G' || c == 'T') t++;
    else t = 0;
    r = max(r, t);
  }

  cout << r << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <bitset>

using namespace std;

struct node {
	string mes;
	int depth;
};

node deldots( node n ) {
	node ret;
	int cnt = 0;
	for(int i = 0; i < n.mes.length(); i++) {
		if( n.mes[i] == '.' ) {
			ret.mes += " ";
			cnt ++;
		}
		else ret.mes += n.mes[i];
	}
	if( cnt > 0 )
		ret.mes[cnt-1] = '+';
	ret.depth = cnt - 1;
	return ret;
}

int main(void){

	//FILE* fp_in = freopen("data.txt", "r", stdin);

	while( 1 ) {
		int n;
		vector< node > v;
		bitset< 1 << 20 > b;
		b.reset();

		cin >> n;
		if( n == 0 ) break;
		
		for(int i = 0; i < n; i++) {
			node str;
			cin >> str.mes;
			str = deldots( str );
			v.push_back( str );
		}

		for(int i = 0; i < n; i++) {
			if( v[i].depth >= 0 ) {
				b.reset( v[i].depth );
				for(int j = 0; j < v[i].mes.length(); j++) {
					if( b[j] )
						cout << "|";
					else
						cout << v[i].mes[j];
				}
				cout << endl;
				//兄弟ノードが存在するかどうか調べる
				for(int j = i + 1; j < n; j++) {
					if( v[i].depth > v[j].depth ) {
						break;
					} else if( v[i].depth == v[j].depth ) {
						b.set( v[i].depth );
					}
				}
			} else {
				cout << v[i].mes << endl;
			}
		}

		
	}
	//while(1){}

	return 0;
}

Measured memory_bytes: 1796
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
using ll = long long;
typedef vector<int> vi;



int main(){
    ll n;
    cin >> n;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];

    int ans = 0;
    int tmp = 0;
    for(int i = 0; i < n-1; i++){
        if(h[i] >= h[i+1]){
            tmp++;
            ans = max(ans, tmp);
        }else{
            tmp = 0;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4048
#AtCoder
from math import sqrt
N = int(input())
lst = [list(map(int, input().split())) for _ in range(N)]

res = 0
for i in range(N):
    for j in range(N):
        if i != j:
            res += sqrt((lst[i][0] - lst[j][0])**2 + (lst[i][1] - lst[j][1])**2) 
print(res/N)

Measured memory_bytes: 3060
import math

N, M, K = (int(x) for x in input().split())

def comb(n,k,p):
    if k < 0 or k > n:
        return 0
    if n == 0 or k == 0:
        return 1
    a=math.factorial(n) % p
    b=math.factorial(k) % p
    c=math.factorial(n-k) % p
    return (a*mypow(b,p-2,p)*mypow(c,p-2,p)) % p

def mypow(a,b,p):
    if b == 0: return 1
    if b % 2 == 0:
        d=mypow(a,b//2,p)
        return d*d % p
    if b % 2 == 1:
        return (a*mypow(a,b-1,p )) % p

c_sum = (M*(N-1)*N*(N+1)*M+N*(M-1)*M*(M+1)*N)//3
c_sum = c_sum//2
c_sum *= comb(N*M-2, K-2, 1000000007)
c_sum = c_sum % 1000000007

print(c_sum)


Measured memory_bytes: 5460
#include<stdio.h>
#define N 100

int main(){
  int n, r[N + 1], c[N +1][N + 1] = {0}, i, l, j, k;
  
  scanf("%d", &n);
  for(i = 1; i <= n; i++)
    scanf("%d%d", &r[i - 1], &r[i]);

  //  for(i = 1; i <= n; i++)
    //    printf("%d %d\n", i, r[i - 1], r[i]);
  
  for(l = 2; l <= n; l++){
    for(i = 1; i <= n - l + 1; i++){
      j = i + l - 1;      
      //      printf("%d\t", c[i][j]);
      c[i][j] = (1 << 21);
      //      printf("%d\n", c[i][j]);
      for(k = i; k <= j - 1; k++){
	if(c[i][j] > c[i][k] + c[k + 1][j] + r[i - 1] * r[k] * r[j]){
	  c[i][j] = c[i][k] + c[k + 1][j] + r[i - 1] * r[k] * r[j];
	}
      }
    }
  }
  
  printf("%d\n", c[1][n]);
  return 0;
}

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

/*
  // Overview
  グラフの単一始点全点間最短路を求める。
  負辺があっても動作。負閉路検出可能。

  // Time complexity
  O(ve) (v: 頂点の数, e: 辺の数)

  // Initialization
  BellmanFord bf = BellmanFord(v, s); (v: 頂点の数, s: start)
  bf.add_edge(u, v, c); (u: start, v: to, c: コスト) (無向グラフの場合は両辺に張る)
  bf.build();
*/
struct BellmanFord {
    struct edge{
        int start;
        int to;
        long long cost;
        edge(int start, int to, long long cost) : start(start), to(to), cost(cost) { }
    };
    typedef pair< long long, int > P;
    const long long INF = 1LL<<60;
    int v;
    int s;
    vector< edge > es;
    vector< long long > dist;
    vector< bool > negative;
    bool has_negative = false;
    BellmanFord(int v, int s) : v(v), s(s), dist(v, INF), negative(v, false) {
        dist[s] = 0;
    }
    void add_edge(int start, int to, long long cost) {
        es.emplace_back(start, to, cost);
    }
    void build() {
        for (int i = 0; i < v; ++i) {
            for (edge &e : es) {
                if (dist[e.start] != INF && dist[e.to] > dist[e.start] + e.cost) {
                    dist[e.to] = dist[e.start] + e.cost;
                    if (i == v - 1) {
                        negative[e.to] = true;
                        has_negative = true;
                    }
                }
            }
        }
    }
    long long shortest_path_value(int t) {
        return dist[t];
    }
    bool is_negative(int t) {
        return negative[t];
    }
};

/*
    verified https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/all/GRL_1_A
*/
int main() {
    int V, E, r; cin >> V >> E >> r;
    BellmanFord bf(V, r);
    for (int i = 0; i < E; ++i) {
        int s, t, d; cin >> s >> t >> d;
        bf.add_edge(s, t, d);
    }
    bf.build();
    if (bf.has_negative) {
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }
    for (int i = 0; i < V; ++i) {
        long long val = bf.shortest_path_value(i);
        if (val == bf.INF) cout << "INF" << endl;
        else cout << val << endl;
    }
}



Measured memory_bytes: 3136
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long ll;

class AACOrWA {
public:
	void solve(std::istream& cin, std::ostream& cout) {
		int a,b;cin >> a >> b;
		if(a == b){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
};


int main() {
	AACOrWA solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define pb push_back;
#define lli long long int
#define ld long double
#define endl "\n"
#define io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define test lli Test;cin>>Test;while(Test--)


int main(){
    io;
    //test
    {
        int n,m;
        cin>>n>>m;
        cout<<(n*(n-1)+m*(m-1))/2<<endl;
    }
    return 0;
}

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

int main(){

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

    if(a[4]-a[0]>k){
        cout << ":(" << endl;
        return 0;
    }

    cout << "Yay!" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=(b); i++)
#define per(i,a,b) for (int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;

const int maxn = 10005;
int a[maxn], b[maxn], n;
ll sum, need;

int main() {
	scanf("%d", &n);
	rep (i, 1, n) scanf("%d", &a[i]);
	rep (i, 1, n) scanf("%d", &b[i]);
	rep (i, 1, n) {
		need += b[i] - a[i];
		if (b[i] < a[i]) sum += a[i] - b[i];
		else sum += (b[i] - a[i]) & 1;
	}
	puts(sum <= need ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
int n,k,sg[100005],a[105],c[105];
int main(){
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=k;i++){
		memset(c,0,sizeof(c));
		for (int j=1;j<=n;j++){
			if (a[j]>i) continue;
			c[sg[i-a[j]]]++; 
		}
		for (int j=0;j<=n;j++) 
			if (!c[j]) {
				sg[i]=j;
				break;
			}
	}
	if (sg[k]) puts("First");
	else puts("Second");
}

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

long long binpow(long long a, long long b, long long k) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2, k);
    if (b % 2)
        return ((res%k) * (res%k) * (a%k))%k;
    else
        return ((res)%k * (res)%k)%k;
}

int main(){
    
    int k;
    cin >> k;
    
    long long result = 0;
    bool found = false;
    for(int j = 0; j < 1000000; j++){
        long long current_result = 7 * binpow(10, j, k);
        current_result = current_result;
        
        result += current_result;
        if(result%k == 0){
            cout << j + 1 << endl;
            found = true;
            break;
        }
    }
    
    if(!found)cout << -1 << endl;
    
}

Measured memory_bytes: 3632
package main
import "fmt"

func main() {
  var n, m int
  fmt.Scan(&n, &m)
  flag := make([]int, n)
  waFlag := make([]int, n)
  ac := 0
  wa := 0
  for i:=0; i<m; i++ {
    var p int
    var s string
    fmt.Scan(&p, &s)
    if s == "AC" && flag[p-1] == 0 {
      flag[p-1] = 1
      ac += 1
    } else if s == "WA" && flag[p-1] == 0 {
      waFlag[p-1] += 1
    }
  }
  for i:=0; i<n; i++ {
    if flag[i] == 1 {
      wa += waFlag[i]
    }
  }
  fmt.Printf("%d %d", ac, wa)
}

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

int main(){
    int n,cnt = 0;
    string s;
    cin >> n >> s;
    rep(i,n-2){
        string sub;
        sub = s.substr(i,3);
        if(sub == "ABC") cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256